@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.
- package/CHANGELOG.md +70 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +236 -0
- package/README.md +108 -0
- package/dist/modules/cpq/acl.js +30 -0
- package/dist/modules/cpq/acl.js.map +7 -0
- package/dist/modules/cpq/api/_helpers/handleArcError.js +37 -0
- package/dist/modules/cpq/api/_helpers/handleArcError.js.map +7 -0
- package/dist/modules/cpq/api/attribute-options/route.js +47 -0
- package/dist/modules/cpq/api/attribute-options/route.js.map +7 -0
- package/dist/modules/cpq/api/bundle-slots/route.js +101 -0
- package/dist/modules/cpq/api/bundle-slots/route.js.map +7 -0
- package/dist/modules/cpq/api/bundle-tree/route.js +28 -0
- package/dist/modules/cpq/api/bundle-tree/route.js.map +7 -0
- package/dist/modules/cpq/api/context.js +29 -0
- package/dist/modules/cpq/api/context.js.map +7 -0
- package/dist/modules/cpq/api/inventory/assets/route.js +113 -0
- package/dist/modules/cpq/api/inventory/assets/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/assets/status/route.js +35 -0
- package/dist/modules/cpq/api/inventory/assets/status/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js +30 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js +31 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscription-items/route.js +99 -0
- package/dist/modules/cpq/api/inventory/subscription-items/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js +57 -0
- package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js +62 -0
- package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/route.js +116 -0
- package/dist/modules/cpq/api/inventory/subscriptions/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/status/route.js +35 -0
- package/dist/modules/cpq/api/inventory/subscriptions/status/route.js.map +7 -0
- package/dist/modules/cpq/api/offering-components/route.js +91 -0
- package/dist/modules/cpq/api/offering-components/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/activate/route.js +39 -0
- package/dist/modules/cpq/api/orders/[orderId]/activate/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/route.js +28 -0
- package/dist/modules/cpq/api/orders/[orderId]/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/status/route.js +38 -0
- package/dist/modules/cpq/api/orders/[orderId]/status/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/route.js +71 -0
- package/dist/modules/cpq/api/orders/route.js.map +7 -0
- package/dist/modules/cpq/api/price-rules/route.js +180 -0
- package/dist/modules/cpq/api/price-rules/route.js.map +7 -0
- package/dist/modules/cpq/api/pricing-table-entries/route.js +142 -0
- package/dist/modules/cpq/api/pricing-table-entries/route.js.map +7 -0
- package/dist/modules/cpq/api/pricing-tables/route.js +179 -0
- package/dist/modules/cpq/api/pricing-tables/route.js.map +7 -0
- package/dist/modules/cpq/api/product-attributes/route.js +160 -0
- package/dist/modules/cpq/api/product-attributes/route.js.map +7 -0
- package/dist/modules/cpq/api/product-charges/route.js +166 -0
- package/dist/modules/cpq/api/product-charges/route.js.map +7 -0
- package/dist/modules/cpq/api/product-offerings/route.js +294 -0
- package/dist/modules/cpq/api/product-offerings/route.js.map +7 -0
- package/dist/modules/cpq/api/product-relationships/route.js +144 -0
- package/dist/modules/cpq/api/product-relationships/route.js.map +7 -0
- package/dist/modules/cpq/api/product-specifications/route.js +292 -0
- package/dist/modules/cpq/api/product-specifications/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js +71 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js +29 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js +54 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js +27 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js +72 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js +35 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/route.js +102 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js +27 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js +79 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js +95 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/attributes/route.js +52 -0
- package/dist/modules/cpq/api/quotes/attributes/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/from-subscription/route.js +72 -0
- package/dist/modules/cpq/api/quotes/from-subscription/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/price/route.js +69 -0
- package/dist/modules/cpq/api/quotes/price/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/route.js +97 -0
- package/dist/modules/cpq/api/quotes/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/validate-relationships/route.js +86 -0
- package/dist/modules/cpq/api/quotes/validate-relationships/route.js.map +7 -0
- package/dist/modules/cpq/api/resolveQuotingService.js +7 -0
- package/dist/modules/cpq/api/resolveQuotingService.js.map +7 -0
- package/dist/modules/cpq/api/wizards/resolve/route.js +38 -0
- package/dist/modules/cpq/api/wizards/resolve/route.js.map +7 -0
- package/dist/modules/cpq/api/wizards/route.js +111 -0
- package/dist/modules/cpq/api/wizards/route.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js +136 -0
- package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js +185 -0
- package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js +343 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.js +35 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/shared.js +20 -0
- package/dist/modules/cpq/backend/cpq/inventory/shared.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js +794 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js +917 -0
- package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.js +405 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/[id]/page.js +677 -0
- package/dist/modules/cpq/backend/cpq/orders/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/page.js +134 -0
- package/dist/modules/cpq/backend/cpq/orders/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/orders/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js +272 -0
- package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js +407 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.js +211 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js +275 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js +112 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js +492 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js +50 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js +249 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.js +87 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js +652 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js +1289 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.js +283 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js +214 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js +1399 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.js +148 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js +204 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js +191 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.js +119 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.meta.js.map +7 -0
- package/dist/modules/cpq/ce.js +151 -0
- package/dist/modules/cpq/ce.js.map +7 -0
- package/dist/modules/cpq/cli.js +11 -0
- package/dist/modules/cpq/cli.js.map +7 -0
- package/dist/modules/cpq/components/CpqListView.js +265 -0
- package/dist/modules/cpq/components/CpqListView.js.map +7 -0
- package/dist/modules/cpq/components/NumberInput.js +95 -0
- package/dist/modules/cpq/components/NumberInput.js.map +7 -0
- package/dist/modules/cpq/components/StatusPath.js +60 -0
- package/dist/modules/cpq/components/StatusPath.js.map +7 -0
- package/dist/modules/cpq/components/statusMaps.js +66 -0
- package/dist/modules/cpq/components/statusMaps.js.map +7 -0
- package/dist/modules/cpq/components/useCpqRowActions.js +125 -0
- package/dist/modules/cpq/components/useCpqRowActions.js.map +7 -0
- package/dist/modules/cpq/data/entities.js +1556 -0
- package/dist/modules/cpq/data/entities.js.map +7 -0
- package/dist/modules/cpq/data/validators.js +575 -0
- package/dist/modules/cpq/data/validators.js.map +7 -0
- package/dist/modules/cpq/di.js +57 -0
- package/dist/modules/cpq/di.js.map +7 -0
- package/dist/modules/cpq/events.js +50 -0
- package/dist/modules/cpq/events.js.map +7 -0
- package/dist/modules/cpq/index.js +16 -0
- package/dist/modules/cpq/index.js.map +7 -0
- package/dist/modules/cpq/lib/seeds/api.js +32 -0
- package/dist/modules/cpq/lib/seeds/api.js.map +7 -0
- package/dist/modules/cpq/lib/seeds/tenant-provisioning.js +158 -0
- package/dist/modules/cpq/lib/seeds/tenant-provisioning.js.map +7 -0
- package/dist/modules/cpq/lib/seeds.js +6 -0
- package/dist/modules/cpq/lib/seeds.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js +40 -0
- package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js +54 -0
- package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js +15 -0
- package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js +62 -0
- package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js +56 -0
- package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js +26 -0
- package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js +37 -0
- package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js +35 -0
- package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js +21 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js +46 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js +118 -0
- package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js +63 -0
- package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js +28 -0
- package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js +36 -0
- package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js +14 -0
- package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js +14 -0
- package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js +58 -0
- package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js +29 -0
- package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js.map +7 -0
- package/dist/modules/cpq/services/cpqBundleService.js +447 -0
- package/dist/modules/cpq/services/cpqBundleService.js.map +7 -0
- package/dist/modules/cpq/services/cpqInventoryService.js +1371 -0
- package/dist/modules/cpq/services/cpqInventoryService.js.map +7 -0
- package/dist/modules/cpq/services/cpqOrderService.js +901 -0
- package/dist/modules/cpq/services/cpqOrderService.js.map +7 -0
- package/dist/modules/cpq/services/cpqPricingService.js +289 -0
- package/dist/modules/cpq/services/cpqPricingService.js.map +7 -0
- package/dist/modules/cpq/services/cpqProductService.js +204 -0
- package/dist/modules/cpq/services/cpqProductService.js.map +7 -0
- package/dist/modules/cpq/services/cpqQuotingService.js +1867 -0
- package/dist/modules/cpq/services/cpqQuotingService.js.map +7 -0
- package/dist/modules/cpq/services/cpqValidationService.js +234 -0
- package/dist/modules/cpq/services/cpqValidationService.js.map +7 -0
- package/dist/modules/cpq/services/cpqWizardService.js +137 -0
- package/dist/modules/cpq/services/cpqWizardService.js.map +7 -0
- package/dist/modules/cpq/services/types.js +114 -0
- package/dist/modules/cpq/services/types.js.map +7 -0
- package/dist/modules/cpq/setup.js +49 -0
- package/dist/modules/cpq/setup.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-amended-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-amended-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-cancelled-log.js +19 -0
- package/dist/modules/cpq/subscribers/subscription-cancelled-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-merged-log.js +20 -0
- package/dist/modules/cpq/subscribers/subscription-merged-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-renewed-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-renewed-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-superseded-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-superseded-log.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js +192 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js +79 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js +181 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection-table.js +44 -0
- package/dist/modules/cpq/widgets/injection-table.js.map +7 -0
- package/dist/modules/cpq/workflows/WizardRunner.js +113 -0
- package/dist/modules/cpq/workflows/WizardRunner.js.map +7 -0
- package/dist/modules/cpq/workflows/WizardTrigger.js +116 -0
- package/dist/modules/cpq/workflows/WizardTrigger.js.map +7 -0
- package/dist/modules/cpq/workflows/engine.js +188 -0
- package/dist/modules/cpq/workflows/engine.js.map +7 -0
- package/dist/modules/cpq/workflows/registry.js +16 -0
- package/dist/modules/cpq/workflows/registry.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js +119 -0
- package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/InventorySelectStep.js +24 -0
- package/dist/modules/cpq/workflows/steps/InventorySelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ItemListStep.js +115 -0
- package/dist/modules/cpq/workflows/steps/ItemListStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js +327 -0
- package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js +231 -0
- package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ReviewStep.js +152 -0
- package/dist/modules/cpq/workflows/steps/ReviewStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/index.js +49 -0
- package/dist/modules/cpq/workflows/steps/index.js.map +7 -0
- package/dist/modules/cpq/workflows/types.js +1 -0
- package/dist/modules/cpq/workflows/types.js.map +7 -0
- package/package.json +150 -0
- package/src/modules/cpq/__integration__/TC-CPQ-001.spec.ts +177 -0
- package/src/modules/cpq/__integration__/TC-CPQ-002.spec.ts +123 -0
- package/src/modules/cpq/__integration__/TC-CPQ-003.spec.ts +115 -0
- package/src/modules/cpq/__integration__/TC-CPQ-004.spec.ts +184 -0
- package/src/modules/cpq/__integration__/TC-CPQ-005.spec.ts +43 -0
- package/src/modules/cpq/__integration__/TC-CPQ-006.spec.ts +87 -0
- package/src/modules/cpq/__integration__/TC-CPQ-007.spec.ts +79 -0
- package/src/modules/cpq/__integration__/TC-CPQ-008.spec.ts +55 -0
- package/src/modules/cpq/__integration__/TC-CPQ-009.spec.ts +45 -0
- package/src/modules/cpq/__integration__/TC-CPQ-010.spec.ts +54 -0
- package/src/modules/cpq/__integration__/TC-CPQ-011.spec.ts +24 -0
- package/src/modules/cpq/__integration__/TC-CPQ-012.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-001.spec.ts +52 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-002.spec.ts +65 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-003.spec.ts +107 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-004.spec.ts +74 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-005.spec.ts +86 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-006.spec.ts +79 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-007.spec.ts +63 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-008.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-009.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-010.spec.ts +59 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-011.spec.ts +128 -0
- package/src/modules/cpq/__integration__/_helpers/cpqArcFixtures.ts +208 -0
- package/src/modules/cpq/__tests__/package-isolation.test.ts +232 -0
- package/src/modules/cpq/acl.ts +26 -0
- package/src/modules/cpq/api/_helpers/__tests__/handleArcError.test.ts +117 -0
- package/src/modules/cpq/api/_helpers/handleArcError.ts +81 -0
- package/src/modules/cpq/api/attribute-options/route.ts +55 -0
- package/src/modules/cpq/api/bundle-slots/route.ts +112 -0
- package/src/modules/cpq/api/bundle-tree/route.ts +31 -0
- package/src/modules/cpq/api/context.ts +39 -0
- package/src/modules/cpq/api/inventory/assets/route.ts +123 -0
- package/src/modules/cpq/api/inventory/assets/status/route.ts +34 -0
- package/src/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.ts +30 -0
- package/src/modules/cpq/api/inventory/customer/[customerId]/route.ts +31 -0
- package/src/modules/cpq/api/inventory/subscription-items/route.ts +107 -0
- package/src/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.ts +64 -0
- package/src/modules/cpq/api/inventory/subscriptions/expiring/route.ts +66 -0
- package/src/modules/cpq/api/inventory/subscriptions/route.ts +126 -0
- package/src/modules/cpq/api/inventory/subscriptions/status/route.ts +34 -0
- package/src/modules/cpq/api/offering-components/route.ts +103 -0
- package/src/modules/cpq/api/orders/[orderId]/activate/route.ts +48 -0
- package/src/modules/cpq/api/orders/[orderId]/route.ts +28 -0
- package/src/modules/cpq/api/orders/[orderId]/status/route.ts +38 -0
- package/src/modules/cpq/api/orders/route.ts +77 -0
- package/src/modules/cpq/api/price-rules/route.ts +210 -0
- package/src/modules/cpq/api/pricing-table-entries/route.ts +159 -0
- package/src/modules/cpq/api/pricing-tables/route.ts +202 -0
- package/src/modules/cpq/api/product-attributes/route.ts +175 -0
- package/src/modules/cpq/api/product-charges/route.ts +181 -0
- package/src/modules/cpq/api/product-offerings/route.ts +329 -0
- package/src/modules/cpq/api/product-relationships/route.ts +156 -0
- package/src/modules/cpq/api/product-specifications/route.ts +325 -0
- package/src/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.ts +77 -0
- package/src/modules/cpq/api/quotes/[quoteId]/clone/route.ts +28 -0
- package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.ts +55 -0
- package/src/modules/cpq/api/quotes/[quoteId]/items/route.ts +26 -0
- package/src/modules/cpq/api/quotes/[quoteId]/merge-meta/route.ts +78 -0
- package/src/modules/cpq/api/quotes/[quoteId]/recalculate/route.ts +34 -0
- package/src/modules/cpq/api/quotes/[quoteId]/route.ts +109 -0
- package/src/modules/cpq/api/quotes/[quoteId]/status/route.ts +26 -0
- package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.ts +91 -0
- package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.ts +107 -0
- package/src/modules/cpq/api/quotes/attributes/route.ts +61 -0
- package/src/modules/cpq/api/quotes/from-subscription/route.ts +85 -0
- package/src/modules/cpq/api/quotes/price/route.ts +81 -0
- package/src/modules/cpq/api/quotes/route.ts +114 -0
- package/src/modules/cpq/api/quotes/validate-relationships/route.ts +100 -0
- package/src/modules/cpq/api/resolveQuotingService.ts +11 -0
- package/src/modules/cpq/api/wizards/resolve/route.ts +39 -0
- package/src/modules/cpq/api/wizards/route.ts +127 -0
- package/src/modules/cpq/backend/cpq/inventory/AssetsTable.tsx +166 -0
- package/src/modules/cpq/backend/cpq/inventory/SubscriptionsTable.tsx +251 -0
- package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.tsx +440 -0
- package/src/modules/cpq/backend/cpq/inventory/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/inventory/page.tsx +49 -0
- package/src/modules/cpq/backend/cpq/inventory/shared.tsx +32 -0
- package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.tsx +1085 -0
- package/src/modules/cpq/backend/cpq/offerings/[id]/page.tsx +1165 -0
- package/src/modules/cpq/backend/cpq/offerings/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/offerings/page.tsx +468 -0
- package/src/modules/cpq/backend/cpq/orders/[id]/page.tsx +921 -0
- package/src/modules/cpq/backend/cpq/orders/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/orders/page.tsx +182 -0
- package/src/modules/cpq/backend/cpq/price-rules/PriceRuleForm.tsx +310 -0
- package/src/modules/cpq/backend/cpq/price-rules/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/price-rules/[id]/page.tsx +472 -0
- package/src/modules/cpq/backend/cpq/price-rules/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/price-rules/page.tsx +253 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.tsx +431 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.tsx +122 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/page.tsx +588 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.ts +90 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.ts +338 -0
- package/src/modules/cpq/backend/cpq/pricing/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/pricing/page.tsx +111 -0
- package/src/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.tsx +737 -0
- package/src/modules/cpq/backend/cpq/quotes/[id]/page.tsx +1721 -0
- package/src/modules/cpq/backend/cpq/quotes/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/quotes/page.tsx +370 -0
- package/src/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.tsx +300 -0
- package/src/modules/cpq/backend/cpq/specifications/[id]/page.tsx +1722 -0
- package/src/modules/cpq/backend/cpq/specifications/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/specifications/page.tsx +191 -0
- package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.tsx +319 -0
- package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/page.tsx +234 -0
- package/src/modules/cpq/backend/cpq/wizards/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/wizards/page.tsx +141 -0
- package/src/modules/cpq/ce.ts +150 -0
- package/src/modules/cpq/cli.ts +10 -0
- package/src/modules/cpq/components/CpqListView.tsx +431 -0
- package/src/modules/cpq/components/NumberInput.tsx +166 -0
- package/src/modules/cpq/components/StatusPath.tsx +116 -0
- package/src/modules/cpq/components/statusMaps.ts +148 -0
- package/src/modules/cpq/components/useCpqRowActions.tsx +183 -0
- package/src/modules/cpq/data/__tests__/validators.arc.test.ts +271 -0
- package/src/modules/cpq/data/__tests__/validators.test.ts +782 -0
- package/src/modules/cpq/data/entities.ts +1467 -0
- package/src/modules/cpq/data/validators.ts +663 -0
- package/src/modules/cpq/di.ts +70 -0
- package/src/modules/cpq/events.ts +62 -0
- package/src/modules/cpq/index.ts +15 -0
- package/src/modules/cpq/lib/seeds/__tests__/api.test.ts +86 -0
- package/src/modules/cpq/lib/seeds/__tests__/tenant-provisioning.test.ts +349 -0
- package/src/modules/cpq/lib/seeds/api.ts +119 -0
- package/src/modules/cpq/lib/seeds/tenant-provisioning.ts +239 -0
- package/src/modules/cpq/lib/seeds.ts +18 -0
- package/src/modules/cpq/migrations/.snapshot-open-mercato.json +7473 -0
- package/src/modules/cpq/migrations/Migration20260220220000_cpq.ts +51 -0
- package/src/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.ts +70 -0
- package/src/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.ts +15 -0
- package/src/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.ts +73 -0
- package/src/modules/cpq/migrations/Migration20260402000000_cpq_workflows.ts +59 -0
- package/src/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.ts +30 -0
- package/src/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.ts +36 -0
- package/src/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.ts +33 -0
- package/src/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.ts +22 -0
- package/src/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.ts +56 -0
- package/src/modules/cpq/migrations/Migration20260410100000_cpq_inventory.ts +118 -0
- package/src/modules/cpq/migrations/Migration20260411000000_cpq_orders.ts +62 -0
- package/src/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.ts +33 -0
- package/src/modules/cpq/migrations/Migration20260504064621_cpq_arc.ts +68 -0
- package/src/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.ts +30 -0
- package/src/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.ts +27 -0
- package/src/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.ts +82 -0
- package/src/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.ts +52 -0
- package/src/modules/cpq/services/__tests__/_helpers/mockEm.ts +59 -0
- package/src/modules/cpq/services/__tests__/cpqBundleService.test.ts +661 -0
- package/src/modules/cpq/services/__tests__/cpqInventoryService.arc.test.ts +357 -0
- package/src/modules/cpq/services/__tests__/cpqInventoryService.test.ts +718 -0
- package/src/modules/cpq/services/__tests__/cpqOrderService.test.ts +603 -0
- package/src/modules/cpq/services/__tests__/cpqPricingService.test.ts +1012 -0
- package/src/modules/cpq/services/__tests__/cpqProductService.test.ts +603 -0
- package/src/modules/cpq/services/__tests__/cpqQuotingService.arc.test.ts +143 -0
- package/src/modules/cpq/services/__tests__/cpqQuotingService.test.ts +658 -0
- package/src/modules/cpq/services/__tests__/cpqValidationService.test.ts +811 -0
- package/src/modules/cpq/services/__tests__/cpqWizardService.test.ts +389 -0
- package/src/modules/cpq/services/__tests__/types.test.ts +359 -0
- package/src/modules/cpq/services/cpqBundleService.ts +671 -0
- package/src/modules/cpq/services/cpqInventoryService.ts +1929 -0
- package/src/modules/cpq/services/cpqOrderService.ts +1230 -0
- package/src/modules/cpq/services/cpqPricingService.ts +412 -0
- package/src/modules/cpq/services/cpqProductService.ts +311 -0
- package/src/modules/cpq/services/cpqQuotingService.ts +2638 -0
- package/src/modules/cpq/services/cpqValidationService.ts +323 -0
- package/src/modules/cpq/services/cpqWizardService.ts +204 -0
- package/src/modules/cpq/services/types.ts +303 -0
- package/src/modules/cpq/setup.ts +63 -0
- package/src/modules/cpq/subscribers/subscription-amended-log.ts +20 -0
- package/src/modules/cpq/subscribers/subscription-cancelled-log.ts +19 -0
- package/src/modules/cpq/subscribers/subscription-merged-log.ts +22 -0
- package/src/modules/cpq/subscribers/subscription-renewed-log.ts +18 -0
- package/src/modules/cpq/subscribers/subscription-superseded-log.ts +19 -0
- package/src/modules/cpq/widgets/injection/customer-inventory/widget.client.tsx +339 -0
- package/src/modules/cpq/widgets/injection/customer-inventory/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.client.tsx +96 -0
- package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection/quote-configurator/widget.client.tsx +265 -0
- package/src/modules/cpq/widgets/injection/quote-configurator/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection-table.ts +42 -0
- package/src/modules/cpq/workflows/WizardRunner.tsx +158 -0
- package/src/modules/cpq/workflows/WizardTrigger.tsx +142 -0
- package/src/modules/cpq/workflows/engine.tsx +278 -0
- package/src/modules/cpq/workflows/registry.ts +15 -0
- package/src/modules/cpq/workflows/steps/CustomerSelectStep.tsx +136 -0
- package/src/modules/cpq/workflows/steps/InventorySelectStep.tsx +34 -0
- package/src/modules/cpq/workflows/steps/ItemListStep.tsx +146 -0
- package/src/modules/cpq/workflows/steps/OfferingSelectStep.tsx +438 -0
- package/src/modules/cpq/workflows/steps/ProductConfigureStep.tsx +287 -0
- package/src/modules/cpq/workflows/steps/ReviewStep.tsx +219 -0
- package/src/modules/cpq/workflows/steps/index.ts +51 -0
- package/src/modules/cpq/workflows/types.ts +102 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { resolveCpqRouteContext } from "../context.js";
|
|
4
|
+
import { CpqProductOffering, CpqProductCharge, CpqProductSpecification, CpqOfferingComponent, CpqBundleSlot } from "../../data/entities.js";
|
|
5
|
+
import { cpqProductOfferingCreateSchema, cpqProductOfferingUpdateSchema } from "../../data/validators.js";
|
|
6
|
+
const metadata = {
|
|
7
|
+
GET: { requireAuth: true, requireFeatures: ["cpq.offerings.view"] },
|
|
8
|
+
POST: { requireAuth: true, requireFeatures: ["cpq.offerings.manage"] },
|
|
9
|
+
PUT: { requireAuth: true, requireFeatures: ["cpq.offerings.manage"] },
|
|
10
|
+
DELETE: { requireAuth: true, requireFeatures: ["cpq.offerings.manage"] }
|
|
11
|
+
};
|
|
12
|
+
async function GET(req) {
|
|
13
|
+
try {
|
|
14
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
15
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
16
|
+
const url = new URL(req.url);
|
|
17
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
18
|
+
const id = url.searchParams.get("id");
|
|
19
|
+
if (id) {
|
|
20
|
+
const offering = await ctx.em.findOne(CpqProductOffering, { id, ...scope });
|
|
21
|
+
if (!offering) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
22
|
+
const [spec, charges] = await Promise.all([
|
|
23
|
+
ctx.em.findOne(CpqProductSpecification, { id: offering.specId, ...scope }),
|
|
24
|
+
ctx.em.find(CpqProductCharge, { offeringId: offering.id, ...scope }, { orderBy: { sortOrder: "asc" } })
|
|
25
|
+
]);
|
|
26
|
+
let componentsData = [];
|
|
27
|
+
if (offering.offeringType === "bundle") {
|
|
28
|
+
const components = await ctx.em.find(CpqOfferingComponent, { offeringId: offering.id, ...scope }, { orderBy: { sortOrder: "asc" } });
|
|
29
|
+
if (components.length > 0) {
|
|
30
|
+
const slotIds = [...new Set(components.map((c) => c.slotId))];
|
|
31
|
+
const childOfferingIds = [...new Set(components.map((c) => c.childOfferingId))];
|
|
32
|
+
const [slots, childOfferings] = await Promise.all([
|
|
33
|
+
ctx.em.find(CpqBundleSlot, { id: { $in: slotIds }, ...scope }),
|
|
34
|
+
ctx.em.find(CpqProductOffering, { id: { $in: childOfferingIds }, ...scope })
|
|
35
|
+
]);
|
|
36
|
+
const slotMap = new Map(slots.map((s) => [s.id, s]));
|
|
37
|
+
const offeringMap = new Map(childOfferings.map((o) => [o.id, o]));
|
|
38
|
+
componentsData = components.map((c) => {
|
|
39
|
+
const sl = slotMap.get(c.slotId);
|
|
40
|
+
const ch = offeringMap.get(c.childOfferingId);
|
|
41
|
+
return {
|
|
42
|
+
id: c.id,
|
|
43
|
+
slotId: c.slotId,
|
|
44
|
+
slot: sl ? { id: sl.id, componentGroup: sl.componentGroup, name: sl.name, cardinalityMin: sl.cardinalityMin, cardinalityMax: sl.cardinalityMax } : null,
|
|
45
|
+
childOfferingId: c.childOfferingId,
|
|
46
|
+
childOffering: ch ? { id: ch.id, code: ch.code, name: ch.name, offeringType: ch.offeringType, specId: ch.specId } : null,
|
|
47
|
+
isDefault: c.isDefault,
|
|
48
|
+
sortOrder: c.sortOrder,
|
|
49
|
+
isActive: c.isActive
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return NextResponse.json({
|
|
55
|
+
id: offering.id,
|
|
56
|
+
specId: offering.specId,
|
|
57
|
+
catalogOfferId: offering.catalogOfferId,
|
|
58
|
+
code: offering.code,
|
|
59
|
+
name: offering.name,
|
|
60
|
+
description: offering.description,
|
|
61
|
+
offeringType: offering.offeringType,
|
|
62
|
+
designTimeValues: offering.designTimeValues,
|
|
63
|
+
lifecycleStatus: offering.lifecycleStatus,
|
|
64
|
+
effectiveFrom: offering.effectiveFrom,
|
|
65
|
+
effectiveTo: offering.effectiveTo,
|
|
66
|
+
metadata: offering.metadata,
|
|
67
|
+
isActive: offering.isActive,
|
|
68
|
+
createdAt: offering.createdAt,
|
|
69
|
+
updatedAt: offering.updatedAt,
|
|
70
|
+
specification: spec ? {
|
|
71
|
+
id: spec.id,
|
|
72
|
+
code: spec.code,
|
|
73
|
+
name: spec.name,
|
|
74
|
+
productId: spec.productId,
|
|
75
|
+
specType: spec.specType
|
|
76
|
+
} : null,
|
|
77
|
+
charges: charges.map((c) => ({
|
|
78
|
+
id: c.id,
|
|
79
|
+
code: c.code,
|
|
80
|
+
name: c.name,
|
|
81
|
+
description: c.description,
|
|
82
|
+
chargeType: c.chargeType,
|
|
83
|
+
pricingMethod: c.pricingMethod,
|
|
84
|
+
pricingTableId: c.pricingTableId,
|
|
85
|
+
priceColumnKey: c.priceColumnKey,
|
|
86
|
+
fixedPrice: c.fixedPrice,
|
|
87
|
+
currencyCode: c.currencyCode,
|
|
88
|
+
quantityAttributeCode: c.quantityAttributeCode,
|
|
89
|
+
applicabilityCondition: c.applicabilityCondition,
|
|
90
|
+
sortOrder: c.sortOrder,
|
|
91
|
+
isActive: c.isActive
|
|
92
|
+
})),
|
|
93
|
+
...offering.offeringType === "bundle" ? { components: componentsData } : {}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
const page = Math.max(1, Number(url.searchParams.get("page") ?? "1"));
|
|
97
|
+
const pageSize = Math.min(100, Math.max(1, Number(url.searchParams.get("pageSize") ?? "50")));
|
|
98
|
+
const filters = { ...scope };
|
|
99
|
+
const specId = url.searchParams.get("specId");
|
|
100
|
+
if (specId) filters.specId = specId;
|
|
101
|
+
const lifecycleStatus = url.searchParams.get("lifecycleStatus");
|
|
102
|
+
if (lifecycleStatus) filters.lifecycleStatus = lifecycleStatus;
|
|
103
|
+
const code = url.searchParams.get("code");
|
|
104
|
+
if (code) filters.code = code;
|
|
105
|
+
const offeringType = url.searchParams.get("offeringType");
|
|
106
|
+
if (offeringType) filters.offeringType = offeringType;
|
|
107
|
+
const isActiveParam = url.searchParams.get("isActive");
|
|
108
|
+
if (isActiveParam === "true") filters.isActive = true;
|
|
109
|
+
else if (isActiveParam === "false") filters.isActive = false;
|
|
110
|
+
const search = url.searchParams.get("search")?.trim();
|
|
111
|
+
if (search) {
|
|
112
|
+
filters.$or = [
|
|
113
|
+
{ code: { $ilike: `%${search}%` } },
|
|
114
|
+
{ name: { $ilike: `%${search}%` } },
|
|
115
|
+
{ description: { $ilike: `%${search}%` } }
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
const ALLOWED_SORT_FIELDS = ["createdAt", "updatedAt", "code", "name", "lifecycleStatus", "offeringType"];
|
|
119
|
+
const sortFieldParam = url.searchParams.get("sortField") ?? "";
|
|
120
|
+
const sortField = ALLOWED_SORT_FIELDS.includes(sortFieldParam) ? sortFieldParam : "createdAt";
|
|
121
|
+
const sortDir = url.searchParams.get("sortDir") === "asc" ? "asc" : "desc";
|
|
122
|
+
const [items, total] = await ctx.em.findAndCount(CpqProductOffering, filters, {
|
|
123
|
+
limit: pageSize,
|
|
124
|
+
offset: (page - 1) * pageSize,
|
|
125
|
+
orderBy: { [sortField]: sortDir }
|
|
126
|
+
});
|
|
127
|
+
const offeringIds = items.map((item) => item.id);
|
|
128
|
+
const chargesByOffering = /* @__PURE__ */ new Map();
|
|
129
|
+
if (offeringIds.length > 0) {
|
|
130
|
+
const allCharges = await ctx.em.find(
|
|
131
|
+
CpqProductCharge,
|
|
132
|
+
{ offeringId: { $in: offeringIds }, ...scope },
|
|
133
|
+
{ orderBy: { sortOrder: "asc" } }
|
|
134
|
+
);
|
|
135
|
+
for (const c of allCharges) {
|
|
136
|
+
if (!c.offeringId) continue;
|
|
137
|
+
const list = chargesByOffering.get(c.offeringId) ?? [];
|
|
138
|
+
list.push({
|
|
139
|
+
id: c.id,
|
|
140
|
+
code: c.code,
|
|
141
|
+
name: c.name,
|
|
142
|
+
description: c.description,
|
|
143
|
+
chargeType: c.chargeType,
|
|
144
|
+
pricingMethod: c.pricingMethod,
|
|
145
|
+
pricingTableId: c.pricingTableId,
|
|
146
|
+
priceColumnKey: c.priceColumnKey,
|
|
147
|
+
fixedPrice: c.fixedPrice,
|
|
148
|
+
currencyCode: c.currencyCode,
|
|
149
|
+
quantityAttributeCode: c.quantityAttributeCode,
|
|
150
|
+
applicabilityCondition: c.applicabilityCondition,
|
|
151
|
+
sortOrder: c.sortOrder,
|
|
152
|
+
isActive: c.isActive
|
|
153
|
+
});
|
|
154
|
+
chargesByOffering.set(c.offeringId, list);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return NextResponse.json({
|
|
158
|
+
items: items.map((item) => ({
|
|
159
|
+
id: item.id,
|
|
160
|
+
specId: item.specId,
|
|
161
|
+
catalogOfferId: item.catalogOfferId,
|
|
162
|
+
code: item.code,
|
|
163
|
+
name: item.name,
|
|
164
|
+
description: item.description,
|
|
165
|
+
offeringType: item.offeringType,
|
|
166
|
+
designTimeValues: item.designTimeValues,
|
|
167
|
+
lifecycleStatus: item.lifecycleStatus,
|
|
168
|
+
effectiveFrom: item.effectiveFrom,
|
|
169
|
+
effectiveTo: item.effectiveTo,
|
|
170
|
+
isActive: item.isActive,
|
|
171
|
+
createdAt: item.createdAt,
|
|
172
|
+
updatedAt: item.updatedAt,
|
|
173
|
+
charges: chargesByOffering.get(item.id) ?? []
|
|
174
|
+
})),
|
|
175
|
+
total,
|
|
176
|
+
page,
|
|
177
|
+
pageSize,
|
|
178
|
+
totalPages: Math.ceil(total / pageSize)
|
|
179
|
+
});
|
|
180
|
+
} catch (err) {
|
|
181
|
+
console.error("[cpq/product-offerings.GET]", err);
|
|
182
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function POST(req) {
|
|
186
|
+
try {
|
|
187
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
188
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
189
|
+
const body = cpqProductOfferingCreateSchema.parse(await req.json());
|
|
190
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId };
|
|
191
|
+
const spec = await ctx.em.findOne(CpqProductSpecification, {
|
|
192
|
+
id: body.specId,
|
|
193
|
+
...scope,
|
|
194
|
+
deletedAt: null
|
|
195
|
+
});
|
|
196
|
+
if (!spec) return NextResponse.json({ error: "Specification not found" }, { status: 400 });
|
|
197
|
+
const offeringType = body.offeringType ?? "simple";
|
|
198
|
+
if (offeringType !== spec.specType) {
|
|
199
|
+
return NextResponse.json(
|
|
200
|
+
{ error: `V-OFF-7: offeringType '${offeringType}' must match specification's specType '${spec.specType}'` },
|
|
201
|
+
{ status: 400 }
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
const entity = ctx.em.create(CpqProductOffering, { ...body, ...scope });
|
|
205
|
+
await ctx.em.flush();
|
|
206
|
+
return NextResponse.json(
|
|
207
|
+
{
|
|
208
|
+
id: entity.id,
|
|
209
|
+
specId: entity.specId,
|
|
210
|
+
catalogOfferId: entity.catalogOfferId,
|
|
211
|
+
code: entity.code,
|
|
212
|
+
name: entity.name,
|
|
213
|
+
description: entity.description,
|
|
214
|
+
offeringType: entity.offeringType,
|
|
215
|
+
designTimeValues: entity.designTimeValues,
|
|
216
|
+
lifecycleStatus: entity.lifecycleStatus,
|
|
217
|
+
effectiveFrom: entity.effectiveFrom,
|
|
218
|
+
effectiveTo: entity.effectiveTo,
|
|
219
|
+
metadata: entity.metadata,
|
|
220
|
+
isActive: entity.isActive,
|
|
221
|
+
createdAt: entity.createdAt,
|
|
222
|
+
updatedAt: entity.updatedAt
|
|
223
|
+
},
|
|
224
|
+
{ status: 201 }
|
|
225
|
+
);
|
|
226
|
+
} catch (err) {
|
|
227
|
+
if (err instanceof z.ZodError) {
|
|
228
|
+
return NextResponse.json({ error: "Validation error", details: err.issues }, { status: 400 });
|
|
229
|
+
}
|
|
230
|
+
console.error("[cpq/product-offerings.POST]", err);
|
|
231
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async function PUT(req) {
|
|
235
|
+
try {
|
|
236
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
237
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
238
|
+
const body = cpqProductOfferingUpdateSchema.parse(await req.json());
|
|
239
|
+
const { id, ...updates } = body;
|
|
240
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
241
|
+
const entity = await ctx.em.findOne(CpqProductOffering, { id, ...scope });
|
|
242
|
+
if (!entity) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
243
|
+
ctx.em.assign(entity, updates);
|
|
244
|
+
await ctx.em.flush();
|
|
245
|
+
return NextResponse.json({
|
|
246
|
+
id: entity.id,
|
|
247
|
+
specId: entity.specId,
|
|
248
|
+
catalogOfferId: entity.catalogOfferId,
|
|
249
|
+
code: entity.code,
|
|
250
|
+
name: entity.name,
|
|
251
|
+
description: entity.description,
|
|
252
|
+
offeringType: entity.offeringType,
|
|
253
|
+
designTimeValues: entity.designTimeValues,
|
|
254
|
+
lifecycleStatus: entity.lifecycleStatus,
|
|
255
|
+
effectiveFrom: entity.effectiveFrom,
|
|
256
|
+
effectiveTo: entity.effectiveTo,
|
|
257
|
+
metadata: entity.metadata,
|
|
258
|
+
isActive: entity.isActive,
|
|
259
|
+
createdAt: entity.createdAt,
|
|
260
|
+
updatedAt: entity.updatedAt
|
|
261
|
+
});
|
|
262
|
+
} catch (err) {
|
|
263
|
+
if (err instanceof z.ZodError) {
|
|
264
|
+
return NextResponse.json({ error: "Validation error", details: err.issues }, { status: 400 });
|
|
265
|
+
}
|
|
266
|
+
console.error("[cpq/product-offerings.PUT]", err);
|
|
267
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
async function DELETE(req) {
|
|
271
|
+
try {
|
|
272
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
273
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
274
|
+
const { id } = await req.json();
|
|
275
|
+
if (!id) return NextResponse.json({ error: "Missing id" }, { status: 400 });
|
|
276
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
277
|
+
const entity = await ctx.em.findOne(CpqProductOffering, { id, ...scope });
|
|
278
|
+
if (!entity) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
279
|
+
entity.deletedAt = /* @__PURE__ */ new Date();
|
|
280
|
+
await ctx.em.flush();
|
|
281
|
+
return NextResponse.json({ success: true });
|
|
282
|
+
} catch (err) {
|
|
283
|
+
console.error("[cpq/product-offerings.DELETE]", err);
|
|
284
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export {
|
|
288
|
+
DELETE,
|
|
289
|
+
GET,
|
|
290
|
+
POST,
|
|
291
|
+
PUT,
|
|
292
|
+
metadata
|
|
293
|
+
};
|
|
294
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/cpq/api/product-offerings/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { resolveCpqRouteContext } from '../context'\nimport { CpqProductOffering, CpqProductCharge, CpqProductSpecification, CpqOfferingComponent, CpqBundleSlot } from '../../data/entities'\nimport { cpqProductOfferingCreateSchema, cpqProductOfferingUpdateSchema } from '../../data/validators'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['cpq.offerings.view'] },\n POST: { requireAuth: true, requireFeatures: ['cpq.offerings.manage'] },\n PUT: { requireAuth: true, requireFeatures: ['cpq.offerings.manage'] },\n DELETE: { requireAuth: true, requireFeatures: ['cpq.offerings.manage'] },\n}\n\nexport async function GET(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const url = new URL(req.url)\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n\n // Detail view \u2014 load offering with spec and charges\n const id = url.searchParams.get('id')\n if (id) {\n const offering = await ctx.em.findOne(CpqProductOffering, { id, ...scope })\n if (!offering) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n const [spec, charges] = await Promise.all([\n ctx.em.findOne(CpqProductSpecification, { id: offering.specId, ...scope }),\n ctx.em.find(CpqProductCharge, { offeringId: offering.id, ...scope }, { orderBy: { sortOrder: 'asc' } }),\n ])\n\n // Load components for bundle offerings\n let componentsData: Array<Record<string, unknown>> = []\n if (offering.offeringType === 'bundle') {\n const components = await ctx.em.find(CpqOfferingComponent, { offeringId: offering.id, ...scope }, { orderBy: { sortOrder: 'asc' } })\n if (components.length > 0) {\n const slotIds = [...new Set(components.map((c) => c.slotId))]\n const childOfferingIds = [...new Set(components.map((c) => c.childOfferingId))]\n const [slots, childOfferings] = await Promise.all([\n ctx.em.find(CpqBundleSlot, { id: { $in: slotIds }, ...scope }),\n ctx.em.find(CpqProductOffering, { id: { $in: childOfferingIds }, ...scope }),\n ])\n const slotMap = new Map(slots.map((s) => [s.id, s]))\n const offeringMap = new Map(childOfferings.map((o) => [o.id, o]))\n componentsData = components.map((c) => {\n const sl = slotMap.get(c.slotId)\n const ch = offeringMap.get(c.childOfferingId)\n return {\n id: c.id,\n slotId: c.slotId,\n slot: sl ? { id: sl.id, componentGroup: sl.componentGroup, name: sl.name, cardinalityMin: sl.cardinalityMin, cardinalityMax: sl.cardinalityMax } : null,\n childOfferingId: c.childOfferingId,\n childOffering: ch ? { id: ch.id, code: ch.code, name: ch.name, offeringType: ch.offeringType, specId: ch.specId } : null,\n isDefault: c.isDefault,\n sortOrder: c.sortOrder,\n isActive: c.isActive,\n }\n })\n }\n }\n\n return NextResponse.json({\n id: offering.id,\n specId: offering.specId,\n catalogOfferId: offering.catalogOfferId,\n code: offering.code,\n name: offering.name,\n description: offering.description,\n offeringType: offering.offeringType,\n designTimeValues: offering.designTimeValues,\n lifecycleStatus: offering.lifecycleStatus,\n effectiveFrom: offering.effectiveFrom,\n effectiveTo: offering.effectiveTo,\n metadata: offering.metadata,\n isActive: offering.isActive,\n createdAt: offering.createdAt,\n updatedAt: offering.updatedAt,\n specification: spec\n ? {\n id: spec.id,\n code: spec.code,\n name: spec.name,\n productId: spec.productId,\n specType: spec.specType,\n }\n : null,\n charges: charges.map((c) => ({\n id: c.id,\n code: c.code,\n name: c.name,\n description: c.description,\n chargeType: c.chargeType,\n pricingMethod: c.pricingMethod,\n pricingTableId: c.pricingTableId,\n priceColumnKey: c.priceColumnKey,\n fixedPrice: c.fixedPrice,\n currencyCode: c.currencyCode,\n quantityAttributeCode: c.quantityAttributeCode,\n applicabilityCondition: c.applicabilityCondition,\n sortOrder: c.sortOrder,\n isActive: c.isActive,\n })),\n ...(offering.offeringType === 'bundle' ? { components: componentsData } : {}),\n })\n }\n\n // List view\n const page = Math.max(1, Number(url.searchParams.get('page') ?? '1'))\n const pageSize = Math.min(100, Math.max(1, Number(url.searchParams.get('pageSize') ?? '50')))\n\n const filters: Record<string, unknown> = { ...scope }\n const specId = url.searchParams.get('specId')\n if (specId) filters.specId = specId\n const lifecycleStatus = url.searchParams.get('lifecycleStatus')\n if (lifecycleStatus) filters.lifecycleStatus = lifecycleStatus\n const code = url.searchParams.get('code')\n if (code) filters.code = code\n const offeringType = url.searchParams.get('offeringType')\n if (offeringType) filters.offeringType = offeringType\n const isActiveParam = url.searchParams.get('isActive')\n if (isActiveParam === 'true') filters.isActive = true\n else if (isActiveParam === 'false') filters.isActive = false\n\n // Free-text search across code, name, description (case-insensitive)\n const search = url.searchParams.get('search')?.trim()\n if (search) {\n filters.$or = [\n { code: { $ilike: `%${search}%` } },\n { name: { $ilike: `%${search}%` } },\n { description: { $ilike: `%${search}%` } },\n ]\n }\n\n // Configurable sort\n const ALLOWED_SORT_FIELDS = ['createdAt', 'updatedAt', 'code', 'name', 'lifecycleStatus', 'offeringType'] as const\n const sortFieldParam = url.searchParams.get('sortField') ?? ''\n const sortField = (ALLOWED_SORT_FIELDS as readonly string[]).includes(sortFieldParam)\n ? (sortFieldParam as (typeof ALLOWED_SORT_FIELDS)[number])\n : 'createdAt'\n const sortDir = url.searchParams.get('sortDir') === 'asc' ? 'asc' : 'desc'\n\n const [items, total] = await ctx.em.findAndCount(CpqProductOffering, filters, {\n limit: pageSize,\n offset: (page - 1) * pageSize,\n orderBy: { [sortField]: sortDir },\n })\n\n // Batch-load charges for all visible offerings in a single query\n // (replaces an N+1 pattern where the UI fetched each offering's detail separately).\n const offeringIds = items.map((item) => item.id)\n const chargesByOffering = new Map<string, Array<Record<string, unknown>>>()\n if (offeringIds.length > 0) {\n const allCharges = await ctx.em.find(\n CpqProductCharge,\n { offeringId: { $in: offeringIds }, ...scope },\n { orderBy: { sortOrder: 'asc' } },\n )\n for (const c of allCharges) {\n if (!c.offeringId) continue\n const list = chargesByOffering.get(c.offeringId) ?? []\n list.push({\n id: c.id,\n code: c.code,\n name: c.name,\n description: c.description,\n chargeType: c.chargeType,\n pricingMethod: c.pricingMethod,\n pricingTableId: c.pricingTableId,\n priceColumnKey: c.priceColumnKey,\n fixedPrice: c.fixedPrice,\n currencyCode: c.currencyCode,\n quantityAttributeCode: c.quantityAttributeCode,\n applicabilityCondition: c.applicabilityCondition,\n sortOrder: c.sortOrder,\n isActive: c.isActive,\n })\n chargesByOffering.set(c.offeringId, list)\n }\n }\n\n return NextResponse.json({\n items: items.map((item) => ({\n id: item.id,\n specId: item.specId,\n catalogOfferId: item.catalogOfferId,\n code: item.code,\n name: item.name,\n description: item.description,\n offeringType: item.offeringType,\n designTimeValues: item.designTimeValues,\n lifecycleStatus: item.lifecycleStatus,\n effectiveFrom: item.effectiveFrom,\n effectiveTo: item.effectiveTo,\n isActive: item.isActive,\n createdAt: item.createdAt,\n updatedAt: item.updatedAt,\n charges: chargesByOffering.get(item.id) ?? [],\n })),\n total,\n page,\n pageSize,\n totalPages: Math.ceil(total / pageSize),\n })\n } catch (err) {\n console.error('[cpq/product-offerings.GET]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function POST(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const body = cpqProductOfferingCreateSchema.parse(await req.json())\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId }\n\n // Validate that the spec exists\n const spec = await ctx.em.findOne(CpqProductSpecification, {\n id: body.specId,\n ...scope,\n deletedAt: null,\n })\n if (!spec) return NextResponse.json({ error: 'Specification not found' }, { status: 400 })\n\n // V-OFF-7: offeringType must match spec's specType\n const offeringType = body.offeringType ?? 'simple'\n if (offeringType !== spec.specType) {\n return NextResponse.json(\n { error: `V-OFF-7: offeringType '${offeringType}' must match specification's specType '${spec.specType}'` },\n { status: 400 },\n )\n }\n\n const entity = ctx.em.create(CpqProductOffering, { ...body, ...scope })\n await ctx.em.flush()\n\n return NextResponse.json(\n {\n id: entity.id,\n specId: entity.specId,\n catalogOfferId: entity.catalogOfferId,\n code: entity.code,\n name: entity.name,\n description: entity.description,\n offeringType: entity.offeringType,\n designTimeValues: entity.designTimeValues,\n lifecycleStatus: entity.lifecycleStatus,\n effectiveFrom: entity.effectiveFrom,\n effectiveTo: entity.effectiveTo,\n metadata: entity.metadata,\n isActive: entity.isActive,\n createdAt: entity.createdAt,\n updatedAt: entity.updatedAt,\n },\n { status: 201 },\n )\n } catch (err) {\n if (err instanceof z.ZodError) {\n return NextResponse.json({ error: 'Validation error', details: err.issues }, { status: 400 })\n }\n console.error('[cpq/product-offerings.POST]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function PUT(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const body = cpqProductOfferingUpdateSchema.parse(await req.json())\n const { id, ...updates } = body\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n\n const entity = await ctx.em.findOne(CpqProductOffering, { id, ...scope })\n if (!entity) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n ctx.em.assign(entity, updates)\n await ctx.em.flush()\n\n return NextResponse.json({\n id: entity.id,\n specId: entity.specId,\n catalogOfferId: entity.catalogOfferId,\n code: entity.code,\n name: entity.name,\n description: entity.description,\n offeringType: entity.offeringType,\n designTimeValues: entity.designTimeValues,\n lifecycleStatus: entity.lifecycleStatus,\n effectiveFrom: entity.effectiveFrom,\n effectiveTo: entity.effectiveTo,\n metadata: entity.metadata,\n isActive: entity.isActive,\n createdAt: entity.createdAt,\n updatedAt: entity.updatedAt,\n })\n } catch (err) {\n if (err instanceof z.ZodError) {\n return NextResponse.json({ error: 'Validation error', details: err.issues }, { status: 400 })\n }\n console.error('[cpq/product-offerings.PUT]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function DELETE(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const { id } = (await req.json()) as { id?: string }\n if (!id) return NextResponse.json({ error: 'Missing id' }, { status: 400 })\n\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n const entity = await ctx.em.findOne(CpqProductOffering, { id, ...scope })\n if (!entity) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n entity.deletedAt = new Date()\n await ctx.em.flush()\n\n return NextResponse.json({ success: true })\n } catch (err) {\n console.error('[cpq/product-offerings.DELETE]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,oBAAoB,kBAAkB,yBAAyB,sBAAsB,qBAAqB;AACnH,SAAS,gCAAgC,sCAAsC;AAExE,MAAM,WAAW;AAAA,EACtB,KAAK,EAA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,QAAI,CAAC,OAAQ,QAAO,aAAa,KAAK,EAAE,OAAO,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;AAE7E,WAAO,YAAY,oBAAI,KAAK;AAC5B,UAAM,IAAI,GAAG,MAAM;AAEnB,WAAO,aAAa,KAAK,EAAE,SAAS,KAAK,CAAC;AAAA,EAC5C,SAAS,KAAK;AACZ,YAAQ,MAAM,kCAAkC,GAAG;AACnD,WAAO,aAAa,KAAK,EAAE,OAAO,iBAAiB,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACvE;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { NextResponse } from "next/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { resolveCpqRouteContext } from "../context.js";
|
|
4
|
+
import { CpqProductRelationship } from "../../data/entities.js";
|
|
5
|
+
import { cpqProductRelationshipCreateSchema, cpqProductRelationshipUpdateSchema } from "../../data/validators.js";
|
|
6
|
+
const metadata = {
|
|
7
|
+
GET: { requireAuth: true, requireFeatures: ["cpq.specifications.view"] },
|
|
8
|
+
POST: { requireAuth: true, requireFeatures: ["cpq.specifications.manage"] },
|
|
9
|
+
PUT: { requireAuth: true, requireFeatures: ["cpq.specifications.manage"] },
|
|
10
|
+
DELETE: { requireAuth: true, requireFeatures: ["cpq.specifications.manage"] }
|
|
11
|
+
};
|
|
12
|
+
async function GET(req) {
|
|
13
|
+
try {
|
|
14
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
15
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
16
|
+
const url = new URL(req.url);
|
|
17
|
+
const page = Math.max(1, Number(url.searchParams.get("page") ?? "1"));
|
|
18
|
+
const pageSize = Math.min(100, Math.max(1, Number(url.searchParams.get("pageSize") ?? "50")));
|
|
19
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
20
|
+
const filters = { ...scope };
|
|
21
|
+
const sourceSpecId = url.searchParams.get("sourceSpecId");
|
|
22
|
+
if (sourceSpecId) filters.sourceSpecId = sourceSpecId;
|
|
23
|
+
const targetSpecId = url.searchParams.get("targetSpecId");
|
|
24
|
+
if (targetSpecId) filters.targetSpecId = targetSpecId;
|
|
25
|
+
const relationshipType = url.searchParams.get("relationshipType");
|
|
26
|
+
if (relationshipType) filters.relationshipType = relationshipType;
|
|
27
|
+
const [items, total] = await ctx.em.findAndCount(CpqProductRelationship, filters, {
|
|
28
|
+
limit: pageSize,
|
|
29
|
+
offset: (page - 1) * pageSize,
|
|
30
|
+
orderBy: { createdAt: "desc" }
|
|
31
|
+
});
|
|
32
|
+
return NextResponse.json({
|
|
33
|
+
items: items.map((item) => ({
|
|
34
|
+
id: item.id,
|
|
35
|
+
sourceSpecId: item.sourceSpecId,
|
|
36
|
+
targetSpecId: item.targetSpecId,
|
|
37
|
+
relationshipType: item.relationshipType,
|
|
38
|
+
cardinalityMin: item.cardinalityMin,
|
|
39
|
+
cardinalityMax: item.cardinalityMax,
|
|
40
|
+
condition: item.condition,
|
|
41
|
+
metadata: item.metadata,
|
|
42
|
+
isActive: item.isActive,
|
|
43
|
+
createdAt: item.createdAt,
|
|
44
|
+
updatedAt: item.updatedAt
|
|
45
|
+
})),
|
|
46
|
+
total,
|
|
47
|
+
page,
|
|
48
|
+
pageSize,
|
|
49
|
+
totalPages: Math.ceil(total / pageSize)
|
|
50
|
+
});
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error("[cpq/product-relationships.GET]", err);
|
|
53
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
async function POST(req) {
|
|
57
|
+
try {
|
|
58
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
59
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
60
|
+
const body = cpqProductRelationshipCreateSchema.parse(await req.json());
|
|
61
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId };
|
|
62
|
+
const entity = ctx.em.create(CpqProductRelationship, { ...body, ...scope });
|
|
63
|
+
await ctx.em.flush();
|
|
64
|
+
return NextResponse.json(
|
|
65
|
+
{
|
|
66
|
+
id: entity.id,
|
|
67
|
+
sourceSpecId: entity.sourceSpecId,
|
|
68
|
+
targetSpecId: entity.targetSpecId,
|
|
69
|
+
relationshipType: entity.relationshipType,
|
|
70
|
+
cardinalityMin: entity.cardinalityMin,
|
|
71
|
+
cardinalityMax: entity.cardinalityMax,
|
|
72
|
+
condition: entity.condition,
|
|
73
|
+
metadata: entity.metadata,
|
|
74
|
+
isActive: entity.isActive,
|
|
75
|
+
createdAt: entity.createdAt,
|
|
76
|
+
updatedAt: entity.updatedAt
|
|
77
|
+
},
|
|
78
|
+
{ status: 201 }
|
|
79
|
+
);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (err instanceof z.ZodError) {
|
|
82
|
+
return NextResponse.json({ error: "Validation error", details: err.issues }, { status: 400 });
|
|
83
|
+
}
|
|
84
|
+
console.error("[cpq/product-relationships.POST]", err);
|
|
85
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
async function PUT(req) {
|
|
89
|
+
try {
|
|
90
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
91
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
92
|
+
const body = cpqProductRelationshipUpdateSchema.parse(await req.json());
|
|
93
|
+
const { id, ...updates } = body;
|
|
94
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
95
|
+
const entity = await ctx.em.findOne(CpqProductRelationship, { id, ...scope });
|
|
96
|
+
if (!entity) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
97
|
+
ctx.em.assign(entity, updates);
|
|
98
|
+
await ctx.em.flush();
|
|
99
|
+
return NextResponse.json({
|
|
100
|
+
id: entity.id,
|
|
101
|
+
sourceSpecId: entity.sourceSpecId,
|
|
102
|
+
targetSpecId: entity.targetSpecId,
|
|
103
|
+
relationshipType: entity.relationshipType,
|
|
104
|
+
cardinalityMin: entity.cardinalityMin,
|
|
105
|
+
cardinalityMax: entity.cardinalityMax,
|
|
106
|
+
condition: entity.condition,
|
|
107
|
+
metadata: entity.metadata,
|
|
108
|
+
isActive: entity.isActive,
|
|
109
|
+
createdAt: entity.createdAt,
|
|
110
|
+
updatedAt: entity.updatedAt
|
|
111
|
+
});
|
|
112
|
+
} catch (err) {
|
|
113
|
+
if (err instanceof z.ZodError) {
|
|
114
|
+
return NextResponse.json({ error: "Validation error", details: err.issues }, { status: 400 });
|
|
115
|
+
}
|
|
116
|
+
console.error("[cpq/product-relationships.PUT]", err);
|
|
117
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function DELETE(req) {
|
|
121
|
+
try {
|
|
122
|
+
const ctx = await resolveCpqRouteContext(req);
|
|
123
|
+
if (!ctx.auth) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
124
|
+
const { id } = await req.json();
|
|
125
|
+
if (!id) return NextResponse.json({ error: "Missing id" }, { status: 400 });
|
|
126
|
+
const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null };
|
|
127
|
+
const entity = await ctx.em.findOne(CpqProductRelationship, { id, ...scope });
|
|
128
|
+
if (!entity) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
|
129
|
+
entity.deletedAt = /* @__PURE__ */ new Date();
|
|
130
|
+
await ctx.em.flush();
|
|
131
|
+
return NextResponse.json({ success: true });
|
|
132
|
+
} catch (err) {
|
|
133
|
+
console.error("[cpq/product-relationships.DELETE]", err);
|
|
134
|
+
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
DELETE,
|
|
139
|
+
GET,
|
|
140
|
+
POST,
|
|
141
|
+
PUT,
|
|
142
|
+
metadata
|
|
143
|
+
};
|
|
144
|
+
//# sourceMappingURL=route.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/cpq/api/product-relationships/route.ts"],
|
|
4
|
+
"sourcesContent": ["import { NextResponse } from 'next/server'\nimport { z } from 'zod'\nimport { resolveCpqRouteContext } from '../context'\nimport { CpqProductRelationship } from '../../data/entities'\nimport { cpqProductRelationshipCreateSchema, cpqProductRelationshipUpdateSchema } from '../../data/validators'\n\nexport const metadata = {\n GET: { requireAuth: true, requireFeatures: ['cpq.specifications.view'] },\n POST: { requireAuth: true, requireFeatures: ['cpq.specifications.manage'] },\n PUT: { requireAuth: true, requireFeatures: ['cpq.specifications.manage'] },\n DELETE: { requireAuth: true, requireFeatures: ['cpq.specifications.manage'] },\n}\n\nexport async function GET(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const url = new URL(req.url)\n const page = Math.max(1, Number(url.searchParams.get('page') ?? '1'))\n const pageSize = Math.min(100, Math.max(1, Number(url.searchParams.get('pageSize') ?? '50')))\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n\n const filters: Record<string, unknown> = { ...scope }\n const sourceSpecId = url.searchParams.get('sourceSpecId')\n if (sourceSpecId) filters.sourceSpecId = sourceSpecId\n const targetSpecId = url.searchParams.get('targetSpecId')\n if (targetSpecId) filters.targetSpecId = targetSpecId\n const relationshipType = url.searchParams.get('relationshipType')\n if (relationshipType) filters.relationshipType = relationshipType\n\n const [items, total] = await ctx.em.findAndCount(CpqProductRelationship, filters, {\n limit: pageSize,\n offset: (page - 1) * pageSize,\n orderBy: { createdAt: 'desc' },\n })\n\n return NextResponse.json({\n items: items.map((item) => ({\n id: item.id,\n sourceSpecId: item.sourceSpecId,\n targetSpecId: item.targetSpecId,\n relationshipType: item.relationshipType,\n cardinalityMin: item.cardinalityMin,\n cardinalityMax: item.cardinalityMax,\n condition: item.condition,\n metadata: item.metadata,\n isActive: item.isActive,\n createdAt: item.createdAt,\n updatedAt: item.updatedAt,\n })),\n total,\n page,\n pageSize,\n totalPages: Math.ceil(total / pageSize),\n })\n } catch (err) {\n console.error('[cpq/product-relationships.GET]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function POST(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const body = cpqProductRelationshipCreateSchema.parse(await req.json())\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId }\n\n const entity = ctx.em.create(CpqProductRelationship, { ...body, ...scope })\n await ctx.em.flush()\n\n return NextResponse.json(\n {\n id: entity.id,\n sourceSpecId: entity.sourceSpecId,\n targetSpecId: entity.targetSpecId,\n relationshipType: entity.relationshipType,\n cardinalityMin: entity.cardinalityMin,\n cardinalityMax: entity.cardinalityMax,\n condition: entity.condition,\n metadata: entity.metadata,\n isActive: entity.isActive,\n createdAt: entity.createdAt,\n updatedAt: entity.updatedAt,\n },\n { status: 201 },\n )\n } catch (err) {\n if (err instanceof z.ZodError) {\n return NextResponse.json({ error: 'Validation error', details: err.issues }, { status: 400 })\n }\n console.error('[cpq/product-relationships.POST]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function PUT(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const body = cpqProductRelationshipUpdateSchema.parse(await req.json())\n const { id, ...updates } = body\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n\n const entity = await ctx.em.findOne(CpqProductRelationship, { id, ...scope })\n if (!entity) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n ctx.em.assign(entity, updates)\n await ctx.em.flush()\n\n return NextResponse.json({\n id: entity.id,\n sourceSpecId: entity.sourceSpecId,\n targetSpecId: entity.targetSpecId,\n relationshipType: entity.relationshipType,\n cardinalityMin: entity.cardinalityMin,\n cardinalityMax: entity.cardinalityMax,\n condition: entity.condition,\n metadata: entity.metadata,\n isActive: entity.isActive,\n createdAt: entity.createdAt,\n updatedAt: entity.updatedAt,\n })\n } catch (err) {\n if (err instanceof z.ZodError) {\n return NextResponse.json({ error: 'Validation error', details: err.issues }, { status: 400 })\n }\n console.error('[cpq/product-relationships.PUT]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n\nexport async function DELETE(req: Request) {\n try {\n const ctx = await resolveCpqRouteContext(req)\n if (!ctx.auth) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })\n\n const { id } = (await req.json()) as { id?: string }\n if (!id) return NextResponse.json({ error: 'Missing id' }, { status: 400 })\n\n const scope = { organizationId: ctx.organizationId, tenantId: ctx.tenantId, deletedAt: null }\n const entity = await ctx.em.findOne(CpqProductRelationship, { id, ...scope })\n if (!entity) return NextResponse.json({ error: 'Not found' }, { status: 404 })\n\n entity.deletedAt = new Date()\n await ctx.em.flush()\n\n return NextResponse.json({ success: true })\n } catch (err) {\n console.error('[cpq/product-relationships.DELETE]', err)\n return NextResponse.json({ error: 'Internal error' }, { status: 500 })\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAC7B,SAAS,SAAS;AAClB,SAAS,8BAA8B;AACvC,SAAS,8BAA8B;AACvC,SAAS,oCAAoC,0CAA0C;AAEhF,MAAM,WAAW;AAAA,EACtB,KAAK,EAAE,aAAa,MAAM,iBAAiB,CAAC,yBAAyB,EAAE;AAAA,EACvE,MAAM,EAAE,aAAa,MAAM,iBAAiB,CAAC,2BAA2B,EAAE;AAAA,EAC1E,KAAK,EAAE,aAAa,MAAM,iBAA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