@adonis-agora/payments 0.2.0

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 (222) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/commands/main.d.ts +16 -0
  3. package/dist/commands/main.d.ts.map +1 -0
  4. package/dist/commands/main.js +17 -0
  5. package/dist/commands/main.js.map +1 -0
  6. package/dist/commands/make_billable.d.ts +16 -0
  7. package/dist/commands/make_billable.d.ts.map +1 -0
  8. package/dist/commands/make_billable.js +30 -0
  9. package/dist/commands/make_billable.js.map +1 -0
  10. package/dist/commands/make_webhook_handler.d.ts +20 -0
  11. package/dist/commands/make_webhook_handler.d.ts.map +1 -0
  12. package/dist/commands/make_webhook_handler.js +34 -0
  13. package/dist/commands/make_webhook_handler.js.map +1 -0
  14. package/dist/commands/payments_sync.d.ts +20 -0
  15. package/dist/commands/payments_sync.d.ts.map +1 -0
  16. package/dist/commands/payments_sync.js +95 -0
  17. package/dist/commands/payments_sync.js.map +1 -0
  18. package/dist/commands/payments_webhook.d.ts +19 -0
  19. package/dist/commands/payments_webhook.d.ts.map +1 -0
  20. package/dist/commands/payments_webhook.js +123 -0
  21. package/dist/commands/payments_webhook.js.map +1 -0
  22. package/dist/configure.d.ts +12 -0
  23. package/dist/configure.d.ts.map +1 -0
  24. package/dist/configure.js +34 -0
  25. package/dist/configure.js.map +1 -0
  26. package/dist/providers/payments_provider.d.ts +15 -0
  27. package/dist/providers/payments_provider.d.ts.map +1 -0
  28. package/dist/providers/payments_provider.js +155 -0
  29. package/dist/providers/payments_provider.js.map +1 -0
  30. package/dist/src/billing/billing_overview.d.ts +26 -0
  31. package/dist/src/billing/billing_overview.d.ts.map +1 -0
  32. package/dist/src/billing/billing_overview.js +27 -0
  33. package/dist/src/billing/billing_overview.js.map +1 -0
  34. package/dist/src/billing/billing_store.d.ts +73 -0
  35. package/dist/src/billing/billing_store.d.ts.map +1 -0
  36. package/dist/src/billing/billing_store.js +2 -0
  37. package/dist/src/billing/billing_store.js.map +1 -0
  38. package/dist/src/billing/index.d.ts +8 -0
  39. package/dist/src/billing/index.d.ts.map +1 -0
  40. package/dist/src/billing/index.js +6 -0
  41. package/dist/src/billing/index.js.map +1 -0
  42. package/dist/src/billing/lucid_billing_store.d.ts +84 -0
  43. package/dist/src/billing/lucid_billing_store.d.ts.map +1 -0
  44. package/dist/src/billing/lucid_billing_store.js +143 -0
  45. package/dist/src/billing/lucid_billing_store.js.map +1 -0
  46. package/dist/src/billing/metered_bill.d.ts +60 -0
  47. package/dist/src/billing/metered_bill.d.ts.map +1 -0
  48. package/dist/src/billing/metered_bill.js +46 -0
  49. package/dist/src/billing/metered_bill.js.map +1 -0
  50. package/dist/src/billing/mixins/index.d.ts +6 -0
  51. package/dist/src/billing/mixins/index.d.ts.map +1 -0
  52. package/dist/src/billing/mixins/index.js +6 -0
  53. package/dist/src/billing/mixins/index.js.map +1 -0
  54. package/dist/src/billing/mixins/with_billable.d.ts +23 -0
  55. package/dist/src/billing/mixins/with_billable.d.ts.map +1 -0
  56. package/dist/src/billing/mixins/with_billable.js +33 -0
  57. package/dist/src/billing/mixins/with_billable.js.map +1 -0
  58. package/dist/src/billing/mixins/with_payment.d.ts +45 -0
  59. package/dist/src/billing/mixins/with_payment.d.ts.map +1 -0
  60. package/dist/src/billing/mixins/with_payment.js +94 -0
  61. package/dist/src/billing/mixins/with_payment.js.map +1 -0
  62. package/dist/src/billing/mixins/with_subscription.d.ts +50 -0
  63. package/dist/src/billing/mixins/with_subscription.d.ts.map +1 -0
  64. package/dist/src/billing/mixins/with_subscription.js +95 -0
  65. package/dist/src/billing/mixins/with_subscription.js.map +1 -0
  66. package/dist/src/billing/mixins/with_usage_event.d.ts +22 -0
  67. package/dist/src/billing/mixins/with_usage_event.d.ts.map +1 -0
  68. package/dist/src/billing/mixins/with_usage_event.js +39 -0
  69. package/dist/src/billing/mixins/with_usage_event.js.map +1 -0
  70. package/dist/src/billing/mixins/with_webhook_event.d.ts +21 -0
  71. package/dist/src/billing/mixins/with_webhook_event.d.ts.map +1 -0
  72. package/dist/src/billing/mixins/with_webhook_event.js +42 -0
  73. package/dist/src/billing/mixins/with_webhook_event.js.map +1 -0
  74. package/dist/src/billing/webhook_dispatcher.d.ts +79 -0
  75. package/dist/src/billing/webhook_dispatcher.d.ts.map +1 -0
  76. package/dist/src/billing/webhook_dispatcher.js +125 -0
  77. package/dist/src/billing/webhook_dispatcher.js.map +1 -0
  78. package/dist/src/billing/webhook_events.d.ts +49 -0
  79. package/dist/src/billing/webhook_events.d.ts.map +1 -0
  80. package/dist/src/billing/webhook_events.js +44 -0
  81. package/dist/src/billing/webhook_events.js.map +1 -0
  82. package/dist/src/billing/webhook_processor.d.ts +39 -0
  83. package/dist/src/billing/webhook_processor.d.ts.map +1 -0
  84. package/dist/src/billing/webhook_processor.js +209 -0
  85. package/dist/src/billing/webhook_processor.js.map +1 -0
  86. package/dist/src/define_config.d.ts +251 -0
  87. package/dist/src/define_config.d.ts.map +1 -0
  88. package/dist/src/define_config.js +67 -0
  89. package/dist/src/define_config.js.map +1 -0
  90. package/dist/src/diagnostics.d.ts +155 -0
  91. package/dist/src/diagnostics.d.ts.map +1 -0
  92. package/dist/src/diagnostics.js +153 -0
  93. package/dist/src/diagnostics.js.map +1 -0
  94. package/dist/src/driver.d.ts +222 -0
  95. package/dist/src/driver.d.ts.map +1 -0
  96. package/dist/src/driver.js +2 -0
  97. package/dist/src/driver.js.map +1 -0
  98. package/dist/src/drivers/abacate.d.ts +35 -0
  99. package/dist/src/drivers/abacate.d.ts.map +1 -0
  100. package/dist/src/drivers/abacate.js +381 -0
  101. package/dist/src/drivers/abacate.js.map +1 -0
  102. package/dist/src/drivers/asaas.d.ts +36 -0
  103. package/dist/src/drivers/asaas.d.ts.map +1 -0
  104. package/dist/src/drivers/asaas.js +455 -0
  105. package/dist/src/drivers/asaas.js.map +1 -0
  106. package/dist/src/drivers/stripe.d.ts +36 -0
  107. package/dist/src/drivers/stripe.d.ts.map +1 -0
  108. package/dist/src/drivers/stripe.js +392 -0
  109. package/dist/src/drivers/stripe.js.map +1 -0
  110. package/dist/src/drivers/woovi.d.ts +49 -0
  111. package/dist/src/drivers/woovi.d.ts.map +1 -0
  112. package/dist/src/drivers/woovi.js +339 -0
  113. package/dist/src/drivers/woovi.js.map +1 -0
  114. package/dist/src/ensure_customer.d.ts +23 -0
  115. package/dist/src/ensure_customer.d.ts.map +1 -0
  116. package/dist/src/ensure_customer.js +25 -0
  117. package/dist/src/ensure_customer.js.map +1 -0
  118. package/dist/src/hooks/webhook_handlers.d.ts +50 -0
  119. package/dist/src/hooks/webhook_handlers.d.ts.map +1 -0
  120. package/dist/src/hooks/webhook_handlers.js +53 -0
  121. package/dist/src/hooks/webhook_handlers.js.map +1 -0
  122. package/dist/src/http.d.ts +24 -0
  123. package/dist/src/http.d.ts.map +1 -0
  124. package/dist/src/http.js +52 -0
  125. package/dist/src/http.js.map +1 -0
  126. package/dist/src/index.d.ts +29 -0
  127. package/dist/src/index.d.ts.map +1 -0
  128. package/dist/src/index.js +15 -0
  129. package/dist/src/index.js.map +1 -0
  130. package/dist/src/invoice/drivers/asaas.d.ts +23 -0
  131. package/dist/src/invoice/drivers/asaas.d.ts.map +1 -0
  132. package/dist/src/invoice/drivers/asaas.js +85 -0
  133. package/dist/src/invoice/drivers/asaas.js.map +1 -0
  134. package/dist/src/invoice/drivers/enotas.d.ts +23 -0
  135. package/dist/src/invoice/drivers/enotas.d.ts.map +1 -0
  136. package/dist/src/invoice/drivers/enotas.js +83 -0
  137. package/dist/src/invoice/drivers/enotas.js.map +1 -0
  138. package/dist/src/invoice/drivers/focus.d.ts +23 -0
  139. package/dist/src/invoice/drivers/focus.d.ts.map +1 -0
  140. package/dist/src/invoice/drivers/focus.js +90 -0
  141. package/dist/src/invoice/drivers/focus.js.map +1 -0
  142. package/dist/src/invoice/drivers/plugnotas.d.ts +22 -0
  143. package/dist/src/invoice/drivers/plugnotas.d.ts.map +1 -0
  144. package/dist/src/invoice/drivers/plugnotas.js +81 -0
  145. package/dist/src/invoice/drivers/plugnotas.js.map +1 -0
  146. package/dist/src/invoice/drivers/tecnospeed.d.ts +29 -0
  147. package/dist/src/invoice/drivers/tecnospeed.d.ts.map +1 -0
  148. package/dist/src/invoice/drivers/tecnospeed.js +87 -0
  149. package/dist/src/invoice/drivers/tecnospeed.js.map +1 -0
  150. package/dist/src/invoice/emit_invoice.d.ts +45 -0
  151. package/dist/src/invoice/emit_invoice.d.ts.map +1 -0
  152. package/dist/src/invoice/emit_invoice.js +72 -0
  153. package/dist/src/invoice/emit_invoice.js.map +1 -0
  154. package/dist/src/invoice/invoice_manager.d.ts +12 -0
  155. package/dist/src/invoice/invoice_manager.d.ts.map +1 -0
  156. package/dist/src/invoice/invoice_manager.js +35 -0
  157. package/dist/src/invoice/invoice_manager.js.map +1 -0
  158. package/dist/src/invoice/invoice_provider.d.ts +48 -0
  159. package/dist/src/invoice/invoice_provider.d.ts.map +1 -0
  160. package/dist/src/invoice/invoice_provider.js +2 -0
  161. package/dist/src/invoice/invoice_provider.js.map +1 -0
  162. package/dist/src/money.d.ts +11 -0
  163. package/dist/src/money.d.ts.map +1 -0
  164. package/dist/src/money.js +14 -0
  165. package/dist/src/money.js.map +1 -0
  166. package/dist/src/payments_manager.d.ts +40 -0
  167. package/dist/src/payments_manager.d.ts.map +1 -0
  168. package/dist/src/payments_manager.js +94 -0
  169. package/dist/src/payments_manager.js.map +1 -0
  170. package/dist/src/services/main.d.ts +6 -0
  171. package/dist/src/services/main.d.ts.map +1 -0
  172. package/dist/src/services/main.js +17 -0
  173. package/dist/src/services/main.js.map +1 -0
  174. package/dist/src/telescope/index.d.ts +3 -0
  175. package/dist/src/telescope/index.d.ts.map +1 -0
  176. package/dist/src/telescope/index.js +2 -0
  177. package/dist/src/telescope/index.js.map +1 -0
  178. package/dist/src/telescope/payments_watcher.d.ts +27 -0
  179. package/dist/src/telescope/payments_watcher.d.ts.map +1 -0
  180. package/dist/src/telescope/payments_watcher.js +58 -0
  181. package/dist/src/telescope/payments_watcher.js.map +1 -0
  182. package/dist/src/telescope/telescope-sdk.d.ts +21 -0
  183. package/dist/src/telescope/telescope-sdk.d.ts.map +1 -0
  184. package/dist/src/telescope/telescope-sdk.js +11 -0
  185. package/dist/src/telescope/telescope-sdk.js.map +1 -0
  186. package/dist/src/testing/fake_payments_driver.d.ts +64 -0
  187. package/dist/src/testing/fake_payments_driver.d.ts.map +1 -0
  188. package/dist/src/testing/fake_payments_driver.js +171 -0
  189. package/dist/src/testing/fake_payments_driver.js.map +1 -0
  190. package/dist/src/testing/in_memory_billing_store.d.ts +110 -0
  191. package/dist/src/testing/in_memory_billing_store.d.ts.map +1 -0
  192. package/dist/src/testing/in_memory_billing_store.js +136 -0
  193. package/dist/src/testing/in_memory_billing_store.js.map +1 -0
  194. package/dist/src/testing/index.d.ts +6 -0
  195. package/dist/src/testing/index.d.ts.map +1 -0
  196. package/dist/src/testing/index.js +4 -0
  197. package/dist/src/testing/index.js.map +1 -0
  198. package/dist/src/testing/mutable_clock.d.ts +12 -0
  199. package/dist/src/testing/mutable_clock.d.ts.map +1 -0
  200. package/dist/src/testing/mutable_clock.js +20 -0
  201. package/dist/src/testing/mutable_clock.js.map +1 -0
  202. package/dist/src/types.d.ts +178 -0
  203. package/dist/src/types.d.ts.map +1 -0
  204. package/dist/src/types.js +9 -0
  205. package/dist/src/types.js.map +1 -0
  206. package/dist/src/webhook_handlers.d.ts +76 -0
  207. package/dist/src/webhook_handlers.d.ts.map +1 -0
  208. package/dist/src/webhook_handlers.js +128 -0
  209. package/dist/src/webhook_handlers.js.map +1 -0
  210. package/dist/src/webhook_security.d.ts +29 -0
  211. package/dist/src/webhook_security.d.ts.map +1 -0
  212. package/dist/src/webhook_security.js +53 -0
  213. package/dist/src/webhook_security.js.map +1 -0
  214. package/dist/stubs/config/payments.stub +101 -0
  215. package/dist/stubs/database/migrations/create_billing_tables.stub +90 -0
  216. package/dist/stubs/main.d.ts +9 -0
  217. package/dist/stubs/main.d.ts.map +1 -0
  218. package/dist/stubs/main.js +16 -0
  219. package/dist/stubs/main.js.map +1 -0
  220. package/dist/stubs/make/billable/main.stub +28 -0
  221. package/dist/stubs/make/webhook_handler/main.stub +29 -0
  222. package/package.json +150 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metered_bill.d.ts","sourceRoot":"","sources":["../../../src/billing/metered_bill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,oEAAoE;AACpE,MAAM,WAAW,SAAS;IACxB,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,EACjD,KAAK,EAAE,SAAS,EAAE,GACjB,WAAW,CAgBb;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAC;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,EAAE,CAAA;CAAE,GAC1E,OAAO,CAAC,WAAW,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC,CAO9E"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Price a period's metered usage against per-meter rates — the "how much do I bill for
