@zonastery/bursar 0.0.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (505) hide show
  1. package/README.md +118 -333
  2. package/dist/billing/auto-recharge-port.d.ts +27 -0
  3. package/dist/billing/auto-recharge-port.d.ts.map +1 -0
  4. package/dist/billing/auto-recharge-port.js +2 -0
  5. package/dist/billing/auto-recharge-port.js.map +1 -0
  6. package/dist/billing/auto-recharge-service.d.ts +43 -0
  7. package/dist/billing/auto-recharge-service.d.ts.map +1 -0
  8. package/dist/billing/auto-recharge-service.js +218 -0
  9. package/dist/billing/auto-recharge-service.js.map +1 -0
  10. package/dist/billing/billing-service.d.ts +71 -0
  11. package/dist/billing/billing-service.d.ts.map +1 -0
  12. package/dist/billing/billing-service.js +172 -0
  13. package/dist/billing/billing-service.js.map +1 -0
  14. package/dist/billing/billing-store.d.ts +45 -13
  15. package/dist/billing/billing-store.d.ts.map +1 -1
  16. package/dist/billing/billing-store.js.map +1 -1
  17. package/dist/billing/contracts.d.ts +149 -0
  18. package/dist/billing/contracts.d.ts.map +1 -0
  19. package/dist/billing/contracts.js +2 -0
  20. package/dist/billing/contracts.js.map +1 -0
  21. package/dist/billing/event-handlers.d.ts +57 -0
  22. package/dist/billing/event-handlers.d.ts.map +1 -0
  23. package/dist/billing/event-handlers.js +684 -0
  24. package/dist/billing/event-handlers.js.map +1 -0
  25. package/dist/billing/event-processor.d.ts +20 -0
  26. package/dist/billing/event-processor.d.ts.map +1 -0
  27. package/dist/billing/event-processor.js +131 -0
  28. package/dist/billing/event-processor.js.map +1 -0
  29. package/dist/billing/financial-event-handlers.d.ts +26 -0
  30. package/dist/billing/financial-event-handlers.d.ts.map +1 -0
  31. package/dist/billing/financial-event-handlers.js +241 -0
  32. package/dist/billing/financial-event-handlers.js.map +1 -0
  33. package/dist/billing/index.d.ts +9 -5
  34. package/dist/billing/index.d.ts.map +1 -1
  35. package/dist/billing/index.js +4 -4
  36. package/dist/billing/index.js.map +1 -1
  37. package/dist/billing/management.d.ts +59 -0
  38. package/dist/billing/management.d.ts.map +1 -0
  39. package/dist/billing/management.js +113 -0
  40. package/dist/billing/management.js.map +1 -0
  41. package/dist/billing/policy-window.d.ts +24 -0
  42. package/dist/billing/policy-window.d.ts.map +1 -0
  43. package/dist/billing/policy-window.js +88 -0
  44. package/dist/billing/policy-window.js.map +1 -0
  45. package/dist/billing/postgres/repositories/auto-recharge.d.ts +32 -0
  46. package/dist/billing/postgres/repositories/auto-recharge.d.ts.map +1 -0
  47. package/dist/billing/postgres/repositories/auto-recharge.js +180 -0
  48. package/dist/billing/postgres/repositories/auto-recharge.js.map +1 -0
  49. package/dist/billing/postgres/repositories/customer.d.ts +12 -0
  50. package/dist/billing/postgres/repositories/customer.d.ts.map +1 -0
  51. package/dist/billing/postgres/repositories/customer.js +33 -0
  52. package/dist/billing/postgres/repositories/customer.js.map +1 -0
  53. package/dist/billing/postgres/repositories/dispute.d.ts +7 -0
  54. package/dist/billing/postgres/repositories/dispute.d.ts.map +1 -0
  55. package/dist/billing/postgres/repositories/dispute.js +18 -0
  56. package/dist/billing/postgres/repositories/dispute.js.map +1 -0
  57. package/dist/billing/postgres/repositories/event.d.ts +21 -0
  58. package/dist/billing/postgres/repositories/event.d.ts.map +1 -0
  59. package/dist/billing/postgres/repositories/event.js +45 -0
  60. package/dist/billing/postgres/repositories/event.js.map +1 -0
  61. package/dist/billing/postgres/repositories/invoice.d.ts +9 -0
  62. package/dist/billing/postgres/repositories/invoice.d.ts.map +1 -0
  63. package/dist/billing/postgres/repositories/invoice.js +36 -0
  64. package/dist/billing/postgres/repositories/invoice.js.map +1 -0
  65. package/dist/billing/postgres/repositories/offer.d.ts +26 -0
  66. package/dist/billing/postgres/repositories/offer.d.ts.map +1 -0
  67. package/dist/billing/postgres/repositories/offer.js +73 -0
  68. package/dist/billing/postgres/repositories/offer.js.map +1 -0
  69. package/dist/billing/postgres/repositories/payment.d.ts +32 -0
  70. package/dist/billing/postgres/repositories/payment.d.ts.map +1 -0
  71. package/dist/billing/postgres/repositories/payment.js +78 -0
  72. package/dist/billing/postgres/repositories/payment.js.map +1 -0
  73. package/dist/billing/postgres/repositories/preferences.d.ts +15 -0
  74. package/dist/billing/postgres/repositories/preferences.d.ts.map +1 -0
  75. package/dist/billing/postgres/repositories/preferences.js +23 -0
  76. package/dist/billing/postgres/repositories/preferences.js.map +1 -0
  77. package/dist/billing/postgres/repositories/refund.d.ts +7 -0
  78. package/dist/billing/postgres/repositories/refund.d.ts.map +1 -0
  79. package/dist/billing/postgres/repositories/refund.js +32 -0
  80. package/dist/billing/postgres/repositories/refund.js.map +1 -0
  81. package/dist/billing/postgres/repositories/subscription.d.ts +46 -0
  82. package/dist/billing/postgres/repositories/subscription.d.ts.map +1 -0
  83. package/dist/billing/postgres/repositories/subscription.js +187 -0
  84. package/dist/billing/postgres/repositories/subscription.js.map +1 -0
  85. package/dist/billing/postgres/repositories/topup.d.ts +27 -0
  86. package/dist/billing/postgres/repositories/topup.d.ts.map +1 -0
  87. package/dist/billing/postgres/repositories/topup.js +51 -0
  88. package/dist/billing/postgres/repositories/topup.js.map +1 -0
  89. package/dist/billing/postgres/store.d.ts +89 -0
  90. package/dist/billing/postgres/store.d.ts.map +1 -0
  91. package/dist/billing/postgres/store.js +542 -0
  92. package/dist/billing/postgres/store.js.map +1 -0
  93. package/dist/billing/service-types.d.ts +37 -0
  94. package/dist/billing/service-types.d.ts.map +1 -0
  95. package/dist/billing/service-types.js +2 -0
  96. package/dist/billing/service-types.js.map +1 -0
  97. package/dist/billing/types/auto-recharge.d.ts +56 -0
  98. package/dist/billing/types/auto-recharge.d.ts.map +1 -0
  99. package/dist/billing/types/auto-recharge.js +2 -0
  100. package/dist/billing/types/auto-recharge.js.map +1 -0
  101. package/dist/billing/types/catalog.d.ts +47 -0
  102. package/dist/billing/types/catalog.d.ts.map +1 -0
  103. package/dist/billing/types/catalog.js +2 -0
  104. package/dist/billing/types/catalog.js.map +1 -0
  105. package/dist/billing/types/common.d.ts +16 -0
  106. package/dist/billing/types/common.d.ts.map +1 -0
  107. package/dist/billing/types/common.js +2 -0
  108. package/dist/billing/types/common.js.map +1 -0
  109. package/dist/billing/types/documents.d.ts +39 -0
  110. package/dist/billing/types/documents.d.ts.map +1 -0
  111. package/dist/billing/types/documents.js +2 -0
  112. package/dist/billing/types/documents.js.map +1 -0
  113. package/dist/billing/types/events.d.ts +75 -0
  114. package/dist/billing/types/events.d.ts.map +1 -0
  115. package/dist/billing/types/events.js +38 -0
  116. package/dist/billing/types/events.js.map +1 -0
  117. package/dist/billing/types/index.d.ts +8 -0
  118. package/dist/billing/types/index.d.ts.map +1 -0
  119. package/dist/billing/types/index.js +8 -0
  120. package/dist/billing/types/index.js.map +1 -0
  121. package/dist/billing/types/preferences.d.ts +13 -0
  122. package/dist/billing/types/preferences.d.ts.map +1 -0
  123. package/dist/billing/types/preferences.js +2 -0
  124. package/dist/billing/types/preferences.js.map +1 -0
  125. package/dist/billing/types/subscriptions.d.ts +97 -0
  126. package/dist/billing/types/subscriptions.d.ts.map +1 -0
  127. package/dist/billing/types/subscriptions.js +12 -0
  128. package/dist/billing/types/subscriptions.js.map +1 -0
  129. package/dist/breakdown.d.ts +3 -1
  130. package/dist/breakdown.d.ts.map +1 -1
  131. package/dist/breakdown.js +4 -1
  132. package/dist/breakdown.js.map +1 -1
  133. package/dist/browser.d.ts +8 -0
  134. package/dist/browser.d.ts.map +1 -0
  135. package/dist/browser.js +7 -0
  136. package/dist/browser.js.map +1 -0
  137. package/dist/bursar.d.ts +84 -0
  138. package/dist/bursar.d.ts.map +1 -0
  139. package/dist/bursar.js +137 -0
  140. package/dist/bursar.js.map +1 -0
  141. package/dist/catalog.d.ts +62 -0
  142. package/dist/catalog.d.ts.map +1 -0
  143. package/dist/catalog.js +96 -0
  144. package/dist/catalog.js.map +1 -0
  145. package/dist/commerce/errors.d.ts +68 -0
  146. package/dist/commerce/errors.d.ts.map +1 -0
  147. package/dist/commerce/errors.js +105 -0
  148. package/dist/commerce/errors.js.map +1 -0
  149. package/dist/commerce/index.d.ts +6 -0
  150. package/dist/commerce/index.d.ts.map +1 -0
  151. package/dist/commerce/index.js +6 -0
  152. package/dist/commerce/index.js.map +1 -0
  153. package/dist/commerce/plan-change.d.ts +10 -0
  154. package/dist/commerce/plan-change.d.ts.map +1 -0
  155. package/dist/commerce/plan-change.js +42 -0
  156. package/dist/commerce/plan-change.js.map +1 -0
  157. package/dist/commerce/provider-registry.d.ts +18 -0
  158. package/dist/commerce/provider-registry.d.ts.map +1 -0
  159. package/dist/commerce/provider-registry.js +70 -0
  160. package/dist/commerce/provider-registry.js.map +1 -0
  161. package/dist/commerce/service.d.ts +73 -0
  162. package/dist/commerce/service.d.ts.map +1 -0
  163. package/dist/commerce/service.js +1016 -0
  164. package/dist/commerce/service.js.map +1 -0
  165. package/dist/commerce/types.d.ts +225 -0
  166. package/dist/commerce/types.d.ts.map +1 -0
  167. package/dist/commerce/types.js.map +1 -0
  168. package/dist/config/parse-access.d.ts +6 -0
  169. package/dist/config/parse-access.d.ts.map +1 -0
  170. package/dist/config/parse-access.js +72 -0
  171. package/dist/config/parse-access.js.map +1 -0
  172. package/dist/config/parse-commerce.d.ts +3 -0
  173. package/dist/config/parse-commerce.d.ts.map +1 -0
  174. package/dist/config/parse-commerce.js +236 -0
  175. package/dist/config/parse-commerce.js.map +1 -0
  176. package/dist/config/parse-credits.d.ts +3 -0
  177. package/dist/config/parse-credits.d.ts.map +1 -0
  178. package/dist/config/parse-credits.js +99 -0
  179. package/dist/config/parse-credits.js.map +1 -0
  180. package/dist/config/parse-plans.d.ts +5 -0
  181. package/dist/config/parse-plans.d.ts.map +1 -0
  182. package/dist/config/parse-plans.js +142 -0
  183. package/dist/config/parse-plans.js.map +1 -0
  184. package/dist/config/parse-pricing.d.ts +4 -0
  185. package/dist/config/parse-pricing.d.ts.map +1 -0
  186. package/dist/config/parse-pricing.js +252 -0
  187. package/dist/config/parse-pricing.js.map +1 -0
  188. package/dist/config/parse-utils.d.ts +18 -0
  189. package/dist/config/parse-utils.d.ts.map +1 -0
  190. package/dist/config/parse-utils.js +118 -0
  191. package/dist/config/parse-utils.js.map +1 -0
  192. package/dist/config/types.d.ts +340 -0
  193. package/dist/config/types.d.ts.map +1 -0
  194. package/dist/config/types.js +2 -0
  195. package/dist/config/types.js.map +1 -0
  196. package/dist/config.d.ts +12 -23
  197. package/dist/config.d.ts.map +1 -1
  198. package/dist/config.js +141 -377
  199. package/dist/config.js.map +1 -1
  200. package/dist/{stores → credits}/events.d.ts +6 -6
  201. package/dist/credits/events.d.ts.map +1 -0
  202. package/dist/{stores → credits}/events.js +5 -5
  203. package/dist/credits/events.js.map +1 -0
  204. package/dist/credits/lease-workflow.d.ts +90 -0
  205. package/dist/credits/lease-workflow.d.ts.map +1 -0
  206. package/dist/credits/lease-workflow.js +378 -0
  207. package/dist/credits/lease-workflow.js.map +1 -0
  208. package/dist/credits/low-balance-monitor.d.ts +26 -0
  209. package/dist/credits/low-balance-monitor.d.ts.map +1 -0
  210. package/dist/credits/low-balance-monitor.js +110 -0
  211. package/dist/credits/low-balance-monitor.js.map +1 -0
  212. package/dist/credits/postgres/repositories/analytics.d.ts +81 -0
  213. package/dist/credits/postgres/repositories/analytics.d.ts.map +1 -0
  214. package/dist/credits/postgres/repositories/analytics.js +153 -0
  215. package/dist/credits/postgres/repositories/analytics.js.map +1 -0
  216. package/dist/credits/postgres/repositories/balance.d.ts +66 -0
  217. package/dist/credits/postgres/repositories/balance.d.ts.map +1 -0
  218. package/dist/credits/postgres/repositories/balance.js +139 -0
  219. package/dist/credits/postgres/repositories/balance.js.map +1 -0
  220. package/dist/credits/postgres/repositories/bucket.d.ts +25 -0
  221. package/dist/credits/postgres/repositories/bucket.d.ts.map +1 -0
  222. package/dist/credits/postgres/repositories/bucket.js +52 -0
  223. package/dist/credits/postgres/repositories/bucket.js.map +1 -0
  224. package/dist/credits/postgres/repositories/deduction.d.ts +64 -0
  225. package/dist/credits/postgres/repositories/deduction.d.ts.map +1 -0
  226. package/dist/credits/postgres/repositories/deduction.js +154 -0
  227. package/dist/credits/postgres/repositories/deduction.js.map +1 -0
  228. package/dist/credits/postgres/repositories/lease.d.ts +69 -0
  229. package/dist/credits/postgres/repositories/lease.d.ts.map +1 -0
  230. package/dist/credits/postgres/repositories/lease.js +148 -0
  231. package/dist/credits/postgres/repositories/lease.js.map +1 -0
  232. package/dist/credits/postgres/repositories/plan.d.ts +110 -0
  233. package/dist/credits/postgres/repositories/plan.d.ts.map +1 -0
  234. package/dist/credits/postgres/repositories/plan.js +194 -0
  235. package/dist/credits/postgres/repositories/plan.js.map +1 -0
  236. package/dist/credits/postgres/repositories/pricing.d.ts +28 -0
  237. package/dist/credits/postgres/repositories/pricing.d.ts.map +1 -0
  238. package/dist/credits/postgres/repositories/pricing.js +76 -0
  239. package/dist/credits/postgres/repositories/pricing.js.map +1 -0
  240. package/dist/credits/postgres/repositories/team.d.ts +63 -0
  241. package/dist/credits/postgres/repositories/team.d.ts.map +1 -0
  242. package/dist/credits/postgres/repositories/team.js +120 -0
  243. package/dist/credits/postgres/repositories/team.js.map +1 -0
  244. package/dist/credits/postgres/store.d.ts +89 -0
  245. package/dist/credits/postgres/store.d.ts.map +1 -0
  246. package/dist/credits/postgres/store.js +838 -0
  247. package/dist/credits/postgres/store.js.map +1 -0
  248. package/dist/credits/postgres/value-mappers.d.ts +17 -0
  249. package/dist/credits/postgres/value-mappers.d.ts.map +1 -0
  250. package/dist/credits/postgres/value-mappers.js +102 -0
  251. package/dist/credits/postgres/value-mappers.js.map +1 -0
  252. package/dist/credits/pricing-runtime.d.ts +35 -0
  253. package/dist/credits/pricing-runtime.d.ts.map +1 -0
  254. package/dist/credits/pricing-runtime.js +141 -0
  255. package/dist/credits/pricing-runtime.js.map +1 -0
  256. package/dist/credits/queries.d.ts +33 -0
  257. package/dist/credits/queries.d.ts.map +1 -0
  258. package/dist/credits/queries.js +71 -0
  259. package/dist/credits/queries.js.map +1 -0
  260. package/dist/credits/service-errors.d.ts +4 -0
  261. package/dist/credits/service-errors.d.ts.map +1 -0
  262. package/dist/credits/service-errors.js +57 -0
  263. package/dist/credits/service-errors.js.map +1 -0
  264. package/dist/credits/service-types.d.ts +122 -0
  265. package/dist/credits/service-types.d.ts.map +1 -0
  266. package/dist/credits/service-types.js +2 -0
  267. package/dist/credits/service-types.js.map +1 -0
  268. package/dist/credits/service.d.ts +220 -0
  269. package/dist/credits/service.d.ts.map +1 -0
  270. package/dist/credits/service.js +640 -0
  271. package/dist/credits/service.js.map +1 -0
  272. package/dist/credits/store.d.ts +172 -0
  273. package/dist/credits/store.d.ts.map +1 -0
  274. package/dist/{stores/credit-store.js → credits/store.js} +27 -43
  275. package/dist/credits/store.js.map +1 -0
  276. package/dist/credits/types/account.d.ts +82 -0
  277. package/dist/credits/types/account.d.ts.map +1 -0
  278. package/dist/credits/types/account.js +2 -0
  279. package/dist/credits/types/account.js.map +1 -0
  280. package/dist/credits/types/admission.d.ts +39 -0
  281. package/dist/credits/types/admission.d.ts.map +1 -0
  282. package/dist/credits/types/admission.js +2 -0
  283. package/dist/credits/types/admission.js.map +1 -0
  284. package/dist/credits/types/analytics.d.ts +52 -0
  285. package/dist/credits/types/analytics.d.ts.map +1 -0
  286. package/dist/credits/types/analytics.js +2 -0
  287. package/dist/credits/types/analytics.js.map +1 -0
  288. package/dist/credits/types/catalog.d.ts +71 -0
  289. package/dist/credits/types/catalog.d.ts.map +1 -0
  290. package/dist/credits/types/catalog.js +2 -0
  291. package/dist/credits/types/catalog.js.map +1 -0
  292. package/dist/credits/types/grants.d.ts +24 -0
  293. package/dist/credits/types/grants.d.ts.map +1 -0
  294. package/dist/credits/types/grants.js +2 -0
  295. package/dist/credits/types/grants.js.map +1 -0
  296. package/dist/credits/types/index.d.ts +9 -0
  297. package/dist/credits/types/index.d.ts.map +1 -0
  298. package/dist/credits/types/index.js +2 -0
  299. package/dist/credits/types/index.js.map +1 -0
  300. package/dist/credits/types/ledger.d.ts +87 -0
  301. package/dist/credits/types/ledger.d.ts.map +1 -0
  302. package/dist/credits/types/ledger.js +2 -0
  303. package/dist/credits/types/ledger.js.map +1 -0
  304. package/dist/credits/types/quotas.d.ts +40 -0
  305. package/dist/credits/types/quotas.d.ts.map +1 -0
  306. package/dist/credits/types/quotas.js +2 -0
  307. package/dist/credits/types/quotas.js.map +1 -0
  308. package/dist/credits/types/teams.d.ts +44 -0
  309. package/dist/credits/types/teams.d.ts.map +1 -0
  310. package/dist/credits/types/teams.js +2 -0
  311. package/dist/credits/types/teams.js.map +1 -0
  312. package/dist/engine.d.ts +18 -39
  313. package/dist/engine.d.ts.map +1 -1
  314. package/dist/engine.js +169 -145
  315. package/dist/engine.js.map +1 -1
  316. package/dist/errors.d.ts +133 -25
  317. package/dist/errors.d.ts.map +1 -1
  318. package/dist/errors.js +173 -24
  319. package/dist/errors.js.map +1 -1
  320. package/dist/expr/ast.d.ts +46 -0
  321. package/dist/expr/ast.d.ts.map +1 -0
  322. package/dist/expr/ast.js +18 -0
  323. package/dist/expr/ast.js.map +1 -0
  324. package/dist/expr/evaluator.d.ts +4 -0
  325. package/dist/expr/evaluator.d.ts.map +1 -0
  326. package/dist/expr/evaluator.js +144 -0
  327. package/dist/expr/evaluator.js.map +1 -0
  328. package/dist/expr/language.d.ts +5 -0
  329. package/dist/expr/language.d.ts.map +1 -0
  330. package/dist/expr/language.js +73 -0
  331. package/dist/expr/language.js.map +1 -0
  332. package/dist/expr/parser.d.ts +24 -0
  333. package/dist/expr/parser.d.ts.map +1 -0
  334. package/dist/expr/parser.js +175 -0
  335. package/dist/expr/parser.js.map +1 -0
  336. package/dist/expr/tokenizer.d.ts +7 -0
  337. package/dist/expr/tokenizer.d.ts.map +1 -0
  338. package/dist/expr/tokenizer.js +85 -0
  339. package/dist/expr/tokenizer.js.map +1 -0
  340. package/dist/expr.d.ts +7 -58
  341. package/dist/expr.d.ts.map +1 -1
  342. package/dist/expr.js +41 -640
  343. package/dist/expr.js.map +1 -1
  344. package/dist/generated/pricing-config.schema.json +2792 -0
  345. package/dist/generated/pricing-config.types.d.ts +685 -0
  346. package/dist/generated/pricing-config.types.d.ts.map +1 -0
  347. package/dist/generated/pricing-config.types.js +8 -0
  348. package/dist/generated/pricing-config.types.js.map +1 -0
  349. package/dist/index.d.ts +23 -17
  350. package/dist/index.d.ts.map +1 -1
  351. package/dist/index.js +12 -10
  352. package/dist/index.js.map +1 -1
  353. package/dist/load-pricing-file.d.ts.map +1 -1
  354. package/dist/load-pricing-file.js +8 -4
  355. package/dist/load-pricing-file.js.map +1 -1
  356. package/dist/metrics.d.ts +6 -16
  357. package/dist/metrics.d.ts.map +1 -1
  358. package/dist/metrics.js.map +1 -1
  359. package/dist/node.d.ts +9 -2
  360. package/dist/node.d.ts.map +1 -1
  361. package/dist/node.js +6 -2
  362. package/dist/node.js.map +1 -1
  363. package/dist/providers/_shared.d.ts +9 -0
  364. package/dist/providers/_shared.d.ts.map +1 -0
  365. package/dist/providers/_shared.js +52 -0
  366. package/dist/providers/_shared.js.map +1 -0
  367. package/dist/providers/dodo/client-contract.d.ts +106 -0
  368. package/dist/providers/dodo/client-contract.d.ts.map +1 -0
  369. package/dist/providers/dodo/client-contract.js +2 -0
  370. package/dist/providers/dodo/client-contract.js.map +1 -0
  371. package/dist/providers/dodo/event-mapper.d.ts +5 -3
  372. package/dist/providers/dodo/event-mapper.d.ts.map +1 -1
  373. package/dist/providers/dodo/event-mapper.js +213 -38
  374. package/dist/providers/dodo/event-mapper.js.map +1 -1
  375. package/dist/providers/dodo/index.d.ts +1 -0
  376. package/dist/providers/dodo/index.d.ts.map +1 -1
  377. package/dist/providers/dodo/index.js.map +1 -1
  378. package/dist/providers/dodo/provider.d.ts +24 -14
  379. package/dist/providers/dodo/provider.d.ts.map +1 -1
  380. package/dist/providers/dodo/provider.js +249 -31
  381. package/dist/providers/dodo/provider.js.map +1 -1
  382. package/dist/providers/index.d.ts +3 -1
  383. package/dist/providers/index.d.ts.map +1 -1
  384. package/dist/providers/index.js +1 -0
  385. package/dist/providers/index.js.map +1 -1
  386. package/dist/providers/mock/index.js.map +1 -1
  387. package/dist/providers/mock/provider.d.ts +14 -10
  388. package/dist/providers/mock/provider.d.ts.map +1 -1
  389. package/dist/providers/mock/provider.js +78 -10
  390. package/dist/providers/mock/provider.js.map +1 -1
  391. package/dist/providers/stripe/event-mapper.d.ts +3 -3
  392. package/dist/providers/stripe/event-mapper.d.ts.map +1 -1
  393. package/dist/providers/stripe/event-mapper.js +139 -30
  394. package/dist/providers/stripe/event-mapper.js.map +1 -1
  395. package/dist/providers/stripe/index.js.map +1 -1
  396. package/dist/providers/stripe/provider.d.ts +21 -12
  397. package/dist/providers/stripe/provider.d.ts.map +1 -1
  398. package/dist/providers/stripe/provider.js +175 -17
  399. package/dist/providers/stripe/provider.js.map +1 -1
  400. package/dist/providers/types.d.ts +128 -32
  401. package/dist/providers/types.d.ts.map +1 -1
  402. package/dist/providers/types.js +17 -1
  403. package/dist/providers/types.js.map +1 -1
  404. package/dist/retry.d.ts +35 -0
  405. package/dist/retry.d.ts.map +1 -0
  406. package/dist/retry.js +70 -0
  407. package/dist/retry.js.map +1 -0
  408. package/dist/shared/diagnostics.d.ts +7 -0
  409. package/dist/shared/diagnostics.d.ts.map +1 -0
  410. package/dist/shared/diagnostics.js +18 -0
  411. package/dist/shared/diagnostics.js.map +1 -0
  412. package/dist/shared/logger.d.ts +10 -0
  413. package/dist/shared/logger.d.ts.map +1 -0
  414. package/dist/shared/logger.js +15 -0
  415. package/dist/shared/logger.js.map +1 -0
  416. package/dist/shared/postgres-client.d.ts +84 -0
  417. package/dist/shared/postgres-client.d.ts.map +1 -0
  418. package/dist/shared/postgres-client.js +337 -0
  419. package/dist/shared/postgres-client.js.map +1 -0
  420. package/dist/shared/postgres-errors.d.ts +11 -0
  421. package/dist/shared/postgres-errors.d.ts.map +1 -0
  422. package/dist/shared/postgres-errors.js +105 -0
  423. package/dist/shared/postgres-errors.js.map +1 -0
  424. package/dist/shared/postgres-types.d.ts +7 -0
  425. package/dist/shared/postgres-types.d.ts.map +1 -0
  426. package/dist/shared/postgres-types.js +2 -0
  427. package/dist/shared/postgres-types.js.map +1 -0
  428. package/dist/shared/postgres-validation.d.ts +8 -0
  429. package/dist/shared/postgres-validation.d.ts.map +1 -0
  430. package/dist/shared/postgres-validation.js +40 -0
  431. package/dist/shared/postgres-validation.js.map +1 -0
  432. package/dist/storage/adapters/clickhouse.d.ts +61 -0
  433. package/dist/storage/adapters/clickhouse.d.ts.map +1 -0
  434. package/dist/storage/adapters/clickhouse.js +347 -0
  435. package/dist/storage/adapters/clickhouse.js.map +1 -0
  436. package/dist/storage/adapters/s3.d.ts +35 -0
  437. package/dist/storage/adapters/s3.d.ts.map +1 -0
  438. package/dist/storage/adapters/s3.js +100 -0
  439. package/dist/storage/adapters/s3.js.map +1 -0
  440. package/dist/storage/outbox-worker.d.ts +41 -0
  441. package/dist/storage/outbox-worker.d.ts.map +1 -0
  442. package/dist/storage/outbox-worker.js +146 -0
  443. package/dist/storage/outbox-worker.js.map +1 -0
  444. package/dist/storage/ports.d.ts +78 -0
  445. package/dist/storage/ports.d.ts.map +1 -0
  446. package/dist/storage/ports.js +2 -0
  447. package/dist/storage/ports.js.map +1 -0
  448. package/dist/storage/postgres-repository.d.ts +14 -0
  449. package/dist/storage/postgres-repository.d.ts.map +1 -0
  450. package/dist/storage/postgres-repository.js +140 -0
  451. package/dist/storage/postgres-repository.js.map +1 -0
  452. package/dist/storage/runtime.d.ts +77 -0
  453. package/dist/storage/runtime.d.ts.map +1 -0
  454. package/dist/storage/runtime.js +369 -0
  455. package/dist/storage/runtime.js.map +1 -0
  456. package/package.json +43 -21
  457. package/dist/allowance.d.ts +0 -48
  458. package/dist/allowance.d.ts.map +0 -1
  459. package/dist/allowance.js +0 -140
  460. package/dist/allowance.js.map +0 -1
  461. package/dist/billing/billing-manager.d.ts +0 -66
  462. package/dist/billing/billing-manager.d.ts.map +0 -1
  463. package/dist/billing/billing-manager.js +0 -560
  464. package/dist/billing/billing-manager.js.map +0 -1
  465. package/dist/billing/billing-types.d.ts +0 -203
  466. package/dist/billing/billing-types.d.ts.map +0 -1
  467. package/dist/billing/billing-types.js +0 -6
  468. package/dist/billing/billing-types.js.map +0 -1
  469. package/dist/billing/memory-billing-store.d.ts +0 -37
  470. package/dist/billing/memory-billing-store.d.ts.map +0 -1
  471. package/dist/billing/memory-billing-store.js +0 -197
  472. package/dist/billing/memory-billing-store.js.map +0 -1
  473. package/dist/billing/postgres-billing-store.d.ts +0 -35
  474. package/dist/billing/postgres-billing-store.d.ts.map +0 -1
  475. package/dist/billing/postgres-billing-store.js +0 -274
  476. package/dist/billing/postgres-billing-store.js.map +0 -1
  477. package/dist/billing/supabase-billing-store.d.ts +0 -29
  478. package/dist/billing/supabase-billing-store.d.ts.map +0 -1
  479. package/dist/billing/supabase-billing-store.js +0 -250
  480. package/dist/billing/supabase-billing-store.js.map +0 -1
  481. package/dist/manager.d.ts +0 -444
  482. package/dist/manager.d.ts.map +0 -1
  483. package/dist/manager.js +0 -1153
  484. package/dist/manager.js.map +0 -1
  485. package/dist/stores/credit-store.d.ts +0 -198
  486. package/dist/stores/credit-store.d.ts.map +0 -1
  487. package/dist/stores/credit-store.js.map +0 -1
  488. package/dist/stores/events.d.ts.map +0 -1
  489. package/dist/stores/events.js.map +0 -1
  490. package/dist/stores/memory-store.d.ts +0 -187
  491. package/dist/stores/memory-store.d.ts.map +0 -1
  492. package/dist/stores/memory-store.js +0 -1890
  493. package/dist/stores/memory-store.js.map +0 -1
  494. package/dist/stores/postgres-store.d.ts +0 -100
  495. package/dist/stores/postgres-store.d.ts.map +0 -1
  496. package/dist/stores/postgres-store.js +0 -891
  497. package/dist/stores/postgres-store.js.map +0 -1
  498. package/dist/stores/supabase-store.d.ts +0 -87
  499. package/dist/stores/supabase-store.d.ts.map +0 -1
  500. package/dist/stores/supabase-store.js +0 -948
  501. package/dist/stores/supabase-store.js.map +0 -1
  502. package/dist/types.d.ts +0 -463
  503. package/dist/types.d.ts.map +0 -1
  504. package/dist/types.js.map +0 -1
  505. /package/dist/{types.js → commerce/types.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/billing/postgres/store.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAgBnD,OAAO,EACL,cAAc,GAGf,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,SAAS,KAAK,CAAC,KAAc;IAC3B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,OAAQ,KAAiC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C,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,MAAc;QACzC,OAAO,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAC7B,OAAmC,EACnC,OAAqC;QAErC,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,wBAAwB,CAC5B,KAA+B;QAE/B,OAAO,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,KAAgC;QAC9D,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,0CAA0C,CAC9C,KAAwC;QAExC,OAAO,IAAI,CAAC,mBAAmB,CAAC,8BAA8B,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,MAAc,EAAE,KAAoB;QAClE,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,0BAA0B,CAC9B,MAAc,EACd,QAAwB;QAExB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC;QAChF,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC;QACzB,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;SAC9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type {\n BillingAutoRechargeAttempt,\n BillingAutoRechargeProfile,\n BillingCustomerRecord,\n BillingEventClaim,\n BillingOfferResult,\n BillingPreferences,\n BillingSubscriptionChange,\n BillingSubscriptionChangeInput,\n BillingSubscriptionOfferContext,\n BillingSubscriptionState,\n BillingSubscriptionStatus,\n CheckoutIntent,\n BillingTopupResult,\n} from \"../types/index.js\";\nimport { BillingStore } from \"../billing-store.js\";\nimport type {\n AutoRechargeAttemptClaim,\n AutoRechargeAttemptUpdate,\n AutoRechargeProviderPaymentUpdate,\n BillingCreditGrantCreate,\n BillingDisputeUpsert,\n BillingInvoiceUpsert,\n BillingPaymentUpsert,\n BillingRefundUpsert,\n BillingSubscriptionChangeUpdate,\n BillingSubscriptionConflictCreate,\n CheckoutIntentCreate,\n CheckoutIntentUpdate,\n} from \"../contracts.js\";\nimport type { QueryFn } from \"../../shared/postgres-types.js\";\nimport {\n PostgresClient,\n type PostgresConnectionOptions,\n type PostgresPool,\n} from \"../../shared/postgres-client.js\";\nimport { StoreClosedError } from \"../../errors.js\";\nimport { optionalBoundedDiagnosticMessage } from \"../../shared/diagnostics.js\";\nimport { BillingOfferRepository } from \"./repositories/offer.js\";\nimport { BillingTopupRepository } from \"./repositories/topup.js\";\nimport { BillingCustomerRepository } from \"./repositories/customer.js\";\nimport { BillingSubscriptionRepository } from \"./repositories/subscription.js\";\nimport { BillingEventRepository } from \"./repositories/event.js\";\nimport { BillingPaymentRepository } from \"./repositories/payment.js\";\nimport { BillingRefundRepository } from \"./repositories/refund.js\";\nimport { BillingInvoiceRepository } from \"./repositories/invoice.js\";\nimport { BillingDisputeRepository } from \"./repositories/dispute.js\";\nimport { BillingPreferencesRepository } from \"./repositories/preferences.js\";\nimport { BillingAutoRechargeRepository } from \"./repositories/auto-recharge.js\";\n\nfunction toIso(value: unknown): string | null {\n if (!value) return null;\n if (typeof value === \"string\") return value;\n if (value instanceof Date) return value.toISOString();\n if (typeof (value as Record<string, unknown>)[\"toISOString\"] === \"function\") {\n return (value as Date).toISOString();\n }\n return String(value);\n}\n\nexport interface PostgresBillingStoreOptions extends PostgresConnectionOptions {\n billingPayloadBackend?: \"postgres\" | \"s3\";\n}\n\nexport class PostgresBillingStore extends BillingStore {\n private readonly postgres: PostgresClient;\n\n private _offer: BillingOfferRepository | null = null;\n private _topup: BillingTopupRepository | null = null;\n private _customer: BillingCustomerRepository | null = null;\n private _subscription: BillingSubscriptionRepository | null = null;\n private _event: BillingEventRepository | null = null;\n private _payment: BillingPaymentRepository | null = null;\n private _refund: BillingRefundRepository | null = null;\n private _invoice: BillingInvoiceRepository | null = null;\n private _dispute: BillingDisputeRepository | null = null;\n private _preferences: BillingPreferencesRepository | null = null;\n private _autoRecharge: BillingAutoRechargeRepository | null = null;\n constructor(\n poolOrUrl: PostgresPool | string,\n tenantId: string,\n storageOptions?: PostgresBillingStoreOptions,\n ) {\n super();\n this.postgres = new PostgresClient(poolOrUrl, {\n tenantId,\n billingPayloadBackend: storageOptions?.billingPayloadBackend,\n connectionTimeoutMs: storageOptions?.connectionTimeoutMs,\n statementTimeoutMs: storageOptions?.statementTimeoutMs,\n idleTransactionTimeoutMs: storageOptions?.idleTransactionTimeoutMs,\n idleTimeoutMs: storageOptions?.idleTimeoutMs,\n maxConnections: storageOptions?.maxConnections,\n applicationName: storageOptions?.applicationName,\n onPoolError: storageOptions?.onPoolError,\n closedError: () => new StoreClosedError(\"Billing store has been closed\"),\n });\n }\n\n async close(): Promise<void> {\n await this.postgres.close();\n }\n\n private get queryFn(): QueryFn {\n return this.postgres.query;\n }\n\n private get billingOffer(): BillingOfferRepository {\n if (!this._offer) this._offer = new BillingOfferRepository(this.queryFn);\n return this._offer;\n }\n\n private get billingTopup(): BillingTopupRepository {\n if (!this._topup) this._topup = new BillingTopupRepository(this.queryFn);\n return this._topup;\n }\n\n private get billingCustomer(): BillingCustomerRepository {\n if (!this._customer) this._customer = new BillingCustomerRepository(this.queryFn);\n return this._customer;\n }\n\n private get billingSubscription(): BillingSubscriptionRepository {\n if (!this._subscription) this._subscription = new BillingSubscriptionRepository(this.queryFn);\n return this._subscription;\n }\n\n private get billingEvent(): BillingEventRepository {\n if (!this._event) this._event = new BillingEventRepository(this.queryFn);\n return this._event;\n }\n\n private get billingPayment(): BillingPaymentRepository {\n if (!this._payment) this._payment = new BillingPaymentRepository(this.queryFn);\n return this._payment;\n }\n\n private get billingRefund(): BillingRefundRepository {\n if (!this._refund) this._refund = new BillingRefundRepository(this.queryFn);\n return this._refund;\n }\n\n private get billingInvoice(): BillingInvoiceRepository {\n if (!this._invoice) this._invoice = new BillingInvoiceRepository(this.queryFn);\n return this._invoice;\n }\n\n private get billingDispute(): BillingDisputeRepository {\n if (!this._dispute) this._dispute = new BillingDisputeRepository(this.queryFn);\n return this._dispute;\n }\n\n private get billingPreferences(): BillingPreferencesRepository {\n if (!this._preferences) this._preferences = new BillingPreferencesRepository(this.queryFn);\n return this._preferences;\n }\n\n private get billingAutoRecharge(): BillingAutoRechargeRepository {\n if (!this._autoRecharge) this._autoRecharge = new BillingAutoRechargeRepository(this.queryFn);\n return this._autoRecharge;\n }\n\n async createOrGetCheckoutIntent(input: CheckoutIntentCreate): Promise<CheckoutIntent> {\n if (!/^[0-9a-fA-F]{64}$/.test(input.requestDigest)) {\n throw new Error(\"requestDigest must be a 32-byte hex string\");\n }\n const rows = await this.queryFn(\n `SELECT bursar.create_checkout_intent($1::uuid, $2, $3, $4, decode($5, 'hex'), $6::timestamptz) AS id`,\n [\n input.subjectId,\n input.provider,\n input.checkoutKind,\n input.productKey,\n input.requestDigest,\n input.expiresAt,\n ],\n );\n const id = (rows[0] as Record<string, unknown> | undefined)?.id;\n if (!id) throw new Error(\"checkout intent creation returned no ID\");\n const intent = await this.getCheckoutIntent(String(id), input.subjectId);\n if (!intent) throw new Error(\"checkout intent creation returned no row\");\n return intent;\n }\n\n async updateCheckoutIntent(id: string, update: CheckoutIntentUpdate): Promise<void> {\n const rows = await this.queryFn(\n `SELECT bursar.advance_checkout_intent($1::uuid, $2, $3, $4) AS advanced`,\n [id, update.status ?? null, update.providerSessionId ?? null, update.checkoutUrl ?? null],\n );\n if (!(rows[0] as Record<string, unknown> | undefined)?.advanced) {\n throw new Error(`checkout intent transition rejected: ${id}`);\n }\n }\n\n async getCheckoutIntent(id: string, subjectId: string): Promise<CheckoutIntent | null> {\n const rows = await this.queryFn(\n `SELECT * FROM bursar.get_checkout_intent($1::uuid, $2::uuid)`,\n [id, subjectId],\n );\n const row = rows[0] as Record<string, unknown> | undefined;\n return row?.id == null ? null : this.rowToCheckoutIntent(row);\n }\n\n private rowToCheckoutIntent(row: Record<string, unknown>): CheckoutIntent {\n return {\n id: String(row.id),\n subjectId: String(row.subject_id),\n provider: String(row.provider),\n checkoutKind: row.checkout_kind as CheckoutIntent[\"checkoutKind\"],\n productKey: String(row.product_key),\n requestDigest: Buffer.from(row.request_digest as Uint8Array).toString(\"hex\"),\n status: row.status as CheckoutIntent[\"status\"],\n providerSessionId: row.provider_session_id == null ? null : String(row.provider_session_id),\n checkoutUrl: row.checkout_url == null ? null : String(row.checkout_url),\n expiresAt: toIso(row.expires_at) ?? new Date(0).toISOString(),\n };\n }\n\n private rowToOffer(row: Record<string, unknown> | null): BillingOfferResult | null {\n if (!row?.offer_key || !row.id) return null;\n return {\n offerId: String(row.id),\n offerKey: String(row.offer_key),\n planId: row.plan_id == null ? null : String(row.plan_id),\n plan: row.plan == null ? null : String(row.plan),\n interval: row.interval == null ? \"month\" : String(row.interval),\n intervalCount: Number(row.interval_count ?? 1),\n grant: {\n mode: row.grant_mode == null ? undefined : String(row.grant_mode),\n credits: row.grant_credits == null ? null : Number(row.grant_credits),\n bucket: row.grant_bucket == null ? undefined : String(row.grant_bucket),\n replacePrior: row.grant_replace_prior === true,\n },\n };\n }\n\n async resolveBillingOffer(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingOfferResult | null> {\n const r = await this.billingOffer.resolveByPrice(provider, priceId ?? null, productId ?? null);\n return this.rowToOffer(r as Record<string, unknown>);\n }\n\n async resolveBillingOfferByLookup(\n provider: string,\n lookupKey: string,\n ): Promise<BillingOfferResult | null> {\n const r = await this.billingOffer.resolveByLookup(provider, lookupKey);\n return this.rowToOffer(r as Record<string, unknown>);\n }\n\n async claimBillingEvent(\n provider: string,\n eventId: string,\n eventType: string,\n envelope?: Record<string, unknown>,\n ): Promise<BillingEventClaim> {\n const result = await this.billingEvent.claim(\n provider,\n eventId,\n eventType,\n JSON.stringify(envelope ?? { eventType }),\n );\n if (!result) return { status: \"retry\" as const };\n const r = result as Record<string, unknown>;\n const s = r.status as string;\n if (s === \"claimed\" && typeof r.claim_token === \"string\" && typeof r.event_id === \"string\") {\n return {\n status: \"claimed\" as const,\n claimToken: r.claim_token,\n billingEventId: r.event_id,\n };\n }\n if (s === \"duplicate\") return { status: \"duplicate\" as const };\n if (s === \"busy\") return { status: \"busy\" as const };\n return { status: \"retry\" as const };\n }\n\n async completeBillingEvent(\n provider: string,\n eventId: string,\n claimToken: string,\n ): Promise<boolean> {\n return this.billingEvent.complete(provider, eventId, claimToken);\n }\n\n async failBillingEvent(\n provider: string,\n eventId: string,\n claimToken: string,\n error?: string,\n ): Promise<boolean> {\n return this.billingEvent.fail(\n provider,\n eventId,\n claimToken,\n optionalBoundedDiagnosticMessage(error) ?? undefined,\n );\n }\n\n async upsertBillingCustomer(\n provider: string,\n providerCustomerId: string,\n userId: string,\n email?: string | null,\n ): Promise<void> {\n await this.billingCustomer.upsert(provider, providerCustomerId, userId, email ?? null);\n }\n\n async upsertBillingSubscription(state: BillingSubscriptionState): Promise<void> {\n await this.billingSubscription.upsert(state as unknown as Record<string, unknown>);\n }\n\n async getBillingCustomer(provider: string, providerCustomerId: string): Promise<string | null> {\n return this.billingCustomer.get(provider, providerCustomerId);\n }\n\n async getBillingSubscription(\n provider: string,\n providerSubscriptionId: string,\n ): Promise<BillingSubscriptionState | null> {\n const r = await this.billingSubscription.get(provider, providerSubscriptionId);\n if (!r) return null;\n return this.rowToSubscriptionState(r);\n }\n\n async createBillingSubscriptionChange(\n input: BillingSubscriptionChangeInput,\n ): Promise<BillingSubscriptionChange> {\n const subscription = await this.billingSubscription.get(\n input.provider,\n input.providerSubscriptionId,\n );\n if (!subscription?.id) throw new Error(\"subscription change requires a persisted subscription\");\n const rows = await this.queryFn(\n `SELECT * FROM bursar.open_subscription_change(\n $1::uuid, $2::uuid, $3::timestamptz, $4, $5, $6\n )`,\n [\n subscription.id,\n input.toOfferId,\n input.effectiveAt,\n input.effective,\n input.idempotencyKey,\n input.prorationBehavior ?? \"provider_default\",\n ],\n );\n const result = (rows[0] as Record<string, unknown> | undefined) ?? {};\n if (result.error_code) throw new Error(`subscription change: ${String(result.error_code)}`);\n const changeRows = await this.queryFn(\n `SELECT * FROM bursar.get_billing_subscription_change($1::bigint)`,\n [result.change_id],\n );\n if ((changeRows[0] as Record<string, unknown> | undefined)?.id == null) {\n throw new Error(\"subscription change creation returned no row\");\n }\n return this.rowToSubscriptionChange(changeRows[0] as Record<string, unknown>);\n }\n\n async getOpenBillingSubscriptionChange(\n provider: string,\n providerSubscriptionId: string,\n ): Promise<BillingSubscriptionChange | null> {\n const rows = await this.queryFn(\n `SELECT * FROM bursar.get_open_billing_subscription_change($1, $2)`,\n [provider, providerSubscriptionId],\n );\n const row = rows[0] as Record<string, unknown> | undefined;\n return row?.id == null ? null : this.rowToSubscriptionChange(row);\n }\n\n async listExpiredGraceSubscriptions(\n now: string,\n limit = 100,\n ): Promise<BillingSubscriptionState[]> {\n const rows = await this.billingSubscription.listExpiredGraceSubscriptions(now, limit);\n return rows.map((row) => this.rowToSubscriptionState(row));\n }\n\n async markSubscriptionGraceExpired(\n subscriptionId: string,\n expectedGraceEndsAt: string,\n expiredAt = new Date().toISOString(),\n ): Promise<boolean> {\n return this.billingSubscription.markGraceExpired(\n subscriptionId,\n expectedGraceEndsAt,\n expiredAt,\n );\n }\n\n async updateBillingSubscriptionChange(\n id: string,\n update: BillingSubscriptionChangeUpdate,\n ): Promise<void> {\n if (!update.state) return;\n const rows = await this.queryFn(\n `SELECT bursar.advance_subscription_change($1::bigint, $2, $3, $4) AS advanced`,\n [\n id,\n update.state,\n update.providerOperationId ?? null,\n optionalBoundedDiagnosticMessage(update.errorMessage),\n ],\n );\n if (!(rows[0] as Record<string, unknown> | undefined)?.advanced) {\n throw new Error(`subscription change transition rejected: ${id}`);\n }\n }\n\n async getUserSubscription(\n userId: string,\n statuses?: string[],\n ): Promise<BillingSubscriptionState | null> {\n const r = await this.billingSubscription.getUserSubscription(userId, statuses);\n if (!r) return null;\n return this.rowToSubscriptionState(r);\n }\n\n async getUserSubscriptions(userId: string): Promise<BillingSubscriptionState[]> {\n const rows = await this.billingSubscription.getUserSubscriptions(userId);\n return rows.map((r) => this.rowToSubscriptionState(r));\n }\n\n async recordSubscriptionConflict(input: BillingSubscriptionConflictCreate): Promise<void> {\n await this.billingSubscription.recordConflict(input);\n }\n\n async selectSubscriptionEntitlementSource(\n userId: string,\n provider: string,\n providerSubscriptionId?: string | null,\n ): Promise<boolean> {\n return this.billingSubscription.selectEntitlementSource(\n userId,\n provider,\n providerSubscriptionId,\n );\n }\n\n private rowToTopup(r: Record<string, unknown>): BillingTopupResult | null {\n if (!r?.topup_key || !r.id) return null;\n return {\n topupId: String(r.id),\n topupKey: r.topup_key as string,\n creditsPerUnit: Number(r.credits_per_unit ?? r.credits_per_major_unit ?? 1000),\n depositTo: (r.bucket_key as string | undefined) || \"purchased\",\n amountMinor: r.amount_minor == null ? undefined : Number(r.amount_minor),\n currency: r.currency == null ? undefined : String(r.currency),\n minQuantity: r.min_quantity == null ? undefined : Number(r.min_quantity),\n maxQuantity: r.max_quantity == null ? undefined : Number(r.max_quantity),\n defaultQuantity: r.default_quantity == null ? undefined : Number(r.default_quantity),\n minAmountMinor:\n r.amount_minor == null ? undefined : Number(r.amount_minor) * Number(r.min_quantity ?? 1),\n maxAmountMinor:\n r.amount_minor == null ? undefined : Number(r.amount_minor) * Number(r.max_quantity ?? 1),\n };\n }\n\n async resolveCreditTopup(\n provider: string,\n productId?: string | null,\n priceId?: string | null,\n ): Promise<BillingTopupResult | null> {\n const r = await this.billingTopup.resolveByPrice(provider, priceId ?? null, productId ?? null);\n return this.rowToTopup(r as Record<string, unknown>);\n }\n\n async resolveCreditTopupByLookup(\n provider: string,\n lookupKey: string,\n ): Promise<BillingTopupResult | null> {\n const r = await this.billingTopup.resolveByLookup(provider, lookupKey);\n return this.rowToTopup(r as Record<string, unknown>);\n }\n\n async computeTopupCredits(amountMinor: number, topupConfig: BillingTopupResult): Promise<number> {\n const unitAmount = topupConfig.amountMinor;\n const creditsPer = topupConfig.creditsPerUnit ?? 0;\n if (!unitAmount || amountMinor % unitAmount !== 0) return 0;\n const quantity = amountMinor / unitAmount;\n if (quantity < (topupConfig.minQuantity ?? 1) || quantity > (topupConfig.maxQuantity ?? 1)) {\n return 0;\n }\n return quantity * creditsPer;\n }\n\n async upsertBillingPayment(options: BillingPaymentUpsert): Promise<string> {\n return this.billingPayment.upsert(\n options.provider,\n options.providerPaymentId,\n options.providerInvoiceId ?? null,\n options.userId ?? null,\n options.amountMinor ?? 0,\n options.taxMinor ?? null,\n options.currency ?? \"USD\",\n options.purpose ?? null,\n options.metadata ? JSON.stringify(options.metadata) : null,\n options.status ?? \"succeeded\",\n options.providerUpdatedAt ?? new Date().toISOString(),\n );\n }\n\n async createBillingCreditGrant(input: BillingCreditGrantCreate): Promise<string> {\n const rows = await this.queryFn(\n \"SELECT bursar.create_billing_credit_grant($1::uuid, $2::uuid, $3::uuid, $4, $5, $6::uuid) AS id\",\n [\n input.paymentId ?? null,\n input.subscriptionId ?? null,\n input.topupId ?? null,\n input.configuredCredits,\n input.quantity ?? 1,\n input.billingEventId ?? null,\n ],\n );\n const id = (rows[0] as Record<string, unknown> | undefined)?.id;\n if (!id) throw new Error(\"billing credit grant creation returned no ID\");\n return String(id);\n }\n\n async grantBillingCredit(\n grantId: string,\n idempotencyKey: string,\n ): Promise<Record<string, unknown>> {\n const rows = await this.queryFn(\"SELECT * FROM bursar.grant_billing_credit($1::uuid, $2)\", [\n grantId,\n idempotencyKey,\n ]);\n return (rows[0] as Record<string, unknown> | undefined) ?? {};\n }\n\n async getBillingCreditGrantByPayment(paymentId: string): Promise<string | null> {\n const rows = await this.queryFn(\n `SELECT * FROM bursar.get_billing_credit_grant_by_payment($1::uuid)`,\n [paymentId],\n );\n const id = (rows[0] as Record<string, unknown> | undefined)?.id;\n return id ? String(id) : null;\n }\n\n async postBillingRefund(\n refundId: string,\n grantId: string,\n amountMinor: number,\n idempotencyKey: string,\n ): Promise<Record<string, unknown>> {\n const rows = await this.queryFn(\n \"SELECT * FROM bursar.post_billing_refund($1::uuid, $2::uuid, $3, $4)\",\n [refundId, grantId, amountMinor, idempotencyKey],\n );\n return (rows[0] as Record<string, unknown> | undefined) ?? {};\n }\n\n async upsertBillingRefund(options: BillingRefundUpsert): Promise<string> {\n return this.billingRefund.upsert(\n options.provider,\n options.providerRefundId,\n options.providerPaymentId ?? null,\n options.userId ?? null,\n options.amountMinor ?? 0,\n options.currency ?? \"USD\",\n options.reason ?? null,\n options.metadata ? JSON.stringify(options.metadata) : null,\n options.status ?? \"pending\",\n options.providerUpdatedAt ?? new Date().toISOString(),\n );\n }\n\n async upsertBillingInvoice(options: BillingInvoiceUpsert): Promise<void> {\n const subscription = options.providerSubscriptionId\n ? await this.billingSubscription.get(options.provider, options.providerSubscriptionId)\n : null;\n const subjectId =\n options.userId ?? (subscription?.subject_id ? String(subscription.subject_id) : null);\n if (!subjectId) throw new Error(\"invoice subject is required\");\n await this.billingInvoice.upsert(\n subjectId,\n options.provider,\n options.providerInvoiceId,\n subscription?.id ? String(subscription.id) : null,\n options.status ?? null,\n options.amountDueMinor ?? null,\n options.amountPaidMinor ?? null,\n options.currency ?? \"USD\",\n options.periodStart ?? null,\n options.periodEnd ?? null,\n options.metadata ?? {},\n options.providerUpdatedAt ?? new Date().toISOString(),\n );\n }\n\n async listBillingInvoices(userId: string) {\n return this.billingInvoice.listForUser(userId);\n }\n\n async upsertBillingDispute(options: BillingDisputeUpsert): Promise<void> {\n const payment = options.providerPaymentId\n ? await this.billingPayment.getForRefund(options.provider, options.providerPaymentId)\n : null;\n if (!payment?.id) throw new Error(\"dispute payment is required\");\n await this.billingDispute.upsert(\n options.provider,\n options.providerDisputeId,\n String(payment.id),\n options.status ?? \"needs_response\",\n options.reason ?? null,\n options.metadata ?? {},\n options.providerUpdatedAt ?? new Date().toISOString(),\n );\n }\n\n async getBillingPayment(\n provider: string,\n providerPaymentId: string,\n ): Promise<Record<string, unknown> | null> {\n const result = await this.billingPayment.getForRefund(provider, providerPaymentId);\n if (!result) return null;\n const row = result as Record<string, unknown>;\n return {\n id: row.id,\n provider: row.provider,\n providerPaymentId: row.provider_payment_id,\n providerInvoiceId: row.provider_invoice_id,\n userId: row.subject_id,\n amountMinor: row.amount_minor == null ? null : Number(row.amount_minor),\n taxMinor: row.tax_minor == null ? null : Number(row.tax_minor),\n currency: row.currency,\n purpose: row.purpose,\n status: row.status,\n providerUpdatedAt: toIso(row.provider_updated_at),\n metadata: row.metadata,\n };\n }\n\n private rowToSubscriptionState(r: Record<string, unknown>): BillingSubscriptionState {\n return {\n subscriptionId: r.id ? String(r.id) : null,\n userId: String(r.user_id),\n provider: String(r.provider),\n providerSubscriptionId: String(r.provider_subscription_id),\n providerCustomerId: r.provider_customer_id ? String(r.provider_customer_id) : null,\n offerId: r.offer_id ? String(r.offer_id) : null,\n offerKey: r.offer_key ? String(r.offer_key) : null,\n plan: r.plan ? String(r.plan) : null,\n status: (r.status ? String(r.status) : \"incomplete\") as BillingSubscriptionStatus,\n currentPeriodStart: toIso(r.current_period_start),\n currentPeriodEnd: toIso(r.current_period_end),\n trialEnd: toIso(r.trial_end),\n cancelAt: toIso(r.cancel_at),\n endedAt: toIso(r.ended_at),\n graceEndsAt: toIso(r.grace_ends_at),\n graceExpiredAt: toIso(r.grace_expired_at),\n providerUpdatedAt: toIso(r.provider_updated_at),\n cancelAtPeriodEnd: Boolean(r.cancel_at_period_end),\n interval: r.interval ? String(r.interval) : null,\n intervalCount: r.interval_count ? Number(r.interval_count) : null,\n metadata:\n r.metadata && typeof r.metadata === \"object\"\n ? (r.metadata as Record<string, unknown>)\n : null,\n };\n }\n\n private async getSubscriptionOfferContexts(r: Record<string, unknown>): Promise<{\n fromOffer: BillingSubscriptionOfferContext;\n toOffer: BillingSubscriptionOfferContext;\n }> {\n const rows = await this.queryFn(\n `SELECT requested.side, requested.offer_id, context.*\n FROM (\n VALUES\n ('from', $1::uuid, $2::uuid),\n ('to', $3::uuid, $4::uuid)\n ) AS requested(side, offer_id, catalog_revision_id)\n CROSS JOIN LATERAL bursar.get_catalog_offer_context(\n requested.offer_id,\n requested.catalog_revision_id\n ) AS context`,\n [r.from_offer_id, r.from_catalog_revision_id, r.to_offer_id, r.to_catalog_revision_id],\n );\n const bySide = new Map(\n rows.map((row) => {\n const context = row as Record<string, unknown>;\n return [String(context.side), context] as const;\n }),\n );\n const mapContext = (side: \"from\" | \"to\"): BillingSubscriptionOfferContext => {\n const context = bySide.get(side);\n if (context?.offer_key == null) {\n throw new Error(`subscription change ${side}-offer context not found`);\n }\n return {\n offerId: String(context.offer_id),\n offerKey: String(context.offer_key),\n planId: context.plan_id ? String(context.plan_id) : null,\n plan: context.plan_key ? String(context.plan_key) : null,\n interval: context.billing_unit ? String(context.billing_unit) : null,\n intervalCount: context.billing_count == null ? null : Number(context.billing_count),\n };\n };\n return { fromOffer: mapContext(\"from\"), toOffer: mapContext(\"to\") };\n }\n\n private async rowToSubscriptionChange(\n r: Record<string, unknown>,\n ): Promise<BillingSubscriptionChange> {\n const { fromOffer, toOffer } = await this.getSubscriptionOfferContexts(r);\n return {\n id: String(r.id),\n subscriptionId: String(r.subscription_id),\n fromOfferId: String(r.from_offer_id),\n toOfferId: String(r.to_offer_id),\n fromOffer,\n toOffer,\n effectiveAt: toIso(r.effective_at),\n effective: String(r.effective_behavior) as BillingSubscriptionChange[\"effective\"],\n state: String(r.state) as BillingSubscriptionChange[\"state\"],\n prorationBehavior: String(\n r.proration_behavior,\n ) as BillingSubscriptionChange[\"prorationBehavior\"],\n idempotencyKey: String(r.idempotency_key),\n providerOperationId: r.provider_operation_id ? String(r.provider_operation_id) : null,\n errorMessage: r.error_message ? String(r.error_message) : null,\n };\n }\n\n async getActiveBursarConfig(): Promise<Record<string, unknown> | null> {\n const rows = await this.queryFn(\"SELECT * FROM bursar.active_catalog_revision()\", []);\n if (!rows || rows.length === 0) return null;\n return (\n ((rows[0] as Record<string, unknown>)?.source_document as Record<string, unknown> | null) ??\n null\n );\n }\n\n async pseudonymizeFinancialSubject(userId: string): Promise<boolean> {\n const rows = await this.queryFn(\n `SELECT bursar.pseudonymize_financial_subject($1::uuid) AS pseudonymized`,\n [userId],\n );\n return (rows[0] as Record<string, unknown> | undefined)?.pseudonymized === true;\n }\n\n async getBillingPreferences(userId: string): Promise<BillingPreferences | null> {\n const row = await this.billingPreferences.get(userId);\n if (!row || row.subject_id == null) return null;\n return {\n userId: String(row.subject_id),\n autoRecharge: Boolean(row.auto_recharge),\n overageProtection: Boolean(row.overage_protection),\n emailNotifications: Boolean(row.email_notifications),\n usageAlerts: Boolean(row.usage_alerts),\n invoiceReminders: Boolean(row.invoice_reminders),\n };\n }\n\n async upsertBillingPreferences(prefs: BillingPreferences): Promise<void> {\n await this.billingPreferences.upsert({\n userId: prefs.userId,\n autoRecharge: prefs.autoRecharge,\n overageProtection: prefs.overageProtection,\n emailNotifications: prefs.emailNotifications,\n usageAlerts: prefs.usageAlerts,\n invoiceReminders: prefs.invoiceReminders,\n });\n }\n\n async getAutoRechargeProfile(userId: string): Promise<BillingAutoRechargeProfile | null> {\n return this.billingAutoRecharge.getProfile(userId);\n }\n\n async upsertAutoRechargeProfile(\n profile: BillingAutoRechargeProfile,\n options?: { resetCooldown?: boolean },\n ): Promise<void> {\n return this.billingAutoRecharge.upsertProfile(profile, options);\n }\n\n async claimAutoRechargeAttempt(\n input: AutoRechargeAttemptClaim,\n ): Promise<BillingAutoRechargeAttempt | null> {\n return this.billingAutoRecharge.claimAttempt(input);\n }\n\n async updateAutoRechargeAttempt(input: AutoRechargeAttemptUpdate): Promise<void> {\n return this.billingAutoRecharge.updateAttempt(input);\n }\n\n async updateAutoRechargeAttemptByProviderPayment(\n input: AutoRechargeProviderPaymentUpdate,\n ): Promise<void> {\n return this.billingAutoRecharge.updateAttemptByProviderPayment(input);\n }\n\n async countAutoRechargeAttempts(userId: string, since: string | Date): Promise<number> {\n return this.billingAutoRecharge.countAttempts(userId, since);\n }\n\n async getBillingCustomerByUserId(\n userId: string,\n provider?: string | null,\n ): Promise<BillingCustomerRecord | null> {\n const result = await this.billingCustomer.getByUserId(userId, provider ?? null);\n if (!result) return null;\n return {\n provider: result.provider,\n providerCustomerId: result.providerCustomerId,\n };\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import type Decimal from "decimal.js";
2
+ import type { Logger } from "../shared/logger.js";
3
+ import type { BillingEventHandler, BillingEventType } from "./types/index.js";
4
+ export type ResolveUser = (provider: string, providerCustomerId: string | null, email: string | null) => string | null;
5
+ export interface BillingServiceOptions {
6
+ provisioning?: BillingProvisioningPort | null;
7
+ resolveUser?: ResolveUser | null;
8
+ eventHandlers?: Partial<Record<BillingEventType, BillingEventHandler>>;
9
+ autoSelectEntitlementSource?: boolean;
10
+ /** Access grace after a failed subscription payment. Defaults to seven days. */
11
+ pastDueGracePeriodMs?: number;
12
+ /** Plan assigned when a paid subscription reaches terminal state. */
13
+ terminalPlanKey?: string | null;
14
+ logger?: Logger | null;
15
+ }
16
+ /**
17
+ * The narrow credit capability billing may request during subscription
18
+ * provisioning. Billing does not depend on the full credit service.
19
+ */
20
+ export interface BillingProvisioningPort {
21
+ getUserPlan?(userId: string): Promise<{
22
+ planAssignedAt?: Date | string | null;
23
+ } | null>;
24
+ setUserPlan(userId: string, planKey: string, planAssignedAt?: Date | null): Promise<void>;
25
+ unsetUserPlan(userId: string): Promise<void>;
26
+ addCredits(userId: string, amount: Decimal | number, options?: {
27
+ type?: string;
28
+ bucket?: string | null;
29
+ idempotencyKey?: string | null;
30
+ }): Promise<unknown>;
31
+ deductCredits(userId: string, amount: Decimal | number, options?: {
32
+ entryType?: string;
33
+ bucket?: string | null;
34
+ }): Promise<unknown>;
35
+ revokeCreditsByEntryType(userId: string, entryType: string): Promise<unknown>;
36
+ }
37
+ //# sourceMappingURL=service-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-types.d.ts","sourceRoot":"","sources":["../../src/billing/service-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,CACxB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,KAAK,EAAE,MAAM,GAAG,IAAI,KACjB,MAAM,GAAG,IAAI,CAAC;AAEnB,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAC,CAAC;IACvE,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,gFAAgF;IAChF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACxF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,UAAU,CACR,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,GACA,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,aAAa,CACX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,OAAO,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GACvD,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=service-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../src/billing/service-types.ts"],"names":[],"mappings":"","sourcesContent":["import type Decimal from \"decimal.js\";\n\nimport type { Logger } from \"../shared/logger.js\";\nimport type { BillingEventHandler, BillingEventType } from \"./types/index.js\";\n\nexport type ResolveUser = (\n provider: string,\n providerCustomerId: string | null,\n email: string | null,\n) => string | null;\n\nexport interface BillingServiceOptions {\n provisioning?: BillingProvisioningPort | null;\n resolveUser?: ResolveUser | null;\n eventHandlers?: Partial<Record<BillingEventType, BillingEventHandler>>;\n autoSelectEntitlementSource?: boolean;\n /** Access grace after a failed subscription payment. Defaults to seven days. */\n pastDueGracePeriodMs?: number;\n /** Plan assigned when a paid subscription reaches terminal state. */\n terminalPlanKey?: string | null;\n logger?: Logger | null;\n}\n\n/**\n * The narrow credit capability billing may request during subscription\n * provisioning. Billing does not depend on the full credit service.\n */\nexport interface BillingProvisioningPort {\n getUserPlan?(userId: string): Promise<{ planAssignedAt?: Date | string | null } | null>;\n setUserPlan(userId: string, planKey: string, planAssignedAt?: Date | null): Promise<void>;\n unsetUserPlan(userId: string): Promise<void>;\n addCredits(\n userId: string,\n amount: Decimal | number,\n options?: {\n type?: string;\n bucket?: string | null;\n idempotencyKey?: string | null;\n },\n ): Promise<unknown>;\n deductCredits(\n userId: string,\n amount: Decimal | number,\n options?: { entryType?: string; bucket?: string | null },\n ): Promise<unknown>;\n revokeCreditsByEntryType(userId: string, entryType: string): Promise<unknown>;\n}\n"]}
@@ -0,0 +1,56 @@
1
+ export declare const AUTO_RECHARGE_STATES: readonly ["disabled", "active", "paused"];
2
+ export type BillingAutoRechargeState = (typeof AUTO_RECHARGE_STATES)[number];
3
+ export interface BillingAutoRechargeProfile {
4
+ userId: string;
5
+ enabled: boolean;
6
+ state: BillingAutoRechargeState;
7
+ armed?: boolean;
8
+ provider: string | null;
9
+ topupId: string | null;
10
+ quantity: number;
11
+ threshold: number;
12
+ maxChargesPerWindow: number | null;
13
+ windowUnit: "second" | "minute" | "hour" | "day" | "week" | "month" | "year";
14
+ windowCount: number;
15
+ windowAnchor: "calendar" | "plan_assignment" | "rolling";
16
+ windowTimezone: string;
17
+ updatedAt?: string | null;
18
+ }
19
+ export interface BillingAutoRechargeAttempt {
20
+ id: string;
21
+ userId: string;
22
+ provider: string;
23
+ idempotencyKey: string;
24
+ providerAttemptId: string | null;
25
+ topupId: string;
26
+ quantity: number;
27
+ state: "claimed" | "submitted" | "processing" | "unknown" | "succeeded" | "failed" | "action_required";
28
+ windowStart: string;
29
+ windowEnd: string;
30
+ quotedAmountMinor: number | null;
31
+ currency: string | null;
32
+ failureCode: string | null;
33
+ failureMessage: string | null;
34
+ metadata: Record<string, unknown>;
35
+ createdAt: string;
36
+ updatedAt: string;
37
+ }
38
+ export interface BillingAutoRechargeStatus {
39
+ enabled: boolean;
40
+ state: BillingAutoRechargeState;
41
+ thresholdCredits: number;
42
+ topupKey: string;
43
+ quantity: number;
44
+ maxRecharges: number;
45
+ windowStart: string;
46
+ windowEnd: string;
47
+ rechargesInWindow: number;
48
+ paymentMethodId: string | null;
49
+ paymentMethodLast4: string | null;
50
+ paymentMethodBrand: string | null;
51
+ suspendedReason: string | null;
52
+ pendingAttemptId: string | null;
53
+ quoteAmountMinor: number | null;
54
+ quoteCurrency: string | null;
55
+ }
56
+ //# sourceMappingURL=auto-recharge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-recharge.d.ts","sourceRoot":"","sources":["../../../src/billing/types/auto-recharge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,2CAA4C,CAAC;AAC9E,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,wBAAwB,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,UAAU,GAAG,iBAAiB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AAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B"}
@@ -0,0 +1,2 @@
1
+ export const AUTO_RECHARGE_STATES = ["disabled", "active", "paused"];
2
+ //# sourceMappingURL=auto-recharge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-recharge.js","sourceRoot":"","sources":["../../../src/billing/types/auto-recharge.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAC","sourcesContent":["export const AUTO_RECHARGE_STATES = [\"disabled\", \"active\", \"paused\"] as const;\nexport type BillingAutoRechargeState = (typeof AUTO_RECHARGE_STATES)[number];\n\nexport interface BillingAutoRechargeProfile {\n userId: string;\n enabled: boolean;\n state: BillingAutoRechargeState;\n armed?: boolean;\n provider: string | null;\n topupId: string | null;\n quantity: number;\n threshold: number;\n maxChargesPerWindow: number | null;\n windowUnit: \"second\" | \"minute\" | \"hour\" | \"day\" | \"week\" | \"month\" | \"year\";\n windowCount: number;\n windowAnchor: \"calendar\" | \"plan_assignment\" | \"rolling\";\n windowTimezone: string;\n updatedAt?: string | null;\n}\n\nexport interface BillingAutoRechargeAttempt {\n id: string;\n userId: string;\n provider: string;\n idempotencyKey: string;\n providerAttemptId: string | null;\n topupId: string;\n quantity: number;\n state:\n \"claimed\" | \"submitted\" | \"processing\" | \"unknown\" | \"succeeded\" | \"failed\" | \"action_required\";\n windowStart: string;\n windowEnd: string;\n quotedAmountMinor: number | null;\n currency: string | null;\n failureCode: string | null;\n failureMessage: string | null;\n metadata: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface BillingAutoRechargeStatus {\n enabled: boolean;\n state: BillingAutoRechargeState;\n thresholdCredits: number;\n topupKey: string;\n quantity: number;\n maxRecharges: number;\n windowStart: string;\n windowEnd: string;\n rechargesInWindow: number;\n paymentMethodId: string | null;\n paymentMethodLast4: string | null;\n paymentMethodBrand: string | null;\n suspendedReason: string | null;\n pendingAttemptId: string | null;\n quoteAmountMinor: number | null;\n quoteCurrency: string | null;\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import type { BillingOfferInterval, ProviderRef, SubscriptionGrant } from "./common.js";
2
+ export interface BillingGrantResult {
3
+ mode?: string;
4
+ credits?: number | null;
5
+ bucket?: string;
6
+ replacePrior?: boolean;
7
+ }
8
+ export interface BillingOfferResult {
9
+ offerId: string;
10
+ offerKey: string;
11
+ planId?: string | null;
12
+ plan?: string | null;
13
+ interval?: string;
14
+ intervalCount?: number;
15
+ grant?: BillingGrantResult;
16
+ }
17
+ export interface BillingTopupResult {
18
+ topupId: string;
19
+ topupKey: string;
20
+ creditsPerUnit?: number;
21
+ depositTo?: string;
22
+ amountMinor?: number;
23
+ currency?: string;
24
+ minQuantity?: number;
25
+ maxQuantity?: number;
26
+ defaultQuantity?: number;
27
+ minAmountMinor?: number;
28
+ maxAmountMinor?: number;
29
+ }
30
+ export interface BillingOffer {
31
+ plan: string;
32
+ interval?: BillingOfferInterval;
33
+ intervalCount?: number;
34
+ grant?: SubscriptionGrant;
35
+ providers?: Record<string, ProviderRef>;
36
+ validFrom?: string | null;
37
+ validTo?: string | null;
38
+ }
39
+ export interface BillingCreditTopup {
40
+ depositTo: string;
41
+ creditsPerUnit?: number;
42
+ minAmountMinor?: number;
43
+ maxAmountMinor?: number;
44
+ taxBehavior?: "exclude_tax" | "include_tax";
45
+ providers?: Record<string, ProviderRef>;
46
+ }
47
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/billing/types/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBA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G,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/billing/types/catalog.ts"],"names":[],"mappings":"","sourcesContent":["import type { BillingOfferInterval, ProviderRef, SubscriptionGrant } from \"./common.js\";\n\nexport interface BillingGrantResult {\n mode?: string;\n credits?: number | null;\n bucket?: string;\n replacePrior?: boolean;\n}\n\nexport interface BillingOfferResult {\n offerId: string;\n offerKey: string;\n planId?: string | null;\n plan?: string | null;\n interval?: string;\n intervalCount?: number;\n grant?: BillingGrantResult;\n}\n\nexport interface BillingTopupResult {\n topupId: string;\n topupKey: string;\n creditsPerUnit?: number;\n depositTo?: string;\n amountMinor?: number;\n currency?: string;\n minQuantity?: number;\n maxQuantity?: number;\n defaultQuantity?: number;\n minAmountMinor?: number;\n maxAmountMinor?: number;\n}\n\nexport interface BillingOffer {\n plan: string;\n interval?: BillingOfferInterval;\n intervalCount?: number;\n grant?: SubscriptionGrant;\n providers?: Record<string, ProviderRef>;\n validFrom?: string | null;\n validTo?: string | null;\n}\n\nexport interface BillingCreditTopup {\n depositTo: string;\n creditsPerUnit?: number;\n minAmountMinor?: number;\n maxAmountMinor?: number;\n taxBehavior?: \"exclude_tax\" | \"include_tax\";\n providers?: Record<string, ProviderRef>;\n}\n"]}
@@ -0,0 +1,16 @@
1
+ export type BillingProvider = "stripe" | "dodo" | "mock";
2
+ export type BillingOfferInterval = "day" | "week" | "month" | "year";
3
+ export type EntitlementMode = "allowance" | "cycle_grant";
4
+ export interface ProviderRef {
5
+ productId?: string | null;
6
+ priceId?: string | null;
7
+ variantId?: string | null;
8
+ lookupKey?: string | null;
9
+ }
10
+ export interface SubscriptionGrant {
11
+ mode?: EntitlementMode;
12
+ credits?: number | null;
13
+ bucket?: string | null;
14
+ replacePrior?: boolean;
15
+ }
16
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/billing/types/common.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzD,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAErE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,aAAa,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/billing/types/common.ts"],"names":[],"mappings":"","sourcesContent":["export type BillingProvider = \"stripe\" | \"dodo\" | \"mock\";\n\nexport type BillingOfferInterval = \"day\" | \"week\" | \"month\" | \"year\";\n\nexport type EntitlementMode = \"allowance\" | \"cycle_grant\";\n\nexport interface ProviderRef {\n productId?: string | null;\n priceId?: string | null;\n variantId?: string | null;\n lookupKey?: string | null;\n}\n\nexport interface SubscriptionGrant {\n mode?: EntitlementMode;\n credits?: number | null;\n bucket?: string | null;\n replacePrior?: boolean;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import type { ProviderRef } from "./common.js";
2
+ export interface BillingCustomerInfo {
3
+ providerCustomerId?: string | null;
4
+ email?: string | null;
5
+ }
6
+ export interface BillingInvoiceInfo {
7
+ provider?: string;
8
+ providerInvoiceId: string;
9
+ status?: string | null;
10
+ amountPaidMinor?: number | null;
11
+ amountDueMinor?: number | null;
12
+ currency?: string | null;
13
+ periodStart?: string | null;
14
+ periodEnd?: string | null;
15
+ }
16
+ export interface BillingPaymentInfo {
17
+ providerPaymentId: string;
18
+ amountMinor: number;
19
+ taxMinor?: number | null;
20
+ currency: string;
21
+ refs?: ProviderRef | null;
22
+ purpose: "subscription" | "credit_topup" | "unknown";
23
+ status?: "pending" | "succeeded" | "failed" | "canceled";
24
+ }
25
+ export interface BillingRefundInfo {
26
+ providerRefundId: string;
27
+ providerPaymentId?: string | null;
28
+ amountMinor: number;
29
+ currency: string;
30
+ reason?: string | null;
31
+ status?: "pending" | "succeeded" | "failed" | "canceled";
32
+ }
33
+ export interface BillingDisputeInfo {
34
+ providerDisputeId: string;
35
+ providerPaymentId?: string | null;
36
+ status?: string | null;
37
+ reason?: string | null;
38
+ }
39
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../src/billing/types/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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E,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["../../../src/billing/types/documents.ts"],"names":[],"mappings":"","sourcesContent":["import type { ProviderRef } from \"./common.js\";\n\nexport interface BillingCustomerInfo {\n providerCustomerId?: string | null;\n email?: string | null;\n}\n\nexport interface BillingInvoiceInfo {\n provider?: string;\n providerInvoiceId: string;\n status?: string | null;\n amountPaidMinor?: number | null;\n amountDueMinor?: number | null;\n currency?: string | null;\n periodStart?: string | null;\n periodEnd?: string | null;\n}\n\nexport interface BillingPaymentInfo {\n providerPaymentId: string;\n amountMinor: number;\n taxMinor?: number | null;\n currency: string;\n refs?: ProviderRef | null;\n purpose: \"subscription\" | \"credit_topup\" | \"unknown\";\n status?: \"pending\" | \"succeeded\" | \"failed\" | \"canceled\";\n}\n\nexport interface BillingRefundInfo {\n providerRefundId: string;\n providerPaymentId?: string | null;\n amountMinor: number;\n currency: string;\n reason?: string | null;\n status?: \"pending\" | \"succeeded\" | \"failed\" | \"canceled\";\n}\n\nexport interface BillingDisputeInfo {\n providerDisputeId: string;\n providerPaymentId?: string | null;\n status?: string | null;\n reason?: string | null;\n}\n"]}
@@ -0,0 +1,75 @@
1
+ import type { BillingCustomerInfo, BillingDisputeInfo, BillingInvoiceInfo, BillingPaymentInfo, BillingRefundInfo } from "./documents.js";
2
+ import type { BillingSubscriptionInfo } from "./subscriptions.js";
3
+ export declare const BillingEventType: {
4
+ readonly CUSTOMER_CREATED: "customer.created";
5
+ readonly CUSTOMER_UPDATED: "customer.updated";
6
+ readonly CUSTOMER_DELETED: "customer.deleted";
7
+ readonly CHECKOUT_COMPLETED: "checkout.completed";
8
+ readonly CHECKOUT_EXPIRED: "checkout.expired";
9
+ readonly SUBSCRIPTION_CREATED: "subscription.created";
10
+ readonly SUBSCRIPTION_UPDATED: "subscription.updated";
11
+ readonly SUBSCRIPTION_ACTIVATED: "subscription.activated";
12
+ readonly SUBSCRIPTION_RENEWED: "subscription.renewed";
13
+ readonly SUBSCRIPTION_PLAN_CHANGED: "subscription.plan_changed";
14
+ readonly SUBSCRIPTION_CANCELLATION_SCHEDULED: "subscription.cancellation_scheduled";
15
+ readonly SUBSCRIPTION_CANCELLATION_UNSCHEDULED: "subscription.cancellation_unscheduled";
16
+ readonly SUBSCRIPTION_CANCELED: "subscription.canceled";
17
+ readonly SUBSCRIPTION_EXPIRED: "subscription.expired";
18
+ readonly SUBSCRIPTION_PAUSED: "subscription.paused";
19
+ readonly SUBSCRIPTION_RESUMED: "subscription.resumed";
20
+ readonly SUBSCRIPTION_TRIAL_WILL_END: "subscription.trial_will_end";
21
+ readonly INVOICE_CREATED: "invoice.created";
22
+ readonly INVOICE_FINALIZED: "invoice.finalized";
23
+ readonly INVOICE_FINALIZATION_FAILED: "invoice.finalization_failed";
24
+ readonly INVOICE_UPCOMING: "invoice.upcoming";
25
+ readonly INVOICE_PAID: "invoice.paid";
26
+ readonly INVOICE_PAYMENT_FAILED: "invoice.payment_failed";
27
+ readonly INVOICE_PAYMENT_ACTION_REQUIRED: "invoice.payment_action_required";
28
+ readonly INVOICE_VOIDED: "invoice.voided";
29
+ readonly PAYMENT_SUCCEEDED: "payment.succeeded";
30
+ readonly PAYMENT_FAILED: "payment.failed";
31
+ readonly REFUND_CREATED: "refund.created";
32
+ readonly REFUND_UPDATED: "refund.updated";
33
+ readonly REFUND_FAILED: "refund.failed";
34
+ readonly DISPUTE_CREATED: "dispute.created";
35
+ readonly DISPUTE_CLOSED: "dispute.closed";
36
+ readonly PAYMENT_METHOD_ATTACHED: "payment_method.attached";
37
+ readonly PAYMENT_METHOD_UPDATED: "payment_method.updated";
38
+ readonly PAYMENT_METHOD_DETACHED: "payment_method.detached";
39
+ };
40
+ export type BillingEventType = (typeof BillingEventType)[keyof typeof BillingEventType];
41
+ export interface BillingEvent {
42
+ provider: string;
43
+ eventId: string;
44
+ eventType: BillingEventType;
45
+ occurredAt: string;
46
+ userId?: string | null;
47
+ customer?: BillingCustomerInfo | null;
48
+ subscription?: BillingSubscriptionInfo | null;
49
+ invoice?: BillingInvoiceInfo | null;
50
+ payment?: BillingPaymentInfo | null;
51
+ refund?: BillingRefundInfo | null;
52
+ dispute?: BillingDisputeInfo | null;
53
+ metadata?: Record<string, unknown> | null;
54
+ raw?: unknown;
55
+ billingEventId?: string;
56
+ }
57
+ export type BillingEventHandler = (event: BillingEvent, userId: string) => Promise<void>;
58
+ export interface BillingEventResult {
59
+ handled: boolean;
60
+ action?: string | null;
61
+ error?: string | null;
62
+ subscriptionId?: string | null;
63
+ }
64
+ export type BillingEventClaim = {
65
+ status: "claimed";
66
+ claimToken: string;
67
+ billingEventId: string;
68
+ } | {
69
+ status: "duplicate";
70
+ } | {
71
+ status: "busy";
72
+ } | {
73
+ status: "retry";
74
+ };
75
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/billing/types/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCnB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC;AAExF,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAA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 CHECKOUT_COMPLETED: "checkout.completed",
6
+ CHECKOUT_EXPIRED: "checkout.expired",
7
+ SUBSCRIPTION_CREATED: "subscription.created",
8
+ SUBSCRIPTION_UPDATED: "subscription.updated",
9
+ SUBSCRIPTION_ACTIVATED: "subscription.activated",
10
+ SUBSCRIPTION_RENEWED: "subscription.renewed",
11
+ SUBSCRIPTION_PLAN_CHANGED: "subscription.plan_changed",
12
+ SUBSCRIPTION_CANCELLATION_SCHEDULED: "subscription.cancellation_scheduled",
13
+ SUBSCRIPTION_CANCELLATION_UNSCHEDULED: "subscription.cancellation_unscheduled",
14
+ SUBSCRIPTION_CANCELED: "subscription.canceled",
15
+ SUBSCRIPTION_EXPIRED: "subscription.expired",
16
+ SUBSCRIPTION_PAUSED: "subscription.paused",
17
+ SUBSCRIPTION_RESUMED: "subscription.resumed",
18
+ SUBSCRIPTION_TRIAL_WILL_END: "subscription.trial_will_end",
19
+ INVOICE_CREATED: "invoice.created",
20
+ INVOICE_FINALIZED: "invoice.finalized",
21
+ INVOICE_FINALIZATION_FAILED: "invoice.finalization_failed",
22
+ INVOICE_UPCOMING: "invoice.upcoming",
23
+ INVOICE_PAID: "invoice.paid",
24
+ INVOICE_PAYMENT_FAILED: "invoice.payment_failed",
25
+ INVOICE_PAYMENT_ACTION_REQUIRED: "invoice.payment_action_required",
26
+ INVOICE_VOIDED: "invoice.voided",
27
+ PAYMENT_SUCCEEDED: "payment.succeeded",
28
+ PAYMENT_FAILED: "payment.failed",
29
+ REFUND_CREATED: "refund.created",
30
+ REFUND_UPDATED: "refund.updated",
31
+ REFUND_FAILED: "refund.failed",
32
+ DISPUTE_CREATED: "dispute.created",
33
+ DISPUTE_CLOSED: "dispute.closed",
34
+ PAYMENT_METHOD_ATTACHED: "payment_method.attached",
35
+ PAYMENT_METHOD_UPDATED: "payment_method.updated",
36
+ PAYMENT_METHOD_DETACHED: "payment_method.detached",
37
+ };
38
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/billing/types/events.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,gBAAgB,EAAE,kBAAkB;IACpC,kBAAkB,EAAE,oBAAoB;IACxC,gBAAgB,EAAE,kBAAkB;IACpC,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,sBAAsB,EAAE,wBAAwB;IAChD,oBAAoB,EAAE,sBAAsB;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,mCAAmC,EAAE,qCAAqC;IAC1E,qCAAqC,EAAE,uCAAuC;IAC9E,qBAAqB,EAAE,uBAAuB;IAC9C,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,2BAA2B,EAAE,6BAA6B;IAC1D,eAAe,EAAE,iBAAiB;IAClC,iBAAiB,EAAE,mBAAmB;IACtC,2BAA2B,EAAE,6BAA6B;IAC1D,gBAAgB,EAAE,kBAAkB;IACpC,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,+BAA+B,EAAE,iCAAiC;IAClE,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,eAAe;IAC9B,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,uBAAuB,EAAE,yBAAyB;IAClD,sBAAsB,EAAE,wBAAwB;IAChD,uBAAuB,EAAE,yBAAyB;CAC1C,CAAC","sourcesContent":["import type {\n BillingCustomerInfo,\n BillingDisputeInfo,\n BillingInvoiceInfo,\n BillingPaymentInfo,\n BillingRefundInfo,\n} from \"./documents.js\";\nimport type { BillingSubscriptionInfo } from \"./subscriptions.js\";\n\nexport const BillingEventType = {\n CUSTOMER_CREATED: \"customer.created\",\n CUSTOMER_UPDATED: \"customer.updated\",\n CUSTOMER_DELETED: \"customer.deleted\",\n CHECKOUT_COMPLETED: \"checkout.completed\",\n CHECKOUT_EXPIRED: \"checkout.expired\",\n SUBSCRIPTION_CREATED: \"subscription.created\",\n SUBSCRIPTION_UPDATED: \"subscription.updated\",\n SUBSCRIPTION_ACTIVATED: \"subscription.activated\",\n SUBSCRIPTION_RENEWED: \"subscription.renewed\",\n SUBSCRIPTION_PLAN_CHANGED: \"subscription.plan_changed\",\n SUBSCRIPTION_CANCELLATION_SCHEDULED: \"subscription.cancellation_scheduled\",\n SUBSCRIPTION_CANCELLATION_UNSCHEDULED: \"subscription.cancellation_unscheduled\",\n SUBSCRIPTION_CANCELED: \"subscription.canceled\",\n SUBSCRIPTION_EXPIRED: \"subscription.expired\",\n SUBSCRIPTION_PAUSED: \"subscription.paused\",\n SUBSCRIPTION_RESUMED: \"subscription.resumed\",\n SUBSCRIPTION_TRIAL_WILL_END: \"subscription.trial_will_end\",\n INVOICE_CREATED: \"invoice.created\",\n INVOICE_FINALIZED: \"invoice.finalized\",\n INVOICE_FINALIZATION_FAILED: \"invoice.finalization_failed\",\n INVOICE_UPCOMING: \"invoice.upcoming\",\n INVOICE_PAID: \"invoice.paid\",\n INVOICE_PAYMENT_FAILED: \"invoice.payment_failed\",\n INVOICE_PAYMENT_ACTION_REQUIRED: \"invoice.payment_action_required\",\n INVOICE_VOIDED: \"invoice.voided\",\n PAYMENT_SUCCEEDED: \"payment.succeeded\",\n PAYMENT_FAILED: \"payment.failed\",\n REFUND_CREATED: \"refund.created\",\n REFUND_UPDATED: \"refund.updated\",\n REFUND_FAILED: \"refund.failed\",\n DISPUTE_CREATED: \"dispute.created\",\n DISPUTE_CLOSED: \"dispute.closed\",\n PAYMENT_METHOD_ATTACHED: \"payment_method.attached\",\n PAYMENT_METHOD_UPDATED: \"payment_method.updated\",\n PAYMENT_METHOD_DETACHED: \"payment_method.detached\",\n} as const;\n\nexport type BillingEventType = (typeof BillingEventType)[keyof typeof BillingEventType];\n\nexport interface BillingEvent {\n provider: string;\n eventId: string;\n eventType: BillingEventType;\n occurredAt: string;\n userId?: string | null;\n customer?: BillingCustomerInfo | null;\n subscription?: BillingSubscriptionInfo | null;\n invoice?: BillingInvoiceInfo | null;\n payment?: BillingPaymentInfo | null;\n refund?: BillingRefundInfo | null;\n dispute?: BillingDisputeInfo | null;\n metadata?: Record<string, unknown> | null;\n raw?: unknown;\n billingEventId?: string;\n}\n\nexport type BillingEventHandler = (event: BillingEvent, userId: string) => Promise<void>;\n\nexport interface BillingEventResult {\n handled: boolean;\n action?: string | null;\n error?: string | null;\n subscriptionId?: string | null;\n}\n\nexport type BillingEventClaim =\n | { status: \"claimed\"; claimToken: string; billingEventId: string }\n | { status: \"duplicate\" }\n | { status: \"busy\" }\n | { status: \"retry\" };\n"]}
@@ -0,0 +1,8 @@
1
+ export * from "./common.js";
2
+ export * from "./documents.js";
3
+ export * from "./events.js";
4
+ export * from "./subscriptions.js";
5
+ export * from "./catalog.js";
6
+ export * from "./auto-recharge.js";
7
+ export * from "./preferences.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/billing/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./common.js";
2
+ export * from "./documents.js";
3
+ export * from "./events.js";
4
+ export * from "./subscriptions.js";
5
+ export * from "./catalog.js";
6
+ export * from "./auto-recharge.js";
7
+ export * from "./preferences.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/billing/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC","sourcesContent":["export * from \"./common.js\";\nexport * from \"./documents.js\";\nexport * from \"./events.js\";\nexport * from \"./subscriptions.js\";\nexport * from \"./catalog.js\";\nexport * from \"./auto-recharge.js\";\nexport * from \"./preferences.js\";\n"]}
@@ -0,0 +1,13 @@
1
+ export interface BillingPreferences {
2
+ userId: string;
3
+ autoRecharge: boolean;
4
+ overageProtection: boolean;
5
+ emailNotifications: boolean;
6
+ usageAlerts: boolean;
7
+ invoiceReminders: boolean;
8
+ }
9
+ export interface BillingCustomerRecord {
10
+ provider: string;
11
+ providerCustomerId: string;
12
+ }
13
+ //# sourceMappingURL=preferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.d.ts","sourceRoot":"","sources":["../../../src/billing/types/preferences.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=preferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../../src/billing/types/preferences.ts"],"names":[],"mappings":"","sourcesContent":["export interface BillingPreferences {\n userId: string;\n autoRecharge: boolean;\n overageProtection: boolean;\n emailNotifications: boolean;\n usageAlerts: boolean;\n invoiceReminders: boolean;\n}\n\nexport interface BillingCustomerRecord {\n provider: string;\n providerCustomerId: string;\n}\n"]}