@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,327 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState, useEffect, useCallback } from "react";
4
+ import { NumberInput } from "../../components/NumberInput.js";
5
+ function ConfigPanel({
6
+ offering,
7
+ configuration,
8
+ onChange,
9
+ onRemove
10
+ }) {
11
+ const [attributes, setAttributes] = useState([]);
12
+ const [loading, setLoading] = useState(true);
13
+ const [configVersion, setConfigVersion] = useState(0);
14
+ useEffect(() => {
15
+ let cancelled = false;
16
+ async function load() {
17
+ setLoading(true);
18
+ try {
19
+ const params = new URLSearchParams({ offeringId: offering.id });
20
+ if (Object.keys(configuration).length > 0) {
21
+ params.set("configuration", JSON.stringify(configuration));
22
+ }
23
+ const res = await fetch(`/api/cpq/quotes/attributes?${params}`);
24
+ if (res.ok && !cancelled) {
25
+ const data = await res.json();
26
+ const attrs = data.attributes ?? [];
27
+ setAttributes(attrs.filter((a) => !a.resolutionTime || a.resolutionTime === "run_time"));
28
+ }
29
+ } finally {
30
+ if (!cancelled) setLoading(false);
31
+ }
32
+ }
33
+ load();
34
+ return () => {
35
+ cancelled = true;
36
+ };
37
+ }, [offering.id, configVersion]);
38
+ const handleChange = useCallback((code, value) => {
39
+ onChange(code, value);
40
+ const hasDependents = attributes.some((a) => {
41
+ const dep = a.constraints;
42
+ const depOn = dep?.dependsOn;
43
+ const dynSrc = dep?.dynamicOptionsSource;
44
+ return depOn?.attributeCode === code || dynSrc?.filterByDimension && Object.values(dynSrc.filterByDimension).some((v) => v === `$${code}`);
45
+ });
46
+ if (hasDependents) setConfigVersion((v) => v + 1);
47
+ }, [onChange, attributes]);
48
+ const renderAttribute = (attr) => {
49
+ const value = configuration[attr.code] ?? "";
50
+ if (attr.attributeType === "select" || attr.attributeType === "enum") {
51
+ return /* @__PURE__ */ jsxs("select", { value: String(value), onChange: (e) => handleChange(attr.code, e.target.value), className: "w-full rounded-md border px-3 py-2 text-sm", children: [
52
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
53
+ attr.options?.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
54
+ ] });
55
+ }
56
+ if (attr.attributeType === "boolean") {
57
+ return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
58
+ /* @__PURE__ */ jsx("input", { type: "checkbox", checked: Boolean(value), onChange: (e) => handleChange(attr.code, e.target.checked), className: "rounded border" }),
59
+ attr.name
60
+ ] });
61
+ }
62
+ if (attr.attributeType === "number") {
63
+ return /* @__PURE__ */ jsx(
64
+ NumberInput,
65
+ {
66
+ value: value === "" || value == null ? null : Number(value),
67
+ onChange: (n) => handleChange(attr.code, n ?? "")
68
+ }
69
+ );
70
+ }
71
+ return /* @__PURE__ */ jsx("input", { type: "text", value: String(value), onChange: (e) => handleChange(attr.code, e.target.value), className: "w-full rounded-md border px-3 py-2 text-sm" });
72
+ };
73
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [
74
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b pb-2", children: [
75
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: offering.name }),
76
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onRemove, className: "text-xs text-muted-foreground hover:text-foreground", children: "Remove" })
77
+ ] }),
78
+ loading ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading attributes..." }) : attributes.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "No configurable attributes." }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: attributes.map((attr) => /* @__PURE__ */ jsxs("div", { children: [
79
+ /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
80
+ attr.name,
81
+ attr.isRequired && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-0.5", children: "*" })
82
+ ] }),
83
+ renderAttribute(attr),
84
+ attr.helpText && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: attr.helpText })
85
+ ] }, attr.code)) })
86
+ ] });
87
+ }
88
+ function BandwidthIndicator({
89
+ portCapacityMb,
90
+ items
91
+ }) {
92
+ const totalBandwidth = items.reduce((sum, item) => {
93
+ const bw = Number(item.configuration.bandwidth_mb) || 0;
94
+ return sum + bw;
95
+ }, 0);
96
+ const pct = portCapacityMb > 0 ? Math.min(100, totalBandwidth / portCapacityMb * 100) : 0;
97
+ const overCapacity = totalBandwidth > portCapacityMb;
98
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-3 space-y-2", children: [
99
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-xs", children: [
100
+ /* @__PURE__ */ jsx("span", { className: "font-medium", children: "Bandwidth Utilization" }),
101
+ /* @__PURE__ */ jsxs("span", { className: overCapacity ? "text-destructive font-medium" : "text-muted-foreground", children: [
102
+ totalBandwidth,
103
+ " / ",
104
+ portCapacityMb,
105
+ " MB"
106
+ ] })
107
+ ] }),
108
+ /* @__PURE__ */ jsx("div", { className: "h-2 rounded-full bg-muted overflow-hidden", children: /* @__PURE__ */ jsx(
109
+ "div",
110
+ {
111
+ className: `h-full rounded-full transition-all ${overCapacity ? "bg-destructive" : "bg-primary"}`,
112
+ style: { width: `${Math.min(100, pct)}%` }
113
+ }
114
+ ) }),
115
+ overCapacity && /* @__PURE__ */ jsxs("p", { className: "text-xs text-destructive", children: [
116
+ "Total bandwidth exceeds port capacity by ",
117
+ totalBandwidth - portCapacityMb,
118
+ " MB"
119
+ ] })
120
+ ] });
121
+ }
122
+ const PORT_SIZE_MB = { "1G": 1e3, "10G": 1e4, "100G": 1e5 };
123
+ function OfferingSelectStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }) {
124
+ const [offerings, setOfferings] = useState([]);
125
+ const [selectedItems, setSelectedItems] = useState([]);
126
+ const [loading, setLoading] = useState(true);
127
+ const [saving, setSaving] = useState(false);
128
+ const enableConfiguration = config.enableConfiguration === true;
129
+ const multiSelect = config.multiSelect !== false;
130
+ const offeringFilter = config.offeringFilter;
131
+ const displayMode = config.displayMode ?? "grid";
132
+ const portCapacityMb = (() => {
133
+ for (const data of Object.values(stepData)) {
134
+ const cfg = data.configuration;
135
+ if (cfg?.port_size) return PORT_SIZE_MB[String(cfg.port_size)] ?? 0;
136
+ }
137
+ return 0;
138
+ })();
139
+ const previousData = stepData[currentStepId];
140
+ useEffect(() => {
141
+ async function load() {
142
+ setLoading(true);
143
+ try {
144
+ const params = new URLSearchParams({ page: "1", pageSize: "100" });
145
+ const res = await fetch(`/api/cpq/product-offerings?${params}`);
146
+ if (res.ok) {
147
+ const data = await res.json();
148
+ let items = data.items ?? [];
149
+ if (offeringFilter?.offeringCodes?.length) {
150
+ const codeOrder = offeringFilter.offeringCodes;
151
+ items = items.filter((o) => codeOrder.includes(o.code)).sort((a, b) => codeOrder.indexOf(a.code) - codeOrder.indexOf(b.code));
152
+ }
153
+ items = items.filter((o) => o.isActive);
154
+ setOfferings(items);
155
+ if (previousData?.items?.length) {
156
+ const restored = previousData.items.map((prev) => {
157
+ const o = items.find((i) => i.id === prev.offering.id);
158
+ return o ? { offering: o, configuration: prev.configuration, lineId: prev.lineId } : null;
159
+ }).filter(Boolean);
160
+ setSelectedItems(restored);
161
+ }
162
+ }
163
+ } finally {
164
+ setLoading(false);
165
+ }
166
+ }
167
+ load();
168
+ }, []);
169
+ const addItem = useCallback((offering) => {
170
+ setSelectedItems((prev) => {
171
+ if (!multiSelect) return [{ offering, configuration: {} }];
172
+ return [...prev, { offering, configuration: {} }];
173
+ });
174
+ }, [multiSelect]);
175
+ const removeItem = useCallback((index) => {
176
+ setSelectedItems((prev) => prev.filter((_, i) => i !== index));
177
+ }, []);
178
+ const updateItemConfig = useCallback((index, code, value) => {
179
+ setSelectedItems((prev) => prev.map(
180
+ (item, i) => i === index ? { ...item, configuration: { ...item.configuration, [code]: value } } : item
181
+ ));
182
+ }, []);
183
+ const resolvedCustomerId = customerId ?? (() => {
184
+ for (const data of Object.values(stepData)) {
185
+ if (data.customerId) return data.customerId;
186
+ }
187
+ return null;
188
+ })();
189
+ const handleNext = useCallback(async () => {
190
+ if (selectedItems.length === 0) return;
191
+ setSaving(true);
192
+ try {
193
+ let activeQuoteId = quoteId;
194
+ const output = { items: selectedItems };
195
+ if (enableConfiguration) {
196
+ if (!activeQuoteId && resolvedCustomerId) {
197
+ const createRes = await fetch("/api/cpq/quotes", {
198
+ method: "POST",
199
+ headers: { "Content-Type": "application/json" },
200
+ body: JSON.stringify({ customerId: resolvedCustomerId })
201
+ });
202
+ if (createRes.ok) {
203
+ const quoteData = await createRes.json();
204
+ activeQuoteId = quoteData.id;
205
+ output.quoteId = activeQuoteId;
206
+ }
207
+ }
208
+ if (activeQuoteId) {
209
+ for (const item of selectedItems) {
210
+ if (item.lineId) {
211
+ await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${item.lineId}`, {
212
+ method: "PUT",
213
+ headers: { "Content-Type": "application/json" },
214
+ body: JSON.stringify({ configuration: item.configuration })
215
+ });
216
+ } else {
217
+ const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {
218
+ method: "POST",
219
+ headers: { "Content-Type": "application/json" },
220
+ body: JSON.stringify({ offeringId: item.offering.id, configuration: item.configuration })
221
+ });
222
+ if (res.ok) {
223
+ const data = await res.json();
224
+ const line = data.lines?.find((l) => l.offeringId === item.offering.id);
225
+ item.lineId = line?.lineId;
226
+ }
227
+ }
228
+ }
229
+ output.quoteId = activeQuoteId;
230
+ }
231
+ }
232
+ if (selectedItems.length === 1) {
233
+ const first = selectedItems[0];
234
+ output.offeringId = first.offering.id;
235
+ output.offeringCode = first.offering.code;
236
+ output.offeringName = first.offering.name;
237
+ output.specId = first.offering.specId;
238
+ if (enableConfiguration) output.configuration = first.configuration;
239
+ }
240
+ onComplete(output);
241
+ } finally {
242
+ setSaving(false);
243
+ }
244
+ }, [selectedItems, enableConfiguration, quoteId, resolvedCustomerId, onComplete]);
245
+ if (loading) {
246
+ return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading offerings..." });
247
+ }
248
+ const availableOfferings = offerings.filter(
249
+ (o) => multiSelect ? true : !selectedItems.some((s) => s.offering.id === o.id)
250
+ );
251
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
252
+ /* @__PURE__ */ jsxs(
253
+ "div",
254
+ {
255
+ className: displayMode === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-3" : "flex flex-col gap-2",
256
+ children: [
257
+ availableOfferings.map((o) => {
258
+ const isAdded = selectedItems.some((s) => s.offering.id === o.id);
259
+ return /* @__PURE__ */ jsxs(
260
+ "div",
261
+ {
262
+ onClick: () => !isAdded && addItem(o),
263
+ className: `rounded-lg border-2 p-4 transition-colors ${isAdded ? "border-primary/30 bg-primary/5 opacity-60 cursor-default" : "border-muted cursor-pointer hover:bg-muted/30"}`,
264
+ children: [
265
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
266
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: o.name }),
267
+ isAdded && /* @__PURE__ */ jsx("span", { className: "text-xs text-primary font-medium", children: "Added" })
268
+ ] }),
269
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: o.description || o.code }),
270
+ !isAdded && /* @__PURE__ */ jsx("span", { className: "text-xs text-primary mt-2 inline-block", children: "+ Add" })
271
+ ]
272
+ },
273
+ o.id
274
+ );
275
+ }),
276
+ offerings.length === 0 && /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No offerings available." })
277
+ ]
278
+ }
279
+ ),
280
+ portCapacityMb > 0 && selectedItems.length > 0 && /* @__PURE__ */ jsx(BandwidthIndicator, { portCapacityMb, items: selectedItems }),
281
+ enableConfiguration && selectedItems.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
282
+ /* @__PURE__ */ jsxs("h4", { className: "text-sm font-medium", children: [
283
+ "Selected Services (",
284
+ selectedItems.length,
285
+ ")"
286
+ ] }),
287
+ selectedItems.map((item, index) => /* @__PURE__ */ jsx(
288
+ ConfigPanel,
289
+ {
290
+ offering: item.offering,
291
+ configuration: item.configuration,
292
+ onChange: (code, value) => updateItemConfig(index, code, value),
293
+ onRemove: () => removeItem(index)
294
+ },
295
+ `${item.offering.id}-${index}`
296
+ ))
297
+ ] }),
298
+ !enableConfiguration && selectedItems.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
299
+ /* @__PURE__ */ jsxs("h4", { className: "text-sm font-medium", children: [
300
+ "Selected (",
301
+ selectedItems.length,
302
+ ")"
303
+ ] }),
304
+ selectedItems.map((item, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-md border p-3", children: [
305
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: item.offering.name }),
306
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: () => removeItem(index), className: "text-xs text-muted-foreground hover:text-foreground", children: "Remove" })
307
+ ] }, `${item.offering.id}-${index}`))
308
+ ] }),
309
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-end pt-2", children: [
310
+ completedSteps.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: onBack, className: "inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted", children: "Back" }),
311
+ /* @__PURE__ */ jsx(
312
+ "button",
313
+ {
314
+ type: "button",
315
+ onClick: handleNext,
316
+ disabled: selectedItems.length === 0 || saving,
317
+ className: "inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
318
+ children: saving ? "Saving..." : "Next"
319
+ }
320
+ )
321
+ ] })
322
+ ] });
323
+ }
324
+ export {
325
+ OfferingSelectStep
326
+ };
327
+ //# sourceMappingURL=OfferingSelectStep.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/modules/cpq/workflows/steps/OfferingSelectStep.tsx"],
4
+ "sourcesContent": ["'use client'\n\nimport React, { useState, useEffect, useCallback } from 'react'\nimport type { WizardStepProps } from '../types'\nimport { NumberInput } from '../../components/NumberInput'\n\ntype Offering = {\n id: string\n code: string\n name: string\n description: string | null\n specId: string\n isActive: boolean\n}\n\ntype ConstrainedAttribute = {\n code: string\n name: string\n attributeType: string\n isRequired: boolean\n options: Array<{ value: string; label: string }> | null\n constraints: Record<string, unknown> | null\n defaultValue: unknown | null\n helpText: string | null\n}\n\ntype SelectedItem = {\n offering: Offering\n configuration: Record<string, unknown>\n lineId?: string\n}\n\n// \u2500\u2500\u2500 Inline configuration panel for a single offering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction ConfigPanel({\n offering,\n configuration,\n onChange,\n onRemove,\n}: {\n offering: Offering\n configuration: Record<string, unknown>\n onChange: (code: string, value: unknown) => void\n onRemove: () => void\n}) {\n const [attributes, setAttributes] = useState<ConstrainedAttribute[]>([])\n const [loading, setLoading] = useState(true)\n const [configVersion, setConfigVersion] = useState(0)\n\n useEffect(() => {\n let cancelled = false\n async function load() {\n setLoading(true)\n try {\n const params = new URLSearchParams({ offeringId: offering.id })\n if (Object.keys(configuration).length > 0) {\n params.set('configuration', JSON.stringify(configuration))\n }\n const res = await fetch(`/api/cpq/quotes/attributes?${params}`)\n if (res.ok && !cancelled) {\n const data = await res.json()\n const attrs = (data.attributes ?? []) as ConstrainedAttribute[]\n setAttributes(attrs.filter((a: ConstrainedAttribute & { resolutionTime?: string }) => !a.resolutionTime || a.resolutionTime === 'run_time'))\n }\n } finally {\n if (!cancelled) setLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [offering.id, configVersion]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleChange = useCallback((code: string, value: unknown) => {\n onChange(code, value)\n // Check for dependent attributes\n const hasDependents = attributes.some((a) => {\n const dep = a.constraints as Record<string, unknown> | null\n const depOn = dep?.dependsOn as { attributeCode?: string } | undefined\n const dynSrc = dep?.dynamicOptionsSource as { filterByDimension?: Record<string, string> } | undefined\n return depOn?.attributeCode === code ||\n (dynSrc?.filterByDimension && Object.values(dynSrc.filterByDimension).some((v) => v === `$${code}`))\n })\n if (hasDependents) setConfigVersion((v) => v + 1)\n }, [onChange, attributes])\n\n const renderAttribute = (attr: ConstrainedAttribute) => {\n const value = configuration[attr.code] ?? ''\n\n if (attr.attributeType === 'select' || attr.attributeType === 'enum') {\n return (\n <select value={String(value)} onChange={(e) => handleChange(attr.code, e.target.value)} className=\"w-full rounded-md border px-3 py-2 text-sm\">\n <option value=\"\">Select...</option>\n {attr.options?.map((opt) => <option key={opt.value} value={opt.value}>{opt.label}</option>)}\n </select>\n )\n }\n if (attr.attributeType === 'boolean') {\n return (\n <label className=\"flex items-center gap-2 text-sm\">\n <input type=\"checkbox\" checked={Boolean(value)} onChange={(e) => handleChange(attr.code, e.target.checked)} className=\"rounded border\" />\n {attr.name}\n </label>\n )\n }\n if (attr.attributeType === 'number') {\n return (\n <NumberInput\n value={value === '' || value == null ? null : Number(value)}\n onChange={(n) => handleChange(attr.code, n ?? '')}\n />\n )\n }\n return <input type=\"text\" value={String(value)} onChange={(e) => handleChange(attr.code, e.target.value)} className=\"w-full rounded-md border px-3 py-2 text-sm\" />\n }\n\n return (\n <div className=\"rounded-lg border p-4 space-y-3\">\n <div className=\"flex items-center justify-between border-b pb-2\">\n <h4 className=\"text-sm font-medium\">{offering.name}</h4>\n <button type=\"button\" onClick={onRemove} className=\"text-xs text-muted-foreground hover:text-foreground\">Remove</button>\n </div>\n {loading ? (\n <div className=\"text-sm text-muted-foreground\">Loading attributes...</div>\n ) : attributes.length === 0 ? (\n <div className=\"text-sm text-muted-foreground\">No configurable attributes.</div>\n ) : (\n <div className=\"space-y-3\">\n {attributes.map((attr) => (\n <div key={attr.code}>\n <label className=\"block text-sm font-medium mb-1\">\n {attr.name}\n {attr.isRequired && <span className=\"text-destructive ml-0.5\">*</span>}\n </label>\n {renderAttribute(attr)}\n {attr.helpText && <p className=\"text-xs text-muted-foreground mt-1\">{attr.helpText}</p>}\n </div>\n ))}\n </div>\n )}\n </div>\n )\n}\n\n// \u2500\u2500\u2500 Port capacity indicator \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction BandwidthIndicator({\n portCapacityMb,\n items,\n}: {\n portCapacityMb: number\n items: SelectedItem[]\n}) {\n const totalBandwidth = items.reduce((sum, item) => {\n const bw = Number(item.configuration.bandwidth_mb) || 0\n return sum + bw\n }, 0)\n\n const pct = portCapacityMb > 0 ? Math.min(100, (totalBandwidth / portCapacityMb) * 100) : 0\n const overCapacity = totalBandwidth > portCapacityMb\n\n return (\n <div className=\"rounded-lg border p-3 space-y-2\">\n <div className=\"flex items-center justify-between text-xs\">\n <span className=\"font-medium\">Bandwidth Utilization</span>\n <span className={overCapacity ? 'text-destructive font-medium' : 'text-muted-foreground'}>\n {totalBandwidth} / {portCapacityMb} MB\n </span>\n </div>\n <div className=\"h-2 rounded-full bg-muted overflow-hidden\">\n <div\n className={`h-full rounded-full transition-all ${overCapacity ? 'bg-destructive' : 'bg-primary'}`}\n style={{ width: `${Math.min(100, pct)}%` }}\n />\n </div>\n {overCapacity && (\n <p className=\"text-xs text-destructive\">\n Total bandwidth exceeds port capacity by {totalBandwidth - portCapacityMb} MB\n </p>\n )}\n </div>\n )\n}\n\n// \u2500\u2500\u2500 Main component \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst PORT_SIZE_MB: Record<string, number> = { '1G': 1000, '10G': 10000, '100G': 100000 }\n\nexport function OfferingSelectStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }: WizardStepProps) {\n const [offerings, setOfferings] = useState<Offering[]>([])\n const [selectedItems, setSelectedItems] = useState<SelectedItem[]>([])\n const [loading, setLoading] = useState(true)\n const [saving, setSaving] = useState(false)\n\n const enableConfiguration = config.enableConfiguration === true\n const multiSelect = config.multiSelect !== false // default true for offering_select\n const offeringFilter = config.offeringFilter as { specCodes?: string[]; offeringCodes?: string[] } | undefined\n const displayMode = (config.displayMode as string) ?? 'grid'\n\n // Resolve port capacity from prior step data\n const portCapacityMb = (() => {\n for (const data of Object.values(stepData)) {\n const cfg = data.configuration as Record<string, unknown> | undefined\n if (cfg?.port_size) return PORT_SIZE_MB[String(cfg.port_size)] ?? 0\n }\n return 0\n })()\n\n // Restore previous selections\n const previousData = stepData[currentStepId] as { items?: SelectedItem[] } | undefined\n\n useEffect(() => {\n async function load() {\n setLoading(true)\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const res = await fetch(`/api/cpq/product-offerings?${params}`)\n if (res.ok) {\n const data = await res.json()\n let items = (data.items ?? []) as Offering[]\n if (offeringFilter?.offeringCodes?.length) {\n const codeOrder = offeringFilter.offeringCodes!\n items = items\n .filter((o) => codeOrder.includes(o.code))\n .sort((a, b) => codeOrder.indexOf(a.code) - codeOrder.indexOf(b.code))\n }\n items = items.filter((o) => o.isActive)\n setOfferings(items)\n\n // Restore previous selections\n if (previousData?.items?.length) {\n const restored = previousData.items\n .map((prev) => {\n const o = items.find((i) => i.id === prev.offering.id)\n return o ? { offering: o, configuration: prev.configuration, lineId: prev.lineId } : null\n })\n .filter(Boolean) as SelectedItem[]\n setSelectedItems(restored)\n }\n }\n } finally {\n setLoading(false)\n }\n }\n load()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n const addItem = useCallback((offering: Offering) => {\n setSelectedItems((prev) => {\n if (!multiSelect) return [{ offering, configuration: {} }]\n return [...prev, { offering, configuration: {} }]\n })\n }, [multiSelect])\n\n const removeItem = useCallback((index: number) => {\n setSelectedItems((prev) => prev.filter((_, i) => i !== index))\n }, [])\n\n const updateItemConfig = useCallback((index: number, code: string, value: unknown) => {\n setSelectedItems((prev) => prev.map((item, i) =>\n i === index ? { ...item, configuration: { ...item.configuration, [code]: value } } : item\n ))\n }, [])\n\n // Resolve customerId from props or stepData\n const resolvedCustomerId = customerId ?? (() => {\n for (const data of Object.values(stepData)) {\n if (data.customerId) return data.customerId as string\n }\n return null\n })()\n\n const handleNext = useCallback(async () => {\n if (selectedItems.length === 0) return\n setSaving(true)\n try {\n let activeQuoteId = quoteId\n const output: Record<string, unknown> = { items: selectedItems }\n\n if (enableConfiguration) {\n // Auto-create quote if needed\n if (!activeQuoteId && resolvedCustomerId) {\n const createRes = await fetch('/api/cpq/quotes', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ customerId: resolvedCustomerId }),\n })\n if (createRes.ok) {\n const quoteData = await createRes.json()\n activeQuoteId = quoteData.id\n output.quoteId = activeQuoteId\n }\n }\n\n // Add or update each selected item on the quote\n if (activeQuoteId) {\n for (const item of selectedItems) {\n if (item.lineId) {\n // Update existing line\n await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${item.lineId}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ configuration: item.configuration }),\n })\n } else {\n // Create new line\n const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ offeringId: item.offering.id, configuration: item.configuration }),\n })\n if (res.ok) {\n const data = await res.json()\n const line = data.lines?.find((l: { offeringId: string }) => l.offeringId === item.offering.id)\n item.lineId = line?.lineId\n }\n }\n }\n output.quoteId = activeQuoteId\n }\n }\n\n // Also set single-item compat fields\n if (selectedItems.length === 1) {\n const first = selectedItems[0]\n output.offeringId = first.offering.id\n output.offeringCode = first.offering.code\n output.offeringName = first.offering.name\n output.specId = first.offering.specId\n if (enableConfiguration) output.configuration = first.configuration\n }\n\n onComplete(output)\n } finally {\n setSaving(false)\n }\n }, [selectedItems, enableConfiguration, quoteId, resolvedCustomerId, onComplete])\n\n if (loading) {\n return <div className=\"text-sm text-muted-foreground\">Loading offerings...</div>\n }\n\n // Offerings not yet added\n const availableOfferings = offerings.filter((o) =>\n multiSelect ? true : !selectedItems.some((s) => s.offering.id === o.id)\n )\n\n return (\n <div className=\"space-y-4\">\n {/* Offering cards */}\n <div\n className={\n displayMode === 'grid'\n ? 'grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-3'\n : 'flex flex-col gap-2'\n }\n >\n {availableOfferings.map((o) => {\n const isAdded = selectedItems.some((s) => s.offering.id === o.id)\n return (\n <div\n key={o.id}\n onClick={() => !isAdded && addItem(o)}\n className={`rounded-lg border-2 p-4 transition-colors ${\n isAdded\n ? 'border-primary/30 bg-primary/5 opacity-60 cursor-default'\n : 'border-muted cursor-pointer hover:bg-muted/30'\n }`}\n >\n <div className=\"flex items-center justify-between\">\n <h4 className=\"text-sm font-medium\">{o.name}</h4>\n {isAdded && <span className=\"text-xs text-primary font-medium\">Added</span>}\n </div>\n <p className=\"text-xs text-muted-foreground mt-1\">{o.description || o.code}</p>\n {!isAdded && (\n <span className=\"text-xs text-primary mt-2 inline-block\">+ Add</span>\n )}\n </div>\n )\n })}\n {offerings.length === 0 && (\n <div className=\"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground\">\n No offerings available.\n </div>\n )}\n </div>\n\n {/* Bandwidth indicator */}\n {portCapacityMb > 0 && selectedItems.length > 0 && (\n <BandwidthIndicator portCapacityMb={portCapacityMb} items={selectedItems} />\n )}\n\n {/* Configuration panels for selected items */}\n {enableConfiguration && selectedItems.length > 0 && (\n <div className=\"space-y-3\">\n <h4 className=\"text-sm font-medium\">Selected Services ({selectedItems.length})</h4>\n {selectedItems.map((item, index) => (\n <ConfigPanel\n key={`${item.offering.id}-${index}`}\n offering={item.offering}\n configuration={item.configuration}\n onChange={(code, value) => updateItemConfig(index, code, value)}\n onRemove={() => removeItem(index)}\n />\n ))}\n </div>\n )}\n\n {/* No configuration \u2014 just show selected list */}\n {!enableConfiguration && selectedItems.length > 0 && (\n <div className=\"space-y-2\">\n <h4 className=\"text-sm font-medium\">Selected ({selectedItems.length})</h4>\n {selectedItems.map((item, index) => (\n <div key={`${item.offering.id}-${index}`} className=\"flex items-center justify-between rounded-md border p-3\">\n <span className=\"text-sm font-medium\">{item.offering.name}</span>\n <button type=\"button\" onClick={() => removeItem(index)} className=\"text-xs text-muted-foreground hover:text-foreground\">Remove</button>\n </div>\n ))}\n </div>\n )}\n\n <div className=\"flex gap-2 justify-end pt-2\">\n {completedSteps.length > 0 && (\n <button type=\"button\" onClick={onBack} className=\"inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted\">\n Back\n </button>\n )}\n <button\n type=\"button\"\n onClick={handleNext}\n disabled={selectedItems.length === 0 || saving}\n className=\"inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {saving ? 'Saving...' : 'Next'}\n </button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": ";AA0FQ,SACE,KADF;AAxFR,SAAgB,UAAU,WAAW,mBAAmB;AAExD,SAAS,mBAAmB;AA8B5B,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAiC,CAAC,CAAC;AACvE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AAEpD,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,mBAAe,OAAO;AACpB,iBAAW,IAAI;AACf,UAAI;AACF,cAAM,SAAS,IAAI,gBAAgB,EAAE,YAAY,SAAS,GAAG,CAAC;AAC9D,YAAI,OAAO,KAAK,aAAa,EAAE,SAAS,GAAG;AACzC,iBAAO,IAAI,iBAA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0,0 +1,231 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useState, useEffect, useCallback } from "react";
4
+ import { NumberInput } from "../../components/NumberInput.js";
5
+ function resolveOfferingId(config, stepData) {
6
+ const source = config.offeringSource;
7
+ if (source && stepData[source]) {
8
+ return stepData[source].offeringId ?? null;
9
+ }
10
+ for (const data of Object.values(stepData)) {
11
+ if (data.offeringId) return data.offeringId;
12
+ }
13
+ return null;
14
+ }
15
+ function ProductConfigureStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }) {
16
+ const [attributes, setAttributes] = useState([]);
17
+ const [values, setValues] = useState({});
18
+ const [loading, setLoading] = useState(true);
19
+ const [saving, setSaving] = useState(false);
20
+ const [resolvedOfferingId, setResolvedOfferingId] = useState(null);
21
+ const directOfferingId = resolveOfferingId(config, stepData);
22
+ const offeringCode = config.offeringCode;
23
+ const attributeGroups = config.attributeGroups;
24
+ useEffect(() => {
25
+ if (directOfferingId) {
26
+ setResolvedOfferingId(directOfferingId);
27
+ return;
28
+ }
29
+ if (!offeringCode) return;
30
+ async function resolve() {
31
+ try {
32
+ const res = await fetch(`/api/cpq/product-offerings?code=${encodeURIComponent(offeringCode)}`);
33
+ if (res.ok) {
34
+ const data = await res.json();
35
+ const items = data.items ?? data;
36
+ if (Array.isArray(items) && items.length > 0) {
37
+ setResolvedOfferingId(items[0].id);
38
+ }
39
+ }
40
+ } catch {
41
+ }
42
+ }
43
+ resolve();
44
+ }, [directOfferingId, offeringCode]);
45
+ const offeringId = resolvedOfferingId;
46
+ const hiddenAttributes = config.hiddenAttributes ?? [];
47
+ const readonlyAttributes = config.readonlyAttributes ?? [];
48
+ const previousData = stepData[currentStepId];
49
+ useEffect(() => {
50
+ async function loadAttributes() {
51
+ if (!offeringId) {
52
+ setLoading(false);
53
+ return;
54
+ }
55
+ setLoading(true);
56
+ try {
57
+ const params = new URLSearchParams({ offeringId });
58
+ if (Object.keys(values).length > 0) {
59
+ params.set("configuration", JSON.stringify(values));
60
+ }
61
+ const res = await fetch(`/api/cpq/quotes/attributes?${params}`);
62
+ if (res.ok) {
63
+ const data = await res.json();
64
+ const attrs = data.attributes ?? [];
65
+ setAttributes(attrs.filter((a) => !hiddenAttributes.includes(a.code)));
66
+ if (Object.keys(values).length === 0) {
67
+ const defaults = previousData?.configuration ?? {};
68
+ for (const attr of attrs) {
69
+ if (defaults[attr.code] === void 0 && attr.defaultValue != null) {
70
+ defaults[attr.code] = attr.defaultValue;
71
+ }
72
+ }
73
+ setValues(defaults);
74
+ }
75
+ }
76
+ } finally {
77
+ setLoading(false);
78
+ }
79
+ }
80
+ loadAttributes();
81
+ }, [offeringId]);
82
+ const handleChange = useCallback((code, value) => {
83
+ setValues((prev) => ({ ...prev, [code]: value }));
84
+ }, []);
85
+ const resolvedCustomerId = customerId ?? (() => {
86
+ for (const data of Object.values(stepData)) {
87
+ if (data.customerId) return data.customerId;
88
+ }
89
+ return null;
90
+ })();
91
+ const handleComplete = useCallback(async () => {
92
+ setSaving(true);
93
+ try {
94
+ let activeQuoteId = quoteId;
95
+ if (!activeQuoteId && resolvedCustomerId && offeringId) {
96
+ const createRes = await fetch("/api/cpq/quotes", {
97
+ method: "POST",
98
+ headers: { "Content-Type": "application/json" },
99
+ body: JSON.stringify({ customerId: resolvedCustomerId })
100
+ });
101
+ if (createRes.ok) {
102
+ const quoteData = await createRes.json();
103
+ activeQuoteId = quoteData.id;
104
+ }
105
+ }
106
+ if (activeQuoteId && offeringId) {
107
+ const existingLineId = stepData[currentStepId]?.lineId;
108
+ if (existingLineId) {
109
+ await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${existingLineId}`, {
110
+ method: "PUT",
111
+ headers: { "Content-Type": "application/json" },
112
+ body: JSON.stringify({ configuration: values })
113
+ });
114
+ onComplete({ configuration: values, offeringId, lineId: existingLineId, quoteId: activeQuoteId });
115
+ } else {
116
+ const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {
117
+ method: "POST",
118
+ headers: { "Content-Type": "application/json" },
119
+ body: JSON.stringify({ offeringId, configuration: values })
120
+ });
121
+ if (res.ok) {
122
+ const data = await res.json();
123
+ const line = data.lines?.find((l) => l.offeringId === offeringId);
124
+ onComplete({ configuration: values, offeringId, lineId: line?.lineId, quoteId: activeQuoteId });
125
+ } else {
126
+ onComplete({ configuration: values, offeringId, quoteId: activeQuoteId });
127
+ }
128
+ }
129
+ } else {
130
+ onComplete({ configuration: values, offeringId });
131
+ }
132
+ } finally {
133
+ setSaving(false);
134
+ }
135
+ }, [values, quoteId, offeringId, stepData, currentStepId, onComplete, resolvedCustomerId]);
136
+ const renderAttribute = (attr) => {
137
+ const isReadonly = readonlyAttributes.includes(attr.code);
138
+ const value = values[attr.code] ?? "";
139
+ if (attr.attributeType === "select" || attr.attributeType === "enum") {
140
+ return /* @__PURE__ */ jsxs(
141
+ "select",
142
+ {
143
+ value: String(value),
144
+ onChange: (e) => handleChange(attr.code, e.target.value),
145
+ disabled: isReadonly,
146
+ className: "w-full rounded-md border px-3 py-2 text-sm disabled:opacity-50",
147
+ children: [
148
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
149
+ attr.options?.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
150
+ ]
151
+ }
152
+ );
153
+ }
154
+ if (attr.attributeType === "boolean") {
155
+ return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
156
+ /* @__PURE__ */ jsx(
157
+ "input",
158
+ {
159
+ type: "checkbox",
160
+ checked: Boolean(value),
161
+ onChange: (e) => handleChange(attr.code, e.target.checked),
162
+ disabled: isReadonly,
163
+ className: "rounded border"
164
+ }
165
+ ),
166
+ attr.name
167
+ ] });
168
+ }
169
+ if (attr.attributeType === "number") {
170
+ return /* @__PURE__ */ jsx(
171
+ NumberInput,
172
+ {
173
+ value: value === "" || value == null ? null : Number(value),
174
+ onChange: (n) => handleChange(attr.code, n ?? ""),
175
+ disabled: isReadonly
176
+ }
177
+ );
178
+ }
179
+ return /* @__PURE__ */ jsx(
180
+ "input",
181
+ {
182
+ type: "text",
183
+ value: String(value),
184
+ onChange: (e) => handleChange(attr.code, e.target.value),
185
+ disabled: isReadonly,
186
+ className: "w-full rounded-md border px-3 py-2 text-sm disabled:opacity-50"
187
+ }
188
+ );
189
+ };
190
+ if (loading) {
191
+ return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading attributes..." });
192
+ }
193
+ if (!offeringId) {
194
+ return /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No offering selected. Please go back and select an offering." });
195
+ }
196
+ const renderGroup = (label, attrs) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
197
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-medium border-b pb-2", children: label }),
198
+ /* @__PURE__ */ jsx("div", { className: "space-y-3", children: attrs.map((attr) => /* @__PURE__ */ jsxs("div", { children: [
199
+ /* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
200
+ attr.name,
201
+ attr.isRequired && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-0.5", children: "*" })
202
+ ] }),
203
+ renderAttribute(attr),
204
+ attr.helpText && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: attr.helpText })
205
+ ] }, attr.code)) })
206
+ ] }, label);
207
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
208
+ attributeGroups?.length ? attributeGroups.map((group) => {
209
+ const groupAttrs = attributes.filter((a) => group.attributeCodes.includes(a.code));
210
+ if (groupAttrs.length === 0) return null;
211
+ return renderGroup(group.label, groupAttrs);
212
+ }) : renderGroup("Configuration", attributes),
213
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-end pt-2", children: [
214
+ completedSteps.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: onBack, className: "inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted", children: "Back" }),
215
+ /* @__PURE__ */ jsx(
216
+ "button",
217
+ {
218
+ type: "button",
219
+ onClick: handleComplete,
220
+ disabled: saving,
221
+ className: "inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",
222
+ children: saving ? "Saving..." : "Next"
223
+ }
224
+ )
225
+ ] })
226
+ ] });
227
+ }
228
+ export {
229
+ ProductConfigureStep
230
+ };
231
+ //# sourceMappingURL=ProductConfigureStep.js.map