index.js 1.58 KB
/**
 * `@drama/billing` 公共面(唯一对外入口,§3 契约)。
 *
 * 把「积分账册 + 付费墙」封装成注入式 package:扣费/入账(原子+幂等)、消费日志、
 * 产品目录、付费墙规则(数据驱动纯判定)、以及给 llm/tts 注入消费的 `BillingPort`。
 *
 * 对外只暴露 §3 契约声明的符号:`createBilling`(工厂)、`createBillingRepo`(仓库工厂,
 * db 注入)、`BillingError`(结构化错误)。
 *
 * 边界纪律(架构红线):包内不读 `process.env`、不建任何顶层连接;`db` 只经
 * `createBillingRepo(db)` 注入;不 import 任何其他领域包 / 能力包,与 llm/tts 协作
 * 只经 `asBillingPort` 注入。
 *
 * @typedef {import('./repo/index.js').BillingRepo} BillingRepo
 * @typedef {import('./port.js').BillingPort} BillingPort
 * @typedef {import('./quota.js').PaywallRules} PaywallRules
 */

export { createBilling } from './billing.js'
export { BillingAction, createActionPolicies } from './action-policies.js'
export { createLedger } from './ledger.js'
export { createProducts } from './products.js'
export { createDailyClaim } from './daily-claim.js'
export { calendarDayOf, midnightInTimezone, shiftCalendarDay } from './calendar-day.js'
export { createCommerceOperations } from './commerce-operations.js'
export { createBillingRepo } from './repo/index.js'
export { createModelSettlementPort } from './model-settlement-port.js'
export { BillingError } from './errors.js'
export { recreateBillingViews } from './views.js'
export { default as billingDbSchema } from './db/tables/index.cjs'