3
+ * what was consumed" step of a metered subscription. Pure: feed it a
4
+ * {@link BillingStore.usageReport} result and the plan's {@link MeterRate}s.
5
+ *
6
+ * ```ts
7
+ * const usage = await store.usageReport({ subscriptionId: sub.id, from, to })
8
+ * const bill = meteredBill(usage, [
9
+ * { meter: 'api_calls', rate: 0.5, included: 1000 },
10
+ * { meter: 'storage_gb', rate: 200 },
11
+ * ])
12
+ * bill.total // cents to charge for overage
13
+ * ```
14
+ */
15
+ export function meteredBill(usage, rates) {
16
+ const byMeter = new Map(rates.map((r) => [r.meter, r]));
17
+ const lines = [];
18
+ for (const line of usage) {
19
+ const rate = byMeter.get(line.meter);
20
+ if (!rate)
21
+ continue; // usage for an unmetered/unpriced meter is ignored
22
+ const included = rate.included ?? 0;
23
+ const billable = Math.max(0, line.quantity - included);
24
+ lines.push({
25
+ meter: line.meter,
26
+ quantity: line.quantity,
27
+ billable,
28
+ amount: Math.round(billable * rate.rate),
29
+ });
30
+ }
31
+ return { lines, total: lines.reduce((sum, line) => sum + line.amount, 0) };
32
+ }
33
+ /**
34
+ * Convenience: run a subscription's metered usage for a window through
35
+ * {@link meteredBill}. Fetches the usage from the store, prices it with `rates`, and
36
+ * returns the bill (plus the raw usage for reference).
37
+ */
38
+ export async function meteredBillForSubscription(store, input) {
39
+ const usage = await store.usageReport({
40
+ subscriptionId: input.subscriptionId,
41
+ from: input.from,
42
+ to: input.to,
43
+ });
44
+ return { ...meteredBill(usage, input.rates), usage };
45
+ }
46
+ //# sourceMappingURL=metered_bill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metered_bill.js","sourceRoot":"","sources":["../../../src/billing/metered_bill.ts"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CACzB,KAAiD,EACjD,KAAkB;IAElB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI;YAAE,SAAS,CAAC,mDAAmD;QACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;QACvD,KAAK,CAAC,IAAI,CAAC;YACT,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ;YACR,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;SACzC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;AAC7E,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAAmB,EACnB,KAA2E;IAE3E,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC;QACpC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,EAAE,EAAE,KAAK,CAAC,EAAE;KACb,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { withBillable } from './with_billable.js';
2
+ export { BillingSubscription, withSubscription } from './with_subscription.js';
3
+ export { BillingPayment, withPayment } from './with_payment.js';
4
+ export { BillingWebhookEvent } from './with_webhook_event.js';
5
+ export { BillingUsageEvent } from './with_usage_event.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { withBillable } from './with_billable.js';
2
+ export { BillingSubscription, withSubscription } from './with_subscription.js';
3
+ export { BillingPayment, withPayment } from './with_payment.js';
4
+ export { BillingWebhookEvent } from './with_webhook_event.js';
5
+ export { BillingUsageEvent } from './with_usage_event.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/billing/mixins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
+ import { BaseModel } from '@adonisjs/lucid/orm';
3
+ import type { DateTime } from 'luxon';
4
+ /** Instância composta pelo mixin {@link withBillable}. */
5
+ export interface BillableRow {
6
+ billingCustomerId: string | null;
7
+ billingProvider: string | null;
8
+ billingTrialEndsAt: DateTime | null;
9
+ }
10
+ export type BillableClass<Model extends NormalizeConstructor<typeof BaseModel>> = Model & {
11
+ new (...args: any[]): BillableRow;
12
+ };
13
+ /**
14
+ * Adds billing customer columns/relationships to a Lucid model (typically the User).
15
+ *
16
+ * ```ts
17
+ * export default class User extends compose(BaseModel, withBillable()) {
18
+ * @column({ isPrimary: true }) declare id: string
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function withBillable(): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => BillableClass<Model>;
23
+ //# sourceMappingURL=with_billable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_billable.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_billable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,QAAQ,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,MAAM,aAAa,CAAC,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,IAAI,KAAK,GAAG;IACxF,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;CACnC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,YAAY,KAClB,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,EAC1D,YAAY,KAAK,KAChB,aAAa,CAAC,KAAK,CAAC,CAgBxB"}
@@ -0,0 +1,33 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { column } from '@adonisjs/lucid/orm';
8
+ /**
9
+ * Adds billing customer columns/relationships to a Lucid model (typically the User).
10
+ *
11
+ * ```ts
12
+ * export default class User extends compose(BaseModel, withBillable()) {
13
+ * @column({ isPrimary: true }) declare id: string
14
+ * }
15
+ * ```
16
+ */
17
+ export function withBillable() {
18
+ return (superclass) => {
19
+ class BillableUser extends superclass {
20
+ }
21
+ __decorate([
22
+ column({ serializeAs: null })
23
+ ], BillableUser.prototype, "billingCustomerId", void 0);
24
+ __decorate([
25
+ column({ serializeAs: null })
26
+ ], BillableUser.prototype, "billingProvider", void 0);
27
+ __decorate([
28
+ column.dateTime({ serializeAs: null })
29
+ ], BillableUser.prototype, "billingTrialEndsAt", void 0);
30
+ return BillableUser;
31
+ };
32
+ }
33
+ //# sourceMappingURL=with_billable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_billable.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_billable.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAa,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAcxD;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,CACL,UAAiB,EACK,EAAE;QACxB,MAAM,YAAa,SAAQ,UAAU;SAYpC;QATS;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;+DACW;QAIjC;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;6DACS;QAI/B;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;gEACK;QAE9C,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
+ import { BaseModel } from '@adonisjs/lucid/orm';
3
+ import type { DateTime } from 'luxon';
4
+ /**
5
+ * The Lucid model backing the `billing_payments` table. Mirrors the gateway payment —
6
+ * kept locally so webhook processing and the app can query payment history without
7
+ * calling the gateway API.
8
+ */
9
+ export declare class BillingPayment extends BaseModel {
10
+ id: string;
11
+ /** Gateway payment id (Stripe `pi_...`, Asaas `pay_...`, Woovi cobr `globalID`). */
12
+ gatewayId: string;
13
+ provider: string;
14
+ status: string;
15
+ amount: number;
16
+ currency: string;
17
+ customerId: string | null;
18
+ subscriptionId: string | null;
19
+ payload: Record<string, unknown>;
20
+ createdAt: DateTime;
21
+ updatedAt: DateTime;
22
+ paidAt: DateTime | null;
23
+ }
24
+ /** Instância composta pelo mixin {@link withPayment}. */
25
+ export interface PaymentRow {
26
+ gatewayId: string;
27
+ provider: string;
28
+ status: string;
29
+ amount: number;
30
+ currency: string;
31
+ customerId: string | null;
32
+ subscriptionId: string | null;
33
+ payload: Record<string, unknown>;
34
+ createdAt: DateTime;
35
+ updatedAt: DateTime;
36
+ paidAt: DateTime | null;
37
+ }
38
+ export type PaymentMixinClass<Model extends NormalizeConstructor<typeof BaseModel>> = Model & {
39
+ new (...args: any[]): PaymentRow;
40
+ };
41
+ /**
42
+ * Mixin to attach payment columns to a custom model.
43
+ */
44
+ export declare function withPayment(): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => PaymentMixinClass<Model>;
45
+ //# sourceMappingURL=with_payment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_payment.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_payment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,SAAS;IAEnC,EAAE,EAAE,MAAM,CAAC;IAEnB,oFAAoF;IAE5E,SAAS,EAAE,MAAM,CAAC;IAGlB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,MAAM,CAAC;IAGf,QAAQ,EAAE,MAAM,CAAC;IAGjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGjC,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;IAGpB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;CACjC;AAED,yDAAyD;AACzD,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;IACpB,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,CAAC,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,IAAI,KAAK,GAAG;IAC5F,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,wBAAgB,WAAW,KACjB,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,EAC1D,YAAY,KAAK,KAChB,iBAAiB,CAAC,KAAK,CAAC,CAqC5B"}
@@ -0,0 +1,94 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseModel, column } from '@adonisjs/lucid/orm';
8
+ /**
9
+ * The Lucid model backing the `billing_payments` table. Mirrors the gateway payment —
10
+ * kept locally so webhook processing and the app can query payment history without
11
+ * calling the gateway API.
12
+ */
13
+ export class BillingPayment extends BaseModel {
14
+ }
15
+ __decorate([
16
+ column({ isPrimary: true })
17
+ ], BillingPayment.prototype, "id", void 0);
18
+ __decorate([
19
+ column()
20
+ ], BillingPayment.prototype, "gatewayId", void 0);
21
+ __decorate([
22
+ column()
23
+ ], BillingPayment.prototype, "provider", void 0);
24
+ __decorate([
25
+ column()
26
+ ], BillingPayment.prototype, "status", void 0);
27
+ __decorate([
28
+ column()
29
+ ], BillingPayment.prototype, "amount", void 0);
30
+ __decorate([
31
+ column()
32
+ ], BillingPayment.prototype, "currency", void 0);
33
+ __decorate([
34
+ column({ serializeAs: null })
35
+ ], BillingPayment.prototype, "customerId", void 0);
36
+ __decorate([
37
+ column({ serializeAs: null })
38
+ ], BillingPayment.prototype, "subscriptionId", void 0);
39
+ __decorate([
40
+ column({ serializeAs: null })
41
+ ], BillingPayment.prototype, "payload", void 0);
42
+ __decorate([
43
+ column.dateTime({ autoCreate: true })
44
+ ], BillingPayment.prototype, "createdAt", void 0);
45
+ __decorate([
46
+ column.dateTime({ autoCreate: true, autoUpdate: true })
47
+ ], BillingPayment.prototype, "updatedAt", void 0);
48
+ __decorate([
49
+ column.dateTime({ serializeAs: null })
50
+ ], BillingPayment.prototype, "paidAt", void 0);
51
+ /**
52
+ * Mixin to attach payment columns to a custom model.
53
+ */
54
+ export function withPayment() {
55
+ return (superclass) => {
56
+ class PaymentMixin extends superclass {
57
+ }
58
+ __decorate([
59
+ column()
60
+ ], PaymentMixin.prototype, "gatewayId", void 0);
61
+ __decorate([
62
+ column()
63
+ ], PaymentMixin.prototype, "provider", void 0);
64
+ __decorate([
65
+ column()
66
+ ], PaymentMixin.prototype, "status", void 0);
67
+ __decorate([
68
+ column()
69
+ ], PaymentMixin.prototype, "amount", void 0);
70
+ __decorate([
71
+ column()
72
+ ], PaymentMixin.prototype, "currency", void 0);
73
+ __decorate([
74
+ column({ serializeAs: null })
75
+ ], PaymentMixin.prototype, "customerId", void 0);
76
+ __decorate([
77
+ column({ serializeAs: null })
78
+ ], PaymentMixin.prototype, "subscriptionId", void 0);
79
+ __decorate([
80
+ column({ serializeAs: null })
81
+ ], PaymentMixin.prototype, "payload", void 0);
82
+ __decorate([
83
+ column.dateTime({ autoCreate: true })
84
+ ], PaymentMixin.prototype, "createdAt", void 0);
85
+ __decorate([
86
+ column.dateTime({ autoCreate: true, autoUpdate: true })
87
+ ], PaymentMixin.prototype, "updatedAt", void 0);
88
+ __decorate([
89
+ column.dateTime({ serializeAs: null })
90
+ ], PaymentMixin.prototype, "paidAt", void 0);
91
+ return PaymentMixin;
92
+ };
93
+ }
94
+ //# sourceMappingURL=with_payment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_payment.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_payment.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,SAAS;CAqC5C;AAnCS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;0CACT;AAIX;IADP,MAAM,EAAE;iDACiB;AAGlB;IADP,MAAM,EAAE;gDACgB;AAGjB;IADP,MAAM,EAAE;8CACc;AAGf;IADP,MAAM,EAAE;8CACc;AAGf;IADP,MAAM,EAAE;gDACgB;AAGjB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;kDACI;AAG1B;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;sDACQ;AAG9B;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;+CACW;AAGjC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;iDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;iDAC5B;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8CACP;AAsBlC;;GAEG;AACH,MAAM,UAAU,WAAW;IACzB,OAAO,CACL,UAAiB,EACS,EAAE;QAC5B,MAAM,YAAa,SAAQ,UAAU;SAiCpC;QA/BS;YADP,MAAM,EAAE;uDACiB;QAGlB;YADP,MAAM,EAAE;sDACgB;QAGjB;YADP,MAAM,EAAE;oDACc;QAGf;YADP,MAAM,EAAE;oDACc;QAGf;YADP,MAAM,EAAE;sDACgB;QAGjB;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;wDACI;QAG1B;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;4DACQ;QAG9B;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;qDACW;QAGjC;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uDACV;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uDAC5B;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACP;QAElC,OAAO,YAAY,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { NormalizeConstructor } from '@adonisjs/core/types/helpers';
2
+ import { BaseModel } from '@adonisjs/lucid/orm';
3
+ import type { DateTime } from 'luxon';
4
+ /**
5
+ * The Lucid model backing the `billing_subscriptions` table.
6
+ *
7
+ * Apps can either use this model directly, or compose `withSubscription()` into their own
8
+ * model. Stores resolve it through the config (`billing.subscriptionModel`).
9
+ */
10
+ export declare class BillingSubscription extends BaseModel {
11
+ id: string;
12
+ /** Gateway subscription id (Stripe `sub_...`, Asaas `sub_...`, Woovi `globalID`). */
13
+ gatewayId: string;
14
+ provider: string;
15
+ status: string;
16
+ planId: string;
17
+ customerId: string;
18
+ trialEndsAt: DateTime | null;
19
+ endsAt: DateTime | null;
20
+ payload: Record<string, unknown>;
21
+ createdAt: DateTime;
22
+ updatedAt: DateTime;
23
+ }
24
+ /** Instância composta pelo mixin {@link withSubscription}. */
25
+ export interface SubscriptionRow {
26
+ gatewayId: string;
27
+ provider: string;
28
+ status: string;
29
+ planId: string;
30
+ customerId: string;
31
+ trialEndsAt: DateTime | null;
32
+ endsAt: DateTime | null;
33
+ payload: Record<string, unknown>;
34
+ createdAt: DateTime;
35
+ updatedAt: DateTime;
36
+ }
37
+ export type SubscriptionMixinClass<Model extends NormalizeConstructor<typeof BaseModel>> = Model & {
38
+ new (...args: any[]): SubscriptionRow;
39
+ };
40
+ /**
41
+ * Mixin to attach subscription columns/relationships to a custom model.
42
+ *
43
+ * ```ts
44
+ * export default class Subscription extends compose(BaseModel, withSubscription()) {
45
+ * @column({ isPrimary: true }) declare id: string
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function withSubscription(): <Model extends NormalizeConstructor<typeof BaseModel>>(superclass: Model) => SubscriptionMixinClass<Model>;
50
+ //# sourceMappingURL=with_subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_subscription.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAExC,EAAE,EAAE,MAAM,CAAC;IAEnB,qFAAqF;IAE7E,SAAS,EAAE,MAAM,CAAC;IAGlB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,MAAM,CAAC;IAGf,UAAU,EAAE,MAAM,CAAC;IAGnB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAG7B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAGxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGjC,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;CAC7B;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,EAAE,QAAQ,CAAC;IACpB,SAAS,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,sBAAsB,CAAC,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,IAAI,KAAK,GAAG;IACjG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,eAAe,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,KACtB,KAAK,SAAS,oBAAoB,CAAC,OAAO,SAAS,CAAC,EAC1D,YAAY,KAAK,KAChB,sBAAsB,CAAC,KAAK,CAAC,CAkCjC"}
@@ -0,0 +1,95 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseModel, column } from '@adonisjs/lucid/orm';
8
+ /**
9
+ * The Lucid model backing the `billing_subscriptions` table.
10
+ *
11
+ * Apps can either use this model directly, or compose `withSubscription()` into their own
12
+ * model. Stores resolve it through the config (`billing.subscriptionModel`).
13
+ */
14
+ export class BillingSubscription extends BaseModel {
15
+ }
16
+ __decorate([
17
+ column({ isPrimary: true })
18
+ ], BillingSubscription.prototype, "id", void 0);
19
+ __decorate([
20
+ column()
21
+ ], BillingSubscription.prototype, "gatewayId", void 0);
22
+ __decorate([
23
+ column()
24
+ ], BillingSubscription.prototype, "provider", void 0);
25
+ __decorate([
26
+ column()
27
+ ], BillingSubscription.prototype, "status", void 0);
28
+ __decorate([
29
+ column()
30
+ ], BillingSubscription.prototype, "planId", void 0);
31
+ __decorate([
32
+ column({ serializeAs: null })
33
+ ], BillingSubscription.prototype, "customerId", void 0);
34
+ __decorate([
35
+ column.dateTime({ serializeAs: null })
36
+ ], BillingSubscription.prototype, "trialEndsAt", void 0);
37
+ __decorate([
38
+ column.dateTime({ serializeAs: null })
39
+ ], BillingSubscription.prototype, "endsAt", void 0);
40
+ __decorate([
41
+ column({ serializeAs: null })
42
+ ], BillingSubscription.prototype, "payload", void 0);
43
+ __decorate([
44
+ column.dateTime({ autoCreate: true })
45
+ ], BillingSubscription.prototype, "createdAt", void 0);
46
+ __decorate([
47
+ column.dateTime({ autoCreate: true, autoUpdate: true })
48
+ ], BillingSubscription.prototype, "updatedAt", void 0);
49
+ /**
50
+ * Mixin to attach subscription columns/relationships to a custom model.
51
+ *
52
+ * ```ts
53
+ * export default class Subscription extends compose(BaseModel, withSubscription()) {
54
+ * @column({ isPrimary: true }) declare id: string
55
+ * }
56
+ * ```
57
+ */
58
+ export function withSubscription() {
59
+ return (superclass) => {
60
+ class SubscriptionMixin extends superclass {
61
+ }
62
+ __decorate([
63
+ column()
64
+ ], SubscriptionMixin.prototype, "gatewayId", void 0);
65
+ __decorate([
66
+ column()
67
+ ], SubscriptionMixin.prototype, "provider", void 0);
68
+ __decorate([
69
+ column()
70
+ ], SubscriptionMixin.prototype, "status", void 0);
71
+ __decorate([
72
+ column()
73
+ ], SubscriptionMixin.prototype, "planId", void 0);
74
+ __decorate([
75
+ column({ serializeAs: null })
76
+ ], SubscriptionMixin.prototype, "customerId", void 0);
77
+ __decorate([
78
+ column.dateTime({ serializeAs: null })
79
+ ], SubscriptionMixin.prototype, "trialEndsAt", void 0);
80
+ __decorate([
81
+ column.dateTime({ serializeAs: null })
82
+ ], SubscriptionMixin.prototype, "endsAt", void 0);
83
+ __decorate([
84
+ column({ serializeAs: null })
85
+ ], SubscriptionMixin.prototype, "payload", void 0);
86
+ __decorate([
87
+ column.dateTime({ autoCreate: true })
88
+ ], SubscriptionMixin.prototype, "createdAt", void 0);
89
+ __decorate([
90
+ column.dateTime({ autoCreate: true, autoUpdate: true })
91
+ ], SubscriptionMixin.prototype, "updatedAt", void 0);
92
+ return SubscriptionMixin;
93
+ };
94
+ }
95
+ //# sourceMappingURL=with_subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_subscription.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_subscription.ts"],"names":[],"mappings":";;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;GAKG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;CAkCjD;AAhCS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACT;AAIX;IADP,MAAM,EAAE;sDACiB;AAGlB;IADP,MAAM,EAAE;qDACgB;AAGjB;IADP,MAAM,EAAE;mDACc;AAGf;IADP,MAAM,EAAE;mDACc;AAGf;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;uDACH;AAGnB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;wDACF;AAG7B;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;mDACP;AAGxB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACW;AAGjC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC5B;AAqB9B;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CACL,UAAiB,EACc,EAAE;QACjC,MAAM,iBAAkB,SAAQ,UAAU;SA8BzC;QA5BS;YADP,MAAM,EAAE;4DACiB;QAGlB;YADP,MAAM,EAAE;2DACgB;QAGjB;YADP,MAAM,EAAE;yDACc;QAGf;YADP,MAAM,EAAE;yDACc;QAGf;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;6DACH;QAGnB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;8DACF;QAG7B;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;yDACP;QAGxB;YADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;0DACW;QAGjC;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;4DACV;QAGpB;YADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;4DAC5B;QAE9B,OAAO,iBAAiB,CAAC;IAC3B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { BaseModel } from '@adonisjs/lucid/orm';
2
+ import type { DateTime } from 'luxon';
3
+ /**
4
+ * The Lucid model backing the `billing_usage_events` table — a metered subscription's
5
+ * consumption ledger. One row per usage event (e.g. an API call, a stored GB, a message);
6
+ * the billing layer aggregates them per meter for a period to bill usage-based plans.
7
+ */
8
+ export declare class BillingUsageEvent extends BaseModel {
9
+ id: string;
10
+ /** The subscription this usage belongs to, when metered against a subscription. */
11
+ subscriptionId: string | null;
12
+ /** The customer this usage belongs to, when metered per customer. */
13
+ customerId: string | null;
14
+ /** The meter name, e.g. `'api_calls'`, `'storage_gb'`, `'messages'`. */
15
+ meter: string;
16
+ /** How much of the meter this event consumed (e.g. request count, GB, minutes). */
17
+ quantity: number;
18
+ metadata: Record<string, unknown>;
19
+ recordedAt: DateTime;
20
+ updatedAt: DateTime;
21
+ }
22
+ //# sourceMappingURL=with_usage_event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_usage_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;IAEtC,EAAE,EAAE,MAAM,CAAC;IAEnB,mFAAmF;IAE3E,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,qEAAqE;IAE7D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,wEAAwE;IAEhE,KAAK,EAAE,MAAM,CAAC;IAEtB,mFAAmF;IAE3E,QAAQ,EAAE,MAAM,CAAC;IAGjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGlC,UAAU,EAAE,QAAQ,CAAC;IAGrB,SAAS,EAAE,QAAQ,CAAC;CAC7B"}
@@ -0,0 +1,39 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseModel, column } from '@adonisjs/lucid/orm';
8
+ /**
9
+ * The Lucid model backing the `billing_usage_events` table — a metered subscription's
10
+ * consumption ledger. One row per usage event (e.g. an API call, a stored GB, a message);
11
+ * the billing layer aggregates them per meter for a period to bill usage-based plans.
12
+ */
13
+ export class BillingUsageEvent extends BaseModel {
14
+ }
15
+ __decorate([
16
+ column({ isPrimary: true })
17
+ ], BillingUsageEvent.prototype, "id", void 0);
18
+ __decorate([
19
+ column()
20
+ ], BillingUsageEvent.prototype, "subscriptionId", void 0);
21
+ __decorate([
22
+ column()
23
+ ], BillingUsageEvent.prototype, "customerId", void 0);
24
+ __decorate([
25
+ column()
26
+ ], BillingUsageEvent.prototype, "meter", void 0);
27
+ __decorate([
28
+ column()
29
+ ], BillingUsageEvent.prototype, "quantity", void 0);
30
+ __decorate([
31
+ column({ serializeAs: null })
32
+ ], BillingUsageEvent.prototype, "metadata", void 0);
33
+ __decorate([
34
+ column.dateTime({ autoCreate: true })
35
+ ], BillingUsageEvent.prototype, "recordedAt", void 0);
36
+ __decorate([
37
+ column.dateTime({ autoCreate: true, autoUpdate: true })
38
+ ], BillingUsageEvent.prototype, "updatedAt", void 0);
39
+ //# sourceMappingURL=with_usage_event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_usage_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_usage_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;CA4B/C;AA1BS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;6CACT;AAIX;IADP,MAAM,EAAE;yDAC6B;AAI9B;IADP,MAAM,EAAE;qDACyB;AAI1B;IADP,MAAM,EAAE;gDACa;AAId;IADP,MAAM,EAAE;mDACgB;AAGjB;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;mDACY;AAGlC;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;qDACT;AAGrB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;oDAC5B"}
@@ -0,0 +1,21 @@
1
+ import { BaseModel } from '@adonisjs/lucid/orm';
2
+ import type { DateTime } from 'luxon';
3
+ /**
4
+ * The Lucid model backing the `billing_webhook_events` table — the idempotency ledger.
5
+ * Every webhook event is recorded here (keyed by gateway event id) so a re-delivered
6
+ * webhook is never processed twice.
7
+ */
8
+ export declare class BillingWebhookEvent extends BaseModel {
9
+ id: string;
10
+ /** Gateway event id — the idempotency key. */
11
+ gatewayEventId: string;
12
+ provider: string;
13
+ type: string;
14
+ status: 'received' | 'processed' | 'failed';
15
+ payload: Record<string, unknown>;
16
+ /** Error message when processing failed. */
17
+ error: string | null;
18
+ createdAt: DateTime;
19
+ updatedAt: DateTime;
20
+ }
21
+ //# sourceMappingURL=with_webhook_event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_webhook_event.d.ts","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,SAAS;IAExC,EAAE,EAAE,MAAM,CAAC;IAEnB,8CAA8C;IAEtC,cAAc,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,MAAM,CAAC;IAGjB,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;IAG5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEzC,4CAA4C;IAEpC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,SAAS,EAAE,QAAQ,CAAC;IAGpB,SAAS,EAAE,QAAQ,CAAC;CAC7B"}
@@ -0,0 +1,42 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { BaseModel, column } from '@adonisjs/lucid/orm';
8
+ /**
9
+ * The Lucid model backing the `billing_webhook_events` table — the idempotency ledger.
10
+ * Every webhook event is recorded here (keyed by gateway event id) so a re-delivered
11
+ * webhook is never processed twice.
12
+ */
13
+ export class BillingWebhookEvent extends BaseModel {
14
+ }
15
+ __decorate([
16
+ column({ isPrimary: true })
17
+ ], BillingWebhookEvent.prototype, "id", void 0);
18
+ __decorate([
19
+ column()
20
+ ], BillingWebhookEvent.prototype, "gatewayEventId", void 0);
21
+ __decorate([
22
+ column()
23
+ ], BillingWebhookEvent.prototype, "provider", void 0);
24
+ __decorate([
25
+ column()
26
+ ], BillingWebhookEvent.prototype, "type", void 0);
27
+ __decorate([
28
+ column()
29
+ ], BillingWebhookEvent.prototype, "status", void 0);
30
+ __decorate([
31
+ column({ serializeAs: null })
32
+ ], BillingWebhookEvent.prototype, "payload", void 0);
33
+ __decorate([
34
+ column({ serializeAs: null })
35
+ ], BillingWebhookEvent.prototype, "error", void 0);
36
+ __decorate([
37
+ column.dateTime({ autoCreate: true })
38
+ ], BillingWebhookEvent.prototype, "createdAt", void 0);
39
+ __decorate([
40
+ column.dateTime({ autoCreate: true, autoUpdate: true })
41
+ ], BillingWebhookEvent.prototype, "updatedAt", void 0);
42
+ //# sourceMappingURL=with_webhook_event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with_webhook_event.js","sourceRoot":"","sources":["../../../../src/billing/mixins/with_webhook_event.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,SAAS;CA6BjD;AA3BS;IADP,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;+CACT;AAIX;IADP,MAAM,EAAE;2DACsB;AAGvB;IADP,MAAM,EAAE;qDACgB;AAGjB;IADP,MAAM,EAAE;iDACY;AAGb;IADP,MAAM,EAAE;mDAC2C;AAG5C;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;oDACW;AAIjC;IADP,MAAM,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;kDACD;AAGrB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDACV;AAGpB;IADP,MAAM,CAAC,QAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;sDAC5B"}