@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,1467 @@
1
+ import { OptionalProps } from '@mikro-orm/core'
2
+ import { Entity, Index, PrimaryKey, Property, Unique } from '@mikro-orm/decorators/legacy'
3
+
4
+ // ─── CpqProductSpecification ─────────────────────────────────────
5
+
6
+ // Additional indexes added in `Migration20260514110000_cpq_list_search_indexes`
7
+ // (hand-written because MikroORM cannot express `gin_trgm_ops` / partial predicates):
8
+ // - GIN trigram on code/name/description (powers list `$ilike` search)
9
+ // - composite (org, tenant, deleted_at, created_at DESC) for default sort path
10
+ @Entity({ tableName: 'cpq_product_specifications' })
11
+ @Unique({ name: 'cpq_product_specifications_product_unique', properties: ['organizationId', 'tenantId', 'productId'] })
12
+ @Unique({ name: 'cpq_product_specifications_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
13
+ @Index({ name: 'cpq_product_specifications_lifecycle_idx', properties: ['organizationId', 'tenantId', 'lifecycleStatus'] })
14
+ export class CpqProductSpecification {
15
+ [OptionalProps]?: 'specType' | 'isAssetizable' | 'lifecycleStatus' | 'version' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
16
+
17
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
18
+ id!: string
19
+
20
+ @Property({ name: 'organization_id', type: 'uuid' })
21
+ organizationId!: string
22
+
23
+ @Property({ name: 'tenant_id', type: 'uuid' })
24
+ tenantId!: string
25
+
26
+ @Property({ name: 'product_id', type: 'uuid' })
27
+ productId!: string
28
+
29
+ @Property({ type: 'text' })
30
+ code!: string
31
+
32
+ @Property({ type: 'text' })
33
+ name!: string
34
+
35
+ @Property({ type: 'text', nullable: true })
36
+ description?: string | null
37
+
38
+ @Property({ name: 'spec_type', type: 'text', default: 'simple' })
39
+ specType: string = 'simple'
40
+
41
+ @Property({ name: 'is_assetizable', type: 'boolean', default: false })
42
+ isAssetizable: boolean = false
43
+
44
+ @Property({ name: 'lifecycle_status', type: 'text', default: 'draft' })
45
+ lifecycleStatus: string = 'draft'
46
+
47
+ @Property({ type: 'integer', default: 1 })
48
+ version: number = 1
49
+
50
+ @Property({ name: 'effective_from', type: Date, nullable: true })
51
+ effectiveFrom?: Date | null
52
+
53
+ @Property({ name: 'effective_to', type: Date, nullable: true })
54
+ effectiveTo?: Date | null
55
+
56
+ @Property({ type: 'jsonb', nullable: true })
57
+ metadata?: Record<string, unknown> | null
58
+
59
+ @Property({ name: 'is_active', type: 'boolean', default: true })
60
+ isActive: boolean = true
61
+
62
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
63
+ createdAt: Date = new Date()
64
+
65
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
66
+ updatedAt: Date = new Date()
67
+
68
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
69
+ deletedAt?: Date | null
70
+ }
71
+
72
+ // ─── CpqProductOffering ─────────────────────────────────────────
73
+
74
+ // Additional indexes added in `Migration20260514110000_cpq_list_search_indexes`
75
+ // (hand-written because MikroORM cannot express `gin_trgm_ops` / partial predicates):
76
+ // - GIN trigram on code/name/description (powers list `$ilike` search)
77
+ // - composite (org, tenant, deleted_at, created_at DESC) for default sort path
78
+ @Entity({ tableName: 'cpq_product_offerings' })
79
+ @Unique({ name: 'cpq_product_offerings_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
80
+ @Index({ name: 'cpq_product_offerings_spec_idx', properties: ['organizationId', 'tenantId', 'specId'] })
81
+ @Index({ name: 'cpq_product_offerings_lifecycle_idx', properties: ['organizationId', 'tenantId', 'lifecycleStatus'] })
82
+ export class CpqProductOffering {
83
+ [OptionalProps]?: 'offeringType' | 'designTimeValues' | 'lifecycleStatus' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
84
+
85
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
86
+ id!: string
87
+
88
+ @Property({ name: 'organization_id', type: 'uuid' })
89
+ organizationId!: string
90
+
91
+ @Property({ name: 'tenant_id', type: 'uuid' })
92
+ tenantId!: string
93
+
94
+ @Property({ name: 'spec_id', type: 'uuid' })
95
+ specId!: string
96
+
97
+ @Property({ name: 'catalog_offer_id', type: 'uuid', nullable: true })
98
+ catalogOfferId?: string | null
99
+
100
+ @Property({ type: 'text' })
101
+ code!: string
102
+
103
+ @Property({ type: 'text' })
104
+ name!: string
105
+
106
+ @Property({ type: 'text', nullable: true })
107
+ description?: string | null
108
+
109
+ @Property({ name: 'offering_type', type: 'text', default: 'simple' })
110
+ offeringType: string = 'simple'
111
+
112
+ @Property({ name: 'design_time_values', type: 'jsonb', default: '{}' })
113
+ designTimeValues: Record<string, unknown> = {}
114
+
115
+ @Property({ name: 'lifecycle_status', type: 'text', default: 'draft' })
116
+ lifecycleStatus: string = 'draft'
117
+
118
+ @Property({ name: 'effective_from', type: Date, nullable: true })
119
+ effectiveFrom?: Date | null
120
+
121
+ @Property({ name: 'effective_to', type: Date, nullable: true })
122
+ effectiveTo?: Date | null
123
+
124
+ @Property({ type: 'jsonb', nullable: true })
125
+ metadata?: Record<string, unknown> | null
126
+
127
+ @Property({ name: 'is_active', type: 'boolean', default: true })
128
+ isActive: boolean = true
129
+
130
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
131
+ createdAt: Date = new Date()
132
+
133
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
134
+ updatedAt: Date = new Date()
135
+
136
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
137
+ deletedAt?: Date | null
138
+ }
139
+
140
+ // ─── CpqProductRelationship ─────────────────────────────────────
141
+
142
+ @Entity({ tableName: 'cpq_product_relationships' })
143
+ @Unique({
144
+ name: 'cpq_product_relationships_unique',
145
+ properties: ['organizationId', 'tenantId', 'sourceSpecId', 'targetSpecId', 'relationshipType'],
146
+ })
147
+ @Index({ name: 'cpq_product_relationships_source_idx', properties: ['organizationId', 'tenantId', 'sourceSpecId'] })
148
+ @Index({ name: 'cpq_product_relationships_target_idx', properties: ['organizationId', 'tenantId', 'targetSpecId'] })
149
+ export class CpqProductRelationship {
150
+ [OptionalProps]?: 'cardinalityMin' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
151
+
152
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
153
+ id!: string
154
+
155
+ @Property({ name: 'organization_id', type: 'uuid' })
156
+ organizationId!: string
157
+
158
+ @Property({ name: 'tenant_id', type: 'uuid' })
159
+ tenantId!: string
160
+
161
+ @Property({ name: 'source_spec_id', type: 'uuid' })
162
+ sourceSpecId!: string
163
+
164
+ @Property({ name: 'target_spec_id', type: 'uuid' })
165
+ targetSpecId!: string
166
+
167
+ @Property({ name: 'relationship_type', type: 'text' })
168
+ relationshipType!: string
169
+
170
+ @Property({ name: 'cardinality_min', type: 'integer', default: 0 })
171
+ cardinalityMin: number = 0
172
+
173
+ @Property({ name: 'cardinality_max', type: 'integer', nullable: true })
174
+ cardinalityMax?: number | null
175
+
176
+ @Property({ type: 'jsonb', nullable: true })
177
+ condition?: Record<string, unknown> | null
178
+
179
+ @Property({ type: 'jsonb', nullable: true })
180
+ metadata?: Record<string, unknown> | null
181
+
182
+ @Property({ name: 'is_active', type: 'boolean', default: true })
183
+ isActive: boolean = true
184
+
185
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
186
+ createdAt: Date = new Date()
187
+
188
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
189
+ updatedAt: Date = new Date()
190
+
191
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
192
+ deletedAt?: Date | null
193
+ }
194
+
195
+ // ─── CpqBundleSlot ──────────────────────────────────────────────
196
+
197
+ @Entity({ tableName: 'cpq_bundle_slots' })
198
+ @Index({ name: 'cpq_bundle_slot_spec_idx', properties: ['organizationId', 'tenantId', 'specId'] })
199
+ @Index({ name: 'cpq_bundle_slot_target_idx', properties: ['organizationId', 'tenantId', 'targetSpecId'] })
200
+ @Index({ name: 'cpq_bundle_slot_group_idx', properties: ['organizationId', 'tenantId', 'specId', 'componentGroup'] })
201
+ export class CpqBundleSlot {
202
+ [OptionalProps]?: 'cardinalityMin' | 'sortOrder' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
203
+
204
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
205
+ id!: string
206
+
207
+ @Property({ name: 'organization_id', type: 'uuid' })
208
+ organizationId!: string
209
+
210
+ @Property({ name: 'tenant_id', type: 'uuid' })
211
+ tenantId!: string
212
+
213
+ @Property({ name: 'spec_id', type: 'uuid' })
214
+ specId!: string
215
+
216
+ @Property({ name: 'target_spec_id', type: 'uuid' })
217
+ targetSpecId!: string
218
+
219
+ @Property({ name: 'component_group', type: 'text' })
220
+ componentGroup!: string
221
+
222
+ @Property({ type: 'text' })
223
+ name!: string
224
+
225
+ @Property({ type: 'text', nullable: true })
226
+ description?: string | null
227
+
228
+ @Property({ name: 'cardinality_min', type: 'integer', default: 0 })
229
+ cardinalityMin: number = 0
230
+
231
+ @Property({ name: 'cardinality_max', type: 'integer', nullable: true })
232
+ cardinalityMax?: number | null
233
+
234
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
235
+ sortOrder: number = 0
236
+
237
+ @Property({ name: 'is_active', type: 'boolean', default: true })
238
+ isActive: boolean = true
239
+
240
+ @Property({ type: 'jsonb', nullable: true })
241
+ metadata?: Record<string, unknown> | null
242
+
243
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
244
+ createdAt: Date = new Date()
245
+
246
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
247
+ updatedAt: Date = new Date()
248
+
249
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
250
+ deletedAt?: Date | null
251
+ }
252
+
253
+ // ─── CpqOfferingComponent ───────────────────────────────────────
254
+
255
+ @Entity({ tableName: 'cpq_offering_components' })
256
+ @Index({ name: 'cpq_off_comp_offering_idx', properties: ['organizationId', 'tenantId', 'offeringId'] })
257
+ @Index({ name: 'cpq_off_comp_slot_idx', properties: ['organizationId', 'tenantId', 'offeringId', 'slotId'] })
258
+ @Index({ name: 'cpq_off_comp_child_idx', properties: ['organizationId', 'tenantId', 'childOfferingId'] })
259
+ @Unique({ name: 'cpq_off_comp_unique', properties: ['organizationId', 'tenantId', 'offeringId', 'childOfferingId'] })
260
+ export class CpqOfferingComponent {
261
+ [OptionalProps]?: 'isDefault' | 'sortOrder' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
262
+
263
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
264
+ id!: string
265
+
266
+ @Property({ name: 'organization_id', type: 'uuid' })
267
+ organizationId!: string
268
+
269
+ @Property({ name: 'tenant_id', type: 'uuid' })
270
+ tenantId!: string
271
+
272
+ @Property({ name: 'offering_id', type: 'uuid' })
273
+ offeringId!: string
274
+
275
+ @Property({ name: 'slot_id', type: 'uuid' })
276
+ slotId!: string
277
+
278
+ @Property({ name: 'child_offering_id', type: 'uuid' })
279
+ childOfferingId!: string
280
+
281
+ @Property({ name: 'is_default', type: 'boolean', default: false })
282
+ isDefault: boolean = false
283
+
284
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
285
+ sortOrder: number = 0
286
+
287
+ @Property({ name: 'is_active', type: 'boolean', default: true })
288
+ isActive: boolean = true
289
+
290
+ @Property({ type: 'jsonb', nullable: true })
291
+ metadata?: Record<string, unknown> | null
292
+
293
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
294
+ createdAt: Date = new Date()
295
+
296
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
297
+ updatedAt: Date = new Date()
298
+
299
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
300
+ deletedAt?: Date | null
301
+ }
302
+
303
+ // ─── CpqProductAttribute ─────────────────────────────────────────
304
+
305
+ @Entity({ tableName: 'cpq_product_attributes' })
306
+ @Index({ name: 'cpq_product_attributes_scope_idx', properties: ['organizationId', 'tenantId', 'productId'] })
307
+ @Index({ name: 'cpq_product_attributes_spec_idx', properties: ['organizationId', 'tenantId', 'specId'] })
308
+ @Index({ name: 'cpq_product_attributes_spec_resolution_idx', properties: ['organizationId', 'tenantId', 'specId', 'resolutionTime'] })
309
+ @Unique({
310
+ name: 'cpq_product_attributes_code_unique',
311
+ properties: ['organizationId', 'tenantId', 'productId', 'code'],
312
+ })
313
+ export class CpqProductAttribute {
314
+ [OptionalProps]?: 'resolutionTime' | 'isRequired' | 'isActive' | 'sortOrder' | 'createdAt' | 'updatedAt' | 'deletedAt'
315
+
316
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
317
+ id!: string
318
+
319
+ @Property({ name: 'organization_id', type: 'uuid' })
320
+ organizationId!: string
321
+
322
+ @Property({ name: 'tenant_id', type: 'uuid' })
323
+ tenantId!: string
324
+
325
+ @Property({ name: 'product_id', type: 'uuid' })
326
+ productId!: string
327
+
328
+ @Property({ name: 'spec_id', type: 'uuid', nullable: true })
329
+ specId?: string | null
330
+
331
+ @Property({ type: 'text' })
332
+ code!: string
333
+
334
+ @Property({ type: 'text' })
335
+ name!: string
336
+
337
+ @Property({ name: 'attribute_type', type: 'text' })
338
+ attributeType!: string
339
+
340
+ @Property({ name: 'resolution_time', type: 'text', default: 'run_time' })
341
+ resolutionTime: string = 'run_time'
342
+
343
+ @Property({ type: 'jsonb', nullable: true })
344
+ options?: Array<{ value: string; label: string }> | null
345
+
346
+ @Property({ type: 'jsonb', nullable: true })
347
+ constraints?: Record<string, unknown> | null
348
+
349
+ @Property({ name: 'reference_entity', type: 'text', nullable: true })
350
+ referenceEntity?: string | null
351
+
352
+ @Property({ name: 'reference_filter', type: 'jsonb', nullable: true })
353
+ referenceFilter?: Record<string, unknown> | null
354
+
355
+ @Property({ name: 'depends_on', type: 'jsonb', nullable: true })
356
+ dependsOn?: Record<string, unknown> | null
357
+
358
+ @Property({ name: 'default_value', type: 'jsonb', nullable: true })
359
+ defaultValue?: unknown | null
360
+
361
+ @Property({ name: 'help_text', type: 'text', nullable: true })
362
+ helpText?: string | null
363
+
364
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
365
+ sortOrder: number = 0
366
+
367
+ @Property({ name: 'is_required', type: 'boolean', default: true })
368
+ isRequired: boolean = true
369
+
370
+ @Property({ name: 'is_active', type: 'boolean', default: true })
371
+ isActive: boolean = true
372
+
373
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
374
+ createdAt: Date = new Date()
375
+
376
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
377
+ updatedAt: Date = new Date()
378
+
379
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
380
+ deletedAt?: Date | null
381
+ }
382
+
383
+ // ─── CpqPricingTable ─────────────────────────────────────────────
384
+
385
+ @Entity({ tableName: 'cpq_pricing_tables' })
386
+ @Index({ name: 'cpq_pricing_tables_scope_idx', properties: ['organizationId', 'tenantId'] })
387
+ @Unique({ name: 'cpq_pricing_tables_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
388
+ export class CpqPricingTable {
389
+ [OptionalProps]?: 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
390
+
391
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
392
+ id!: string
393
+
394
+ @Property({ name: 'organization_id', type: 'uuid' })
395
+ organizationId!: string
396
+
397
+ @Property({ name: 'tenant_id', type: 'uuid' })
398
+ tenantId!: string
399
+
400
+ @Property({ type: 'text' })
401
+ code!: string
402
+
403
+ @Property({ type: 'text' })
404
+ name!: string
405
+
406
+ @Property({ type: 'jsonb' })
407
+ dimensions!: Array<{ key: string; label: string }>
408
+
409
+ @Property({ name: 'price_columns', type: 'jsonb' })
410
+ priceColumns!: Array<{ key: string; label: string }>
411
+
412
+ @Property({ name: 'currency_code_list', type: 'jsonb' })
413
+ currencyCodeList!: string[]
414
+
415
+ @Property({ name: 'is_active', type: 'boolean', default: true })
416
+ isActive: boolean = true
417
+
418
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
419
+ createdAt: Date = new Date()
420
+
421
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
422
+ updatedAt: Date = new Date()
423
+
424
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
425
+ deletedAt?: Date | null
426
+ }
427
+
428
+ // ─── CpqPricingTableEntry ────────────────────────────────────────
429
+
430
+ @Entity({ tableName: 'cpq_pricing_table_entries' })
431
+ @Index({ name: 'cpq_pricing_table_entries_scope_idx', properties: ['organizationId', 'tenantId', 'pricingTableId'] })
432
+ @Index({ name: 'cpq_pricing_table_entries_dim_gin_idx', properties: ['dimensionValues'], type: 'GIN' })
433
+ export class CpqPricingTableEntry {
434
+ [OptionalProps]?: 'isActive' | 'currencyCode' | 'createdAt' | 'updatedAt' | 'deletedAt'
435
+
436
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
437
+ id!: string
438
+
439
+ @Property({ name: 'organization_id', type: 'uuid' })
440
+ organizationId!: string
441
+
442
+ @Property({ name: 'tenant_id', type: 'uuid' })
443
+ tenantId!: string
444
+
445
+ @Property({ name: 'pricing_table_id', type: 'uuid' })
446
+ pricingTableId!: string
447
+
448
+ @Property({ name: 'dimension_values', type: 'jsonb' })
449
+ dimensionValues!: Record<string, string>
450
+
451
+ @Property({ name: 'tier_number', type: 'integer', nullable: true })
452
+ tierNumber?: number | null
453
+
454
+ @Property({ name: 'range_from', type: 'numeric', nullable: true })
455
+ rangeFrom?: string | null
456
+
457
+ @Property({ name: 'range_to', type: 'numeric', nullable: true })
458
+ rangeTo?: string | null
459
+
460
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
461
+ currencyCode: string = 'USD'
462
+
463
+ @Property({ type: 'jsonb' })
464
+ prices!: Record<string, number>
465
+
466
+ @Property({ name: 'is_active', type: 'boolean', default: true })
467
+ isActive: boolean = true
468
+
469
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
470
+ createdAt: Date = new Date()
471
+
472
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
473
+ updatedAt: Date = new Date()
474
+
475
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
476
+ deletedAt?: Date | null
477
+ }
478
+
479
+ // ─── CpqProductCharge ────────────────────────────────────────────
480
+
481
+ @Entity({ tableName: 'cpq_product_charges' })
482
+ @Index({ name: 'cpq_product_charges_scope_idx', properties: ['organizationId', 'tenantId', 'productId'] })
483
+ @Index({ name: 'cpq_product_charges_offering_idx', properties: ['organizationId', 'tenantId', 'offeringId'] })
484
+ @Unique({
485
+ name: 'cpq_product_charges_offering_code_unique',
486
+ properties: ['organizationId', 'tenantId', 'offeringId', 'code'],
487
+ })
488
+ export class CpqProductCharge {
489
+ [OptionalProps]?: 'isActive' | 'sortOrder' | 'createdAt' | 'updatedAt' | 'deletedAt'
490
+
491
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
492
+ id!: string
493
+
494
+ @Property({ name: 'organization_id', type: 'uuid' })
495
+ organizationId!: string
496
+
497
+ @Property({ name: 'tenant_id', type: 'uuid' })
498
+ tenantId!: string
499
+
500
+ @Property({ name: 'product_id', type: 'uuid' })
501
+ productId!: string
502
+
503
+ @Property({ name: 'offering_id', type: 'uuid', nullable: true })
504
+ offeringId?: string | null
505
+
506
+ @Property({ type: 'text' })
507
+ code!: string
508
+
509
+ @Property({ type: 'text' })
510
+ name!: string
511
+
512
+ @Property({ type: 'text', nullable: true })
513
+ description?: string | null
514
+
515
+ @Property({ name: 'charge_type', type: 'text' })
516
+ chargeType!: string
517
+
518
+ @Property({ name: 'pricing_method', type: 'text' })
519
+ pricingMethod!: string
520
+
521
+ @Property({ name: 'pricing_table_id', type: 'uuid', nullable: true })
522
+ pricingTableId?: string | null
523
+
524
+ @Property({ name: 'price_column_key', type: 'text', nullable: true })
525
+ priceColumnKey?: string | null
526
+
527
+ @Property({ name: 'fixed_price', type: 'numeric', nullable: true })
528
+ fixedPrice?: string | null
529
+
530
+ @Property({ name: 'currency_code', type: 'text', nullable: true })
531
+ currencyCode?: string | null
532
+
533
+ @Property({ name: 'quantity_attribute_code', type: 'text', nullable: true })
534
+ quantityAttributeCode?: string | null
535
+
536
+ @Property({ name: 'applicability_condition', type: 'jsonb', nullable: true })
537
+ applicabilityCondition?: Record<string, unknown> | null
538
+
539
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
540
+ sortOrder: number = 0
541
+
542
+ @Property({ name: 'is_active', type: 'boolean', default: true })
543
+ isActive: boolean = true
544
+
545
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
546
+ createdAt: Date = new Date()
547
+
548
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
549
+ updatedAt: Date = new Date()
550
+
551
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
552
+ deletedAt?: Date | null
553
+ }
554
+
555
+ // ─── CpqPriceRule ─────────────────────────────────────────────────
556
+
557
+ @Entity({ tableName: 'cpq_price_rules' })
558
+ @Index({ name: 'cpq_price_rules_scope_idx', properties: ['organizationId', 'tenantId'] })
559
+ @Unique({ name: 'cpq_price_rules_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
560
+ @Index({ name: 'cpq_price_rules_product_idx', properties: ['organizationId', 'tenantId', 'productOfferingId'] })
561
+ export class CpqPriceRule {
562
+ [OptionalProps]?: 'sortOrder' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
563
+
564
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
565
+ id!: string
566
+
567
+ @Property({ name: 'organization_id', type: 'uuid' })
568
+ organizationId!: string
569
+
570
+ @Property({ name: 'tenant_id', type: 'uuid' })
571
+ tenantId!: string
572
+
573
+ @Property({ type: 'text' })
574
+ code!: string
575
+
576
+ @Property({ type: 'text' })
577
+ name!: string
578
+
579
+ @Property({ type: 'text', nullable: true })
580
+ description?: string | null
581
+
582
+ @Property({ name: 'product_offering_id', type: 'uuid', nullable: true })
583
+ productOfferingId?: string | null
584
+
585
+ @Property({ name: 'rule_type', type: 'text' })
586
+ ruleType!: string
587
+
588
+ @Property({ type: 'numeric' })
589
+ value!: string
590
+
591
+ @Property({ name: 'charge_code_filter', type: 'text', nullable: true })
592
+ chargeCodeFilter?: string | null
593
+
594
+ @Property({ name: 'charge_type_filter', type: 'text', nullable: true })
595
+ chargeTypeFilter?: string | null
596
+
597
+ @Property({ name: 'applicability_condition', type: 'jsonb', nullable: true })
598
+ applicabilityCondition?: Record<string, unknown> | null
599
+
600
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
601
+ sortOrder: number = 0
602
+
603
+ @Property({ name: 'is_active', type: 'boolean', default: true })
604
+ isActive: boolean = true
605
+
606
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
607
+ createdAt: Date = new Date()
608
+
609
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
610
+ updatedAt: Date = new Date()
611
+
612
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
613
+ deletedAt?: Date | null
614
+ }
615
+
616
+ // ─── CpqQuoteConfiguration ───────────────────────────────────────
617
+
618
+ @Entity({ tableName: 'cpq_quote_configurations' })
619
+ @Unique({ name: 'cpq_quote_configurations_quote_unique', properties: ['organizationId', 'tenantId', 'quoteId'] })
620
+ @Index({ name: 'cpq_quote_configurations_quote_type_idx', properties: ['organizationId', 'tenantId', 'quoteType'] })
621
+ export class CpqQuoteConfiguration {
622
+ [OptionalProps]?:
623
+ | 'cpqStatus'
624
+ | 'version'
625
+ | 'currencyCode'
626
+ | 'quoteType'
627
+ | 'createdAt'
628
+ | 'updatedAt'
629
+ | 'deletedAt'
630
+
631
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
632
+ id!: string
633
+
634
+ @Property({ name: 'organization_id', type: 'uuid' })
635
+ organizationId!: string
636
+
637
+ @Property({ name: 'tenant_id', type: 'uuid' })
638
+ tenantId!: string
639
+
640
+ @Property({ name: 'quote_id', type: 'uuid' })
641
+ quoteId!: string
642
+
643
+ @Property({ name: 'customer_id', type: 'uuid' })
644
+ customerId!: string
645
+
646
+ @Property({ name: 'cpq_status', type: 'text', default: 'new' })
647
+ cpqStatus: string = 'new'
648
+
649
+ @Property({ type: 'integer', default: 1 })
650
+ version: number = 1
651
+
652
+ @Property({ name: 'parent_quote_id', type: 'uuid', nullable: true })
653
+ parentQuoteId?: string | null
654
+
655
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
656
+ currencyCode: string = 'USD'
657
+
658
+ @Property({ name: 'quote_context', type: 'jsonb', nullable: true })
659
+ quoteContext?: Record<string, string | number | boolean> | null
660
+
661
+ @Property({ name: 'validation_result', type: 'jsonb', nullable: true })
662
+ validationResult?: Record<string, unknown> | null
663
+
664
+ @Property({ name: 'pricing_summary', type: 'jsonb', nullable: true })
665
+ pricingSummary?: Record<string, unknown> | null
666
+
667
+ // ── ARC (Amend / Renew / Cancel) — XD-250 ───────────────────────
668
+ @Property({ name: 'quote_type', type: 'text', default: 'new' })
669
+ quoteType: string = 'new'
670
+
671
+ // Cancel meta — only meaningful for quoteType='cancel'.
672
+ @Property({ name: 'arc_reason_code', type: 'text', nullable: true })
673
+ arcReasonCode?: string | null
674
+
675
+ @Property({ name: 'arc_reason_text', type: 'text', nullable: true })
676
+ arcReasonText?: string | null
677
+
678
+ @Property({ name: 'arc_etf_amount', type: 'numeric', columnType: 'numeric(18, 4)', nullable: true })
679
+ arcEtfAmount?: string | null
680
+
681
+ @Property({ name: 'arc_etf_currency', type: 'text', nullable: true })
682
+ arcEtfCurrency?: string | null
683
+
684
+ // Merge meta — only meaningful for quoteType='renew' with ≥2 absorb targets.
685
+ @Property({ name: 'arc_merge_new_term_start', type: 'date', nullable: true })
686
+ arcMergeNewTermStart?: Date | null
687
+
688
+ @Property({ name: 'arc_merge_new_term_end', type: 'date', nullable: true })
689
+ arcMergeNewTermEnd?: Date | null
690
+
691
+ @Property({ name: 'arc_merge_new_term_months', type: 'integer', nullable: true })
692
+ arcMergeNewTermMonths?: number | null
693
+
694
+ @Property({ name: 'arc_merge_new_sub_code', type: 'text', nullable: true })
695
+ arcMergeNewSubCode?: string | null
696
+
697
+ @Property({ name: 'arc_merge_new_sub_name', type: 'text', nullable: true })
698
+ arcMergeNewSubName?: string | null
699
+
700
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
701
+ createdAt: Date = new Date()
702
+
703
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
704
+ updatedAt: Date = new Date()
705
+
706
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
707
+ deletedAt?: Date | null
708
+ }
709
+
710
+ // ─── CpqWizardDefinition ───────────────────────────────────────
711
+
712
+ @Entity({ tableName: 'cpq_wizard_definitions' })
713
+ @Unique({ name: 'cpq_wizard_definitions_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
714
+ @Index({ name: 'cpq_wizard_definitions_active_idx', properties: ['organizationId', 'tenantId', 'isActive'] })
715
+ @Index({ name: 'cpq_wizard_definitions_surface_idx', properties: ['organizationId', 'tenantId', 'surface'] })
716
+ export class CpqWizardDefinition {
717
+ [OptionalProps]?: 'version' | 'surface' | 'isActive' | 'createdAt' | 'updatedAt' | 'deletedAt'
718
+
719
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
720
+ id!: string
721
+
722
+ @Property({ name: 'organization_id', type: 'uuid' })
723
+ organizationId!: string
724
+
725
+ @Property({ name: 'tenant_id', type: 'uuid' })
726
+ tenantId!: string
727
+
728
+ @Property({ type: 'text' })
729
+ code!: string
730
+
731
+ @Property({ type: 'text' })
732
+ name!: string
733
+
734
+ @Property({ type: 'text', nullable: true })
735
+ description?: string | null
736
+
737
+ @Property({ type: 'integer', default: 1 })
738
+ version: number = 1
739
+
740
+ @Property({ type: 'jsonb', default: '[]' })
741
+ steps!: Array<Record<string, unknown>>
742
+
743
+ @Property({ type: 'jsonb', nullable: true })
744
+ applicability?: Record<string, unknown> | null
745
+
746
+ @Property({ name: 'params_schema', type: 'jsonb', nullable: true })
747
+ paramsSchema?: Record<string, unknown> | null
748
+
749
+ @Property({ type: 'text', default: 'backend' })
750
+ surface: string = 'backend'
751
+
752
+ @Property({ name: 'is_active', type: 'boolean', default: true })
753
+ isActive: boolean = true
754
+
755
+ @Property({ type: 'jsonb', nullable: true })
756
+ metadata?: Record<string, unknown> | null
757
+
758
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
759
+ createdAt: Date = new Date()
760
+
761
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
762
+ updatedAt: Date = new Date()
763
+
764
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
765
+ deletedAt?: Date | null
766
+ }
767
+
768
+ // ─── CpqQuoteLineConfiguration ──────────────────────────────────
769
+
770
+ @Entity({ tableName: 'cpq_quote_line_configurations' })
771
+ @Unique({ name: 'cpq_qlc_quote_line_unique', properties: ['organizationId', 'tenantId', 'quoteLineId'] })
772
+ @Index({ name: 'cpq_qlc_quote_config_idx', properties: ['organizationId', 'tenantId', 'quoteConfigurationId'] })
773
+ @Index({ name: 'cpq_qlc_parent_line_idx', properties: ['organizationId', 'tenantId', 'parentLineId'] })
774
+ @Index({ name: 'cpq_qlc_target_sub_idx', properties: ['organizationId', 'tenantId', 'targetSubscriptionId'] })
775
+ export class CpqQuoteLineConfiguration {
776
+ [OptionalProps]?: 'action' | 'configuration' | 'quantity' | 'nrcTotal' | 'mrcTotal' | 'isConfigured' | 'createdAt' | 'updatedAt' | 'deletedAt'
777
+
778
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
779
+ id!: string
780
+
781
+ @Property({ name: 'organization_id', type: 'uuid' })
782
+ organizationId!: string
783
+
784
+ @Property({ name: 'tenant_id', type: 'uuid' })
785
+ tenantId!: string
786
+
787
+ @Property({ name: 'quote_line_id', type: 'uuid' })
788
+ quoteLineId!: string
789
+
790
+ @Property({ name: 'quote_configuration_id', type: 'uuid' })
791
+ quoteConfigurationId!: string
792
+
793
+ @Property({ name: 'offering_id', type: 'uuid', nullable: true })
794
+ offeringId?: string | null
795
+
796
+ @Property({ name: 'product_id', type: 'uuid', nullable: true })
797
+ productId?: string | null
798
+
799
+ @Property({ name: 'spec_id', type: 'uuid', nullable: true })
800
+ specId?: string | null
801
+
802
+ @Property({ type: 'text', default: 'add' })
803
+ action: string = 'add'
804
+
805
+ @Property({ name: 'parent_line_id', type: 'uuid', nullable: true })
806
+ parentLineId?: string | null
807
+
808
+ @Property({ name: 'start_date', type: 'date', nullable: true })
809
+ startDate?: Date | null
810
+
811
+ @Property({ name: 'term_months', type: 'integer', nullable: true })
812
+ termMonths?: number | null
813
+
814
+ @Property({ name: 'end_date', type: 'date', nullable: true })
815
+ endDate?: Date | null
816
+
817
+ @Property({ type: 'jsonb', default: '{}' })
818
+ configuration: Record<string, unknown> = {}
819
+
820
+ @Property({ type: 'integer', default: 1 })
821
+ quantity: number = 1
822
+
823
+ @Property({ type: 'jsonb', nullable: true })
824
+ charges?: Array<Record<string, unknown>> | null
825
+
826
+ @Property({ name: 'nrc_total', columnType: 'numeric(18, 4)', default: 0 })
827
+ nrcTotal: string = '0'
828
+
829
+ @Property({ name: 'mrc_total', columnType: 'numeric(18, 4)', default: 0 })
830
+ mrcTotal: string = '0'
831
+
832
+ @Property({ name: 'usage_estimates', type: 'jsonb', nullable: true })
833
+ usageEstimates?: Array<{ chargeCode: string; estimatedQuantity: number; estimatedTotal: number }> | null
834
+
835
+ @Property({ name: 'usage_total_estimated', type: 'numeric', columnType: 'numeric(18, 4)', nullable: true })
836
+ usageTotalEstimated?: string | null
837
+
838
+ @Property({ name: 'validation_errors', type: 'jsonb', nullable: true })
839
+ validationErrors?: Array<Record<string, unknown>> | null
840
+
841
+ @Property({ name: 'is_configured', type: 'boolean', default: false })
842
+ isConfigured: boolean = false
843
+
844
+ // ── ARC (Amend / Renew / Cancel) — XD-250 ───────────────────────
845
+ // For quote_type='amend'/'cancel'/'renew' standalone: identifies which
846
+ // target subscription the line affects. Null for type='new' and merge
847
+ // mode (M doesn't exist at quote time).
848
+ @Property({ name: 'target_subscription_id', type: 'uuid', nullable: true })
849
+ targetSubscriptionId?: string | null
850
+
851
+ // Required when action ∈ {cancel, modify} on amend/renew quotes.
852
+ // Identifies the existing subscription item the line is changing.
853
+ @Property({ name: 'source_subscription_item_id', type: 'uuid', nullable: true })
854
+ sourceSubscriptionItemId?: string | null
855
+
856
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
857
+ createdAt: Date = new Date()
858
+
859
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
860
+ updatedAt: Date = new Date()
861
+
862
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
863
+ deletedAt?: Date | null
864
+ }
865
+
866
+ // ─── CpqInventorySubscription ───────────────────────────────────
867
+
868
+ @Entity({ tableName: 'cpq_inventory_subscriptions' })
869
+ @Index({ name: 'cpq_inventory_subscriptions_scope_idx', properties: ['organizationId', 'tenantId'] })
870
+ @Unique({ name: 'cpq_inventory_subscriptions_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
871
+ @Index({ name: 'cpq_inventory_subscriptions_customer_idx', properties: ['organizationId', 'tenantId', 'customerId'] })
872
+ @Index({ name: 'cpq_inventory_subscriptions_status_idx', properties: ['organizationId', 'tenantId', 'status'] })
873
+ @Index({ name: 'cpq_inventory_subscriptions_source_quote_idx', properties: ['organizationId', 'tenantId', 'sourceQuoteId'] })
874
+ @Index({ name: 'cpq_inventory_subscriptions_term_end_idx', properties: ['organizationId', 'tenantId', 'currentTermEnd'] })
875
+ @Index({ name: 'cpq_inventory_subscriptions_merged_into_idx', properties: ['organizationId', 'tenantId', 'mergedIntoSubscriptionId'] })
876
+ export class CpqInventorySubscription {
877
+ [OptionalProps]?:
878
+ | 'status'
879
+ | 'billingCycle'
880
+ | 'currencyCode'
881
+ | 'mrcAmount'
882
+ | 'nrcAmount'
883
+ | 'autoRenew'
884
+ | 'version'
885
+ | 'createdAt'
886
+ | 'updatedAt'
887
+ | 'deletedAt'
888
+
889
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
890
+ id!: string
891
+
892
+ @Property({ name: 'organization_id', type: 'uuid' })
893
+ organizationId!: string
894
+
895
+ @Property({ name: 'tenant_id', type: 'uuid' })
896
+ tenantId!: string
897
+
898
+ @Property({ name: 'customer_id', type: 'uuid' })
899
+ customerId!: string
900
+
901
+ @Property({ type: 'text' })
902
+ code!: string
903
+
904
+ @Property({ type: 'text' })
905
+ name!: string
906
+
907
+ @Property({ type: 'text', nullable: true })
908
+ description?: string | null
909
+
910
+ @Property({ type: 'text', default: 'pending' })
911
+ status: string = 'pending'
912
+
913
+ @Property({ name: 'billing_cycle', type: 'text', default: 'monthly' })
914
+ billingCycle: string = 'monthly'
915
+
916
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
917
+ currencyCode: string = 'USD'
918
+
919
+ @Property({ name: 'mrc_amount', columnType: 'numeric(18, 4)', default: 0 })
920
+ mrcAmount: string = '0'
921
+
922
+ @Property({ name: 'nrc_amount', columnType: 'numeric(18, 4)', default: 0 })
923
+ nrcAmount: string = '0'
924
+
925
+ @Property({ name: 'start_date', type: 'date', nullable: true })
926
+ startDate?: Date | null
927
+
928
+ @Property({ name: 'current_term_start', type: 'date', nullable: true })
929
+ currentTermStart?: Date | null
930
+
931
+ @Property({ name: 'current_term_end', type: 'date', nullable: true })
932
+ currentTermEnd?: Date | null
933
+
934
+ @Property({ name: 'term_months', type: 'integer', nullable: true })
935
+ termMonths?: number | null
936
+
937
+ @Property({ name: 'auto_renew', type: 'boolean', default: true })
938
+ autoRenew: boolean = true
939
+
940
+ @Property({ name: 'activated_at', type: Date, nullable: true })
941
+ activatedAt?: Date | null
942
+
943
+ @Property({ name: 'suspended_at', type: Date, nullable: true })
944
+ suspendedAt?: Date | null
945
+
946
+ @Property({ name: 'terminated_at', type: Date, nullable: true })
947
+ terminatedAt?: Date | null
948
+
949
+ @Property({ name: 'pricing_summary', type: 'jsonb', nullable: true })
950
+ pricingSummary?: Record<string, unknown> | null
951
+
952
+ @Property({ name: 'source_quote_id', type: 'uuid', nullable: true })
953
+ sourceQuoteId?: string | null
954
+
955
+ @Property({ name: 'source_order_id', type: 'uuid', nullable: true })
956
+ sourceOrderId?: string | null
957
+
958
+ // ── ARC (Amend / Renew / Cancel) — XD-250 ───────────────────────
959
+ // Set when this row is a merge source (terminal status='superseded').
960
+ // Points at the new merge sub M that absorbed this one.
961
+ @Property({ name: 'merged_into_subscription_id', type: 'uuid', nullable: true })
962
+ mergedIntoSubscriptionId?: string | null
963
+
964
+ // Convenience pointer to most recent CpqSubscriptionChangeLog for fast UI.
965
+ @Property({ name: 'last_change_log_id', type: 'uuid', nullable: true })
966
+ lastChangeLogId?: string | null
967
+
968
+ // MikroORM optimistic lock — auto-increments on every UPDATE.
969
+ @Property({ type: 'integer', version: true })
970
+ version: number = 1
971
+
972
+ @Property({ type: 'jsonb', nullable: true })
973
+ metadata?: Record<string, unknown> | null
974
+
975
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
976
+ createdAt: Date = new Date()
977
+
978
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
979
+ updatedAt: Date = new Date()
980
+
981
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
982
+ deletedAt?: Date | null
983
+ }
984
+
985
+ // ─── CpqInventorySubscriptionItem ───────────────────────────────
986
+
987
+ @Entity({ tableName: 'cpq_inventory_subscription_items' })
988
+ @Index({ name: 'cpq_inventory_subscription_items_scope_idx', properties: ['organizationId', 'tenantId', 'subscriptionId'] })
989
+ @Index({ name: 'cpq_inventory_subscription_items_customer_idx', properties: ['organizationId', 'tenantId', 'customerId'] })
990
+ @Index({ name: 'cpq_inventory_subscription_items_parent_idx', properties: ['organizationId', 'tenantId', 'parentItemId'] })
991
+ @Index({ name: 'cpq_inventory_subscription_items_status_idx', properties: ['organizationId', 'tenantId', 'status'] })
992
+ export class CpqInventorySubscriptionItem {
993
+ [OptionalProps]?: 'status' | 'configuration' | 'mrcAmount' | 'nrcAmount' | 'currencyCode' | 'quantity' | 'sortOrder' | 'createdAt' | 'updatedAt' | 'deletedAt'
994
+
995
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
996
+ id!: string
997
+
998
+ @Property({ name: 'organization_id', type: 'uuid' })
999
+ organizationId!: string
1000
+
1001
+ @Property({ name: 'tenant_id', type: 'uuid' })
1002
+ tenantId!: string
1003
+
1004
+ @Property({ name: 'subscription_id', type: 'uuid' })
1005
+ subscriptionId!: string
1006
+
1007
+ @Property({ name: 'customer_id', type: 'uuid' })
1008
+ customerId!: string
1009
+
1010
+ @Property({ name: 'parent_item_id', type: 'uuid', nullable: true })
1011
+ parentItemId?: string | null
1012
+
1013
+ @Property({ name: 'product_id', type: 'uuid', nullable: true })
1014
+ productId?: string | null
1015
+
1016
+ @Property({ name: 'offering_id', type: 'uuid', nullable: true })
1017
+ offeringId?: string | null
1018
+
1019
+ @Property({ name: 'spec_id', type: 'uuid', nullable: true })
1020
+ specId?: string | null
1021
+
1022
+ @Property({ type: 'text' })
1023
+ name!: string
1024
+
1025
+ @Property({ type: 'text', default: 'pending' })
1026
+ status: string = 'pending'
1027
+
1028
+ @Property({ type: 'jsonb', default: '{}' })
1029
+ configuration: Record<string, unknown> = {}
1030
+
1031
+ @Property({ type: 'jsonb', nullable: true })
1032
+ charges?: Array<Record<string, unknown>> | null
1033
+
1034
+ @Property({ name: 'mrc_amount', columnType: 'numeric(18, 4)', default: 0 })
1035
+ mrcAmount: string = '0'
1036
+
1037
+ @Property({ name: 'nrc_amount', columnType: 'numeric(18, 4)', default: 0 })
1038
+ nrcAmount: string = '0'
1039
+
1040
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
1041
+ currencyCode: string = 'USD'
1042
+
1043
+ @Property({ type: 'integer', default: 1 })
1044
+ quantity: number = 1
1045
+
1046
+ @Property({ name: 'capacity_total', type: 'numeric', columnType: 'numeric(18, 4)', nullable: true })
1047
+ capacityTotal?: string | null
1048
+
1049
+ @Property({ name: 'capacity_used', type: 'numeric', columnType: 'numeric(18, 4)', nullable: true })
1050
+ capacityUsed?: string | null
1051
+
1052
+ @Property({ name: 'capacity_unit', type: 'text', nullable: true })
1053
+ capacityUnit?: string | null
1054
+
1055
+ @Property({ name: 'source_quote_line_id', type: 'uuid', nullable: true })
1056
+ sourceQuoteLineId?: string | null
1057
+
1058
+ @Property({ type: 'jsonb', nullable: true })
1059
+ metadata?: Record<string, unknown> | null
1060
+
1061
+ @Property({ name: 'sort_order', type: 'integer', default: 0 })
1062
+ sortOrder: number = 0
1063
+
1064
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1065
+ createdAt: Date = new Date()
1066
+
1067
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
1068
+ updatedAt: Date = new Date()
1069
+
1070
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1071
+ deletedAt?: Date | null
1072
+ }
1073
+
1074
+ // ─── CpqInventoryAsset ──────────────────────────────────────────
1075
+
1076
+ @Entity({ tableName: 'cpq_inventory_assets' })
1077
+ @Index({ name: 'cpq_inventory_assets_scope_idx', properties: ['organizationId', 'tenantId'] })
1078
+ @Unique({ name: 'cpq_inventory_assets_code_unique', properties: ['organizationId', 'tenantId', 'code'] })
1079
+ @Index({ name: 'cpq_inventory_assets_customer_idx', properties: ['organizationId', 'tenantId', 'customerId'] })
1080
+ @Index({ name: 'cpq_inventory_assets_status_idx', properties: ['organizationId', 'tenantId', 'status'] })
1081
+ @Index({ name: 'cpq_inventory_assets_subscription_idx', properties: ['organizationId', 'tenantId', 'subscriptionId'] })
1082
+ @Index({ name: 'cpq_inventory_assets_item_idx', properties: ['organizationId', 'tenantId', 'subscriptionItemId'] })
1083
+ export class CpqInventoryAsset {
1084
+ [OptionalProps]?: 'status' | 'assetType' | 'currencyCode' | 'purchasePrice' | 'quantity' | 'configuration' | 'createdAt' | 'updatedAt' | 'deletedAt'
1085
+
1086
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
1087
+ id!: string
1088
+
1089
+ @Property({ name: 'organization_id', type: 'uuid' })
1090
+ organizationId!: string
1091
+
1092
+ @Property({ name: 'tenant_id', type: 'uuid' })
1093
+ tenantId!: string
1094
+
1095
+ @Property({ name: 'customer_id', type: 'uuid' })
1096
+ customerId!: string
1097
+
1098
+ @Property({ name: 'subscription_id', type: 'uuid', nullable: true })
1099
+ subscriptionId?: string | null
1100
+
1101
+ @Property({ name: 'subscription_item_id', type: 'uuid', nullable: true })
1102
+ subscriptionItemId?: string | null
1103
+
1104
+ @Property({ name: 'product_id', type: 'uuid', nullable: true })
1105
+ productId?: string | null
1106
+
1107
+ @Property({ name: 'offering_id', type: 'uuid', nullable: true })
1108
+ offeringId?: string | null
1109
+
1110
+ @Property({ name: 'spec_id', type: 'uuid', nullable: true })
1111
+ specId?: string | null
1112
+
1113
+ @Property({ type: 'text' })
1114
+ code!: string
1115
+
1116
+ @Property({ type: 'text' })
1117
+ name!: string
1118
+
1119
+ @Property({ type: 'text', nullable: true })
1120
+ description?: string | null
1121
+
1122
+ @Property({ type: 'text', default: 'pending' })
1123
+ status: string = 'pending'
1124
+
1125
+ @Property({ name: 'asset_type', type: 'text', default: 'one_time' })
1126
+ assetType: string = 'one_time'
1127
+
1128
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
1129
+ currencyCode: string = 'USD'
1130
+
1131
+ @Property({ name: 'purchase_price', columnType: 'numeric(18, 4)', default: 0 })
1132
+ purchasePrice: string = '0'
1133
+
1134
+ @Property({ type: 'integer', default: 1 })
1135
+ quantity: number = 1
1136
+
1137
+ @Property({ name: 'purchase_date', type: 'date', nullable: true })
1138
+ purchaseDate?: Date | null
1139
+
1140
+ @Property({ name: 'delivery_date', type: 'date', nullable: true })
1141
+ deliveryDate?: Date | null
1142
+
1143
+ @Property({ type: 'jsonb', default: '{}' })
1144
+ configuration: Record<string, unknown> = {}
1145
+
1146
+ @Property({ type: 'jsonb', nullable: true })
1147
+ charges?: Array<Record<string, unknown>> | null
1148
+
1149
+ @Property({ name: 'source_quote_id', type: 'uuid', nullable: true })
1150
+ sourceQuoteId?: string | null
1151
+
1152
+ @Property({ name: 'source_order_id', type: 'uuid', nullable: true })
1153
+ sourceOrderId?: string | null
1154
+
1155
+ @Property({ name: 'source_quote_line_id', type: 'uuid', nullable: true })
1156
+ sourceQuoteLineId?: string | null
1157
+
1158
+ @Property({ type: 'jsonb', nullable: true })
1159
+ metadata?: Record<string, unknown> | null
1160
+
1161
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1162
+ createdAt: Date = new Date()
1163
+
1164
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
1165
+ updatedAt: Date = new Date()
1166
+
1167
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1168
+ deletedAt?: Date | null
1169
+ }
1170
+
1171
+ // ─── CpqOrderConfiguration ──────────────────────────────────────
1172
+
1173
+ @Entity({ tableName: 'cpq_order_configurations' })
1174
+ @Unique({ name: 'cpq_order_configurations_order_unique', properties: ['organizationId', 'tenantId', 'orderId'] })
1175
+ @Index({ name: 'cpq_order_configurations_scope_idx', properties: ['organizationId', 'tenantId'] })
1176
+ @Index({ name: 'cpq_order_configurations_customer_idx', properties: ['organizationId', 'tenantId', 'customerId'] })
1177
+ @Index({ name: 'cpq_order_configurations_source_quote_idx', properties: ['organizationId', 'tenantId', 'sourceQuoteId'] })
1178
+ @Index({ name: 'cpq_order_configurations_status_idx', properties: ['organizationId', 'tenantId', 'cpqStatus'] })
1179
+ export class CpqOrderConfiguration {
1180
+ [OptionalProps]?: 'cpqStatus' | 'currencyCode' | 'createdAt' | 'updatedAt' | 'deletedAt'
1181
+
1182
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
1183
+ id!: string
1184
+
1185
+ @Property({ name: 'organization_id', type: 'uuid' })
1186
+ organizationId!: string
1187
+
1188
+ @Property({ name: 'tenant_id', type: 'uuid' })
1189
+ tenantId!: string
1190
+
1191
+ @Property({ name: 'order_id', type: 'uuid' })
1192
+ orderId!: string
1193
+
1194
+ @Property({ name: 'source_quote_id', type: 'uuid', nullable: true })
1195
+ sourceQuoteId?: string | null
1196
+
1197
+ @Property({ name: 'customer_id', type: 'uuid' })
1198
+ customerId!: string
1199
+
1200
+ @Property({ name: 'cpq_status', type: 'text', default: 'draft' })
1201
+ cpqStatus: string = 'draft'
1202
+
1203
+ @Property({ name: 'currency_code', type: 'text', default: 'USD' })
1204
+ currencyCode: string = 'USD'
1205
+
1206
+ @Property({ name: 'pricing_summary', type: 'jsonb', nullable: true })
1207
+ pricingSummary?: Record<string, unknown> | null
1208
+
1209
+ @Property({ type: 'jsonb', nullable: true })
1210
+ metadata?: Record<string, unknown> | null
1211
+
1212
+ @Property({ name: 'activated_at', type: Date, nullable: true })
1213
+ activatedAt?: Date | null
1214
+
1215
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1216
+ createdAt: Date = new Date()
1217
+
1218
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
1219
+ updatedAt: Date = new Date()
1220
+
1221
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1222
+ deletedAt?: Date | null
1223
+ }
1224
+
1225
+ // ─── CpqOrderLineConfiguration ──────────────────────────────────
1226
+
1227
+ @Entity({ tableName: 'cpq_order_line_configurations' })
1228
+ @Unique({ name: 'cpq_olc_order_line_unique', properties: ['organizationId', 'tenantId', 'orderLineId'] })
1229
+ @Index({ name: 'cpq_olc_order_config_idx', properties: ['organizationId', 'tenantId', 'orderConfigurationId'] })
1230
+ @Index({ name: 'cpq_olc_parent_line_idx', properties: ['organizationId', 'tenantId', 'parentLineId'] })
1231
+ export class CpqOrderLineConfiguration {
1232
+ [OptionalProps]?: 'action' | 'configuration' | 'quantity' | 'nrcTotal' | 'mrcTotal' | 'createdAt' | 'updatedAt' | 'deletedAt'
1233
+
1234
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
1235
+ id!: string
1236
+
1237
+ @Property({ name: 'organization_id', type: 'uuid' })
1238
+ organizationId!: string
1239
+
1240
+ @Property({ name: 'tenant_id', type: 'uuid' })
1241
+ tenantId!: string
1242
+
1243
+ @Property({ name: 'order_line_id', type: 'uuid' })
1244
+ orderLineId!: string
1245
+
1246
+ @Property({ name: 'order_configuration_id', type: 'uuid' })
1247
+ orderConfigurationId!: string
1248
+
1249
+ @Property({ name: 'offering_id', type: 'uuid', nullable: true })
1250
+ offeringId?: string | null
1251
+
1252
+ @Property({ name: 'product_id', type: 'uuid', nullable: true })
1253
+ productId?: string | null
1254
+
1255
+ @Property({ name: 'spec_id', type: 'uuid', nullable: true })
1256
+ specId?: string | null
1257
+
1258
+ @Property({ type: 'text', default: 'add' })
1259
+ action: string = 'add'
1260
+
1261
+ @Property({ name: 'parent_line_id', type: 'uuid', nullable: true })
1262
+ parentLineId?: string | null
1263
+
1264
+ @Property({ name: 'start_date', type: 'date', nullable: true })
1265
+ startDate?: Date | null
1266
+
1267
+ @Property({ name: 'term_months', type: 'integer', nullable: true })
1268
+ termMonths?: number | null
1269
+
1270
+ @Property({ name: 'end_date', type: 'date', nullable: true })
1271
+ endDate?: Date | null
1272
+
1273
+ @Property({ type: 'jsonb', default: '{}' })
1274
+ configuration: Record<string, unknown> = {}
1275
+
1276
+ @Property({ type: 'integer', default: 1 })
1277
+ quantity: number = 1
1278
+
1279
+ @Property({ type: 'jsonb', nullable: true })
1280
+ charges?: Array<Record<string, unknown>> | null
1281
+
1282
+ @Property({ name: 'nrc_total', columnType: 'numeric(18, 4)', default: 0 })
1283
+ nrcTotal: string = '0'
1284
+
1285
+ @Property({ name: 'mrc_total', columnType: 'numeric(18, 4)', default: 0 })
1286
+ mrcTotal: string = '0'
1287
+
1288
+ @Property({ name: 'source_quote_line_id', type: 'uuid', nullable: true })
1289
+ sourceQuoteLineId?: string | null
1290
+
1291
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1292
+ createdAt: Date = new Date()
1293
+
1294
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
1295
+ updatedAt: Date = new Date()
1296
+
1297
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1298
+ deletedAt?: Date | null
1299
+ }
1300
+
1301
+ // ─── CpqQuoteTargetSubscription (XD-250 ARC) ────────────────────
1302
+ //
1303
+ // Junction between an ARC quote and the subscription(s) it targets.
1304
+ // One row per (quote, subscription) pair.
1305
+
1306
+ @Entity({ tableName: 'cpq_quote_target_subscriptions' })
1307
+ @Unique({
1308
+ name: 'cpq_qts_quote_sub_unique',
1309
+ properties: ['organizationId', 'tenantId', 'quoteId', 'subscriptionId'],
1310
+ })
1311
+ @Index({ name: 'cpq_qts_quote_idx', properties: ['organizationId', 'tenantId', 'quoteId'] })
1312
+ @Index({
1313
+ name: 'cpq_qts_sub_type_idx',
1314
+ properties: ['organizationId', 'tenantId', 'subscriptionId', 'quoteType'],
1315
+ })
1316
+ export class CpqQuoteTargetSubscription {
1317
+ [OptionalProps]?: 'createdAt' | 'updatedAt' | 'deletedAt'
1318
+
1319
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
1320
+ id!: string
1321
+
1322
+ @Property({ name: 'organization_id', type: 'uuid' })
1323
+ organizationId!: string
1324
+
1325
+ @Property({ name: 'tenant_id', type: 'uuid' })
1326
+ tenantId!: string
1327
+
1328
+ // FK to CpqQuoteConfiguration.id (intra-module — could be ORM relation,
1329
+ // kept as string id for consistency with the rest of the CPQ schema).
1330
+ @Property({ name: 'quote_id', type: 'uuid' })
1331
+ quoteId!: string
1332
+
1333
+ // FK to CpqInventorySubscription.id (intra-module).
1334
+ @Property({ name: 'subscription_id', type: 'uuid' })
1335
+ subscriptionId!: string
1336
+
1337
+ // MUST mirror parent CpqQuoteConfiguration.quoteType ∈ {amend, renew, cancel}.
1338
+ @Property({ name: 'quote_type', type: 'text' })
1339
+ quoteType!: string
1340
+
1341
+ // Renew-only: standalone (single target, in-place mutation) or absorb
1342
+ // (merge source — items migrate to a new sub at activation). Null for
1343
+ // amend / cancel.
1344
+ @Property({ name: 'merge_action', type: 'text', nullable: true })
1345
+ mergeAction?: string | null
1346
+
1347
+ // Renew-only, populated only when merge_action='standalone'.
1348
+ @Property({ name: 'new_term_start', type: 'date', nullable: true })
1349
+ newTermStart?: Date | null
1350
+
1351
+ @Property({ name: 'new_term_end', type: 'date', nullable: true })
1352
+ newTermEnd?: Date | null
1353
+
1354
+ @Property({ name: 'new_term_months', type: 'integer', nullable: true })
1355
+ newTermMonths?: number | null
1356
+
1357
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1358
+ createdAt: Date = new Date()
1359
+
1360
+ @Property({ name: 'updated_at', type: Date, onUpdate: () => new Date() })
1361
+ updatedAt: Date = new Date()
1362
+
1363
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1364
+ deletedAt?: Date | null
1365
+ }
1366
+
1367
+ // ─── CpqSubscriptionChangeLog (XD-250 ARC) ──────────────────────
1368
+ //
1369
+ // Append-only audit record. One row per ARC operation per affected
1370
+ // subscription. Drives the "Change History" UI tab and downstream
1371
+ // billing / notification consumers.
1372
+
1373
+ @Entity({ tableName: 'cpq_subscription_change_logs' })
1374
+ @Index({
1375
+ name: 'cpq_scl_sub_history_idx',
1376
+ properties: ['organizationId', 'tenantId', 'subscriptionId', 'createdAt'],
1377
+ })
1378
+ @Index({ name: 'cpq_scl_source_order_idx', properties: ['sourceOrderId'] })
1379
+ @Index({ name: 'cpq_scl_merged_into_idx', properties: ['mergedIntoSubscriptionId'] })
1380
+ // Idempotency: re-running activation for the same (order, sub) pair is a no-op.
1381
+ // PostgreSQL treats NULLs as distinct in UNIQUE indexes by default, so multiple
1382
+ // rows with NULL source_order_id can coexist for the same subscription
1383
+ // (hypothetical future non-order-driven entries — manual reconciliation, etc.).
1384
+ @Unique({
1385
+ name: 'cpq_scl_order_sub_unique',
1386
+ properties: ['sourceOrderId', 'subscriptionId'],
1387
+ })
1388
+ export class CpqSubscriptionChangeLog {
1389
+ [OptionalProps]?: 'createdAt' | 'deletedAt'
1390
+
1391
+ @PrimaryKey({ type: 'uuid', defaultRaw: 'gen_random_uuid()' })
1392
+ id!: string
1393
+
1394
+ @Property({ name: 'organization_id', type: 'uuid' })
1395
+ organizationId!: string
1396
+
1397
+ @Property({ name: 'tenant_id', type: 'uuid' })
1398
+ tenantId!: string
1399
+
1400
+ // FK to CpqInventorySubscription.id (intra-module).
1401
+ @Property({ name: 'subscription_id', type: 'uuid' })
1402
+ subscriptionId!: string
1403
+
1404
+ // 'amend' | 'renew' | 'cancel' | 'merge-result' | 'merge-source'.
1405
+ // Validated in service layer (see CHANGE_LOG_TYPES in services/types.ts).
1406
+ @Property({ name: 'change_type', type: 'text' })
1407
+ changeType!: string
1408
+
1409
+ @Property({ name: 'source_quote_id', type: 'uuid', nullable: true })
1410
+ sourceQuoteId?: string | null
1411
+
1412
+ @Property({ name: 'source_order_id', type: 'uuid', nullable: true })
1413
+ sourceOrderId?: string | null
1414
+
1415
+ @Property({ name: 'performed_by_user_id', type: 'uuid', nullable: true })
1416
+ performedByUserId?: string | null
1417
+
1418
+ @Property({ name: 'effective_at', type: Date })
1419
+ effectiveAt: Date = new Date()
1420
+
1421
+ // Full state snapshot (subscription + items + assets) before mutation.
1422
+ // Null on change_type='merge-result' (M is brand new — no "before").
1423
+ @Property({ name: 'before_snapshot', type: 'jsonb', nullable: true })
1424
+ beforeSnapshot?: Record<string, unknown> | null
1425
+
1426
+ // Full state snapshot after mutation. Null on change_type='merge-source'
1427
+ // (source's terminal state is the meaningful "after").
1428
+ @Property({ name: 'after_snapshot', type: 'jsonb', nullable: true })
1429
+ afterSnapshot?: Record<string, unknown> | null
1430
+
1431
+ // Summary array: [{ action, lineId, productCode, qty, mrcDelta, ... }]
1432
+ @Property({ name: 'line_changes', type: 'jsonb', nullable: true })
1433
+ lineChanges?: Array<Record<string, unknown>> | null
1434
+
1435
+ // { oldTermStart, newTermStart, oldTermEnd, newTermEnd, oldTermMonths, newTermMonths }
1436
+ // Populated for change_type='renew' (standalone) and 'merge-result'.
1437
+ @Property({ name: 'term_change', type: 'jsonb', nullable: true })
1438
+ termChange?: Record<string, unknown> | null
1439
+
1440
+ // Set on change_type='merge-source' rows; points at the new merge sub M.
1441
+ @Property({ name: 'merged_into_subscription_id', type: 'uuid', nullable: true })
1442
+ mergedIntoSubscriptionId?: string | null
1443
+
1444
+ // Set on change_type='merge-result' rows; array of source ids absorbed into M.
1445
+ @Property({ name: 'merged_from_subscription_ids', type: 'jsonb', nullable: true })
1446
+ mergedFromSubscriptionIds?: string[] | null
1447
+
1448
+ // Cancel-only.
1449
+ @Property({ name: 'reason_code', type: 'text', nullable: true })
1450
+ reasonCode?: string | null
1451
+
1452
+ @Property({ name: 'reason_text', type: 'text', nullable: true })
1453
+ reasonText?: string | null
1454
+
1455
+ @Property({ name: 'etf_amount', type: 'numeric', columnType: 'numeric(18, 4)', nullable: true })
1456
+ etfAmount?: string | null
1457
+
1458
+ @Property({ name: 'etf_currency', type: 'text', nullable: true })
1459
+ etfCurrency?: string | null
1460
+
1461
+ @Property({ name: 'created_at', type: Date, onCreate: () => new Date() })
1462
+ createdAt: Date = new Date()
1463
+
1464
+ // Soft-delete reserved for compliance erasure; runtime ignores deleted rows.
1465
+ @Property({ name: 'deleted_at', type: Date, nullable: true })
1466
+ deletedAt?: Date | null
1467
+ }