@powerhousedao/service-offering 1.0.0-dev.1 → 1.0.0-dev.10
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/dist/document-models/facet/v1/actions.d.ts +3 -1
- package/dist/document-models/facet/v1/actions.d.ts.map +1 -1
- package/dist/document-models/facet/v1/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/facet/v1/gen/document-model.js +31 -7
- package/dist/document-models/facet/v1/gen/document-schema.d.ts +6 -6
- package/dist/document-models/facet/v1/gen/index.d.ts.map +1 -1
- package/dist/document-models/facet/v1/gen/index.js +2 -0
- package/dist/document-models/facet/v1/gen/option-management/error.d.ts +27 -1
- package/dist/document-models/facet/v1/gen/option-management/error.d.ts.map +1 -1
- package/dist/document-models/facet/v1/gen/option-management/error.js +23 -1
- package/dist/document-models/facet/v1/gen/ph-factories.js +2 -2
- package/dist/document-models/facet/v1/gen/schema/types.d.ts +2 -2
- package/dist/document-models/facet/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/facet/v1/gen/schema/zod.js +2 -2
- package/dist/document-models/facet/v1/gen/utils.js +2 -2
- package/dist/document-models/facet/v1/module.d.ts +1 -1
- package/dist/document-models/facet/v1/module.d.ts.map +1 -1
- package/dist/document-models/facet/v1/module.js +4 -1
- package/dist/document-models/resource-instance/v1/actions.d.ts +4 -1
- package/dist/document-models/resource-instance/v1/actions.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/configuration-management/error.d.ts +34 -1
- package/dist/document-models/resource-instance/v1/gen/configuration-management/error.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/configuration-management/error.js +32 -1
- package/dist/document-models/resource-instance/v1/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/document-model.js +222 -70
- package/dist/document-models/resource-instance/v1/gen/document-schema.d.ts +0 -6
- package/dist/document-models/resource-instance/v1/gen/document-schema.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/index.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/index.js +2 -0
- package/dist/document-models/resource-instance/v1/gen/instance-management/actions.d.ts +6 -2
- package/dist/document-models/resource-instance/v1/gen/instance-management/actions.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/creators.d.ts +3 -2
- package/dist/document-models/resource-instance/v1/gen/instance-management/creators.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/creators.js +2 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/error.d.ts +98 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/error.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/error.js +112 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/operations.d.ts +2 -1
- package/dist/document-models/resource-instance/v1/gen/instance-management/operations.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/ph-factories.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/ph-factories.js +0 -2
- package/dist/document-models/resource-instance/v1/gen/reducer.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/reducer.js +6 -1
- package/dist/document-models/resource-instance/v1/gen/schema/types.d.ts +3 -3
- package/dist/document-models/resource-instance/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/schema/zod.d.ts +2 -1
- package/dist/document-models/resource-instance/v1/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/schema/zod.js +5 -3
- package/dist/document-models/resource-instance/v1/gen/utils.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/gen/utils.js +0 -2
- package/dist/document-models/resource-instance/v1/module.d.ts +1 -1
- package/dist/document-models/resource-instance/v1/module.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/module.js +4 -1
- package/dist/document-models/resource-instance/v1/src/reducers/configuration-management.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/src/reducers/configuration-management.js +57 -53
- package/dist/document-models/resource-instance/v1/src/reducers/instance-management.d.ts.map +1 -1
- package/dist/document-models/resource-instance/v1/src/reducers/instance-management.js +57 -21
- package/dist/document-models/resource-instance/v1/tests/instance-management.test.js +11 -1
- package/dist/document-models/resource-template/v1/actions.d.ts +3 -1
- package/dist/document-models/resource-template/v1/actions.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/audience-management/error.d.ts +20 -1
- package/dist/document-models/resource-template/v1/gen/audience-management/error.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/audience-management/error.js +16 -1
- package/dist/document-models/resource-template/v1/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/document-model.js +207 -89
- package/dist/document-models/resource-template/v1/gen/document-schema.d.ts +12 -12
- package/dist/document-models/resource-template/v1/gen/facet-targeting/error.d.ts +27 -1
- package/dist/document-models/resource-template/v1/gen/facet-targeting/error.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/facet-targeting/error.js +23 -1
- package/dist/document-models/resource-template/v1/gen/index.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/index.js +2 -0
- package/dist/document-models/resource-template/v1/gen/option-group-management/error.d.ts +27 -1
- package/dist/document-models/resource-template/v1/gen/option-group-management/error.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/option-group-management/error.js +23 -1
- package/dist/document-models/resource-template/v1/gen/ph-factories.js +3 -3
- package/dist/document-models/resource-template/v1/gen/schema/types.d.ts +4 -4
- package/dist/document-models/resource-template/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/schema/zod.js +4 -4
- package/dist/document-models/resource-template/v1/gen/service-management/error.d.ts +51 -1
- package/dist/document-models/resource-template/v1/gen/service-management/error.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/gen/service-management/error.js +49 -1
- package/dist/document-models/resource-template/v1/gen/utils.js +3 -3
- package/dist/document-models/resource-template/v1/module.d.ts +1 -1
- package/dist/document-models/resource-template/v1/module.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/module.js +4 -1
- package/dist/document-models/resource-template/v1/src/reducers/option-group-management.d.ts.map +1 -1
- package/dist/document-models/resource-template/v1/src/reducers/option-group-management.js +2 -21
- package/dist/document-models/service-offering/v1/actions.d.ts +3 -1
- package/dist/document-models/service-offering/v1/actions.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/document-model.js +421 -199
- package/dist/document-models/service-offering/v1/gen/document-schema.d.ts +9 -9
- package/dist/document-models/service-offering/v1/gen/index.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/index.js +2 -0
- package/dist/document-models/service-offering/v1/gen/offering/error.d.ts +41 -1
- package/dist/document-models/service-offering/v1/gen/offering/error.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/offering/error.js +37 -1
- package/dist/document-models/service-offering/v1/gen/option-groups/error.d.ts +55 -1
- package/dist/document-models/service-offering/v1/gen/option-groups/error.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/option-groups/error.js +53 -1
- package/dist/document-models/service-offering/v1/gen/ph-factories.js +3 -3
- package/dist/document-models/service-offering/v1/gen/schema/types.d.ts +134 -61
- package/dist/document-models/service-offering/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/schema/zod.d.ts +35 -10
- package/dist/document-models/service-offering/v1/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/schema/zod.js +182 -64
- package/dist/document-models/service-offering/v1/gen/services/error.d.ts +20 -1
- package/dist/document-models/service-offering/v1/gen/services/error.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/services/error.js +16 -1
- package/dist/document-models/service-offering/v1/gen/tiers/error.d.ts +100 -1
- package/dist/document-models/service-offering/v1/gen/tiers/error.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/gen/tiers/error.js +106 -1
- package/dist/document-models/service-offering/v1/gen/utils.js +4 -4
- package/dist/document-models/service-offering/v1/module.d.ts +1 -1
- package/dist/document-models/service-offering/v1/module.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/module.js +4 -1
- package/dist/document-models/service-offering/v1/src/reducers/offering.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/src/reducers/offering.js +20 -12
- package/dist/document-models/service-offering/v1/src/reducers/option-groups.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/src/reducers/option-groups.js +157 -39
- package/dist/document-models/service-offering/v1/src/reducers/services.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/src/reducers/services.js +17 -14
- package/dist/document-models/service-offering/v1/src/reducers/tiers.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/src/reducers/tiers.js +111 -78
- package/dist/document-models/service-offering/v1/src/utils.d.ts +60 -1
- package/dist/document-models/service-offering/v1/src/utils.d.ts.map +1 -1
- package/dist/document-models/service-offering/v1/src/utils.js +173 -1
- package/dist/document-models/service-offering/v1/tests/option-groups.test.js +1 -1
- package/dist/document-models/service-offering/v1/utils.d.ts +3 -0
- package/dist/document-models/service-offering/v1/utils.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/actions.d.ts +3 -1
- package/dist/document-models/subscription-instance/v1/actions.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/document-model.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/document-model.js +488 -246
- package/dist/document-models/subscription-instance/v1/gen/document-schema.d.ts +3 -3
- package/dist/document-models/subscription-instance/v1/gen/index.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/index.js +2 -0
- package/dist/document-models/subscription-instance/v1/gen/metrics/error.d.ts +73 -1
- package/dist/document-models/subscription-instance/v1/gen/metrics/error.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/metrics/error.js +86 -1
- package/dist/document-models/subscription-instance/v1/gen/ph-factories.js +1 -1
- package/dist/document-models/subscription-instance/v1/gen/schema/types.d.ts +199 -82
- package/dist/document-models/subscription-instance/v1/gen/schema/types.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/schema/zod.d.ts +22 -12
- package/dist/document-models/subscription-instance/v1/gen/schema/zod.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/schema/zod.js +230 -84
- package/dist/document-models/subscription-instance/v1/gen/service/error.d.ts +62 -1
- package/dist/document-models/subscription-instance/v1/gen/service/error.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/service/error.js +60 -1
- package/dist/document-models/subscription-instance/v1/gen/service-group/error.d.ts +39 -1
- package/dist/document-models/subscription-instance/v1/gen/service-group/error.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/service-group/error.js +39 -1
- package/dist/document-models/subscription-instance/v1/gen/subscription/error.d.ts +55 -1
- package/dist/document-models/subscription-instance/v1/gen/subscription/error.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/gen/subscription/error.js +51 -1
- package/dist/document-models/subscription-instance/v1/gen/utils.js +2 -2
- package/dist/document-models/subscription-instance/v1/module.d.ts +1 -1
- package/dist/document-models/subscription-instance/v1/module.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/module.js +4 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/customer.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/customer.js +1 -0
- package/dist/document-models/subscription-instance/v1/src/reducers/metrics.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/metrics.js +70 -45
- package/dist/document-models/subscription-instance/v1/src/reducers/service-group.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/service-group.js +108 -30
- package/dist/document-models/subscription-instance/v1/src/reducers/service.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/service.js +108 -39
- package/dist/document-models/subscription-instance/v1/src/reducers/subscription.d.ts.map +1 -1
- package/dist/document-models/subscription-instance/v1/src/reducers/subscription.js +193 -35
- package/dist/document-models/upgrade-manifests.d.ts.map +1 -1
- package/dist/document-models/upgrade-manifests.js +0 -2
- package/dist/editors/resource-instance-editor/editor.d.ts.map +1 -1
- package/dist/editors/resource-instance-editor/editor.js +13 -3
- package/dist/editors/service-offering-editor/components/ResourceTemplateSelector.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/components/ResourceTemplateSelector.js +4 -2
- package/dist/editors/service-offering-editor/components/ServiceCatalog.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/components/ServiceCatalog.js +189 -32
- package/dist/editors/service-offering-editor/components/TheMatrix.d.ts +1 -1
- package/dist/editors/service-offering-editor/components/TheMatrix.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/components/TheMatrix.js +295 -140
- package/dist/editors/service-offering-editor/components/TierDefinition.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/components/TierDefinition.js +2 -0
- package/dist/editors/service-offering-editor/components/TierPricingOptionsPanel.js +3 -3
- package/dist/editors/service-offering-editor/components/pricing-utils.d.ts.map +1 -1
- package/dist/editors/service-offering-editor/components/pricing-utils.js +26 -7
- package/dist/editors/service-offering-editor/editor.css +119 -0
- package/dist/editors/subscription-instance-editor/components/BillingPanel.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/BillingPanel.js +4 -4
- package/dist/editors/subscription-instance-editor/components/CustomerInfo.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/CustomerInfo.js +3 -2
- package/dist/editors/subscription-instance-editor/components/ImportServiceConfigButton.d.ts +3 -0
- package/dist/editors/subscription-instance-editor/components/ImportServiceConfigButton.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/ImportServiceConfigButton.js +12 -0
- package/dist/editors/subscription-instance-editor/components/MetricActions.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/MetricActions.js +4 -2
- package/dist/editors/subscription-instance-editor/components/MockDataButton.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/MockDataButton.js +214 -2
- package/dist/editors/subscription-instance-editor/components/OperatorNotes.js +1 -1
- package/dist/editors/subscription-instance-editor/components/ServicesPanel.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/ServicesPanel.js +9 -20
- package/dist/editors/subscription-instance-editor/components/SubscriptionActions.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/SubscriptionActions.js +8 -9
- package/dist/editors/subscription-instance-editor/components/SubscriptionHeader.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/SubscriptionHeader.js +1 -1
- package/dist/editors/subscription-instance-editor/components/billing-utils.d.ts +14 -6
- package/dist/editors/subscription-instance-editor/components/billing-utils.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/billing-utils.js +19 -23
- package/dist/editors/subscription-instance-editor/components/mapOfferingToSubscription.d.ts +16 -2
- package/dist/editors/subscription-instance-editor/components/mapOfferingToSubscription.d.ts.map +1 -1
- package/dist/editors/subscription-instance-editor/components/mapOfferingToSubscription.js +155 -6
- package/dist/powerhouse.manifest.json +29 -3
- package/dist/style.css +14 -0
- package/dist/subgraphs/resources-services/resolvers.d.ts +2 -2
- package/dist/subgraphs/resources-services/resolvers.d.ts.map +1 -1
- package/dist/subgraphs/resources-services/resolvers.js +285 -213
- package/package.json +24 -19
- package/dist/document-models/facet/gen/schema/types.d.ts +0 -195
- package/dist/document-models/facet/gen/schema/types.d.ts.map +0 -1
- package/dist/document-models/facet/gen/schema/types.js +0 -1
- package/dist/document-models/facet/gen/schema/zod.d.ts +0 -18
- package/dist/document-models/facet/gen/schema/zod.d.ts.map +0 -1
- package/dist/document-models/facet/gen/schema/zod.js +0 -69
- package/dist/document-models/resource-instance/gen/schema/types.d.ts +0 -272
- package/dist/document-models/resource-instance/gen/schema/types.d.ts.map +0 -1
- package/dist/document-models/resource-instance/gen/schema/types.js +0 -1
- package/dist/document-models/resource-instance/gen/schema/zod.d.ts +0 -43
- package/dist/document-models/resource-instance/gen/schema/zod.d.ts.map +0 -1
- package/dist/document-models/resource-instance/gen/schema/zod.js +0 -185
- package/dist/document-models/resource-template/gen/schema/types.d.ts +0 -371
- package/dist/document-models/resource-template/gen/schema/types.d.ts.map +0 -1
- package/dist/document-models/resource-template/gen/schema/types.js +0 -1
- package/dist/document-models/resource-template/gen/schema/zod.d.ts +0 -52
- package/dist/document-models/resource-template/gen/schema/zod.d.ts.map +0 -1
- package/dist/document-models/resource-template/gen/schema/zod.js +0 -312
- package/dist/document-models/service-offering/gen/schema/types.d.ts +0 -451
- package/dist/document-models/service-offering/gen/schema/types.d.ts.map +0 -1
- package/dist/document-models/service-offering/gen/schema/types.js +0 -1
- package/dist/document-models/service-offering/gen/schema/zod.d.ts +0 -89
- package/dist/document-models/service-offering/gen/schema/zod.d.ts.map +0 -1
- package/dist/document-models/service-offering/gen/schema/zod.js +0 -419
- package/dist/document-models/subscription-instance/gen/schema/types.d.ts +0 -435
- package/dist/document-models/subscription-instance/gen/schema/types.d.ts.map +0 -1
- package/dist/document-models/subscription-instance/gen/schema/types.js +0 -1
- package/dist/document-models/subscription-instance/gen/schema/zod.d.ts +0 -99
- package/dist/document-models/subscription-instance/gen/schema/zod.d.ts.map +0 -1
- package/dist/document-models/subscription-instance/gen/schema/zod.js +0 -410
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {} from "
|
|
2
|
-
import { createAction
|
|
3
|
-
import { addFile } from "document-drive";
|
|
4
|
-
import {
|
|
1
|
+
import { getUserSelectionPriceBreakdown, } from "../../document-models/service-offering/v1/src/utils.js";
|
|
2
|
+
import { createAction } from "document-model/core";
|
|
3
|
+
import { addFile, driveCreateDocument } from "document-drive";
|
|
4
|
+
import { ResourceInstance } from "../../document-models/resource-instance/v1/module.js";
|
|
5
|
+
import { SubscriptionInstance } from "../../document-models/subscription-instance/v1/module.js";
|
|
6
|
+
import { mapOfferingToSubscription } from "../../editors/subscription-instance-editor/components/mapOfferingToSubscription.js";
|
|
5
7
|
export const getResolvers = (subgraph) => {
|
|
6
|
-
const
|
|
8
|
+
const reactorClient = subgraph.reactorClient;
|
|
7
9
|
return {
|
|
8
10
|
Query: {
|
|
9
11
|
resourceTemplates: async (_, args) => {
|
|
@@ -11,17 +13,15 @@ export const getResolvers = (subgraph) => {
|
|
|
11
13
|
// If filtering by specific id, try to fetch directly
|
|
12
14
|
if (id) {
|
|
13
15
|
try {
|
|
14
|
-
const doc = await
|
|
16
|
+
const doc = await reactorClient.get(id);
|
|
15
17
|
if (doc &&
|
|
16
18
|
doc.header.documentType === "powerhouse/resource-template") {
|
|
17
19
|
const state = doc.state.global;
|
|
18
|
-
// Check status filter if provided
|
|
19
20
|
if (status &&
|
|
20
21
|
status.length > 0 &&
|
|
21
22
|
!status.includes(state.status)) {
|
|
22
23
|
return [];
|
|
23
24
|
}
|
|
24
|
-
// Check operatorId filter if provided
|
|
25
25
|
if (operatorId && state.operatorId !== operatorId) {
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
@@ -33,42 +33,26 @@ export const getResolvers = (subgraph) => {
|
|
|
33
33
|
}
|
|
34
34
|
return [];
|
|
35
35
|
}
|
|
36
|
-
//
|
|
37
|
-
const
|
|
36
|
+
// Find all resource template documents
|
|
37
|
+
const { results: docs } = await reactorClient.find({
|
|
38
|
+
type: "powerhouse/resource-template",
|
|
39
|
+
});
|
|
38
40
|
const resourceTemplates = [];
|
|
39
|
-
for (const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
}));
|
|
50
|
-
for (const doc of docs) {
|
|
51
|
-
if (doc &&
|
|
52
|
-
doc.header.documentType === "powerhouse/resource-template") {
|
|
53
|
-
const resourceDoc = doc;
|
|
54
|
-
const state = resourceDoc.state.global;
|
|
55
|
-
// Apply status filter if provided
|
|
56
|
-
if (status &&
|
|
57
|
-
status.length > 0 &&
|
|
58
|
-
!status.includes(state.status)) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
// Apply operatorId filter if provided
|
|
62
|
-
if (operatorId && state.operatorId !== operatorId) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
resourceTemplates.push(mapResourceTemplateState(state, doc));
|
|
66
|
-
}
|
|
67
|
-
}
|
|
41
|
+
for (const doc of docs) {
|
|
42
|
+
const resourceDoc = doc;
|
|
43
|
+
const state = resourceDoc.state.global;
|
|
44
|
+
// Skip documents missing required fields
|
|
45
|
+
if (!state.operatorId)
|
|
46
|
+
continue;
|
|
47
|
+
// Apply status filter if provided
|
|
48
|
+
if (status && status.length > 0 && !status.includes(state.status)) {
|
|
49
|
+
continue;
|
|
68
50
|
}
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
// Apply operatorId filter if provided
|
|
52
|
+
if (operatorId && state.operatorId !== operatorId) {
|
|
53
|
+
continue;
|
|
71
54
|
}
|
|
55
|
+
resourceTemplates.push(mapResourceTemplateState(state, doc));
|
|
72
56
|
}
|
|
73
57
|
return resourceTemplates;
|
|
74
58
|
},
|
|
@@ -77,21 +61,18 @@ export const getResolvers = (subgraph) => {
|
|
|
77
61
|
// If filtering by specific id, try to fetch directly
|
|
78
62
|
if (id) {
|
|
79
63
|
try {
|
|
80
|
-
const doc = await
|
|
64
|
+
const doc = await reactorClient.get(id);
|
|
81
65
|
if (doc &&
|
|
82
66
|
doc.header.documentType === "powerhouse/service-offering") {
|
|
83
67
|
const state = doc.state.global;
|
|
84
|
-
// Check status filter if provided
|
|
85
68
|
if (status &&
|
|
86
69
|
status.length > 0 &&
|
|
87
70
|
!status.includes(state.status)) {
|
|
88
71
|
return [];
|
|
89
72
|
}
|
|
90
|
-
// Check operatorId filter if provided
|
|
91
73
|
if (operatorId && state.operatorId !== operatorId) {
|
|
92
74
|
return [];
|
|
93
75
|
}
|
|
94
|
-
// Check resourceTemplateId filter if provided
|
|
95
76
|
if (resourceTemplateId &&
|
|
96
77
|
state.resourceTemplateId !== resourceTemplateId) {
|
|
97
78
|
return [];
|
|
@@ -104,47 +85,31 @@ export const getResolvers = (subgraph) => {
|
|
|
104
85
|
}
|
|
105
86
|
return [];
|
|
106
87
|
}
|
|
107
|
-
//
|
|
108
|
-
const
|
|
88
|
+
// Find all service offering documents
|
|
89
|
+
const { results: docs } = await reactorClient.find({
|
|
90
|
+
type: "powerhouse/service-offering",
|
|
91
|
+
});
|
|
109
92
|
const serviceOfferings = [];
|
|
110
|
-
for (const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
doc.header.documentType === "powerhouse/service-offering") {
|
|
124
|
-
const offeringDoc = doc;
|
|
125
|
-
const state = offeringDoc.state.global;
|
|
126
|
-
// Apply status filter if provided
|
|
127
|
-
if (status &&
|
|
128
|
-
status.length > 0 &&
|
|
129
|
-
!status.includes(state.status)) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
// Apply operatorId filter if provided
|
|
133
|
-
if (operatorId && state.operatorId !== operatorId) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
// Apply resourceTemplateId filter if provided
|
|
137
|
-
if (resourceTemplateId &&
|
|
138
|
-
state.resourceTemplateId !== resourceTemplateId) {
|
|
139
|
-
continue;
|
|
140
|
-
}
|
|
141
|
-
serviceOfferings.push(mapServiceOfferingState(state, doc));
|
|
142
|
-
}
|
|
143
|
-
}
|
|
93
|
+
for (const doc of docs) {
|
|
94
|
+
const offeringDoc = doc;
|
|
95
|
+
const state = offeringDoc.state.global;
|
|
96
|
+
// Skip documents missing required fields
|
|
97
|
+
if (!state.operatorId)
|
|
98
|
+
continue;
|
|
99
|
+
// Apply status filter if provided
|
|
100
|
+
if (status && status.length > 0 && !status.includes(state.status)) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// Apply operatorId filter if provided
|
|
104
|
+
if (operatorId && state.operatorId !== operatorId) {
|
|
105
|
+
continue;
|
|
144
106
|
}
|
|
145
|
-
|
|
146
|
-
|
|
107
|
+
// Apply resourceTemplateId filter if provided
|
|
108
|
+
if (resourceTemplateId &&
|
|
109
|
+
state.resourceTemplateId !== resourceTemplateId) {
|
|
110
|
+
continue;
|
|
147
111
|
}
|
|
112
|
+
serviceOfferings.push(mapServiceOfferingState(state, doc));
|
|
148
113
|
}
|
|
149
114
|
return serviceOfferings;
|
|
150
115
|
},
|
|
@@ -230,7 +195,7 @@ export const getResolvers = (subgraph) => {
|
|
|
230
195
|
};
|
|
231
196
|
}
|
|
232
197
|
// Fetch the service offering
|
|
233
|
-
const serviceOfferingDoc = await
|
|
198
|
+
const serviceOfferingDoc = await reactorClient.get(serviceOfferingId);
|
|
234
199
|
if (!serviceOfferingDoc) {
|
|
235
200
|
return {
|
|
236
201
|
success: false,
|
|
@@ -247,13 +212,38 @@ export const getResolvers = (subgraph) => {
|
|
|
247
212
|
errors: ["Service offering has no associated resource template"],
|
|
248
213
|
};
|
|
249
214
|
}
|
|
250
|
-
//
|
|
251
|
-
const
|
|
252
|
-
|
|
215
|
+
// Convert GraphQL overrides to Record<string, BillingCycle>
|
|
216
|
+
const groupBillingCycleOverrides = {};
|
|
217
|
+
for (const o of userSelection.groupBillingCycleOverrides ?? []) {
|
|
218
|
+
groupBillingCycleOverrides[o.groupId] =
|
|
219
|
+
o.billingCycle;
|
|
220
|
+
}
|
|
221
|
+
const addonBillingCycleOverrides = {};
|
|
222
|
+
for (const o of userSelection.addonBillingCycleOverrides ?? []) {
|
|
223
|
+
addonBillingCycleOverrides[o.groupId] =
|
|
224
|
+
o.billingCycle;
|
|
225
|
+
}
|
|
226
|
+
// Compute price breakdown from user selection
|
|
227
|
+
const selection = {
|
|
228
|
+
tierId: userSelection.tierId,
|
|
229
|
+
billingCycle: userSelection.billingCycle,
|
|
230
|
+
optionGroupIds: userSelection.optionGroupIds ?? [],
|
|
231
|
+
groupBillingCycleOverrides,
|
|
232
|
+
addonBillingCycleOverrides,
|
|
233
|
+
};
|
|
234
|
+
let priceBreakdown;
|
|
235
|
+
try {
|
|
236
|
+
priceBreakdown = getUserSelectionPriceBreakdown(serviceOfferingDoc.state, selection);
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
253
239
|
return {
|
|
254
240
|
success: false,
|
|
255
241
|
data: null,
|
|
256
|
-
errors: [
|
|
242
|
+
errors: [
|
|
243
|
+
error instanceof Error
|
|
244
|
+
? error.message
|
|
245
|
+
: "Failed to compute price breakdown from user selection",
|
|
246
|
+
],
|
|
257
247
|
};
|
|
258
248
|
}
|
|
259
249
|
// Sanitize names for use as drive id/slug: lowercase, trim, collapse whitespace, replace spaces with hyphens
|
|
@@ -262,37 +252,51 @@ export const getResolvers = (subgraph) => {
|
|
|
262
252
|
.toLowerCase()
|
|
263
253
|
.replace(/\s+/g, "-")
|
|
264
254
|
.replace(/_/g, "-");
|
|
265
|
-
const parsedName = name
|
|
266
|
-
.trim()
|
|
267
|
-
.toLowerCase()
|
|
268
|
-
.replace(/\s+/g, "-")
|
|
269
|
-
.replace(/_/g, "-");
|
|
270
255
|
try {
|
|
271
256
|
// create team-builder-admin drive
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
257
|
+
const driveDoc = driveCreateDocument();
|
|
258
|
+
driveDoc.header.name = teamName;
|
|
259
|
+
driveDoc.state.global.name = teamName;
|
|
260
|
+
driveDoc.state.global.icon =
|
|
261
|
+
"https://cdn-icons-png.flaticon.com/512/6020/6020347.png";
|
|
262
|
+
driveDoc.header.slug = parsedTeamName;
|
|
263
|
+
if (!driveDoc.header.meta)
|
|
264
|
+
driveDoc.header.meta = {};
|
|
265
|
+
driveDoc.header.meta.preferredEditor = "builder-team-admin";
|
|
266
|
+
const teamBuilderAdminDrive = await reactorClient.create(driveDoc);
|
|
267
|
+
const driveId = teamBuilderAdminDrive.header.id;
|
|
268
|
+
// create documents as children of the drive so Connect can sync them
|
|
269
|
+
const builderProfileDoc = await reactorClient.createEmpty("powerhouse/builder-profile", { parentIdentifier: driveId });
|
|
270
|
+
const resourceInstanceDoc = await reactorClient.createEmpty("powerhouse/resource-instance", { parentIdentifier: driveId });
|
|
271
|
+
const subscriptionInstanceDoc = await reactorClient.createEmpty("powerhouse/subscription-instance", { parentIdentifier: driveId });
|
|
272
|
+
// add file references to the team drive
|
|
273
|
+
const teamRootFolder = teamBuilderAdminDrive.state.global.nodes.find((node) => node.kind === "folder")?.parentFolder;
|
|
274
|
+
await reactorClient.execute(driveId, "main", [
|
|
275
|
+
addFile({
|
|
276
|
+
documentType: "powerhouse/builder-profile",
|
|
277
|
+
id: builderProfileDoc.header.id,
|
|
278
|
+
name: `${parsedTeamName} Builder Profile`,
|
|
279
|
+
parentFolder: teamRootFolder,
|
|
280
|
+
}),
|
|
281
|
+
addFile({
|
|
282
|
+
documentType: "powerhouse/resource-instance",
|
|
283
|
+
id: resourceInstanceDoc.header.id,
|
|
284
|
+
name: `${parsedTeamName} Resource Instance`,
|
|
285
|
+
parentFolder: teamRootFolder,
|
|
286
|
+
}),
|
|
287
|
+
addFile({
|
|
288
|
+
documentType: "powerhouse/subscription-instance",
|
|
289
|
+
id: subscriptionInstanceDoc.header.id,
|
|
290
|
+
name: `${parsedTeamName} Subscription Instance`,
|
|
291
|
+
parentFolder: teamRootFolder,
|
|
292
|
+
}),
|
|
293
|
+
]);
|
|
294
|
+
// update builder profile
|
|
295
|
+
await reactorClient.execute(builderProfileDoc.header.id, "main", [
|
|
296
|
+
createAction("UPDATE_PROFILE", { name: parsedTeamName }, undefined, undefined, "global"),
|
|
297
|
+
]);
|
|
298
|
+
// find operator drive and add references there too
|
|
299
|
+
const operatorDrive = await getOperatorDrive(reactorClient, resourceTemplateId);
|
|
296
300
|
if (!operatorDrive) {
|
|
297
301
|
throw new Error(`Operator drive not found for resource template ${resourceTemplateId}`);
|
|
298
302
|
}
|
|
@@ -304,23 +308,14 @@ export const getResolvers = (subgraph) => {
|
|
|
304
308
|
throw new Error(`Operator profile not found for drive ${operatorDrive.header.id}`);
|
|
305
309
|
}
|
|
306
310
|
const operatorParentFolder = operatorDrive.state.global.nodes.find((node) => node.kind === "folder")?.parentFolder;
|
|
307
|
-
//
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
name: `${parsedTeamName} Resource Instance`,
|
|
313
|
-
parentFolder: teamParentFolder,
|
|
314
|
-
}),
|
|
315
|
-
addFile({
|
|
316
|
-
documentType: "powerhouse/subscription-instance",
|
|
317
|
-
id: subscriptionInstanceDoc.header.id,
|
|
318
|
-
name: `${parsedTeamName} Subscription Instance`,
|
|
319
|
-
parentFolder: teamParentFolder,
|
|
320
|
-
}),
|
|
311
|
+
// add reactor-level relationships so Connect syncs the child documents
|
|
312
|
+
// (createEmpty guarantees CREATE_DOCUMENT is persisted before this runs)
|
|
313
|
+
await reactorClient.addChildren(operatorDrive.header.id, [
|
|
314
|
+
resourceInstanceDoc.header.id,
|
|
315
|
+
subscriptionInstanceDoc.header.id,
|
|
321
316
|
]);
|
|
322
|
-
//
|
|
323
|
-
await
|
|
317
|
+
// add file references to operator drive
|
|
318
|
+
await reactorClient.execute(operatorDrive.header.id, "main", [
|
|
324
319
|
addFile({
|
|
325
320
|
documentType: "powerhouse/resource-instance",
|
|
326
321
|
id: resourceInstanceDoc.header.id,
|
|
@@ -335,30 +330,37 @@ export const getResolvers = (subgraph) => {
|
|
|
335
330
|
}),
|
|
336
331
|
]);
|
|
337
332
|
// populate documents after all files are added to both drives
|
|
338
|
-
await populateResourceInstance(
|
|
333
|
+
await populateResourceInstance(reactorClient, resourceInstanceDoc.header.id, resourceTemplateId, operatorProfileId, // operator profile id
|
|
339
334
|
builderProfileDoc.header.id, // customer id
|
|
340
335
|
parsedTeamName);
|
|
341
336
|
const now = new Date().toISOString();
|
|
342
|
-
|
|
343
|
-
|
|
337
|
+
const subscriptionInput = mapOfferingToSubscription({
|
|
338
|
+
offering: serviceOfferingState,
|
|
339
|
+
tierId: selection.tierId,
|
|
340
|
+
selectedBillingCycle: selection.billingCycle,
|
|
344
341
|
customerId: builderProfileDoc.header.id,
|
|
345
342
|
customerName: name,
|
|
346
343
|
customerEmail,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
344
|
+
createdAt: now,
|
|
345
|
+
priceBreakdown,
|
|
346
|
+
});
|
|
347
|
+
await reactorClient.execute(subscriptionInstanceDoc.header.id, "main", [
|
|
348
|
+
SubscriptionInstance.actions.initializeSubscription({
|
|
349
|
+
...subscriptionInput,
|
|
350
|
+
resourceId: resourceInstanceDoc.header.id,
|
|
351
|
+
resourceLabel: parsedTeamName,
|
|
352
|
+
resourceThumbnailUrl: serviceOfferingState.thumbnailUrl,
|
|
353
|
+
}),
|
|
354
|
+
]);
|
|
355
|
+
// Set billing projection from tier price
|
|
356
|
+
const projectedAmount = subscriptionInput.tierPrice ?? priceBreakdown.tierCycleTotal;
|
|
357
357
|
if (projectedAmount != null) {
|
|
358
|
-
await
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
358
|
+
await reactorClient.execute(subscriptionInstanceDoc.header.id, "main", [
|
|
359
|
+
SubscriptionInstance.actions.updateBillingProjection({
|
|
360
|
+
projectedBillAmount: projectedAmount,
|
|
361
|
+
projectedBillCurrency: priceBreakdown.tierCurrency || "USD",
|
|
362
|
+
}),
|
|
363
|
+
]);
|
|
362
364
|
}
|
|
363
365
|
return {
|
|
364
366
|
success: true,
|
|
@@ -389,7 +391,7 @@ export const getResolvers = (subgraph) => {
|
|
|
389
391
|
* Uses the drive slug in the switchboard URL path.
|
|
390
392
|
*/
|
|
391
393
|
function getDriveLink(driveSlug) {
|
|
392
|
-
const baseUri = process.env.BASE_URI || "";
|
|
394
|
+
const baseUri = typeof process !== "undefined" ? process.env.BASE_URI || "" : "";
|
|
393
395
|
if (baseUri.includes("-dev.")) {
|
|
394
396
|
return `https://connect-dev.powerhouse.xyz/?driveUrl=https://switchboard-dev.powerhouse.xyz/d/${driveSlug}`;
|
|
395
397
|
}
|
|
@@ -415,18 +417,18 @@ function mapResourceTemplateState(state, doc) {
|
|
|
415
417
|
infoLink: state.infoLink || null,
|
|
416
418
|
status: state.status,
|
|
417
419
|
lastModified: state.lastModified,
|
|
418
|
-
targetAudiences: state.targetAudiences.map((audience) => ({
|
|
420
|
+
targetAudiences: (state.targetAudiences || []).map((audience) => ({
|
|
419
421
|
id: audience.id,
|
|
420
422
|
label: audience.label,
|
|
421
423
|
color: audience.color || null,
|
|
422
424
|
})),
|
|
423
|
-
setupServices: state.setupServices,
|
|
424
|
-
recurringServices: state.recurringServices,
|
|
425
|
-
facetTargets: state.facetTargets.map((facet) => ({
|
|
425
|
+
setupServices: state.setupServices || [],
|
|
426
|
+
recurringServices: state.recurringServices || [],
|
|
427
|
+
facetTargets: (state.facetTargets || []).map((facet) => ({
|
|
426
428
|
id: facet.id,
|
|
427
429
|
categoryKey: facet.categoryKey,
|
|
428
430
|
categoryLabel: facet.categoryLabel,
|
|
429
|
-
selectedOptions: facet.selectedOptions,
|
|
431
|
+
selectedOptions: facet.selectedOptions || [],
|
|
430
432
|
})),
|
|
431
433
|
services: (state.services || []).map((service) => ({
|
|
432
434
|
id: service.id,
|
|
@@ -436,6 +438,12 @@ function mapResourceTemplateState(state, doc) {
|
|
|
436
438
|
parentServiceId: service.parentServiceId || null,
|
|
437
439
|
isSetupFormation: service.isSetupFormation,
|
|
438
440
|
optionGroupId: service.optionGroupId || null,
|
|
441
|
+
facetBindings: (service.facetBindings || []).map((binding) => ({
|
|
442
|
+
id: binding.id,
|
|
443
|
+
facetName: binding.facetName,
|
|
444
|
+
facetType: binding.facetType,
|
|
445
|
+
supportedOptions: binding.supportedOptions || [],
|
|
446
|
+
})),
|
|
439
447
|
})),
|
|
440
448
|
optionGroups: (state.optionGroups || []).map((group) => ({
|
|
441
449
|
id: group.id,
|
|
@@ -450,7 +458,7 @@ function mapResourceTemplateState(state, doc) {
|
|
|
450
458
|
answer: faq.answer || null,
|
|
451
459
|
displayOrder: faq.displayOrder,
|
|
452
460
|
})),
|
|
453
|
-
contentSections: state.contentSections.map((section) => ({
|
|
461
|
+
contentSections: (state.contentSections || []).map((section) => ({
|
|
454
462
|
id: section.id,
|
|
455
463
|
title: section.title,
|
|
456
464
|
content: section.content,
|
|
@@ -462,35 +470,50 @@ function mapResourceTemplateState(state, doc) {
|
|
|
462
470
|
* Populate a resource-instance document with data from a resource-template.
|
|
463
471
|
* Initializes basic info and sets facet configuration from template facetTargets.
|
|
464
472
|
*/
|
|
465
|
-
async function populateResourceInstance(
|
|
466
|
-
const resourceTemplateDoc = await
|
|
473
|
+
async function populateResourceInstance(reactorClient, resourceInstanceDocId, resourceTemplateId, operatorId, customerId, customerName) {
|
|
474
|
+
const resourceTemplateDoc = await reactorClient.get(resourceTemplateId);
|
|
467
475
|
if (!resourceTemplateDoc)
|
|
468
476
|
return;
|
|
469
477
|
const templateState = resourceTemplateDoc.state.global;
|
|
470
478
|
// Initialize instance with basic info from template
|
|
471
|
-
await
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
479
|
+
await reactorClient.execute(resourceInstanceDocId, "main", [
|
|
480
|
+
ResourceInstance.actions.initializeInstance({
|
|
481
|
+
operatorId,
|
|
482
|
+
operatorDocumentType: "powerhouse/builder-profile",
|
|
483
|
+
resourceTemplateId,
|
|
484
|
+
customerId,
|
|
485
|
+
customerName,
|
|
486
|
+
templateName: templateState.title,
|
|
487
|
+
thumbnailUrl: templateState.thumbnailUrl,
|
|
488
|
+
infoLink: templateState.infoLink,
|
|
489
|
+
description: templateState.description,
|
|
490
|
+
}),
|
|
491
|
+
]);
|
|
482
492
|
// Populate facet configuration from template's facetTargets
|
|
483
493
|
for (const facetTarget of templateState.facetTargets) {
|
|
484
494
|
if (facetTarget.selectedOptions.length > 0) {
|
|
485
|
-
await
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
495
|
+
await reactorClient.execute(resourceInstanceDocId, "main", [
|
|
496
|
+
ResourceInstance.actions.setInstanceFacet({
|
|
497
|
+
id: facetTarget.id,
|
|
498
|
+
categoryKey: facetTarget.categoryKey,
|
|
499
|
+
categoryLabel: facetTarget.categoryLabel,
|
|
500
|
+
selectedOption: facetTarget.selectedOptions[0],
|
|
501
|
+
}),
|
|
502
|
+
]);
|
|
491
503
|
}
|
|
492
504
|
}
|
|
493
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Map a DiscountRule to the GraphQL shape, or null
|
|
508
|
+
*/
|
|
509
|
+
function mapDiscountRule(rule) {
|
|
510
|
+
if (!rule)
|
|
511
|
+
return null;
|
|
512
|
+
return {
|
|
513
|
+
discountType: rule.discountType,
|
|
514
|
+
discountValue: rule.discountValue,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
494
517
|
/**
|
|
495
518
|
* Map ServiceOfferingState from document model to GraphQL response
|
|
496
519
|
*/
|
|
@@ -506,14 +529,14 @@ function mapServiceOfferingState(state, doc) {
|
|
|
506
529
|
infoLink: state.infoLink || null,
|
|
507
530
|
status: state.status,
|
|
508
531
|
lastModified: state.lastModified,
|
|
509
|
-
availableBillingCycles: state.availableBillingCycles,
|
|
510
|
-
facetTargets: state.facetTargets.map((facet) => ({
|
|
532
|
+
availableBillingCycles: state.availableBillingCycles || [],
|
|
533
|
+
facetTargets: (state.facetTargets || []).map((facet) => ({
|
|
511
534
|
id: facet.id,
|
|
512
535
|
categoryKey: facet.categoryKey,
|
|
513
536
|
categoryLabel: facet.categoryLabel,
|
|
514
|
-
selectedOptions: facet.selectedOptions,
|
|
537
|
+
selectedOptions: facet.selectedOptions || [],
|
|
515
538
|
})),
|
|
516
|
-
services: state.services.map((service) => ({
|
|
539
|
+
services: (state.services || []).map((service) => ({
|
|
517
540
|
id: service.id,
|
|
518
541
|
title: service.title,
|
|
519
542
|
description: service.description || null,
|
|
@@ -521,37 +544,45 @@ function mapServiceOfferingState(state, doc) {
|
|
|
521
544
|
isSetupFormation: service.isSetupFormation,
|
|
522
545
|
optionGroupId: service.optionGroupId || null,
|
|
523
546
|
})),
|
|
524
|
-
tiers: state.tiers.map((tier) => ({
|
|
547
|
+
tiers: (state.tiers || []).map((tier) => ({
|
|
525
548
|
id: tier.id,
|
|
526
549
|
name: tier.name,
|
|
527
550
|
description: tier.description || null,
|
|
528
551
|
isCustomPricing: tier.isCustomPricing,
|
|
529
552
|
pricingMode: tier.pricingMode || null,
|
|
530
|
-
pricing:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
}
|
|
535
|
-
: null,
|
|
553
|
+
pricing: {
|
|
554
|
+
amount: tier.pricing?.amount ?? null,
|
|
555
|
+
currency: tier.pricing?.currency ?? "USD",
|
|
556
|
+
},
|
|
536
557
|
defaultBillingCycle: tier.defaultBillingCycle || null,
|
|
537
|
-
billingCycleDiscounts: tier.billingCycleDiscounts.map((d) => ({
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
558
|
+
billingCycleDiscounts: (tier.billingCycleDiscounts || []).map((d) => ({
|
|
559
|
+
billingCycle: d.billingCycle,
|
|
560
|
+
discountRule: {
|
|
561
|
+
discountType: d.discountRule?.discountType,
|
|
562
|
+
discountValue: d.discountRule?.discountValue,
|
|
563
|
+
},
|
|
541
564
|
})),
|
|
542
|
-
serviceLevels: tier.serviceLevels.map((level) => ({
|
|
565
|
+
serviceLevels: (tier.serviceLevels || []).map((level) => ({
|
|
543
566
|
id: level.id,
|
|
544
567
|
serviceId: level.serviceId,
|
|
545
568
|
level: level.level,
|
|
569
|
+
customValue: level.customValue || null,
|
|
570
|
+
optionGroupId: level.optionGroupId || null,
|
|
546
571
|
})),
|
|
547
|
-
usageLimits: tier.usageLimits.map((limit) => ({
|
|
572
|
+
usageLimits: (tier.usageLimits || []).map((limit) => ({
|
|
548
573
|
id: limit.id,
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
574
|
+
serviceId: limit.serviceId,
|
|
575
|
+
metric: limit.metric,
|
|
576
|
+
unitName: limit.unitName || null,
|
|
577
|
+
freeLimit: limit.freeLimit ?? null,
|
|
578
|
+
paidLimit: limit.paidLimit ?? null,
|
|
579
|
+
resetCycle: limit.resetCycle || null,
|
|
580
|
+
notes: limit.notes || null,
|
|
581
|
+
unitPrice: limit.unitPrice ?? null,
|
|
582
|
+
unitPriceCurrency: limit.unitPriceCurrency || null,
|
|
552
583
|
})),
|
|
553
584
|
})),
|
|
554
|
-
optionGroups: state.optionGroups.map((group) => ({
|
|
585
|
+
optionGroups: (state.optionGroups || []).map((group) => ({
|
|
555
586
|
id: group.id,
|
|
556
587
|
name: group.name,
|
|
557
588
|
description: group.description || null,
|
|
@@ -560,21 +591,55 @@ function mapServiceOfferingState(state, doc) {
|
|
|
560
591
|
pricingMode: group.pricingMode || null,
|
|
561
592
|
standalonePricing: group.standalonePricing
|
|
562
593
|
? {
|
|
563
|
-
|
|
564
|
-
|
|
594
|
+
setupCost: group.standalonePricing.setupCost
|
|
595
|
+
? {
|
|
596
|
+
amount: group.standalonePricing.setupCost.amount,
|
|
597
|
+
currency: group.standalonePricing.setupCost.currency,
|
|
598
|
+
discount: mapDiscountRule(group.standalonePricing.setupCost.discount),
|
|
599
|
+
}
|
|
600
|
+
: null,
|
|
601
|
+
recurringPricing: (group.standalonePricing.recurringPricing || []).map((rp) => ({
|
|
602
|
+
id: rp.id,
|
|
603
|
+
billingCycle: rp.billingCycle,
|
|
604
|
+
amount: rp.amount,
|
|
605
|
+
currency: rp.currency,
|
|
606
|
+
discount: mapDiscountRule(rp.discount),
|
|
607
|
+
})),
|
|
565
608
|
}
|
|
566
609
|
: null,
|
|
567
610
|
tierDependentPricing: (group.tierDependentPricing || []).map((tp) => ({
|
|
611
|
+
id: tp.id,
|
|
568
612
|
tierId: tp.tierId,
|
|
569
|
-
|
|
570
|
-
|
|
613
|
+
setupCost: tp.setupCost
|
|
614
|
+
? {
|
|
615
|
+
amount: tp.setupCost.amount,
|
|
616
|
+
currency: tp.setupCost.currency,
|
|
617
|
+
discount: mapDiscountRule(tp.setupCost.discount),
|
|
618
|
+
}
|
|
619
|
+
: null,
|
|
620
|
+
setupCostDiscounts: (tp.setupCostDiscounts || []).map((d) => ({
|
|
621
|
+
billingCycle: d.billingCycle,
|
|
622
|
+
discountRule: {
|
|
623
|
+
discountType: d.discountRule?.discountType,
|
|
624
|
+
discountValue: d.discountRule?.discountValue,
|
|
625
|
+
},
|
|
626
|
+
})),
|
|
627
|
+
recurringPricing: (tp.recurringPricing || []).map((rp) => ({
|
|
628
|
+
id: rp.id,
|
|
629
|
+
billingCycle: rp.billingCycle,
|
|
630
|
+
amount: rp.amount,
|
|
631
|
+
currency: rp.currency,
|
|
632
|
+
discount: mapDiscountRule(rp.discount),
|
|
633
|
+
})),
|
|
571
634
|
})),
|
|
572
635
|
costType: group.costType || null,
|
|
573
636
|
availableBillingCycles: group.availableBillingCycles || [],
|
|
574
|
-
billingCycleDiscounts: group.billingCycleDiscounts.map((d) => ({
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
637
|
+
billingCycleDiscounts: (group.billingCycleDiscounts || []).map((d) => ({
|
|
638
|
+
billingCycle: d.billingCycle,
|
|
639
|
+
discountRule: {
|
|
640
|
+
discountType: d.discountRule?.discountType,
|
|
641
|
+
discountValue: d.discountRule?.discountValue,
|
|
642
|
+
},
|
|
578
643
|
})),
|
|
579
644
|
discountMode: group.discountMode || null,
|
|
580
645
|
price: group.price ?? null,
|
|
@@ -582,12 +647,19 @@ function mapServiceOfferingState(state, doc) {
|
|
|
582
647
|
})),
|
|
583
648
|
};
|
|
584
649
|
}
|
|
585
|
-
async function getOperatorDrive(
|
|
586
|
-
|
|
587
|
-
const results = await
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
650
|
+
async function getOperatorDrive(reactorClient, resourceTemplateId) {
|
|
651
|
+
// Find all drives
|
|
652
|
+
const { results: drives } = await reactorClient.find({
|
|
653
|
+
type: "powerhouse/document-drive",
|
|
654
|
+
});
|
|
655
|
+
for (const drive of drives) {
|
|
656
|
+
const driveDoc = drive;
|
|
657
|
+
// Check if this drive contains the resource template as a child
|
|
658
|
+
const { results: children } = await reactorClient.getChildren(driveDoc.header.id);
|
|
659
|
+
const hasTemplate = children.some((child) => child.header.id === resourceTemplateId);
|
|
660
|
+
if (hasTemplate) {
|
|
661
|
+
return driveDoc;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return undefined;
|
|
593
665
|
}
|