@dainamite/cpq 0.2.2

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 (504) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +21 -0
  3. package/MIGRATION.md +236 -0
  4. package/README.md +108 -0
  5. package/dist/modules/cpq/acl.js +30 -0
  6. package/dist/modules/cpq/acl.js.map +7 -0
  7. package/dist/modules/cpq/api/_helpers/handleArcError.js +37 -0
  8. package/dist/modules/cpq/api/_helpers/handleArcError.js.map +7 -0
  9. package/dist/modules/cpq/api/attribute-options/route.js +47 -0
  10. package/dist/modules/cpq/api/attribute-options/route.js.map +7 -0
  11. package/dist/modules/cpq/api/bundle-slots/route.js +101 -0
  12. package/dist/modules/cpq/api/bundle-slots/route.js.map +7 -0
  13. package/dist/modules/cpq/api/bundle-tree/route.js +28 -0
  14. package/dist/modules/cpq/api/bundle-tree/route.js.map +7 -0
  15. package/dist/modules/cpq/api/context.js +29 -0
  16. package/dist/modules/cpq/api/context.js.map +7 -0
  17. package/dist/modules/cpq/api/inventory/assets/route.js +113 -0
  18. package/dist/modules/cpq/api/inventory/assets/route.js.map +7 -0
  19. package/dist/modules/cpq/api/inventory/assets/status/route.js +35 -0
  20. package/dist/modules/cpq/api/inventory/assets/status/route.js.map +7 -0
  21. package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js +30 -0
  22. package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js.map +7 -0
  23. package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js +31 -0
  24. package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js.map +7 -0
  25. package/dist/modules/cpq/api/inventory/subscription-items/route.js +99 -0
  26. package/dist/modules/cpq/api/inventory/subscription-items/route.js.map +7 -0
  27. package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js +57 -0
  28. package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js.map +7 -0
  29. package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js +62 -0
  30. package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js.map +7 -0
  31. package/dist/modules/cpq/api/inventory/subscriptions/route.js +116 -0
  32. package/dist/modules/cpq/api/inventory/subscriptions/route.js.map +7 -0
  33. package/dist/modules/cpq/api/inventory/subscriptions/status/route.js +35 -0
  34. package/dist/modules/cpq/api/inventory/subscriptions/status/route.js.map +7 -0
  35. package/dist/modules/cpq/api/offering-components/route.js +91 -0
  36. package/dist/modules/cpq/api/offering-components/route.js.map +7 -0
  37. package/dist/modules/cpq/api/orders/[orderId]/activate/route.js +39 -0
  38. package/dist/modules/cpq/api/orders/[orderId]/activate/route.js.map +7 -0
  39. package/dist/modules/cpq/api/orders/[orderId]/route.js +28 -0
  40. package/dist/modules/cpq/api/orders/[orderId]/route.js.map +7 -0
  41. package/dist/modules/cpq/api/orders/[orderId]/status/route.js +38 -0
  42. package/dist/modules/cpq/api/orders/[orderId]/status/route.js.map +7 -0
  43. package/dist/modules/cpq/api/orders/route.js +71 -0
  44. package/dist/modules/cpq/api/orders/route.js.map +7 -0
  45. package/dist/modules/cpq/api/price-rules/route.js +180 -0
  46. package/dist/modules/cpq/api/price-rules/route.js.map +7 -0
  47. package/dist/modules/cpq/api/pricing-table-entries/route.js +142 -0
  48. package/dist/modules/cpq/api/pricing-table-entries/route.js.map +7 -0
  49. package/dist/modules/cpq/api/pricing-tables/route.js +179 -0
  50. package/dist/modules/cpq/api/pricing-tables/route.js.map +7 -0
  51. package/dist/modules/cpq/api/product-attributes/route.js +160 -0
  52. package/dist/modules/cpq/api/product-attributes/route.js.map +7 -0
  53. package/dist/modules/cpq/api/product-charges/route.js +166 -0
  54. package/dist/modules/cpq/api/product-charges/route.js.map +7 -0
  55. package/dist/modules/cpq/api/product-offerings/route.js +294 -0
  56. package/dist/modules/cpq/api/product-offerings/route.js.map +7 -0
  57. package/dist/modules/cpq/api/product-relationships/route.js +144 -0
  58. package/dist/modules/cpq/api/product-relationships/route.js.map +7 -0
  59. package/dist/modules/cpq/api/product-specifications/route.js +292 -0
  60. package/dist/modules/cpq/api/product-specifications/route.js.map +7 -0
  61. package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js +71 -0
  62. package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js.map +7 -0
  63. package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js +29 -0
  64. package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js.map +7 -0
  65. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js +54 -0
  66. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js.map +7 -0
  67. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js +27 -0
  68. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js.map +7 -0
  69. package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js +72 -0
  70. package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js.map +7 -0
  71. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js +35 -0
  72. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js.map +7 -0
  73. package/dist/modules/cpq/api/quotes/[quoteId]/route.js +102 -0
  74. package/dist/modules/cpq/api/quotes/[quoteId]/route.js.map +7 -0
  75. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js +27 -0
  76. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js.map +7 -0
  77. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js +79 -0
  78. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js.map +7 -0
  79. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js +95 -0
  80. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js.map +7 -0
  81. package/dist/modules/cpq/api/quotes/attributes/route.js +52 -0
  82. package/dist/modules/cpq/api/quotes/attributes/route.js.map +7 -0
  83. package/dist/modules/cpq/api/quotes/from-subscription/route.js +72 -0
  84. package/dist/modules/cpq/api/quotes/from-subscription/route.js.map +7 -0
  85. package/dist/modules/cpq/api/quotes/price/route.js +69 -0
  86. package/dist/modules/cpq/api/quotes/price/route.js.map +7 -0
  87. package/dist/modules/cpq/api/quotes/route.js +97 -0
  88. package/dist/modules/cpq/api/quotes/route.js.map +7 -0
  89. package/dist/modules/cpq/api/quotes/validate-relationships/route.js +86 -0
  90. package/dist/modules/cpq/api/quotes/validate-relationships/route.js.map +7 -0
  91. package/dist/modules/cpq/api/resolveQuotingService.js +7 -0
  92. package/dist/modules/cpq/api/resolveQuotingService.js.map +7 -0
  93. package/dist/modules/cpq/api/wizards/resolve/route.js +38 -0
  94. package/dist/modules/cpq/api/wizards/resolve/route.js.map +7 -0
  95. package/dist/modules/cpq/api/wizards/route.js +111 -0
  96. package/dist/modules/cpq/api/wizards/route.js.map +7 -0
  97. package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js +136 -0
  98. package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js.map +7 -0
  99. package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js +185 -0
  100. package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js.map +7 -0
  101. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js +343 -0
  102. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js.map +7 -0
  103. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js +13 -0
  104. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js.map +7 -0
  105. package/dist/modules/cpq/backend/cpq/inventory/page.js +35 -0
  106. package/dist/modules/cpq/backend/cpq/inventory/page.js.map +7 -0
  107. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js +18 -0
  108. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js.map +7 -0
  109. package/dist/modules/cpq/backend/cpq/inventory/shared.js +20 -0
  110. package/dist/modules/cpq/backend/cpq/inventory/shared.js.map +7 -0
  111. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js +794 -0
  112. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js.map +7 -0
  113. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js +13 -0
  114. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js.map +7 -0
  115. package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js +917 -0
  116. package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js.map +7 -0
  117. package/dist/modules/cpq/backend/cpq/offerings/page.js +405 -0
  118. package/dist/modules/cpq/backend/cpq/offerings/page.js.map +7 -0
  119. package/dist/modules/cpq/backend/cpq/offerings/page.meta.js +18 -0
  120. package/dist/modules/cpq/backend/cpq/offerings/page.meta.js.map +7 -0
  121. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js +677 -0
  122. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js.map +7 -0
  123. package/dist/modules/cpq/backend/cpq/orders/page.js +134 -0
  124. package/dist/modules/cpq/backend/cpq/orders/page.js.map +7 -0
  125. package/dist/modules/cpq/backend/cpq/orders/page.meta.js +18 -0
  126. package/dist/modules/cpq/backend/cpq/orders/page.meta.js.map +7 -0
  127. package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js +272 -0
  128. package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js.map +7 -0
  129. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js +407 -0
  130. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js.map +7 -0
  131. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js +13 -0
  132. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js.map +7 -0
  133. package/dist/modules/cpq/backend/cpq/price-rules/page.js +211 -0
  134. package/dist/modules/cpq/backend/cpq/price-rules/page.js.map +7 -0
  135. package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js +18 -0
  136. package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js.map +7 -0
  137. package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js +275 -0
  138. package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js.map +7 -0
  139. package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js +112 -0
  140. package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js.map +7 -0
  141. package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js +492 -0
  142. package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js.map +7 -0
  143. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js +50 -0
  144. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js.map +7 -0
  145. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js +249 -0
  146. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js.map +7 -0
  147. package/dist/modules/cpq/backend/cpq/pricing/page.js +87 -0
  148. package/dist/modules/cpq/backend/cpq/pricing/page.js.map +7 -0
  149. package/dist/modules/cpq/backend/cpq/pricing/page.meta.js +18 -0
  150. package/dist/modules/cpq/backend/cpq/pricing/page.meta.js.map +7 -0
  151. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js +652 -0
  152. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js.map +7 -0
  153. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js +1289 -0
  154. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js.map +7 -0
  155. package/dist/modules/cpq/backend/cpq/quotes/page.js +283 -0
  156. package/dist/modules/cpq/backend/cpq/quotes/page.js.map +7 -0
  157. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js +18 -0
  158. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js.map +7 -0
  159. package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js +214 -0
  160. package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js.map +7 -0
  161. package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js +1399 -0
  162. package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js.map +7 -0
  163. package/dist/modules/cpq/backend/cpq/specifications/page.js +148 -0
  164. package/dist/modules/cpq/backend/cpq/specifications/page.js.map +7 -0
  165. package/dist/modules/cpq/backend/cpq/specifications/page.meta.js +18 -0
  166. package/dist/modules/cpq/backend/cpq/specifications/page.meta.js.map +7 -0
  167. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js +204 -0
  168. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js.map +7 -0
  169. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js +191 -0
  170. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js.map +7 -0
  171. package/dist/modules/cpq/backend/cpq/wizards/page.js +119 -0
  172. package/dist/modules/cpq/backend/cpq/wizards/page.js.map +7 -0
  173. package/dist/modules/cpq/backend/cpq/wizards/page.meta.js +18 -0
  174. package/dist/modules/cpq/backend/cpq/wizards/page.meta.js.map +7 -0
  175. package/dist/modules/cpq/ce.js +151 -0
  176. package/dist/modules/cpq/ce.js.map +7 -0
  177. package/dist/modules/cpq/cli.js +11 -0
  178. package/dist/modules/cpq/cli.js.map +7 -0
  179. package/dist/modules/cpq/components/CpqListView.js +265 -0
  180. package/dist/modules/cpq/components/CpqListView.js.map +7 -0
  181. package/dist/modules/cpq/components/NumberInput.js +95 -0
  182. package/dist/modules/cpq/components/NumberInput.js.map +7 -0
  183. package/dist/modules/cpq/components/StatusPath.js +60 -0
  184. package/dist/modules/cpq/components/StatusPath.js.map +7 -0
  185. package/dist/modules/cpq/components/statusMaps.js +66 -0
  186. package/dist/modules/cpq/components/statusMaps.js.map +7 -0
  187. package/dist/modules/cpq/components/useCpqRowActions.js +125 -0
  188. package/dist/modules/cpq/components/useCpqRowActions.js.map +7 -0
  189. package/dist/modules/cpq/data/entities.js +1556 -0
  190. package/dist/modules/cpq/data/entities.js.map +7 -0
  191. package/dist/modules/cpq/data/validators.js +575 -0
  192. package/dist/modules/cpq/data/validators.js.map +7 -0
  193. package/dist/modules/cpq/di.js +57 -0
  194. package/dist/modules/cpq/di.js.map +7 -0
  195. package/dist/modules/cpq/events.js +50 -0
  196. package/dist/modules/cpq/events.js.map +7 -0
  197. package/dist/modules/cpq/index.js +16 -0
  198. package/dist/modules/cpq/index.js.map +7 -0
  199. package/dist/modules/cpq/lib/seeds/api.js +32 -0
  200. package/dist/modules/cpq/lib/seeds/api.js.map +7 -0
  201. package/dist/modules/cpq/lib/seeds/tenant-provisioning.js +158 -0
  202. package/dist/modules/cpq/lib/seeds/tenant-provisioning.js.map +7 -0
  203. package/dist/modules/cpq/lib/seeds.js +6 -0
  204. package/dist/modules/cpq/lib/seeds.js.map +7 -0
  205. package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js +40 -0
  206. package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js.map +7 -0
  207. package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js +54 -0
  208. package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js.map +7 -0
  209. package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js +15 -0
  210. package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js.map +7 -0
  211. package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js +62 -0
  212. package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js.map +7 -0
  213. package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js +56 -0
  214. package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js.map +7 -0
  215. package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js +26 -0
  216. package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js.map +7 -0
  217. package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js +37 -0
  218. package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js.map +7 -0
  219. package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js +35 -0
  220. package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js.map +7 -0
  221. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js +21 -0
  222. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js.map +7 -0
  223. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js +46 -0
  224. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js.map +7 -0
  225. package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js +118 -0
  226. package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js.map +7 -0
  227. package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js +63 -0
  228. package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js.map +7 -0
  229. package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js +28 -0
  230. package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js.map +7 -0
  231. package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js +36 -0
  232. package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js.map +7 -0
  233. package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js +14 -0
  234. package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js.map +7 -0
  235. package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js +14 -0
  236. package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js.map +7 -0
  237. package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js +58 -0
  238. package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js.map +7 -0
  239. package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js +29 -0
  240. package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js.map +7 -0
  241. package/dist/modules/cpq/services/cpqBundleService.js +447 -0
  242. package/dist/modules/cpq/services/cpqBundleService.js.map +7 -0
  243. package/dist/modules/cpq/services/cpqInventoryService.js +1371 -0
  244. package/dist/modules/cpq/services/cpqInventoryService.js.map +7 -0
  245. package/dist/modules/cpq/services/cpqOrderService.js +901 -0
  246. package/dist/modules/cpq/services/cpqOrderService.js.map +7 -0
  247. package/dist/modules/cpq/services/cpqPricingService.js +289 -0
  248. package/dist/modules/cpq/services/cpqPricingService.js.map +7 -0
  249. package/dist/modules/cpq/services/cpqProductService.js +204 -0
  250. package/dist/modules/cpq/services/cpqProductService.js.map +7 -0
  251. package/dist/modules/cpq/services/cpqQuotingService.js +1867 -0
  252. package/dist/modules/cpq/services/cpqQuotingService.js.map +7 -0
  253. package/dist/modules/cpq/services/cpqValidationService.js +234 -0
  254. package/dist/modules/cpq/services/cpqValidationService.js.map +7 -0
  255. package/dist/modules/cpq/services/cpqWizardService.js +137 -0
  256. package/dist/modules/cpq/services/cpqWizardService.js.map +7 -0
  257. package/dist/modules/cpq/services/types.js +114 -0
  258. package/dist/modules/cpq/services/types.js.map +7 -0
  259. package/dist/modules/cpq/setup.js +49 -0
  260. package/dist/modules/cpq/setup.js.map +7 -0
  261. package/dist/modules/cpq/subscribers/subscription-amended-log.js +18 -0
  262. package/dist/modules/cpq/subscribers/subscription-amended-log.js.map +7 -0
  263. package/dist/modules/cpq/subscribers/subscription-cancelled-log.js +19 -0
  264. package/dist/modules/cpq/subscribers/subscription-cancelled-log.js.map +7 -0
  265. package/dist/modules/cpq/subscribers/subscription-merged-log.js +20 -0
  266. package/dist/modules/cpq/subscribers/subscription-merged-log.js.map +7 -0
  267. package/dist/modules/cpq/subscribers/subscription-renewed-log.js +18 -0
  268. package/dist/modules/cpq/subscribers/subscription-renewed-log.js.map +7 -0
  269. package/dist/modules/cpq/subscribers/subscription-superseded-log.js +18 -0
  270. package/dist/modules/cpq/subscribers/subscription-superseded-log.js.map +7 -0
  271. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js +192 -0
  272. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js.map +7 -0
  273. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js +17 -0
  274. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js.map +7 -0
  275. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js +79 -0
  276. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js.map +7 -0
  277. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js +17 -0
  278. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js.map +7 -0
  279. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js +181 -0
  280. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js.map +7 -0
  281. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js +17 -0
  282. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js.map +7 -0
  283. package/dist/modules/cpq/widgets/injection-table.js +44 -0
  284. package/dist/modules/cpq/widgets/injection-table.js.map +7 -0
  285. package/dist/modules/cpq/workflows/WizardRunner.js +113 -0
  286. package/dist/modules/cpq/workflows/WizardRunner.js.map +7 -0
  287. package/dist/modules/cpq/workflows/WizardTrigger.js +116 -0
  288. package/dist/modules/cpq/workflows/WizardTrigger.js.map +7 -0
  289. package/dist/modules/cpq/workflows/engine.js +188 -0
  290. package/dist/modules/cpq/workflows/engine.js.map +7 -0
  291. package/dist/modules/cpq/workflows/registry.js +16 -0
  292. package/dist/modules/cpq/workflows/registry.js.map +7 -0
  293. package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js +119 -0
  294. package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js.map +7 -0
  295. package/dist/modules/cpq/workflows/steps/InventorySelectStep.js +24 -0
  296. package/dist/modules/cpq/workflows/steps/InventorySelectStep.js.map +7 -0
  297. package/dist/modules/cpq/workflows/steps/ItemListStep.js +115 -0
  298. package/dist/modules/cpq/workflows/steps/ItemListStep.js.map +7 -0
  299. package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js +327 -0
  300. package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js.map +7 -0
  301. package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js +231 -0
  302. package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js.map +7 -0
  303. package/dist/modules/cpq/workflows/steps/ReviewStep.js +152 -0
  304. package/dist/modules/cpq/workflows/steps/ReviewStep.js.map +7 -0
  305. package/dist/modules/cpq/workflows/steps/index.js +49 -0
  306. package/dist/modules/cpq/workflows/steps/index.js.map +7 -0
  307. package/dist/modules/cpq/workflows/types.js +1 -0
  308. package/dist/modules/cpq/workflows/types.js.map +7 -0
  309. package/package.json +150 -0
  310. package/src/modules/cpq/__integration__/TC-CPQ-001.spec.ts +177 -0
  311. package/src/modules/cpq/__integration__/TC-CPQ-002.spec.ts +123 -0
  312. package/src/modules/cpq/__integration__/TC-CPQ-003.spec.ts +115 -0
  313. package/src/modules/cpq/__integration__/TC-CPQ-004.spec.ts +184 -0
  314. package/src/modules/cpq/__integration__/TC-CPQ-005.spec.ts +43 -0
  315. package/src/modules/cpq/__integration__/TC-CPQ-006.spec.ts +87 -0
  316. package/src/modules/cpq/__integration__/TC-CPQ-007.spec.ts +79 -0
  317. package/src/modules/cpq/__integration__/TC-CPQ-008.spec.ts +55 -0
  318. package/src/modules/cpq/__integration__/TC-CPQ-009.spec.ts +45 -0
  319. package/src/modules/cpq/__integration__/TC-CPQ-010.spec.ts +54 -0
  320. package/src/modules/cpq/__integration__/TC-CPQ-011.spec.ts +24 -0
  321. package/src/modules/cpq/__integration__/TC-CPQ-012.spec.ts +62 -0
  322. package/src/modules/cpq/__integration__/TC-CPQ-ARC-001.spec.ts +52 -0
  323. package/src/modules/cpq/__integration__/TC-CPQ-ARC-002.spec.ts +65 -0
  324. package/src/modules/cpq/__integration__/TC-CPQ-ARC-003.spec.ts +107 -0
  325. package/src/modules/cpq/__integration__/TC-CPQ-ARC-004.spec.ts +74 -0
  326. package/src/modules/cpq/__integration__/TC-CPQ-ARC-005.spec.ts +86 -0
  327. package/src/modules/cpq/__integration__/TC-CPQ-ARC-006.spec.ts +79 -0
  328. package/src/modules/cpq/__integration__/TC-CPQ-ARC-007.spec.ts +63 -0
  329. package/src/modules/cpq/__integration__/TC-CPQ-ARC-008.spec.ts +62 -0
  330. package/src/modules/cpq/__integration__/TC-CPQ-ARC-009.spec.ts +62 -0
  331. package/src/modules/cpq/__integration__/TC-CPQ-ARC-010.spec.ts +59 -0
  332. package/src/modules/cpq/__integration__/TC-CPQ-ARC-011.spec.ts +128 -0
  333. package/src/modules/cpq/__integration__/_helpers/cpqArcFixtures.ts +208 -0
  334. package/src/modules/cpq/__tests__/package-isolation.test.ts +232 -0
  335. package/src/modules/cpq/acl.ts +26 -0
  336. package/src/modules/cpq/api/_helpers/__tests__/handleArcError.test.ts +117 -0
  337. package/src/modules/cpq/api/_helpers/handleArcError.ts +81 -0
  338. package/src/modules/cpq/api/attribute-options/route.ts +55 -0
  339. package/src/modules/cpq/api/bundle-slots/route.ts +112 -0
  340. package/src/modules/cpq/api/bundle-tree/route.ts +31 -0
  341. package/src/modules/cpq/api/context.ts +39 -0
  342. package/src/modules/cpq/api/inventory/assets/route.ts +123 -0
  343. package/src/modules/cpq/api/inventory/assets/status/route.ts +34 -0
  344. package/src/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.ts +30 -0
  345. package/src/modules/cpq/api/inventory/customer/[customerId]/route.ts +31 -0
  346. package/src/modules/cpq/api/inventory/subscription-items/route.ts +107 -0
  347. package/src/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.ts +64 -0
  348. package/src/modules/cpq/api/inventory/subscriptions/expiring/route.ts +66 -0
  349. package/src/modules/cpq/api/inventory/subscriptions/route.ts +126 -0
  350. package/src/modules/cpq/api/inventory/subscriptions/status/route.ts +34 -0
  351. package/src/modules/cpq/api/offering-components/route.ts +103 -0
  352. package/src/modules/cpq/api/orders/[orderId]/activate/route.ts +48 -0
  353. package/src/modules/cpq/api/orders/[orderId]/route.ts +28 -0
  354. package/src/modules/cpq/api/orders/[orderId]/status/route.ts +38 -0
  355. package/src/modules/cpq/api/orders/route.ts +77 -0
  356. package/src/modules/cpq/api/price-rules/route.ts +210 -0
  357. package/src/modules/cpq/api/pricing-table-entries/route.ts +159 -0
  358. package/src/modules/cpq/api/pricing-tables/route.ts +202 -0
  359. package/src/modules/cpq/api/product-attributes/route.ts +175 -0
  360. package/src/modules/cpq/api/product-charges/route.ts +181 -0
  361. package/src/modules/cpq/api/product-offerings/route.ts +329 -0
  362. package/src/modules/cpq/api/product-relationships/route.ts +156 -0
  363. package/src/modules/cpq/api/product-specifications/route.ts +325 -0
  364. package/src/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.ts +77 -0
  365. package/src/modules/cpq/api/quotes/[quoteId]/clone/route.ts +28 -0
  366. package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.ts +55 -0
  367. package/src/modules/cpq/api/quotes/[quoteId]/items/route.ts +26 -0
  368. package/src/modules/cpq/api/quotes/[quoteId]/merge-meta/route.ts +78 -0
  369. package/src/modules/cpq/api/quotes/[quoteId]/recalculate/route.ts +34 -0
  370. package/src/modules/cpq/api/quotes/[quoteId]/route.ts +109 -0
  371. package/src/modules/cpq/api/quotes/[quoteId]/status/route.ts +26 -0
  372. package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.ts +91 -0
  373. package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.ts +107 -0
  374. package/src/modules/cpq/api/quotes/attributes/route.ts +61 -0
  375. package/src/modules/cpq/api/quotes/from-subscription/route.ts +85 -0
  376. package/src/modules/cpq/api/quotes/price/route.ts +81 -0
  377. package/src/modules/cpq/api/quotes/route.ts +114 -0
  378. package/src/modules/cpq/api/quotes/validate-relationships/route.ts +100 -0
  379. package/src/modules/cpq/api/resolveQuotingService.ts +11 -0
  380. package/src/modules/cpq/api/wizards/resolve/route.ts +39 -0
  381. package/src/modules/cpq/api/wizards/route.ts +127 -0
  382. package/src/modules/cpq/backend/cpq/inventory/AssetsTable.tsx +166 -0
  383. package/src/modules/cpq/backend/cpq/inventory/SubscriptionsTable.tsx +251 -0
  384. package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.ts +9 -0
  385. package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.tsx +440 -0
  386. package/src/modules/cpq/backend/cpq/inventory/page.meta.ts +16 -0
  387. package/src/modules/cpq/backend/cpq/inventory/page.tsx +49 -0
  388. package/src/modules/cpq/backend/cpq/inventory/shared.tsx +32 -0
  389. package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.ts +9 -0
  390. package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.tsx +1085 -0
  391. package/src/modules/cpq/backend/cpq/offerings/[id]/page.tsx +1165 -0
  392. package/src/modules/cpq/backend/cpq/offerings/page.meta.ts +16 -0
  393. package/src/modules/cpq/backend/cpq/offerings/page.tsx +468 -0
  394. package/src/modules/cpq/backend/cpq/orders/[id]/page.tsx +921 -0
  395. package/src/modules/cpq/backend/cpq/orders/page.meta.ts +16 -0
  396. package/src/modules/cpq/backend/cpq/orders/page.tsx +182 -0
  397. package/src/modules/cpq/backend/cpq/price-rules/PriceRuleForm.tsx +310 -0
  398. package/src/modules/cpq/backend/cpq/price-rules/[id]/page.meta.ts +9 -0
  399. package/src/modules/cpq/backend/cpq/price-rules/[id]/page.tsx +472 -0
  400. package/src/modules/cpq/backend/cpq/price-rules/page.meta.ts +16 -0
  401. package/src/modules/cpq/backend/cpq/price-rules/page.tsx +253 -0
  402. package/src/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.tsx +431 -0
  403. package/src/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.tsx +122 -0
  404. package/src/modules/cpq/backend/cpq/pricing/[id]/page.tsx +588 -0
  405. package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.ts +90 -0
  406. package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.ts +338 -0
  407. package/src/modules/cpq/backend/cpq/pricing/page.meta.ts +16 -0
  408. package/src/modules/cpq/backend/cpq/pricing/page.tsx +111 -0
  409. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.tsx +737 -0
  410. package/src/modules/cpq/backend/cpq/quotes/[id]/page.tsx +1721 -0
  411. package/src/modules/cpq/backend/cpq/quotes/page.meta.ts +16 -0
  412. package/src/modules/cpq/backend/cpq/quotes/page.tsx +370 -0
  413. package/src/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.tsx +300 -0
  414. package/src/modules/cpq/backend/cpq/specifications/[id]/page.tsx +1722 -0
  415. package/src/modules/cpq/backend/cpq/specifications/page.meta.ts +16 -0
  416. package/src/modules/cpq/backend/cpq/specifications/page.tsx +191 -0
  417. package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.tsx +319 -0
  418. package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/page.tsx +234 -0
  419. package/src/modules/cpq/backend/cpq/wizards/page.meta.ts +16 -0
  420. package/src/modules/cpq/backend/cpq/wizards/page.tsx +141 -0
  421. package/src/modules/cpq/ce.ts +150 -0
  422. package/src/modules/cpq/cli.ts +10 -0
  423. package/src/modules/cpq/components/CpqListView.tsx +431 -0
  424. package/src/modules/cpq/components/NumberInput.tsx +166 -0
  425. package/src/modules/cpq/components/StatusPath.tsx +116 -0
  426. package/src/modules/cpq/components/statusMaps.ts +148 -0
  427. package/src/modules/cpq/components/useCpqRowActions.tsx +183 -0
  428. package/src/modules/cpq/data/__tests__/validators.arc.test.ts +271 -0
  429. package/src/modules/cpq/data/__tests__/validators.test.ts +782 -0
  430. package/src/modules/cpq/data/entities.ts +1467 -0
  431. package/src/modules/cpq/data/validators.ts +663 -0
  432. package/src/modules/cpq/di.ts +70 -0
  433. package/src/modules/cpq/events.ts +62 -0
  434. package/src/modules/cpq/index.ts +15 -0
  435. package/src/modules/cpq/lib/seeds/__tests__/api.test.ts +86 -0
  436. package/src/modules/cpq/lib/seeds/__tests__/tenant-provisioning.test.ts +349 -0
  437. package/src/modules/cpq/lib/seeds/api.ts +119 -0
  438. package/src/modules/cpq/lib/seeds/tenant-provisioning.ts +239 -0
  439. package/src/modules/cpq/lib/seeds.ts +18 -0
  440. package/src/modules/cpq/migrations/.snapshot-open-mercato.json +7473 -0
  441. package/src/modules/cpq/migrations/Migration20260220220000_cpq.ts +51 -0
  442. package/src/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.ts +70 -0
  443. package/src/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.ts +15 -0
  444. package/src/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.ts +73 -0
  445. package/src/modules/cpq/migrations/Migration20260402000000_cpq_workflows.ts +59 -0
  446. package/src/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.ts +30 -0
  447. package/src/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.ts +36 -0
  448. package/src/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.ts +33 -0
  449. package/src/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.ts +22 -0
  450. package/src/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.ts +56 -0
  451. package/src/modules/cpq/migrations/Migration20260410100000_cpq_inventory.ts +118 -0
  452. package/src/modules/cpq/migrations/Migration20260411000000_cpq_orders.ts +62 -0
  453. package/src/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.ts +33 -0
  454. package/src/modules/cpq/migrations/Migration20260504064621_cpq_arc.ts +68 -0
  455. package/src/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.ts +30 -0
  456. package/src/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.ts +27 -0
  457. package/src/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.ts +82 -0
  458. package/src/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.ts +52 -0
  459. package/src/modules/cpq/services/__tests__/_helpers/mockEm.ts +59 -0
  460. package/src/modules/cpq/services/__tests__/cpqBundleService.test.ts +661 -0
  461. package/src/modules/cpq/services/__tests__/cpqInventoryService.arc.test.ts +357 -0
  462. package/src/modules/cpq/services/__tests__/cpqInventoryService.test.ts +718 -0
  463. package/src/modules/cpq/services/__tests__/cpqOrderService.test.ts +603 -0
  464. package/src/modules/cpq/services/__tests__/cpqPricingService.test.ts +1012 -0
  465. package/src/modules/cpq/services/__tests__/cpqProductService.test.ts +603 -0
  466. package/src/modules/cpq/services/__tests__/cpqQuotingService.arc.test.ts +143 -0
  467. package/src/modules/cpq/services/__tests__/cpqQuotingService.test.ts +658 -0
  468. package/src/modules/cpq/services/__tests__/cpqValidationService.test.ts +811 -0
  469. package/src/modules/cpq/services/__tests__/cpqWizardService.test.ts +389 -0
  470. package/src/modules/cpq/services/__tests__/types.test.ts +359 -0
  471. package/src/modules/cpq/services/cpqBundleService.ts +671 -0
  472. package/src/modules/cpq/services/cpqInventoryService.ts +1929 -0
  473. package/src/modules/cpq/services/cpqOrderService.ts +1230 -0
  474. package/src/modules/cpq/services/cpqPricingService.ts +412 -0
  475. package/src/modules/cpq/services/cpqProductService.ts +311 -0
  476. package/src/modules/cpq/services/cpqQuotingService.ts +2638 -0
  477. package/src/modules/cpq/services/cpqValidationService.ts +323 -0
  478. package/src/modules/cpq/services/cpqWizardService.ts +204 -0
  479. package/src/modules/cpq/services/types.ts +303 -0
  480. package/src/modules/cpq/setup.ts +63 -0
  481. package/src/modules/cpq/subscribers/subscription-amended-log.ts +20 -0
  482. package/src/modules/cpq/subscribers/subscription-cancelled-log.ts +19 -0
  483. package/src/modules/cpq/subscribers/subscription-merged-log.ts +22 -0
  484. package/src/modules/cpq/subscribers/subscription-renewed-log.ts +18 -0
  485. package/src/modules/cpq/subscribers/subscription-superseded-log.ts +19 -0
  486. package/src/modules/cpq/widgets/injection/customer-inventory/widget.client.tsx +339 -0
  487. package/src/modules/cpq/widgets/injection/customer-inventory/widget.ts +16 -0
  488. package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.client.tsx +96 -0
  489. package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.ts +16 -0
  490. package/src/modules/cpq/widgets/injection/quote-configurator/widget.client.tsx +265 -0
  491. package/src/modules/cpq/widgets/injection/quote-configurator/widget.ts +16 -0
  492. package/src/modules/cpq/widgets/injection-table.ts +42 -0
  493. package/src/modules/cpq/workflows/WizardRunner.tsx +158 -0
  494. package/src/modules/cpq/workflows/WizardTrigger.tsx +142 -0
  495. package/src/modules/cpq/workflows/engine.tsx +278 -0
  496. package/src/modules/cpq/workflows/registry.ts +15 -0
  497. package/src/modules/cpq/workflows/steps/CustomerSelectStep.tsx +136 -0
  498. package/src/modules/cpq/workflows/steps/InventorySelectStep.tsx +34 -0
  499. package/src/modules/cpq/workflows/steps/ItemListStep.tsx +146 -0
  500. package/src/modules/cpq/workflows/steps/OfferingSelectStep.tsx +438 -0
  501. package/src/modules/cpq/workflows/steps/ProductConfigureStep.tsx +287 -0
  502. package/src/modules/cpq/workflows/steps/ReviewStep.tsx +219 -0
  503. package/src/modules/cpq/workflows/steps/index.ts +51 -0
  504. package/src/modules/cpq/workflows/types.ts +102 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/cpq/services/cpqInventoryService.ts"],
