@veloceapps/sdk 8.0.0-18 → 8.0.0-180
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -1
- package/cms/README.md +0 -20
- package/cms/cms.actions.d.ts +7 -1
- package/cms/components/preview/preview.component.d.ts +2 -3
- package/cms/components/preview/preview.types.d.ts +4 -0
- package/cms/index.d.ts +1 -0
- package/cms/modules/runtime/services/runtime.service.d.ts +1 -1
- package/cms/services/index.d.ts +0 -1
- package/cms/services/resources.service.d.ts +2 -0
- package/cms/types/index.d.ts +0 -1
- package/cms/utils/element-metadata-worker.d.ts +11 -0
- package/cms/utils/elements-resolver.d.ts +0 -2
- package/cms/utils/index.d.ts +3 -0
- package/cms/utils/transpilation-worker.d.ts +13 -0
- package/cms/vendor-map.d.ts +26 -15
- package/core/README.md +20 -0
- package/core/modules/configuration/configuration.module.d.ts +2 -1
- package/core/modules/configuration/helpers.d.ts +4 -3
- package/core/modules/configuration/index.d.ts +1 -1
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
- package/core/modules/configuration/services/configuration-state.service.d.ts +51 -0
- package/core/modules/configuration/services/configuration.service.d.ts +10 -5
- package/core/modules/configuration/types/configuration.types.d.ts +4 -0
- package/core/modules/flow-configuration/flow-configuration.module.d.ts +2 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
- package/core/pipes/action-code.pipe.d.ts +8 -0
- package/core/pipes/date.pipe.d.ts +2 -1
- package/core/pipes/index.d.ts +1 -0
- package/core/pipes/pipes.module.d.ts +2 -1
- package/core/services/context.service.d.ts +4 -0
- package/core/services/flow-info.service.d.ts +29 -0
- package/core/services/flow-state-configuration.service.d.ts +19 -0
- package/core/services/flow-state.service.d.ts +79 -0
- package/core/services/index.d.ts +4 -1
- package/core/services/quote-draft.service.d.ts +8 -1
- package/core/services/runtime-settings.service.d.ts +4 -1
- package/core/types/flow-customization.types.d.ts +22 -0
- package/core/types/flow-state.types.d.ts +6 -0
- package/core/types/formatting-settings.types.d.ts +2 -0
- package/core/types/index.d.ts +3 -0
- package/{cms → core}/types/integration.types.d.ts +1 -0
- package/core/types/pipe.types.d.ts +1 -0
- package/core/utils/line-item.utils.d.ts +0 -1
- package/esm2020/cms/cms.actions.mjs +15 -1
- package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
- package/esm2020/cms/components/preview/preview.component.mjs +10 -10
- package/esm2020/cms/components/preview/preview.module.mjs +2 -2
- package/esm2020/cms/components/preview/preview.types.mjs +1 -1
- package/esm2020/cms/index.mjs +2 -1
- package/esm2020/cms/launcher.module.mjs +4 -4
- package/esm2020/cms/modules/migrations/migrations.mjs +2 -2
- package/esm2020/cms/modules/migrations/services/migrations.service.mjs +6 -2
- package/esm2020/cms/modules/runtime/services/compilation.service.mjs +11 -7
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +4 -4
- package/esm2020/cms/plugins/configuration.plugin.mjs +8 -4
- package/esm2020/cms/services/index.mjs +1 -2
- package/esm2020/cms/services/io-provider.service.mjs +10 -9
- package/esm2020/cms/services/resources.service.mjs +10 -6
- package/esm2020/cms/services/templates.service.mjs +10 -9
- package/esm2020/cms/types/index.mjs +1 -2
- package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
- package/esm2020/cms/utils/elements-resolver.mjs +14 -28
- package/esm2020/cms/utils/index.mjs +4 -1
- package/esm2020/cms/utils/path.utils.mjs +3 -3
- package/esm2020/cms/utils/script.utils.mjs +19 -15
- package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
- package/esm2020/cms/vendor-map.mjs +18 -6
- package/esm2020/core/core.module.mjs +12 -5
- package/esm2020/core/modules/configuration/configuration.module.mjs +7 -23
- package/esm2020/core/modules/configuration/helpers.mjs +28 -3
- package/esm2020/core/modules/configuration/index.mjs +2 -2
- package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +8 -11
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +304 -0
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +68 -45
- package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +6 -6
- package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
- package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +6 -6
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +10 -7
- package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
- package/esm2020/core/pipes/date.pipe.mjs +10 -4
- package/esm2020/core/pipes/index.mjs +2 -1
- package/esm2020/core/pipes/pipes.module.mjs +5 -4
- package/esm2020/core/services/context.service.mjs +32 -5
- package/esm2020/core/services/flow-info.service.mjs +99 -0
- package/esm2020/core/services/flow-state-configuration.service.mjs +53 -0
- package/esm2020/core/services/flow-state.service.mjs +506 -0
- package/esm2020/core/services/index.mjs +5 -2
- package/esm2020/core/services/integration.state.mjs +36 -0
- package/esm2020/core/services/product-images.service.mjs +4 -5
- package/esm2020/core/services/quote-draft.service.mjs +32 -8
- package/esm2020/core/services/runtime-settings.service.mjs +19 -5
- package/esm2020/core/types/flow-customization.types.mjs +3 -0
- package/esm2020/core/types/flow-state.types.mjs +2 -0
- package/esm2020/core/types/formatting-settings.types.mjs +1 -1
- package/esm2020/core/types/index.mjs +4 -1
- package/esm2020/core/types/integration.types.mjs +2 -0
- package/esm2020/core/types/pipe.types.mjs +2 -0
- package/esm2020/core/utils/line-item.utils.mjs +30 -15
- package/esm2020/src/components/doc-gen/doc-gen.component.mjs +49 -49
- package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
- package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
- package/esm2020/src/components/flow-header/index.mjs +2 -0
- package/esm2020/src/components/guided-selling/guided-selling.component.mjs +37 -43
- package/esm2020/src/configure-primeng.mjs +33 -0
- package/esm2020/src/flow-routing.module.mjs +62 -71
- package/esm2020/src/flow.component.mjs +23 -32
- package/esm2020/src/flow.module.mjs +7 -5
- package/esm2020/src/guards/context.guard.mjs +6 -11
- package/esm2020/src/guards/flow.guard.mjs +37 -0
- package/esm2020/src/guards/product-unload.guard.mjs +4 -1
- package/esm2020/src/guards/root.guard.mjs +14 -10
- package/esm2020/src/pages/assets/assets.component.mjs +33 -37
- package/esm2020/src/pages/catalog/catalog.component.mjs +33 -37
- package/esm2020/src/pages/debug/debug.component.mjs +10 -14
- package/esm2020/src/pages/product/product.component.mjs +22 -12
- package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +6 -3
- package/esm2020/src/pages/remote/remote.component.mjs +19 -19
- package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +34 -38
- package/esm2020/src/resolvers/flow.resolver.mjs +37 -49
- package/esm2020/src/resolvers/quote.resolver.mjs +55 -63
- package/esm2020/src/services/doc-gen.service.mjs +4 -3
- package/esm2020/src/services/flow-dialog.service.mjs +21 -6
- package/esm2020/src/services/flow-router.service.mjs +57 -16
- package/esm2020/src/services/flow.service.mjs +72 -23
- package/esm2020/src/services/guided-selling.service.mjs +5 -4
- package/esm2020/src/services/index.mjs +3 -1
- package/esm2020/src/types/index.mjs +1 -2
- package/esm2020/src/utils/flow.utils.mjs +6 -2
- package/fesm2015/veloceapps-sdk-cms.mjs +287 -195
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +1595 -728
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +740 -1451
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +291 -209
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +1741 -910
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +802 -1511
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +5 -12
- package/src/components/doc-gen/doc-gen.component.d.ts +8 -9
- package/src/components/flow-header/flow-header.component.d.ts +25 -0
- package/src/components/flow-header/flow-header.module.d.ts +9 -0
- package/src/components/flow-header/index.d.ts +1 -0
- package/src/components/guided-selling/guided-selling.component.d.ts +6 -8
- package/src/configure-primeng.d.ts +1 -0
- package/src/flow-routing.module.d.ts +6 -7
- package/src/flow.component.d.ts +7 -11
- package/src/flow.module.d.ts +2 -2
- package/src/guards/context.guard.d.ts +4 -5
- package/src/guards/flow.guard.d.ts +2 -0
- package/src/guards/product-unload.guard.d.ts +2 -2
- package/src/guards/root.guard.d.ts +0 -1
- package/src/pages/assets/assets.component.d.ts +5 -7
- package/src/pages/catalog/catalog.component.d.ts +5 -7
- package/src/pages/debug/debug.component.d.ts +5 -8
- package/src/pages/product/product.component.d.ts +7 -6
- package/src/pages/record-not-found/record-not-found.component.d.ts +2 -0
- package/src/pages/remote/remote.component.d.ts +2 -3
- package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
- package/src/resolvers/flow.resolver.d.ts +6 -7
- package/src/resolvers/quote.resolver.d.ts +7 -12
- package/src/services/doc-gen.service.d.ts +1 -1
- package/src/services/flow-dialog.service.d.ts +5 -2
- package/src/services/flow-router.service.d.ts +7 -3
- package/src/services/flow.service.d.ts +10 -4
- package/src/services/guided-selling.service.d.ts +1 -1
- package/src/services/index.d.ts +2 -0
- package/src/types/index.d.ts +0 -1
- package/core/modules/configuration/services/configuration.state.d.ts +0 -30
- package/core/services/metric-calculation/metric-calculation.service.d.ts +0 -25
- package/core/services/metric-calculation/metric-calculation.types.d.ts +0 -1
- package/core/services/metric-calculation/metric-calculation.utils.d.ts +0 -5
- package/esm2020/cms/services/integration.state.mjs +0 -37
- package/esm2020/cms/types/integration.types.mjs +0 -2
- package/esm2020/core/modules/configuration/services/configuration.state.mjs +0 -142
- package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +0 -85
- package/esm2020/core/services/metric-calculation/metric-calculation.types.mjs +0 -2
- package/esm2020/core/services/metric-calculation/metric-calculation.utils.mjs +0 -42
- package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
- package/esm2020/runtime/components/index.mjs +0 -5
- package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
- package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
- package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
- package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
- package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
- package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
- package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
- package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
- package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
- package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
- package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
- package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
- package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
- package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
- package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
- package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
- package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
- package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
- package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
- package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
- package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
- package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
- package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
- package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
- package/esm2020/runtime/index.mjs +0 -5
- package/esm2020/runtime/runtime.module.mjs +0 -74
- package/esm2020/runtime/services/cart.service.mjs +0 -29
- package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
- package/esm2020/runtime/services/configuration.service.mjs +0 -119
- package/esm2020/runtime/services/current-state.service.mjs +0 -17
- package/esm2020/runtime/services/form-scope.service.mjs +0 -30
- package/esm2020/runtime/services/index.mjs +0 -4
- package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
- package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
- package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
- package/esm2020/runtime/services/runtime.service.mjs +0 -115
- package/esm2020/runtime/services/section-helper.service.mjs +0 -27
- package/esm2020/runtime/services/section-scope.service.mjs +0 -36
- package/esm2020/runtime/services/section-store.service.mjs +0 -22
- package/esm2020/runtime/services/section.service.mjs +0 -117
- package/esm2020/runtime/types/bound-data.types.mjs +0 -7
- package/esm2020/runtime/types/index.mjs +0 -3
- package/esm2020/runtime/types/quote-states.types.mjs +0 -2
- package/esm2020/runtime/types/runtime.types.mjs +0 -2
- package/esm2020/runtime/types/script-registry.types.mjs +0 -51
- package/esm2020/runtime/utils/line-item.util.mjs +0 -270
- package/esm2020/runtime/utils/section.utils.mjs +0 -26
- package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
- package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
- package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
- package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
- package/esm2020/src/components/header/header.component.mjs +0 -355
- package/esm2020/src/components/header/header.module.mjs +0 -52
- package/esm2020/src/components/header/header.types.mjs +0 -2
- package/esm2020/src/components/header/metrics/index.mjs +0 -2
- package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
- package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
- package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
- package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
- package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
- package/esm2020/src/types/flow-customization.types.mjs +0 -3
- package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
- package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
- package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
- package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
- package/runtime/README.md +0 -5
- package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
- package/runtime/components/index.d.ts +0 -4
- package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
- package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
- package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
- package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
- package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
- package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
- package/runtime/execution/components/federated/federated.component.d.ts +0 -36
- package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
- package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
- package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
- package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
- package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
- package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
- package/runtime/execution/directives/section-script.directive.d.ts +0 -59
- package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
- package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
- package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
- package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
- package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
- package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
- package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
- package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
- package/runtime/execution/runtime-execution.module.d.ts +0 -25
- package/runtime/execution/utils/federated.util.d.ts +0 -6
- package/runtime/index.d.ts +0 -4
- package/runtime/runtime.module.d.ts +0 -16
- package/runtime/services/cart.service.d.ts +0 -15
- package/runtime/services/collapsible-state.service.d.ts +0 -15
- package/runtime/services/configuration.service.d.ts +0 -20
- package/runtime/services/current-state.service.d.ts +0 -8
- package/runtime/services/form-scope.service.d.ts +0 -20
- package/runtime/services/index.d.ts +0 -3
- package/runtime/services/product-model-cache.service.d.ts +0 -14
- package/runtime/services/runtime-context.service.d.ts +0 -16
- package/runtime/services/runtime-form.service.d.ts +0 -24
- package/runtime/services/runtime.service.d.ts +0 -44
- package/runtime/services/section-helper.service.d.ts +0 -8
- package/runtime/services/section-scope.service.d.ts +0 -14
- package/runtime/services/section-store.service.d.ts +0 -11
- package/runtime/services/section.service.d.ts +0 -30
- package/runtime/types/bound-data.types.d.ts +0 -13
- package/runtime/types/index.d.ts +0 -2
- package/runtime/types/quote-states.types.d.ts +0 -6
- package/runtime/types/runtime.types.d.ts +0 -19
- package/runtime/types/script-registry.types.d.ts +0 -13
- package/runtime/utils/line-item.util.d.ts +0 -34
- package/runtime/utils/section.utils.d.ts +0 -2
- package/runtime/utils/sections-binder.helper.d.ts +0 -16
- package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
- package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
- package/src/components/header/header.component.d.ts +0 -70
- package/src/components/header/header.module.d.ts +0 -16
- package/src/components/header/header.types.d.ts +0 -20
- package/src/components/header/metrics/index.d.ts +0 -1
- package/src/components/header/metrics/metrics.component.d.ts +0 -67
- package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
- package/src/components/header/metrics/metrics.module.d.ts +0 -18
- package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
- package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
- package/src/types/flow-customization.types.d.ts +0 -12
- /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -1,17 +1,17 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
|
-
import { InjectionToken, Injectable, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContextMode, ConfigurationContext,
|
4
|
-
import { BehaviorSubject,
|
5
|
-
import { filter, tap,
|
2
|
+
import { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
|
+
import { BehaviorSubject, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
|
5
|
+
import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
|
6
6
|
import * as i1 from '@veloceapps/api';
|
7
|
-
import {
|
8
|
-
import { merge, flatten, sortBy, map as map$
|
9
|
-
import
|
10
|
-
import * as i4 from '@veloceapps/components';
|
7
|
+
import { ApiModule } from '@veloceapps/api';
|
8
|
+
import { merge, isEmpty, flatten, entries, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform } from 'lodash';
|
9
|
+
import * as i6 from '@veloceapps/components';
|
11
10
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
12
|
-
import * as i5 from 'primeng/api';
|
13
|
-
import * as i6 from 'primeng/dynamicdialog';
|
14
11
|
import moment from 'moment';
|
12
|
+
import { HttpErrorResponse } from '@angular/common/http';
|
13
|
+
import * as i5 from 'primeng/api';
|
14
|
+
import * as i6$1 from 'primeng/dynamicdialog';
|
15
15
|
import { NgControl } from '@angular/forms';
|
16
16
|
import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
|
17
17
|
|
@@ -24,21 +24,16 @@ const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
|
|
24
24
|
attributes,
|
25
25
|
lineItems, productName: ((_b = context.properties) === null || _b === void 0 ? void 0 : _b['displayName']) || context.productName, productId: (_c = context.productId) !== null && _c !== void 0 ? _c : '' }, (uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}));
|
26
26
|
};
|
27
|
-
const getGuidedSellingConfigurationRequest = (data) => {
|
27
|
+
const getGuidedSellingConfigurationRequest = (data, context) => {
|
28
|
+
const _context = Object.assign({}, context);
|
29
|
+
delete _context.configurationToken;
|
30
|
+
const properties = Object.assign({}, context.properties);
|
31
|
+
delete properties['ConfigurationToken'];
|
28
32
|
return {
|
29
33
|
mode: 'SEARCH',
|
30
34
|
step: 'START',
|
31
35
|
attributeDomainMode: 'ALL',
|
32
|
-
context: {
|
33
|
-
headerId: 'TestId',
|
34
|
-
mode: ConfigurationContextMode.TEST,
|
35
|
-
properties: {
|
36
|
-
ModelId: data.modelId,
|
37
|
-
Name: 'Veloce Guided Selling',
|
38
|
-
PricingEnabled: 'false',
|
39
|
-
RuntimeMode: 'TEST',
|
40
|
-
},
|
41
|
-
},
|
36
|
+
context: Object.assign(Object.assign({}, _context), { mode: ConfigurationContextMode.TEST, properties: Object.assign(Object.assign({}, properties), { ModelId: data.modelId, Name: 'Veloce Guided Selling', PricingEnabled: 'false', RuntimeMode: 'TEST' }) }),
|
42
37
|
lineItem: {
|
43
38
|
actionCode: 'ADD',
|
44
39
|
cfgStatus: 'Default',
|
@@ -53,6 +48,29 @@ const getGuidedSellingConfigurationRequest = (data) => {
|
|
53
48
|
},
|
54
49
|
};
|
55
50
|
};
|
51
|
+
const generateConfigurationLineItem = (props, qty = 1) => {
|
52
|
+
var _a, _b, _c;
|
53
|
+
const id = UUID.UUID();
|
54
|
+
const attributes = Object.entries((_a = props.attributesMap) !== null && _a !== void 0 ? _a : {}).map(([name, value]) => ({
|
55
|
+
name,
|
56
|
+
value,
|
57
|
+
cfgStatus: 'User',
|
58
|
+
}));
|
59
|
+
const lineItems = [];
|
60
|
+
return {
|
61
|
+
id,
|
62
|
+
type: (_b = props.product.typeName) !== null && _b !== void 0 ? _b : '',
|
63
|
+
cfgStatus: 'Default',
|
64
|
+
actionCode: 'ADD',
|
65
|
+
qty,
|
66
|
+
attributes,
|
67
|
+
lineItems,
|
68
|
+
productName: props.product.name,
|
69
|
+
productId: (_c = props.product.id) !== null && _c !== void 0 ? _c : '',
|
70
|
+
};
|
71
|
+
};
|
72
|
+
|
73
|
+
const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
|
56
74
|
|
57
75
|
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
58
76
|
|
@@ -82,9 +100,25 @@ class ContextService {
|
|
82
100
|
get isInitialized() {
|
83
101
|
return Boolean(this.context.value);
|
84
102
|
}
|
103
|
+
get isInitialized$() {
|
104
|
+
return this.context.pipe(map(Boolean));
|
105
|
+
}
|
85
106
|
get mode() {
|
86
107
|
return this.resolve().properties.mode;
|
87
108
|
}
|
109
|
+
get isEditMode$() {
|
110
|
+
return this.resolve$().pipe(map(() => this.isEditMode));
|
111
|
+
}
|
112
|
+
get isEditMode() {
|
113
|
+
const context = this.resolve();
|
114
|
+
if (context.mode === ConfigurationContextMode.ACCOUNT) {
|
115
|
+
return true;
|
116
|
+
}
|
117
|
+
if (context.mode === ConfigurationContextMode.QUOTE) {
|
118
|
+
return context.properties.Status === 'Draft';
|
119
|
+
}
|
120
|
+
return false;
|
121
|
+
}
|
88
122
|
resolve() {
|
89
123
|
if (!this.context.value) {
|
90
124
|
throw new Error('Context is not initialized yet!');
|
@@ -97,6 +131,13 @@ class ContextService {
|
|
97
131
|
create(headerId, mode) {
|
98
132
|
return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
|
99
133
|
}
|
134
|
+
initTestMode() {
|
135
|
+
return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
|
136
|
+
return this.update({
|
137
|
+
properties: Object.assign(Object.assign({}, context.properties), { RuntimeMode: ConfigurationContextMode.TEST, StartDate: new Date().toISOString().substring(0, 10), standalone: 'true' }),
|
138
|
+
});
|
139
|
+
}));
|
140
|
+
}
|
100
141
|
update(partialContext) {
|
101
142
|
const originalContext = this.resolve();
|
102
143
|
const updatedContext = Object.assign(Object.assign(Object.assign({}, originalContext), partialContext), { properties: Object.assign(Object.assign({}, originalContext.properties), partialContext.properties) });
|
@@ -114,135 +155,106 @@ class ContextService {
|
|
114
155
|
}
|
115
156
|
}
|
116
157
|
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
117
|
-
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService
|
158
|
+
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService });
|
118
159
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
|
119
|
-
type: Injectable
|
120
|
-
args: [{ providedIn: 'root' }]
|
160
|
+
type: Injectable
|
121
161
|
}], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
|
122
162
|
|
123
|
-
class
|
124
|
-
|
125
|
-
this.
|
163
|
+
class FlowInfoService {
|
164
|
+
get flow() {
|
165
|
+
return this.flowSubj$.value;
|
126
166
|
}
|
127
|
-
|
128
|
-
|
129
|
-
var _a;
|
130
|
-
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
131
|
-
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
132
|
-
const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
|
133
|
-
const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
|
134
|
-
return {
|
135
|
-
modelId: runtimeData.modelId,
|
136
|
-
uiDefinitionContainer: uiDefinitionContainer,
|
137
|
-
runtimeModel: runtimeModel,
|
138
|
-
runtimeMode: RuntimeMode.PROD,
|
139
|
-
productId: productId,
|
140
|
-
productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
|
141
|
-
offeringId: offeringId,
|
142
|
-
properties: {
|
143
|
-
PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
|
144
|
-
PriceListId: uiDefinitionProperties.priceList,
|
145
|
-
},
|
146
|
-
};
|
147
|
-
}));
|
167
|
+
set flow(value) {
|
168
|
+
this.flowSubj$.next(value);
|
148
169
|
}
|
149
|
-
|
170
|
+
get isLegacy() {
|
150
171
|
var _a;
|
151
|
-
|
152
|
-
return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
|
153
|
-
}
|
154
|
-
}
|
155
|
-
RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
156
|
-
RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
|
157
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
|
158
|
-
type: Injectable
|
159
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
|
160
|
-
|
161
|
-
class ConfigurationRuntimeService {
|
162
|
-
constructor(apiService, contextService, runtimeContextService) {
|
163
|
-
this.apiService = apiService;
|
164
|
-
this.contextService = contextService;
|
165
|
-
this.runtimeContextService = runtimeContextService;
|
166
|
-
this._isInitialized = false;
|
167
|
-
this.uiDefinitionProperties = {};
|
168
|
-
}
|
169
|
-
reset() {
|
170
|
-
this._isInitialized = false;
|
171
|
-
this._runtimeContext = undefined;
|
172
|
-
this.initializationProps = undefined;
|
173
|
-
this.uiDefinitionProperties = {};
|
172
|
+
return !!this.flow && ((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) == null;
|
174
173
|
}
|
175
|
-
|
174
|
+
get isStateful() {
|
176
175
|
var _a;
|
177
|
-
this.
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
176
|
+
return !!((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful);
|
177
|
+
}
|
178
|
+
constructor(flowsApiService, templatesApiService, customizationService) {
|
179
|
+
this.flowsApiService = flowsApiService;
|
180
|
+
this.templatesApiService = templatesApiService;
|
181
|
+
this.customizationService = customizationService;
|
182
|
+
this.templates = {};
|
183
|
+
this.defaultTemplates = {
|
184
|
+
flowEngine: 'Flow Engine',
|
185
|
+
};
|
186
|
+
this.flowSubj$ = new BehaviorSubject(null);
|
187
|
+
this.flow$ = this.flowSubj$.asObservable();
|
188
|
+
}
|
189
|
+
init$(flowId, params) {
|
190
|
+
this.params = params;
|
191
|
+
return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => this.flowSubj$.next(flow)), map$1(noop), catchError(e => {
|
192
|
+
this.flowSubj$.next(null);
|
193
|
+
return throwError(() => e);
|
194
|
+
}));
|
195
195
|
}
|
196
|
-
|
197
|
-
this.
|
198
|
-
|
199
|
-
|
200
|
-
var _a, _b;
|
201
|
-
this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
|
202
|
-
const { PriceListId } = (_a = context.properties) !== null && _a !== void 0 ? _a : {};
|
203
|
-
const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
204
|
-
this.id15to18('AccountId', mergeContext.properties);
|
205
|
-
this._runtimeContext = mergeContext;
|
206
|
-
if (context.properties && ((_b = this._runtimeContext.properties) === null || _b === void 0 ? void 0 : _b.StartDate)) {
|
207
|
-
this.contextService.update({
|
208
|
-
properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
|
209
|
-
});
|
210
|
-
}
|
211
|
-
return this._runtimeContext;
|
212
|
-
}), tap(() => (this._isInitialized = true)));
|
196
|
+
cleanup() {
|
197
|
+
this.flowSubj$.next(null);
|
198
|
+
this.params = undefined;
|
199
|
+
this.templates = {};
|
213
200
|
}
|
214
|
-
|
215
|
-
|
216
|
-
|
201
|
+
initFlowTemplates$(flow) {
|
202
|
+
var _a, _b, _c;
|
203
|
+
if (isEmpty(flow.properties.templates)) {
|
204
|
+
return of(undefined);
|
217
205
|
}
|
218
|
-
|
219
|
-
|
206
|
+
return forkJoin([
|
207
|
+
this.templatesApiService.fetchTemplates$(),
|
208
|
+
(_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplates) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : of([]),
|
209
|
+
]).pipe(map$1(([templates, localTemplates]) => {
|
210
|
+
Object.entries(Object.assign(Object.assign({}, this.defaultTemplates), flow.properties.templates)).forEach(([key, name]) => {
|
211
|
+
var _a;
|
212
|
+
const type = this.remapTemplateName(key);
|
213
|
+
if (type) {
|
214
|
+
this.templates[type] =
|
215
|
+
(_a = localTemplates.find(template => template.name === name && template.type === type)) !== null && _a !== void 0 ? _a : templates.find(template => template.name === name && template.type === type);
|
216
|
+
}
|
217
|
+
});
|
218
|
+
}));
|
220
219
|
}
|
221
|
-
|
222
|
-
|
223
|
-
|
220
|
+
remapTemplateName(templateType) {
|
221
|
+
switch (templateType) {
|
222
|
+
case 'flowEngine':
|
223
|
+
return UITemplateType.FLOW_ENGINE;
|
224
|
+
default:
|
225
|
+
break;
|
224
226
|
}
|
225
|
-
|
226
|
-
|
227
|
-
|
227
|
+
switch (templateType) {
|
228
|
+
case 'assets':
|
229
|
+
case 'shoppingCart':
|
230
|
+
// No separate Assets template at the moment
|
231
|
+
return UITemplateType.SHOPPING_CART;
|
232
|
+
case 'catalog':
|
233
|
+
return UITemplateType.CATALOG;
|
234
|
+
case 'docGen':
|
235
|
+
return UITemplateType.DOCGEN;
|
236
|
+
case 'guidedSelling':
|
237
|
+
return UITemplateType.GUIDED_SELLING;
|
238
|
+
case 'flowHeader':
|
239
|
+
return UITemplateType.FLOW_HEADER;
|
240
|
+
default:
|
241
|
+
break;
|
228
242
|
}
|
229
|
-
|
230
|
-
get isInitialized() {
|
231
|
-
return this._isInitialized;
|
232
|
-
}
|
233
|
-
get runtimeModel() {
|
234
|
-
var _a;
|
235
|
-
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
236
|
-
}
|
237
|
-
get runtimeContext() {
|
238
|
-
return this._runtimeContext;
|
243
|
+
return undefined;
|
239
244
|
}
|
240
245
|
}
|
241
|
-
|
242
|
-
|
243
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
246
|
+
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
247
|
+
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
248
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
244
249
|
type: Injectable
|
245
|
-
}], ctorParameters: function () {
|
250
|
+
}], ctorParameters: function () {
|
251
|
+
return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
|
252
|
+
type: Optional
|
253
|
+
}, {
|
254
|
+
type: Inject,
|
255
|
+
args: [FLOW_CUSTOMIZATION]
|
256
|
+
}] }];
|
257
|
+
} });
|
246
258
|
|
247
259
|
const findLineItem = (id, lineItems) => {
|
248
260
|
return findLineItemWithComparator(lineItems, (li) => li.id === id);
|
@@ -291,28 +303,45 @@ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false
|
|
291
303
|
}
|
292
304
|
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)) });
|
293
305
|
};
|
294
|
-
const
|
306
|
+
const collectCardinalityComputations = (portDomains) => {
|
307
|
+
const cardinalityComputations = new Map();
|
308
|
+
entries(portDomains).forEach(([key, portDomain]) => {
|
309
|
+
cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
|
310
|
+
});
|
311
|
+
return cardinalityComputations;
|
312
|
+
};
|
313
|
+
const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
|
295
314
|
const cardVars = new Map();
|
296
315
|
lineItems
|
297
316
|
.filter(({ port, type }) => !!port && !!type)
|
298
317
|
.forEach(li => {
|
299
318
|
var _a;
|
300
|
-
|
301
|
-
|
319
|
+
if (cardinalityComputations.get(`${li.port}`)) {
|
320
|
+
const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
|
321
|
+
cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
322
|
+
}
|
302
323
|
});
|
303
324
|
return cardVars;
|
304
325
|
};
|
326
|
+
const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
|
305
327
|
const recalculateCardinalityVariables = (original, updated) => {
|
306
|
-
|
307
|
-
const
|
328
|
+
var _a, _b;
|
329
|
+
const cardinalityComputations = collectCardinalityComputations((_b = (_a = updated.portDomains) !== null && _a !== void 0 ? _a : original.portDomains) !== null && _b !== void 0 ? _b : {});
|
330
|
+
const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
|
331
|
+
const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
|
308
332
|
originalCardinalityVariables.forEach((value, key) => {
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
333
|
+
var _a;
|
334
|
+
const execArray = cardinalityRegexp.exec(key);
|
335
|
+
const portName = (_a = execArray === null || execArray === void 0 ? void 0 : execArray.groups) === null || _a === void 0 ? void 0 : _a['portName'];
|
336
|
+
if (!portName || cardinalityComputations.get(portName)) {
|
337
|
+
if (cardinalityVariables.get(key) === value) {
|
338
|
+
// no need to update cardinality if no changes
|
339
|
+
cardinalityVariables.delete(key);
|
340
|
+
}
|
341
|
+
else if (!cardinalityVariables.has(key)) {
|
342
|
+
// remove last item from port
|
343
|
+
cardinalityVariables.set(key, 0);
|
344
|
+
}
|
316
345
|
}
|
317
346
|
});
|
318
347
|
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))) });
|
@@ -329,7 +358,7 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
|
|
329
358
|
const [origAttr] = getAttributes(acc, [name]);
|
330
359
|
return [
|
331
360
|
...acc.filter(attr => attr.name !== name),
|
332
|
-
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
|
361
|
+
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name, type: '' })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
|
333
362
|
];
|
334
363
|
}, originalAttributes);
|
335
364
|
};
|
@@ -395,7 +424,7 @@ const isLineItemModified = (lineItem) => {
|
|
395
424
|
const multiplyLineItems = (lineItem, qty, split) => {
|
396
425
|
if (split) {
|
397
426
|
const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
|
398
|
-
return map$
|
427
|
+
return map$2(new Array(qty), () => unifyIds(lineItem));
|
399
428
|
}
|
400
429
|
else {
|
401
430
|
return [
|
@@ -412,7 +441,6 @@ const filterOutTechnicalAttributes = (attributes) => {
|
|
412
441
|
|
413
442
|
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
414
443
|
__proto__: null,
|
415
|
-
calculateCardinalityVariables: calculateCardinalityVariables,
|
416
444
|
filterOutTechnicalAttributes: filterOutTechnicalAttributes,
|
417
445
|
findLineItem: findLineItem,
|
418
446
|
findLineItemWithComparator: findLineItemWithComparator,
|
@@ -452,7 +480,51 @@ class LineItemWorker {
|
|
452
480
|
}
|
453
481
|
}
|
454
482
|
|
483
|
+
function extractMetadata(uiDefinition) {
|
484
|
+
return omit(uiDefinition, [
|
485
|
+
'children',
|
486
|
+
'pages',
|
487
|
+
'components',
|
488
|
+
]);
|
489
|
+
}
|
490
|
+
|
491
|
+
class IntegrationState {
|
492
|
+
constructor() {
|
493
|
+
this.stateSubj$ = new BehaviorSubject({});
|
494
|
+
this.action$ = new Subject();
|
495
|
+
}
|
496
|
+
get state$() {
|
497
|
+
return this.stateSubj$.asObservable();
|
498
|
+
}
|
499
|
+
get state() {
|
500
|
+
return this.stateSubj$.getValue();
|
501
|
+
}
|
502
|
+
patchState(update) {
|
503
|
+
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
504
|
+
}
|
505
|
+
dispatch(action) {
|
506
|
+
this.action$.next(action);
|
507
|
+
}
|
508
|
+
listen$(actionType) {
|
509
|
+
return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
|
510
|
+
}
|
511
|
+
listenAll$() {
|
512
|
+
return this.action$.asObservable();
|
513
|
+
}
|
514
|
+
clear() {
|
515
|
+
this.stateSubj$.next({});
|
516
|
+
}
|
517
|
+
}
|
518
|
+
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
519
|
+
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
|
520
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
|
521
|
+
type: Injectable
|
522
|
+
}] });
|
523
|
+
|
455
524
|
class QuoteDraftService {
|
525
|
+
get isInitialized$() {
|
526
|
+
return this.isInitializedSubj$.asObservable();
|
527
|
+
}
|
456
528
|
get isInitialized() {
|
457
529
|
return this.isInitializedSubj$.getValue();
|
458
530
|
}
|
@@ -476,12 +548,20 @@ class QuoteDraftService {
|
|
476
548
|
}
|
477
549
|
get hasProducts() {
|
478
550
|
const quoteDraft = this.quoteSubj$.value;
|
479
|
-
return
|
551
|
+
return this.filterByActivePriceList((quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.currentState) || []).some(li => !li.assetId && !li.openOrderLineItemId);
|
552
|
+
}
|
553
|
+
get hasAssets$() {
|
554
|
+
return this.quoteSubj$.pipe(map(() => this.hasAssets));
|
555
|
+
}
|
556
|
+
get hasAssets() {
|
557
|
+
const quoteDraft = this.quoteSubj$.value;
|
558
|
+
return this.filterByActivePriceList((quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.currentState) || []).some(li => li.assetId || li.openOrderLineItemId);
|
480
559
|
}
|
481
|
-
constructor(context, quoteApiService, priceApiService) {
|
560
|
+
constructor(context, quoteApiService, priceApiService, integrationState) {
|
482
561
|
this.context = context;
|
483
562
|
this.quoteApiService = quoteApiService;
|
484
563
|
this.priceApiService = priceApiService;
|
564
|
+
this.integrationState = integrationState;
|
485
565
|
this.quoteSubj$ = new BehaviorSubject(null);
|
486
566
|
this.resetSubj$ = new BehaviorSubject(true);
|
487
567
|
this.isInitializedSubj$ = new BehaviorSubject(false);
|
@@ -492,12 +572,13 @@ class QuoteDraftService {
|
|
492
572
|
this.reset$ = this.resetSubj$.asObservable();
|
493
573
|
this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList !== null && priceList !== void 0 ? priceList : null));
|
494
574
|
this.isInitializedSubj$
|
495
|
-
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
575
|
+
.pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
496
576
|
.subscribe();
|
497
577
|
}
|
498
578
|
reset() {
|
499
579
|
this.resetSubj$.next(true);
|
500
580
|
this.quoteSubj$.next(null);
|
581
|
+
this.isInitialized = false;
|
501
582
|
this.hasUnsavedChanges = false;
|
502
583
|
}
|
503
584
|
init(quoteId, params) {
|
@@ -508,6 +589,11 @@ class QuoteDraftService {
|
|
508
589
|
this.populateActivePriceLists$();
|
509
590
|
}), map(() => noop()), take(1));
|
510
591
|
}
|
592
|
+
finalizeInit() {
|
593
|
+
this.initializeModifiedAssetsMap();
|
594
|
+
this.isInitialized = true;
|
595
|
+
this.hasUnsavedChanges = false;
|
596
|
+
}
|
511
597
|
setCurrentLineItemState(lineItems) {
|
512
598
|
const quoteDraft = this.quoteSubj$.value;
|
513
599
|
if (!quoteDraft) {
|
@@ -653,354 +739,526 @@ class QuoteDraftService {
|
|
653
739
|
this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
654
740
|
}
|
655
741
|
}
|
742
|
+
initializeModifiedAssetsMap() {
|
743
|
+
this.integrationState.patchState({
|
744
|
+
modifiedAssets: generateModifiedAssetsMap(this.currentState),
|
745
|
+
});
|
746
|
+
}
|
656
747
|
}
|
657
|
-
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
658
|
-
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService
|
748
|
+
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Injectable });
|
749
|
+
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
|
659
750
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
|
660
|
-
type: Injectable
|
661
|
-
|
662
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
|
751
|
+
type: Injectable
|
752
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
|
663
753
|
|
664
|
-
class
|
665
|
-
constructor(quoteDraftService,
|
666
|
-
this.quoteDraftService = quoteDraftService;
|
667
|
-
this.runtimeService = runtimeService;
|
754
|
+
class FlowStateService {
|
755
|
+
constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
|
668
756
|
this.contextService = contextService;
|
669
|
-
this.
|
670
|
-
this.
|
671
|
-
this.
|
672
|
-
this.
|
673
|
-
this.
|
674
|
-
this.
|
675
|
-
this.
|
676
|
-
this.
|
677
|
-
this.
|
678
|
-
this.
|
679
|
-
|
680
|
-
|
681
|
-
this.
|
682
|
-
this.
|
683
|
-
this.
|
684
|
-
this.
|
685
|
-
this.
|
686
|
-
this.
|
757
|
+
this.quoteDraftService = quoteDraftService;
|
758
|
+
this.flowInfoService = flowInfoService;
|
759
|
+
this.flowConfiguration = flowConfiguration;
|
760
|
+
this.processorsApiService = processorsApiService;
|
761
|
+
this.flowStateApiService = flowStateApiService;
|
762
|
+
this.quoteApiService = quoteApiService;
|
763
|
+
this.toastService = toastService;
|
764
|
+
this.customizationService = customizationService;
|
765
|
+
this.NOT_INITIALIZED = Symbol();
|
766
|
+
this.EXECUTION_BUFFER_TIME = 100;
|
767
|
+
this.executedFunctions = {};
|
768
|
+
this.stateId$ = new BehaviorSubject(null);
|
769
|
+
this._hasStatefulUnsavedChanges = true;
|
770
|
+
this.processors = {};
|
771
|
+
this.subscriptions = {};
|
772
|
+
this.flowStore = {};
|
773
|
+
this.statefulExecutionInProgress$ = new BehaviorSubject(false);
|
774
|
+
this.statefulRequestStream$ = new Subject();
|
775
|
+
this.cleanup$ = new Subject();
|
776
|
+
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
777
|
+
/*
|
778
|
+
In stateless mode watch QuoteDraft changes and call executeRequest so that
|
779
|
+
all subscriptions get their updates according to updated QuoteDraft
|
780
|
+
*/
|
781
|
+
this.isInitialized$()
|
782
|
+
.pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
783
|
+
.subscribe();
|
784
|
+
this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
785
|
+
if (!flow.properties.stateful) {
|
786
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
|
787
|
+
}
|
788
|
+
else {
|
789
|
+
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
|
790
|
+
cold: true,
|
791
|
+
}).pipe(map$1(response => (response.success ? response.result : {})));
|
792
|
+
}
|
793
|
+
}), filter$1(isDefined), shareReplay$1());
|
794
|
+
this.charges$.subscribe();
|
795
|
+
this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
796
|
+
if (!flow.properties.stateful) {
|
797
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
|
798
|
+
}
|
799
|
+
else {
|
800
|
+
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
|
801
|
+
cold: true,
|
802
|
+
}).pipe(map$1(response => (response.success ? response.result : {})));
|
803
|
+
}
|
804
|
+
}), filter$1(isDefined), shareReplay$1());
|
805
|
+
this.pricePlans$.subscribe();
|
806
|
+
this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
|
807
|
+
if (!flow.properties.stateful) {
|
808
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
|
809
|
+
}
|
810
|
+
else {
|
811
|
+
return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
|
812
|
+
cold: true,
|
813
|
+
}).pipe(map$1(response => (response.success ? response.result : [])));
|
814
|
+
}
|
815
|
+
}), filter$1(isDefined), shareReplay$1());
|
816
|
+
this.activeMetrics$.subscribe();
|
687
817
|
}
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
|
693
|
-
this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
|
694
|
-
return this.configure().pipe(catchError(error => {
|
695
|
-
console.error(error);
|
696
|
-
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
697
|
-
this.messageService.add({ severity: 'error', summary: error });
|
818
|
+
init$() {
|
819
|
+
return this.initProcessors$().pipe(switchMap(() => {
|
820
|
+
if (this.getFlowSafe().properties.stateful) {
|
821
|
+
return this.initStateful$();
|
698
822
|
}
|
699
|
-
|
700
|
-
|
701
|
-
return throwError(() => error);
|
702
|
-
}), tap(() => {
|
703
|
-
if (!this.hasUnsavedChanges) {
|
704
|
-
this.hasUnsavedChanges = true;
|
823
|
+
else {
|
824
|
+
return this.initStateless$();
|
705
825
|
}
|
706
826
|
}));
|
707
827
|
}
|
708
|
-
|
709
|
-
this.
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
get() {
|
715
|
-
return this.lineItem.asObservable().pipe(shareReplay$1());
|
716
|
-
}
|
717
|
-
getSnapshot() {
|
718
|
-
return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
|
719
|
-
}
|
720
|
-
getRuntimeModel() {
|
721
|
-
const runtimeModel = this.runtimeService.runtimeModel;
|
722
|
-
if (!runtimeModel) {
|
723
|
-
throw new Error('Runtime model not initialized');
|
828
|
+
cleanup() {
|
829
|
+
Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
|
830
|
+
this.subscriptions = {};
|
831
|
+
if (this.stateId$.value) {
|
832
|
+
this.flowStateApiService.cancel(this.stateId$.value).subscribe();
|
833
|
+
this.stateId$.next(null);
|
724
834
|
}
|
725
|
-
|
835
|
+
this.processors = {};
|
836
|
+
this.flowStore = {};
|
837
|
+
this.cleanup$.next();
|
726
838
|
}
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
}
|
732
|
-
return runtimeContext;
|
839
|
+
get hasUnsavedChanges() {
|
840
|
+
return this.getFlowSafe().properties.stateful
|
841
|
+
? this._hasStatefulUnsavedChanges
|
842
|
+
: this.quoteDraftService.hasUnsavedChanges;
|
733
843
|
}
|
734
|
-
get
|
735
|
-
return this.
|
844
|
+
get stateId() {
|
845
|
+
return this.stateId$.value;
|
736
846
|
}
|
737
|
-
get
|
738
|
-
return this.
|
847
|
+
get isExecutionInProgress$() {
|
848
|
+
return this.statefulExecutionInProgress$.asObservable();
|
739
849
|
}
|
740
|
-
|
741
|
-
return this.
|
850
|
+
isInitialized$() {
|
851
|
+
return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
|
742
852
|
}
|
743
|
-
|
744
|
-
return this.
|
853
|
+
isInitialized() {
|
854
|
+
return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
|
745
855
|
}
|
746
|
-
|
747
|
-
|
856
|
+
execute$(scope, exec) {
|
857
|
+
const request = this.execToRequest(scope, exec);
|
858
|
+
return this.executeRequest$(request).pipe(map$1(result => {
|
859
|
+
// Keep only requested results
|
860
|
+
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
861
|
+
var _a;
|
862
|
+
if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
|
863
|
+
trunk[requestId] = result;
|
864
|
+
}
|
865
|
+
return trunk;
|
866
|
+
}, {});
|
867
|
+
return actualSelectors;
|
868
|
+
}));
|
748
869
|
}
|
749
|
-
|
750
|
-
|
870
|
+
dispatch$(scope, action, inputData) {
|
871
|
+
const exec = {
|
872
|
+
actions: [{ name: action, inputData }],
|
873
|
+
};
|
874
|
+
const request = this.execToRequest(scope, exec);
|
875
|
+
return this.executeRequest$(request).pipe(map$1(noop));
|
751
876
|
}
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
this.
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
877
|
+
select$(scope, selectorName, inputData) {
|
878
|
+
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
879
|
+
const request = this.execToRequest(scope, {
|
880
|
+
selectors: {
|
881
|
+
[requestId]: {
|
882
|
+
name: selectorName,
|
883
|
+
inputData,
|
884
|
+
},
|
885
|
+
},
|
886
|
+
});
|
887
|
+
return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
|
888
|
+
}
|
889
|
+
subscribe$(scope, selectorName, inputData, options) {
|
890
|
+
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
891
|
+
let subscription = this.subscriptions[requestId];
|
892
|
+
if (!subscription) {
|
893
|
+
const request = this.execToRequest(scope, {
|
894
|
+
selectors: {
|
895
|
+
[requestId]: {
|
896
|
+
name: selectorName,
|
897
|
+
inputData,
|
898
|
+
},
|
899
|
+
},
|
900
|
+
});
|
901
|
+
subscription = {
|
902
|
+
request,
|
903
|
+
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
904
|
+
};
|
905
|
+
this.subscriptions[requestId] = subscription;
|
906
|
+
if (!(options === null || options === void 0 ? void 0 : options.cold)) {
|
907
|
+
this.executeRequest$(request).subscribe();
|
769
908
|
}
|
770
|
-
|
771
|
-
|
909
|
+
}
|
910
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
|
911
|
+
var _a;
|
912
|
+
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
913
|
+
delete this.subscriptions[requestId];
|
772
914
|
}
|
773
|
-
|
774
|
-
}), map(({ lineItem }) => lineItem), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })), finalize(() => this.isLoadingSubj$.next(false)));
|
775
|
-
}
|
776
|
-
configureExternal$(props) {
|
777
|
-
return this.runtimeService
|
778
|
-
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
779
|
-
.pipe(switchMap(() => this.configure()), first(), catchError(error => {
|
780
|
-
this.messageService.add({ severity: ToastType.error, summary: error });
|
781
|
-
throw error;
|
782
|
-
}), finalize(() => this.reset()));
|
915
|
+
}));
|
783
916
|
}
|
784
|
-
|
785
|
-
|
786
|
-
.
|
787
|
-
|
788
|
-
})
|
789
|
-
.pipe(catchError(error => {
|
790
|
-
if (error instanceof HttpErrorResponse) {
|
791
|
-
this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
|
917
|
+
save$() {
|
918
|
+
if (this.getFlowSafe().properties.stateful) {
|
919
|
+
if (this.stateId$.value) {
|
920
|
+
return this.flowStateApiService.save(this.stateId$.value);
|
792
921
|
}
|
793
|
-
|
794
|
-
|
922
|
+
}
|
923
|
+
else {
|
924
|
+
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
925
|
+
if (quoteDraft) {
|
926
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
|
927
|
+
this.contextService.update({ properties: { ConfigurationId: configurationId } });
|
928
|
+
}));
|
929
|
+
}
|
930
|
+
}
|
931
|
+
return of({ quoteId: '' });
|
795
932
|
}
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
let lineItem = this.configurableRamp;
|
801
|
-
if (!lineItem) {
|
802
|
-
const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
|
803
|
-
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
804
|
-
// Set default attributes
|
805
|
-
if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
|
806
|
-
const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
807
|
-
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
933
|
+
submit$() {
|
934
|
+
if (this.getFlowSafe().properties.stateful) {
|
935
|
+
if (this.stateId$.value) {
|
936
|
+
return this.flowStateApiService.submit(this.stateId$.value);
|
808
937
|
}
|
809
938
|
}
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
};
|
819
|
-
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
820
|
-
return request;
|
939
|
+
else {
|
940
|
+
const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
|
941
|
+
if (quoteDraft) {
|
942
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
|
943
|
+
this.contextService.update({ properties: { ConfigurationId: configurationId } });
|
944
|
+
}));
|
945
|
+
}
|
946
|
+
}
|
947
|
+
return of({ quoteId: '' });
|
821
948
|
}
|
822
|
-
|
949
|
+
getFlowStore() {
|
950
|
+
return this.flowStore;
|
951
|
+
}
|
952
|
+
getOwnerIdByScope(scope) {
|
823
953
|
var _a;
|
824
|
-
|
954
|
+
const ownerId = (_a = this.flowInfoService.templates[scope]) === null || _a === void 0 ? void 0 : _a.id;
|
955
|
+
if (!ownerId) {
|
956
|
+
throw `OwnerId is not found for scope ${scope}`;
|
957
|
+
}
|
958
|
+
return ownerId;
|
825
959
|
}
|
826
|
-
|
827
|
-
const
|
828
|
-
|
829
|
-
|
830
|
-
primaryButtonLabel: 'Remove products',
|
831
|
-
secondaryButtonLabel: 'Back to Quote',
|
832
|
-
};
|
833
|
-
this.dialogService
|
834
|
-
.open(ConfirmationComponent, {
|
835
|
-
dismissableMask: false,
|
836
|
-
closeOnEscape: false,
|
837
|
-
closable: false,
|
838
|
-
showHeader: true,
|
839
|
-
header: `Inactive Products in Quote`,
|
840
|
-
width: '440px',
|
841
|
-
data: { confirmationConfig },
|
842
|
-
})
|
843
|
-
.onClose.subscribe(result => {
|
844
|
-
if (!result) {
|
845
|
-
const context = this.contextService.resolve();
|
846
|
-
window['VELO_BACK_FN'].apply(null, [context.headerId]);
|
960
|
+
getScopeByOwnerId(id) {
|
961
|
+
for (const template of Object.values(this.flowInfoService.templates)) {
|
962
|
+
if (template.id === id) {
|
963
|
+
return template.type;
|
847
964
|
}
|
848
|
-
}
|
965
|
+
}
|
966
|
+
return;
|
849
967
|
}
|
850
|
-
|
968
|
+
execToRequest(scope, exec) {
|
851
969
|
var _a;
|
852
|
-
const
|
853
|
-
|
854
|
-
return;
|
855
|
-
|
856
|
-
|
970
|
+
const ownerId = this.getOwnerIdByScope(scope);
|
971
|
+
return {
|
972
|
+
actions: (_a = exec.actions) === null || _a === void 0 ? void 0 : _a.map(action => { var _a; return ({ apiName: action.name, ownerId, inputData: (_a = action.inputData) !== null && _a !== void 0 ? _a : {} }); }),
|
973
|
+
selectors: exec.selectors &&
|
974
|
+
Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
|
975
|
+
var _a;
|
976
|
+
return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
|
977
|
+
}, {}),
|
978
|
+
};
|
857
979
|
}
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
this.
|
870
|
-
this.toastService = toastService;
|
871
|
-
this.stateSubj$ = new BehaviorSubject({});
|
872
|
-
this.state$ = this.stateSubj$.asObservable();
|
873
|
-
this.stateId = null;
|
980
|
+
executeRequest$(request, forceSubscriptions = false) {
|
981
|
+
var _a;
|
982
|
+
const fullRequest = cloneDeep(request);
|
983
|
+
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
984
|
+
for (const subscription of Object.values(this.subscriptions)) {
|
985
|
+
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
986
|
+
}
|
987
|
+
}
|
988
|
+
const execution$ = this.getFlowSafe().properties.stateful
|
989
|
+
? this.executeStateful$(fullRequest)
|
990
|
+
: this.executeStateless$(fullRequest);
|
991
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
874
992
|
}
|
875
|
-
|
876
|
-
|
877
|
-
var _a
|
878
|
-
if (!
|
879
|
-
|
993
|
+
handleSelectorsResponse(selectors) {
|
994
|
+
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
995
|
+
var _a;
|
996
|
+
if (!selectorResult.success) {
|
997
|
+
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
880
998
|
}
|
881
|
-
const
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
});
|
887
|
-
}), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
|
999
|
+
const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
|
1000
|
+
if (subscription$ && subscription$.value !== selectorResult) {
|
1001
|
+
subscription$.next(selectorResult);
|
1002
|
+
}
|
1003
|
+
});
|
888
1004
|
}
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
this.
|
1005
|
+
initStateful$() {
|
1006
|
+
var _a;
|
1007
|
+
// Subscriptions
|
1008
|
+
this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
|
1009
|
+
.pipe(tap$1(response => {
|
1010
|
+
if (response.success) {
|
1011
|
+
this.contextService.update(response.result);
|
1012
|
+
}
|
1013
|
+
}), takeUntil(this.cleanup$))
|
1014
|
+
.subscribe();
|
1015
|
+
const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap !== null && ownerMap !== void 0 ? ownerMap : {})));
|
1016
|
+
const processors = processorsList.length ? processorsList : undefined;
|
1017
|
+
const selectors = Object.values(this.subscriptions)
|
1018
|
+
.map(({ request }) => request.selectors)
|
1019
|
+
.filter(isDefined)
|
1020
|
+
.reduce((trunk, selectors) => (Object.assign(Object.assign({}, trunk), selectors)), {});
|
1021
|
+
const request = this.getDefaultExecutionRequestDTO();
|
1022
|
+
return this.flowStateApiService
|
1023
|
+
.init({
|
1024
|
+
quoteId: this.contextService.resolve().headerId,
|
1025
|
+
params: (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {},
|
1026
|
+
actionsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
|
1027
|
+
selectorsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
|
1028
|
+
selectors: Object.assign(Object.assign({}, selectors), request.selectors),
|
1029
|
+
actions: request.actions,
|
1030
|
+
})
|
1031
|
+
.pipe(map$1(({ stateId, selectors }) => {
|
1032
|
+
this.handleSelectorsResponse(selectors);
|
1033
|
+
this.stateId$.next(stateId);
|
1034
|
+
}));
|
893
1035
|
}
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
1036
|
+
initBufferedRequest$() {
|
1037
|
+
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
1038
|
+
if (!this.stateId$.value) {
|
1039
|
+
throw 'Stateful session is not initialized';
|
1040
|
+
}
|
1041
|
+
// merge buffered requests
|
1042
|
+
const request = {
|
1043
|
+
actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
|
1044
|
+
selectors: requests
|
1045
|
+
.map(({ selectors }) => selectors)
|
1046
|
+
.filter(isDefined)
|
1047
|
+
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
1048
|
+
};
|
1049
|
+
this.statefulExecutionInProgress$.next(true);
|
1050
|
+
return this.flowStateApiService.execute(this.stateId$.value, request);
|
1051
|
+
}), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.statefulExecutionInProgress$.next(false)), catchError(e => {
|
1052
|
+
this.statefulExecutionInProgress$.next(false);
|
1053
|
+
return throwError(() => e);
|
1054
|
+
}));
|
901
1055
|
}
|
902
|
-
|
903
|
-
return this.
|
1056
|
+
executeStateful$(request) {
|
1057
|
+
return this.statefulExecutionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
|
1058
|
+
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
1059
|
+
combineLatest([
|
1060
|
+
this.statefulExecutionRequest$,
|
1061
|
+
of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
|
1062
|
+
])), map$1(([response]) => response), take$1(1));
|
904
1063
|
}
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
[requestId]: {
|
910
|
-
name: selectorName,
|
911
|
-
inputData,
|
912
|
-
},
|
913
|
-
},
|
914
|
-
}).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
|
1064
|
+
initStateless$() {
|
1065
|
+
var _a;
|
1066
|
+
const { headerId } = this.contextService.resolve();
|
1067
|
+
return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
|
915
1068
|
}
|
916
|
-
|
1069
|
+
calculate$() {
|
917
1070
|
var _a;
|
918
|
-
|
1071
|
+
const flowState = this.quoteDraftService.quoteDraft;
|
1072
|
+
if (!flowState) {
|
1073
|
+
return of(undefined);
|
1074
|
+
}
|
1075
|
+
/*
|
1076
|
+
Don't execute procedures when:
|
1077
|
+
* Initializing a standalone product configuration UI, as procedure is execute in /price call
|
1078
|
+
* Initializing an empty account (account with no assets)
|
1079
|
+
*/
|
1080
|
+
const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT &&
|
1081
|
+
!this.quoteDraftService.hasProducts &&
|
1082
|
+
!this.quoteDraftService.hasAssets &&
|
1083
|
+
!((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.length);
|
1084
|
+
if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
|
1085
|
+
return of(undefined);
|
1086
|
+
}
|
1087
|
+
return this.flowConfiguration.calculate$(flowState);
|
919
1088
|
}
|
920
1089
|
executeStateless$(request) {
|
921
|
-
return of(undefined).pipe(
|
1090
|
+
return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
|
922
1091
|
var _a;
|
923
|
-
|
924
|
-
|
925
|
-
|
1092
|
+
/*
|
1093
|
+
Skip price calculation in case
|
1094
|
+
1. No actions in the request
|
1095
|
+
2. Initialization process execution (state not initialized yet)
|
1096
|
+
*/
|
1097
|
+
if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length) || !this.isInitialized()) {
|
926
1098
|
return of(undefined);
|
927
1099
|
}
|
928
|
-
|
929
|
-
|
930
|
-
var _a;
|
931
|
-
configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
|
932
|
-
});
|
933
|
-
return this.configurationService.configureRequest$(configurationRequest);
|
934
|
-
}), tap$1(() => {
|
935
|
-
if (!request.selectors) {
|
936
|
-
return;
|
1100
|
+
else {
|
1101
|
+
return this.calculate$();
|
937
1102
|
}
|
938
|
-
|
939
|
-
const finalConfigurationRequest = this.configurationService.generateRequest();
|
940
|
-
const selectorsResult = EntityUtil.entries(request.selectors).reduce((trunk, [key, selector]) => {
|
941
|
-
trunk[key] = this.executeSelectorScript(finalConfigurationRequest, selector);
|
942
|
-
return trunk;
|
943
|
-
}, {});
|
944
|
-
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.value), selectorsResult));
|
945
|
-
}), map$2(() => undefined));
|
1103
|
+
}), map$1(() => this.executeStatelessSelectors(request)));
|
946
1104
|
}
|
947
|
-
|
948
|
-
|
1105
|
+
executeStatelessActions(request) {
|
1106
|
+
var _a;
|
1107
|
+
if (!this.quoteDraftService.quoteDraft || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
1108
|
+
return;
|
1109
|
+
}
|
1110
|
+
let flowState = this.quoteDraftService.quoteDraft;
|
1111
|
+
request.actions.forEach(action => {
|
1112
|
+
var _a;
|
1113
|
+
try {
|
1114
|
+
flowState = (_a = this.executeActionScript(flowState, action)) !== null && _a !== void 0 ? _a : flowState;
|
1115
|
+
}
|
1116
|
+
catch (e) {
|
1117
|
+
console.error(e);
|
1118
|
+
this.toastService.add({ severity: ToastType.error, summary: String(e) });
|
1119
|
+
throw e;
|
1120
|
+
}
|
1121
|
+
});
|
1122
|
+
this.quoteDraftService.updateQuoteDraft(flowState);
|
1123
|
+
}
|
1124
|
+
executeStatelessSelectors(request) {
|
1125
|
+
var _a;
|
1126
|
+
if (!this.quoteDraftService.quoteDraft) {
|
1127
|
+
throw 'QuoteDraft is not initialized';
|
1128
|
+
}
|
1129
|
+
const flowState = this.quoteDraftService.quoteDraft;
|
1130
|
+
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
1131
|
+
try {
|
1132
|
+
result.selectors[key] = {
|
1133
|
+
success: true,
|
1134
|
+
result: this.executeSelectorScript(flowState, selector),
|
1135
|
+
};
|
1136
|
+
}
|
1137
|
+
catch (e) {
|
1138
|
+
console.error(e);
|
1139
|
+
result.selectors[key] = {
|
1140
|
+
success: false,
|
1141
|
+
errorMessage: String(e),
|
1142
|
+
};
|
1143
|
+
}
|
1144
|
+
return result;
|
1145
|
+
}, { stateId: '', selectors: {} });
|
1146
|
+
}
|
1147
|
+
getFlowSafe() {
|
1148
|
+
if (!this.flowInfoService.flow) {
|
1149
|
+
throw 'Flow is not defined';
|
1150
|
+
}
|
1151
|
+
return this.flowInfoService.flow;
|
1152
|
+
}
|
1153
|
+
initProcessors$() {
|
1154
|
+
var _a;
|
1155
|
+
const hasOverrides = Boolean((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors);
|
1156
|
+
const flow = this.getFlowSafe();
|
1157
|
+
if (flow.properties.stateful && !hasOverrides) {
|
1158
|
+
// Skip initialization as backend will take processors from SF
|
949
1159
|
return of(undefined);
|
950
1160
|
}
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
1161
|
+
const owners$ = Object.values(this.flowInfoService.templates)
|
1162
|
+
.map(template => {
|
1163
|
+
var _a, _b, _c;
|
1164
|
+
if (!template) {
|
1165
|
+
return;
|
1166
|
+
}
|
1167
|
+
const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
|
1168
|
+
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
|
1169
|
+
const processorsMap = processors.reduce((acc, p) => {
|
1170
|
+
acc[p.apiName] = p;
|
1171
|
+
return acc;
|
1172
|
+
}, {});
|
1173
|
+
this.processors[template.id] = processorsMap;
|
1174
|
+
}));
|
1175
|
+
})
|
1176
|
+
.filter(isDefined);
|
1177
|
+
if (!owners$.length) {
|
1178
|
+
return of(undefined);
|
1179
|
+
}
|
1180
|
+
return forkJoin(owners$).pipe(map$1(noop));
|
965
1181
|
}
|
966
|
-
executeActionScript(request,
|
967
|
-
var _a
|
968
|
-
const
|
969
|
-
|
970
|
-
|
971
|
-
|
1182
|
+
executeActionScript(request, executable) {
|
1183
|
+
var _a;
|
1184
|
+
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
1185
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1186
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1187
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
1188
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
972
1189
|
}
|
973
|
-
return this.executeProcessorScript(request,
|
1190
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
974
1191
|
}
|
975
|
-
executeSelectorScript(request,
|
976
|
-
var _a
|
977
|
-
const
|
978
|
-
|
979
|
-
|
980
|
-
|
1192
|
+
executeSelectorScript(request, executable) {
|
1193
|
+
var _a;
|
1194
|
+
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
1195
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1196
|
+
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1197
|
+
const scopeText = scope ? ` in ${scope}` : '';
|
1198
|
+
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
981
1199
|
}
|
982
|
-
return this.executeProcessorScript(request,
|
1200
|
+
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
983
1201
|
}
|
984
|
-
executeProcessorScript(request,
|
985
|
-
|
1202
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
1203
|
+
var _a;
|
1204
|
+
const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
|
1205
|
+
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
1206
|
+
if (!functionToExecute) {
|
1207
|
+
const script = `${configurationProcessor.script}\nreturn transform;`;
|
1208
|
+
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
1209
|
+
functionToExecute = new Function(script + sourceMap)();
|
1210
|
+
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
1211
|
+
}
|
1212
|
+
return functionToExecute({
|
986
1213
|
request,
|
987
|
-
inputData
|
1214
|
+
inputData,
|
1215
|
+
flowStore: this.flowStore,
|
988
1216
|
});
|
989
1217
|
}
|
1218
|
+
generateRequestId(scope, selectorName, inputData) {
|
1219
|
+
const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
|
1220
|
+
return `${scope}/${selectorName}/${inputDataHash}`;
|
1221
|
+
}
|
1222
|
+
getDefaultExecutionRequestDTO() {
|
1223
|
+
var _a, _b, _c;
|
1224
|
+
const request = {
|
1225
|
+
actions: [],
|
1226
|
+
selectors: {},
|
1227
|
+
};
|
1228
|
+
if (this.getFlowSafe().properties.standalone) {
|
1229
|
+
return request;
|
1230
|
+
}
|
1231
|
+
const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
|
1232
|
+
(_a = request.actions) === null || _a === void 0 ? void 0 : _a.push({
|
1233
|
+
apiName: 'UPDATE_PRICE_LIST',
|
1234
|
+
ownerId,
|
1235
|
+
inputData: {},
|
1236
|
+
});
|
1237
|
+
(_b = request.actions) === null || _b === void 0 ? void 0 : _b.push({
|
1238
|
+
apiName: 'UPDATE_ASSET_IDS',
|
1239
|
+
ownerId,
|
1240
|
+
inputData: {},
|
1241
|
+
});
|
1242
|
+
(_c = request.actions) === null || _c === void 0 ? void 0 : _c.push({
|
1243
|
+
apiName: 'UPDATE_CONTEXT_PROPERTIES',
|
1244
|
+
ownerId,
|
1245
|
+
inputData: this.contextService.resolve().properties,
|
1246
|
+
});
|
1247
|
+
return request;
|
1248
|
+
}
|
990
1249
|
}
|
991
|
-
|
992
|
-
|
993
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
1250
|
+
FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
1251
|
+
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|
1252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
|
994
1253
|
type: Injectable
|
995
|
-
}], ctorParameters: function () {
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
}
|
1254
|
+
}], ctorParameters: function () {
|
1255
|
+
return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
|
1256
|
+
type: Optional
|
1257
|
+
}, {
|
1258
|
+
type: Inject,
|
1259
|
+
args: [FLOW_CUSTOMIZATION]
|
1260
|
+
}] }];
|
1261
|
+
} });
|
1004
1262
|
|
1005
1263
|
class FlowUpdateService {
|
1006
1264
|
update(rootLineItems, updates, charges) {
|
@@ -1134,37 +1392,371 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1134
1392
|
type: Injectable
|
1135
1393
|
}] });
|
1136
1394
|
|
1137
|
-
class
|
1138
|
-
constructor(
|
1139
|
-
this.
|
1140
|
-
this.
|
1141
|
-
this.
|
1142
|
-
|
1143
|
-
|
1395
|
+
class RuntimeSettingsService {
|
1396
|
+
constructor(configurationSettingsApiService) {
|
1397
|
+
this.configurationSettingsApiService = configurationSettingsApiService;
|
1398
|
+
this.configurationSettings$ = new BehaviorSubject({});
|
1399
|
+
this.currencySettings$ = new BehaviorSubject({
|
1400
|
+
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1401
|
+
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1402
|
+
});
|
1403
|
+
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
1404
|
+
this.getCurrencySymbol = (locale, currency) => {
|
1405
|
+
return (0)
|
1406
|
+
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1407
|
+
.replace(/\d/g, '')
|
1408
|
+
.trim();
|
1409
|
+
};
|
1144
1410
|
}
|
1145
|
-
|
1146
|
-
return this.
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
this.quoteDraftService.updateQuoteDraft(result);
|
1153
|
-
}), map$2(noop));
|
1411
|
+
create() {
|
1412
|
+
return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
|
1413
|
+
var _a;
|
1414
|
+
this.configurationSettings$.next(configurationSettings);
|
1415
|
+
this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
|
1416
|
+
this.formattingSettings = this.getFormattingSettings();
|
1417
|
+
}), map$1(() => undefined));
|
1154
1418
|
}
|
1155
|
-
|
1156
|
-
|
1419
|
+
initCurrency(iso) {
|
1420
|
+
if (iso) {
|
1421
|
+
const symbol = this.getCurrencySymbol('en-US', iso);
|
1422
|
+
this.currencySettings$.next({ iso, symbol });
|
1423
|
+
}
|
1424
|
+
}
|
1425
|
+
getFormattingSettings() {
|
1426
|
+
var _a, _b;
|
1427
|
+
if (this.formattingSettings) {
|
1428
|
+
return this.formattingSettings;
|
1429
|
+
}
|
1430
|
+
const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
|
1431
|
+
return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
|
1432
|
+
}, {});
|
1433
|
+
const currencySettings = this.getCurrencySettings();
|
1434
|
+
const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
|
1435
|
+
DEFAULT_DATE_FORMAT;
|
1436
|
+
const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
|
1437
|
+
const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
|
1438
|
+
// the number of decimal places can be 0
|
1439
|
+
const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
|
1440
|
+
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1441
|
+
? Number(priceScale)
|
1442
|
+
: DEFAULT_DECIMALS_COUNT;
|
1443
|
+
const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
|
1444
|
+
return {
|
1445
|
+
currencySymbol: currencySettings.symbol,
|
1446
|
+
dateFormats: getSupportedDateFormats(dateFormat),
|
1447
|
+
decimalsCount,
|
1448
|
+
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1449
|
+
? decimalSeparator
|
1450
|
+
: DEFAULT_DECIMAL_SEPARATOR,
|
1451
|
+
// thousands separator can be a blank value, so it can also be null
|
1452
|
+
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1453
|
+
? thousandsSeparator || ''
|
1454
|
+
: DEFAULT_THOUSANDS_SEPARATOR,
|
1455
|
+
actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
|
1456
|
+
? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
|
1457
|
+
: DEFAULT_ACTION_CODE_LABELS,
|
1458
|
+
};
|
1459
|
+
}
|
1460
|
+
getConfigurationSettings() {
|
1461
|
+
return this.configurationSettings$.value;
|
1462
|
+
}
|
1463
|
+
getShoppingCartSettings() {
|
1464
|
+
return this.shoppingCartSettings$.value;
|
1465
|
+
}
|
1466
|
+
getCurrencySettings() {
|
1467
|
+
return this.currencySettings$.value;
|
1468
|
+
}
|
1469
|
+
parseConfigurationSettings(settings) {
|
1470
|
+
return settings.reduce((acc, setting) => {
|
1471
|
+
switch (setting.key) {
|
1472
|
+
case 'shopping-cart':
|
1473
|
+
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
1474
|
+
break;
|
1475
|
+
case 'navigation':
|
1476
|
+
acc.navigation = parseJsonSafely(setting.value, {});
|
1477
|
+
break;
|
1478
|
+
case 'flows':
|
1479
|
+
acc.flows = parseJsonSafely(setting.value, []);
|
1480
|
+
break;
|
1481
|
+
default:
|
1482
|
+
acc[setting.key] = setting.value;
|
1483
|
+
}
|
1484
|
+
return acc;
|
1485
|
+
}, {});
|
1486
|
+
}
|
1487
|
+
addShoppingCartSettings(settings) {
|
1488
|
+
// uniqBy removes items with the biggest index
|
1489
|
+
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
1490
|
+
this.shoppingCartSettings$.next(newSettings);
|
1491
|
+
}
|
1492
|
+
}
|
1493
|
+
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1494
|
+
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
1495
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
1496
|
+
type: Injectable
|
1497
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
1498
|
+
|
1499
|
+
class ConfigurationService {
|
1500
|
+
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
|
1501
|
+
this.quoteDraftService = quoteDraftService;
|
1502
|
+
this.runtimeService = runtimeService;
|
1503
|
+
this.contextService = contextService;
|
1504
|
+
this.configurationApiService = configurationApiService;
|
1505
|
+
this.messageService = messageService;
|
1506
|
+
this.dialogService = dialogService;
|
1507
|
+
this.runtimeSettings = runtimeSettings;
|
1508
|
+
this.mode = ConfigurationMode.SEARCH;
|
1509
|
+
this.configurationState = new BehaviorSubject(null);
|
1510
|
+
this.isLoadingSubj$ = new BehaviorSubject(false);
|
1511
|
+
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
1512
|
+
this.hasUnsavedChanges = false;
|
1513
|
+
}
|
1514
|
+
reset() {
|
1515
|
+
this.hasUnsavedChanges = false;
|
1516
|
+
this.runtimeService.reset();
|
1517
|
+
this.configurableRamp = undefined;
|
1518
|
+
this.configurationState.next(null);
|
1519
|
+
}
|
1520
|
+
patch$(lineItem, options) {
|
1521
|
+
const source = this.getSnapshot();
|
1522
|
+
if (!source) {
|
1523
|
+
return throwError(() => new Error(`Source LineItem not found`));
|
1524
|
+
}
|
1525
|
+
const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
|
1526
|
+
this.configurableRamp = new LineItemWorker(source).replace(lineItem, skipCardinalityCalculation).li;
|
1527
|
+
return this.configure().pipe(catchError$1(error => {
|
1528
|
+
console.error(error);
|
1529
|
+
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
1530
|
+
this.messageService.add({ severity: 'error', summary: error });
|
1531
|
+
}
|
1532
|
+
// bounce back if configuration call has failed
|
1533
|
+
const prevState = this.configurationState.value;
|
1534
|
+
this.configurationState.next(prevState ? Object.assign({}, prevState) : null);
|
1535
|
+
return throwError(() => error);
|
1536
|
+
}), tap(() => {
|
1537
|
+
if (!this.hasUnsavedChanges) {
|
1538
|
+
this.hasUnsavedChanges = true;
|
1539
|
+
}
|
1540
|
+
}));
|
1541
|
+
}
|
1542
|
+
patch(lineItem, options) {
|
1543
|
+
this.patch$(lineItem, options).subscribe();
|
1544
|
+
}
|
1545
|
+
setConfigurableRamp(lineItem) {
|
1546
|
+
this.configurableRamp = lineItem;
|
1547
|
+
}
|
1548
|
+
get() {
|
1549
|
+
return this.configurationState.pipe(map(state => state === null || state === void 0 ? void 0 : state.lineItem), shareReplay$1());
|
1550
|
+
}
|
1551
|
+
getSnapshot() {
|
1552
|
+
var _a, _b;
|
1553
|
+
return ((_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.lineItem) ? Object.assign({}, (_b = this.configurationState.value) === null || _b === void 0 ? void 0 : _b.lineItem) : undefined;
|
1554
|
+
}
|
1555
|
+
getRuntimeModel() {
|
1556
|
+
const runtimeModel = this.runtimeService.runtimeModel;
|
1557
|
+
if (!runtimeModel) {
|
1558
|
+
throw new Error('Runtime model not initialized');
|
1559
|
+
}
|
1560
|
+
return runtimeModel;
|
1561
|
+
}
|
1562
|
+
getRuntimeContext() {
|
1563
|
+
const runtimeContext = this.runtimeService.runtimeContext;
|
1564
|
+
if (!runtimeContext) {
|
1565
|
+
throw new Error('Runtime context not initialized');
|
1566
|
+
}
|
1567
|
+
return runtimeContext;
|
1568
|
+
}
|
1569
|
+
get state$() {
|
1570
|
+
return this.configurationState.asObservable();
|
1571
|
+
}
|
1572
|
+
get stateSnapshot() {
|
1573
|
+
return this.configurationState.value;
|
1574
|
+
}
|
1575
|
+
get contextSnapshot() {
|
1576
|
+
return this.contextService.resolve();
|
1577
|
+
}
|
1578
|
+
get context$() {
|
1579
|
+
return this.contextService.resolve$();
|
1580
|
+
}
|
1581
|
+
get charges$() {
|
1582
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.charges) !== null && _a !== void 0 ? _a : {}; }));
|
1583
|
+
}
|
1584
|
+
get chargesSnapshot() {
|
1585
|
+
var _a, _b;
|
1586
|
+
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.charges) !== null && _b !== void 0 ? _b : {};
|
1587
|
+
}
|
1588
|
+
get pricePlans$() {
|
1589
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.pricePlans) !== null && _a !== void 0 ? _a : {}; }));
|
1590
|
+
}
|
1591
|
+
get pricePlansSnapshot() {
|
1592
|
+
var _a, _b;
|
1593
|
+
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.pricePlans) !== null && _b !== void 0 ? _b : {};
|
1594
|
+
}
|
1595
|
+
get procedureContext$() {
|
1596
|
+
return this.configurationState.pipe(map(state => { var _a; return (_a = state === null || state === void 0 ? void 0 : state.procedureContext) !== null && _a !== void 0 ? _a : {}; }));
|
1597
|
+
}
|
1598
|
+
get procedureContextSnapshot() {
|
1599
|
+
var _a, _b;
|
1600
|
+
return (_b = (_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.procedureContext) !== null && _b !== void 0 ? _b : {};
|
1601
|
+
}
|
1602
|
+
configure() {
|
1603
|
+
return this.configureRequest$(this.generateRequest());
|
1604
|
+
}
|
1605
|
+
configureRequest$(configurationRequest) {
|
1606
|
+
var _a;
|
1607
|
+
const runtimeContext = this.getRuntimeContext();
|
1608
|
+
const runtimeModel = this.getRuntimeModel();
|
1609
|
+
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1610
|
+
const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
|
1611
|
+
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
1612
|
+
const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
|
1613
|
+
this.isLoadingSubj$.next(true);
|
1614
|
+
const configure$ = pricingEnabled && customPriceApi
|
1615
|
+
? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
|
1616
|
+
: this.configurationApiService.configureLineItem({
|
1617
|
+
configurationRequest,
|
1618
|
+
runtimeModel,
|
1619
|
+
pricingEnabled,
|
1620
|
+
});
|
1621
|
+
return configure$.pipe(tap(result => {
|
1622
|
+
var _a;
|
1623
|
+
this.contextService.update(result.context);
|
1624
|
+
this.configurationState.next(result);
|
1625
|
+
if ((_a = result.deletedLineItems) === null || _a === void 0 ? void 0 : _a.length) {
|
1626
|
+
this.showInactiveProductsConfirmation();
|
1627
|
+
}
|
1628
|
+
this.configurableRamp = result.lineItem;
|
1629
|
+
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })), finalize$1(() => this.isLoadingSubj$.next(false)));
|
1630
|
+
}
|
1631
|
+
configureExternal$(props) {
|
1632
|
+
return this.runtimeService
|
1633
|
+
.init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
|
1634
|
+
.pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
|
1635
|
+
this.messageService.add({ severity: ToastType.error, summary: error });
|
1636
|
+
throw error;
|
1637
|
+
}), finalize$1(() => this.reset()));
|
1638
|
+
}
|
1639
|
+
configureGuidedSelling$(data) {
|
1640
|
+
return this.configurationApiService
|
1641
|
+
.configureLineItem({
|
1642
|
+
configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
|
1643
|
+
})
|
1644
|
+
.pipe(catchError$1(error => {
|
1645
|
+
if (error instanceof HttpErrorResponse) {
|
1646
|
+
this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
|
1647
|
+
}
|
1648
|
+
throw error;
|
1649
|
+
}));
|
1650
|
+
}
|
1651
|
+
generateRequest(lightMode = true) {
|
1652
|
+
var _a, _b;
|
1653
|
+
const lineItem = this.generateLineItem();
|
1654
|
+
let request = {
|
1655
|
+
lineItem,
|
1656
|
+
mode: this.mode,
|
1657
|
+
step: !((_a = this.configurationState.value) === null || _a === void 0 ? void 0 : _a.lineItem) ? RuntimeStep.START : RuntimeStep.UPDATE,
|
1658
|
+
attributeDomainMode: 'ALL',
|
1659
|
+
context: this.contextService.resolve(),
|
1660
|
+
lineItems: ((_b = this.quoteDraftService.quoteDraft) === null || _b === void 0 ? void 0 : _b.currentState) || [],
|
1661
|
+
asset: this.getAsset(),
|
1662
|
+
};
|
1663
|
+
if (lightMode) {
|
1664
|
+
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
1665
|
+
}
|
1666
|
+
return request;
|
1667
|
+
}
|
1668
|
+
generateLineItem() {
|
1669
|
+
var _a;
|
1670
|
+
const runtimeContext = this.getRuntimeContext();
|
1671
|
+
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1672
|
+
let lineItem = cloneDeep(this.configurableRamp);
|
1673
|
+
if (!lineItem) {
|
1674
|
+
const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
|
1675
|
+
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
1676
|
+
// Set default attributes
|
1677
|
+
if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
|
1678
|
+
const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
1679
|
+
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
1680
|
+
}
|
1681
|
+
}
|
1682
|
+
return lineItem;
|
1683
|
+
}
|
1684
|
+
getUIDefinitionProperties() {
|
1685
|
+
var _a, _b, _c;
|
1686
|
+
return Object.assign(Object.assign({}, ((_b = (_a = this.getRuntimeContext().uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
|
1687
|
+
}
|
1688
|
+
showInactiveProductsConfirmation() {
|
1689
|
+
const confirmationConfig = {
|
1690
|
+
title: ' ',
|
1691
|
+
description: 'This quote contains inactive products. Do you want to remove them?',
|
1692
|
+
primaryButtonLabel: 'Remove products',
|
1693
|
+
secondaryButtonLabel: 'Back to Quote',
|
1694
|
+
};
|
1695
|
+
this.dialogService
|
1696
|
+
.open(ConfirmationComponent, {
|
1697
|
+
dismissableMask: false,
|
1698
|
+
closeOnEscape: false,
|
1699
|
+
closable: false,
|
1700
|
+
showHeader: true,
|
1701
|
+
header: `Inactive Products in Quote`,
|
1702
|
+
width: '440px',
|
1703
|
+
data: { confirmationConfig },
|
1704
|
+
})
|
1705
|
+
.onClose.subscribe(result => {
|
1706
|
+
if (!result) {
|
1707
|
+
const context = this.contextService.resolve();
|
1708
|
+
window['VELO_BACK_FN'].apply(null, [context.headerId]);
|
1709
|
+
}
|
1710
|
+
});
|
1711
|
+
}
|
1712
|
+
getAsset() {
|
1713
|
+
var _a;
|
1714
|
+
const lineItem = this.configurableRamp;
|
1715
|
+
if (!lineItem) {
|
1716
|
+
return;
|
1717
|
+
}
|
1718
|
+
return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
|
1719
|
+
}
|
1720
|
+
}
|
1721
|
+
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1722
|
+
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
1723
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
|
1724
|
+
type: Injectable
|
1725
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
|
1726
|
+
|
1727
|
+
class FlowConfigurationService {
|
1728
|
+
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
|
1729
|
+
this.proceduresApiService = proceduresApiService;
|
1730
|
+
this.contextService = contextService;
|
1731
|
+
this.quoteDraftService = quoteDraftService;
|
1732
|
+
this.updateService = updateService;
|
1733
|
+
this.configurationService = configurationService;
|
1734
|
+
this.updatedSubj$ = new Subject();
|
1735
|
+
this.updated$ = this.updatedSubj$.asObservable();
|
1736
|
+
}
|
1737
|
+
calculate$(quoteDraft) {
|
1738
|
+
return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
|
1739
|
+
// sort the result current state based on the quote draft initial state
|
1740
|
+
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1741
|
+
result.currentState = result.currentState
|
1742
|
+
.slice()
|
1743
|
+
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
1744
|
+
this.quoteDraftService.updateQuoteDraft(result);
|
1745
|
+
}), map$1(noop));
|
1746
|
+
}
|
1747
|
+
calculate(quoteDraft) {
|
1748
|
+
this.calculate$(quoteDraft).subscribe();
|
1157
1749
|
}
|
1158
1750
|
update$(updates) {
|
1159
1751
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1160
1752
|
if (!quoteDraft) {
|
1161
1753
|
return of(null);
|
1162
1754
|
}
|
1163
|
-
return of([]).pipe(map$
|
1755
|
+
return of([]).pipe(map$1(() => {
|
1164
1756
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
1165
1757
|
this.updateService.update(updatedState, updates, quoteDraft.charges);
|
1166
1758
|
return updatedState;
|
1167
|
-
}), switchMap
|
1759
|
+
}), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1168
1760
|
}
|
1169
1761
|
update(updates) {
|
1170
1762
|
this.update$(updates).subscribe();
|
@@ -1183,7 +1775,7 @@ class FlowConfigurationService {
|
|
1183
1775
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
1184
1776
|
return of([]).pipe(tap$1(() => {
|
1185
1777
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
1186
|
-
}), switchMap
|
1778
|
+
}), switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1187
1779
|
}
|
1188
1780
|
revert(lineItemId) {
|
1189
1781
|
this.revert$(lineItemId).subscribe();
|
@@ -1194,7 +1786,7 @@ class FlowConfigurationService {
|
|
1194
1786
|
if (!quoteDraft) {
|
1195
1787
|
return of(null);
|
1196
1788
|
}
|
1197
|
-
return of([]).pipe(map$
|
1789
|
+
return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1198
1790
|
}
|
1199
1791
|
delete(ids) {
|
1200
1792
|
this.delete$(ids).subscribe();
|
@@ -1205,36 +1797,36 @@ class FlowConfigurationService {
|
|
1205
1797
|
return of(null);
|
1206
1798
|
}
|
1207
1799
|
const updatedState = [...quoteDraft.currentState, term];
|
1208
|
-
return of([]).pipe(switchMap
|
1800
|
+
return of([]).pipe(switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1209
1801
|
}
|
1210
1802
|
addToCart$(props) {
|
1211
1803
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1212
1804
|
if (!quoteDraft) {
|
1213
1805
|
return of(null);
|
1214
1806
|
}
|
1215
|
-
return this.configurationService.configureExternal$(props).pipe(map$
|
1807
|
+
return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
|
1216
1808
|
var _a, _b, _c;
|
1217
1809
|
const model = this.configurationService.getRuntimeModel();
|
1218
1810
|
const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
|
1219
1811
|
const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
|
1220
1812
|
return [...quoteDraft.currentState, ...lineItems];
|
1221
|
-
}), switchMap
|
1813
|
+
}), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
1222
1814
|
}
|
1223
1815
|
get() {
|
1224
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
1816
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
|
1225
1817
|
}
|
1226
1818
|
getSnapshot() {
|
1227
1819
|
var _a, _b;
|
1228
1820
|
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
1229
1821
|
}
|
1230
1822
|
get charges$() {
|
1231
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
1823
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
|
1232
1824
|
}
|
1233
1825
|
get pricePlans$() {
|
1234
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
1826
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
|
1235
1827
|
}
|
1236
1828
|
get activeMetrics$() {
|
1237
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
1829
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
|
1238
1830
|
}
|
1239
1831
|
get chargesSnapshot() {
|
1240
1832
|
var _a, _b;
|
@@ -1256,298 +1848,541 @@ class FlowConfigurationService {
|
|
1256
1848
|
}
|
1257
1849
|
handleErrorAndBounceBack() {
|
1258
1850
|
return (source$) => {
|
1259
|
-
return source$.pipe(catchError
|
1851
|
+
return source$.pipe(catchError(error => {
|
1260
1852
|
console.error(error);
|
1261
1853
|
// bounce back if configuration call has failed
|
1262
1854
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
1263
1855
|
if (quoteDraft) {
|
1264
1856
|
this.quoteDraftService.updateQuoteDraft(quoteDraft);
|
1857
|
+
this.updatedSubj$.next();
|
1265
1858
|
}
|
1266
1859
|
return throwError(() => error);
|
1267
1860
|
}));
|
1268
1861
|
};
|
1269
1862
|
}
|
1270
1863
|
}
|
1271
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1272
|
-
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
1273
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
1864
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1865
|
+
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
1866
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
1867
|
+
type: Injectable
|
1868
|
+
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1869
|
+
|
1870
|
+
class FlowConfigurationModule {
|
1871
|
+
}
|
1872
|
+
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1873
|
+
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
|
1874
|
+
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService], imports: [ApiModule] });
|
1875
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
1876
|
+
type: NgModule,
|
1877
|
+
args: [{
|
1878
|
+
imports: [ApiModule],
|
1879
|
+
providers: [FlowConfigurationService, FlowUpdateService],
|
1880
|
+
}]
|
1881
|
+
}] });
|
1882
|
+
|
1883
|
+
class FlowStateConfigurationService {
|
1884
|
+
constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
|
1885
|
+
this.flowInfoService = flowInfoService;
|
1886
|
+
this.flowConfigurationService = flowConfigurationService;
|
1887
|
+
this.flowStateApiService = flowStateApiService;
|
1888
|
+
this.flowStateService = flowStateService;
|
1889
|
+
this.configurationStateId$ = new BehaviorSubject(null);
|
1890
|
+
}
|
1891
|
+
get configurationStateId() {
|
1892
|
+
return this.configurationStateId$.value;
|
1893
|
+
}
|
1894
|
+
addToCart$(props) {
|
1895
|
+
var _a;
|
1896
|
+
let request$;
|
1897
|
+
const stateful = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful;
|
1898
|
+
if (stateful) {
|
1899
|
+
const stateId = this.flowStateService.stateId;
|
1900
|
+
if (!stateId) {
|
1901
|
+
request$ = of();
|
1902
|
+
}
|
1903
|
+
else {
|
1904
|
+
const lineItem = generateConfigurationLineItem(props, props.qty);
|
1905
|
+
request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
|
1906
|
+
if (!this.configurationStateId) {
|
1907
|
+
return of();
|
1908
|
+
}
|
1909
|
+
return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
|
1910
|
+
}));
|
1911
|
+
}
|
1912
|
+
}
|
1913
|
+
else {
|
1914
|
+
request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
|
1915
|
+
}
|
1916
|
+
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
|
1917
|
+
}
|
1918
|
+
}
|
1919
|
+
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1920
|
+
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
|
1921
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
1922
|
+
type: Injectable
|
1923
|
+
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
|
1924
|
+
|
1925
|
+
class ProductImagesService {
|
1926
|
+
constructor(productApiService) {
|
1927
|
+
this.productApiService = productApiService;
|
1928
|
+
this.imagesMap$ = new BehaviorSubject({});
|
1929
|
+
}
|
1930
|
+
getImageUrl$(productId) {
|
1931
|
+
if (this.imagesMap$.value[productId] == null) {
|
1932
|
+
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
1933
|
+
this.fetchProductImage(productId);
|
1934
|
+
}
|
1935
|
+
return this.imagesMap$.pipe(map$1(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
|
1936
|
+
}
|
1937
|
+
fetchProductImage(productId) {
|
1938
|
+
this.productApiService
|
1939
|
+
.fetchImage$(productId)
|
1940
|
+
.pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
1941
|
+
.subscribe();
|
1942
|
+
}
|
1943
|
+
}
|
1944
|
+
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1945
|
+
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
|
1946
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
|
1947
|
+
type: Injectable
|
1948
|
+
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
1949
|
+
|
1950
|
+
class RuntimeContextService {
|
1951
|
+
constructor(configurationApiService) {
|
1952
|
+
this.configurationApiService = configurationApiService;
|
1953
|
+
}
|
1954
|
+
getRuntimeContext(productId, offeringId) {
|
1955
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
1956
|
+
var _a;
|
1957
|
+
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
1958
|
+
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
1959
|
+
const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
|
1960
|
+
const uiDefinitionProperties = uiDefinitionContainer === null || uiDefinitionContainer === void 0 ? void 0 : uiDefinitionContainer.source.properties;
|
1961
|
+
return {
|
1962
|
+
modelId: runtimeData.modelId,
|
1963
|
+
uiDefinitionContainer: uiDefinitionContainer,
|
1964
|
+
runtimeModel: runtimeModel,
|
1965
|
+
runtimeMode: RuntimeMode.PROD,
|
1966
|
+
productId: productId,
|
1967
|
+
productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
|
1968
|
+
offeringId: offeringId,
|
1969
|
+
properties: {
|
1970
|
+
PricingEnabled: (uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.pricingEnabled) ? 'true' : 'false',
|
1971
|
+
PriceListId: uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.priceList,
|
1972
|
+
},
|
1973
|
+
};
|
1974
|
+
}));
|
1975
|
+
}
|
1976
|
+
getUIDefinitionContainer(runtimeData) {
|
1977
|
+
var _a;
|
1978
|
+
const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
|
1979
|
+
return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
|
1980
|
+
}
|
1981
|
+
}
|
1982
|
+
RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1983
|
+
RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
|
1984
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
|
1985
|
+
type: Injectable
|
1986
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
|
1987
|
+
|
1988
|
+
class ConfigurationRuntimeService {
|
1989
|
+
constructor(apiService, contextService, runtimeContextService) {
|
1990
|
+
this.apiService = apiService;
|
1991
|
+
this.contextService = contextService;
|
1992
|
+
this.runtimeContextService = runtimeContextService;
|
1993
|
+
this._isInitialized = false;
|
1994
|
+
this.uiDefinitionProperties = {};
|
1995
|
+
}
|
1996
|
+
reset() {
|
1997
|
+
this._isInitialized = false;
|
1998
|
+
this._runtimeContext = undefined;
|
1999
|
+
this.initializationProps = undefined;
|
2000
|
+
this.uiDefinitionProperties = {};
|
2001
|
+
}
|
2002
|
+
initTestMode(uiDefinitionContainer) {
|
2003
|
+
var _a, _b;
|
2004
|
+
this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
|
2005
|
+
const uiDefinitionExternals = (_b = uiDefinitionContainer.source.externals) !== null && _b !== void 0 ? _b : {};
|
2006
|
+
return combineLatest([
|
2007
|
+
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
2008
|
+
this.contextService.initTestMode(),
|
2009
|
+
]).pipe(first(), map(([runtimeData, context]) => {
|
2010
|
+
var _a;
|
2011
|
+
this.contextService.update({
|
2012
|
+
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: uiDefinitionContainer.modelId, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', PriceListId: this.uiDefinitionProperties.priceList, offeringId: this.uiDefinitionProperties.offeringId }), uiDefinitionExternals),
|
2013
|
+
});
|
2014
|
+
this._runtimeContext = {
|
2015
|
+
modelId: uiDefinitionContainer.modelId,
|
2016
|
+
runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
|
2017
|
+
runtimeMode: RuntimeMode.TEST,
|
2018
|
+
uiDefinitionContainer,
|
2019
|
+
};
|
2020
|
+
return this._runtimeContext;
|
2021
|
+
}), tap(() => (this._isInitialized = true)));
|
2022
|
+
}
|
2023
|
+
init(props) {
|
2024
|
+
this.initializationProps = props;
|
2025
|
+
const context = this.contextService.resolve();
|
2026
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
2027
|
+
var _a, _b, _c, _d;
|
2028
|
+
this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
|
2029
|
+
const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
|
2030
|
+
const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
2031
|
+
this.id15to18('AccountId', mergeContext.properties);
|
2032
|
+
this._runtimeContext = mergeContext;
|
2033
|
+
if (context.properties && ((_d = this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
|
2034
|
+
this.contextService.update({
|
2035
|
+
properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
|
2036
|
+
});
|
2037
|
+
}
|
2038
|
+
return this._runtimeContext;
|
2039
|
+
}), tap(() => (this._isInitialized = true)));
|
2040
|
+
}
|
2041
|
+
overrideUIDefinition(uiDefinitionContainer) {
|
2042
|
+
var _a;
|
2043
|
+
if (!this._runtimeContext) {
|
2044
|
+
return;
|
2045
|
+
}
|
2046
|
+
this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
|
2047
|
+
this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
|
2048
|
+
}
|
2049
|
+
id15to18(propertyName, source) {
|
2050
|
+
if (!source) {
|
2051
|
+
return;
|
2052
|
+
}
|
2053
|
+
const value = source[propertyName];
|
2054
|
+
if (typeof value === 'string' && value.length === 15) {
|
2055
|
+
source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
|
2056
|
+
}
|
2057
|
+
}
|
2058
|
+
get isInitialized() {
|
2059
|
+
return this._isInitialized;
|
2060
|
+
}
|
2061
|
+
get runtimeModel() {
|
2062
|
+
var _a;
|
2063
|
+
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
2064
|
+
}
|
2065
|
+
get runtimeContext() {
|
2066
|
+
return this._runtimeContext;
|
2067
|
+
}
|
2068
|
+
}
|
2069
|
+
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
|
2070
|
+
ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
|
2071
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
|
1274
2072
|
type: Injectable
|
1275
|
-
}], ctorParameters: function () { return [{ type: i1.
|
1276
|
-
|
1277
|
-
class FlowConfigurationModule {
|
1278
|
-
}
|
1279
|
-
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1280
|
-
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
|
1281
|
-
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
|
1282
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
1283
|
-
type: NgModule,
|
1284
|
-
args: [{
|
1285
|
-
imports: [],
|
1286
|
-
providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
|
1287
|
-
}]
|
1288
|
-
}] });
|
1289
|
-
|
1290
|
-
class ConfigurationModule {
|
1291
|
-
}
|
1292
|
-
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1293
|
-
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
|
1294
|
-
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
|
1295
|
-
ContextApiService,
|
1296
|
-
ProductModelApiService,
|
1297
|
-
ConfigurationApiService,
|
1298
|
-
ConfigurationRuntimeService,
|
1299
|
-
RuntimeContextService,
|
1300
|
-
ConfigurationService,
|
1301
|
-
ConfigurationState,
|
1302
|
-
], imports: [ConfirmationDialogModule] });
|
1303
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
1304
|
-
type: NgModule,
|
1305
|
-
args: [{
|
1306
|
-
imports: [ConfirmationDialogModule],
|
1307
|
-
providers: [
|
1308
|
-
ContextApiService,
|
1309
|
-
ProductModelApiService,
|
1310
|
-
ConfigurationApiService,
|
1311
|
-
ConfigurationRuntimeService,
|
1312
|
-
RuntimeContextService,
|
1313
|
-
ConfigurationService,
|
1314
|
-
ConfigurationState,
|
1315
|
-
],
|
1316
|
-
}]
|
1317
|
-
}] });
|
2073
|
+
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
1318
2074
|
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
}
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
.map(item => [item]);
|
1344
|
-
}
|
1345
|
-
case 'avg': {
|
1346
|
-
const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
|
1347
|
-
return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
|
2075
|
+
class ConfigurationStateService {
|
2076
|
+
constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
|
2077
|
+
this.configurationRuntimeService = configurationRuntimeService;
|
2078
|
+
this.configurationService = configurationService;
|
2079
|
+
this.quoteDraftService = quoteDraftService;
|
2080
|
+
this.toastService = toastService;
|
2081
|
+
this.flowStateService = flowStateService;
|
2082
|
+
this.flowInfoService = flowInfoService;
|
2083
|
+
this.flowConfigurationService = flowConfigurationService;
|
2084
|
+
this.flowStateApiService = flowStateApiService;
|
2085
|
+
this.quoteApiService = quoteApiService;
|
2086
|
+
this.isInitialized$ = new BehaviorSubject(false);
|
2087
|
+
this.canceledConfiguration$ = new Subject();
|
2088
|
+
this.NOT_INITIALIZED = Symbol();
|
2089
|
+
this.executedFunctions = {};
|
2090
|
+
this.stateId = null;
|
2091
|
+
this.ownerId = '';
|
2092
|
+
this.subscriptions = {};
|
2093
|
+
this.configurationStore = {};
|
2094
|
+
}
|
2095
|
+
init$() {
|
2096
|
+
let request$;
|
2097
|
+
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
2098
|
+
request$ = this.initStateful$();
|
1348
2099
|
}
|
1349
|
-
|
1350
|
-
|
2100
|
+
else {
|
2101
|
+
request$ = this.initStateless$();
|
1351
2102
|
}
|
1352
|
-
|
1353
|
-
|
2103
|
+
return request$.pipe(finalize(() => {
|
2104
|
+
this.isInitialized$.next(true);
|
2105
|
+
this.canceledConfiguration$ = new Subject();
|
2106
|
+
}));
|
2107
|
+
}
|
2108
|
+
cleanup() {
|
2109
|
+
Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
|
2110
|
+
this.subscriptions = {};
|
2111
|
+
if (this.stateId) {
|
2112
|
+
this.cancelConfiguration();
|
1354
2113
|
}
|
2114
|
+
this.configurationStore = {};
|
2115
|
+
this.executedFunctions = {};
|
2116
|
+
this.configurationService.reset();
|
1355
2117
|
}
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
2118
|
+
execute$(req, forceSubscriptions) {
|
2119
|
+
var _a;
|
2120
|
+
const fullRequest = cloneDeep(req);
|
2121
|
+
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
2122
|
+
for (const subscription of Object.values(this.subscriptions)) {
|
2123
|
+
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
2124
|
+
}
|
2125
|
+
}
|
2126
|
+
let execution$;
|
2127
|
+
if (this.isStatefulConfiguration) {
|
2128
|
+
execution$ = this.executeStateful$(fullRequest);
|
2129
|
+
}
|
2130
|
+
else {
|
2131
|
+
execution$ = this.executeStateless$(fullRequest);
|
2132
|
+
}
|
2133
|
+
return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
|
1364
2134
|
}
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
this.quoteMetricsSettings = {};
|
1371
|
-
this.metricsCalculationMethodMap = {};
|
1372
|
-
this.metricsData = {};
|
1373
|
-
this.activeMetricRules = [];
|
1374
|
-
this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
|
1375
|
-
combineLatest([
|
1376
|
-
this.quoteDraftService.currentState$,
|
1377
|
-
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
|
1378
|
-
]).subscribe(([lineItems, setting]) => {
|
1379
|
-
let settingsData = {};
|
1380
|
-
try {
|
1381
|
-
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
2135
|
+
handleSelectorsResponse(selectors) {
|
2136
|
+
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
2137
|
+
var _a;
|
2138
|
+
if (!selectorResult.success) {
|
2139
|
+
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
1382
2140
|
}
|
1383
|
-
|
1384
|
-
|
2141
|
+
const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
|
2142
|
+
if (subscription$) {
|
2143
|
+
subscription$.next(selectorResult);
|
1385
2144
|
}
|
1386
|
-
this.quoteMetricsSettings = settingsData;
|
1387
|
-
this.updateMetrics(lineItems);
|
1388
2145
|
});
|
1389
2146
|
}
|
1390
|
-
|
1391
|
-
return this.
|
1392
|
-
}
|
1393
|
-
updateMetrics(lineItems) {
|
1394
|
-
const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
|
1395
|
-
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
1396
|
-
this.metricsData = metricKeys.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: this.calculateMetric(lineItems, key) })), {});
|
1397
|
-
this.metricsUpdated$.next();
|
2147
|
+
dispatch$(actionName, inputData = {}) {
|
2148
|
+
return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
|
1398
2149
|
}
|
1399
|
-
|
1400
|
-
|
2150
|
+
select$(selectorName, inputData = {}) {
|
2151
|
+
const requestId = UUID.UUID();
|
2152
|
+
return this.execute$({
|
2153
|
+
selectors: {
|
2154
|
+
[requestId]: {
|
2155
|
+
apiName: selectorName,
|
2156
|
+
inputData,
|
2157
|
+
ownerId: this.ownerId,
|
2158
|
+
},
|
2159
|
+
},
|
2160
|
+
}).pipe(map$1(response => response.selectors[requestId]));
|
1401
2161
|
}
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
2162
|
+
subscribe$(selectorName, inputData = {}, options) {
|
2163
|
+
const requestId = UUID.UUID();
|
2164
|
+
let subscription = this.subscriptions[requestId];
|
2165
|
+
if (!subscription) {
|
2166
|
+
const request = {
|
2167
|
+
selectors: {
|
2168
|
+
[requestId]: {
|
2169
|
+
apiName: selectorName,
|
2170
|
+
inputData,
|
2171
|
+
ownerId: this.ownerId,
|
2172
|
+
},
|
2173
|
+
},
|
2174
|
+
};
|
2175
|
+
subscription = {
|
2176
|
+
request,
|
2177
|
+
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
2178
|
+
};
|
2179
|
+
this.subscriptions[requestId] = subscription;
|
2180
|
+
if (!(options === null || options === void 0 ? void 0 : options.cold)) {
|
2181
|
+
this.execute$(request).subscribe();
|
1407
2182
|
}
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
if (this.
|
1412
|
-
|
2183
|
+
}
|
2184
|
+
return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), distinctUntilChanged(), finalize(() => {
|
2185
|
+
var _a;
|
2186
|
+
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
2187
|
+
delete this.subscriptions[requestId];
|
1413
2188
|
}
|
1414
|
-
|
1415
|
-
}, initial);
|
2189
|
+
}), takeUntil(this.canceledConfiguration$));
|
1416
2190
|
}
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
2191
|
+
saveConfiguration(quoteId, flow) {
|
2192
|
+
var _a, _b;
|
2193
|
+
if (this.isStatefulConfiguration) {
|
2194
|
+
return this.flowStateApiService
|
2195
|
+
.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
|
2196
|
+
.pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
|
2197
|
+
}
|
2198
|
+
else {
|
2199
|
+
if (!flow) {
|
2200
|
+
if (!quoteId) {
|
2201
|
+
return of({ quoteId: '' });
|
2202
|
+
}
|
2203
|
+
const rootLineItem = this.configurationService.getSnapshot();
|
2204
|
+
const currentState = rootLineItem ? [rootLineItem] : [];
|
2205
|
+
return this.quoteApiService
|
2206
|
+
.getQuoteDraft(quoteId)
|
2207
|
+
.pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState }))));
|
2208
|
+
}
|
2209
|
+
else {
|
2210
|
+
const quoteDraft = this.quoteDraftService.quoteDraft;
|
2211
|
+
const lineItem = this.configurationService.getSnapshot();
|
2212
|
+
if (!quoteDraft || !lineItem) {
|
2213
|
+
return of({ quoteId: '' });
|
2214
|
+
}
|
2215
|
+
const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
|
2216
|
+
let updatedState;
|
2217
|
+
if (isNewLineItem) {
|
2218
|
+
updatedState = [...quoteDraft.currentState, lineItem];
|
2219
|
+
}
|
2220
|
+
else {
|
2221
|
+
updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
|
2222
|
+
}
|
2223
|
+
return this.flowConfigurationService
|
2224
|
+
.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))
|
2225
|
+
.pipe(map$1(() => ({ quoteId: '' })));
|
2226
|
+
}
|
2227
|
+
}
|
1424
2228
|
}
|
1425
|
-
|
1426
|
-
|
2229
|
+
cancelConfiguration() {
|
2230
|
+
var _a, _b;
|
2231
|
+
if (!this.isInitialized$.value) {
|
2232
|
+
return of(undefined);
|
2233
|
+
}
|
2234
|
+
this.canceledConfiguration$.next();
|
2235
|
+
this.canceledConfiguration$.complete();
|
2236
|
+
this.subscriptions = {};
|
2237
|
+
this.isInitialized$.next(false);
|
2238
|
+
if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
|
2239
|
+
return of(undefined);
|
2240
|
+
}
|
2241
|
+
return this.flowStateApiService.cancelConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '');
|
1427
2242
|
}
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, decorators: [{
|
1432
|
-
type: Injectable,
|
1433
|
-
args: [{ providedIn: 'root' }]
|
1434
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
|
1435
|
-
|
1436
|
-
class ProductImagesService {
|
1437
|
-
constructor(productApiService) {
|
1438
|
-
this.productApiService = productApiService;
|
1439
|
-
this.imagesMap$ = new BehaviorSubject({});
|
2243
|
+
get isStatefulConfiguration() {
|
2244
|
+
var _a, _b;
|
2245
|
+
return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) !== null && _b !== void 0 ? _b : false;
|
1440
2246
|
}
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
2247
|
+
initStateful$() {
|
2248
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
2249
|
+
this.ownerId = (_c = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '';
|
2250
|
+
const lineItemId = (_e = (_d = this.configurationRuntimeService.runtimeContext) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.lineItemId;
|
2251
|
+
if (!this.flowStateService.stateId) {
|
2252
|
+
return of(undefined);
|
1445
2253
|
}
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
.
|
1451
|
-
|
1452
|
-
|
2254
|
+
const container = (_f = this.configurationRuntimeService.runtimeContext) === null || _f === void 0 ? void 0 : _f.uiDefinitionContainer;
|
2255
|
+
const lineItem = this.configurationService.generateLineItem();
|
2256
|
+
let request$;
|
2257
|
+
if (!lineItemId) {
|
2258
|
+
request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
|
2259
|
+
lineItem,
|
2260
|
+
actionsOverride: (_g = container === null || container === void 0 ? void 0 : container.actions) === null || _g === void 0 ? void 0 : _g.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
2261
|
+
selectorsOverride: (_h = container === null || container === void 0 ? void 0 : container.selectors) === null || _h === void 0 ? void 0 : _h.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
2262
|
+
});
|
2263
|
+
}
|
2264
|
+
else {
|
2265
|
+
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
2266
|
+
lineItemId,
|
2267
|
+
actionsOverride: (_j = container === null || container === void 0 ? void 0 : container.actions) === null || _j === void 0 ? void 0 : _j.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
2268
|
+
selectorsOverride: (_k = container === null || container === void 0 ? void 0 : container.selectors) === null || _k === void 0 ? void 0 : _k.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
2269
|
+
});
|
2270
|
+
}
|
2271
|
+
return request$.pipe(map$1(r => {
|
2272
|
+
this.stateId = r.stateId;
|
2273
|
+
return undefined;
|
2274
|
+
}));
|
1453
2275
|
}
|
1454
|
-
|
1455
|
-
|
1456
|
-
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
|
1457
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
|
1458
|
-
type: Injectable,
|
1459
|
-
args: [{ providedIn: 'root' }]
|
1460
|
-
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
1461
|
-
|
1462
|
-
class RuntimeSettingsService {
|
1463
|
-
constructor(configurationSettingsApiService) {
|
1464
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
1465
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
1466
|
-
this.currencySettings$ = new BehaviorSubject({
|
1467
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
1468
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
1469
|
-
});
|
1470
|
-
this.getCurrencySymbol = (locale, currency) => {
|
1471
|
-
return (0)
|
1472
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
1473
|
-
.replace(/\d/g, '')
|
1474
|
-
.trim();
|
1475
|
-
};
|
2276
|
+
initStateless$() {
|
2277
|
+
return this.configurationService.configure().pipe(map$1(() => undefined));
|
1476
2278
|
}
|
1477
|
-
|
1478
|
-
return
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
2279
|
+
executeStateless$(request) {
|
2280
|
+
return of(undefined).pipe(switchMap(() => {
|
2281
|
+
var _a;
|
2282
|
+
// Apply actions and execute configuration/price call
|
2283
|
+
// No need to run configuration if no actions in the request
|
2284
|
+
if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
2285
|
+
return of(undefined);
|
2286
|
+
}
|
2287
|
+
let configurationRequest = this.configurationService.generateRequest();
|
2288
|
+
request.actions.forEach(action => {
|
2289
|
+
var _a;
|
2290
|
+
try {
|
2291
|
+
configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
|
2292
|
+
}
|
2293
|
+
catch (e) {
|
2294
|
+
console.error(e);
|
2295
|
+
this.toastService.add({ severity: ToastType.error, summary: String(e) });
|
2296
|
+
throw e;
|
2297
|
+
}
|
2298
|
+
});
|
2299
|
+
return this.configurationService.configureRequest$(configurationRequest);
|
2300
|
+
}), map$1(() => {
|
2301
|
+
var _a;
|
2302
|
+
// Run selectors and apply them to the state
|
2303
|
+
const configurationState = cloneDeep(this.configurationService.stateSnapshot);
|
2304
|
+
if (!configurationState) {
|
2305
|
+
return { stateId: '', selectors: {} };
|
2306
|
+
}
|
2307
|
+
const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
2308
|
+
try {
|
2309
|
+
result.selectors[key] = {
|
2310
|
+
success: true,
|
2311
|
+
result: this.executeSelectorScript(configurationState, selector),
|
2312
|
+
};
|
2313
|
+
}
|
2314
|
+
catch (e) {
|
2315
|
+
console.error(e);
|
2316
|
+
result.selectors[key] = {
|
2317
|
+
success: false,
|
2318
|
+
errorMessage: String(e),
|
2319
|
+
};
|
2320
|
+
}
|
2321
|
+
return result;
|
2322
|
+
}, { stateId: '', selectors: {} });
|
2323
|
+
return selectorsResult;
|
2324
|
+
}));
|
1482
2325
|
}
|
1483
|
-
|
1484
|
-
if (
|
1485
|
-
|
1486
|
-
this.currencySettings$.next({ iso, symbol });
|
2326
|
+
executeStateful$(request) {
|
2327
|
+
if (!this.flowStateService.stateId || !this.stateId) {
|
2328
|
+
return of();
|
1487
2329
|
}
|
2330
|
+
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap$1(response => {
|
2331
|
+
this.stateId = response.stateId;
|
2332
|
+
}));
|
1488
2333
|
}
|
1489
|
-
|
2334
|
+
executeActionScript(request, processor) {
|
1490
2335
|
var _a, _b;
|
1491
|
-
|
1492
|
-
|
2336
|
+
const { actions } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
2337
|
+
const configurationProcessor = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.apiName);
|
2338
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
2339
|
+
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
1493
2340
|
}
|
1494
|
-
|
1495
|
-
return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
|
1496
|
-
}, {});
|
1497
|
-
const currencySettings = this.getCurrencySettings();
|
1498
|
-
const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
|
1499
|
-
DEFAULT_DATE_FORMAT;
|
1500
|
-
const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
|
1501
|
-
const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
|
1502
|
-
// the number of decimal places can be 0
|
1503
|
-
const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
|
1504
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
1505
|
-
? Number(priceScale)
|
1506
|
-
: DEFAULT_DECIMALS_COUNT;
|
1507
|
-
return {
|
1508
|
-
currencySymbol: currencySettings.symbol,
|
1509
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
1510
|
-
decimalsCount,
|
1511
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
1512
|
-
? decimalSeparator
|
1513
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
1514
|
-
// thousands separator can be a blank value, so it can also be null
|
1515
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
1516
|
-
? thousandsSeparator || ''
|
1517
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
1518
|
-
};
|
1519
|
-
}
|
1520
|
-
getConfigurationSettings() {
|
1521
|
-
return this.configurationSettings$.value;
|
1522
|
-
}
|
1523
|
-
getCurrencySettings() {
|
1524
|
-
return this.currencySettings$.value;
|
2341
|
+
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
1525
2342
|
}
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
}
|
2343
|
+
executeSelectorScript(request, processor) {
|
2344
|
+
var _a, _b;
|
2345
|
+
const { selectors } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
2346
|
+
const configurationProcessor = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.apiName);
|
2347
|
+
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
2348
|
+
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
2349
|
+
}
|
2350
|
+
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
2351
|
+
}
|
2352
|
+
executeProcessorScript(request, configurationProcessor, inputData) {
|
2353
|
+
let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
|
2354
|
+
if (!functionToExecute) {
|
2355
|
+
const script = `${configurationProcessor.script}\nreturn transform;`;
|
2356
|
+
const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
|
2357
|
+
functionToExecute = new Function(script + sourceMap)();
|
2358
|
+
this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
|
2359
|
+
}
|
2360
|
+
return functionToExecute({
|
2361
|
+
request,
|
2362
|
+
inputData,
|
2363
|
+
flowStore: this.flowStateService.getFlowStore(),
|
2364
|
+
configurationStore: this.configurationStore,
|
2365
|
+
});
|
1543
2366
|
}
|
1544
2367
|
}
|
1545
|
-
|
1546
|
-
|
1547
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type:
|
1548
|
-
type: Injectable
|
1549
|
-
|
1550
|
-
|
2368
|
+
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
2369
|
+
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
2370
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
2371
|
+
type: Injectable
|
2372
|
+
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: QuoteDraftService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }]; } });
|
2373
|
+
|
2374
|
+
class ConfigurationModule {
|
2375
|
+
}
|
2376
|
+
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
2377
|
+
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
|
2378
|
+
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService], imports: [ConfirmationDialogModule, ApiModule] });
|
2379
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
2380
|
+
type: NgModule,
|
2381
|
+
args: [{
|
2382
|
+
imports: [ConfirmationDialogModule, ApiModule],
|
2383
|
+
providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService],
|
2384
|
+
}]
|
2385
|
+
}] });
|
1551
2386
|
|
1552
2387
|
const DEFAULT_FORMATTING_SETTINGS = {
|
1553
2388
|
currencySymbol: DEFAULT_CURRENCY_SYMBOL,
|
@@ -1555,6 +2390,7 @@ const DEFAULT_FORMATTING_SETTINGS = {
|
|
1555
2390
|
dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
|
1556
2391
|
decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
|
1557
2392
|
thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
|
2393
|
+
actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
|
1558
2394
|
};
|
1559
2395
|
class SdkCoreModule {
|
1560
2396
|
}
|
@@ -1562,9 +2398,12 @@ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1562
2398
|
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1563
2399
|
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
|
1564
2400
|
ContextService,
|
2401
|
+
FlowInfoService,
|
1565
2402
|
QuoteDraftService,
|
1566
2403
|
ProductImagesService,
|
1567
|
-
|
2404
|
+
IntegrationState,
|
2405
|
+
FlowStateService,
|
2406
|
+
FlowStateConfigurationService,
|
1568
2407
|
RuntimeSettingsService,
|
1569
2408
|
{
|
1570
2409
|
provide: FORMATTING_SETTINGS_TOKEN,
|
@@ -1577,9 +2416,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1577
2416
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
1578
2417
|
providers: [
|
1579
2418
|
ContextService,
|
2419
|
+
FlowInfoService,
|
1580
2420
|
QuoteDraftService,
|
1581
2421
|
ProductImagesService,
|
1582
|
-
|
2422
|
+
IntegrationState,
|
2423
|
+
FlowStateService,
|
2424
|
+
FlowStateConfigurationService,
|
1583
2425
|
RuntimeSettingsService,
|
1584
2426
|
{
|
1585
2427
|
provide: FORMATTING_SETTINGS_TOKEN,
|
@@ -1650,13 +2492,19 @@ class DatePipe {
|
|
1650
2492
|
this.destroy$.next();
|
1651
2493
|
this.destroy$.complete();
|
1652
2494
|
}
|
1653
|
-
transform(date) {
|
2495
|
+
transform(date, type = 'date') {
|
1654
2496
|
var _a, _b;
|
1655
2497
|
if (!date) {
|
1656
2498
|
return '';
|
1657
2499
|
}
|
2500
|
+
const dateFormat = ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT;
|
2501
|
+
const formatMap = {
|
2502
|
+
date: dateFormat,
|
2503
|
+
time: DEFAULT_TIME_FORMAT,
|
2504
|
+
datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
|
2505
|
+
};
|
1658
2506
|
try {
|
1659
|
-
return formatDate(date,
|
2507
|
+
return formatDate(date, formatMap[type], this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
|
1660
2508
|
}
|
1661
2509
|
catch (error) {
|
1662
2510
|
return new Date(date).toString();
|
@@ -1723,16 +2571,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1723
2571
|
}]
|
1724
2572
|
}] });
|
1725
2573
|
|
2574
|
+
class ActionCodePipe {
|
2575
|
+
constructor() {
|
2576
|
+
var _a;
|
2577
|
+
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
2578
|
+
}
|
2579
|
+
transform(actionCode) {
|
2580
|
+
var _a, _b;
|
2581
|
+
return (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.actionCodeLabels[actionCode]) !== null && _b !== void 0 ? _b : actionCode;
|
2582
|
+
}
|
2583
|
+
}
|
2584
|
+
ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
2585
|
+
ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
|
2586
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
|
2587
|
+
type: Pipe,
|
2588
|
+
args: [{
|
2589
|
+
name: 'vlActionCode',
|
2590
|
+
}]
|
2591
|
+
}] });
|
2592
|
+
|
1726
2593
|
class SdkPipesModule {
|
1727
2594
|
}
|
1728
2595
|
SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1729
|
-
SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
|
2596
|
+
SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe], exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe] });
|
1730
2597
|
SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
|
1731
2598
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
|
1732
2599
|
type: NgModule,
|
1733
2600
|
args: [{
|
1734
|
-
declarations: [NumberPipe, PricePipe, DatePipe],
|
1735
|
-
exports: [NumberPipe, PricePipe, DatePipe],
|
2601
|
+
declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
|
2602
|
+
exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
|
1736
2603
|
}]
|
1737
2604
|
}] });
|
1738
2605
|
|
@@ -1740,5 +2607,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1740
2607
|
* Generated bundle index. Do not edit.
|
1741
2608
|
*/
|
1742
2609
|
|
1743
|
-
export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService,
|
2610
|
+
export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
1744
2611
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|