@dainamite/billing 0.17.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 (248) hide show
  1. package/CHANGELOG.md +658 -0
  2. package/LICENSE +21 -0
  3. package/README.md +77 -0
  4. package/dist/modules/billing/acl.js +20 -0
  5. package/dist/modules/billing/acl.js.map +7 -0
  6. package/dist/modules/billing/api/accounts/route.js +182 -0
  7. package/dist/modules/billing/api/accounts/route.js.map +7 -0
  8. package/dist/modules/billing/api/export/account/[id]/route.js +170 -0
  9. package/dist/modules/billing/api/export/account/[id]/route.js.map +7 -0
  10. package/dist/modules/billing/api/invoices/[id]/route.js +85 -0
  11. package/dist/modules/billing/api/invoices/[id]/route.js.map +7 -0
  12. package/dist/modules/billing/api/invoices/add-line/route.js +69 -0
  13. package/dist/modules/billing/api/invoices/add-line/route.js.map +7 -0
  14. package/dist/modules/billing/api/invoices/edit-line/route.js +78 -0
  15. package/dist/modules/billing/api/invoices/edit-line/route.js.map +7 -0
  16. package/dist/modules/billing/api/invoices/post/route.js +74 -0
  17. package/dist/modules/billing/api/invoices/post/route.js.map +7 -0
  18. package/dist/modules/billing/api/invoices/remove-line/route.js +69 -0
  19. package/dist/modules/billing/api/invoices/remove-line/route.js.map +7 -0
  20. package/dist/modules/billing/api/invoices/route.js +109 -0
  21. package/dist/modules/billing/api/invoices/route.js.map +7 -0
  22. package/dist/modules/billing/api/items/bulk/route.js +74 -0
  23. package/dist/modules/billing/api/items/bulk/route.js.map +7 -0
  24. package/dist/modules/billing/api/items/route.js +224 -0
  25. package/dist/modules/billing/api/items/route.js.map +7 -0
  26. package/dist/modules/billing/api/openapi.js +25 -0
  27. package/dist/modules/billing/api/openapi.js.map +7 -0
  28. package/dist/modules/billing/api/run-outcomes/route.js +122 -0
  29. package/dist/modules/billing/api/run-outcomes/route.js.map +7 -0
  30. package/dist/modules/billing/api/runs/retry-failed/route.js +70 -0
  31. package/dist/modules/billing/api/runs/retry-failed/route.js.map +7 -0
  32. package/dist/modules/billing/api/runs/route.js +143 -0
  33. package/dist/modules/billing/api/runs/route.js.map +7 -0
  34. package/dist/modules/billing/api/test-invoices/wipe/route.js +65 -0
  35. package/dist/modules/billing/api/test-invoices/wipe/route.js.map +7 -0
  36. package/dist/modules/billing/api/usage/route.js +138 -0
  37. package/dist/modules/billing/api/usage/route.js.map +7 -0
  38. package/dist/modules/billing/backend/billing/accounts/[id]/page.js +402 -0
  39. package/dist/modules/billing/backend/billing/accounts/[id]/page.js.map +7 -0
  40. package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js +25 -0
  41. package/dist/modules/billing/backend/billing/accounts/[id]/page.meta.js.map +7 -0
  42. package/dist/modules/billing/backend/billing/accounts/create/page.js +82 -0
  43. package/dist/modules/billing/backend/billing/accounts/create/page.js.map +7 -0
  44. package/dist/modules/billing/backend/billing/accounts/create/page.meta.js +25 -0
  45. package/dist/modules/billing/backend/billing/accounts/create/page.meta.js.map +7 -0
  46. package/dist/modules/billing/backend/billing/accounts/page.js +173 -0
  47. package/dist/modules/billing/backend/billing/accounts/page.js.map +7 -0
  48. package/dist/modules/billing/backend/billing/accounts/page.meta.js +18 -0
  49. package/dist/modules/billing/backend/billing/accounts/page.meta.js.map +7 -0
  50. package/dist/modules/billing/backend/billing/invoices/[id]/page.js +500 -0
  51. package/dist/modules/billing/backend/billing/invoices/[id]/page.js.map +7 -0
  52. package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js +25 -0
  53. package/dist/modules/billing/backend/billing/invoices/[id]/page.meta.js.map +7 -0
  54. package/dist/modules/billing/backend/billing/invoices/page.js +187 -0
  55. package/dist/modules/billing/backend/billing/invoices/page.js.map +7 -0
  56. package/dist/modules/billing/backend/billing/invoices/page.meta.js +18 -0
  57. package/dist/modules/billing/backend/billing/invoices/page.meta.js.map +7 -0
  58. package/dist/modules/billing/backend/billing/items/[id]/page.js +265 -0
  59. package/dist/modules/billing/backend/billing/items/[id]/page.js.map +7 -0
  60. package/dist/modules/billing/backend/billing/items/[id]/page.meta.js +25 -0
  61. package/dist/modules/billing/backend/billing/items/[id]/page.meta.js.map +7 -0
  62. package/dist/modules/billing/backend/billing/items/create/page.js +90 -0
  63. package/dist/modules/billing/backend/billing/items/create/page.js.map +7 -0
  64. package/dist/modules/billing/backend/billing/items/create/page.meta.js +25 -0
  65. package/dist/modules/billing/backend/billing/items/create/page.meta.js.map +7 -0
  66. package/dist/modules/billing/backend/billing/items/page.js +208 -0
  67. package/dist/modules/billing/backend/billing/items/page.js.map +7 -0
  68. package/dist/modules/billing/backend/billing/items/page.meta.js +18 -0
  69. package/dist/modules/billing/backend/billing/items/page.meta.js.map +7 -0
  70. package/dist/modules/billing/backend/billing/runs/[id]/page.js +293 -0
  71. package/dist/modules/billing/backend/billing/runs/[id]/page.js.map +7 -0
  72. package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js +21 -0
  73. package/dist/modules/billing/backend/billing/runs/[id]/page.meta.js.map +7 -0
  74. package/dist/modules/billing/backend/billing/runs/page.js +341 -0
  75. package/dist/modules/billing/backend/billing/runs/page.js.map +7 -0
  76. package/dist/modules/billing/backend/billing/runs/page.meta.js +18 -0
  77. package/dist/modules/billing/backend/billing/runs/page.meta.js.map +7 -0
  78. package/dist/modules/billing/backend/billing/usage/create/page.js +100 -0
  79. package/dist/modules/billing/backend/billing/usage/create/page.js.map +7 -0
  80. package/dist/modules/billing/backend/billing/usage/create/page.meta.js +25 -0
  81. package/dist/modules/billing/backend/billing/usage/create/page.meta.js.map +7 -0
  82. package/dist/modules/billing/ce.js +56 -0
  83. package/dist/modules/billing/ce.js.map +7 -0
  84. package/dist/modules/billing/cli.js +67 -0
  85. package/dist/modules/billing/cli.js.map +7 -0
  86. package/dist/modules/billing/commands/accounts.js +157 -0
  87. package/dist/modules/billing/commands/accounts.js.map +7 -0
  88. package/dist/modules/billing/commands/index.js +6 -0
  89. package/dist/modules/billing/commands/index.js.map +7 -0
  90. package/dist/modules/billing/commands/invoices.js +401 -0
  91. package/dist/modules/billing/commands/invoices.js.map +7 -0
  92. package/dist/modules/billing/commands/items.js +317 -0
  93. package/dist/modules/billing/commands/items.js.map +7 -0
  94. package/dist/modules/billing/commands/runs.js +123 -0
  95. package/dist/modules/billing/commands/runs.js.map +7 -0
  96. package/dist/modules/billing/commands/usage.js +88 -0
  97. package/dist/modules/billing/commands/usage.js.map +7 -0
  98. package/dist/modules/billing/components/AccountForm.js +420 -0
  99. package/dist/modules/billing/components/AccountForm.js.map +7 -0
  100. package/dist/modules/billing/components/DetailFields.js +37 -0
  101. package/dist/modules/billing/components/DetailFields.js.map +7 -0
  102. package/dist/modules/billing/components/ItemForm.js +440 -0
  103. package/dist/modules/billing/components/ItemForm.js.map +7 -0
  104. package/dist/modules/billing/components/LineFormDialog.js +195 -0
  105. package/dist/modules/billing/components/LineFormDialog.js.map +7 -0
  106. package/dist/modules/billing/components/UsageForm.js +262 -0
  107. package/dist/modules/billing/components/UsageForm.js.map +7 -0
  108. package/dist/modules/billing/data/entities.js +433 -0
  109. package/dist/modules/billing/data/entities.js.map +7 -0
  110. package/dist/modules/billing/data/entityIds.js +12 -0
  111. package/dist/modules/billing/data/entityIds.js.map +7 -0
  112. package/dist/modules/billing/data/validators.js +396 -0
  113. package/dist/modules/billing/data/validators.js.map +7 -0
  114. package/dist/modules/billing/di.js +6 -0
  115. package/dist/modules/billing/di.js.map +7 -0
  116. package/dist/modules/billing/events.js +35 -0
  117. package/dist/modules/billing/events.js.map +7 -0
  118. package/dist/modules/billing/i18n/en.json +336 -0
  119. package/dist/modules/billing/i18n/pl.json +336 -0
  120. package/dist/modules/billing/index.js +17 -0
  121. package/dist/modules/billing/index.js.map +7 -0
  122. package/dist/modules/billing/lib/billPeriod.js +101 -0
  123. package/dist/modules/billing/lib/billPeriod.js.map +7 -0
  124. package/dist/modules/billing/lib/billRunEngine.js +256 -0
  125. package/dist/modules/billing/lib/billRunEngine.js.map +7 -0
  126. package/dist/modules/billing/lib/billRunLabel.js +8 -0
  127. package/dist/modules/billing/lib/billRunLabel.js.map +7 -0
  128. package/dist/modules/billing/lib/idempotency.js +13 -0
  129. package/dist/modules/billing/lib/idempotency.js.map +7 -0
  130. package/dist/modules/billing/lib/invoiceStatus.js +38 -0
  131. package/dist/modules/billing/lib/invoiceStatus.js.map +7 -0
  132. package/dist/modules/billing/lib/invoiceWriter.js +153 -0
  133. package/dist/modules/billing/lib/invoiceWriter.js.map +7 -0
  134. package/dist/modules/billing/lib/itemSelector.js +77 -0
  135. package/dist/modules/billing/lib/itemSelector.js.map +7 -0
  136. package/dist/modules/billing/lib/seeds/demo.js +130 -0
  137. package/dist/modules/billing/lib/seeds/demo.js.map +7 -0
  138. package/dist/modules/billing/lib/tenantLock.js +32 -0
  139. package/dist/modules/billing/lib/tenantLock.js.map +7 -0
  140. package/dist/modules/billing/lib/usageRater.js +150 -0
  141. package/dist/modules/billing/lib/usageRater.js.map +7 -0
  142. package/dist/modules/billing/lib/usageRunner.js +82 -0
  143. package/dist/modules/billing/lib/usageRunner.js.map +7 -0
  144. package/dist/modules/billing/migrations/Migration20260519000000_billing.js +144 -0
  145. package/dist/modules/billing/migrations/Migration20260519000000_billing.js.map +7 -0
  146. package/dist/modules/billing/setup.js +190 -0
  147. package/dist/modules/billing/setup.js.map +7 -0
  148. package/dist/modules/billing/subscribers/payment-captured-to-paid.js +47 -0
  149. package/dist/modules/billing/subscribers/payment-captured-to-paid.js.map +7 -0
  150. package/dist/modules/billing/translations.js +5 -0
  151. package/dist/modules/billing/translations.js.map +7 -0
  152. package/dist/modules/billing/workers/reap-stale-bill-runs.js +31 -0
  153. package/dist/modules/billing/workers/reap-stale-bill-runs.js.map +7 -0
  154. package/package.json +148 -0
  155. package/src/modules/billing/__integration__/TC-BILL-001.spec.ts +116 -0
  156. package/src/modules/billing/__integration__/TC-BILL-002.spec.ts +169 -0
  157. package/src/modules/billing/__integration__/TC-BILL-003.spec.ts +28 -0
  158. package/src/modules/billing/__integration__/meta.ts +4 -0
  159. package/src/modules/billing/__tests__/commands/invoices.test.ts +464 -0
  160. package/src/modules/billing/__tests__/commands/itemsBulk.test.ts +284 -0
  161. package/src/modules/billing/__tests__/lib/billPeriod.test.ts +131 -0
  162. package/src/modules/billing/__tests__/lib/billRunEngine.test.ts +561 -0
  163. package/src/modules/billing/__tests__/lib/idempotency.test.ts +81 -0
  164. package/src/modules/billing/__tests__/lib/invoiceStatus.test.ts +97 -0
  165. package/src/modules/billing/__tests__/lib/invoiceWriter.test.ts +119 -0
  166. package/src/modules/billing/__tests__/lib/itemSelector.test.ts +192 -0
  167. package/src/modules/billing/__tests__/lib/seedsDemo.test.ts +86 -0
  168. package/src/modules/billing/__tests__/lib/tenantLock.test.ts +126 -0
  169. package/src/modules/billing/__tests__/lib/usageRater.test.ts +190 -0
  170. package/src/modules/billing/__tests__/package-isolation.test.ts +223 -0
  171. package/src/modules/billing/__tests__/setup.test.ts +107 -0
  172. package/src/modules/billing/__tests__/validators.test.ts +594 -0
  173. package/src/modules/billing/acl.ts +16 -0
  174. package/src/modules/billing/api/accounts/route.ts +198 -0
  175. package/src/modules/billing/api/export/account/[id]/route.ts +233 -0
  176. package/src/modules/billing/api/invoices/[id]/route.ts +143 -0
  177. package/src/modules/billing/api/invoices/add-line/route.ts +74 -0
  178. package/src/modules/billing/api/invoices/edit-line/route.ts +97 -0
  179. package/src/modules/billing/api/invoices/post/route.ts +97 -0
  180. package/src/modules/billing/api/invoices/remove-line/route.ts +75 -0
  181. package/src/modules/billing/api/invoices/route.ts +167 -0
  182. package/src/modules/billing/api/items/bulk/route.ts +92 -0
  183. package/src/modules/billing/api/items/route.ts +255 -0
  184. package/src/modules/billing/api/openapi.ts +33 -0
  185. package/src/modules/billing/api/run-outcomes/route.ts +149 -0
  186. package/src/modules/billing/api/runs/retry-failed/route.ts +88 -0
  187. package/src/modules/billing/api/runs/route.ts +170 -0
  188. package/src/modules/billing/api/test-invoices/wipe/route.ts +87 -0
  189. package/src/modules/billing/api/usage/route.ts +148 -0
  190. package/src/modules/billing/backend/billing/accounts/[id]/page.meta.ts +23 -0
  191. package/src/modules/billing/backend/billing/accounts/[id]/page.tsx +574 -0
  192. package/src/modules/billing/backend/billing/accounts/create/page.meta.ts +23 -0
  193. package/src/modules/billing/backend/billing/accounts/create/page.tsx +101 -0
  194. package/src/modules/billing/backend/billing/accounts/page.meta.ts +16 -0
  195. package/src/modules/billing/backend/billing/accounts/page.tsx +222 -0
  196. package/src/modules/billing/backend/billing/invoices/[id]/page.meta.ts +23 -0
  197. package/src/modules/billing/backend/billing/invoices/[id]/page.tsx +613 -0
  198. package/src/modules/billing/backend/billing/invoices/page.meta.ts +16 -0
  199. package/src/modules/billing/backend/billing/invoices/page.tsx +245 -0
  200. package/src/modules/billing/backend/billing/items/[id]/page.meta.ts +23 -0
  201. package/src/modules/billing/backend/billing/items/[id]/page.tsx +366 -0
  202. package/src/modules/billing/backend/billing/items/create/page.meta.ts +23 -0
  203. package/src/modules/billing/backend/billing/items/create/page.tsx +110 -0
  204. package/src/modules/billing/backend/billing/items/page.meta.ts +16 -0
  205. package/src/modules/billing/backend/billing/items/page.tsx +272 -0
  206. package/src/modules/billing/backend/billing/runs/[id]/page.meta.ts +19 -0
  207. package/src/modules/billing/backend/billing/runs/[id]/page.tsx +404 -0
  208. package/src/modules/billing/backend/billing/runs/page.meta.ts +16 -0
  209. package/src/modules/billing/backend/billing/runs/page.tsx +426 -0
  210. package/src/modules/billing/backend/billing/usage/create/page.meta.ts +23 -0
  211. package/src/modules/billing/backend/billing/usage/create/page.tsx +120 -0
  212. package/src/modules/billing/ce.ts +74 -0
  213. package/src/modules/billing/cli.ts +89 -0
  214. package/src/modules/billing/commands/accounts.ts +205 -0
  215. package/src/modules/billing/commands/index.ts +13 -0
  216. package/src/modules/billing/commands/invoices.ts +542 -0
  217. package/src/modules/billing/commands/items.ts +438 -0
  218. package/src/modules/billing/commands/runs.ts +166 -0
  219. package/src/modules/billing/commands/usage.ts +118 -0
  220. package/src/modules/billing/components/AccountForm.tsx +517 -0
  221. package/src/modules/billing/components/DetailFields.tsx +60 -0
  222. package/src/modules/billing/components/ItemForm.tsx +558 -0
  223. package/src/modules/billing/components/LineFormDialog.tsx +253 -0
  224. package/src/modules/billing/components/UsageForm.tsx +326 -0
  225. package/src/modules/billing/data/entities.ts +533 -0
  226. package/src/modules/billing/data/entityIds.ts +25 -0
  227. package/src/modules/billing/data/validators.ts +562 -0
  228. package/src/modules/billing/di.ts +14 -0
  229. package/src/modules/billing/events.ts +47 -0
  230. package/src/modules/billing/i18n/en.json +336 -0
  231. package/src/modules/billing/i18n/pl.json +336 -0
  232. package/src/modules/billing/index.ts +22 -0
  233. package/src/modules/billing/lib/billPeriod.ts +181 -0
  234. package/src/modules/billing/lib/billRunEngine.ts +416 -0
  235. package/src/modules/billing/lib/billRunLabel.ts +14 -0
  236. package/src/modules/billing/lib/idempotency.ts +46 -0
  237. package/src/modules/billing/lib/invoiceStatus.ts +61 -0
  238. package/src/modules/billing/lib/invoiceWriter.ts +260 -0
  239. package/src/modules/billing/lib/itemSelector.ts +154 -0
  240. package/src/modules/billing/lib/seeds/demo.ts +199 -0
  241. package/src/modules/billing/lib/tenantLock.ts +87 -0
  242. package/src/modules/billing/lib/usageRater.ts +250 -0
  243. package/src/modules/billing/lib/usageRunner.ts +189 -0
  244. package/src/modules/billing/migrations/Migration20260519000000_billing.ts +175 -0
  245. package/src/modules/billing/setup.ts +252 -0
  246. package/src/modules/billing/subscribers/payment-captured-to-paid.ts +89 -0
  247. package/src/modules/billing/translations.ts +9 -0
  248. package/src/modules/billing/workers/reap-stale-bill-runs.ts +57 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/modules/billing/ce.ts"],
