@dainamite/cpq 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (504) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/LICENSE +21 -0
  3. package/MIGRATION.md +236 -0
  4. package/README.md +108 -0
  5. package/dist/modules/cpq/acl.js +30 -0
  6. package/dist/modules/cpq/acl.js.map +7 -0
  7. package/dist/modules/cpq/api/_helpers/handleArcError.js +37 -0
  8. package/dist/modules/cpq/api/_helpers/handleArcError.js.map +7 -0
  9. package/dist/modules/cpq/api/attribute-options/route.js +47 -0
  10. package/dist/modules/cpq/api/attribute-options/route.js.map +7 -0
  11. package/dist/modules/cpq/api/bundle-slots/route.js +101 -0
  12. package/dist/modules/cpq/api/bundle-slots/route.js.map +7 -0
  13. package/dist/modules/cpq/api/bundle-tree/route.js +28 -0
  14. package/dist/modules/cpq/api/bundle-tree/route.js.map +7 -0
  15. package/dist/modules/cpq/api/context.js +29 -0
  16. package/dist/modules/cpq/api/context.js.map +7 -0
  17. package/dist/modules/cpq/api/inventory/assets/route.js +113 -0
  18. package/dist/modules/cpq/api/inventory/assets/route.js.map +7 -0
  19. package/dist/modules/cpq/api/inventory/assets/status/route.js +35 -0
  20. package/dist/modules/cpq/api/inventory/assets/status/route.js.map +7 -0
  21. package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js +30 -0
  22. package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js.map +7 -0
  23. package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js +31 -0
  24. package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js.map +7 -0
  25. package/dist/modules/cpq/api/inventory/subscription-items/route.js +99 -0
  26. package/dist/modules/cpq/api/inventory/subscription-items/route.js.map +7 -0
  27. package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js +57 -0
  28. package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js.map +7 -0
  29. package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js +62 -0
  30. package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js.map +7 -0
  31. package/dist/modules/cpq/api/inventory/subscriptions/route.js +116 -0
  32. package/dist/modules/cpq/api/inventory/subscriptions/route.js.map +7 -0
  33. package/dist/modules/cpq/api/inventory/subscriptions/status/route.js +35 -0
  34. package/dist/modules/cpq/api/inventory/subscriptions/status/route.js.map +7 -0
  35. package/dist/modules/cpq/api/offering-components/route.js +91 -0
  36. package/dist/modules/cpq/api/offering-components/route.js.map +7 -0
  37. package/dist/modules/cpq/api/orders/[orderId]/activate/route.js +39 -0
  38. package/dist/modules/cpq/api/orders/[orderId]/activate/route.js.map +7 -0
  39. package/dist/modules/cpq/api/orders/[orderId]/route.js +28 -0
  40. package/dist/modules/cpq/api/orders/[orderId]/route.js.map +7 -0
  41. package/dist/modules/cpq/api/orders/[orderId]/status/route.js +38 -0
  42. package/dist/modules/cpq/api/orders/[orderId]/status/route.js.map +7 -0
  43. package/dist/modules/cpq/api/orders/route.js +71 -0
  44. package/dist/modules/cpq/api/orders/route.js.map +7 -0
  45. package/dist/modules/cpq/api/price-rules/route.js +180 -0
  46. package/dist/modules/cpq/api/price-rules/route.js.map +7 -0
  47. package/dist/modules/cpq/api/pricing-table-entries/route.js +142 -0
  48. package/dist/modules/cpq/api/pricing-table-entries/route.js.map +7 -0
  49. package/dist/modules/cpq/api/pricing-tables/route.js +179 -0
  50. package/dist/modules/cpq/api/pricing-tables/route.js.map +7 -0
  51. package/dist/modules/cpq/api/product-attributes/route.js +160 -0
  52. package/dist/modules/cpq/api/product-attributes/route.js.map +7 -0
  53. package/dist/modules/cpq/api/product-charges/route.js +166 -0
  54. package/dist/modules/cpq/api/product-charges/route.js.map +7 -0
  55. package/dist/modules/cpq/api/product-offerings/route.js +294 -0
  56. package/dist/modules/cpq/api/product-offerings/route.js.map +7 -0
  57. package/dist/modules/cpq/api/product-relationships/route.js +144 -0
  58. package/dist/modules/cpq/api/product-relationships/route.js.map +7 -0
  59. package/dist/modules/cpq/api/product-specifications/route.js +292 -0
  60. package/dist/modules/cpq/api/product-specifications/route.js.map +7 -0
  61. package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js +71 -0
  62. package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js.map +7 -0
  63. package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js +29 -0
  64. package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js.map +7 -0
  65. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js +54 -0
  66. package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js.map +7 -0
  67. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js +27 -0
  68. package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js.map +7 -0
  69. package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js +72 -0
  70. package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js.map +7 -0
  71. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js +35 -0
  72. package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js.map +7 -0
  73. package/dist/modules/cpq/api/quotes/[quoteId]/route.js +102 -0
  74. package/dist/modules/cpq/api/quotes/[quoteId]/route.js.map +7 -0
  75. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js +27 -0
  76. package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js.map +7 -0
  77. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js +79 -0
  78. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js.map +7 -0
  79. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js +95 -0
  80. package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js.map +7 -0
  81. package/dist/modules/cpq/api/quotes/attributes/route.js +52 -0
  82. package/dist/modules/cpq/api/quotes/attributes/route.js.map +7 -0
  83. package/dist/modules/cpq/api/quotes/from-subscription/route.js +72 -0
  84. package/dist/modules/cpq/api/quotes/from-subscription/route.js.map +7 -0
  85. package/dist/modules/cpq/api/quotes/price/route.js +69 -0
  86. package/dist/modules/cpq/api/quotes/price/route.js.map +7 -0
  87. package/dist/modules/cpq/api/quotes/route.js +97 -0
  88. package/dist/modules/cpq/api/quotes/route.js.map +7 -0
  89. package/dist/modules/cpq/api/quotes/validate-relationships/route.js +86 -0
  90. package/dist/modules/cpq/api/quotes/validate-relationships/route.js.map +7 -0
  91. package/dist/modules/cpq/api/resolveQuotingService.js +7 -0
  92. package/dist/modules/cpq/api/resolveQuotingService.js.map +7 -0
  93. package/dist/modules/cpq/api/wizards/resolve/route.js +38 -0
  94. package/dist/modules/cpq/api/wizards/resolve/route.js.map +7 -0
  95. package/dist/modules/cpq/api/wizards/route.js +111 -0
  96. package/dist/modules/cpq/api/wizards/route.js.map +7 -0
  97. package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js +136 -0
  98. package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js.map +7 -0
  99. package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js +185 -0
  100. package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js.map +7 -0
  101. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js +343 -0
  102. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js.map +7 -0
  103. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js +13 -0
  104. package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js.map +7 -0
  105. package/dist/modules/cpq/backend/cpq/inventory/page.js +35 -0
  106. package/dist/modules/cpq/backend/cpq/inventory/page.js.map +7 -0
  107. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js +18 -0
  108. package/dist/modules/cpq/backend/cpq/inventory/page.meta.js.map +7 -0
  109. package/dist/modules/cpq/backend/cpq/inventory/shared.js +20 -0
  110. package/dist/modules/cpq/backend/cpq/inventory/shared.js.map +7 -0
  111. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js +794 -0
  112. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js.map +7 -0
  113. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js +13 -0
  114. package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js.map +7 -0
  115. package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js +917 -0
  116. package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js.map +7 -0
  117. package/dist/modules/cpq/backend/cpq/offerings/page.js +405 -0
  118. package/dist/modules/cpq/backend/cpq/offerings/page.js.map +7 -0
  119. package/dist/modules/cpq/backend/cpq/offerings/page.meta.js +18 -0
  120. package/dist/modules/cpq/backend/cpq/offerings/page.meta.js.map +7 -0
  121. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js +677 -0
  122. package/dist/modules/cpq/backend/cpq/orders/[id]/page.js.map +7 -0
  123. package/dist/modules/cpq/backend/cpq/orders/page.js +134 -0
  124. package/dist/modules/cpq/backend/cpq/orders/page.js.map +7 -0
  125. package/dist/modules/cpq/backend/cpq/orders/page.meta.js +18 -0
  126. package/dist/modules/cpq/backend/cpq/orders/page.meta.js.map +7 -0
  127. package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js +272 -0
  128. package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js.map +7 -0
  129. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js +407 -0
  130. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js.map +7 -0
  131. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js +13 -0
  132. package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js.map +7 -0
  133. package/dist/modules/cpq/backend/cpq/price-rules/page.js +211 -0
  134. package/dist/modules/cpq/backend/cpq/price-rules/page.js.map +7 -0
  135. package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js +18 -0
  136. package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js.map +7 -0
  137. package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js +275 -0
  138. package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js.map +7 -0
  139. package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js +112 -0
  140. package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js.map +7 -0
  141. package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js +492 -0
  142. package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js.map +7 -0
  143. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js +50 -0
  144. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js.map +7 -0
  145. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js +249 -0
  146. package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js.map +7 -0
  147. package/dist/modules/cpq/backend/cpq/pricing/page.js +87 -0
  148. package/dist/modules/cpq/backend/cpq/pricing/page.js.map +7 -0
  149. package/dist/modules/cpq/backend/cpq/pricing/page.meta.js +18 -0
  150. package/dist/modules/cpq/backend/cpq/pricing/page.meta.js.map +7 -0
  151. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js +652 -0
  152. package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js.map +7 -0
  153. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js +1289 -0
  154. package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js.map +7 -0
  155. package/dist/modules/cpq/backend/cpq/quotes/page.js +283 -0
  156. package/dist/modules/cpq/backend/cpq/quotes/page.js.map +7 -0
  157. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js +18 -0
  158. package/dist/modules/cpq/backend/cpq/quotes/page.meta.js.map +7 -0
  159. package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js +214 -0
  160. package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js.map +7 -0
  161. package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js +1399 -0
  162. package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js.map +7 -0
  163. package/dist/modules/cpq/backend/cpq/specifications/page.js +148 -0
  164. package/dist/modules/cpq/backend/cpq/specifications/page.js.map +7 -0
  165. package/dist/modules/cpq/backend/cpq/specifications/page.meta.js +18 -0
  166. package/dist/modules/cpq/backend/cpq/specifications/page.meta.js.map +7 -0
  167. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js +204 -0
  168. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js.map +7 -0
  169. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js +191 -0
  170. package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js.map +7 -0
  171. package/dist/modules/cpq/backend/cpq/wizards/page.js +119 -0
  172. package/dist/modules/cpq/backend/cpq/wizards/page.js.map +7 -0
  173. package/dist/modules/cpq/backend/cpq/wizards/page.meta.js +18 -0
  174. package/dist/modules/cpq/backend/cpq/wizards/page.meta.js.map +7 -0
  175. package/dist/modules/cpq/ce.js +151 -0
  176. package/dist/modules/cpq/ce.js.map +7 -0
  177. package/dist/modules/cpq/cli.js +11 -0
  178. package/dist/modules/cpq/cli.js.map +7 -0
  179. package/dist/modules/cpq/components/CpqListView.js +265 -0
  180. package/dist/modules/cpq/components/CpqListView.js.map +7 -0
  181. package/dist/modules/cpq/components/NumberInput.js +95 -0
  182. package/dist/modules/cpq/components/NumberInput.js.map +7 -0
  183. package/dist/modules/cpq/components/StatusPath.js +60 -0
  184. package/dist/modules/cpq/components/StatusPath.js.map +7 -0
  185. package/dist/modules/cpq/components/statusMaps.js +66 -0
  186. package/dist/modules/cpq/components/statusMaps.js.map +7 -0
  187. package/dist/modules/cpq/components/useCpqRowActions.js +125 -0
  188. package/dist/modules/cpq/components/useCpqRowActions.js.map +7 -0
  189. package/dist/modules/cpq/data/entities.js +1556 -0
  190. package/dist/modules/cpq/data/entities.js.map +7 -0
  191. package/dist/modules/cpq/data/validators.js +575 -0
  192. package/dist/modules/cpq/data/validators.js.map +7 -0
  193. package/dist/modules/cpq/di.js +57 -0
  194. package/dist/modules/cpq/di.js.map +7 -0
  195. package/dist/modules/cpq/events.js +50 -0
  196. package/dist/modules/cpq/events.js.map +7 -0
  197. package/dist/modules/cpq/index.js +16 -0
  198. package/dist/modules/cpq/index.js.map +7 -0
  199. package/dist/modules/cpq/lib/seeds/api.js +32 -0
  200. package/dist/modules/cpq/lib/seeds/api.js.map +7 -0
  201. package/dist/modules/cpq/lib/seeds/tenant-provisioning.js +158 -0
  202. package/dist/modules/cpq/lib/seeds/tenant-provisioning.js.map +7 -0
  203. package/dist/modules/cpq/lib/seeds.js +6 -0
  204. package/dist/modules/cpq/lib/seeds.js.map +7 -0
  205. package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js +40 -0
  206. package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js.map +7 -0
  207. package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js +54 -0
  208. package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js.map +7 -0
  209. package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js +15 -0
  210. package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js.map +7 -0
  211. package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js +62 -0
  212. package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js.map +7 -0
  213. package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js +56 -0
  214. package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js.map +7 -0
  215. package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js +26 -0
  216. package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js.map +7 -0
  217. package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js +37 -0
  218. package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js.map +7 -0
  219. package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js +35 -0
  220. package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js.map +7 -0
  221. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js +21 -0
  222. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js.map +7 -0
  223. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js +46 -0
  224. package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js.map +7 -0
  225. package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js +118 -0
  226. package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js.map +7 -0
  227. package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js +63 -0
  228. package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js.map +7 -0
  229. package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js +28 -0
  230. package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js.map +7 -0
  231. package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js +36 -0
  232. package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js.map +7 -0
  233. package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js +14 -0
  234. package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js.map +7 -0
  235. package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js +14 -0
  236. package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js.map +7 -0
  237. package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js +58 -0
  238. package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js.map +7 -0
  239. package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js +29 -0
  240. package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js.map +7 -0
  241. package/dist/modules/cpq/services/cpqBundleService.js +447 -0
  242. package/dist/modules/cpq/services/cpqBundleService.js.map +7 -0
  243. package/dist/modules/cpq/services/cpqInventoryService.js +1371 -0
  244. package/dist/modules/cpq/services/cpqInventoryService.js.map +7 -0
  245. package/dist/modules/cpq/services/cpqOrderService.js +901 -0
  246. package/dist/modules/cpq/services/cpqOrderService.js.map +7 -0
  247. package/dist/modules/cpq/services/cpqPricingService.js +289 -0
  248. package/dist/modules/cpq/services/cpqPricingService.js.map +7 -0
  249. package/dist/modules/cpq/services/cpqProductService.js +204 -0
  250. package/dist/modules/cpq/services/cpqProductService.js.map +7 -0
  251. package/dist/modules/cpq/services/cpqQuotingService.js +1867 -0
  252. package/dist/modules/cpq/services/cpqQuotingService.js.map +7 -0
  253. package/dist/modules/cpq/services/cpqValidationService.js +234 -0
  254. package/dist/modules/cpq/services/cpqValidationService.js.map +7 -0
  255. package/dist/modules/cpq/services/cpqWizardService.js +137 -0
  256. package/dist/modules/cpq/services/cpqWizardService.js.map +7 -0
  257. package/dist/modules/cpq/services/types.js +114 -0
  258. package/dist/modules/cpq/services/types.js.map +7 -0
  259. package/dist/modules/cpq/setup.js +49 -0
  260. package/dist/modules/cpq/setup.js.map +7 -0
  261. package/dist/modules/cpq/subscribers/subscription-amended-log.js +18 -0
  262. package/dist/modules/cpq/subscribers/subscription-amended-log.js.map +7 -0
  263. package/dist/modules/cpq/subscribers/subscription-cancelled-log.js +19 -0
  264. package/dist/modules/cpq/subscribers/subscription-cancelled-log.js.map +7 -0
  265. package/dist/modules/cpq/subscribers/subscription-merged-log.js +20 -0
  266. package/dist/modules/cpq/subscribers/subscription-merged-log.js.map +7 -0
  267. package/dist/modules/cpq/subscribers/subscription-renewed-log.js +18 -0
  268. package/dist/modules/cpq/subscribers/subscription-renewed-log.js.map +7 -0
  269. package/dist/modules/cpq/subscribers/subscription-superseded-log.js +18 -0
  270. package/dist/modules/cpq/subscribers/subscription-superseded-log.js.map +7 -0
  271. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js +192 -0
  272. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js.map +7 -0
  273. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js +17 -0
  274. package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js.map +7 -0
  275. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js +79 -0
  276. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js.map +7 -0
  277. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js +17 -0
  278. package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js.map +7 -0
  279. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js +181 -0
  280. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js.map +7 -0
  281. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js +17 -0
  282. package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js.map +7 -0
  283. package/dist/modules/cpq/widgets/injection-table.js +44 -0
  284. package/dist/modules/cpq/widgets/injection-table.js.map +7 -0
  285. package/dist/modules/cpq/workflows/WizardRunner.js +113 -0
  286. package/dist/modules/cpq/workflows/WizardRunner.js.map +7 -0
  287. package/dist/modules/cpq/workflows/WizardTrigger.js +116 -0
  288. package/dist/modules/cpq/workflows/WizardTrigger.js.map +7 -0
  289. package/dist/modules/cpq/workflows/engine.js +188 -0
  290. package/dist/modules/cpq/workflows/engine.js.map +7 -0
  291. package/dist/modules/cpq/workflows/registry.js +16 -0
  292. package/dist/modules/cpq/workflows/registry.js.map +7 -0
  293. package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js +119 -0
  294. package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js.map +7 -0
  295. package/dist/modules/cpq/workflows/steps/InventorySelectStep.js +24 -0
  296. package/dist/modules/cpq/workflows/steps/InventorySelectStep.js.map +7 -0
  297. package/dist/modules/cpq/workflows/steps/ItemListStep.js +115 -0
  298. package/dist/modules/cpq/workflows/steps/ItemListStep.js.map +7 -0
  299. package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js +327 -0
  300. package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js.map +7 -0
  301. package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js +231 -0
  302. package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js.map +7 -0
  303. package/dist/modules/cpq/workflows/steps/ReviewStep.js +152 -0
  304. package/dist/modules/cpq/workflows/steps/ReviewStep.js.map +7 -0
  305. package/dist/modules/cpq/workflows/steps/index.js +49 -0
  306. package/dist/modules/cpq/workflows/steps/index.js.map +7 -0
  307. package/dist/modules/cpq/workflows/types.js +1 -0
  308. package/dist/modules/cpq/workflows/types.js.map +7 -0
  309. package/package.json +150 -0
  310. package/src/modules/cpq/__integration__/TC-CPQ-001.spec.ts +177 -0
  311. package/src/modules/cpq/__integration__/TC-CPQ-002.spec.ts +123 -0
  312. package/src/modules/cpq/__integration__/TC-CPQ-003.spec.ts +115 -0
  313. package/src/modules/cpq/__integration__/TC-CPQ-004.spec.ts +184 -0
  314. package/src/modules/cpq/__integration__/TC-CPQ-005.spec.ts +43 -0
  315. package/src/modules/cpq/__integration__/TC-CPQ-006.spec.ts +87 -0
  316. package/src/modules/cpq/__integration__/TC-CPQ-007.spec.ts +79 -0
  317. package/src/modules/cpq/__integration__/TC-CPQ-008.spec.ts +55 -0
  318. package/src/modules/cpq/__integration__/TC-CPQ-009.spec.ts +45 -0
  319. package/src/modules/cpq/__integration__/TC-CPQ-010.spec.ts +54 -0
  320. package/src/modules/cpq/__integration__/TC-CPQ-011.spec.ts +24 -0
  321. package/src/modules/cpq/__integration__/TC-CPQ-012.spec.ts +62 -0
  322. package/src/modules/cpq/__integration__/TC-CPQ-ARC-001.spec.ts +52 -0
  323. package/src/modules/cpq/__integration__/TC-CPQ-ARC-002.spec.ts +65 -0
  324. package/src/modules/cpq/__integration__/TC-CPQ-ARC-003.spec.ts +107 -0
  325. package/src/modules/cpq/__integration__/TC-CPQ-ARC-004.spec.ts +74 -0
  326. package/src/modules/cpq/__integration__/TC-CPQ-ARC-005.spec.ts +86 -0
  327. package/src/modules/cpq/__integration__/TC-CPQ-ARC-006.spec.ts +79 -0
  328. package/src/modules/cpq/__integration__/TC-CPQ-ARC-007.spec.ts +63 -0
  329. package/src/modules/cpq/__integration__/TC-CPQ-ARC-008.spec.ts +62 -0
  330. package/src/modules/cpq/__integration__/TC-CPQ-ARC-009.spec.ts +62 -0
  331. package/src/modules/cpq/__integration__/TC-CPQ-ARC-010.spec.ts +59 -0
  332. package/src/modules/cpq/__integration__/TC-CPQ-ARC-011.spec.ts +128 -0
  333. package/src/modules/cpq/__integration__/_helpers/cpqArcFixtures.ts +208 -0
  334. package/src/modules/cpq/__tests__/package-isolation.test.ts +232 -0
  335. package/src/modules/cpq/acl.ts +26 -0
  336. package/src/modules/cpq/api/_helpers/__tests__/handleArcError.test.ts +117 -0
  337. package/src/modules/cpq/api/_helpers/handleArcError.ts +81 -0
  338. package/src/modules/cpq/api/attribute-options/route.ts +55 -0
  339. package/src/modules/cpq/api/bundle-slots/route.ts +112 -0
  340. package/src/modules/cpq/api/bundle-tree/route.ts +31 -0
  341. package/src/modules/cpq/api/context.ts +39 -0
  342. package/src/modules/cpq/api/inventory/assets/route.ts +123 -0
  343. package/src/modules/cpq/api/inventory/assets/status/route.ts +34 -0
  344. package/src/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.ts +30 -0
  345. package/src/modules/cpq/api/inventory/customer/[customerId]/route.ts +31 -0
  346. package/src/modules/cpq/api/inventory/subscription-items/route.ts +107 -0
  347. package/src/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.ts +64 -0
  348. package/src/modules/cpq/api/inventory/subscriptions/expiring/route.ts +66 -0
  349. package/src/modules/cpq/api/inventory/subscriptions/route.ts +126 -0
  350. package/src/modules/cpq/api/inventory/subscriptions/status/route.ts +34 -0
  351. package/src/modules/cpq/api/offering-components/route.ts +103 -0
  352. package/src/modules/cpq/api/orders/[orderId]/activate/route.ts +48 -0
  353. package/src/modules/cpq/api/orders/[orderId]/route.ts +28 -0
  354. package/src/modules/cpq/api/orders/[orderId]/status/route.ts +38 -0
  355. package/src/modules/cpq/api/orders/route.ts +77 -0
  356. package/src/modules/cpq/api/price-rules/route.ts +210 -0
  357. package/src/modules/cpq/api/pricing-table-entries/route.ts +159 -0
  358. package/src/modules/cpq/api/pricing-tables/route.ts +202 -0
  359. package/src/modules/cpq/api/product-attributes/route.ts +175 -0
  360. package/src/modules/cpq/api/product-charges/route.ts +181 -0
  361. package/src/modules/cpq/api/product-offerings/route.ts +329 -0
  362. package/src/modules/cpq/api/product-relationships/route.ts +156 -0
  363. package/src/modules/cpq/api/product-specifications/route.ts +325 -0
  364. package/src/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.ts +77 -0
  365. package/src/modules/cpq/api/quotes/[quoteId]/clone/route.ts +28 -0
  366. package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.ts +55 -0
  367. package/src/modules/cpq/api/quotes/[quoteId]/items/route.ts +26 -0
  368. package/src/modules/cpq/api/quotes/[quoteId]/merge-meta/route.ts +78 -0
  369. package/src/modules/cpq/api/quotes/[quoteId]/recalculate/route.ts +34 -0
  370. package/src/modules/cpq/api/quotes/[quoteId]/route.ts +109 -0
  371. package/src/modules/cpq/api/quotes/[quoteId]/status/route.ts +26 -0
  372. package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.ts +91 -0
  373. package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.ts +107 -0
  374. package/src/modules/cpq/api/quotes/attributes/route.ts +61 -0
  375. package/src/modules/cpq/api/quotes/from-subscription/route.ts +85 -0
  376. package/src/modules/cpq/api/quotes/price/route.ts +81 -0
  377. package/src/modules/cpq/api/quotes/route.ts +114 -0
  378. package/src/modules/cpq/api/quotes/validate-relationships/route.ts +100 -0
  379. package/src/modules/cpq/api/resolveQuotingService.ts +11 -0
  380. package/src/modules/cpq/api/wizards/resolve/route.ts +39 -0
  381. package/src/modules/cpq/api/wizards/route.ts +127 -0
  382. package/src/modules/cpq/backend/cpq/inventory/AssetsTable.tsx +166 -0
  383. package/src/modules/cpq/backend/cpq/inventory/SubscriptionsTable.tsx +251 -0
  384. package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.ts +9 -0
  385. package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.tsx +440 -0
  386. package/src/modules/cpq/backend/cpq/inventory/page.meta.ts +16 -0
  387. package/src/modules/cpq/backend/cpq/inventory/page.tsx +49 -0
  388. package/src/modules/cpq/backend/cpq/inventory/shared.tsx +32 -0
  389. package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.ts +9 -0
  390. package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.tsx +1085 -0
  391. package/src/modules/cpq/backend/cpq/offerings/[id]/page.tsx +1165 -0
  392. package/src/modules/cpq/backend/cpq/offerings/page.meta.ts +16 -0
  393. package/src/modules/cpq/backend/cpq/offerings/page.tsx +468 -0
  394. package/src/modules/cpq/backend/cpq/orders/[id]/page.tsx +921 -0
  395. package/src/modules/cpq/backend/cpq/orders/page.meta.ts +16 -0
  396. package/src/modules/cpq/backend/cpq/orders/page.tsx +182 -0
  397. package/src/modules/cpq/backend/cpq/price-rules/PriceRuleForm.tsx +310 -0
  398. package/src/modules/cpq/backend/cpq/price-rules/[id]/page.meta.ts +9 -0
  399. package/src/modules/cpq/backend/cpq/price-rules/[id]/page.tsx +472 -0
  400. package/src/modules/cpq/backend/cpq/price-rules/page.meta.ts +16 -0
  401. package/src/modules/cpq/backend/cpq/price-rules/page.tsx +253 -0
  402. package/src/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.tsx +431 -0
  403. package/src/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.tsx +122 -0
  404. package/src/modules/cpq/backend/cpq/pricing/[id]/page.tsx +588 -0
  405. package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.ts +90 -0
  406. package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.ts +338 -0
  407. package/src/modules/cpq/backend/cpq/pricing/page.meta.ts +16 -0
  408. package/src/modules/cpq/backend/cpq/pricing/page.tsx +111 -0
  409. package/src/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.tsx +737 -0
  410. package/src/modules/cpq/backend/cpq/quotes/[id]/page.tsx +1721 -0
  411. package/src/modules/cpq/backend/cpq/quotes/page.meta.ts +16 -0
  412. package/src/modules/cpq/backend/cpq/quotes/page.tsx +370 -0
  413. package/src/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.tsx +300 -0
  414. package/src/modules/cpq/backend/cpq/specifications/[id]/page.tsx +1722 -0
  415. package/src/modules/cpq/backend/cpq/specifications/page.meta.ts +16 -0
  416. package/src/modules/cpq/backend/cpq/specifications/page.tsx +191 -0
  417. package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.tsx +319 -0
  418. package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/page.tsx +234 -0
  419. package/src/modules/cpq/backend/cpq/wizards/page.meta.ts +16 -0
  420. package/src/modules/cpq/backend/cpq/wizards/page.tsx +141 -0
  421. package/src/modules/cpq/ce.ts +150 -0
  422. package/src/modules/cpq/cli.ts +10 -0
  423. package/src/modules/cpq/components/CpqListView.tsx +431 -0
  424. package/src/modules/cpq/components/NumberInput.tsx +166 -0
  425. package/src/modules/cpq/components/StatusPath.tsx +116 -0
  426. package/src/modules/cpq/components/statusMaps.ts +148 -0
  427. package/src/modules/cpq/components/useCpqRowActions.tsx +183 -0
  428. package/src/modules/cpq/data/__tests__/validators.arc.test.ts +271 -0
  429. package/src/modules/cpq/data/__tests__/validators.test.ts +782 -0
  430. package/src/modules/cpq/data/entities.ts +1467 -0
  431. package/src/modules/cpq/data/validators.ts +663 -0
  432. package/src/modules/cpq/di.ts +70 -0
  433. package/src/modules/cpq/events.ts +62 -0
  434. package/src/modules/cpq/index.ts +15 -0
  435. package/src/modules/cpq/lib/seeds/__tests__/api.test.ts +86 -0
  436. package/src/modules/cpq/lib/seeds/__tests__/tenant-provisioning.test.ts +349 -0
  437. package/src/modules/cpq/lib/seeds/api.ts +119 -0
  438. package/src/modules/cpq/lib/seeds/tenant-provisioning.ts +239 -0
  439. package/src/modules/cpq/lib/seeds.ts +18 -0
  440. package/src/modules/cpq/migrations/.snapshot-open-mercato.json +7473 -0
  441. package/src/modules/cpq/migrations/Migration20260220220000_cpq.ts +51 -0
  442. package/src/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.ts +70 -0
  443. package/src/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.ts +15 -0
  444. package/src/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.ts +73 -0
  445. package/src/modules/cpq/migrations/Migration20260402000000_cpq_workflows.ts +59 -0
  446. package/src/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.ts +30 -0
  447. package/src/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.ts +36 -0
  448. package/src/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.ts +33 -0
  449. package/src/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.ts +22 -0
  450. package/src/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.ts +56 -0
  451. package/src/modules/cpq/migrations/Migration20260410100000_cpq_inventory.ts +118 -0
  452. package/src/modules/cpq/migrations/Migration20260411000000_cpq_orders.ts +62 -0
  453. package/src/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.ts +33 -0
  454. package/src/modules/cpq/migrations/Migration20260504064621_cpq_arc.ts +68 -0
  455. package/src/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.ts +30 -0
  456. package/src/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.ts +27 -0
  457. package/src/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.ts +82 -0
  458. package/src/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.ts +52 -0
  459. package/src/modules/cpq/services/__tests__/_helpers/mockEm.ts +59 -0
  460. package/src/modules/cpq/services/__tests__/cpqBundleService.test.ts +661 -0
  461. package/src/modules/cpq/services/__tests__/cpqInventoryService.arc.test.ts +357 -0
  462. package/src/modules/cpq/services/__tests__/cpqInventoryService.test.ts +718 -0
  463. package/src/modules/cpq/services/__tests__/cpqOrderService.test.ts +603 -0
  464. package/src/modules/cpq/services/__tests__/cpqPricingService.test.ts +1012 -0
  465. package/src/modules/cpq/services/__tests__/cpqProductService.test.ts +603 -0
  466. package/src/modules/cpq/services/__tests__/cpqQuotingService.arc.test.ts +143 -0
  467. package/src/modules/cpq/services/__tests__/cpqQuotingService.test.ts +658 -0
  468. package/src/modules/cpq/services/__tests__/cpqValidationService.test.ts +811 -0
  469. package/src/modules/cpq/services/__tests__/cpqWizardService.test.ts +389 -0
  470. package/src/modules/cpq/services/__tests__/types.test.ts +359 -0
  471. package/src/modules/cpq/services/cpqBundleService.ts +671 -0
  472. package/src/modules/cpq/services/cpqInventoryService.ts +1929 -0
  473. package/src/modules/cpq/services/cpqOrderService.ts +1230 -0
  474. package/src/modules/cpq/services/cpqPricingService.ts +412 -0
  475. package/src/modules/cpq/services/cpqProductService.ts +311 -0
  476. package/src/modules/cpq/services/cpqQuotingService.ts +2638 -0
  477. package/src/modules/cpq/services/cpqValidationService.ts +323 -0
  478. package/src/modules/cpq/services/cpqWizardService.ts +204 -0
  479. package/src/modules/cpq/services/types.ts +303 -0
  480. package/src/modules/cpq/setup.ts +63 -0
  481. package/src/modules/cpq/subscribers/subscription-amended-log.ts +20 -0
  482. package/src/modules/cpq/subscribers/subscription-cancelled-log.ts +19 -0
  483. package/src/modules/cpq/subscribers/subscription-merged-log.ts +22 -0
  484. package/src/modules/cpq/subscribers/subscription-renewed-log.ts +18 -0
  485. package/src/modules/cpq/subscribers/subscription-superseded-log.ts +19 -0
  486. package/src/modules/cpq/widgets/injection/customer-inventory/widget.client.tsx +339 -0
  487. package/src/modules/cpq/widgets/injection/customer-inventory/widget.ts +16 -0
  488. package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.client.tsx +96 -0
  489. package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.ts +16 -0
  490. package/src/modules/cpq/widgets/injection/quote-configurator/widget.client.tsx +265 -0
  491. package/src/modules/cpq/widgets/injection/quote-configurator/widget.ts +16 -0
  492. package/src/modules/cpq/widgets/injection-table.ts +42 -0
  493. package/src/modules/cpq/workflows/WizardRunner.tsx +158 -0
  494. package/src/modules/cpq/workflows/WizardTrigger.tsx +142 -0
  495. package/src/modules/cpq/workflows/engine.tsx +278 -0
  496. package/src/modules/cpq/workflows/registry.ts +15 -0
  497. package/src/modules/cpq/workflows/steps/CustomerSelectStep.tsx +136 -0
  498. package/src/modules/cpq/workflows/steps/InventorySelectStep.tsx +34 -0
  499. package/src/modules/cpq/workflows/steps/ItemListStep.tsx +146 -0
  500. package/src/modules/cpq/workflows/steps/OfferingSelectStep.tsx +438 -0
  501. package/src/modules/cpq/workflows/steps/ProductConfigureStep.tsx +287 -0
  502. package/src/modules/cpq/workflows/steps/ReviewStep.tsx +219 -0
  503. package/src/modules/cpq/workflows/steps/index.ts +51 -0
  504. package/src/modules/cpq/workflows/types.ts +102 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/modules/cpq/backend/cpq/pricing/%5Bid%5D/page.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useParams, useRouter } from 'next/navigation'\nimport { Alert } from '@open-mercato/ui/primitives/alert'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport { Download, Trash2, Upload } from 'lucide-react'\nimport { EntriesEditor, type Entry } from './EntriesEditor'\nimport { exportPricingTableToXlsx } from './xlsxExport'\nimport {\n commitImportDiff,\n parsePricingTableXlsx,\n type ImportDiff,\n} from './xlsxImport'\nimport { ImportPreview } from './ImportPreview'\n\ntype Dimension = { key: string; label: string }\ntype PriceColumn = { key: string; label: string }\n\ntype PricingTable = {\n id: string\n code: string\n name: string\n dimensions: Dimension[]\n priceColumns: PriceColumn[]\n currencyCodeList: string[]\n isActive: boolean\n}\n\nconst EMPTY_TABLE: PricingTable = {\n id: '',\n code: '',\n name: '',\n dimensions: [],\n priceColumns: [],\n currencyCodeList: ['USD'],\n isActive: true,\n}\n\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\nexport default function PricingTableDetailPage(props: { params?: { id?: string } }) {\n const t = useT()\n const router = useRouter()\n const urlParams = useParams()\n const id = (props.params?.id ?? urlParams?.id) as string\n const isNew = id === 'new'\n\n const [table, setTable] = React.useState<PricingTable>(EMPTY_TABLE)\n const [entries, setEntries] = React.useState<Entry[]>([])\n const [loading, setLoading] = React.useState(!isNew)\n const [error, setError] = React.useState<string | null>(null)\n const [mode, setMode] = React.useState<'view' | 'edit'>(isNew ? 'edit' : 'view')\n const [draft, setDraft] = React.useState<PricingTable>(EMPTY_TABLE)\n const [saving, setSaving] = React.useState(false)\n\n // Import state\n const fileInputRef = React.useRef<HTMLInputElement>(null)\n const [importDiff, setImportDiff] = React.useState<ImportDiff | null>(null)\n const [importApplying, setImportApplying] = React.useState(false)\n\n // \u2500\u2500\u2500 Load \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n const load = React.useCallback(async () => {\n if (isNew) return\n if (!id || !UUID_RE.test(id)) {\n setError('Invalid pricing table ID')\n setLoading(false)\n return\n }\n setLoading(true)\n try {\n const res = await fetch(`/api/cpq/pricing-tables?id=${encodeURIComponent(id)}`)\n if (!res.ok) {\n setError('Pricing table not found')\n return\n }\n const data = await res.json()\n const loaded: PricingTable = {\n id: data.id,\n code: data.code,\n name: data.name,\n dimensions: data.dimensions ?? [],\n priceColumns: data.priceColumns ?? [],\n currencyCodeList: data.currencyCodeList ?? ['USD'],\n isActive: data.isActive,\n }\n setTable(loaded)\n setDraft(loaded)\n setEntries(data.entries ?? [])\n } catch (err) {\n console.error('Failed to load pricing table', err)\n setError('Failed to load')\n } finally {\n setLoading(false)\n }\n }, [id, isNew])\n\n React.useEffect(() => {\n void load()\n }, [load])\n\n // \u2500\u2500\u2500 Config CRUD \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\n const startEdit = () => {\n setDraft(table)\n setMode('edit')\n setError(null)\n }\n\n const cancelEdit = () => {\n if (isNew) {\n router.push('/backend/cpq/pricing')\n return\n }\n setDraft(table)\n setMode('view')\n setError(null)\n }\n\n // Mirror V-PT-1 from validators.ts so the user gets feedback before the\n // server rejects the payload.\n const configValidationError = React.useMemo(() => {\n if (!draft.code.trim()) return 'Code is required'\n if (!draft.name.trim()) return 'Name is required'\n if (draft.currencyCodeList.length === 0) return 'At least one currency is required'\n const checkList = (items: Array<{ key: string; label: string }>, label: string): string | null => {\n const seen = new Set<string>()\n for (let i = 0; i < items.length; i++) {\n const item = items[i]\n if (!item.key.trim()) return `${label} #${i + 1}: key is required`\n if (!item.label.trim()) return `${label} #${i + 1}: label is required`\n if (seen.has(item.key)) return `${label}: duplicate key \"${item.key}\"`\n seen.add(item.key)\n }\n return null\n }\n return checkList(draft.dimensions, 'Dimension') ?? checkList(draft.priceColumns, 'Price Column')\n }, [draft])\n\n const saveConfig = async () => {\n if (configValidationError) {\n setError(configValidationError)\n return\n }\n setSaving(true)\n setError(null)\n try {\n const payload = {\n code: draft.code,\n name: draft.name,\n dimensions: draft.dimensions,\n priceColumns: draft.priceColumns,\n currencyCodeList: draft.currencyCodeList,\n isActive: draft.isActive,\n }\n const res = await fetch('/api/cpq/pricing-tables', {\n method: isNew ? 'POST' : 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(isNew ? payload : { id, ...payload }),\n })\n if (!res.ok) {\n const body = await res.json().catch(() => ({}))\n setError(body.error ?? `Failed to ${isNew ? 'create' : 'save'} pricing table`)\n return\n }\n const saved = await res.json()\n if (isNew) {\n router.push(`/backend/cpq/pricing/${saved.id}`)\n } else {\n setTable({ ...draft, id })\n setMode('view')\n }\n } catch (err) {\n console.error('Failed to save', err)\n setError('Failed to save')\n } finally {\n setSaving(false)\n }\n }\n\n // \u2500\u2500\u2500 Excel import \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\n const handleImportFile = async (file: File) => {\n setError(null)\n const r = await parsePricingTableXlsx(\n file,\n {\n dimensions: table.dimensions,\n priceColumns: table.priceColumns,\n currencyCodeList: table.currencyCodeList,\n },\n entries,\n )\n if (!r.ok) {\n setError(r.error)\n return\n }\n setImportDiff(r.diff)\n }\n\n const applyImportDiff = async () => {\n if (!importDiff) return\n setImportApplying(true)\n setError(null)\n try {\n const r = await commitImportDiff(table.id, importDiff)\n if (!r.ok) {\n setError(r.error)\n return\n }\n setImportDiff(null)\n await load()\n } finally {\n setImportApplying(false)\n }\n }\n\n const cancelImport = () => {\n setImportDiff(null)\n if (fileInputRef.current) fileInputRef.current.value = ''\n }\n\n const deleteTable = async () => {\n if (!window.confirm(t('cpq.pricing.confirmDelete', 'Delete this pricing table and all its entries?'))) return\n try {\n const res = await fetch('/api/cpq/pricing-tables', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id }),\n })\n if (res.ok) {\n router.push('/backend/cpq/pricing')\n } else {\n const body = await res.json().catch(() => ({}))\n setError(body.error ?? 'Failed to delete')\n }\n } catch {\n setError('Failed to delete')\n }\n }\n\n // \u2500\u2500\u2500 Render \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n if (loading) {\n return <div className=\"text-sm text-muted-foreground\">{t('common.loading', 'Loading...')}</div>\n }\n\n if (error && !isNew && !table.id) {\n return (\n <div className=\"space-y-4\">\n <button\n onClick={() => router.push('/backend/cpq/pricing')}\n className=\"text-sm text-muted-foreground hover:text-foreground\"\n >\n \u2190 {t('common.back', 'Back')}\n </button>\n <Alert variant=\"destructive\">{error}</Alert>\n </div>\n )\n }\n\n const editing = mode === 'edit'\n const view = editing ? draft : table\n\n return (\n <div className=\"space-y-6\">\n {/* Header */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-3\">\n <button\n onClick={() => router.push('/backend/cpq/pricing')}\n className=\"text-sm text-muted-foreground hover:text-foreground\"\n >\n \u2190 {t('common.back', 'Back')}\n </button>\n <h1 className=\"text-2xl font-bold\">\n {isNew ? t('cpq.pricing.new', 'New Pricing Table') : table.name}\n </h1>\n {!isNew && (\n <Tag variant={table.isActive ? 'success' : 'neutral'} dot>\n {table.isActive ? t('common.active', 'Active') : t('common.inactive', 'Inactive')}\n </Tag>\n )}\n </div>\n {!isNew && mode === 'view' && (\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => exportPricingTableToXlsx(table, entries)}\n title={t('cpq.pricing.export.tooltip', 'Download this pricing table as an Excel file')}\n >\n <Download className=\"h-4 w-4 mr-1.5\" />\n {t('cpq.pricing.export.button', 'Export to Excel')}\n </Button>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => fileInputRef.current?.click()}\n title={t('cpq.pricing.import.tooltip', 'Upload an Excel file to add / update / delete entries')}\n disabled={importDiff !== null}\n >\n <Upload className=\"h-4 w-4 mr-1.5\" />\n {t('cpq.pricing.import.button', 'Import from Excel')}\n </Button>\n <input\n ref={fileInputRef}\n type=\"file\"\n accept=\".xlsx,.xls,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"\n className=\"hidden\"\n onChange={(e) => {\n const file = e.target.files?.[0]\n if (file) void handleImportFile(file)\n // reset so re-uploading the same file fires onChange again\n e.target.value = ''\n }}\n />\n <Button type=\"button\" onClick={startEdit}>{t('common.edit', 'Edit')}</Button>\n <Button type=\"button\" variant=\"destructive\" onClick={deleteTable}>\n {t('common.delete', 'Delete')}\n </Button>\n </div>\n )}\n </div>\n\n {error && <Alert variant=\"destructive\">{error}</Alert>}\n\n {/* Excel import preview \u2014 shown after a file is parsed, hides until user confirms / cancels */}\n {importDiff && (\n <ImportPreview\n diff={importDiff}\n saving={importApplying}\n onConfirm={applyImportDiff}\n onCancel={cancelImport}\n />\n )}\n\n {/* Configuration section */}\n <div className=\"rounded-lg border bg-card p-6 space-y-4\">\n <h2 className=\"text-lg font-semibold\">Configuration</h2>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 gap-4\">\n <ConfigField label=\"Code\" required>\n {editing ? (\n <Input\n value={view.code}\n onChange={(e) => setDraft({ ...draft, code: e.target.value })}\n placeholder=\"e.g. cloud-connect-pricing\"\n />\n ) : (\n <span className=\"font-mono text-sm\">{view.code}</span>\n )}\n </ConfigField>\n <ConfigField label=\"Name\" required>\n {editing ? (\n <Input\n value={view.name}\n onChange={(e) => setDraft({ ...draft, name: e.target.value })}\n placeholder=\"Cloud Connect Pricing\"\n />\n ) : (\n <span className=\"font-medium text-sm\">{view.name}</span>\n )}\n </ConfigField>\n <ConfigField label=\"Currencies (comma-separated)\" required>\n {editing ? (\n <Input\n value={view.currencyCodeList.join(', ')}\n onChange={(e) =>\n setDraft({\n ...draft,\n currencyCodeList: e.target.value\n .split(',')\n .map((s) => s.trim().toUpperCase())\n .filter(Boolean),\n })\n }\n placeholder=\"USD, EUR\"\n />\n ) : (\n <span className=\"text-sm\">{view.currencyCodeList.join(', ') || '\u2014'}</span>\n )}\n </ConfigField>\n <ConfigField label=\"Active\">\n {editing ? (\n <label className=\"flex items-center gap-2 text-sm\">\n <input\n type=\"checkbox\"\n checked={view.isActive}\n onChange={(e) => setDraft({ ...draft, isActive: e.target.checked })}\n className=\"rounded border\"\n />\n {view.isActive ? 'Yes' : 'No'}\n </label>\n ) : (\n <span className=\"text-sm\">{view.isActive ? 'Yes' : 'No'}</span>\n )}\n </ConfigField>\n </div>\n\n <KeyLabelListEditor\n title=\"Dimensions\"\n description=\"Lookup keys for matching entries (e.g. region, tier). Leave empty if you use tier ranges only.\"\n items={view.dimensions}\n editing={editing}\n onChange={(dimensions) => setDraft({ ...draft, dimensions })}\n />\n\n <KeyLabelListEditor\n title=\"Price Columns\"\n description=\"Each price column becomes a numeric field on every entry. Charges reference one column by its key.\"\n items={view.priceColumns}\n editing={editing}\n onChange={(priceColumns) => setDraft({ ...draft, priceColumns })}\n />\n\n {editing && (\n <>\n {configValidationError && (\n <Alert variant=\"destructive\">{configValidationError}</Alert>\n )}\n <div className=\"flex gap-2 pt-2 border-t\">\n <Button\n type=\"button\"\n onClick={saveConfig}\n disabled={saving || configValidationError !== null}\n >\n {saving ? 'Saving...' : (isNew ? 'Create Pricing Table' : 'Save')}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={cancelEdit} disabled={saving}>\n Cancel\n </Button>\n </div>\n </>\n )}\n </div>\n\n {/* Entries section \u2014 only when table exists */}\n {!isNew && (\n <EntriesEditor\n table={{\n id: table.id,\n dimensions: table.dimensions,\n priceColumns: table.priceColumns,\n currencyCodeList: table.currencyCodeList,\n }}\n initialEntries={entries}\n onSaved={() => {\n void load()\n }}\n />\n )}\n </div>\n )\n}\n\n// \u2500\u2500\u2500 ConfigField \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction ConfigField({\n label,\n required,\n children,\n}: {\n label: string\n required?: boolean\n children: React.ReactNode\n}) {\n return (\n <div>\n <div className=\"text-muted-foreground text-xs mb-1\">\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </div>\n <div>{children}</div>\n </div>\n )\n}\n\n// \u2500\u2500\u2500 KeyLabelListEditor (dimensions / price columns) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction KeyLabelListEditor({\n title,\n description,\n items,\n editing,\n onChange,\n}: {\n title: string\n description: string\n items: Array<{ key: string; label: string }>\n editing: boolean\n onChange: (next: Array<{ key: string; label: string }>) => void\n}) {\n return (\n <div className=\"space-y-2\">\n <div>\n <div className=\"text-sm font-medium\">{title}</div>\n <p className=\"text-xs text-muted-foreground\">{description}</p>\n </div>\n\n {items.length === 0 && !editing && (\n <div className=\"text-xs text-muted-foreground italic\">\u2014</div>\n )}\n\n {items.length > 0 && (\n <div className=\"rounded-md border\">\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b bg-muted/30 text-xs\">\n <th className=\"px-3 py-2 text-left font-medium\">\n Key {editing && <span className=\"text-destructive\">*</span>}\n </th>\n <th className=\"px-3 py-2 text-left font-medium\">\n Label {editing && <span className=\"text-destructive\">*</span>}\n </th>\n {editing && <th className=\"px-3 py-2 w-8\" aria-label=\"Actions\" />}\n </tr>\n </thead>\n <tbody>\n {items.map((item, idx) => (\n <tr key={idx} className=\"border-b last:border-0\">\n <td className=\"px-3 py-2\">\n {editing ? (\n <Input\n value={item.key}\n onChange={(e) => {\n const next = [...items]\n next[idx] = { ...item, key: e.target.value }\n onChange(next)\n }}\n placeholder=\"e.g. region\"\n className=\"h-8\"\n />\n ) : (\n <span className=\"font-mono text-xs\">{item.key}</span>\n )}\n </td>\n <td className=\"px-3 py-2\">\n {editing ? (\n <Input\n value={item.label}\n onChange={(e) => {\n const next = [...items]\n next[idx] = { ...item, label: e.target.value }\n onChange(next)\n }}\n placeholder=\"Region\"\n className=\"h-8\"\n />\n ) : (\n <span>{item.label}</span>\n )}\n </td>\n {editing && (\n <td className=\"px-3 py-2\">\n <button\n type=\"button\"\n onClick={() => onChange(items.filter((_, i) => i !== idx))}\n className=\"text-destructive hover:bg-destructive/10 rounded p-1\"\n aria-label=\"Remove\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </button>\n </td>\n )}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n\n {editing && (\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => onChange([...items, { key: '', label: '' }])}\n >\n + Add {title.slice(0, -1)}\n </Button>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": ";AAuPW,SA6KD,UA7KC,KAMH,YANG;AAtPX,YAAY,WAAW;AACvB,SAAS,Y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portPricingTableToXlsx(table, entries) {
3
+ const hasTiers = entries.some((e) => e.tierNumber != null);
4
+ const headers = ["id"];
5
+ if (hasTiers) {
6
+ headers.push("tier_number", "range_from", "range_to");
7
+ }
8
+ for (const d of table.dimensions) headers.push(d.key);
9
+ for (const c of table.priceColumns) headers.push(c.key);
10
+ headers.push("currency_code");
11
+ const rows = entries.map((e) => {
12
+ const row = { id: e.id };
13
+ if (hasTiers) {
14
+ row.tier_number = e.tierNumber ?? "";
15
+ row.range_from = e.rangeFrom ?? "";
16
+ row.range_to = e.rangeTo ?? "";
17
+ }
18
+ for (const d of table.dimensions) {
19
+ row[d.key] = e.dimensionValues?.[d.key] ?? "";
20
+ }
21
+ for (const c of table.priceColumns) {
22
+ row[c.key] = e.prices?.[c.key] ?? "";
23
+ }
24
+ row.currency_code = e.currencyCode;
25
+ return row;
26
+ });
27
+ const worksheet = XLSX.utils.json_to_sheet(rows, { header: headers });
28
+ const labelRow = {};
29
+ for (const d of table.dimensions) labelRow[d.key] = d.label;
30
+ for (const c of table.priceColumns) labelRow[c.key] = c.label;
31
+ XLSX.utils.sheet_add_aoa(
32
+ worksheet,
33
+ [headers.map((h) => labelRow[h] ?? h)],
34
+ { origin: "A1" }
35
+ );
36
+ const workbook = XLSX.utils.book_new();
37
+ XLSX.utils.book_append_sheet(workbook, worksheet, sheetSafeName(table.code || table.name || "Pricing"));
38
+ const filename = `${slugForFile(table.code || table.name || "pricing-table")}.xlsx`;
39
+ XLSX.writeFile(workbook, filename);
40
+ }
41
+ function sheetSafeName(name) {
42
+ return name.replace(/[\[\]:*?/\\]/g, "_").slice(0, 31);
43
+ }
44
+ function slugForFile(name) {
45
+ return name.toLowerCase().replace(/[^a-z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "") || "pricing-table";
46
+ }
47
+ export {
48
+ exportPricingTableToXlsx
49
+ };
50
+ //# sourceMappingURL=xlsxExport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/modules/cpq/backend/cpq/pricing/%5Bid%5D/xlsxExport.ts"],
4
+ "sourcesContent": ["// Browser-side Excel export for pricing tables.\n//\n// Single sheet, dimensions-as-columns per user spec. Tier columns are\n// emitted only when at least one entry is tiered, to keep the file\n// uncluttered for dimensions-only tables. Each price column becomes one\n// numeric column.\n\nimport * as XLSX from 'xlsx'\n\ntype Dimension = { key: string; label: string }\ntype PriceColumn = { key: string; label: string }\n\ntype Entry = {\n id: string\n dimensionValues: Record<string, string>\n tierNumber: number | null\n rangeFrom: string | null\n rangeTo: string | null\n currencyCode: string\n prices: Record<string, number>\n}\n\ntype Table = {\n code: string\n name: string\n dimensions: Dimension[]\n priceColumns: PriceColumn[]\n currencyCodeList: string[]\n}\n\nexport function exportPricingTableToXlsx(table: Table, entries: Entry[]): void {\n const hasTiers = entries.some((e) => e.tierNumber != null)\n\n // Column order: id, [tier columns?], dimensions, price columns, currency.\n // The id column is intentionally last-of-leading so it doesn't bury data,\n // but kept exposed so a future re-import can match rows by UUID.\n const headers: string[] = ['id']\n if (hasTiers) {\n headers.push('tier_number', 'range_from', 'range_to')\n }\n for (const d of table.dimensions) headers.push(d.key)\n for (const c of table.priceColumns) headers.push(c.key)\n headers.push('currency_code')\n\n const rows: Array<Record<string, unknown>> = entries.map((e) => {\n const row: Record<string, unknown> = { id: e.id }\n if (hasTiers) {\n row.tier_number = e.tierNumber ?? ''\n row.range_from = e.rangeFrom ?? ''\n row.range_to = e.rangeTo ?? ''\n }\n for (const d of table.dimensions) {\n row[d.key] = e.dimensionValues?.[d.key] ?? ''\n }\n for (const c of table.priceColumns) {\n row[c.key] = e.prices?.[c.key] ?? ''\n }\n row.currency_code = e.currencyCode\n return row\n })\n\n const worksheet = XLSX.utils.json_to_sheet(rows, { header: headers })\n\n // Replace technical keys with human labels in the header row so the file\n // reads naturally in Excel. The first row is the only one with labels;\n // keep `id` / tier_* / currency_code as-is because they have no label.\n const labelRow: Record<string, string> = {}\n for (const d of table.dimensions) labelRow[d.key] = d.label\n for (const c of table.priceColumns) labelRow[c.key] = c.label\n XLSX.utils.sheet_add_aoa(\n worksheet,\n [headers.map((h) => labelRow[h] ?? h)],\n { origin: 'A1' },\n )\n\n const workbook = XLSX.utils.book_new()\n XLSX.utils.book_append_sheet(workbook, worksheet, sheetSafeName(table.code || table.name || 'Pricing'))\n\n const filename = `${slugForFile(table.code || table.name || 'pricing-table')}.xlsx`\n XLSX.writeFile(workbook, filename)\n}\n\n// Excel sheet names: max 31 chars, no `[]:*?/\\`.\nfunction sheetSafeName(name: string): string {\n return name.replace(/[\\[\\]:*?/\\\\]/g, '_').slice(0, 31)\n}\n\nfunction slugForFile(name: string): string {\n return name.toLowerCase().replace(/[^a-z0-9-_.]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '') || 'pricing-table'\n}\n"],
5
+ "mappings": "AAOA,YAAY,UAAU;AAuBf,SAAS,yBAAyB,OAAc,SAAwB;AAC7E,QAAM,WAAW,QAAQ,KAAK,CAAC,MAAM,EAAE,cAAc,IAAI;AAKzD,QAAM,UAAoB,CAAC,IAAI;AAC/B,MAAI,UAAU;AACZ,YAAQ,KAAK,eAAe,cAAc,UAAU;AAAA,EACtD;AACA,aAAW,KAAK,MAAM,WAAY,SAAQ,KAAK,EAAE,GAAG;AACpD,aAAW,KAAK,MAAM,aAAc,SAAQ,KAAK,EAAE,GAAG;AACtD,UAAQ,KAAK,eAAe;AAE5B,QAAM,OAAuC,QAAQ,IAAI,CAAC,MAAM;AAC9D,UAAM,MAA+B,EAAE,IAAI,EAAE,GAAG;AAChD,QAAI,UAAU;AACZ,UAAI,cAAc,EAAE,cAAc;AAClC,UAAI,aAAa,EAAE,aAAa;AAChC,UAAI,WAAW,EAAE,WAAW;AAAA,IAC9B;AACA,eAAW,KAAK,MAAM,YAAY;AAChC,UAAI,EAAE,GAAG,IAAI,EAAE,kBAAkB,EAAE,GAAG,KAAK;AAAA,IAC7C;AACA,eAAW,KAAK,MAAM,cAAc;AAClC,UAAI,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK;AAAA,IACpC;AACA,QAAI,gBAAgB,EAAE;AACtB,WAAO;AAAA,EACT,CAAC;AAED,QAAM,YAAY,KAAK,MAAM,cAAc,MAAM,EAAE,QAAQ,QAAQ,CAAC;AAKpE,QAAM,WAAmC,CAAC;AAC1C,aAAW,KAAK,MAAM,WAAY,UAAS,EAAE,GAAG,IAAI,EAAE;AACtD,aAAW,KAAK,MAAM,aAAc,UAAS,EAAE,GAAG,IAAI,EAAE;AACxD,OAAK,MAAM;AAAA,IACT;AAAA,IACA,CAAC,QAAQ,IAAI,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,CAAC;AAAA,IACrC,EAAE,QAAQ,KAAK;AAAA,EACjB;AAEA,QAAM,WAAW,KAAK,MAAM,SAAS;AACrC,OAAK,MAAM,kBAAkB,UAAU,WAAW,cAAc,MAAM,QAAQ,MAAM,QAAQ,SAAS,CAAC;AAEtG,QAAM,WAAW,GAAG,YAAY,MAAM,QAAQ,MAAM,QAAQ,eAAe,CAAC;AAC5E,OAAK,UAAU,UAAU,QAAQ;AACnC;AAGA,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,iBAAiB,GAAG,EAAE,MAAM,GAAG,EAAE;AACvD;AAEA,SAAS,YAAY,MAAsB;AACzC,SAAO,KAAK,YAAY,EAAE,QAAQ,iBAAiB,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,UAAU,EAAE,KAAK;AACvG;",
6
+ "names": []
7
+ }
@@ -0,0 +1,249 @@
1
+ import * as XLSX from "xlsx";
2
+ async function parsePricingTableXlsx(file, table, existingEntries) {
3
+ let workbook;
4
+ try {
5
+ const buffer = await file.arrayBuffer();
6
+ workbook = XLSX.read(buffer, { type: "array" });
7
+ } catch (err) {
8
+ return { ok: false, error: err instanceof Error ? `Failed to read file: ${err.message}` : "Failed to read file" };
9
+ }
10
+ const sheetName = workbook.SheetNames[0];
11
+ if (!sheetName) return { ok: false, error: "Workbook has no sheets" };
12
+ const sheet = workbook.Sheets[sheetName];
13
+ const rows = XLSX.utils.sheet_to_json(sheet, {
14
+ defval: "",
15
+ raw: false
16
+ // keep strings, parse numbers ourselves
17
+ });
18
+ if (rows.length === 0) {
19
+ return { ok: false, error: "Sheet has no data rows" };
20
+ }
21
+ const headerToKey = /* @__PURE__ */ new Map();
22
+ for (const d of table.dimensions) {
23
+ headerToKey.set(d.label.toLowerCase(), { kind: "dimension", key: d.key });
24
+ headerToKey.set(d.key.toLowerCase(), { kind: "dimension", key: d.key });
25
+ }
26
+ for (const c of table.priceColumns) {
27
+ headerToKey.set(c.label.toLowerCase(), { kind: "price", key: c.key });
28
+ headerToKey.set(c.key.toLowerCase(), { kind: "price", key: c.key });
29
+ }
30
+ const firstRow = rows[0];
31
+ const headers = Object.keys(firstRow);
32
+ const dimensionHeaders = [];
33
+ const priceHeaders = [];
34
+ let idHeader = null;
35
+ let tierHeader = null;
36
+ let rangeFromHeader = null;
37
+ let rangeToHeader = null;
38
+ let currencyHeader = null;
39
+ for (const header of headers) {
40
+ const lower = header.trim().toLowerCase();
41
+ if (lower === "id") {
42
+ idHeader = header;
43
+ continue;
44
+ }
45
+ if (lower === "tier_number" || lower === "tier #" || lower === "tier number") {
46
+ tierHeader = header;
47
+ continue;
48
+ }
49
+ if (lower === "range_from" || lower === "range from") {
50
+ rangeFromHeader = header;
51
+ continue;
52
+ }
53
+ if (lower === "range_to" || lower === "range to") {
54
+ rangeToHeader = header;
55
+ continue;
56
+ }
57
+ if (lower === "currency_code" || lower === "currency code" || lower === "currency") {
58
+ currencyHeader = header;
59
+ continue;
60
+ }
61
+ const mapped = headerToKey.get(lower);
62
+ if (!mapped) continue;
63
+ if (mapped.kind === "dimension") dimensionHeaders.push({ header, key: mapped.key });
64
+ else priceHeaders.push({ header, key: mapped.key });
65
+ }
66
+ const warnings = [];
67
+ const knownHeaders = new Set([
68
+ idHeader,
69
+ tierHeader,
70
+ rangeFromHeader,
71
+ rangeToHeader,
72
+ currencyHeader,
73
+ ...dimensionHeaders.map((d) => d.header),
74
+ ...priceHeaders.map((p) => p.header)
75
+ ].filter((h) => h !== null));
76
+ for (const h of headers) {
77
+ if (!knownHeaders.has(h)) warnings.push(`Ignored unknown column "${h}"`);
78
+ }
79
+ const missingDims = table.dimensions.filter((d) => !dimensionHeaders.some((h) => h.key === d.key));
80
+ const missingPrices = table.priceColumns.filter((c) => !priceHeaders.some((h) => h.key === c.key));
81
+ if (missingDims.length > 0) {
82
+ return { ok: false, error: `Missing dimension column(s): ${missingDims.map((d) => d.label).join(", ")}` };
83
+ }
84
+ if (missingPrices.length > 0) {
85
+ return { ok: false, error: `Missing price column(s): ${missingPrices.map((c) => c.label).join(", ")}` };
86
+ }
87
+ if (!currencyHeader) {
88
+ return { ok: false, error: 'Missing "currency_code" column' };
89
+ }
90
+ const parsed = [];
91
+ for (let i = 0; i < rows.length; i++) {
92
+ const raw = rows[i];
93
+ const rowNumber = i + 2;
94
+ const id = idHeader ? toStringOrNull(raw[idHeader]) : null;
95
+ const tierStr = tierHeader ? toStringOrNull(raw[tierHeader]) : null;
96
+ const rangeFromStr = rangeFromHeader ? toStringOrNull(raw[rangeFromHeader]) : null;
97
+ const rangeToStr = rangeToHeader ? toStringOrNull(raw[rangeToHeader]) : null;
98
+ const currency = toStringOrNull(raw[currencyHeader]) ?? "";
99
+ if (!currency) {
100
+ return { ok: false, error: `Row ${rowNumber}: missing currency_code` };
101
+ }
102
+ if (!table.currencyCodeList.includes(currency.toUpperCase())) {
103
+ return { ok: false, error: `Row ${rowNumber}: currency "${currency}" is not in the table's currency list (${table.currencyCodeList.join(", ")})` };
104
+ }
105
+ const tierNumber = tierStr ? Number(tierStr) : null;
106
+ if (tierNumber !== null && Number.isNaN(tierNumber)) {
107
+ return { ok: false, error: `Row ${rowNumber}: tier_number must be a number, got "${tierStr}"` };
108
+ }
109
+ const dimensionValues = {};
110
+ for (const { header, key } of dimensionHeaders) {
111
+ dimensionValues[key] = toStringOrNull(raw[header]) ?? "";
112
+ }
113
+ const prices = {};
114
+ for (const { header, key } of priceHeaders) {
115
+ const v = raw[header];
116
+ if (v === "" || v === null || v === void 0) {
117
+ prices[key] = 0;
118
+ continue;
119
+ }
120
+ const num = Number(v);
121
+ if (Number.isNaN(num)) {
122
+ return { ok: false, error: `Row ${rowNumber}: price column "${header}" must be a number, got "${String(v)}"` };
123
+ }
124
+ prices[key] = num;
125
+ }
126
+ parsed.push({
127
+ rowNumber,
128
+ id,
129
+ dimensionValues,
130
+ tierNumber,
131
+ rangeFrom: rangeFromStr,
132
+ rangeTo: rangeToStr,
133
+ currencyCode: currency.toUpperCase(),
134
+ prices
135
+ });
136
+ }
137
+ const existingById = new Map(existingEntries.map((e) => [e.id, e]));
138
+ const fileIds = new Set(parsed.map((p) => p.id).filter((id) => !!id));
139
+ const inserts = [];
140
+ const updates = [];
141
+ const unchanged = [];
142
+ for (const row of parsed) {
143
+ if (!row.id) {
144
+ inserts.push(row);
145
+ continue;
146
+ }
147
+ const existing = existingById.get(row.id);
148
+ if (!existing) {
149
+ warnings.push(`Row ${row.rowNumber}: id "${row.id}" not found in current entries \u2014 will be inserted as new`);
150
+ inserts.push({ ...row, id: null });
151
+ continue;
152
+ }
153
+ if (rowMatchesEntry(row, existing)) {
154
+ unchanged.push(existing);
155
+ } else {
156
+ updates.push({ before: existing, after: row });
157
+ }
158
+ }
159
+ const deletes = existingEntries.filter((e) => !fileIds.has(e.id));
160
+ return {
161
+ ok: true,
162
+ diff: { inserts, updates, deletes, unchanged, warnings }
163
+ };
164
+ }
165
+ async function commitImportDiff(pricingTableId, diff) {
166
+ if (diff.inserts.length > 0) {
167
+ const payload = diff.inserts.map((r) => ({
168
+ pricingTableId,
169
+ dimensionValues: r.dimensionValues,
170
+ tierNumber: r.tierNumber ?? void 0,
171
+ rangeFrom: r.rangeFrom !== null ? Number(r.rangeFrom) : void 0,
172
+ rangeTo: r.rangeTo !== null ? Number(r.rangeTo) : void 0,
173
+ currencyCode: r.currencyCode,
174
+ prices: r.prices
175
+ }));
176
+ const res = await fetch("/api/cpq/pricing-table-entries", {
177
+ method: "POST",
178
+ headers: { "Content-Type": "application/json" },
179
+ body: JSON.stringify(payload)
180
+ });
181
+ if (!res.ok) {
182
+ const body = await res.json().catch(() => ({}));
183
+ return { ok: false, error: body.error ?? "Failed to insert entries" };
184
+ }
185
+ }
186
+ for (const { before, after } of diff.updates) {
187
+ const res = await fetch("/api/cpq/pricing-table-entries", {
188
+ method: "PUT",
189
+ headers: { "Content-Type": "application/json" },
190
+ body: JSON.stringify({
191
+ id: before.id,
192
+ dimensionValues: after.dimensionValues,
193
+ tierNumber: after.tierNumber ?? null,
194
+ rangeFrom: after.rangeFrom !== null ? Number(after.rangeFrom) : null,
195
+ rangeTo: after.rangeTo !== null ? Number(after.rangeTo) : null,
196
+ currencyCode: after.currencyCode,
197
+ prices: after.prices
198
+ })
199
+ });
200
+ if (!res.ok) {
201
+ const body = await res.json().catch(() => ({}));
202
+ return { ok: false, error: body.error ?? `Failed to update entry ${before.id}` };
203
+ }
204
+ }
205
+ for (const entry of diff.deletes) {
206
+ const res = await fetch("/api/cpq/pricing-table-entries", {
207
+ method: "DELETE",
208
+ headers: { "Content-Type": "application/json" },
209
+ body: JSON.stringify({ id: entry.id })
210
+ });
211
+ if (!res.ok) {
212
+ const body = await res.json().catch(() => ({}));
213
+ return { ok: false, error: body.error ?? `Failed to delete entry ${entry.id}` };
214
+ }
215
+ }
216
+ return { ok: true };
217
+ }
218
+ function toStringOrNull(v) {
219
+ if (v === null || v === void 0) return null;
220
+ const s = String(v).trim();
221
+ return s === "" ? null : s;
222
+ }
223
+ function rowMatchesEntry(row, entry) {
224
+ if (row.currencyCode !== entry.currencyCode) return false;
225
+ if ((row.tierNumber ?? null) !== (entry.tierNumber ?? null)) return false;
226
+ if (!numericEqual(row.rangeFrom, entry.rangeFrom)) return false;
227
+ if (!numericEqual(row.rangeTo, entry.rangeTo)) return false;
228
+ const dimKeys = /* @__PURE__ */ new Set([...Object.keys(row.dimensionValues), ...Object.keys(entry.dimensionValues)]);
229
+ for (const k of dimKeys) {
230
+ if ((row.dimensionValues[k] ?? "") !== (entry.dimensionValues[k] ?? "")) return false;
231
+ }
232
+ const priceKeys = /* @__PURE__ */ new Set([...Object.keys(row.prices), ...Object.keys(entry.prices)]);
233
+ for (const k of priceKeys) {
234
+ if ((row.prices[k] ?? 0) !== (entry.prices[k] ?? 0)) return false;
235
+ }
236
+ return true;
237
+ }
238
+ function numericEqual(a, b) {
239
+ const an = a == null ? null : Number(a);
240
+ const bn = b == null ? null : Number(b);
241
+ if (an === null && bn === null) return true;
242
+ if (an === null || bn === null) return false;
243
+ return an === bn;
244
+ }
245
+ export {
246
+ commitImportDiff,
247
+ parsePricingTableXlsx
248
+ };
249
+ //# sourceMappingURL=xlsxImport.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../src/modules/cpq/backend/cpq/pricing/%5Bid%5D/xlsxImport.ts"],
4
+ "sourcesContent": ["// Browser-side Excel import for pricing tables.\n//\n// Parses an .xlsx produced by `exportPricingTableToXlsx` (or any sheet with\n// the matching column shape) and computes a diff against the current\n// in-memory entries. Reconciliation key is the `id` UUID column from the\n// export \u2014 rows without an id are treated as INSERTS, entries whose id is\n// absent from the file are treated as DELETES.\n\nimport * as XLSX from 'xlsx'\n\ntype Dimension = { key: string; label: string }\ntype PriceColumn = { key: string; label: string }\n\nexport type ImportEntry = {\n id: string\n dimensionValues: Record<string, string>\n tierNumber: number | null\n rangeFrom: string | null\n rangeTo: string | null\n currencyCode: string\n prices: Record<string, number>\n}\n\ntype TableShape = {\n dimensions: Dimension[]\n priceColumns: PriceColumn[]\n currencyCodeList: string[]\n}\n\ntype ParsedRow = {\n rowNumber: number // 1-indexed (excluding header)\n id: string | null\n dimensionValues: Record<string, string>\n tierNumber: number | null\n rangeFrom: string | null\n rangeTo: string | null\n currencyCode: string\n prices: Record<string, number>\n}\n\nexport type ImportDiff = {\n inserts: ParsedRow[]\n updates: Array<{ before: ImportEntry; after: ParsedRow }>\n deletes: ImportEntry[]\n unchanged: ImportEntry[]\n warnings: string[]\n}\n\nexport type ImportResult =\n | { ok: true; diff: ImportDiff }\n | { ok: false; error: string }\n\nexport async function parsePricingTableXlsx(\n file: File,\n table: TableShape,\n existingEntries: ImportEntry[],\n): Promise<ImportResult> {\n let workbook: XLSX.WorkBook\n try {\n const buffer = await file.arrayBuffer()\n workbook = XLSX.read(buffer, { type: 'array' })\n } catch (err) {\n return { ok: false, error: err instanceof Error ? `Failed to read file: ${err.message}` : 'Failed to read file' }\n }\n\n const sheetName = workbook.SheetNames[0]\n if (!sheetName) return { ok: false, error: 'Workbook has no sheets' }\n const sheet = workbook.Sheets[sheetName]\n\n // Two-row header strategy: row 1 is human labels (from export), row 2+ is\n // data. But during round-trip the original technical keys are not in the\n // file \u2014 only labels. Re-derive keys from the table's `dimensions` and\n // `priceColumns` by matching labels first; fall back to keys for the\n // fixed columns (id, tier_number, range_from, range_to, currency_code).\n const rows = XLSX.utils.sheet_to_json<Record<string, unknown>>(sheet, {\n defval: '',\n raw: false, // keep strings, parse numbers ourselves\n })\n\n if (rows.length === 0) {\n return { ok: false, error: 'Sheet has no data rows' }\n }\n\n // Build label\u2192key map for dimensions and price columns so we can match\n // either the label or the technical key (both are valid header forms).\n const headerToKey = new Map<string, { kind: 'dimension' | 'price'; key: string }>()\n for (const d of table.dimensions) {\n headerToKey.set(d.label.toLowerCase(), { kind: 'dimension', key: d.key })\n headerToKey.set(d.key.toLowerCase(), { kind: 'dimension', key: d.key })\n }\n for (const c of table.priceColumns) {\n headerToKey.set(c.label.toLowerCase(), { kind: 'price', key: c.key })\n headerToKey.set(c.key.toLowerCase(), { kind: 'price', key: c.key })\n }\n\n // Inspect first row to discover which technical keys each column maps to.\n const firstRow = rows[0]\n const headers = Object.keys(firstRow)\n const dimensionHeaders: Array<{ header: string; key: string }> = []\n const priceHeaders: Array<{ header: string; key: string }> = []\n let idHeader: string | null = null\n let tierHeader: string | null = null\n let rangeFromHeader: string | null = null\n let rangeToHeader: string | null = null\n let currencyHeader: string | null = null\n\n for (const header of headers) {\n const lower = header.trim().toLowerCase()\n if (lower === 'id') { idHeader = header; continue }\n if (lower === 'tier_number' || lower === 'tier #' || lower === 'tier number') { tierHeader = header; continue }\n if (lower === 'range_from' || lower === 'range from') { rangeFromHeader = header; continue }\n if (lower === 'range_to' || lower === 'range to') { rangeToHeader = header; continue }\n if (lower === 'currency_code' || lower === 'currency code' || lower === 'currency') { currencyHeader = header; continue }\n const mapped = headerToKey.get(lower)\n if (!mapped) continue // unknown column \u2014 silently ignored (with warning later)\n if (mapped.kind === 'dimension') dimensionHeaders.push({ header, key: mapped.key })\n else priceHeaders.push({ header, key: mapped.key })\n }\n\n const warnings: string[] = []\n\n // Unknown columns \u2192 warning (not error \u2014 Excel files often have stray\n // columns from user notes).\n const knownHeaders = new Set<string>([\n idHeader,\n tierHeader,\n rangeFromHeader,\n rangeToHeader,\n currencyHeader,\n ...dimensionHeaders.map((d) => d.header),\n ...priceHeaders.map((p) => p.header),\n ].filter((h): h is string => h !== null))\n for (const h of headers) {\n if (!knownHeaders.has(h)) warnings.push(`Ignored unknown column \"${h}\"`)\n }\n\n // Missing required columns from the table \u2192 error.\n const missingDims = table.dimensions.filter((d) => !dimensionHeaders.some((h) => h.key === d.key))\n const missingPrices = table.priceColumns.filter((c) => !priceHeaders.some((h) => h.key === c.key))\n if (missingDims.length > 0) {\n return { ok: false, error: `Missing dimension column(s): ${missingDims.map((d) => d.label).join(', ')}` }\n }\n if (missingPrices.length > 0) {\n return { ok: false, error: `Missing price column(s): ${missingPrices.map((c) => c.label).join(', ')}` }\n }\n if (!currencyHeader) {\n return { ok: false, error: 'Missing \"currency_code\" column' }\n }\n\n // \u2500\u2500\u2500 Parse rows \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\n const parsed: ParsedRow[] = []\n for (let i = 0; i < rows.length; i++) {\n const raw = rows[i]\n const rowNumber = i + 2 // +1 for header, +1 because rows are 1-indexed in Excel\n\n const id = idHeader ? toStringOrNull(raw[idHeader]) : null\n const tierStr = tierHeader ? toStringOrNull(raw[tierHeader]) : null\n const rangeFromStr = rangeFromHeader ? toStringOrNull(raw[rangeFromHeader]) : null\n const rangeToStr = rangeToHeader ? toStringOrNull(raw[rangeToHeader]) : null\n const currency = toStringOrNull(raw[currencyHeader]) ?? ''\n\n if (!currency) {\n return { ok: false, error: `Row ${rowNumber}: missing currency_code` }\n }\n if (!table.currencyCodeList.includes(currency.toUpperCase())) {\n return { ok: false, error: `Row ${rowNumber}: currency \"${currency}\" is not in the table's currency list (${table.currencyCodeList.join(', ')})` }\n }\n\n const tierNumber = tierStr ? Number(tierStr) : null\n if (tierNumber !== null && Number.isNaN(tierNumber)) {\n return { ok: false, error: `Row ${rowNumber}: tier_number must be a number, got \"${tierStr}\"` }\n }\n\n const dimensionValues: Record<string, string> = {}\n for (const { header, key } of dimensionHeaders) {\n dimensionValues[key] = toStringOrNull(raw[header]) ?? ''\n }\n\n const prices: Record<string, number> = {}\n for (const { header, key } of priceHeaders) {\n const v = raw[header]\n if (v === '' || v === null || v === undefined) {\n prices[key] = 0\n continue\n }\n const num = Number(v)\n if (Number.isNaN(num)) {\n return { ok: false, error: `Row ${rowNumber}: price column \"${header}\" must be a number, got \"${String(v)}\"` }\n }\n prices[key] = num\n }\n\n parsed.push({\n rowNumber,\n id,\n dimensionValues,\n tierNumber,\n rangeFrom: rangeFromStr,\n rangeTo: rangeToStr,\n currencyCode: currency.toUpperCase(),\n prices,\n })\n }\n\n // \u2500\u2500\u2500 Compute diff \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\n const existingById = new Map<string, ImportEntry>(existingEntries.map((e) => [e.id, e]))\n const fileIds = new Set<string>(parsed.map((p) => p.id).filter((id): id is string => !!id))\n\n const inserts: ParsedRow[] = []\n const updates: Array<{ before: ImportEntry; after: ParsedRow }> = []\n const unchanged: ImportEntry[] = []\n\n for (const row of parsed) {\n if (!row.id) {\n inserts.push(row)\n continue\n }\n const existing = existingById.get(row.id)\n if (!existing) {\n warnings.push(`Row ${row.rowNumber}: id \"${row.id}\" not found in current entries \u2014 will be inserted as new`)\n inserts.push({ ...row, id: null })\n continue\n }\n if (rowMatchesEntry(row, existing)) {\n unchanged.push(existing)\n } else {\n updates.push({ before: existing, after: row })\n }\n }\n\n const deletes = existingEntries.filter((e) => !fileIds.has(e.id))\n\n return {\n ok: true,\n diff: { inserts, updates, deletes, unchanged, warnings },\n }\n}\n\n// \u2500\u2500\u2500 Commit \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nexport async function commitImportDiff(\n pricingTableId: string,\n diff: ImportDiff,\n): Promise<{ ok: true } | { ok: false; error: string }> {\n // INSERTS (batch \u2014 route accepts arrays)\n if (diff.inserts.length > 0) {\n const payload = diff.inserts.map((r) => ({\n pricingTableId,\n dimensionValues: r.dimensionValues,\n tierNumber: r.tierNumber ?? undefined,\n rangeFrom: r.rangeFrom !== null ? Number(r.rangeFrom) : undefined,\n rangeTo: r.rangeTo !== null ? Number(r.rangeTo) : undefined,\n currencyCode: r.currencyCode,\n prices: r.prices,\n }))\n const res = await fetch('/api/cpq/pricing-table-entries', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n if (!res.ok) {\n const body = await res.json().catch(() => ({}))\n return { ok: false, error: body.error ?? 'Failed to insert entries' }\n }\n }\n\n // UPDATES (one-by-one)\n for (const { before, after } of diff.updates) {\n const res = await fetch('/api/cpq/pricing-table-entries', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n id: before.id,\n dimensionValues: after.dimensionValues,\n tierNumber: after.tierNumber ?? null,\n rangeFrom: after.rangeFrom !== null ? Number(after.rangeFrom) : null,\n rangeTo: after.rangeTo !== null ? Number(after.rangeTo) : null,\n currencyCode: after.currencyCode,\n prices: after.prices,\n }),\n })\n if (!res.ok) {\n const body = await res.json().catch(() => ({}))\n return { ok: false, error: body.error ?? `Failed to update entry ${before.id}` }\n }\n }\n\n // DELETES (one-by-one)\n for (const entry of diff.deletes) {\n const res = await fetch('/api/cpq/pricing-table-entries', {\n method: 'DELETE',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ id: entry.id }),\n })\n if (!res.ok) {\n const body = await res.json().catch(() => ({}))\n return { ok: false, error: body.error ?? `Failed to delete entry ${entry.id}` }\n }\n }\n\n return { ok: true }\n}\n\n// \u2500\u2500\u2500 helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction toStringOrNull(v: unknown): string | null {\n if (v === null || v === undefined) return null\n const s = String(v).trim()\n return s === '' ? null : s\n}\n\nfunction rowMatchesEntry(row: ParsedRow, entry: ImportEntry): boolean {\n if (row.currencyCode !== entry.currencyCode) return false\n if ((row.tierNumber ?? null) !== (entry.tierNumber ?? null)) return false\n if (!numericEqual(row.rangeFrom, entry.rangeFrom)) return false\n if (!numericEqual(row.rangeTo, entry.rangeTo)) return false\n // dimensions\n const dimKeys = new Set([...Object.keys(row.dimensionValues), ...Object.keys(entry.dimensionValues)])\n for (const k of dimKeys) {\n if ((row.dimensionValues[k] ?? '') !== (entry.dimensionValues[k] ?? '')) return false\n }\n // prices\n const priceKeys = new Set([...Object.keys(row.prices), ...Object.keys(entry.prices)])\n for (const k of priceKeys) {\n if ((row.prices[k] ?? 0) !== (entry.prices[k] ?? 0)) return false\n }\n return true\n}\n\nfunction numericEqual(a: string | null, b: string | null): boolean {\n const an = a == null ? null : Number(a)\n const bn = b == null ? null : Number(b)\n if (an === null && bn === null) return true\n if (an === null || bn === null) return false\n return an === bn\n}\n"],
5
+ "mappings": "AAQA,YAAY,UAAU;AA4CtB,eAAsB,sBACpB,MACA,OACA,iBACuB;AACvB,MAAI;AACJ,MAAI;AACF,UAAM,SAAS,MAAM,KAAK,YAAY;AACtC,eAAW,KAAK,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAAA,EAChD,SAAS,KAAK;AACZ,WAAO,EAAE,IAAI,OAAO,OAAO,eAAe,QAAQ,wBAAwB,IAAI,OAAO,KAAK,sBAAsB;AAAA,EAClH;AAEA,QAAM,YAAY,SAAS,WAAW,CAAC;AACvC,MAAI,CAAC,UAAW,QAAO,EAAE,IAAI,OAAO,OAAO,yBAAyB;AACpE,QAAM,QAAQ,SAAS,OAAO,SAAS;AAOvC,QAAM,OAAO,KAAK,MAAM,cAAuC,OAAO;AAAA,IACpE,QAAQ;AAAA,IACR,KAAK;AAAA;AAAA,EACP,CAAC;AAED,MAAI,KAAK,WAAW,GAAG;AACrB,WAAO,EAAE,IAAI,OAAO,OAAO,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AAC;AACpF,aAAW,KAAK,WAAW;AACzB,SAAK,IAAI,OAAO,CAAC,KAAK,QAAQ,MAAM,OAAO,CAAC,KAAK,GAAI,QAAO;AAAA,EAC9D;AACA,SAAO;AACT;AAEA,SAAS,aAAa,GAAkB,GAA2B;AACjE,QAAM,KAAK,KAAK,OAAO,OAAO,OAAO,CAAC;AACtC,QAAM,KAAK,KAAK,OAAO,OAAO,OAAO,CAAC;AACtC,MAAI,OAAO,QAAQ,OAAO,KAAM,QAAO;AACvC,MAAI,OAAO,QAAQ,OAAO,KAAM,QAAO;AACvC,SAAO,OAAO;AAChB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { useT } from "@open-mercato/shared/lib/i18n/context";
5
+ import { useRouter } from "next/navigation";
6
+ import { Button } from "@open-mercato/ui/primitives/button";
7
+ import { Tag } from "@open-mercato/ui/primitives/tag";
8
+ import { CpqListView, useCpqListData } from "../../../components/CpqListView.js";
9
+ const PAGE_SIZE = 50;
10
+ function buildFilterParams(values, params) {
11
+ if (values.isActive === true) params.set("isActive", "true");
12
+ if (values.isActive === false) params.set("isActive", "false");
13
+ }
14
+ function PricingTablesPage() {
15
+ const t = useT();
16
+ const router = useRouter();
17
+ const data = useCpqListData({
18
+ endpoint: "/api/cpq/pricing-tables",
19
+ pageSize: PAGE_SIZE,
20
+ buildFilterParams,
21
+ loadErrorMessage: t("cpq.pricing.list.error.load", "Failed to load pricing tables")
22
+ });
23
+ const filters = React.useMemo(
24
+ () => [
25
+ {
26
+ id: "isActive",
27
+ label: t("cpq.pricing.filters.isActive", "Active"),
28
+ type: "checkbox"
29
+ }
30
+ ],
31
+ [t]
32
+ );
33
+ const columns = React.useMemo(
34
+ () => [
35
+ {
36
+ accessorKey: "name",
37
+ header: t("cpq.pricing.name", "Name"),
38
+ cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: row.original.name })
39
+ },
40
+ {
41
+ accessorKey: "code",
42
+ header: t("cpq.pricing.code", "Code"),
43
+ cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.original.code })
44
+ },
45
+ {
46
+ id: "priceColumns",
47
+ header: t("cpq.pricing.priceColumns", "Price Columns"),
48
+ cell: ({ row }) => /* @__PURE__ */ jsx("span", { children: row.original.priceColumns?.length ?? 0 })
49
+ },
50
+ {
51
+ id: "currencies",
52
+ header: t("cpq.pricing.currencies", "Currencies"),
53
+ cell: ({ row }) => /* @__PURE__ */ jsx("span", { children: row.original.currencyCodeList?.join(", ") ?? "\u2014" })
54
+ },
55
+ {
56
+ accessorKey: "isActive",
57
+ header: t("cpq.pricing.status", "Status"),
58
+ cell: ({ row }) => /* @__PURE__ */ jsx(Tag, { variant: row.original.isActive ? "success" : "neutral", dot: true, children: row.original.isActive ? t("common.active", "Active") : t("common.inactive", "Inactive") })
59
+ }
60
+ ],
61
+ [t]
62
+ );
63
+ return /* @__PURE__ */ jsx(
64
+ CpqListView,
65
+ {
66
+ title: t("cpq.pricing.list.title", "Pricing Tables"),
67
+ tableId: "cpq.pricing.list",
68
+ data,
69
+ columns,
70
+ filters,
71
+ pageSize: PAGE_SIZE,
72
+ searchPlaceholder: t("cpq.pricing.search.placeholder", "Search pricing tables..."),
73
+ actions: /* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsx("a", { href: "/backend/cpq/pricing/new", children: t("cpq.pricing.add", "New Pricing Table") }) }),
74
+ crud: {
75
+ endpoint: "/api/cpq/pricing-tables",
76
+ entityName: t("cpq.pricing.entityName", "pricing table"),
77
+ editHref: (row) => `/backend/cpq/pricing/${row.id}`
78
+ },
79
+ onRowClick: (row) => router.push(`/backend/cpq/pricing/${row.id}`),
80
+ emptyState: /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: t("cpq.pricing.empty", "No pricing tables found.") })
81
+ }
82
+ );
83
+ }
84
+ export {
85
+ PricingTablesPage as default
86
+ };
87
+ //# sourceMappingURL=page.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/modules/cpq/backend/cpq/pricing/page.tsx"],
4
+ "sourcesContent": ["\"use client\"\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { useRouter } from 'next/navigation'\nimport type { ColumnDef } from '@tanstack/react-table'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Tag } from '@open-mercato/ui/primitives/tag'\nimport type { FilterDef, FilterValues } from '@open-mercato/ui/backend/FilterBar'\nimport { CpqListView, useCpqListData } from '../../../components/CpqListView'\n\ntype PricingTable = {\n id: string\n code: string\n name: string\n priceColumns: Array<{ key: string; label: string }>\n currencyCodeList: string[]\n isActive: boolean\n}\n\nconst PAGE_SIZE = 50\n\nfunction buildFilterParams(values: FilterValues, params: URLSearchParams) {\n if (values.isActive === true) params.set('isActive', 'true')\n if (values.isActive === false) params.set('isActive', 'false')\n}\n\nexport default function PricingTablesPage() {\n const t = useT()\n const router = useRouter()\n\n const data = useCpqListData<PricingTable>({\n endpoint: '/api/cpq/pricing-tables',\n pageSize: PAGE_SIZE,\n buildFilterParams,\n loadErrorMessage: t('cpq.pricing.list.error.load', 'Failed to load pricing tables'),\n })\n\n const filters = React.useMemo<FilterDef[]>(\n () => [\n {\n id: 'isActive',\n label: t('cpq.pricing.filters.isActive', 'Active'),\n type: 'checkbox',\n },\n ],\n [t],\n )\n\n const columns = React.useMemo<ColumnDef<PricingTable>[]>(\n () => [\n {\n accessorKey: 'name',\n header: t('cpq.pricing.name', 'Name'),\n cell: ({ row }) => <span className=\"font-medium\">{row.original.name}</span>,\n },\n {\n accessorKey: 'code',\n header: t('cpq.pricing.code', 'Code'),\n cell: ({ row }) => <span className=\"font-mono text-xs\">{row.original.code}</span>,\n },\n {\n id: 'priceColumns',\n header: t('cpq.pricing.priceColumns', 'Price Columns'),\n cell: ({ row }) => <span>{row.original.priceColumns?.length ?? 0}</span>,\n },\n {\n id: 'currencies',\n header: t('cpq.pricing.currencies', 'Currencies'),\n cell: ({ row }) => <span>{row.original.currencyCodeList?.join(', ') ?? '\u2014'}</span>,\n },\n {\n accessorKey: 'isActive',\n header: t('cpq.pricing.status', 'Status'),\n cell: ({ row }) => (\n <Tag variant={row.original.isActive ? 'success' : 'neutral'} dot>\n {row.original.isActive ? t('common.active', 'Active') : t('common.inactive', 'Inactive')}\n </Tag>\n ),\n },\n ],\n [t],\n )\n\n return (\n <CpqListView<PricingTable>\n title={t('cpq.pricing.list.title', 'Pricing Tables')}\n tableId=\"cpq.pricing.list\"\n data={data}\n columns={columns}\n filters={filters}\n pageSize={PAGE_SIZE}\n searchPlaceholder={t('cpq.pricing.search.placeholder', 'Search pricing tables...')}\n actions={\n <Button asChild>\n <a href=\"/backend/cpq/pricing/new\">{t('cpq.pricing.add', 'New Pricing Table')}</a>\n </Button>\n }\n crud={{\n endpoint: '/api/cpq/pricing-tables',\n entityName: t('cpq.pricing.entityName', 'pricing table'),\n editHref: (row) => `/backend/cpq/pricing/${row.id}`,\n }}\n onRowClick={(row) => router.push(`/backend/cpq/pricing/${row.id}`)}\n emptyState={\n <div className=\"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground\">\n {t('cpq.pricing.empty', 'No pricing tables found.')}\n </div>\n }\n />\n )\n}\n"],
5
+ "mappings": ";AAqD2B;AApD3B,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAE1B,SAAS,cAAc;AACvB,SAAS,WAAW;AAEpB,SAAS,aAAa,sBAAsB;AAW5C,MAAM,YAAY;AAElB,SAAS,kBAAkB,QAAsB,QAAyB;AACxE,MAAI,OAAO,aAAa,KAAM,QAAO,IAAI,YAAY,MAAM;AAC3D,MAAI,OAAO,aAAa,MAAO,QAAO,IAAI,YAAY,OAAO;AAC/D;AAEe,SAAR,oBAAqC;AAC1C,QAAM,IAAI,KAAK;AACf,QAAM,SAA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,EAAE,iBAAiB,QAAQ,IAAI,EAAE,mBAAmB,UAAU,GACzF;AAAA,MAEJ;AAAA,IACF;AAAA,IACA,CAAC,CAAC;AAAA,EACJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,EAAE,0BAA0B,gBAAgB;AAAA,MACnD,SAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV,mBAAmB,EAAE,kCAAkC,0BAA0B;AAAA,MACjF,SACE,oBAAC,UAAO,SAAO,MACb,8BAAC,OAAE,MAAK,4BAA4B,YAAE,mBAAmB,mBAAmB,GAAE,GAChF;AAAA,MAEF,MAAM;AAAA,QACJ,UAAU;AAAA,QACV,YAAY,EAAE,0BAA0B,eAAe;AAAA,QACvD,UAAU,CAAC,QAAQ,wBAAwB,IAAI,EAAE;AAAA,MACnD;AAAA,MACA,YAAY,CAAC,QAAQ,OAAO,KAAK,wBAAwB,IAAI,EAAE,EAAE;AAAA,MACjE,YACE,oBAAC,SAAI,WAAU,2EACZ,YAAE,qBAAqB,0BAA0B,GACpD;AAAA;AAAA,EAEJ;AAEJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import { Calculator } from "lucide-react";
3
+ const pricingIcon = React.createElement(Calculator, { size: 16 });
4
+ const metadata = {
5
+ requireAuth: true,
6
+ requireFeatures: ["cpq.pricing.view"],
7
+ pageTitle: "Pricing Tables",
8
+ pageTitleKey: "cpq.pricing.list.title",
9
+ pageGroup: "CPQ",
10
+ pageGroupKey: "customers~sales~cpq.nav.group",
11
+ pageOrder: 20,
12
+ icon: pricingIcon,
13
+ breadcrumb: [{ label: "Pricing Tables", labelKey: "cpq.pricing.list.title" }]
14
+ };
15
+ export {
16
+ metadata
17
+ };
18
+ //# sourceMappingURL=page.meta.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/modules/cpq/backend/cpq/pricing/page.meta.ts"],
4
+ "sourcesContent": ["import React from 'react'\nimport { Calculator } from 'lucide-react'\n\nconst pricingIcon = React.createElement(Calculator, { size: 16 })\n\nexport const metadata = {\n requireAuth: true,\n requireFeatures: ['cpq.pricing.view'],\n pageTitle: 'Pricing Tables',\n pageTitleKey: 'cpq.pricing.list.title',\n pageGroup: 'CPQ',\n pageGroupKey: 'customers~sales~cpq.nav.group',\n pageOrder: 20,\n icon: pricingIcon,\n breadcrumb: [{ label: 'Pricing Tables', labelKey: 'cpq.pricing.list.title' }],\n} as const\n"],
5
+ "mappings": "AAAA,OAAO,WAAW;AAClB,SAAS,kBAAkB;AAE3B,MAAM,cAAc,MAAM,cAAc,YAAY,EAAE,MAAM,GAAG,CAAC;AAEzD,MAAM,WAAW;AAAA,EACtB,aAAa;AAAA,EACb,iBAAiB,CAAC,kBAAkB;AAAA,EACpC,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,cAAc;AAAA,EACd,WAAW;AAAA,EACX,MAAM;AAAA,EACN,YAAY,CAAC,EAAE,OAAO,kBAAkB,UAAU,yBAAyB,CAAC;AAC9E;",
6
+ "names": []
7
+ }