4
+ "sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport {\n CpqInventorySubscription,\n CpqInventorySubscriptionItem,\n CpqInventoryAsset,\n CpqProductSpecification,\n CpqSubscriptionChangeLog,\n} from '../data/entities'\nimport {\n INVENTORY_SUBSCRIPTION_TRANSITIONS,\n INVENTORY_ASSET_TRANSITIONS,\n getBaseCurrencyCode,\n type ChangeLogType,\n type InventorySubscriptionStatus,\n type InventoryAssetStatus,\n type TenantScope,\n} from './types'\n\n// \u2500\u2500\u2500 Filter / Input / Result types \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\ninterface SubscriptionListFilters {\n customerId?: string\n sourceOrderId?: string\n status?: string | string[]\n productId?: string\n billingCycle?: string\n search?: string\n /** Only subscriptions whose currentTermEnd falls within the next N days. */\n expiringWithinDays?: number\n sortField?: 'createdAt' | 'updatedAt' | 'code' | 'name' | 'status' | 'startDate' | 'currentTermEnd'\n sortDir?: 'asc' | 'desc'\n page?: number\n pageSize?: number\n}\n\ninterface SubscriptionItemListFilters {\n subscriptionId?: string\n parentItemId?: string\n status?: string\n}\n\ninterface AssetListFilters {\n customerId?: string\n status?: string | string[]\n assetType?: string\n productId?: string\n subscriptionId?: string\n subscriptionItemId?: string\n search?: string\n sortField?: 'createdAt' | 'updatedAt' | 'code' | 'name' | 'status' | 'assetType' | 'purchasePrice'\n sortDir?: 'asc' | 'desc'\n page?: number\n pageSize?: number\n}\n\ninterface CustomerInventoryFilters {\n status?: string | string[]\n productId?: string\n includeTerminated?: boolean\n}\n\n// \u2500\u2500\u2500 ARC (Amend / Renew / Cancel) \u2014 XD-250 input shapes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport type ArcLineAction = 'add' | 'modify' | 'cancel'\n\nexport interface ArcLineChange {\n /** Source quote line id (for traceability + sourceQuoteLineId on items). */\n quoteLineId?: string | null\n action: ArcLineAction\n /** Required for action \u2208 {cancel, modify}. */\n sourceSubscriptionItemId?: string | null\n /** Required for action='add'. Used to materialize the new item. */\n itemInput?: Omit<CreateSubscriptionItemInput, 'name'> & { name: string }\n /** XD-250 ARC: source quote line's `parentLineId`. When set, applyLineChanges\n * resolves the resulting `parentItemId` on the new sub item \u2014 either from\n * the parent's `sourceSubscriptionItemId` (if parent is a modify line) or\n * from another `add` line's pre-generated id (if parent is also brand new\n * in this apply). Without this, bundle children added through ARC are\n * created as standalone sub items, not nested under the bundle. */\n parentQuoteLineId?: string | null\n /** Optional metadata for action='modify' \u2014 the configuration / pricing changes. */\n modifyPatch?: {\n configuration?: Record<string, unknown>\n charges?: Array<Record<string, unknown>>\n mrcAmount?: number\n nrcAmount?: number\n quantity?: number\n }\n}\n\nexport interface ArcTermInput {\n newTermStart: Date | string\n newTermEnd: Date | string\n newTermMonths?: number | null\n}\n\nexport interface ArcMergeMeta {\n newSubCode?: string | null\n newSubName?: string | null\n}\n\nexport interface ApplyAmendmentInput {\n subscriptionId: string\n lineChanges: ArcLineChange[]\n sourceQuoteId: string\n sourceOrderId: string\n performedByUserId?: string | null\n}\n\nexport interface ApplyRenewalInput extends ApplyAmendmentInput {\n term: ArcTermInput\n}\n\nexport interface ApplyMergeRenewalInput {\n sourceIds: string[]\n term: ArcTermInput\n mergeMeta: ArcMergeMeta\n lineChanges: ArcLineChange[]\n sourceQuoteId: string\n sourceOrderId: string\n performedByUserId?: string | null\n}\n\nexport interface ApplyCancelInput {\n subscriptionId: string\n sourceQuoteId: string\n sourceOrderId: string\n performedByUserId?: string | null\n etfAmount?: number | string | null\n etfCurrency?: string | null\n reasonCode?: string | null\n reasonText?: string | null\n}\n\nexport interface ApplyArcResult {\n changeLog: CpqSubscriptionChangeLog\n /** Subscription as left after mutation (for amend / renew / cancel) or M (for merge-result). */\n subscription: CpqInventorySubscription\n}\n\nexport interface ApplyMergeRenewalResult {\n /** The new merge sub M. */\n mergedSubscription: CpqInventorySubscription\n /** The merge-result ChangeLog row (on M). */\n mergeResultChangeLog: CpqSubscriptionChangeLog\n /** One per source \u2014 change_type='merge-source'. */\n sourceChangeLogs: CpqSubscriptionChangeLog[]\n}\n\nexport interface CreateSubscriptionInput {\n customerId: string\n code?: string\n name: string\n description?: string\n billingCycle?: string\n currencyCode?: string\n startDate?: string\n termMonths?: number\n autoRenew?: boolean\n sourceQuoteId?: string\n sourceOrderId?: string\n metadata?: Record<string, unknown>\n items: CreateSubscriptionItemInput[]\n}\n\nexport interface CreateSubscriptionItemInput {\n parentItemId?: string\n productId?: string\n offeringId?: string\n specId?: string\n name: string\n configuration?: Record<string, unknown>\n charges?: Array<Record<string, unknown>>\n mrcAmount?: number\n nrcAmount?: number\n currencyCode?: string\n quantity?: number\n capacityTotal?: number\n capacityUnit?: string\n sourceQuoteLineId?: string\n metadata?: Record<string, unknown>\n sortOrder?: number\n}\n\ninterface UpdateSubscriptionInput {\n name?: string\n description?: string\n billingCycle?: string\n autoRenew?: boolean\n termMonths?: number\n currentTermEnd?: string\n metadata?: Record<string, unknown>\n}\n\ninterface UpdateSubscriptionItemInput {\n name?: string\n metadata?: Record<string, unknown>\n capacityTotal?: number\n capacityUsed?: number\n capacityUnit?: string\n sortOrder?: number\n}\n\ninterface CreateAssetInput {\n customerId: string\n subscriptionId?: string\n subscriptionItemId?: string\n productId?: string\n offeringId?: string\n specId?: string\n code?: string\n name: string\n description?: string\n assetType?: string\n currencyCode?: string\n purchasePrice?: number\n quantity?: number\n purchaseDate?: string\n deliveryDate?: string\n configuration?: Record<string, unknown>\n charges?: Array<Record<string, unknown>>\n sourceQuoteId?: string\n sourceOrderId?: string\n sourceQuoteLineId?: string\n metadata?: Record<string, unknown>\n}\n\ninterface UpdateAssetInput {\n name?: string\n description?: string\n assetType?: string\n deliveryDate?: string\n metadata?: Record<string, unknown>\n}\n\ninterface PaginatedResult<T> {\n items: T[]\n total: number\n page: number\n pageSize: number\n totalPages: number\n}\n\ninterface SubscriptionItemResultNode {\n id: string\n subscriptionId: string\n parentItemId: string | null\n productId: string | null\n offeringId: string | null\n specId: string | null\n name: string\n status: string\n configuration: Record<string, unknown>\n charges: Array<Record<string, unknown>> | null\n mrcAmount: number\n nrcAmount: number\n currencyCode: string\n quantity: number\n capacityTotal: number | null\n capacityUsed: number | null\n capacityUnit: string | null\n metadata: Record<string, unknown> | null\n sortOrder: number\n children: SubscriptionItemResultNode[]\n}\n\n// \u2500\u2500\u2500 Service implementation \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\nexport class DefaultCpqInventoryService {\n private em: EntityManager\n\n constructor(em: EntityManager) {\n this.em = em\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // Subscriptions\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n async listSubscriptions(filters: SubscriptionListFilters, scope: TenantScope): Promise<PaginatedResult<CpqInventorySubscription>> {\n const page = Math.max(1, filters.page ?? 1)\n const pageSize = Math.min(100, Math.max(1, filters.pageSize ?? 50))\n const offset = (page - 1) * pageSize\n\n const where: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n }\n\n if (filters.customerId) where.customerId = filters.customerId\n if (filters.sourceOrderId) where.sourceOrderId = filters.sourceOrderId\n if (filters.billingCycle) where.billingCycle = filters.billingCycle\n if (filters.status) {\n where.status = Array.isArray(filters.status)\n ? { $in: filters.status }\n : filters.status\n }\n\n const search = filters.search?.trim()\n if (search) {\n where.$or = [\n { code: { $ilike: `%${search}%` } },\n { name: { $ilike: `%${search}%` } },\n ]\n }\n\n if (filters.productId) {\n const itemIds = await this.em.find(\n CpqInventorySubscriptionItem,\n {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n productId: filters.productId,\n },\n { fields: ['subscriptionId'] as const },\n )\n const subIds = [...new Set(itemIds.map((i) => i.subscriptionId))]\n if (subIds.length === 0) {\n return { items: [], total: 0, page, pageSize, totalPages: 0 }\n }\n where.id = { $in: subIds }\n }\n\n // Expiring window: subscriptions whose currentTermEnd is between now\n // and now + N days. Replaces the separate /expiring page \u2014 operators\n // save this as a perspective on the main list.\n if (filters.expiringWithinDays != null && filters.expiringWithinDays > 0) {\n const now = new Date()\n const cutoff = new Date(now.getTime() + filters.expiringWithinDays * 24 * 60 * 60 * 1000)\n where.currentTermEnd = { $gte: now, $lte: cutoff }\n }\n\n // Default sort for the expiring view is \"soonest first\"; otherwise\n // the caller's choice (or newest-first).\n const defaultSortField =\n filters.expiringWithinDays != null && filters.expiringWithinDays > 0\n ? 'currentTermEnd'\n : 'createdAt'\n const sortField = filters.sortField ?? defaultSortField\n const sortDir = filters.sortDir === 'asc' ? 'asc' :\n filters.sortField === undefined && filters.expiringWithinDays != null ? 'asc' : 'desc'\n\n const [items, total] = await this.em.findAndCount(\n CpqInventorySubscription,\n where,\n { limit: pageSize, offset, orderBy: { [sortField]: sortDir } },\n )\n\n return {\n items,\n total,\n page,\n pageSize,\n totalPages: Math.ceil(total / pageSize),\n }\n }\n\n async getSubscription(subscriptionId: string, scope: TenantScope) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id: subscriptionId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n\n const allItems = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n }, { orderBy: { sortOrder: 'asc' } })\n\n const itemTree = this.buildItemTree(allItems)\n\n return { ...sub, items: itemTree }\n }\n\n async createSubscription(input: CreateSubscriptionInput, scope: TenantScope) {\n const code = input.code ?? await this.generateSubscriptionCode(scope)\n\n const subId = crypto.randomUUID()\n const sub = this.em.create(CpqInventorySubscription, {\n id: subId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n customerId: input.customerId,\n code,\n name: input.name,\n description: input.description ?? null,\n status: 'pending',\n billingCycle: input.billingCycle ?? 'monthly',\n currencyCode: input.currencyCode ?? await getBaseCurrencyCode(this.em, scope),\n mrcAmount: '0',\n nrcAmount: '0',\n startDate: input.startDate ? new Date(input.startDate) : null,\n termMonths: input.termMonths ?? null,\n autoRenew: input.autoRenew ?? true,\n sourceQuoteId: input.sourceQuoteId ?? null,\n sourceOrderId: input.sourceOrderId ?? null,\n metadata: input.metadata ?? null,\n })\n this.em.persist(sub)\n\n const items: CpqInventorySubscriptionItem[] = []\n for (const itemInput of input.items) {\n const item = this.em.create(CpqInventorySubscriptionItem, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n subscriptionId: sub.id,\n customerId: input.customerId,\n parentItemId: itemInput.parentItemId ?? null,\n productId: itemInput.productId ?? null,\n offeringId: itemInput.offeringId ?? null,\n specId: itemInput.specId ?? null,\n name: itemInput.name,\n status: 'pending',\n configuration: itemInput.configuration ?? {},\n charges: itemInput.charges ?? null,\n mrcAmount: String(itemInput.mrcAmount ?? 0),\n nrcAmount: String(itemInput.nrcAmount ?? 0),\n currencyCode: itemInput.currencyCode ?? input.currencyCode ?? await getBaseCurrencyCode(this.em, scope),\n quantity: itemInput.quantity ?? 1,\n capacityTotal: itemInput.capacityTotal != null ? String(itemInput.capacityTotal) : null,\n capacityUsed: null,\n capacityUnit: itemInput.capacityUnit ?? null,\n sourceQuoteLineId: itemInput.sourceQuoteLineId ?? null,\n metadata: itemInput.metadata ?? null,\n sortOrder: itemInput.sortOrder ?? 0,\n })\n this.em.persist(item)\n items.push(item)\n }\n\n const mrcSum = items.reduce((s, i) => s + Number(i.mrcAmount), 0)\n const nrcSum = items.reduce((s, i) => s + Number(i.nrcAmount), 0)\n sub.mrcAmount = String(mrcSum)\n sub.nrcAmount = String(nrcSum)\n\n // Seed the change log with a `created` entry so the Change History\n // panel always shows where the subscription came from \u2014 same shape\n // as the `amend` / `renew` / `cancel` entries written by ARC flows.\n // beforeSnapshot is null because there is no prior state; the after\n // snapshot is the freshly-built subscription so the UI can diff\n // against subsequent changes.\n await this.em.flush() // need sub.id and items persisted before snapshot\n const afterSnapshot = await this.snapshotSubscription(sub, scope)\n const log = this.createChangeLog({\n subscription: sub,\n changeType: 'created',\n sourceQuoteId: input.sourceQuoteId ?? null,\n sourceOrderId: input.sourceOrderId ?? null,\n performedByUserId: null,\n beforeSnapshot: null,\n afterSnapshot,\n lineChanges: items.map((item) => ({\n action: 'add' as const,\n itemId: item.id,\n sourceQuoteLineId: item.sourceQuoteLineId ?? null,\n mrcAmount: Number(item.mrcAmount),\n nrcAmount: Number(item.nrcAmount),\n quantity: item.quantity,\n })),\n })\n sub.lastChangeLogId = log.id\n await this.em.flush()\n return sub\n }\n\n async updateSubscription(id: string, updates: UpdateSubscriptionInput, scope: TenantScope) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n\n if (updates.name !== undefined) sub.name = updates.name\n if (updates.description !== undefined) sub.description = updates.description\n if (updates.billingCycle !== undefined) sub.billingCycle = updates.billingCycle\n if (updates.autoRenew !== undefined) sub.autoRenew = updates.autoRenew\n if (updates.termMonths !== undefined) sub.termMonths = updates.termMonths\n if (updates.currentTermEnd !== undefined) sub.currentTermEnd = updates.currentTermEnd ? new Date(updates.currentTermEnd) : null\n if (updates.metadata !== undefined) sub.metadata = updates.metadata\n\n await this.em.flush()\n return sub\n }\n\n async deleteSubscription(id: string, scope: TenantScope) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n\n sub.deletedAt = new Date()\n await this.em.flush()\n return { success: true }\n }\n\n async transitionSubscriptionStatus(id: string, targetStatus: string, scope: TenantScope) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n\n const currentStatus = sub.status as InventorySubscriptionStatus\n const allowed = INVENTORY_SUBSCRIPTION_TRANSITIONS[currentStatus] ?? []\n if (!allowed.includes(targetStatus as InventorySubscriptionStatus)) {\n throw { status: 409, error: `Cannot transition from '${sub.status}' to '${targetStatus}'` }\n }\n\n const now = new Date()\n\n if (targetStatus === 'active' && !sub.activatedAt) {\n sub.activatedAt = now\n }\n if (targetStatus === 'suspended') {\n sub.suspendedAt = now\n }\n if (currentStatus === 'suspended' && targetStatus === 'active') {\n sub.suspendedAt = null\n }\n if (targetStatus === 'terminated' || targetStatus === 'superseded') {\n sub.terminatedAt = now\n }\n\n const items = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['terminated', 'expired', 'superseded'] },\n })\n for (const item of items) {\n item.status = targetStatus\n }\n\n if (targetStatus === 'active' || targetStatus === 'terminated' || targetStatus === 'superseded') {\n const assetTargetStatus = targetStatus === 'active' ? 'active' : 'cancelled'\n const excludeStatuses = targetStatus === 'active'\n ? ['returned']\n : ['returned', 'cancelled']\n const assets = await this.em.find(CpqInventoryAsset, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: excludeStatuses },\n })\n for (const asset of assets) {\n asset.status = assetTargetStatus\n }\n }\n\n sub.status = targetStatus\n await this.em.flush()\n return sub\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // Subscription Items\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n async listSubscriptionItems(filters: SubscriptionItemListFilters, scope: TenantScope) {\n const where: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n }\n\n if (filters.subscriptionId) where.subscriptionId = filters.subscriptionId\n if (filters.parentItemId) where.parentItemId = filters.parentItemId\n if (filters.status) where.status = filters.status\n\n return this.em.find(CpqInventorySubscriptionItem, where, {\n orderBy: { sortOrder: 'asc' },\n })\n }\n\n async addSubscriptionItem(subscriptionId: string, input: CreateSubscriptionItemInput, scope: TenantScope) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id: subscriptionId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n\n if (input.parentItemId) {\n const parent = await this.em.findOne(CpqInventorySubscriptionItem, {\n id: input.parentItemId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!parent) throw { status: 404, error: 'Parent item not found' }\n if (parent.subscriptionId !== subscriptionId) {\n throw { status: 409, error: 'Parent item does not belong to this subscription' }\n }\n }\n\n const item = this.em.create(CpqInventorySubscriptionItem, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n subscriptionId,\n customerId: sub.customerId,\n parentItemId: input.parentItemId ?? null,\n productId: input.productId ?? null,\n offeringId: input.offeringId ?? null,\n specId: input.specId ?? null,\n name: input.name,\n status: 'pending',\n configuration: input.configuration ?? {},\n charges: input.charges ?? null,\n mrcAmount: String(input.mrcAmount ?? 0),\n nrcAmount: String(input.nrcAmount ?? 0),\n currencyCode: input.currencyCode ?? sub.currencyCode,\n quantity: input.quantity ?? 1,\n capacityTotal: input.capacityTotal != null ? String(input.capacityTotal) : null,\n capacityUsed: null,\n capacityUnit: input.capacityUnit ?? null,\n sourceQuoteLineId: input.sourceQuoteLineId ?? null,\n metadata: input.metadata ?? null,\n sortOrder: input.sortOrder ?? 0,\n })\n this.em.persist(item)\n\n await this.em.flush()\n await this.recomputeSubscriptionAggregates(subscriptionId, scope)\n\n return item\n }\n\n async updateSubscriptionItem(id: string, updates: UpdateSubscriptionItemInput, scope: TenantScope) {\n const item = await this.em.findOne(CpqInventorySubscriptionItem, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!item) throw { status: 404, error: 'Subscription item not found' }\n\n if (updates.name !== undefined) item.name = updates.name\n if (updates.metadata !== undefined) item.metadata = updates.metadata\n if (updates.capacityTotal !== undefined) item.capacityTotal = updates.capacityTotal != null ? String(updates.capacityTotal) : null\n if (updates.capacityUsed !== undefined) item.capacityUsed = updates.capacityUsed != null ? String(updates.capacityUsed) : null\n if (updates.capacityUnit !== undefined) item.capacityUnit = updates.capacityUnit\n if (updates.sortOrder !== undefined) item.sortOrder = updates.sortOrder\n\n await this.em.flush()\n return item\n }\n\n async deleteSubscriptionItem(id: string, scope: TenantScope) {\n const item = await this.em.findOne(CpqInventorySubscriptionItem, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!item) throw { status: 404, error: 'Subscription item not found' }\n\n item.deletedAt = new Date()\n await this.em.flush()\n await this.recomputeSubscriptionAggregates(item.subscriptionId, scope)\n\n return { success: true }\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // Assets\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n async listAssets(filters: AssetListFilters, scope: TenantScope): Promise<PaginatedResult<CpqInventoryAsset>> {\n const page = Math.max(1, filters.page ?? 1)\n const pageSize = Math.min(100, Math.max(1, filters.pageSize ?? 50))\n const offset = (page - 1) * pageSize\n\n const where: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n }\n\n if (filters.customerId) where.customerId = filters.customerId\n if (filters.status) {\n where.status = Array.isArray(filters.status)\n ? { $in: filters.status }\n : filters.status\n }\n if (filters.assetType) where.assetType = filters.assetType\n if (filters.productId) where.productId = filters.productId\n if (filters.subscriptionId) where.subscriptionId = filters.subscriptionId\n if (filters.subscriptionItemId) where.subscriptionItemId = filters.subscriptionItemId\n\n const search = filters.search?.trim()\n if (search) {\n where.$or = [\n { code: { $ilike: `%${search}%` } },\n { name: { $ilike: `%${search}%` } },\n ]\n }\n\n const sortField = filters.sortField ?? 'createdAt'\n const sortDir = filters.sortDir === 'asc' ? 'asc' : 'desc'\n\n const [items, total] = await this.em.findAndCount(\n CpqInventoryAsset,\n where,\n { limit: pageSize, offset, orderBy: { [sortField]: sortDir } },\n )\n\n return {\n items,\n total,\n page,\n pageSize,\n totalPages: Math.ceil(total / pageSize),\n }\n }\n\n async getAsset(assetId: string, scope: TenantScope) {\n const asset = await this.em.findOne(CpqInventoryAsset, {\n id: assetId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!asset) throw { status: 404, error: 'Asset not found' }\n return asset\n }\n\n async createAsset(input: CreateAssetInput, scope: TenantScope) {\n const code = input.code ?? await this.generateAssetCode(scope)\n\n if (input.subscriptionId) {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id: input.subscriptionId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n }\n\n if (input.subscriptionItemId) {\n const item = await this.em.findOne(CpqInventorySubscriptionItem, {\n id: input.subscriptionItemId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!item) throw { status: 404, error: 'Subscription item not found' }\n }\n\n const asset = this.em.create(CpqInventoryAsset, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n customerId: input.customerId,\n subscriptionId: input.subscriptionId ?? null,\n subscriptionItemId: input.subscriptionItemId ?? null,\n productId: input.productId ?? null,\n offeringId: input.offeringId ?? null,\n specId: input.specId ?? null,\n code,\n name: input.name,\n description: input.description ?? null,\n status: 'pending',\n assetType: input.assetType ?? 'one_time',\n currencyCode: input.currencyCode ?? await getBaseCurrencyCode(this.em, scope),\n purchasePrice: String(input.purchasePrice ?? 0),\n quantity: input.quantity ?? 1,\n purchaseDate: input.purchaseDate ? new Date(input.purchaseDate) : null,\n deliveryDate: input.deliveryDate ? new Date(input.deliveryDate) : null,\n configuration: input.configuration ?? {},\n charges: input.charges ?? null,\n sourceQuoteId: input.sourceQuoteId ?? null,\n sourceOrderId: input.sourceOrderId ?? null,\n sourceQuoteLineId: input.sourceQuoteLineId ?? null,\n metadata: input.metadata ?? null,\n })\n this.em.persist(asset)\n\n await this.em.flush()\n return asset\n }\n\n async updateAsset(id: string, updates: UpdateAssetInput, scope: TenantScope) {\n const asset = await this.em.findOne(CpqInventoryAsset, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!asset) throw { status: 404, error: 'Asset not found' }\n\n if (updates.name !== undefined) asset.name = updates.name\n if (updates.description !== undefined) asset.description = updates.description\n if (updates.assetType !== undefined) asset.assetType = updates.assetType\n if (updates.deliveryDate !== undefined) asset.deliveryDate = updates.deliveryDate ? new Date(updates.deliveryDate) : null\n if (updates.metadata !== undefined) asset.metadata = updates.metadata\n\n await this.em.flush()\n return asset\n }\n\n async deleteAsset(id: string, scope: TenantScope) {\n const asset = await this.em.findOne(CpqInventoryAsset, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!asset) throw { status: 404, error: 'Asset not found' }\n\n asset.deletedAt = new Date()\n await this.em.flush()\n return { success: true }\n }\n\n async transitionAssetStatus(id: string, targetStatus: string, scope: TenantScope) {\n const asset = await this.em.findOne(CpqInventoryAsset, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!asset) throw { status: 404, error: 'Asset not found' }\n\n const currentStatus = asset.status as InventoryAssetStatus\n const allowed = INVENTORY_ASSET_TRANSITIONS[currentStatus] ?? []\n if (!allowed.includes(targetStatus as InventoryAssetStatus)) {\n throw { status: 409, error: `Cannot transition from '${asset.status}' to '${targetStatus}'` }\n }\n\n asset.status = targetStatus\n await this.em.flush()\n return asset\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // Customer View\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n async getCustomerInventory(customerId: string, filters: CustomerInventoryFilters, scope: TenantScope) {\n const baseWhere: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n customerId,\n }\n\n const subTerminalStatuses = ['terminated', 'expired']\n const itemTerminalStatuses = ['terminated', 'expired']\n const assetTerminalStatuses = ['returned']\n\n const subWhere: Record<string, unknown> = { ...baseWhere }\n const itemWhere: Record<string, unknown> = { ...baseWhere }\n const assetWhere: Record<string, unknown> = { ...baseWhere }\n\n if (filters.status) {\n const statuses = Array.isArray(filters.status) ? filters.status : [filters.status]\n subWhere.status = { $in: statuses }\n itemWhere.status = { $in: statuses }\n assetWhere.status = { $in: statuses }\n } else if (!filters.includeTerminated) {\n subWhere.status = { $nin: subTerminalStatuses }\n itemWhere.status = { $nin: itemTerminalStatuses }\n assetWhere.status = { $nin: assetTerminalStatuses }\n }\n\n if (filters.productId) {\n subWhere.id = { $in: await this.subscriptionIdsForProduct(filters.productId, scope) }\n itemWhere.productId = filters.productId\n assetWhere.productId = filters.productId\n }\n\n const [subscriptions, subscriptionItems, assets] = await Promise.all([\n this.em.find(CpqInventorySubscription, subWhere, { orderBy: { createdAt: 'desc' } }),\n this.em.find(CpqInventorySubscriptionItem, itemWhere, { orderBy: { sortOrder: 'asc' } }),\n this.em.find(CpqInventoryAsset, assetWhere, { orderBy: { createdAt: 'desc' } }),\n ])\n\n const activeSubscriptions = subscriptions.filter((s) => s.status === 'active').length\n const totalMrc = subscriptions\n .filter((s) => s.status === 'active')\n .reduce((sum, s) => sum + Number(s.mrcAmount), 0)\n const activeAssets = assets.filter((a) => a.status === 'active').length\n const pendingItems = subscriptionItems.filter((i) => i.status === 'pending').length\n\n const currencyCode = subscriptions[0]?.currencyCode ?? assets[0]?.currencyCode ?? await getBaseCurrencyCode(this.em, scope)\n\n return {\n customerId,\n subscriptions,\n subscriptionItems,\n assets,\n summary: {\n activeSubscriptions,\n totalMrc,\n activeAssets,\n pendingItems,\n currencyCode,\n },\n }\n }\n\n async getCustomerParentItems(\n customerId: string,\n filters: { productId?: string; offeringId?: string },\n scope: TenantScope,\n ) {\n const where: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n customerId,\n parentItemId: null,\n status: 'active',\n }\n\n if (filters.productId) where.productId = filters.productId\n if (filters.offeringId) where.offeringId = filters.offeringId\n\n return this.em.find(CpqInventorySubscriptionItem, where, {\n orderBy: { sortOrder: 'asc' },\n })\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // ARC (Amend / Renew / Cancel) \u2014 XD-250\n //\n // Mutate-in-place primitives invoked by cpqOrderService.activateOrder\n // per attached target subscription. Each method:\n // \u2022 is idempotent on (sourceOrderId, subscriptionId), enforced via the\n // DB-level UNIQUE on cpq_subscription_change_logs;\n // \u2022 takes optimistic lock on subscription.version (MikroORM auto-bumps);\n // \u2022 writes a CpqSubscriptionChangeLog row and updates\n // subscription.lastChangeLogId.\n //\n // Event emission is the caller's job (centralized in cpqOrderService\n // AFTER the activation transaction commits).\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n async findExpiringSubscriptions(\n filters: {\n withinDays?: number\n customerId?: string\n billingCycle?: string\n status?: string\n page?: number\n pageSize?: number\n },\n scope: TenantScope,\n ): Promise<PaginatedResult<CpqInventorySubscription>> {\n const withinDays = Math.min(365, Math.max(1, filters.withinDays ?? 30))\n const status = filters.status ?? 'active'\n const page = Math.max(1, filters.page ?? 1)\n const pageSize = Math.min(100, Math.max(1, filters.pageSize ?? 50))\n const offset = (page - 1) * pageSize\n\n const now = new Date()\n const horizon = new Date(now.getTime() + withinDays * 24 * 60 * 60 * 1000)\n\n const where: Record<string, unknown> = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status,\n currentTermEnd: { $gte: now, $lte: horizon },\n }\n if (filters.customerId) where.customerId = filters.customerId\n if (filters.billingCycle) where.billingCycle = filters.billingCycle\n\n const [items, total] = await this.em.findAndCount(\n CpqInventorySubscription,\n where,\n { limit: pageSize, offset, orderBy: { currentTermEnd: 'asc' } },\n )\n\n return { items, total, page, pageSize, totalPages: Math.ceil(total / pageSize) }\n }\n\n async listChangeLog(\n subscriptionId: string,\n filters: { page?: number; pageSize?: number },\n scope: TenantScope,\n ): Promise<PaginatedResult<CpqSubscriptionChangeLog>> {\n const page = Math.max(1, filters.page ?? 1)\n const pageSize = Math.min(100, Math.max(1, filters.pageSize ?? 50))\n const offset = (page - 1) * pageSize\n\n const where = {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n subscriptionId,\n }\n\n const [items, total] = await this.em.findAndCount(\n CpqSubscriptionChangeLog,\n where,\n { limit: pageSize, offset, orderBy: { createdAt: 'desc' } },\n )\n\n return { items, total, page, pageSize, totalPages: Math.ceil(total / pageSize) }\n }\n\n async applyAmendment(input: ApplyAmendmentInput, scope: TenantScope): Promise<ApplyArcResult> {\n const idempotent = await this.findIdempotentChangeLog(\n input.sourceOrderId,\n input.subscriptionId,\n scope,\n )\n if (idempotent) {\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n return { changeLog: idempotent, subscription: sub }\n }\n\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n const beforeSnapshot = await this.snapshotSubscription(sub, scope)\n\n const { lineChangeSummary } = await this.applyLineChanges(\n sub,\n input.lineChanges,\n scope,\n null,\n )\n\n await this.recomputeSubscriptionAggregatesInPlace(sub, scope)\n\n await this.em.flush()\n\n const afterSnapshot = await this.snapshotSubscription(sub, scope)\n\n const log = this.createChangeLog({\n subscription: sub,\n changeType: 'amend',\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n performedByUserId: input.performedByUserId,\n beforeSnapshot,\n afterSnapshot,\n lineChanges: lineChangeSummary,\n })\n\n sub.lastChangeLogId = log.id\n await this.em.flush()\n\n return { changeLog: log, subscription: sub }\n }\n\n async applyRenewal(input: ApplyRenewalInput, scope: TenantScope): Promise<ApplyArcResult> {\n const idempotent = await this.findIdempotentChangeLog(\n input.sourceOrderId,\n input.subscriptionId,\n scope,\n )\n if (idempotent) {\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n return { changeLog: idempotent, subscription: sub }\n }\n\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n const beforeSnapshot = await this.snapshotSubscription(sub, scope)\n const oldTermStart = sub.currentTermStart\n const oldTermEnd = sub.currentTermEnd\n const oldTermMonths = sub.termMonths\n\n const newStart = toDate(input.term.newTermStart)\n const newEnd = toDate(input.term.newTermEnd)\n sub.currentTermStart = newStart\n sub.currentTermEnd = newEnd\n if (input.term.newTermMonths != null) sub.termMonths = input.term.newTermMonths\n\n const { lineChangeSummary } = await this.applyLineChanges(\n sub,\n input.lineChanges,\n scope,\n null,\n )\n\n await this.recomputeSubscriptionAggregatesInPlace(sub, scope)\n\n await this.em.flush()\n\n const afterSnapshot = await this.snapshotSubscription(sub, scope)\n\n const log = this.createChangeLog({\n subscription: sub,\n changeType: 'renew',\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n performedByUserId: input.performedByUserId,\n beforeSnapshot,\n afterSnapshot,\n lineChanges: lineChangeSummary,\n termChange: {\n oldTermStart: toIsoOrNull(oldTermStart),\n newTermStart: newStart.toISOString(),\n oldTermEnd: toIsoOrNull(oldTermEnd),\n newTermEnd: newEnd.toISOString(),\n oldTermMonths: oldTermMonths ?? null,\n newTermMonths: input.term.newTermMonths ?? oldTermMonths ?? null,\n },\n })\n\n sub.lastChangeLogId = log.id\n await this.em.flush()\n\n return { changeLog: log, subscription: sub }\n }\n\n async applyMergeRenewal(\n input: ApplyMergeRenewalInput,\n scope: TenantScope,\n ): Promise<ApplyMergeRenewalResult> {\n if (input.sourceIds.length < 2) {\n throw { status: 400, error: 'Merge requires at least two source subscriptions' }\n }\n\n // Idempotency: if every source already has a merge-source ChangeLog row\n // for this order, the merge has been applied \u2014 re-fetch and return.\n const existingSourceLogs = await this.em.find(CpqSubscriptionChangeLog, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n sourceOrderId: input.sourceOrderId,\n subscriptionId: { $in: input.sourceIds },\n changeType: 'merge-source',\n })\n if (existingSourceLogs.length === input.sourceIds.length) {\n const mergeResult = await this.em.findOne(CpqSubscriptionChangeLog, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n sourceOrderId: input.sourceOrderId,\n changeType: 'merge-result',\n })\n if (mergeResult) {\n const m = await this.requireSubscription(mergeResult.subscriptionId, scope)\n return {\n mergedSubscription: m,\n mergeResultChangeLog: mergeResult,\n sourceChangeLogs: existingSourceLogs,\n }\n }\n }\n\n // Validate sources: same customer/currency/billingCycle, all in {active, suspended}.\n const sources = await this.em.find(CpqInventorySubscription, {\n id: { $in: input.sourceIds },\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (sources.length !== input.sourceIds.length) {\n throw { status: 404, error: 'One or more source subscriptions not found' }\n }\n const customers = new Set(sources.map((s) => s.customerId))\n const currencies = new Set(sources.map((s) => s.currencyCode))\n const cycles = new Set(sources.map((s) => s.billingCycle))\n if (customers.size > 1 || currencies.size > 1 || cycles.size > 1) {\n throw {\n status: 400,\n error: 'Merge sources must share customer, currency, and billing cycle',\n }\n }\n for (const s of sources) {\n if (s.status !== 'active' && s.status !== 'suspended') {\n throw {\n status: 409,\n error: `Source subscription ${s.id} is in '${s.status}' status \u2014 must be active or suspended to merge`,\n }\n }\n }\n\n const customerId = sources[0].customerId\n const currencyCode = sources[0].currencyCode\n const billingCycle = sources[0].billingCycle\n\n const beforeSnapshots = new Map<string, Record<string, unknown>>()\n for (const s of sources) {\n beforeSnapshots.set(s.id, await this.snapshotSubscription(s, scope))\n }\n\n // Create the new merge sub M.\n const newTermStart = toDate(input.term.newTermStart)\n const newTermEnd = toDate(input.term.newTermEnd)\n const code =\n input.mergeMeta.newSubCode ?? (await this.generateSubscriptionCode(scope))\n const name = input.mergeMeta.newSubName ?? `Merged contract`\n\n // Pre-generate id so child rows referenced before flush (carry-over items\n // FK to subscriptionId, asset migration FK update) don't depend on the\n // intervening flush() to populate it. Matches the createSubscription pattern.\n const newSubId = crypto.randomUUID()\n const m = this.em.create(CpqInventorySubscription, {\n id: newSubId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n customerId,\n code,\n name,\n status: 'active',\n billingCycle,\n currencyCode,\n mrcAmount: '0',\n nrcAmount: '0',\n currentTermStart: newTermStart,\n currentTermEnd: newTermEnd,\n termMonths: input.term.newTermMonths ?? null,\n autoRenew: true,\n activatedAt: new Date(),\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n })\n this.em.persist(m)\n await this.em.flush()\n\n // Carry-over phase: clone every source's active items onto M.\n // Build sourceItemId \u2192 newItemIdOnM map for line resolution.\n const sourceItemToNewItem = new Map<string, string>()\n\n for (const source of sources) {\n const activeItems = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: source.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['terminated', 'expired', 'superseded'] },\n })\n for (const item of activeItems) {\n // Pre-generate the cloned item id \u2014 `defaultRaw: 'gen_random_uuid()'`\n // only fires at INSERT, so without this `cloned.id` is undefined right\n // after em.create(). Then `sourceItemToNewItem.set(item.id, cloned.id)`\n // would store undefined and the line-change translation below would\n // fall back to the source-sub item id, which doesn't exist on the new\n // merged sub M \u2192 applyLineChanges throws 404 at activation.\n const clonedId = crypto.randomUUID()\n const cloned = this.em.create(CpqInventorySubscriptionItem, {\n id: clonedId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n subscriptionId: m.id,\n customerId,\n parentItemId: null,\n productId: item.productId ?? null,\n offeringId: item.offeringId ?? null,\n specId: item.specId ?? null,\n name: item.name,\n status: 'active',\n configuration: { ...item.configuration },\n charges: item.charges ? [...item.charges] : null,\n mrcAmount: item.mrcAmount,\n nrcAmount: item.nrcAmount,\n currencyCode: item.currencyCode,\n quantity: item.quantity,\n capacityTotal: item.capacityTotal,\n capacityUsed: item.capacityUsed,\n capacityUnit: item.capacityUnit,\n // Carry-over marker: sourceQuoteLineId stays null so the operator can\n // distinguish from operator-add lines later.\n sourceQuoteLineId: null,\n metadata: item.metadata,\n sortOrder: item.sortOrder,\n })\n this.em.persist(cloned)\n sourceItemToNewItem.set(item.id, clonedId)\n }\n }\n await this.em.flush()\n\n // Migrate assets: every source's assets switch FK to M (and to the new\n // item id mapped from the original source item id).\n for (const source of sources) {\n const assets = await this.em.find(CpqInventoryAsset, {\n subscriptionId: source.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['returned', 'cancelled'] },\n })\n for (const asset of assets) {\n asset.subscriptionId = m.id\n if (asset.subscriptionItemId) {\n const newItemId = sourceItemToNewItem.get(asset.subscriptionItemId)\n if (newItemId) asset.subscriptionItemId = newItemId\n }\n }\n }\n await this.em.flush()\n\n // Operator-edit phase: apply lineChanges on M's combined item set.\n // For cancel/modify lines, sourceSubscriptionItemId references an item on\n // one of the source subs \u2014 translate to the corresponding new item on M.\n const translatedChanges: ArcLineChange[] = input.lineChanges.map((lc) => {\n if (\n (lc.action === 'cancel' || lc.action === 'modify') &&\n lc.sourceSubscriptionItemId\n ) {\n const newItemId = sourceItemToNewItem.get(lc.sourceSubscriptionItemId)\n return {\n ...lc,\n sourceSubscriptionItemId: newItemId ?? lc.sourceSubscriptionItemId,\n }\n }\n return lc\n })\n\n const { lineChangeSummary } = await this.applyLineChanges(\n m,\n translatedChanges,\n scope,\n null,\n )\n\n await this.recomputeSubscriptionAggregatesInPlace(m, scope)\n await this.em.flush()\n\n const afterSnapshot = await this.snapshotSubscription(m, scope)\n\n // Retire each source: status='superseded', mergedIntoSubscriptionId=M.id,\n // items cascaded to 'superseded'.\n const sourceLogs: CpqSubscriptionChangeLog[] = []\n const now = new Date()\n for (const source of sources) {\n const items = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: source.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['terminated', 'expired', 'superseded'] },\n })\n for (const item of items) {\n item.status = 'superseded'\n }\n source.status = 'superseded'\n source.mergedIntoSubscriptionId = m.id\n source.terminatedAt = now\n // Recompute aggregates: source has no active items left.\n source.mrcAmount = '0'\n\n const sourceLog = this.createChangeLog({\n subscription: source,\n changeType: 'merge-source',\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n performedByUserId: input.performedByUserId,\n beforeSnapshot: beforeSnapshots.get(source.id) ?? null,\n // afterSnapshot intentionally null \u2014 terminal state IS the meaningful \"after\".\n afterSnapshot: null,\n lineChanges: null,\n mergedIntoSubscriptionId: m.id,\n })\n source.lastChangeLogId = sourceLog.id\n sourceLogs.push(sourceLog)\n }\n\n const mergeResultLog = this.createChangeLog({\n subscription: m,\n changeType: 'merge-result',\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n performedByUserId: input.performedByUserId,\n beforeSnapshot: null, // M is brand new \u2014 no \"before\" state.\n afterSnapshot,\n lineChanges: lineChangeSummary,\n termChange: {\n oldTermStart: null,\n newTermStart: newTermStart.toISOString(),\n oldTermEnd: null,\n newTermEnd: newTermEnd.toISOString(),\n oldTermMonths: null,\n newTermMonths: input.term.newTermMonths ?? null,\n },\n mergedFromSubscriptionIds: input.sourceIds,\n })\n m.lastChangeLogId = mergeResultLog.id\n\n await this.em.flush()\n\n return {\n mergedSubscription: m,\n mergeResultChangeLog: mergeResultLog,\n sourceChangeLogs: sourceLogs,\n }\n }\n\n async applyCancel(input: ApplyCancelInput, scope: TenantScope): Promise<ApplyArcResult> {\n const idempotent = await this.findIdempotentChangeLog(\n input.sourceOrderId,\n input.subscriptionId,\n scope,\n )\n if (idempotent) {\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n return { changeLog: idempotent, subscription: sub }\n }\n\n const sub = await this.requireSubscription(input.subscriptionId, scope)\n if (sub.status !== 'active' && sub.status !== 'suspended') {\n throw {\n status: 409,\n error: `Cannot cancel subscription in '${sub.status}' status`,\n }\n }\n const beforeSnapshot = await this.snapshotSubscription(sub, scope)\n\n // Reuse the existing cascade. transitionSubscriptionStatus flushes; that's\n // fine \u2014 we'll snapshot again afterwards.\n await this.transitionSubscriptionStatus(sub.id, 'terminated', scope)\n\n const reload = await this.requireSubscription(input.subscriptionId, scope)\n const afterSnapshot = await this.snapshotSubscription(reload, scope)\n\n const log = this.createChangeLog({\n subscription: reload,\n changeType: 'cancel',\n sourceQuoteId: input.sourceQuoteId,\n sourceOrderId: input.sourceOrderId,\n performedByUserId: input.performedByUserId,\n beforeSnapshot,\n afterSnapshot,\n lineChanges: null,\n reasonCode: input.reasonCode ?? null,\n reasonText: input.reasonText ?? null,\n etfAmount: input.etfAmount != null ? String(input.etfAmount) : null,\n etfCurrency: input.etfCurrency ?? null,\n })\n\n reload.lastChangeLogId = log.id\n await this.em.flush()\n\n return { changeLog: log, subscription: reload }\n }\n\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n // Private helpers\n // \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\n private async recomputeSubscriptionAggregates(subscriptionId: string, scope: TenantScope) {\n const items = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n\n const mrcSum = items.reduce((s, i) => s + Number(i.mrcAmount), 0)\n const nrcSum = items.reduce((s, i) => s + Number(i.nrcAmount), 0)\n\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id: subscriptionId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n })\n if (sub) {\n sub.mrcAmount = String(mrcSum)\n sub.nrcAmount = String(nrcSum)\n await this.em.flush()\n }\n }\n\n // \u2500\u2500\u2500 ARC private helpers (XD-250) \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\n private async requireSubscription(\n id: string,\n scope: TenantScope,\n ): Promise<CpqInventorySubscription> {\n const sub = await this.em.findOne(CpqInventorySubscription, {\n id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!sub) throw { status: 404, error: 'Subscription not found' }\n return sub\n }\n\n private async findIdempotentChangeLog(\n sourceOrderId: string | null | undefined,\n subscriptionId: string,\n scope: TenantScope,\n ): Promise<CpqSubscriptionChangeLog | null> {\n if (!sourceOrderId) return null\n return this.em.findOne(CpqSubscriptionChangeLog, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n sourceOrderId,\n subscriptionId,\n })\n }\n\n private async snapshotSubscription(\n sub: CpqInventorySubscription,\n scope: TenantScope,\n ): Promise<Record<string, unknown>> {\n // `?? []` is defensive: in unit tests with a partially-mocked EM the\n // `find` call may return undefined. Mikro at runtime always returns an\n // array, so this only matters for harness code.\n const items = (await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })) ?? []\n const assets = (await this.em.find(CpqInventoryAsset, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })) ?? []\n return {\n id: sub.id,\n code: sub.code,\n name: sub.name,\n status: sub.status,\n billingCycle: sub.billingCycle,\n currencyCode: sub.currencyCode,\n mrcAmount: sub.mrcAmount,\n nrcAmount: sub.nrcAmount,\n currentTermStart: toIsoOrNull(sub.currentTermStart),\n currentTermEnd: toIsoOrNull(sub.currentTermEnd),\n termMonths: sub.termMonths ?? null,\n version: sub.version,\n items: items.map((i) => ({\n id: i.id,\n productId: i.productId,\n offeringId: i.offeringId,\n specId: i.specId,\n name: i.name,\n status: i.status,\n configuration: i.configuration,\n mrcAmount: i.mrcAmount,\n nrcAmount: i.nrcAmount,\n currencyCode: i.currencyCode,\n quantity: i.quantity,\n sourceQuoteLineId: i.sourceQuoteLineId,\n })),\n assets: assets.map((a) => ({\n id: a.id,\n code: a.code,\n name: a.name,\n status: a.status,\n subscriptionItemId: a.subscriptionItemId,\n productId: a.productId,\n })),\n }\n }\n\n /**\n * Apply ARC line changes to a subscription's item set in place.\n * Returns a per-line summary ready to write into ChangeLog.line_changes.\n */\n private async applyLineChanges(\n sub: CpqInventorySubscription,\n lineChanges: ArcLineChange[],\n scope: TenantScope,\n _ignored: null,\n ): Promise<{ lineChangeSummary: Array<Record<string, unknown>> }> {\n void _ignored\n\n const summary: Array<Record<string, unknown>> = []\n if (lineChanges.length === 0) return { lineChangeSummary: summary }\n\n // Pre-load assetizable specs for new items to decide whether to materialize\n // assets on add lines.\n const specIdsForAdd = new Set<string>()\n for (const lc of lineChanges) {\n if (lc.action === 'add' && lc.itemInput?.specId) {\n specIdsForAdd.add(lc.itemInput.specId)\n }\n }\n const assetizableSpecs = new Map<string, boolean>()\n if (specIdsForAdd.size > 0) {\n const specs = await this.em.find(CpqProductSpecification, {\n id: { $in: Array.from(specIdsForAdd) },\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n for (const s of specs) assetizableSpecs.set(s.id, s.isAssetizable === true)\n }\n\n // XD-250 ARC: build quoteLineId \u2192 resulting subscriptionItemId map up-front\n // so `add` lines can resolve their parentItemId regardless of the order\n // their parent appears in `lineChanges`. For 'modify' the parent already\n // exists (its sourceSubscriptionItemId is the answer); for sibling 'add'\n // lines we pre-generate the new item id.\n const quoteLineToFinalItemId = new Map<string, string>()\n const preGeneratedAddIds = new Map<string, string>()\n for (const lc of lineChanges) {\n if (!lc.quoteLineId) continue\n if (lc.action === 'add') {\n const id = crypto.randomUUID()\n preGeneratedAddIds.set(lc.quoteLineId, id)\n quoteLineToFinalItemId.set(lc.quoteLineId, id)\n } else if (lc.action === 'modify' && lc.sourceSubscriptionItemId) {\n quoteLineToFinalItemId.set(lc.quoteLineId, lc.sourceSubscriptionItemId)\n }\n }\n\n for (const lc of lineChanges) {\n if (lc.action === 'add') {\n if (!lc.itemInput) {\n throw { status: 400, error: 'add line is missing itemInput' }\n }\n // Pre-generated id \u2014 `defaultRaw: 'gen_random_uuid()'` only fires at\n // INSERT, so without this `item.id` is undefined between em.create()\n // and em.flush(). That breaks: (a) the asset row that references\n // `subscriptionItemId: item.id`, (b) the change-log `itemId` (which\n // the UI joins against the after-snapshot to resolve names), and\n // (c) the parentItemId resolution for sibling `add` children.\n const newItemId = lc.quoteLineId\n ? preGeneratedAddIds.get(lc.quoteLineId) ?? crypto.randomUUID()\n : crypto.randomUUID()\n const parentItemId =\n lc.itemInput.parentItemId ??\n (lc.parentQuoteLineId\n ? quoteLineToFinalItemId.get(lc.parentQuoteLineId) ?? null\n : null)\n const item = this.em.create(CpqInventorySubscriptionItem, {\n id: newItemId,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n subscriptionId: sub.id,\n customerId: sub.customerId,\n parentItemId,\n productId: lc.itemInput.productId ?? null,\n offeringId: lc.itemInput.offeringId ?? null,\n specId: lc.itemInput.specId ?? null,\n name: lc.itemInput.name,\n status: 'active',\n configuration: lc.itemInput.configuration ?? {},\n charges: lc.itemInput.charges ?? null,\n mrcAmount: String(lc.itemInput.mrcAmount ?? 0),\n nrcAmount: String(lc.itemInput.nrcAmount ?? 0),\n currencyCode: lc.itemInput.currencyCode ?? sub.currencyCode,\n quantity: lc.itemInput.quantity ?? 1,\n capacityTotal:\n lc.itemInput.capacityTotal != null ? String(lc.itemInput.capacityTotal) : null,\n capacityUsed: null,\n capacityUnit: lc.itemInput.capacityUnit ?? null,\n sourceQuoteLineId: lc.quoteLineId ?? lc.itemInput.sourceQuoteLineId ?? null,\n metadata: lc.itemInput.metadata ?? null,\n sortOrder: lc.itemInput.sortOrder ?? 0,\n })\n this.em.persist(item)\n\n // Materialize a pending asset only when the spec is assetizable.\n if (lc.itemInput.specId && assetizableSpecs.get(lc.itemInput.specId)) {\n const code = await this.generateAssetCode(scope)\n const asset = this.em.create(CpqInventoryAsset, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n customerId: sub.customerId,\n subscriptionId: sub.id,\n subscriptionItemId: item.id,\n productId: lc.itemInput.productId ?? null,\n offeringId: lc.itemInput.offeringId ?? null,\n specId: lc.itemInput.specId,\n code,\n name: lc.itemInput.name,\n status: 'pending',\n assetType: 'one_time',\n currencyCode: lc.itemInput.currencyCode ?? sub.currencyCode,\n purchasePrice: String(lc.itemInput.nrcAmount ?? 0),\n quantity: lc.itemInput.quantity ?? 1,\n configuration: lc.itemInput.configuration ?? {},\n charges: lc.itemInput.charges ?? null,\n sourceOrderId: null,\n sourceQuoteLineId: lc.quoteLineId ?? null,\n })\n this.em.persist(asset)\n }\n\n summary.push({\n action: 'add',\n itemId: item.id,\n quoteLineId: lc.quoteLineId ?? null,\n mrcAmount: Number(item.mrcAmount),\n nrcAmount: Number(item.nrcAmount),\n quantity: item.quantity,\n })\n } else if (lc.action === 'cancel') {\n if (!lc.sourceSubscriptionItemId) {\n throw { status: 400, error: 'cancel line is missing sourceSubscriptionItemId' }\n }\n const item = await this.em.findOne(CpqInventorySubscriptionItem, {\n id: lc.sourceSubscriptionItemId,\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!item) {\n throw {\n status: 404,\n error: `Subscription item ${lc.sourceSubscriptionItemId} not found on subscription ${sub.id}`,\n }\n }\n item.status = 'terminated'\n\n // Cancel any active assets attached to this item.\n const assets = await this.em.find(CpqInventoryAsset, {\n subscriptionItemId: item.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['returned', 'cancelled'] },\n })\n for (const asset of assets) asset.status = 'cancelled'\n\n summary.push({\n action: 'cancel',\n itemId: item.id,\n quoteLineId: lc.quoteLineId ?? null,\n mrcDelta: -Number(item.mrcAmount),\n })\n } else if (lc.action === 'modify') {\n if (!lc.sourceSubscriptionItemId) {\n throw { status: 400, error: 'modify line is missing sourceSubscriptionItemId' }\n }\n const item = await this.em.findOne(CpqInventorySubscriptionItem, {\n id: lc.sourceSubscriptionItemId,\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n })\n if (!item) {\n throw {\n status: 404,\n error: `Subscription item ${lc.sourceSubscriptionItemId} not found on subscription ${sub.id}`,\n }\n }\n const oldMrc = Number(item.mrcAmount)\n if (lc.modifyPatch?.configuration !== undefined) {\n item.configuration = lc.modifyPatch.configuration\n }\n if (lc.modifyPatch?.charges !== undefined) {\n item.charges = lc.modifyPatch.charges\n }\n if (lc.modifyPatch?.mrcAmount !== undefined) {\n item.mrcAmount = String(lc.modifyPatch.mrcAmount)\n }\n if (lc.modifyPatch?.nrcAmount !== undefined) {\n item.nrcAmount = String(lc.modifyPatch.nrcAmount)\n }\n if (lc.modifyPatch?.quantity !== undefined) {\n item.quantity = lc.modifyPatch.quantity\n }\n const newMrc = Number(item.mrcAmount)\n if (newMrc !== oldMrc || lc.modifyPatch?.configuration || lc.modifyPatch?.charges) {\n summary.push({\n action: 'modify',\n itemId: item.id,\n quoteLineId: lc.quoteLineId ?? null,\n mrcDelta: newMrc - oldMrc,\n })\n }\n }\n }\n\n return { lineChangeSummary: summary }\n }\n\n private async recomputeSubscriptionAggregatesInPlace(\n sub: CpqInventorySubscription,\n scope: TenantScope,\n ): Promise<void> {\n const items = await this.em.find(CpqInventorySubscriptionItem, {\n subscriptionId: sub.id,\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n status: { $nin: ['terminated', 'expired', 'superseded'] },\n })\n const mrcSum = items.reduce((s, i) => s + Number(i.mrcAmount), 0)\n const nrcSum = items.reduce((s, i) => s + Number(i.nrcAmount), 0)\n sub.mrcAmount = String(mrcSum)\n sub.nrcAmount = String(nrcSum)\n }\n\n private createChangeLog(args: {\n subscription: CpqInventorySubscription\n changeType: ChangeLogType\n sourceQuoteId?: string | null\n sourceOrderId?: string | null\n performedByUserId?: string | null\n beforeSnapshot: Record<string, unknown> | null\n afterSnapshot: Record<string, unknown> | null\n lineChanges: Array<Record<string, unknown>> | null\n termChange?: Record<string, unknown> | null\n mergedIntoSubscriptionId?: string | null\n mergedFromSubscriptionIds?: string[] | null\n reasonCode?: string | null\n reasonText?: string | null\n etfAmount?: string | null\n etfCurrency?: string | null\n }): CpqSubscriptionChangeLog {\n const log = this.em.create(CpqSubscriptionChangeLog, {\n organizationId: args.subscription.organizationId,\n tenantId: args.subscription.tenantId,\n subscriptionId: args.subscription.id,\n changeType: args.changeType,\n sourceQuoteId: args.sourceQuoteId ?? null,\n sourceOrderId: args.sourceOrderId ?? null,\n performedByUserId: args.performedByUserId ?? null,\n effectiveAt: new Date(),\n beforeSnapshot: args.beforeSnapshot,\n afterSnapshot: args.afterSnapshot,\n lineChanges: args.lineChanges,\n termChange: args.termChange ?? null,\n mergedIntoSubscriptionId: args.mergedIntoSubscriptionId ?? null,\n mergedFromSubscriptionIds: args.mergedFromSubscriptionIds ?? null,\n reasonCode: args.reasonCode ?? null,\n reasonText: args.reasonText ?? null,\n etfAmount: args.etfAmount ?? null,\n etfCurrency: args.etfCurrency ?? null,\n })\n this.em.persist(log)\n return log\n }\n\n private buildItemTree(items: CpqInventorySubscriptionItem[]): SubscriptionItemResultNode[] {\n const nodeMap = new Map<string, SubscriptionItemResultNode>()\n\n for (const item of items) {\n nodeMap.set(item.id, {\n id: item.id,\n subscriptionId: item.subscriptionId,\n parentItemId: item.parentItemId ?? null,\n productId: item.productId ?? null,\n offeringId: item.offeringId ?? null,\n specId: item.specId ?? null,\n name: item.name,\n status: item.status,\n configuration: item.configuration ?? {},\n charges: item.charges ?? null,\n mrcAmount: Number(item.mrcAmount),\n nrcAmount: Number(item.nrcAmount),\n currencyCode: item.currencyCode,\n quantity: item.quantity,\n capacityTotal: item.capacityTotal != null ? Number(item.capacityTotal) : null,\n capacityUsed: item.capacityUsed != null ? Number(item.capacityUsed) : null,\n capacityUnit: item.capacityUnit ?? null,\n metadata: item.metadata ?? null,\n sortOrder: item.sortOrder,\n children: [],\n })\n }\n\n const roots: SubscriptionItemResultNode[] = []\n\n for (const node of nodeMap.values()) {\n if (node.parentItemId && nodeMap.has(node.parentItemId)) {\n nodeMap.get(node.parentItemId)!.children.push(node)\n } else {\n roots.push(node)\n }\n }\n\n return roots\n }\n\n private async generateSubscriptionCode(scope: TenantScope): Promise<string> {\n const year = new Date().getFullYear()\n const count = await this.em.count(CpqInventorySubscription, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n })\n const seq = String(count + 1).padStart(5, '0')\n return `SUB-${year}-${seq}`\n }\n\n private async generateAssetCode(scope: TenantScope): Promise<string> {\n const year = new Date().getFullYear()\n const count = await this.em.count(CpqInventoryAsset, {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n })\n const seq = String(count + 1).padStart(5, '0')\n return `AST-${year}-${seq}`\n }\n\n private async subscriptionIdsForProduct(productId: string, scope: TenantScope): Promise<string[]> {\n const items = await this.em.find(\n CpqInventorySubscriptionItem,\n {\n organizationId: scope.organizationId,\n tenantId: scope.tenantId,\n deletedAt: null,\n productId,\n },\n { fields: ['subscriptionId'] as const },\n )\n return [...new Set(items.map((i) => i.subscriptionId))]\n }\n}\n\n// \u2500\u2500\u2500 Module-private helpers \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\nfunction toDate(value: Date | string): Date {\n return value instanceof Date ? value : new Date(value)\n}\n\n/**\n * MikroORM `@Property({ type: 'date' })` columns hydrate as strings on\n * Postgres (YYYY-MM-DD) \u2014 calling `.toISOString()` on them throws. This\n * helper accepts either form.\n */\nfunction toIsoOrNull(value: Date | string | null | undefined): string | null {\n if (value == null) return null\n if (value instanceof Date) return value.toISOString()\n return String(value)\n}\n"],
5
+ "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AA4PA,MAAM,2BAA2B;AAAA,EAGtC,YAAY,IAAmB;AAC7B,SAAK,KAAK;AAAA,EACZ;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,kBAAkB,SAAkC,OAAwE;AAChI,UAAM,OAAO,KAAK,IAAI,GAA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