4
+ "sourcesContent": ["import type { CustomEntitySpec } from '@open-mercato/shared/modules/entities'\n\n/**\n * Billing module entity registry.\n *\n * Listing our MikroORM entities here gets them into the framework's\n * `E.billing.<entity>` generated registry (`entities.ids.generated.ts`),\n * which the CRUD factory, query engine, and indexers reference. Phase 0\n * shipped with no entries because the standalone CLI didn't traverse\n * `@dainamite/*` packages \u2014 adding them in Phase 1 once the resolver\n * patch lands.\n *\n * `fields: []` means billing does NOT expose custom-field surfaces on\n * these entities today (no EAV). Adding fields here is reserved for\n * Phase 4+ if operators request per-tenant custom fields on Billing\n * Account or Billing Item.\n *\n * `showInSidebar: false` keeps the Custom Entities admin UI from listing\n * these \u2014 they are first-class entities with their own dedicated pages\n * (Phase 4), not generic EAV entries.\n */\nconst entities: CustomEntitySpec[] = [\n {\n id: 'billing:billing_account',\n label: 'Billing Account',\n description: 'A per-customer container for billing items, usage, and bill-cycle metadata.',\n labelField: 'name',\n showInSidebar: false,\n fields: [],\n },\n {\n id: 'billing:billing_item',\n label: 'Billing Item',\n description: 'A single charge (one_time / recurring / usage) attached to a Billing Account.',\n labelField: 'description',\n showInSidebar: false,\n fields: [],\n },\n {\n id: 'billing:billing_account_usage',\n label: 'Billing Account Usage',\n description: 'A pre-aggregated usage record uploaded by external metering systems.',\n labelField: 'id',\n showInSidebar: false,\n fields: [],\n },\n {\n id: 'billing:billing_run',\n label: 'Bill Run',\n description: 'A single execution of the Bill Run engine (schedule or manual trigger).',\n labelField: 'id',\n showInSidebar: false,\n fields: [],\n },\n {\n id: 'billing:billing_run_outcome',\n label: 'Bill Run Outcome',\n description: 'Per-account outcome of a Bill Run \u2014 success / warnings / skipped / failed.',\n labelField: 'id',\n showInSidebar: false,\n fields: [],\n },\n {\n id: 'billing:billing_draft_invoice_edit',\n label: 'Draft Invoice Edit',\n description: 'Append-only audit of operator edits on draft invoice lines.',\n labelField: 'id',\n showInSidebar: false,\n fields: [],\n },\n]\n\nexport { entities }\nexport default entities\n"],
5
+ "mappings": "AAqBA,MAAM,WAA+B;AAAA,EACnC;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,QAAQ,CAAC;AAAA,EACX;AACF;AAGA,IAAO,aAAQ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,67 @@
1
+ import { createRequestContainer } from "@open-mercato/shared/lib/di/container";
2
+ import { seedBillingDemo } from "./lib/seeds/demo.js";
3
+ function parseArgs(rest) {
4
+ const out = {};
5
+ for (let i = 0; i < rest.length; i++) {
6
+ const token = rest[i];
7
+ if (!token || !token.startsWith("--")) continue;
8
+ const key = token.slice(2);
9
+ const next = rest[i + 1];
10
+ if (next === void 0 || next.startsWith("--")) out[key] = true;
11
+ else {
12
+ out[key] = next;
13
+ i++;
14
+ }
15
+ }
16
+ return out;
17
+ }
18
+ async function resolveScope(em, args) {
19
+ const orgArg = typeof args.org === "string" ? args.org : void 0;
20
+ const tenantArg = typeof args.tenant === "string" ? args.tenant : void 0;
21
+ const { Organization } = await import("@open-mercato/core/modules/directory/data/entities");
22
+ if (orgArg) {
23
+ const org2 = await em.findOne(Organization, { id: orgArg });
24
+ if (!org2) return null;
25
+ return { organizationId: org2.id, tenantId: tenantArg ?? org2.tenant.id };
26
+ }
27
+ const orgs = await em.find(
28
+ Organization,
29
+ { isActive: true },
30
+ { orderBy: { createdAt: "asc" }, limit: 5 }
31
+ );
32
+ if (orgs.length === 0) return null;
33
+ const org = orgs[0];
34
+ if (orgs.length > 1) {
35
+ console.warn(
36
+ `[billing seed] Multiple organizations found \u2014 defaulting to "${org.name}" (${org.id}). Pass --org <id> to target another.`
37
+ );
38
+ }
39
+ return { organizationId: org.id, tenantId: tenantArg ?? org.tenant.id };
40
+ }
41
+ const seed = {
42
+ command: "seed",
43
+ async run(rest) {
44
+ const args = parseArgs(rest);
45
+ const reset = Boolean(args.reset);
46
+ const container = await createRequestContainer();
47
+ const em = container.resolve("em");
48
+ const scope = await resolveScope(em, args);
49
+ if (!scope) {
50
+ console.error(
51
+ '[billing seed] No organization found. Run "yarn initialize" first, or pass --org <id>.'
52
+ );
53
+ return;
54
+ }
55
+ const res = await seedBillingDemo(em, scope, { reset });
56
+ console.log(
57
+ `[billing seed] tenant=${scope.tenantId} org=${scope.organizationId}${reset ? " (reset)" : ""}
58
+ \u2713 accounts +${res.accountsCreated}, items +${res.itemsCreated}, usage +${res.usageCreated} (existing rows left untouched)
59
+ \u2192 Bill Runs \xB7 New run \xB7 As-of = today \xB7 Real \u2192 invoice for the previous month.`
60
+ );
61
+ }
62
+ };
63
+ var cli_default = [seed];
64
+ export {
65
+ cli_default as default
66
+ };
67
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/modules/billing/cli.ts"],
4
+ "sourcesContent": ["import type { ModuleCli } from '@open-mercato/shared/modules/registry'\nimport { createRequestContainer } from '@open-mercato/shared/lib/di/container'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { seedBillingDemo } from './lib/seeds/demo'\n\n/**\n * `mercato billing seed [--reset] [--tenant <id>] [--org <id>]`\n *\n * Loads self-contained billing test data (demo accounts + recurring/usage\n * items + an unrated usage record) into a single tenant. With no `--tenant`/\n * `--org`, it resolves the first (primary) organization created by\n * `mercato init`. `--reset` clears the seed's own rows first.\n */\n\nfunction parseArgs(rest: string[]): Record<string, string | boolean> {\n const out: Record<string, string | boolean> = {}\n for (let i = 0; i < rest.length; i++) {\n const token = rest[i]\n if (!token || !token.startsWith('--')) continue\n const key = token.slice(2)\n const next = rest[i + 1]\n if (next === undefined || next.startsWith('--')) out[key] = true\n else {\n out[key] = next\n i++\n }\n }\n return out\n}\n\nasync function resolveScope(\n em: EntityManager,\n args: Record<string, string | boolean>,\n): Promise<{ tenantId: string; organizationId: string } | null> {\n const orgArg = typeof args.org === 'string' ? args.org : undefined\n const tenantArg = typeof args.tenant === 'string' ? args.tenant : undefined\n\n const { Organization } = await import('@open-mercato/core/modules/directory/data/entities')\n\n if (orgArg) {\n const org = await em.findOne(Organization, { id: orgArg } as never)\n if (!org) return null\n return { organizationId: org.id, tenantId: tenantArg ?? org.tenant.id }\n }\n\n const orgs = await em.find(\n Organization,\n { isActive: true } as never,\n { orderBy: { createdAt: 'asc' } as never, limit: 5 },\n )\n if (orgs.length === 0) return null\n const org = orgs[0]\n if (orgs.length > 1) {\n console.warn(\n `[billing seed] Multiple organizations found \u2014 defaulting to \"${org.name}\" (${org.id}). ` +\n `Pass --org <id> to target another.`,\n )\n }\n return { organizationId: org.id, tenantId: tenantArg ?? org.tenant.id }\n}\n\nconst seed: ModuleCli = {\n command: 'seed',\n async run(rest) {\n const args = parseArgs(rest)\n const reset = Boolean(args.reset)\n\n const container = await createRequestContainer()\n const em = container.resolve<EntityManager>('em')\n\n const scope = await resolveScope(em, args)\n if (!scope) {\n console.error(\n '[billing seed] No organization found. Run \"yarn initialize\" first, or pass --org <id>.',\n )\n return\n }\n\n const res = await seedBillingDemo(em, scope, { reset })\n console.log(\n `[billing seed] tenant=${scope.tenantId} org=${scope.organizationId}${reset ? ' (reset)' : ''}\\n` +\n ` \u2713 accounts +${res.accountsCreated}, items +${res.itemsCreated}, usage +${res.usageCreated} ` +\n `(existing rows left untouched)\\n` +\n ` \u2192 Bill Runs \u00B7 New run \u00B7 As-of = today \u00B7 Real \u2192 invoice for the previous month.`,\n )\n },\n}\n\nexport default [seed]\n"],
5
+ "mappings": "AACA,SAAS,8BAA8B;AAEvC,SAAS,uBAAuB;AAWhC,SAAS,UAAU,MAAkD;AACnE,QAAM,MAAwC,CAAC;AAC/C,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,CAAC,SAAS,CAAC,MAAM,WAAW,IAAI,EAAG;AACvC,UAAM,MAAM,MAAM,MAAM,CAAC;AACzB,UAAM,OAAO,KAAK,IAAI,CAAC;AACvB,QAAI,SAAS,UAAa,KAAK,WAAW,IAAI,EAAG,KAAI,GAAG,IAAI;AAAA,SACvD;AACH,UAAI,GAAG,IAAI;AACX;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAe,aACb,IACA,MAC8D;AAC9D,QAAM,SAAS,OAAO,KAAK,QAAQ,WAAW,KAAK,MAAM;AACzD,QAAM,YAAY,OAAO,KAAK,WAAW,WAAW,KAAK,SAAS;AAElE,QAAM,EAAE,aAAa,IAAI,MAAM,OAAO,oDAAoD;AAE1F,MAAI,QAAQ;AACV,UAAMA,OAAM,MAAM,GAAG,QAAQ,cAAc,EAAE,IAAI,OAAO,CAAU;AAClE,QAAI,CAACA,KAAK,QAAO;AACjB,WAAO,EAAE,gBAAgBA,KAAI,IAAI,UAAU,aAAaA,KAAI,OAAO,GAAG;AAAA,EACxE;AAEA,QAAM,OAAO,MAAM,GAAG;AAAA,IACpB;AAAA,IACA,EAAE,UAAU,KAAK;AAAA,IACjB,EAAE,SAAS,EAAE,WAAW,MAAM,GAAY,OAAO,EAAE;AAAA,EACrD;AACA,MAAI,KAAK,WAAW,EAAG,QAAO;AAC9B,QAAM,MAAM,KAAK,CAAC;AAClB,MAAI,KAAK,SAAS,GAAG;AACnB,YAAQ;AAAA,MACN,qEAAgE,IAAI,IAAI,MAAM,IAAI,EAAE;AAAA,IAEtF;AAAA,EACF;AACA,SAAO,EAAE,gBAAgB,IAAI,IAAI,UAAU,aAAa,IAAI,OAAO,GAAG;AACxE;AAEA,MAAM,OAAkB;AAAA,EACtB,SAAS;AAAA,EACT,MAAM,IAAI,MAAM;AACd,UAAM,OAAO,UAAU,IAAI;AAC3B,UAAM,QAAQ,QAAQ,KAAK,KAAK;AAEhC,UAAM,YAAY,MAAM,uBAAuB;AAC/C,UAAM,KAAK,UAAU,QAAuB,IAAI;AAEhD,UAAM,QAAQ,MAAM,aAAa,IAAI,IAAI;AACzC,QAAI,CAAC,OAAO;AACV,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,MAAM,MAAM,gBAAgB,IAAI,OAAO,EAAE,MAAM,CAAC;AACtD,YAAQ;AAAA,MACN,yBAAyB,MAAM,QAAQ,QAAQ,MAAM,cAAc,GAAG,QAAQ,aAAa,EAAE;AAAA,qBAC1E,IAAI,eAAe,YAAY,IAAI,YAAY,YAAY,IAAI,YAAY;AAAA;AAAA,IAGhG;AAAA,EACF;AACF;AAEA,IAAO,cAAQ,CAAC,IAAI;",
6
+ "names": ["org"]
7
+ }
@@ -0,0 +1,157 @@
1
+ import { registerCommand } from "@open-mercato/shared/lib/commands";
2
+ import {
3
+ ensureOrganizationScope,
4
+ ensureTenantScope
5
+ } from "@open-mercato/shared/lib/commands/scope";
6
+ import {
7
+ emitCrudSideEffects,
8
+ requireId
9
+ } from "@open-mercato/shared/lib/commands/helpers";
10
+ import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
11
+ import { BillingAccount } from "../data/entities.js";
12
+ import { billingEntityIds } from "../data/entityIds.js";
13
+ import {
14
+ billingAccountCreateSchema,
15
+ billingAccountDeleteSchema,
16
+ billingAccountUpdateSchema
17
+ } from "../data/validators.js";
18
+ const accountIndexer = { entityType: billingEntityIds.account };
19
+ const accountEvents = { module: "billing", entity: "account", persistent: true };
20
+ function getEm(ctx) {
21
+ return ctx.container.resolve("em").fork();
22
+ }
23
+ function getDataEngine(ctx) {
24
+ return ctx.container.resolve("dataEngine");
25
+ }
26
+ const createAccountCommand = {
27
+ id: "billing.accounts.create",
28
+ async execute(rawInput, ctx) {
29
+ const parsed = billingAccountCreateSchema.parse(rawInput);
30
+ ensureTenantScope(ctx, parsed.tenantId);
31
+ ensureOrganizationScope(ctx, parsed.organizationId);
32
+ const em = getEm(ctx);
33
+ const now = /* @__PURE__ */ new Date();
34
+ const entity = em.create(BillingAccount, {
35
+ organizationId: parsed.organizationId,
36
+ tenantId: parsed.tenantId,
37
+ customerId: parsed.customerId,
38
+ name: parsed.name,
39
+ currencyCode: parsed.currencyCode,
40
+ billCycle: parsed.billCycle,
41
+ billCycleAnchor: parsed.billCycleAnchor,
42
+ invoiceEmail: parsed.invoiceEmail,
43
+ invoiceLanguage: parsed.invoiceLanguage,
44
+ taxId: parsed.taxId ?? null,
45
+ invoiceAddress: parsed.invoiceAddress,
46
+ nextBillDate: parsed.nextBillDate,
47
+ lastBillDate: parsed.lastBillDate ?? null,
48
+ isActive: parsed.isActive ?? true,
49
+ createdAt: now,
50
+ updatedAt: now
51
+ });
52
+ em.persist(entity);
53
+ await em.flush();
54
+ await emitCrudSideEffects({
55
+ dataEngine: getDataEngine(ctx),
56
+ action: "created",
57
+ entity,
58
+ identifiers: {
59
+ id: entity.id,
60
+ tenantId: entity.tenantId,
61
+ organizationId: entity.organizationId
62
+ },
63
+ indexer: accountIndexer,
64
+ events: accountEvents
65
+ });
66
+ return { id: entity.id };
67
+ }
68
+ };
69
+ const updateAccountCommand = {
70
+ id: "billing.accounts.update",
71
+ async execute(rawInput, ctx) {
72
+ const parsed = billingAccountUpdateSchema.parse(rawInput);
73
+ ensureTenantScope(ctx, parsed.tenantId);
74
+ ensureOrganizationScope(ctx, parsed.organizationId);
75
+ const em = getEm(ctx);
76
+ const record = await em.findOne(BillingAccount, {
77
+ id: parsed.id,
78
+ tenantId: parsed.tenantId,
79
+ organizationId: parsed.organizationId,
80
+ deletedAt: null
81
+ });
82
+ if (!record) {
83
+ throw new CrudHttpError(404, { error: "Billing account not found" });
84
+ }
85
+ if (parsed.name !== void 0) record.name = parsed.name;
86
+ if (parsed.billCycle !== void 0) record.billCycle = parsed.billCycle;
87
+ if (parsed.billCycleAnchor !== void 0) record.billCycleAnchor = parsed.billCycleAnchor;
88
+ if (parsed.invoiceEmail !== void 0) record.invoiceEmail = parsed.invoiceEmail;
89
+ if (parsed.invoiceLanguage !== void 0) record.invoiceLanguage = parsed.invoiceLanguage;
90
+ if (parsed.taxId !== void 0) record.taxId = parsed.taxId;
91
+ if (parsed.invoiceAddress !== void 0) {
92
+ record.invoiceAddress = parsed.invoiceAddress;
93
+ }
94
+ if (parsed.nextBillDate !== void 0) record.nextBillDate = parsed.nextBillDate;
95
+ if (parsed.lastBillDate !== void 0) record.lastBillDate = parsed.lastBillDate;
96
+ if (parsed.isActive !== void 0) record.isActive = parsed.isActive;
97
+ record.updatedAt = /* @__PURE__ */ new Date();
98
+ await em.flush();
99
+ await emitCrudSideEffects({
100
+ dataEngine: getDataEngine(ctx),
101
+ action: "updated",
102
+ entity: record,
103
+ identifiers: {
104
+ id: record.id,
105
+ tenantId: record.tenantId,
106
+ organizationId: record.organizationId
107
+ },
108
+ indexer: accountIndexer,
109
+ events: accountEvents
110
+ });
111
+ return { id: record.id };
112
+ }
113
+ };
114
+ const deleteAccountCommand = {
115
+ id: "billing.accounts.delete",
116
+ async execute(rawInput, ctx) {
117
+ const parsed = billingAccountDeleteSchema.parse(rawInput);
118
+ ensureTenantScope(ctx, parsed.tenantId);
119
+ ensureOrganizationScope(ctx, parsed.organizationId);
120
+ const id = requireId(parsed);
121
+ const em = getEm(ctx);
122
+ const record = await em.findOne(BillingAccount, {
123
+ id,
124
+ tenantId: parsed.tenantId,
125
+ organizationId: parsed.organizationId,
126
+ deletedAt: null
127
+ });
128
+ if (!record) {
129
+ throw new CrudHttpError(404, { error: "Billing account not found" });
130
+ }
131
+ record.deletedAt = /* @__PURE__ */ new Date();
132
+ record.updatedAt = record.deletedAt;
133
+ await em.flush();
134
+ await emitCrudSideEffects({
135
+ dataEngine: getDataEngine(ctx),
136
+ action: "deleted",
137
+ entity: record,
138
+ identifiers: {
139
+ id: record.id,
140
+ tenantId: record.tenantId,
141
+ organizationId: record.organizationId
142
+ },
143
+ indexer: accountIndexer,
144
+ events: accountEvents
145
+ });
146
+ return { id: record.id };
147
+ }
148
+ };
149
+ registerCommand(createAccountCommand);
150
+ registerCommand(updateAccountCommand);
151
+ registerCommand(deleteAccountCommand);
152
+ export {
153
+ createAccountCommand,
154
+ deleteAccountCommand,
155
+ updateAccountCommand
156
+ };
157
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/commands/accounts.ts"],
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport type { CommandHandler, CommandRuntimeContext } from '@open-mercato/shared/lib/commands/types'\nimport { registerCommand } from '@open-mercato/shared/lib/commands'\nimport {\n ensureOrganizationScope,\n ensureTenantScope,\n} from '@open-mercato/shared/lib/commands/scope'\nimport {\n emitCrudSideEffects,\n requireId,\n} from '@open-mercato/shared/lib/commands/helpers'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport type { DataEngine } from '@open-mercato/shared/lib/data/engine'\nimport { BillingAccount } from '../data/entities'\nimport { billingEntityIds } from '../data/entityIds'\nimport {\n billingAccountCreateSchema,\n billingAccountDeleteSchema,\n billingAccountUpdateSchema,\n type BillingAccountCreateInput,\n type BillingAccountDeleteInput,\n type BillingAccountUpdateInput,\n} from '../data/validators'\n\n/**\n * BillingAccount writes \u2014 create / update / soft-delete.\n *\n * Phase 1 keeps the command surface lean \u2014 no undo / snapshot / audit\n * log. Phase 4 (admin UI + posting flow) revisits to add operator-driven\n * undo. The patterns to add:\n * - `prepare`: capture BEFORE snapshot for update / delete\n * - `captureAfter`: capture AFTER snapshot\n * - `buildLog`: emit a structured audit log entry\n * - `undo`: restore from snapshots + reverse side effects\n * See `node_modules/@open-mercato/core/src/modules/customers/commands/people.ts`\n * for the canonical full-feature shape.\n */\n\nconst accountIndexer = { entityType: billingEntityIds.account } as const\nconst accountEvents = { module: 'billing', entity: 'account', persistent: true } as const\n\nfunction getEm(ctx: CommandRuntimeContext): EntityManager {\n return (ctx.container.resolve('em') as EntityManager).fork()\n}\n\nfunction getDataEngine(ctx: CommandRuntimeContext): DataEngine {\n return ctx.container.resolve('dataEngine') as DataEngine\n}\n\n// \u2500\u2500\u2500 Create \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst createAccountCommand: CommandHandler<BillingAccountCreateInput, { id: string }> = {\n id: 'billing.accounts.create',\n\n async execute(rawInput, ctx) {\n const parsed = billingAccountCreateSchema.parse(rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = getEm(ctx)\n const now = new Date()\n const entity = em.create(BillingAccount, {\n organizationId: parsed.organizationId,\n tenantId: parsed.tenantId,\n customerId: parsed.customerId,\n name: parsed.name,\n currencyCode: parsed.currencyCode,\n billCycle: parsed.billCycle,\n billCycleAnchor: parsed.billCycleAnchor,\n invoiceEmail: parsed.invoiceEmail,\n invoiceLanguage: parsed.invoiceLanguage,\n taxId: parsed.taxId ?? null,\n invoiceAddress: parsed.invoiceAddress as Record<string, unknown>,\n nextBillDate: parsed.nextBillDate,\n lastBillDate: parsed.lastBillDate ?? null,\n isActive: parsed.isActive ?? true,\n createdAt: now,\n updatedAt: now,\n })\n em.persist(entity)\n await em.flush()\n\n await emitCrudSideEffects({\n dataEngine: getDataEngine(ctx),\n action: 'created',\n entity,\n identifiers: {\n id: entity.id,\n tenantId: entity.tenantId,\n organizationId: entity.organizationId,\n },\n indexer: accountIndexer,\n events: accountEvents,\n })\n\n return { id: entity.id }\n },\n}\n\n// \u2500\u2500\u2500 Update \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst updateAccountCommand: CommandHandler<BillingAccountUpdateInput, { id: string }> = {\n id: 'billing.accounts.update',\n\n async execute(rawInput, ctx) {\n const parsed = billingAccountUpdateSchema.parse(rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n\n const em = getEm(ctx)\n const record = await em.findOne(BillingAccount, {\n id: parsed.id,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n deletedAt: null,\n })\n if (!record) {\n throw new CrudHttpError(404, { error: 'Billing account not found' })\n }\n\n if (parsed.name !== undefined) record.name = parsed.name\n if (parsed.billCycle !== undefined) record.billCycle = parsed.billCycle\n if (parsed.billCycleAnchor !== undefined) record.billCycleAnchor = parsed.billCycleAnchor\n if (parsed.invoiceEmail !== undefined) record.invoiceEmail = parsed.invoiceEmail\n if (parsed.invoiceLanguage !== undefined) record.invoiceLanguage = parsed.invoiceLanguage\n if (parsed.taxId !== undefined) record.taxId = parsed.taxId\n if (parsed.invoiceAddress !== undefined) {\n record.invoiceAddress = parsed.invoiceAddress as Record<string, unknown>\n }\n if (parsed.nextBillDate !== undefined) record.nextBillDate = parsed.nextBillDate\n if (parsed.lastBillDate !== undefined) record.lastBillDate = parsed.lastBillDate\n if (parsed.isActive !== undefined) record.isActive = parsed.isActive\n\n record.updatedAt = new Date()\n await em.flush()\n\n await emitCrudSideEffects({\n dataEngine: getDataEngine(ctx),\n action: 'updated',\n entity: record,\n identifiers: {\n id: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n },\n indexer: accountIndexer,\n events: accountEvents,\n })\n\n return { id: record.id }\n },\n}\n\n// \u2500\u2500\u2500 Delete (soft) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst deleteAccountCommand: CommandHandler<BillingAccountDeleteInput, { id: string }> = {\n id: 'billing.accounts.delete',\n\n async execute(rawInput, ctx) {\n const parsed = billingAccountDeleteSchema.parse(rawInput)\n ensureTenantScope(ctx, parsed.tenantId)\n ensureOrganizationScope(ctx, parsed.organizationId)\n const id = requireId(parsed)\n\n const em = getEm(ctx)\n const record = await em.findOne(BillingAccount, {\n id,\n tenantId: parsed.tenantId,\n organizationId: parsed.organizationId,\n deletedAt: null,\n })\n if (!record) {\n throw new CrudHttpError(404, { error: 'Billing account not found' })\n }\n\n record.deletedAt = new Date()\n record.updatedAt = record.deletedAt\n await em.flush()\n\n await emitCrudSideEffects({\n dataEngine: getDataEngine(ctx),\n action: 'deleted',\n entity: record,\n identifiers: {\n id: record.id,\n tenantId: record.tenantId,\n organizationId: record.organizationId,\n },\n indexer: accountIndexer,\n events: accountEvents,\n })\n\n return { id: record.id }\n },\n}\n\nregisterCommand(createAccountCommand)\nregisterCommand(updateAccountCommand)\nregisterCommand(deleteAccountCommand)\n\nexport {\n createAcc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;AAAA,IACV,CAAC;AAED,WAAO,EAAE,IAAI,OAAO,GAAG;AAAA,EACzB;AACF;AAEA,gBAAgB,oBAAoB;AACpC,gBAAgB,oBAAoB;AACpC,gBAAgB,oBAAoB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ import "./accounts.js";
2
+ import "./items.js";
3
+ import "./usage.js";
4
+ import "./runs.js";
5
+ import "./invoices.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/billing/commands/index.ts"],
4
+ "sourcesContent": ["/**\n * Billing module command registry.\n *\n * Each file below side-effect-registers its commands via\n * `registerCommand(...)` from `@open-mercato/shared/lib/commands`.\n * Importing this barrel forces the registrations to run. The CRUD\n * factory's `commandId` lookups then resolve at request time.\n */\nimport './accounts'\nimport './items'\nimport './usage'\nimport './runs'\nimport './invoices'\n"],
5
+ "mappings": "AAQA,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;AACP,OAAO;",
6
+ "names": []
7
+ }