@veloceapps/sdk 12.0.0-13 → 12.0.0-15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cms/index.d.ts +921 -15
- package/core/index.d.ts +525 -8
- package/fesm2022/veloceapps-sdk-cms.mjs +2617 -0
- package/fesm2022/veloceapps-sdk-cms.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/veloceapps-sdk-core.mjs +117 -112
- package/fesm2022/veloceapps-sdk-core.mjs.map +1 -0
- package/{fesm2020 → fesm2022}/veloceapps-sdk.mjs +170 -170
- package/fesm2022/veloceapps-sdk.mjs.map +1 -0
- package/index.d.ts +330 -1
- package/package.json +17 -34
- package/cms/cms.actions.d.ts +0 -154
- package/cms/cms.default.d.ts +0 -5
- package/cms/cms.elements.d.ts +0 -4
- package/cms/cms.layouts.d.ts +0 -4
- package/cms/components/element-children/element-children.component.d.ts +0 -22
- package/cms/components/element-children/element-children.module.d.ts +0 -11
- package/cms/components/element-drop-handle/element-drop-handle.component.d.ts +0 -12
- package/cms/components/element-drop-handle/element-drop-handle.module.d.ts +0 -9
- package/cms/components/element-renderer/element-renderer.component.d.ts +0 -29
- package/cms/components/element-renderer/element-renderer.module.d.ts +0 -7
- package/cms/components/element-tools-panel/element-tools-panel.component.d.ts +0 -14
- package/cms/components/element.component.d.ts +0 -17
- package/cms/components/index.d.ts +0 -1
- package/cms/components/plugin.component.d.ts +0 -15
- package/cms/components/preview/index.d.ts +0 -3
- package/cms/components/preview/preview.component.d.ts +0 -32
- package/cms/components/preview/preview.module.d.ts +0 -13
- package/cms/components/preview/preview.types.d.ts +0 -20
- package/cms/decorators/element.decorator.d.ts +0 -2
- package/cms/decorators/index.d.ts +0 -1
- package/cms/definitions/index.d.ts +0 -1
- package/cms/definitions/ui-builder.definitions.d.ts +0 -6
- package/cms/directives/custom-template.directive.d.ts +0 -17
- package/cms/engine/models/entity.d.ts +0 -11
- package/cms/engine/models/plugin.d.ts +0 -5
- package/cms/injection-tokens.d.ts +0 -9
- package/cms/launcher.module.d.ts +0 -12
- package/cms/modules/federated/default-options.d.ts +0 -4
- package/cms/modules/federated/export.d.ts +0 -1
- package/cms/modules/federated/federated-host.directive.d.ts +0 -8
- package/cms/modules/federated/federated.component.d.ts +0 -25
- package/cms/modules/federated/federated.module.d.ts +0 -10
- package/cms/modules/federated/federated.types.d.ts +0 -26
- package/cms/modules/migrations/index.d.ts +0 -2
- package/cms/modules/migrations/migrations.d.ts +0 -2
- package/cms/modules/migrations/migrations.module.d.ts +0 -6
- package/cms/modules/migrations/services/migrations.service.d.ts +0 -10
- package/cms/modules/migrations/types/migrations.types.d.ts +0 -2
- package/cms/modules/runtime/index.d.ts +0 -3
- package/cms/modules/runtime/runtime.module.d.ts +0 -8
- package/cms/modules/runtime/services/compilation.service.d.ts +0 -19
- package/cms/modules/runtime/services/runtime-editor.service.d.ts +0 -20
- package/cms/modules/runtime/services/runtime.service.d.ts +0 -33
- package/cms/modules/runtime/tokens.d.ts +0 -3
- package/cms/modules/runtime/types/compilation.types.d.ts +0 -8
- package/cms/modules/runtime/types/runtime.actions.d.ts +0 -12
- package/cms/plugins/element-hover.plugin.d.ts +0 -33
- package/cms/plugins/io.plugin.d.ts +0 -9
- package/cms/plugins/page.plugin.d.ts +0 -15
- package/cms/plugins/region.plugin.d.ts +0 -17
- package/cms/plugins/script.plugin.d.ts +0 -10
- package/cms/services/element-context.service.d.ts +0 -7
- package/cms/services/index.d.ts +0 -2
- package/cms/services/io-provider.service.d.ts +0 -15
- package/cms/services/resources.service.d.ts +0 -21
- package/cms/services/templates.service.d.ts +0 -14
- package/cms/types/common.types.d.ts +0 -130
- package/cms/types/elements.types.d.ts +0 -2
- package/cms/types/index.d.ts +0 -6
- package/cms/types/layouts.types.d.ts +0 -102
- package/cms/types/pages.types.d.ts +0 -1
- package/cms/types/path.types.d.ts +0 -11
- package/cms/utils/element-metadata-worker.d.ts +0 -11
- package/cms/utils/element.utils.d.ts +0 -20
- package/cms/utils/elements-resolver.d.ts +0 -28
- package/cms/utils/encoding.utils.d.ts +0 -2
- package/cms/utils/index.d.ts +0 -9
- package/cms/utils/inject.d.ts +0 -1
- package/cms/utils/path.utils.d.ts +0 -3
- package/cms/utils/script.utils.d.ts +0 -2
- package/cms/utils/transpilation-worker.d.ts +0 -13
- package/cms/utils/ui-builder-layout.utils.d.ts +0 -4
- package/cms/utils/ui-definition.utils.d.ts +0 -6
- package/cms/vendor-map.d.ts +0 -86
- package/core/core.module.d.ts +0 -10
- package/core/directives/directives.module.d.ts +0 -7
- package/core/directives/index.d.ts +0 -2
- package/core/directives/primeng-calendar.directive.d.ts +0 -14
- package/core/modules/configuration/configuration.module.d.ts +0 -8
- package/core/modules/configuration/index.d.ts +0 -6
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +0 -19
- package/core/modules/configuration/services/configuration-state.service.d.ts +0 -60
- package/core/modules/configuration/services/configuration.service.d.ts +0 -38
- package/core/modules/configuration/services/guided-selling.service.d.ts +0 -15
- package/core/modules/configuration/services/test-mode-configuration.service.d.ts +0 -26
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -3
- package/core/modules/configuration/types/configuration.types.d.ts +0 -20
- package/core/modules/configuration/types/index.d.ts +0 -2
- package/core/modules/flow-configuration/flow-configuration.module.d.ts +0 -7
- package/core/modules/flow-configuration/index.d.ts +0 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +0 -23
- package/core/modules/index.d.ts +0 -2
- package/core/operators/filter-successful-execute.operator.d.ts +0 -3
- package/core/operators/index.d.ts +0 -1
- package/core/pipes/action-code.pipe.d.ts +0 -8
- package/core/pipes/date.pipe.d.ts +0 -13
- package/core/pipes/index.d.ts +0 -5
- package/core/pipes/number.pipe.d.ts +0 -10
- package/core/pipes/pipes.module.d.ts +0 -10
- package/core/pipes/price.pipe.d.ts +0 -10
- package/core/services/catalog-products.service.d.ts +0 -11
- package/core/services/flow-info.service.d.ts +0 -44
- package/core/services/flow-state-configuration.service.d.ts +0 -25
- package/core/services/flow-state.service.d.ts +0 -70
- package/core/services/index.d.ts +0 -8
- package/core/services/integration.state.d.ts +0 -16
- package/core/services/product-images.service.d.ts +0 -12
- package/core/services/runtime-settings.service.d.ts +0 -24
- package/core/services/sales-transaction.service.d.ts +0 -27
- package/core/types/flow-customization.types.d.ts +0 -10
- package/core/types/flow-state.types.d.ts +0 -12
- package/core/types/formatting-settings.types.d.ts +0 -13
- package/core/types/index.d.ts +0 -5
- package/core/types/integration.types.d.ts +0 -10
- package/core/types/pipe.types.d.ts +0 -1
- package/core/types/ui-definition.types.d.ts +0 -1
- package/core/utils/index.d.ts +0 -4
- package/core/utils/pcm.utils.d.ts +0 -5
- package/core/utils/transaction-item.utils.d.ts +0 -10
- package/core/utils/transaction-item.worker.d.ts +0 -8
- package/core/utils/ui-definition.utils.d.ts +0 -2
- package/esm2020/cms/cms.actions.mjs +0 -151
- package/esm2020/cms/cms.default.mjs +0 -5
- package/esm2020/cms/cms.elements.mjs +0 -52
- package/esm2020/cms/cms.layouts.mjs +0 -239
- package/esm2020/cms/components/element-children/element-children.component.mjs +0 -41
- package/esm2020/cms/components/element-children/element-children.module.mjs +0 -21
- package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +0 -28
- package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +0 -19
- package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +0 -117
- package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +0 -16
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +0 -35
- package/esm2020/cms/components/element.component.mjs +0 -45
- package/esm2020/cms/components/index.mjs +0 -2
- package/esm2020/cms/components/plugin.component.mjs +0 -17
- package/esm2020/cms/components/preview/index.mjs +0 -4
- package/esm2020/cms/components/preview/preview.component.mjs +0 -75
- package/esm2020/cms/components/preview/preview.module.mjs +0 -42
- package/esm2020/cms/components/preview/preview.types.mjs +0 -2
- package/esm2020/cms/decorators/element.decorator.mjs +0 -6
- package/esm2020/cms/decorators/index.mjs +0 -2
- package/esm2020/cms/definitions/index.mjs +0 -2
- package/esm2020/cms/definitions/ui-builder.definitions.mjs +0 -18
- package/esm2020/cms/directives/custom-template.directive.mjs +0 -38
- package/esm2020/cms/engine/models/entity.mjs +0 -17
- package/esm2020/cms/engine/models/plugin.mjs +0 -6
- package/esm2020/cms/index.mjs +0 -16
- package/esm2020/cms/injection-tokens.mjs +0 -7
- package/esm2020/cms/launcher.module.mjs +0 -24
- package/esm2020/cms/modules/federated/default-options.mjs +0 -5
- package/esm2020/cms/modules/federated/export.mjs +0 -2
- package/esm2020/cms/modules/federated/federated-host.directive.mjs +0 -16
- package/esm2020/cms/modules/federated/federated.component.mjs +0 -74
- package/esm2020/cms/modules/federated/federated.module.mjs +0 -20
- package/esm2020/cms/modules/federated/federated.types.mjs +0 -2
- package/esm2020/cms/modules/migrations/index.mjs +0 -3
- package/esm2020/cms/modules/migrations/migrations.mjs +0 -22
- package/esm2020/cms/modules/migrations/migrations.module.mjs +0 -15
- package/esm2020/cms/modules/migrations/services/migrations.service.mjs +0 -47
- package/esm2020/cms/modules/migrations/types/migrations.types.mjs +0 -2
- package/esm2020/cms/modules/runtime/index.mjs +0 -4
- package/esm2020/cms/modules/runtime/runtime.module.mjs +0 -32
- package/esm2020/cms/modules/runtime/services/compilation.service.mjs +0 -93
- package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +0 -30
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +0 -117
- package/esm2020/cms/modules/runtime/tokens.mjs +0 -3
- package/esm2020/cms/modules/runtime/types/compilation.types.mjs +0 -2
- package/esm2020/cms/modules/runtime/types/runtime.actions.mjs +0 -2
- package/esm2020/cms/plugins/element-hover.plugin.mjs +0 -121
- package/esm2020/cms/plugins/io.plugin.mjs +0 -45
- package/esm2020/cms/plugins/page.plugin.mjs +0 -37
- package/esm2020/cms/plugins/region.plugin.mjs +0 -59
- package/esm2020/cms/plugins/script.plugin.mjs +0 -31
- package/esm2020/cms/services/element-context.service.mjs +0 -10
- package/esm2020/cms/services/index.mjs +0 -3
- package/esm2020/cms/services/io-provider.service.mjs +0 -53
- package/esm2020/cms/services/resources.service.mjs +0 -71
- package/esm2020/cms/services/templates.service.mjs +0 -32
- package/esm2020/cms/types/common.types.mjs +0 -2
- package/esm2020/cms/types/elements.types.mjs +0 -2
- package/esm2020/cms/types/index.mjs +0 -7
- package/esm2020/cms/types/layouts.types.mjs +0 -71
- package/esm2020/cms/types/pages.types.mjs +0 -2
- package/esm2020/cms/types/path.types.mjs +0 -2
- package/esm2020/cms/utils/element-metadata-worker.mjs +0 -31
- package/esm2020/cms/utils/element.utils.mjs +0 -182
- package/esm2020/cms/utils/elements-resolver.mjs +0 -206
- package/esm2020/cms/utils/encoding.utils.mjs +0 -29
- package/esm2020/cms/utils/index.mjs +0 -10
- package/esm2020/cms/utils/inject.mjs +0 -27
- package/esm2020/cms/utils/path.utils.mjs +0 -44
- package/esm2020/cms/utils/script.utils.mjs +0 -46
- package/esm2020/cms/utils/transpilation-worker.mjs +0 -52
- package/esm2020/cms/utils/ui-builder-layout.utils.mjs +0 -46
- package/esm2020/cms/utils/ui-definition.utils.mjs +0 -85
- package/esm2020/cms/veloceapps-sdk-cms.mjs +0 -5
- package/esm2020/cms/vendor-map.mjs +0 -83
- package/esm2020/core/core.module.mjs +0 -54
- package/esm2020/core/directives/directives.module.mjs +0 -16
- package/esm2020/core/directives/index.mjs +0 -3
- package/esm2020/core/directives/primeng-calendar.directive.mjs +0 -41
- package/esm2020/core/index.mjs +0 -9
- package/esm2020/core/modules/configuration/configuration.module.mjs +0 -34
- package/esm2020/core/modules/configuration/index.mjs +0 -7
- package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +0 -38
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +0 -381
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +0 -172
- package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +0 -62
- package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +0 -97
- package/esm2020/core/modules/configuration/types/configuration-runtime.types.mjs +0 -2
- package/esm2020/core/modules/configuration/types/configuration.types.mjs +0 -2
- package/esm2020/core/modules/configuration/types/index.mjs +0 -3
- package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +0 -17
- package/esm2020/core/modules/flow-configuration/index.mjs +0 -2
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +0 -80
- package/esm2020/core/modules/index.mjs +0 -3
- package/esm2020/core/operators/filter-successful-execute.operator.mjs +0 -5
- package/esm2020/core/operators/index.mjs +0 -2
- package/esm2020/core/pipes/action-code.pipe.mjs +0 -20
- package/esm2020/core/pipes/date.pipe.mjs +0 -44
- package/esm2020/core/pipes/index.mjs +0 -6
- package/esm2020/core/pipes/number.pipe.mjs +0 -27
- package/esm2020/core/pipes/pipes.module.mjs +0 -19
- package/esm2020/core/pipes/price.pipe.mjs +0 -30
- package/esm2020/core/services/catalog-products.service.mjs +0 -25
- package/esm2020/core/services/flow-info.service.mjs +0 -146
- package/esm2020/core/services/flow-state-configuration.service.mjs +0 -120
- package/esm2020/core/services/flow-state.service.mjs +0 -417
- package/esm2020/core/services/index.mjs +0 -9
- package/esm2020/core/services/integration.state.mjs +0 -36
- package/esm2020/core/services/product-images.service.mjs +0 -30
- package/esm2020/core/services/runtime-settings.service.mjs +0 -112
- package/esm2020/core/services/sales-transaction.service.mjs +0 -67
- package/esm2020/core/types/flow-customization.types.mjs +0 -3
- package/esm2020/core/types/flow-state.types.mjs +0 -2
- package/esm2020/core/types/formatting-settings.types.mjs +0 -3
- package/esm2020/core/types/index.mjs +0 -6
- package/esm2020/core/types/integration.types.mjs +0 -2
- package/esm2020/core/types/pipe.types.mjs +0 -2
- package/esm2020/core/types/ui-definition.types.mjs +0 -2
- package/esm2020/core/utils/index.mjs +0 -5
- package/esm2020/core/utils/pcm.utils.mjs +0 -15
- package/esm2020/core/utils/transaction-item.utils.mjs +0 -144
- package/esm2020/core/utils/transaction-item.worker.mjs +0 -16
- package/esm2020/core/utils/ui-definition.utils.mjs +0 -9
- package/esm2020/core/veloceapps-sdk-core.mjs +0 -5
- package/esm2020/index.mjs +0 -2
- package/esm2020/src/components/dialog/dialog.component.mjs +0 -36
- package/esm2020/src/components/dialog/dialog.module.mjs +0 -19
- package/esm2020/src/components/dialog/dialog.types.mjs +0 -2
- package/esm2020/src/components/flow-header/flow-header.component.mjs +0 -107
- package/esm2020/src/components/flow-header/flow-header.module.mjs +0 -19
- package/esm2020/src/components/flow-header/index.mjs +0 -2
- package/esm2020/src/components/guided-selling/guided-selling.component.mjs +0 -107
- package/esm2020/src/components/guided-selling/guided-selling.module.mjs +0 -19
- package/esm2020/src/configure-primeng.mjs +0 -33
- package/esm2020/src/constants.mjs +0 -2
- package/esm2020/src/flow-routing.module.mjs +0 -97
- package/esm2020/src/flow.component.mjs +0 -39
- package/esm2020/src/flow.module.mjs +0 -60
- package/esm2020/src/guards/flow.guard.mjs +0 -35
- package/esm2020/src/guards/product-unload.guard.mjs +0 -49
- package/esm2020/src/guards/root.guard.mjs +0 -46
- package/esm2020/src/index.mjs +0 -5
- package/esm2020/src/pages/assets/assets.component.mjs +0 -106
- package/esm2020/src/pages/assets/assets.module.mjs +0 -20
- package/esm2020/src/pages/catalog/catalog.component.mjs +0 -106
- package/esm2020/src/pages/catalog/catalog.module.mjs +0 -20
- package/esm2020/src/pages/debug/debug.component.mjs +0 -49
- package/esm2020/src/pages/debug/debug.module.mjs +0 -46
- package/esm2020/src/pages/product/product.component.mjs +0 -55
- package/esm2020/src/pages/product/product.module.mjs +0 -20
- package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +0 -27
- package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +0 -20
- package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +0 -106
- package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +0 -20
- package/esm2020/src/resolvers/flow.resolver.mjs +0 -50
- package/esm2020/src/resolvers/pcm-model.resolver.mjs +0 -12
- package/esm2020/src/resolvers/sales-transaction.resolver.mjs +0 -64
- package/esm2020/src/resolvers/ui-definition.resolver.mjs +0 -44
- package/esm2020/src/services/flow-dialog.service.mjs +0 -91
- package/esm2020/src/services/flow-router.service.mjs +0 -173
- package/esm2020/src/services/flow.service.mjs +0 -102
- package/esm2020/src/services/guided-selling.service.mjs +0 -34
- package/esm2020/src/services/index.mjs +0 -4
- package/esm2020/src/types/index.mjs +0 -2
- package/esm2020/src/types/route.types.mjs +0 -2
- package/esm2020/veloceapps-sdk.mjs +0 -5
- package/fesm2015/veloceapps-sdk-cms.mjs +0 -2514
- package/fesm2015/veloceapps-sdk-cms.mjs.map +0 -1
- package/fesm2015/veloceapps-sdk-core.mjs +0 -2104
- package/fesm2015/veloceapps-sdk-core.mjs.map +0 -1
- package/fesm2015/veloceapps-sdk.mjs +0 -1598
- package/fesm2015/veloceapps-sdk.mjs.map +0 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +0 -2613
- package/fesm2020/veloceapps-sdk-cms.mjs.map +0 -1
- package/fesm2020/veloceapps-sdk-core.mjs.map +0 -1
- package/fesm2020/veloceapps-sdk.mjs.map +0 -1
- package/src/components/dialog/dialog.component.d.ts +0 -13
- package/src/components/dialog/dialog.module.d.ts +0 -9
- package/src/components/dialog/dialog.types.d.ts +0 -7
- package/src/components/flow-header/flow-header.component.d.ts +0 -25
- package/src/components/flow-header/flow-header.module.d.ts +0 -9
- package/src/components/flow-header/index.d.ts +0 -1
- package/src/components/guided-selling/guided-selling.component.d.ts +0 -25
- package/src/components/guided-selling/guided-selling.module.d.ts +0 -9
- package/src/configure-primeng.d.ts +0 -1
- package/src/constants.d.ts +0 -1
- package/src/flow-routing.module.d.ts +0 -11
- package/src/flow.component.d.ts +0 -21
- package/src/flow.module.d.ts +0 -16
- package/src/guards/flow.guard.d.ts +0 -2
- package/src/guards/product-unload.guard.d.ts +0 -16
- package/src/guards/root.guard.d.ts +0 -14
- package/src/index.d.ts +0 -4
- package/src/pages/assets/assets.component.d.ts +0 -31
- package/src/pages/assets/assets.module.d.ts +0 -10
- package/src/pages/catalog/catalog.component.d.ts +0 -31
- package/src/pages/catalog/catalog.module.d.ts +0 -10
- package/src/pages/debug/debug.component.d.ts +0 -21
- package/src/pages/debug/debug.module.d.ts +0 -14
- package/src/pages/product/product.component.d.ts +0 -24
- package/src/pages/product/product.module.d.ts +0 -10
- package/src/pages/record-not-found/record-not-found.component.d.ts +0 -12
- package/src/pages/record-not-found/record-not-found.module.d.ts +0 -9
- package/src/pages/shopping-cart/shopping-cart.component.d.ts +0 -31
- package/src/pages/shopping-cart/shopping-cart.module.d.ts +0 -10
- package/src/resolvers/flow.resolver.d.ts +0 -14
- package/src/resolvers/pcm-model.resolver.d.ts +0 -3
- package/src/resolvers/sales-transaction.resolver.d.ts +0 -18
- package/src/resolvers/ui-definition.resolver.d.ts +0 -3
- package/src/services/flow-dialog.service.d.ts +0 -23
- package/src/services/flow-router.service.d.ts +0 -42
- package/src/services/flow.service.d.ts +0 -21
- package/src/services/guided-selling.service.d.ts +0 -13
- package/src/services/index.d.ts +0 -3
- package/src/types/index.d.ts +0 -1
- package/src/types/route.types.d.ts +0 -4
@@ -1,2104 +0,0 @@
|
|
1
|
-
import * as i0 from '@angular/core';
|
2
|
-
import { Injectable, InjectionToken, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
3
|
-
import { isDefined, UUID, 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, UITemplateType, SalesforceIdUtils, ConfigurationProcessorTypes, EntityUtil, extractErrorDetails, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
|
4
|
-
import * as i3 from '@veloceapps/api';
|
5
|
-
import { ApiModule } from '@veloceapps/api';
|
6
|
-
import * as i6 from '@veloceapps/components';
|
7
|
-
import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
|
8
|
-
import { BehaviorSubject, tap, map, filter, switchMap, of, forkJoin, throwError, noop, Subject, catchError, combineLatest, finalize, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
|
9
|
-
import * as i1 from '@veloceapps/api/v2';
|
10
|
-
import { flatten, omit, uniqBy, cloneDeep, assign, isEqual } from 'lodash';
|
11
|
-
import { filter as filter$1, map as map$1, tap as tap$1, catchError as catchError$1, finalize as finalize$1 } from 'rxjs/operators';
|
12
|
-
import * as i2 from 'primeng/api';
|
13
|
-
import { NgControl } from '@angular/forms';
|
14
|
-
import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
|
15
|
-
|
16
|
-
class ConfigurationRuntimeService {
|
17
|
-
constructor(pcmApiService) {
|
18
|
-
this.pcmApiService = pcmApiService;
|
19
|
-
this.uiDefinitionContainer = null;
|
20
|
-
this.pcmModelSubj$ = new BehaviorSubject(null);
|
21
|
-
}
|
22
|
-
get uiDefinitionProps() {
|
23
|
-
var _a, _b;
|
24
|
-
return (_b = (_a = this.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
|
25
|
-
}
|
26
|
-
get pcmModel() {
|
27
|
-
return this.pcmModelSubj$.value;
|
28
|
-
}
|
29
|
-
get pcmModel$() {
|
30
|
-
return this.pcmModelSubj$;
|
31
|
-
}
|
32
|
-
reset() {
|
33
|
-
this.uiDefinitionContainer = null;
|
34
|
-
this.initializationProps = undefined;
|
35
|
-
this.pcmModelSubj$.next(null);
|
36
|
-
}
|
37
|
-
init$(props) {
|
38
|
-
this.initializationProps = props;
|
39
|
-
return this.pcmApiService
|
40
|
-
.fetchPCMByProductId(props.productId)
|
41
|
-
.pipe(tap(pcmModel => this.pcmModelSubj$.next(pcmModel)));
|
42
|
-
}
|
43
|
-
}
|
44
|
-
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
45
|
-
ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
|
46
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
|
47
|
-
type: Injectable
|
48
|
-
}], ctorParameters: function () { return [{ type: i1.PCMApiService }]; } });
|
49
|
-
|
50
|
-
class PCMUtils {
|
51
|
-
static mapByPrcId(pcm) {
|
52
|
-
const map = {};
|
53
|
-
if (pcm.productRelatedComponent) {
|
54
|
-
map[pcm.productRelatedComponent.id] = pcm;
|
55
|
-
}
|
56
|
-
for (const group of pcm.productComponentGroups) {
|
57
|
-
for (const gc of group.components) {
|
58
|
-
Object.assign(map, PCMUtils.mapByPrcId(gc));
|
59
|
-
}
|
60
|
-
}
|
61
|
-
return map;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
const findTransactionItem = (id, items) => {
|
66
|
-
return findTransactionItemWithComparator(items, (ti) => ti.id === id);
|
67
|
-
};
|
68
|
-
const findTransactionItemWithComparator = (items, comparator) => {
|
69
|
-
let currentLevel = items;
|
70
|
-
while (currentLevel.length) {
|
71
|
-
const found = currentLevel.find(comparator);
|
72
|
-
if (found) {
|
73
|
-
return found;
|
74
|
-
}
|
75
|
-
currentLevel = flatten(currentLevel.map(parent => parent.children));
|
76
|
-
}
|
77
|
-
return;
|
78
|
-
};
|
79
|
-
const insertTransactionItem = (item, parentId, toInsert) => {
|
80
|
-
const insertData = item.id === parentId ? [toInsert] : [];
|
81
|
-
return Object.assign(Object.assign({}, item), { children: [
|
82
|
-
...insertData,
|
83
|
-
...item.children.map(ti => {
|
84
|
-
return insertTransactionItem(ti, parentId, toInsert);
|
85
|
-
}),
|
86
|
-
] });
|
87
|
-
};
|
88
|
-
const removeTransactionItem = (item, idToRemove) => {
|
89
|
-
return Object.assign(Object.assign({}, item), { children: item.children
|
90
|
-
.map(ti => {
|
91
|
-
if (ti.id === idToRemove) {
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
else if (ti.children.length) {
|
95
|
-
return removeTransactionItem(ti, idToRemove);
|
96
|
-
}
|
97
|
-
return ti;
|
98
|
-
})
|
99
|
-
.filter(isDefined) });
|
100
|
-
};
|
101
|
-
const replaceTransactionItem = (item, replaceTo) => {
|
102
|
-
if (item.id === replaceTo.id) {
|
103
|
-
return Object.assign({}, replaceTo);
|
104
|
-
}
|
105
|
-
return Object.assign(Object.assign({}, item), { children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)) });
|
106
|
-
};
|
107
|
-
const generateTransactionItem = (option, salesTransactionId, qty, parentTi) => {
|
108
|
-
const newItem = generateTransactionItemFromPCM(option, salesTransactionId, parentTi);
|
109
|
-
// propagate Proportional quantities to children
|
110
|
-
const updatedNewItem = updateQuantity(newItem, qty !== null && qty !== void 0 ? qty : newItem.qty, option, parentTi === null || parentTi === void 0 ? void 0 : parentTi.qty);
|
111
|
-
return updatedNewItem;
|
112
|
-
};
|
113
|
-
const generateTransactionItemFromPCM = (option, salesTransactionId, parentTi) => {
|
114
|
-
var _a, _b, _c, _d, _e;
|
115
|
-
const childId = UUID.UUID();
|
116
|
-
const newItem = {
|
117
|
-
id: childId,
|
118
|
-
productId: option.id,
|
119
|
-
productName: option.name,
|
120
|
-
productCode: option.productCode,
|
121
|
-
productRelatedComponentId: (_a = option.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.id,
|
122
|
-
constraintEngineNodeStatus: {
|
123
|
-
attributes: [],
|
124
|
-
cfgStatus: 'User',
|
125
|
-
},
|
126
|
-
stiAttributes: [],
|
127
|
-
attributes: {
|
128
|
-
ParentReference: salesTransactionId,
|
129
|
-
ItemPath: option.id,
|
130
|
-
SalesTransactionItemSource: childId,
|
131
|
-
SalesTransactionItemParent: salesTransactionId,
|
132
|
-
ProductSellingModel: (_c = (_b = option.productSellingModelOptions) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.productSellingModel.id,
|
133
|
-
},
|
134
|
-
qty: (_e = (_d = option.productRelatedComponent) === null || _d === void 0 ? void 0 : _d.quantity) !== null && _e !== void 0 ? _e : 1,
|
135
|
-
};
|
136
|
-
if (parentTi) {
|
137
|
-
newItem.parentId = parentTi.id;
|
138
|
-
}
|
139
|
-
newItem.children = option.productComponentGroups.reduce((acc, group) => {
|
140
|
-
group.components.forEach(component => {
|
141
|
-
var _a, _b;
|
142
|
-
if (((_a = component.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.isComponentRequired) ||
|
143
|
-
((_b = component.productRelatedComponent) === null || _b === void 0 ? void 0 : _b.isDefaultComponent)) {
|
144
|
-
acc.push(generateTransactionItemFromPCM(component, salesTransactionId, newItem));
|
145
|
-
}
|
146
|
-
});
|
147
|
-
return acc;
|
148
|
-
}, []);
|
149
|
-
return newItem;
|
150
|
-
};
|
151
|
-
const flattenTransactionItem = (ti) => {
|
152
|
-
const result = [];
|
153
|
-
const traverse = (item) => {
|
154
|
-
if (!item)
|
155
|
-
return;
|
156
|
-
result.push(item);
|
157
|
-
if (Array.isArray(item.children) && item.children.length) {
|
158
|
-
for (const child of item.children) {
|
159
|
-
traverse(child);
|
160
|
-
}
|
161
|
-
}
|
162
|
-
};
|
163
|
-
traverse(ti);
|
164
|
-
return result;
|
165
|
-
};
|
166
|
-
const updateQuantity = (ti, qty, pcm, parentQty = 1) => {
|
167
|
-
const pcmMap = PCMUtils.mapByPrcId(pcm);
|
168
|
-
const calcNewQty = (item, parentPrevQty, parentNewQty, parentPcm, inputQty, isDirectChange) => {
|
169
|
-
var _a;
|
170
|
-
const scaleMethod = (_a = parentPcm === null || parentPcm === void 0 ? void 0 : parentPcm.productRelatedComponent) === null || _a === void 0 ? void 0 : _a.quantityScaleMethod;
|
171
|
-
if (isDirectChange) {
|
172
|
-
return scaleMethod === 'Proportional' ? parentPrevQty * inputQty : inputQty;
|
173
|
-
}
|
174
|
-
else {
|
175
|
-
return scaleMethod === 'Proportional' ? (item.qty / parentPrevQty) * parentNewQty : item.qty;
|
176
|
-
}
|
177
|
-
};
|
178
|
-
const updateItem = (item, parentPrevQty, parentNewQty, isDirectChange) => {
|
179
|
-
const pcm = pcmMap[item.productRelatedComponentId];
|
180
|
-
let nextQty = item.qty;
|
181
|
-
if (item.id === ti.id || isDirectChange) {
|
182
|
-
nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, true);
|
183
|
-
}
|
184
|
-
else if (parentPrevQty !== parentNewQty) {
|
185
|
-
nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, false);
|
186
|
-
}
|
187
|
-
const sti = Object.assign(Object.assign({}, item), { qty: nextQty, children: item.children.map(child => updateItem(child, item.qty, nextQty, false)) });
|
188
|
-
if (nextQty !== item.qty) {
|
189
|
-
sti.constraintEngineNodeStatus = Object.assign(Object.assign({}, sti.constraintEngineNodeStatus), { cfgStatus: 'User' });
|
190
|
-
}
|
191
|
-
return sti;
|
192
|
-
};
|
193
|
-
return updateItem(ti, parentQty, parentQty, false);
|
194
|
-
};
|
195
|
-
|
196
|
-
class TransactionItemWorker {
|
197
|
-
constructor(src) {
|
198
|
-
this.ti = Object.assign({}, src);
|
199
|
-
}
|
200
|
-
insert(parentId, toInsert) {
|
201
|
-
return new TransactionItemWorker(insertTransactionItem(this.ti, parentId, toInsert));
|
202
|
-
}
|
203
|
-
remove(id) {
|
204
|
-
return new TransactionItemWorker(removeTransactionItem(this.ti, id));
|
205
|
-
}
|
206
|
-
replace(toReplace) {
|
207
|
-
return new TransactionItemWorker(replaceTransactionItem(this.ti, toReplace));
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
function extractMetadata(uiDefinition) {
|
212
|
-
return omit(uiDefinition, [
|
213
|
-
'children',
|
214
|
-
'pages',
|
215
|
-
'components',
|
216
|
-
]);
|
217
|
-
}
|
218
|
-
|
219
|
-
const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
|
220
|
-
|
221
|
-
class RuntimeSettingsService {
|
222
|
-
constructor(configurationSettingsApiService) {
|
223
|
-
this.configurationSettingsApiService = configurationSettingsApiService;
|
224
|
-
this.configurationSettings$ = new BehaviorSubject({});
|
225
|
-
this.currencySettings$ = new BehaviorSubject({
|
226
|
-
iso: DEFAULT_CURRENCY_ISO_CODE,
|
227
|
-
symbol: DEFAULT_CURRENCY_SYMBOL,
|
228
|
-
});
|
229
|
-
this.shoppingCartSettings$ = new BehaviorSubject([]);
|
230
|
-
this.getCurrencySymbol = (locale, currency) => {
|
231
|
-
return (0)
|
232
|
-
.toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
|
233
|
-
.replace(/\d/g, '')
|
234
|
-
.trim();
|
235
|
-
};
|
236
|
-
}
|
237
|
-
create() {
|
238
|
-
return this.configurationSettingsApiService.fetchSettings().pipe(map(settings => this.parseConfigurationSettings(settings)), tap(configurationSettings => {
|
239
|
-
var _a;
|
240
|
-
this.configurationSettings$.next(configurationSettings);
|
241
|
-
this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
|
242
|
-
this.formattingSettings = this.getFormattingSettings();
|
243
|
-
}), map(() => undefined));
|
244
|
-
}
|
245
|
-
initCurrency(iso) {
|
246
|
-
if (iso) {
|
247
|
-
const symbol = this.getCurrencySymbol('en-US', iso);
|
248
|
-
this.currencySettings$.next({ iso, symbol });
|
249
|
-
if (this.formattingSettings) {
|
250
|
-
this.formattingSettings.currencySymbol = symbol;
|
251
|
-
}
|
252
|
-
}
|
253
|
-
}
|
254
|
-
getFormattingSettings() {
|
255
|
-
var _a, _b;
|
256
|
-
if (this.formattingSettings) {
|
257
|
-
return this.formattingSettings;
|
258
|
-
}
|
259
|
-
const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
|
260
|
-
return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
|
261
|
-
}, {});
|
262
|
-
const currencySettings = this.getCurrencySettings();
|
263
|
-
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)) ||
|
264
|
-
DEFAULT_DATE_FORMAT;
|
265
|
-
const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
|
266
|
-
const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
|
267
|
-
// the number of decimal places can be 0
|
268
|
-
const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
|
269
|
-
const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
|
270
|
-
? Number(priceScale)
|
271
|
-
: DEFAULT_DECIMALS_COUNT;
|
272
|
-
const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
|
273
|
-
return {
|
274
|
-
currencySymbol: currencySettings.symbol,
|
275
|
-
dateFormats: getSupportedDateFormats(dateFormat),
|
276
|
-
decimalsCount,
|
277
|
-
decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
|
278
|
-
? decimalSeparator
|
279
|
-
: DEFAULT_DECIMAL_SEPARATOR,
|
280
|
-
// thousands separator can be a blank value, so it can also be null
|
281
|
-
thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
|
282
|
-
? thousandsSeparator || ''
|
283
|
-
: DEFAULT_THOUSANDS_SEPARATOR,
|
284
|
-
actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
|
285
|
-
? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
|
286
|
-
: DEFAULT_ACTION_CODE_LABELS,
|
287
|
-
};
|
288
|
-
}
|
289
|
-
getConfigurationSettings() {
|
290
|
-
return this.configurationSettings$.value;
|
291
|
-
}
|
292
|
-
getShoppingCartSettings() {
|
293
|
-
return this.shoppingCartSettings$.value;
|
294
|
-
}
|
295
|
-
getCurrencySettings() {
|
296
|
-
return this.currencySettings$.value;
|
297
|
-
}
|
298
|
-
parseConfigurationSettings(settings) {
|
299
|
-
return settings.reduce((acc, setting) => {
|
300
|
-
switch (setting.key) {
|
301
|
-
case 'shopping-cart':
|
302
|
-
acc['shopping-cart'] = parseJsonSafely(setting.value, []);
|
303
|
-
break;
|
304
|
-
case 'navigation':
|
305
|
-
acc.navigation = parseJsonSafely(setting.value, {});
|
306
|
-
break;
|
307
|
-
case 'flows':
|
308
|
-
acc.flows = parseJsonSafely(setting.value, []);
|
309
|
-
break;
|
310
|
-
default:
|
311
|
-
acc[setting.key] = setting.value;
|
312
|
-
}
|
313
|
-
return acc;
|
314
|
-
}, {});
|
315
|
-
}
|
316
|
-
addShoppingCartSettings(settings) {
|
317
|
-
// uniqBy removes items with the biggest index
|
318
|
-
const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
|
319
|
-
this.shoppingCartSettings$.next(newSettings);
|
320
|
-
}
|
321
|
-
}
|
322
|
-
RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
323
|
-
RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
|
324
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
|
325
|
-
type: Injectable
|
326
|
-
}], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
|
327
|
-
|
328
|
-
class FlowInfoService {
|
329
|
-
constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
|
330
|
-
this.runtimeSettingsService = runtimeSettingsService;
|
331
|
-
this.templatesAdminApiService = templatesAdminApiService;
|
332
|
-
this.customizationService = customizationService;
|
333
|
-
this.defaultTemplates = {
|
334
|
-
flowEngine: 'Flow Engine',
|
335
|
-
};
|
336
|
-
this.flowSubj$ = new BehaviorSubject(null);
|
337
|
-
this.templatesSubj$ = new BehaviorSubject({});
|
338
|
-
this.contextSubj$ = new BehaviorSubject(null);
|
339
|
-
this.flow$ = this.flowSubj$.asObservable();
|
340
|
-
this.templates$ = this.templatesSubj$.asObservable();
|
341
|
-
}
|
342
|
-
get flow() {
|
343
|
-
if (!this.flowSubj$.value) {
|
344
|
-
throw new Error(`Flow not initialized yet`);
|
345
|
-
}
|
346
|
-
return this.flowSubj$.value;
|
347
|
-
}
|
348
|
-
get isFlowInitialized() {
|
349
|
-
return Boolean(this.flowSubj$.value);
|
350
|
-
}
|
351
|
-
get context() {
|
352
|
-
if (!this.contextSubj$.value) {
|
353
|
-
throw new Error('Context is not initialized yet!');
|
354
|
-
}
|
355
|
-
return Object.assign({}, this.contextSubj$.value);
|
356
|
-
}
|
357
|
-
get context$() {
|
358
|
-
return this.contextSubj$.asObservable().pipe(filter(isDefined));
|
359
|
-
}
|
360
|
-
get templates() {
|
361
|
-
return this.templatesSubj$.value;
|
362
|
-
}
|
363
|
-
get isFlowEngineInitialized$() {
|
364
|
-
return this.templates$.pipe(map(v => Boolean(v.FLOW_ENGINE)));
|
365
|
-
}
|
366
|
-
get isStateful() {
|
367
|
-
var _a;
|
368
|
-
return !!((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful);
|
369
|
-
}
|
370
|
-
reset() {
|
371
|
-
this.flowSubj$.next(null);
|
372
|
-
this.templatesSubj$.next({});
|
373
|
-
this.contextSubj$.next(null);
|
374
|
-
}
|
375
|
-
init$(flowId, routeQueryParams) {
|
376
|
-
return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
|
377
|
-
}
|
378
|
-
updateContext(update) {
|
379
|
-
this.contextSubj$.next(Object.assign(Object.assign({}, this.context), update));
|
380
|
-
}
|
381
|
-
initFlow$(flowId, routeQueryParams) {
|
382
|
-
var _a;
|
383
|
-
const flow = (_a = this.runtimeSettingsService.getConfigurationSettings()['flows']) === null || _a === void 0 ? void 0 : _a.find(({ id }) => flowId === id);
|
384
|
-
if (!flow) {
|
385
|
-
this.flowSubj$.next(null);
|
386
|
-
throw new Error(`Flow with flowId=${flowId} is not defined`);
|
387
|
-
}
|
388
|
-
const headerId = routeQueryParams['headerId'];
|
389
|
-
if (typeof headerId !== 'string') {
|
390
|
-
throw new Error(`Please provide 'headerId'`);
|
391
|
-
}
|
392
|
-
const mode = this.getFlowContextMode(headerId);
|
393
|
-
// Restrict if mode is not defined
|
394
|
-
if (mode == null) {
|
395
|
-
throw new Error('Mode is undefined');
|
396
|
-
}
|
397
|
-
this.contextSubj$.next(Object.assign(Object.assign(Object.assign({}, flow.properties.queryParams), routeQueryParams), { mode }));
|
398
|
-
this.flowSubj$.next(flow);
|
399
|
-
return of(undefined);
|
400
|
-
}
|
401
|
-
initFlowTemplates$() {
|
402
|
-
var _a, _b, _c;
|
403
|
-
return forkJoin([
|
404
|
-
this.templatesAdminApiService.fetchTemplates$(),
|
405
|
-
(_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([]),
|
406
|
-
]).pipe(map(([templates, localTemplates]) => {
|
407
|
-
var _a, _b;
|
408
|
-
const newValue = {};
|
409
|
-
Object.entries(Object.assign(Object.assign({}, this.defaultTemplates), ((_b = (_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.templates) !== null && _b !== void 0 ? _b : {}))).forEach(([key, name]) => {
|
410
|
-
var _a;
|
411
|
-
const type = this.remapTemplateName(key);
|
412
|
-
if (type) {
|
413
|
-
newValue[type] =
|
414
|
-
(_a = localTemplates.find(template => template.name === name && template.type === type)) !== null && _a !== void 0 ? _a : templates.find(template => template.name === name && template.type === type);
|
415
|
-
}
|
416
|
-
});
|
417
|
-
this.templatesSubj$.next(newValue);
|
418
|
-
}));
|
419
|
-
}
|
420
|
-
remapTemplateName(templateType) {
|
421
|
-
switch (templateType) {
|
422
|
-
case 'flowEngine':
|
423
|
-
return UITemplateType.FLOW_ENGINE;
|
424
|
-
default:
|
425
|
-
break;
|
426
|
-
}
|
427
|
-
switch (templateType) {
|
428
|
-
case 'assets':
|
429
|
-
case 'shoppingCart':
|
430
|
-
// No separate Assets template at the moment
|
431
|
-
return UITemplateType.SHOPPING_CART;
|
432
|
-
case 'catalog':
|
433
|
-
return UITemplateType.CATALOG;
|
434
|
-
case 'guidedSelling':
|
435
|
-
return UITemplateType.GUIDED_SELLING;
|
436
|
-
case 'flowHeader':
|
437
|
-
return UITemplateType.FLOW_HEADER;
|
438
|
-
default:
|
439
|
-
break;
|
440
|
-
}
|
441
|
-
return undefined;
|
442
|
-
}
|
443
|
-
getFlowContextMode(headerId) {
|
444
|
-
const objectName = SalesforceIdUtils.getSfObjectNameById(headerId);
|
445
|
-
if (!objectName) {
|
446
|
-
return;
|
447
|
-
}
|
448
|
-
return objectName.toUpperCase();
|
449
|
-
}
|
450
|
-
}
|
451
|
-
FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: RuntimeSettingsService }, { token: i1.UITemplatesAdminApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
452
|
-
FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
|
453
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
|
454
|
-
type: Injectable
|
455
|
-
}], ctorParameters: function () {
|
456
|
-
return [{ type: RuntimeSettingsService }, { type: i1.UITemplatesAdminApiService }, { type: undefined, decorators: [{
|
457
|
-
type: Optional
|
458
|
-
}, {
|
459
|
-
type: Inject,
|
460
|
-
args: [FLOW_CUSTOMIZATION]
|
461
|
-
}] }];
|
462
|
-
} });
|
463
|
-
|
464
|
-
class TestModeConfigurationService {
|
465
|
-
constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService, sfApiService) {
|
466
|
-
this.flowInfoService = flowInfoService;
|
467
|
-
this.configurationService = configurationService;
|
468
|
-
this.configurationRuntimeService = configurationRuntimeService;
|
469
|
-
this.salesTransactionService = salesTransactionService;
|
470
|
-
this.runtimeSettingsService = runtimeSettingsService;
|
471
|
-
this.sfApiService = sfApiService;
|
472
|
-
this.isInitialized = false;
|
473
|
-
}
|
474
|
-
initTestMode$(uiDefinitionContainer, options) {
|
475
|
-
var _a;
|
476
|
-
this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
|
477
|
-
if (this.checkInitialized(uiDefinitionContainer)) {
|
478
|
-
this.configurationRuntimeService.pcmModelSubj$.next(this.pcmModel || null);
|
479
|
-
return of(undefined);
|
480
|
-
}
|
481
|
-
this.configurationService.reset();
|
482
|
-
const { productId, quoteId, flowId } = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
|
483
|
-
if (!productId) {
|
484
|
-
return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
|
485
|
-
}
|
486
|
-
if (!quoteId) {
|
487
|
-
return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
|
488
|
-
}
|
489
|
-
if (!flowId) {
|
490
|
-
return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
|
491
|
-
}
|
492
|
-
return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId, testMode: true })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
|
493
|
-
if (options === null || options === void 0 ? void 0 : options.customizationMode) {
|
494
|
-
return of(undefined);
|
495
|
-
}
|
496
|
-
return this.initConfiguration$(quoteId);
|
497
|
-
}), tap(() => (this.isInitialized = true)), map(noop));
|
498
|
-
}
|
499
|
-
initConfiguration$(quoteId) {
|
500
|
-
return this.getPriceBookId(quoteId).pipe(map(priceBookId => this.getTestTransactionContext(quoteId, priceBookId)), tap(state => this.salesTransactionService.setState(state)), switchMap(() => this.configurationService.init$()), switchMap(() => this.configurationService.state
|
501
|
-
? this.configurationService.configure$(this.configurationService.state)
|
502
|
-
: of(undefined)), map(noop));
|
503
|
-
}
|
504
|
-
getPriceBookId(quoteId) {
|
505
|
-
return this.sfApiService
|
506
|
-
.query({ count: 1, fields: ['Pricebook2Id'], rawCondition: `Id = '${quoteId}'` }, 'Quote')
|
507
|
-
.pipe(map(r => { var _a, _b; return (_b = (_a = r === null || r === void 0 ? void 0 : r[0]) === null || _a === void 0 ? void 0 : _a.Pricebook2Id) !== null && _b !== void 0 ? _b : null; }));
|
508
|
-
}
|
509
|
-
getTestTransactionContext(quoteId, priceBookId) {
|
510
|
-
var _a;
|
511
|
-
const dateStr = (_a = new Date().toISOString().split('T')[0]) !== null && _a !== void 0 ? _a : '';
|
512
|
-
const testTransaction = {
|
513
|
-
id: quoteId,
|
514
|
-
businessObjectType: 'Quote',
|
515
|
-
salesTransactionItems: [],
|
516
|
-
salesTransactionName: 'Test Quote',
|
517
|
-
account: '',
|
518
|
-
quoteAccount: '',
|
519
|
-
pricebook: '',
|
520
|
-
status: 'Draft',
|
521
|
-
totalAmount: 0,
|
522
|
-
subtotal: 0,
|
523
|
-
activatedDate: dateStr,
|
524
|
-
effectiveDate: dateStr,
|
525
|
-
startDate: dateStr,
|
526
|
-
attributes: {},
|
527
|
-
nodes: {},
|
528
|
-
};
|
529
|
-
if (priceBookId) {
|
530
|
-
testTransaction.pricebook = priceBookId;
|
531
|
-
}
|
532
|
-
return {
|
533
|
-
salesTransaction: testTransaction,
|
534
|
-
transactionId: quoteId,
|
535
|
-
businessObjectType: 'Quote',
|
536
|
-
nodes: {},
|
537
|
-
id: UUID.UUID(),
|
538
|
-
attributes: {},
|
539
|
-
};
|
540
|
-
}
|
541
|
-
checkInitialized(uiDefinitionContainer) {
|
542
|
-
var _a;
|
543
|
-
return this.isInitialized && !!((_a = uiDefinitionContainer.source.properties) === null || _a === void 0 ? void 0 : _a.persistTestState);
|
544
|
-
}
|
545
|
-
}
|
546
|
-
TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
547
|
-
TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
|
548
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
|
549
|
-
type: Injectable
|
550
|
-
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }, { type: i1.SalesforceApiService }]; } });
|
551
|
-
|
552
|
-
class GuidedSellingService {
|
553
|
-
constructor(orchestrationsApiService) {
|
554
|
-
this.orchestrationsApiService = orchestrationsApiService;
|
555
|
-
this.guidedSellingResult$ = new BehaviorSubject({});
|
556
|
-
}
|
557
|
-
get guidedSellingResult() {
|
558
|
-
return this.guidedSellingResult$.value;
|
559
|
-
}
|
560
|
-
configureGuidedSelling$(data) {
|
561
|
-
return this.orchestrationsApiService
|
562
|
-
.apply$({
|
563
|
-
transactionContext: this.getTransactionContext(data.attributesMap),
|
564
|
-
orchestrationName: data.orchestrationName,
|
565
|
-
})
|
566
|
-
.pipe(map(transactionContext => {
|
567
|
-
var _a, _b;
|
568
|
-
const guidedSellingNode = (_a = transactionContext.nodes['GuidedSelling']) === null || _a === void 0 ? void 0 : _a[0];
|
569
|
-
const guidedSellingResult = ((_b = guidedSellingNode === null || guidedSellingNode === void 0 ? void 0 : guidedSellingNode.attributes) === null || _b === void 0 ? void 0 : _b['result']) || {};
|
570
|
-
this.guidedSellingResult$.next(guidedSellingResult);
|
571
|
-
return guidedSellingResult;
|
572
|
-
}));
|
573
|
-
}
|
574
|
-
clearGuidedSelling$() {
|
575
|
-
this.guidedSellingResult$.next({});
|
576
|
-
}
|
577
|
-
getTransactionContext(guidedSellingAttributes) {
|
578
|
-
const testTransaction = {
|
579
|
-
id: UUID.UUID(),
|
580
|
-
businessObjectType: 'Quote',
|
581
|
-
salesTransactionItems: [],
|
582
|
-
attributes: {},
|
583
|
-
};
|
584
|
-
return {
|
585
|
-
salesTransaction: testTransaction,
|
586
|
-
transactionId: UUID.UUID(),
|
587
|
-
businessObjectType: 'Quote',
|
588
|
-
nodes: {
|
589
|
-
GuidedSelling: [
|
590
|
-
{
|
591
|
-
id: UUID.UUID(),
|
592
|
-
attributes: {},
|
593
|
-
nodes: {},
|
594
|
-
properties: { guidedSellingAttributes },
|
595
|
-
},
|
596
|
-
],
|
597
|
-
},
|
598
|
-
id: UUID.UUID(),
|
599
|
-
attributes: {},
|
600
|
-
};
|
601
|
-
}
|
602
|
-
}
|
603
|
-
GuidedSellingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, deps: [{ token: i1.OrchestrationsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
604
|
-
GuidedSellingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService });
|
605
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: GuidedSellingService, decorators: [{
|
606
|
-
type: Injectable
|
607
|
-
}], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }]; } });
|
608
|
-
|
609
|
-
class SalesTransactionService {
|
610
|
-
get isInitialized$() {
|
611
|
-
return this.isInitializedSubj$.asObservable();
|
612
|
-
}
|
613
|
-
get isInitialized() {
|
614
|
-
return this.isInitializedSubj$.getValue();
|
615
|
-
}
|
616
|
-
set hasUnsavedChanges(value) {
|
617
|
-
var _a, _b;
|
618
|
-
this.hasUnsavedChangesSubj$.next(value);
|
619
|
-
if (!this.hasUnsavedChanges) {
|
620
|
-
this.initialState = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems) !== null && _b !== void 0 ? _b : [];
|
621
|
-
}
|
622
|
-
}
|
623
|
-
get hasUnsavedChanges() {
|
624
|
-
return this.hasUnsavedChangesSubj$.getValue();
|
625
|
-
}
|
626
|
-
get state() {
|
627
|
-
return this.stateSubj$.getValue();
|
628
|
-
}
|
629
|
-
get hasProducts() {
|
630
|
-
var _a;
|
631
|
-
return Boolean((_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems.length);
|
632
|
-
}
|
633
|
-
constructor(salesTransactionApiService) {
|
634
|
-
this.salesTransactionApiService = salesTransactionApiService;
|
635
|
-
this.stateSubj$ = new BehaviorSubject(null);
|
636
|
-
this.isInitializedSubj$ = new BehaviorSubject(false);
|
637
|
-
this.hasUnsavedChangesSubj$ = new BehaviorSubject(false);
|
638
|
-
this.initialState = [];
|
639
|
-
this.hasUnsavedChanges$ = this.hasUnsavedChangesSubj$.asObservable();
|
640
|
-
this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
|
641
|
-
}
|
642
|
-
init(headerId, params) {
|
643
|
-
return this.salesTransactionApiService.query(headerId, params).pipe(tap(res => {
|
644
|
-
if (!res.salesTransaction) {
|
645
|
-
throw new Error('SalesTransaction is not defined. Please check Query Orchestration.');
|
646
|
-
}
|
647
|
-
this.stateSubj$.next(res);
|
648
|
-
}));
|
649
|
-
}
|
650
|
-
finalizeInit() {
|
651
|
-
this.isInitializedSubj$.next(true);
|
652
|
-
this.hasUnsavedChanges = false;
|
653
|
-
}
|
654
|
-
reset() {
|
655
|
-
this.stateSubj$.next(null);
|
656
|
-
this.isInitializedSubj$.next(false);
|
657
|
-
this.hasUnsavedChangesSubj$.next(false);
|
658
|
-
}
|
659
|
-
getInitialState() {
|
660
|
-
return this.initialState;
|
661
|
-
}
|
662
|
-
setState(state) {
|
663
|
-
this.stateSubj$.next(state);
|
664
|
-
}
|
665
|
-
}
|
666
|
-
SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
667
|
-
SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
|
668
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
|
669
|
-
type: Injectable
|
670
|
-
}], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
|
671
|
-
|
672
|
-
class FlowConfigurationService {
|
673
|
-
constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
|
674
|
-
this.orchestrationsApiService = orchestrationsApiService;
|
675
|
-
this.salesTransactionService = salesTransactionService;
|
676
|
-
this.flowInfoService = flowInfoService;
|
677
|
-
this.updatedSubj$ = new Subject();
|
678
|
-
this.updated$ = this.updatedSubj$.asObservable();
|
679
|
-
}
|
680
|
-
calculate$(state) {
|
681
|
-
return this.orchestrationsApiService
|
682
|
-
.apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
|
683
|
-
.pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
|
684
|
-
}
|
685
|
-
calculate(state) {
|
686
|
-
this.calculate$(state).subscribe();
|
687
|
-
}
|
688
|
-
revert$(transactionItemId) {
|
689
|
-
var _a;
|
690
|
-
const state = this.salesTransactionService.state;
|
691
|
-
const initialState = this.salesTransactionService.getInitialState();
|
692
|
-
const currentState = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
|
693
|
-
const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
|
694
|
-
const currentItem = currentState[currentItemIndex];
|
695
|
-
const initialItem = initialState.find(({ integrationId }) => integrationId === (currentItem === null || currentItem === void 0 ? void 0 : currentItem.integrationId));
|
696
|
-
if (!state || !currentItem || !initialItem) {
|
697
|
-
return of(null);
|
698
|
-
}
|
699
|
-
const updatedState = cloneDeep(currentState);
|
700
|
-
updatedState.splice(currentItemIndex, 1, initialItem);
|
701
|
-
return of([]).pipe(map(() => (Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
702
|
-
}
|
703
|
-
revert(transactionItemId) {
|
704
|
-
this.revert$(transactionItemId).subscribe();
|
705
|
-
}
|
706
|
-
delete$(ids) {
|
707
|
-
const state = this.salesTransactionService.state;
|
708
|
-
if (!state) {
|
709
|
-
return of(null);
|
710
|
-
}
|
711
|
-
return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
|
712
|
-
}
|
713
|
-
delete(ids) {
|
714
|
-
this.delete$(ids).subscribe();
|
715
|
-
}
|
716
|
-
handleErrorAndBounceBack() {
|
717
|
-
return (source$) => {
|
718
|
-
return source$.pipe(catchError(error => {
|
719
|
-
console.error(error);
|
720
|
-
// bounce back if configuration call has failed
|
721
|
-
const state = this.salesTransactionService.state;
|
722
|
-
if (state) {
|
723
|
-
this.salesTransactionService.setState(state);
|
724
|
-
this.updatedSubj$.next();
|
725
|
-
}
|
726
|
-
return throwError(() => error);
|
727
|
-
}));
|
728
|
-
};
|
729
|
-
}
|
730
|
-
}
|
731
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
732
|
-
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
733
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
734
|
-
type: Injectable
|
735
|
-
}], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
|
736
|
-
|
737
|
-
class FlowStateService {
|
738
|
-
constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
|
739
|
-
this.flowConfiguration = flowConfiguration;
|
740
|
-
this.flowInfoService = flowInfoService;
|
741
|
-
this.flowStateApiService = flowStateApiService;
|
742
|
-
this.processorsApiService = processorsApiService;
|
743
|
-
this.salesTransactionApiService = salesTransactionApiService;
|
744
|
-
this.salesTransactionService = salesTransactionService;
|
745
|
-
this.toastService = toastService;
|
746
|
-
this.customizationService = customizationService;
|
747
|
-
this.NOT_INITIALIZED = Symbol();
|
748
|
-
this.EXECUTION_BUFFER_TIME = 100;
|
749
|
-
this.executedFunctions = {};
|
750
|
-
this.stateId$ = new BehaviorSubject(null);
|
751
|
-
this.initialStatefulData = {};
|
752
|
-
this.trackedStatefulChangesMap = new Map();
|
753
|
-
this.processors = {};
|
754
|
-
this.subscriptions = {};
|
755
|
-
this.flowStore = {};
|
756
|
-
this.executionInProgress$ = new BehaviorSubject(false);
|
757
|
-
this.statefulRequestStream$ = new Subject();
|
758
|
-
this.cleanup$ = new Subject();
|
759
|
-
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
760
|
-
/*
|
761
|
-
In stateless mode watch State changes and call executeRequest so that
|
762
|
-
all subscriptions get their updates according to updated State
|
763
|
-
*/
|
764
|
-
this.isInitialized$()
|
765
|
-
.pipe(filter(Boolean), filter(() => !this.flowInfoService.flow.properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
|
766
|
-
.subscribe();
|
767
|
-
}
|
768
|
-
init$() {
|
769
|
-
if (this.flowInfoService.flow.properties.stateful) {
|
770
|
-
return this.initProcessors$().pipe(switchMap(() => this.initStateful$()));
|
771
|
-
}
|
772
|
-
else {
|
773
|
-
return forkJoin([this.initStateless$(), this.initProcessors$()]).pipe(map(noop));
|
774
|
-
}
|
775
|
-
}
|
776
|
-
reset() {
|
777
|
-
Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
|
778
|
-
this.subscriptions = {};
|
779
|
-
if (this.stateId$.value) {
|
780
|
-
this.flowStateApiService.cancel(this.stateId$.value).subscribe();
|
781
|
-
this.stateId$.next(null);
|
782
|
-
}
|
783
|
-
this.processors = {};
|
784
|
-
this.flowStore = {};
|
785
|
-
this.cleanup$.next();
|
786
|
-
}
|
787
|
-
get hasUnsavedChanges() {
|
788
|
-
return this.flowInfoService.flow.properties.stateful
|
789
|
-
? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
|
790
|
-
: this.salesTransactionService.hasUnsavedChanges;
|
791
|
-
}
|
792
|
-
get stateId() {
|
793
|
-
return this.stateId$.value;
|
794
|
-
}
|
795
|
-
get isExecutionInProgress$() {
|
796
|
-
return this.executionInProgress$.asObservable();
|
797
|
-
}
|
798
|
-
isInitialized$() {
|
799
|
-
return combineLatest([this.stateId$, this.salesTransactionService.isInitialized$]).pipe(map(values => values.some(Boolean)));
|
800
|
-
}
|
801
|
-
isInitialized() {
|
802
|
-
return Boolean(this.stateId$.value) || this.salesTransactionService.isInitialized;
|
803
|
-
}
|
804
|
-
execute$(scope, exec) {
|
805
|
-
const request = this.execToRequest(scope, exec);
|
806
|
-
return this.executeRequest$(request).pipe(map(result => {
|
807
|
-
// Keep only requested results
|
808
|
-
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
809
|
-
var _a;
|
810
|
-
if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
|
811
|
-
trunk[requestId] = result;
|
812
|
-
}
|
813
|
-
return trunk;
|
814
|
-
}, {});
|
815
|
-
return actualSelectors;
|
816
|
-
}));
|
817
|
-
}
|
818
|
-
dispatch$(scope, action, inputData) {
|
819
|
-
const exec = {
|
820
|
-
actions: [{ name: action, inputData }],
|
821
|
-
};
|
822
|
-
const request = this.execToRequest(scope, exec);
|
823
|
-
return this.executeRequest$(request).pipe(map(noop));
|
824
|
-
}
|
825
|
-
select$(scope, selectorName, inputData) {
|
826
|
-
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
827
|
-
const request = this.execToRequest(scope, {
|
828
|
-
selectors: {
|
829
|
-
[requestId]: {
|
830
|
-
name: selectorName,
|
831
|
-
inputData,
|
832
|
-
},
|
833
|
-
},
|
834
|
-
});
|
835
|
-
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
836
|
-
}
|
837
|
-
subscribe$(scope, selectorName, inputData, options) {
|
838
|
-
const requestId = this.generateRequestId(scope, selectorName, inputData);
|
839
|
-
let subscription = this.subscriptions[requestId];
|
840
|
-
if (!subscription) {
|
841
|
-
const request = this.execToRequest(scope, {
|
842
|
-
selectors: {
|
843
|
-
[requestId]: {
|
844
|
-
name: selectorName,
|
845
|
-
inputData,
|
846
|
-
},
|
847
|
-
},
|
848
|
-
});
|
849
|
-
subscription = {
|
850
|
-
request,
|
851
|
-
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
852
|
-
};
|
853
|
-
this.subscriptions[requestId] = subscription;
|
854
|
-
if (options === null || options === void 0 ? void 0 : options.trackedChanges) {
|
855
|
-
this.trackedStatefulChangesMap.set(requestId, false);
|
856
|
-
}
|
857
|
-
if (!(options === null || options === void 0 ? void 0 : options.cold)) {
|
858
|
-
this.executeRequest$(request).subscribe();
|
859
|
-
}
|
860
|
-
}
|
861
|
-
return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), finalize(() => {
|
862
|
-
var _a;
|
863
|
-
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
864
|
-
delete this.subscriptions[requestId];
|
865
|
-
}
|
866
|
-
}));
|
867
|
-
}
|
868
|
-
save$() {
|
869
|
-
if (this.flowInfoService.flow.properties.stateful) {
|
870
|
-
if (this.stateId$.value) {
|
871
|
-
return this.flowStateApiService.save(this.stateId$.value).pipe(map(({ quoteId }) => ({ id: quoteId })), tap(() => {
|
872
|
-
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
873
|
-
this.trackedStatefulChangesMap.set(key, false);
|
874
|
-
});
|
875
|
-
}));
|
876
|
-
}
|
877
|
-
}
|
878
|
-
else {
|
879
|
-
const state = this.salesTransactionService.state;
|
880
|
-
if (state) {
|
881
|
-
const request = {
|
882
|
-
transactionContext: state,
|
883
|
-
flowId: this.flowInfoService.flow.id,
|
884
|
-
};
|
885
|
-
return this.salesTransactionApiService.save(request).pipe(map(id => ({ id })));
|
886
|
-
}
|
887
|
-
}
|
888
|
-
return of({ id: '' });
|
889
|
-
}
|
890
|
-
getFlowStore() {
|
891
|
-
return this.flowStore;
|
892
|
-
}
|
893
|
-
getOwnerIdByScope(scope) {
|
894
|
-
var _a;
|
895
|
-
const ownerId = (_a = this.flowInfoService.templates[scope]) === null || _a === void 0 ? void 0 : _a.id;
|
896
|
-
if (!ownerId) {
|
897
|
-
throw `OwnerId is not found for scope ${scope}`;
|
898
|
-
}
|
899
|
-
return ownerId;
|
900
|
-
}
|
901
|
-
getScopeByOwnerId(id) {
|
902
|
-
for (const template of Object.values(this.flowInfoService.templates)) {
|
903
|
-
if (template.id === id) {
|
904
|
-
return template.type;
|
905
|
-
}
|
906
|
-
}
|
907
|
-
return;
|
908
|
-
}
|
909
|
-
execToRequest(scope, exec) {
|
910
|
-
var _a;
|
911
|
-
const ownerId = this.getOwnerIdByScope(scope);
|
912
|
-
return {
|
913
|
-
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 : {} }); }),
|
914
|
-
selectors: exec.selectors &&
|
915
|
-
Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
|
916
|
-
var _a;
|
917
|
-
return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
|
918
|
-
}, {}),
|
919
|
-
};
|
920
|
-
}
|
921
|
-
executeRequest$(request, forceSubscriptions = false) {
|
922
|
-
var _a;
|
923
|
-
const fullRequest = cloneDeep(request);
|
924
|
-
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
925
|
-
for (const subscription of Object.values(this.subscriptions)) {
|
926
|
-
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
927
|
-
}
|
928
|
-
}
|
929
|
-
const execution$ = this.flowInfoService.flow.properties.stateful
|
930
|
-
? this.executeStateful$(fullRequest)
|
931
|
-
: this.executeStateless$(fullRequest);
|
932
|
-
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
933
|
-
}
|
934
|
-
handleSelectorsResponse(selectors) {
|
935
|
-
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
936
|
-
var _a;
|
937
|
-
if (!selectorResult.success) {
|
938
|
-
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
939
|
-
}
|
940
|
-
const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
|
941
|
-
if (subscription$ && subscription$.value !== selectorResult) {
|
942
|
-
this.checkStatefulChanges(requestId, selectorResult);
|
943
|
-
subscription$.next(selectorResult);
|
944
|
-
}
|
945
|
-
});
|
946
|
-
}
|
947
|
-
initStateful$() {
|
948
|
-
const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap !== null && ownerMap !== void 0 ? ownerMap : {})));
|
949
|
-
const processors = processorsList.length ? processorsList : undefined;
|
950
|
-
const selectors = Object.values(this.subscriptions)
|
951
|
-
.map(({ request }) => request.selectors)
|
952
|
-
.filter(isDefined)
|
953
|
-
.reduce((trunk, selectors) => (Object.assign(Object.assign({}, trunk), selectors)), {});
|
954
|
-
return this.flowStateApiService
|
955
|
-
.init({
|
956
|
-
quoteId: this.flowInfoService.context.headerId,
|
957
|
-
params: this.flowInfoService.context,
|
958
|
-
actionsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
|
959
|
-
selectorsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
|
960
|
-
selectors: selectors,
|
961
|
-
})
|
962
|
-
.pipe(map(({ stateId, selectors }) => {
|
963
|
-
this.handleSelectorsResponse(selectors);
|
964
|
-
this.stateId$.next(stateId);
|
965
|
-
}));
|
966
|
-
}
|
967
|
-
initBufferedRequest$() {
|
968
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
969
|
-
if (!this.stateId$.value) {
|
970
|
-
throw 'Stateful session is not initialized';
|
971
|
-
}
|
972
|
-
// merge buffered requests
|
973
|
-
const request = {
|
974
|
-
actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
|
975
|
-
selectors: requests
|
976
|
-
.map(({ selectors }) => selectors)
|
977
|
-
.filter(isDefined)
|
978
|
-
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
979
|
-
};
|
980
|
-
this.executionInProgress$.next(true);
|
981
|
-
return this.flowStateApiService.execute(this.stateId$.value, request);
|
982
|
-
}), tap(({ stateId }) => this.stateId$.next(stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
983
|
-
this.executionInProgress$.next(false);
|
984
|
-
return throwError(() => e);
|
985
|
-
}));
|
986
|
-
}
|
987
|
-
executeStateful$(request) {
|
988
|
-
return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
|
989
|
-
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
990
|
-
combineLatest([
|
991
|
-
this.statefulExecutionRequest$,
|
992
|
-
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
993
|
-
])), map(([response]) => response), take(1));
|
994
|
-
}
|
995
|
-
initStateless$() {
|
996
|
-
return this.salesTransactionService.init(this.flowInfoService.context.headerId, this.flowInfoService.context).pipe(switchMap(state => this.flowConfiguration.calculate$(state)), tap(() => this.salesTransactionService.finalizeInit()), map(noop));
|
997
|
-
}
|
998
|
-
executeStateless$(request) {
|
999
|
-
this.executionInProgress$.next(true);
|
1000
|
-
return of(undefined).pipe(tap(() => this.executeStatelessActions(request)), switchMap(() => {
|
1001
|
-
var _a;
|
1002
|
-
/*
|
1003
|
-
Skip price calculation in case
|
1004
|
-
1. No actions in the request
|
1005
|
-
2. Initialization process execution (state not initialized yet)
|
1006
|
-
*/
|
1007
|
-
const { state } = this.salesTransactionService;
|
1008
|
-
if (!state || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length) || !this.isInitialized()) {
|
1009
|
-
return of(undefined);
|
1010
|
-
}
|
1011
|
-
else {
|
1012
|
-
return this.flowConfiguration.calculate$(state);
|
1013
|
-
}
|
1014
|
-
}), map(() => this.executeStatelessSelectors(request)), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
1015
|
-
this.executionInProgress$.next(false);
|
1016
|
-
return throwError(() => e);
|
1017
|
-
}));
|
1018
|
-
}
|
1019
|
-
executeStatelessActions(request) {
|
1020
|
-
var _a;
|
1021
|
-
const state = this.salesTransactionService.state;
|
1022
|
-
if (!state || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
1023
|
-
return;
|
1024
|
-
}
|
1025
|
-
let flowState = state;
|
1026
|
-
request.actions.forEach(action => {
|
1027
|
-
var _a;
|
1028
|
-
try {
|
1029
|
-
flowState = (_a = this.executeActionScript(flowState, action)) !== null && _a !== void 0 ? _a : flowState;
|
1030
|
-
}
|
1031
|
-
catch (e) {
|
1032
|
-
console.error(e);
|
1033
|
-
this.toastService.add({ severity: ToastType.error, summary: String(e) });
|
1034
|
-
throw e;
|
1035
|
-
}
|
1036
|
-
});
|
1037
|
-
this.salesTransactionService.setState(flowState);
|
1038
|
-
}
|
1039
|
-
executeStatelessSelectors(request) {
|
1040
|
-
var _a;
|
1041
|
-
if (!this.salesTransactionService.state) {
|
1042
|
-
throw 'State is not initialized';
|
1043
|
-
}
|
1044
|
-
const flowState = this.salesTransactionService.state;
|
1045
|
-
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
1046
|
-
try {
|
1047
|
-
result.selectors[key] = {
|
1048
|
-
success: true,
|
1049
|
-
result: this.executeSelectorScript(flowState, selector),
|
1050
|
-
};
|
1051
|
-
}
|
1052
|
-
catch (e) {
|
1053
|
-
console.error(e);
|
1054
|
-
result.selectors[key] = {
|
1055
|
-
success: false,
|
1056
|
-
errorMessage: String(e),
|
1057
|
-
};
|
1058
|
-
}
|
1059
|
-
return result;
|
1060
|
-
}, { stateId: '', selectors: {} });
|
1061
|
-
}
|
1062
|
-
initProcessors$() {
|
1063
|
-
var _a;
|
1064
|
-
const hasOverrides = Boolean((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors);
|
1065
|
-
if (this.flowInfoService.flow.properties.stateful && !hasOverrides) {
|
1066
|
-
// Skip initialization as backend will take processors from SF
|
1067
|
-
return of(undefined);
|
1068
|
-
}
|
1069
|
-
const owners$ = Object.values(this.flowInfoService.templates)
|
1070
|
-
.map(template => {
|
1071
|
-
var _a, _b, _c;
|
1072
|
-
if (!template) {
|
1073
|
-
return;
|
1074
|
-
}
|
1075
|
-
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);
|
1076
|
-
return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap(processors => {
|
1077
|
-
const processorsMap = processors.reduce((acc, p) => {
|
1078
|
-
acc[p.apiName] = p;
|
1079
|
-
return acc;
|
1080
|
-
}, {});
|
1081
|
-
this.processors[template.id] = processorsMap;
|
1082
|
-
}));
|
1083
|
-
})
|
1084
|
-
.filter(isDefined);
|
1085
|
-
if (!owners$.length) {
|
1086
|
-
return of(undefined);
|
1087
|
-
}
|
1088
|
-
return forkJoin(owners$).pipe(map(noop));
|
1089
|
-
}
|
1090
|
-
executeActionScript(request, executable) {
|
1091
|
-
var _a;
|
1092
|
-
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
1093
|
-
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1094
|
-
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1095
|
-
const scopeText = scope ? ` in ${scope}` : '';
|
1096
|
-
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
1097
|
-
}
|
1098
|
-
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
1099
|
-
}
|
1100
|
-
executeSelectorScript(request, executable) {
|
1101
|
-
var _a;
|
1102
|
-
const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
|
1103
|
-
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1104
|
-
const scope = this.getScopeByOwnerId(executable.ownerId);
|
1105
|
-
const scopeText = scope ? ` in ${scope}` : '';
|
1106
|
-
throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
|
1107
|
-
}
|
1108
|
-
return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
|
1109
|
-
}
|
1110
|
-
executeProcessorScript(request, configurationProcessor, inputData) {
|
1111
|
-
var _a;
|
1112
|
-
const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
|
1113
|
-
let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
|
1114
|
-
if (!functionToExecute) {
|
1115
|
-
const script = `${configurationProcessor.script}\nreturn transform;`;
|
1116
|
-
const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
|
1117
|
-
functionToExecute = new Function(script + sourceMap)();
|
1118
|
-
this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
|
1119
|
-
}
|
1120
|
-
return functionToExecute({
|
1121
|
-
request,
|
1122
|
-
inputData,
|
1123
|
-
flowStore: this.flowStore,
|
1124
|
-
});
|
1125
|
-
}
|
1126
|
-
generateRequestId(scope, selectorName, inputData) {
|
1127
|
-
const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
|
1128
|
-
return `${scope}/${selectorName}/${inputDataHash}`;
|
1129
|
-
}
|
1130
|
-
checkStatefulChanges(requestId, selectorResult) {
|
1131
|
-
if (this.trackedStatefulChangesMap.has(requestId)) {
|
1132
|
-
if (!this.initialStatefulData[requestId]) {
|
1133
|
-
this.initialStatefulData[requestId] = selectorResult;
|
1134
|
-
}
|
1135
|
-
const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
|
1136
|
-
this.trackedStatefulChangesMap.set(requestId, hasChanges);
|
1137
|
-
}
|
1138
|
-
}
|
1139
|
-
}
|
1140
|
-
FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: FlowConfigurationService }, { token: FlowInfoService }, { token: i3.FlowStateApiService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.SalesTransactionApiService }, { token: SalesTransactionService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
|
1141
|
-
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|
1142
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
|
1143
|
-
type: Injectable
|
1144
|
-
}], ctorParameters: function () {
|
1145
|
-
return [{ type: FlowConfigurationService }, { type: FlowInfoService }, { type: i3.FlowStateApiService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.SalesTransactionApiService }, { type: SalesTransactionService }, { type: i6.ToastService }, { type: undefined, decorators: [{
|
1146
|
-
type: Optional
|
1147
|
-
}, {
|
1148
|
-
type: Inject,
|
1149
|
-
args: [FLOW_CUSTOMIZATION]
|
1150
|
-
}] }];
|
1151
|
-
} });
|
1152
|
-
|
1153
|
-
class FlowStateConfigurationService {
|
1154
|
-
constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService, pcmApiService) {
|
1155
|
-
this.flowInfoService = flowInfoService;
|
1156
|
-
this.flowStateService = flowStateService;
|
1157
|
-
this.configurationService = configurationService;
|
1158
|
-
this.salesTransactionService = salesTransactionService;
|
1159
|
-
this.flowConfigurationService = flowConfigurationService;
|
1160
|
-
this.pcmApiService = pcmApiService;
|
1161
|
-
this.pcmCache = {};
|
1162
|
-
}
|
1163
|
-
updateQuantity$(props) {
|
1164
|
-
var _a, _b, _c;
|
1165
|
-
const allItems = (_c = (_b = (_a = this.salesTransactionService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction) === null || _b === void 0 ? void 0 : _b.salesTransactionItems) !== null && _c !== void 0 ? _c : [];
|
1166
|
-
const ti = allItems.find(item => item.id === props.id);
|
1167
|
-
if (!ti) {
|
1168
|
-
return of(undefined);
|
1169
|
-
}
|
1170
|
-
return this.getPCMProduct$(ti.productId).pipe(map(pcm => updateQuantity(ti, props.qty, pcm)), switchMap(updatedTi => {
|
1171
|
-
const state = this.salesTransactionService.state;
|
1172
|
-
if (!state) {
|
1173
|
-
return of(undefined);
|
1174
|
-
}
|
1175
|
-
const updatedState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: state.salesTransaction.salesTransactionItems.map(item => {
|
1176
|
-
return updatedTi.id === item.id ? updatedTi : item;
|
1177
|
-
}) }) });
|
1178
|
-
return this.flowConfigurationService.calculate$(updatedState);
|
1179
|
-
}), switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1180
|
-
}
|
1181
|
-
addToCart$(props) {
|
1182
|
-
var _a;
|
1183
|
-
let request$;
|
1184
|
-
const stateful = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful;
|
1185
|
-
if (stateful) {
|
1186
|
-
const stateId = this.flowStateService.stateId;
|
1187
|
-
if (!stateId) {
|
1188
|
-
request$ = of();
|
1189
|
-
}
|
1190
|
-
else {
|
1191
|
-
// TODO: Implement
|
1192
|
-
request$ = of();
|
1193
|
-
}
|
1194
|
-
}
|
1195
|
-
else {
|
1196
|
-
request$ = this.configureExternal$(props);
|
1197
|
-
}
|
1198
|
-
return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
|
1199
|
-
}
|
1200
|
-
configureExternal$(props) {
|
1201
|
-
return this.getPCMProduct$(props.productId).pipe(switchMap(pcm => {
|
1202
|
-
var _a, _b, _c;
|
1203
|
-
const { state } = this.salesTransactionService;
|
1204
|
-
if (!state) {
|
1205
|
-
return of();
|
1206
|
-
}
|
1207
|
-
const stateToConfigure = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [
|
1208
|
-
Object.assign(Object.assign({}, generateTransactionItem(pcm, (_a = this.configurationService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id, (_b = props.qty) !== null && _b !== void 0 ? _b : 1)), { stiAttributes: Object.entries((_c = props.attributesMap) !== null && _c !== void 0 ? _c : {}).map(([attributeName, value]) => ({
|
1209
|
-
attributeName,
|
1210
|
-
value,
|
1211
|
-
})) }),
|
1212
|
-
] }) });
|
1213
|
-
return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
|
1214
|
-
const state = this.salesTransactionService.state;
|
1215
|
-
const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
|
1216
|
-
if (!state || !addedProduct) {
|
1217
|
-
return of();
|
1218
|
-
}
|
1219
|
-
return this.flowConfigurationService.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct] }) }));
|
1220
|
-
}));
|
1221
|
-
}));
|
1222
|
-
}
|
1223
|
-
getPCMProduct$(productId) {
|
1224
|
-
const cached = this.pcmCache[productId];
|
1225
|
-
if (cached) {
|
1226
|
-
return of(cached);
|
1227
|
-
}
|
1228
|
-
return this.pcmApiService
|
1229
|
-
.fetchPCMByProductId(productId)
|
1230
|
-
.pipe(tap(pcmProduct => (this.pcmCache[productId] = pcmProduct)));
|
1231
|
-
}
|
1232
|
-
}
|
1233
|
-
FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1234
|
-
FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
|
1235
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
|
1236
|
-
type: Injectable
|
1237
|
-
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }, { type: i1.PCMApiService }]; } });
|
1238
|
-
|
1239
|
-
class IntegrationState {
|
1240
|
-
constructor() {
|
1241
|
-
this.stateSubj$ = new BehaviorSubject({});
|
1242
|
-
this.action$ = new Subject();
|
1243
|
-
}
|
1244
|
-
get state$() {
|
1245
|
-
return this.stateSubj$.asObservable();
|
1246
|
-
}
|
1247
|
-
get state() {
|
1248
|
-
return this.stateSubj$.getValue();
|
1249
|
-
}
|
1250
|
-
patchState(update) {
|
1251
|
-
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
|
1252
|
-
}
|
1253
|
-
dispatch(action) {
|
1254
|
-
this.action$.next(action);
|
1255
|
-
}
|
1256
|
-
listen$(actionType) {
|
1257
|
-
return this.action$.pipe(filter(action => action.type === actionType), map(action => action.payload));
|
1258
|
-
}
|
1259
|
-
listenAll$() {
|
1260
|
-
return this.action$.asObservable();
|
1261
|
-
}
|
1262
|
-
reset() {
|
1263
|
-
this.stateSubj$.next({});
|
1264
|
-
}
|
1265
|
-
}
|
1266
|
-
IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
1267
|
-
IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
|
1268
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
|
1269
|
-
type: Injectable
|
1270
|
-
}] });
|
1271
|
-
|
1272
|
-
class ProductImagesService {
|
1273
|
-
constructor(productsAdminApiService) {
|
1274
|
-
this.productsAdminApiService = productsAdminApiService;
|
1275
|
-
this.imagesMap$ = new BehaviorSubject({});
|
1276
|
-
}
|
1277
|
-
getImageUrl$(productId) {
|
1278
|
-
if (this.imagesMap$.value[productId] == null) {
|
1279
|
-
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
1280
|
-
this.fetchProductImage(productId);
|
1281
|
-
}
|
1282
|
-
return this.imagesMap$.pipe(map(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
|
1283
|
-
}
|
1284
|
-
fetchProductImage(productId) {
|
1285
|
-
this.productsAdminApiService
|
1286
|
-
.fetchImage$(productId)
|
1287
|
-
.pipe(map(file => URL.createObjectURL(file)), catchError(() => of('')), tap(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
1288
|
-
.subscribe();
|
1289
|
-
}
|
1290
|
-
}
|
1291
|
-
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductsAdminApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1292
|
-
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
|
1293
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
|
1294
|
-
type: Injectable
|
1295
|
-
}], ctorParameters: function () { return [{ type: i1.ProductsAdminApiService }]; } });
|
1296
|
-
|
1297
|
-
class CatalogProductsService {
|
1298
|
-
constructor() {
|
1299
|
-
this.stateSubj$ = new BehaviorSubject(null);
|
1300
|
-
this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
|
1301
|
-
}
|
1302
|
-
get state() {
|
1303
|
-
return this.stateSubj$.getValue();
|
1304
|
-
}
|
1305
|
-
reset() {
|
1306
|
-
this.stateSubj$.next(null);
|
1307
|
-
}
|
1308
|
-
setState(state) {
|
1309
|
-
this.stateSubj$.next(state);
|
1310
|
-
}
|
1311
|
-
}
|
1312
|
-
CatalogProductsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
1313
|
-
CatalogProductsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService });
|
1314
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CatalogProductsService, decorators: [{
|
1315
|
-
type: Injectable
|
1316
|
-
}] });
|
1317
|
-
|
1318
|
-
class ConfigurationService {
|
1319
|
-
constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService, guidedSellingService) {
|
1320
|
-
this.flowInfoService = flowInfoService;
|
1321
|
-
this.messageService = messageService;
|
1322
|
-
this.configurationRuntimeService = configurationRuntimeService;
|
1323
|
-
this.salesTransactionService = salesTransactionService;
|
1324
|
-
this.orchestrationsApiService = orchestrationsApiService;
|
1325
|
-
this.guidedSellingService = guidedSellingService;
|
1326
|
-
this.hasUnsavedChanges = false;
|
1327
|
-
this.configurationStateSubj$ = new BehaviorSubject(null);
|
1328
|
-
this.previousConfigurationStateSubj$ = new BehaviorSubject(null);
|
1329
|
-
this.isLoadingSubj$ = new BehaviorSubject(false);
|
1330
|
-
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
1331
|
-
}
|
1332
|
-
get state$() {
|
1333
|
-
return this.configurationStateSubj$.asObservable().pipe(filter$1(isDefined));
|
1334
|
-
}
|
1335
|
-
get state() {
|
1336
|
-
return this.configurationStateSubj$.getValue();
|
1337
|
-
}
|
1338
|
-
get previousState() {
|
1339
|
-
return this.previousConfigurationStateSubj$.getValue();
|
1340
|
-
}
|
1341
|
-
get root$() {
|
1342
|
-
return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
|
1343
|
-
}
|
1344
|
-
get root() {
|
1345
|
-
var _a, _b;
|
1346
|
-
return (_b = (_a = this.configurationStateSubj$.getValue()) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems[0]) !== null && _b !== void 0 ? _b : null;
|
1347
|
-
}
|
1348
|
-
reset() {
|
1349
|
-
this.hasUnsavedChanges = false;
|
1350
|
-
this.configurationStateSubj$.next(null);
|
1351
|
-
this.previousConfigurationStateSubj$.next(null);
|
1352
|
-
}
|
1353
|
-
init$() {
|
1354
|
-
var _a, _b;
|
1355
|
-
const { state } = this.salesTransactionService;
|
1356
|
-
const { standalone } = this.flowInfoService.flow.properties;
|
1357
|
-
const { productId, transactionItemId, newProductQty } = this.flowInfoService.context;
|
1358
|
-
if (!state || !productId) {
|
1359
|
-
return of(undefined);
|
1360
|
-
}
|
1361
|
-
const salesTransactionItems = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
|
1362
|
-
let isRootGenerated = false;
|
1363
|
-
let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
|
1364
|
-
if (!transactionItem && standalone) {
|
1365
|
-
transactionItem = salesTransactionItems.find(item => item.productId === productId);
|
1366
|
-
}
|
1367
|
-
if (!transactionItem) {
|
1368
|
-
const quantity = typeof newProductQty === 'number' && newProductQty > 0 ? newProductQty : undefined;
|
1369
|
-
transactionItem = generateTransactionItem(this.getPCMModel(), (_b = this.state) === null || _b === void 0 ? void 0 : _b.salesTransaction.id, quantity);
|
1370
|
-
isRootGenerated = true;
|
1371
|
-
}
|
1372
|
-
const guidedSellingResult = this.guidedSellingService.guidedSellingResult;
|
1373
|
-
if (transactionItem && Object.keys(guidedSellingResult).length && isRootGenerated) {
|
1374
|
-
transactionItem.stiAttributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
|
1375
|
-
attributeName,
|
1376
|
-
value,
|
1377
|
-
}));
|
1378
|
-
}
|
1379
|
-
const configurationState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: transactionItem ? [transactionItem] : [] }) });
|
1380
|
-
return (isRootGenerated ? this.configure$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
|
1381
|
-
this.configurationStateSubj$.next(configurationState);
|
1382
|
-
this.previousConfigurationStateSubj$.next(configurationState);
|
1383
|
-
}), map$1(noop));
|
1384
|
-
}
|
1385
|
-
patch$(transactionItem) {
|
1386
|
-
const { state, root } = this;
|
1387
|
-
if (!state) {
|
1388
|
-
return throwError(() => new Error(`Configuration State is not initialized`));
|
1389
|
-
}
|
1390
|
-
if (!root) {
|
1391
|
-
return throwError(() => new Error(`Root SalesTransactionItem not found`));
|
1392
|
-
}
|
1393
|
-
const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
|
1394
|
-
const newTransactionContext = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [newRoot] }) });
|
1395
|
-
return this.configure$(newTransactionContext).pipe(catchError$1(error => {
|
1396
|
-
console.error(error);
|
1397
|
-
if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
|
1398
|
-
this.messageService.add({ severity: 'error', summary: error });
|
1399
|
-
}
|
1400
|
-
return throwError(() => error);
|
1401
|
-
}), tap$1(() => {
|
1402
|
-
if (!this.hasUnsavedChanges) {
|
1403
|
-
this.hasUnsavedChanges = true;
|
1404
|
-
}
|
1405
|
-
}), map$1(noop));
|
1406
|
-
}
|
1407
|
-
patch(transactionItem) {
|
1408
|
-
this.patch$(transactionItem).subscribe();
|
1409
|
-
}
|
1410
|
-
configure$(transactionContext) {
|
1411
|
-
this.isLoadingSubj$.next(true);
|
1412
|
-
return this.justConfigureRequest$(transactionContext).pipe(tap$1(result => {
|
1413
|
-
this.configurationStateSubj$.next(result);
|
1414
|
-
this.previousConfigurationStateSubj$.next(cloneDeep(result));
|
1415
|
-
}), catchError$1(e => {
|
1416
|
-
const resetState = this.previousConfigurationStateSubj$.getValue();
|
1417
|
-
if (resetState) {
|
1418
|
-
this.previousConfigurationStateSubj$.next(cloneDeep(resetState));
|
1419
|
-
this.configurationStateSubj$.next(resetState);
|
1420
|
-
}
|
1421
|
-
return throwError(() => e);
|
1422
|
-
}), finalize$1(() => this.isLoadingSubj$.next(false)));
|
1423
|
-
}
|
1424
|
-
justConfigureRequest$(transactionContext) {
|
1425
|
-
const request = {
|
1426
|
-
transactionContext,
|
1427
|
-
flowId: this.flowInfoService.flow.id,
|
1428
|
-
};
|
1429
|
-
return this.orchestrationsApiService.apply$(request).pipe(catchError$1(error => throwError(() => {
|
1430
|
-
if (error.error) {
|
1431
|
-
return extractErrorDetails(error.error).join('. ');
|
1432
|
-
}
|
1433
|
-
return error.message || JSON.stringify(error);
|
1434
|
-
})));
|
1435
|
-
}
|
1436
|
-
getPCMModel() {
|
1437
|
-
const pcmModel = this.configurationRuntimeService.pcmModel;
|
1438
|
-
if (!pcmModel) {
|
1439
|
-
throw new Error('PCM model not initialized');
|
1440
|
-
}
|
1441
|
-
return pcmModel;
|
1442
|
-
}
|
1443
|
-
getPCMModel$() {
|
1444
|
-
return this.configurationRuntimeService.pcmModel$.pipe(distinctUntilChanged((prev, curr) => (prev === null || prev === void 0 ? void 0 : prev.id) === (curr === null || curr === void 0 ? void 0 : curr.id)));
|
1445
|
-
}
|
1446
|
-
swapProduct$(productId) {
|
1447
|
-
const rootTransactionItem = this.root;
|
1448
|
-
this.flowInfoService.updateContext({ productId });
|
1449
|
-
return this.configurationRuntimeService.init$({ productId }).pipe(map$1(pcm => { var _a; return generateTransactionItem(pcm, (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id, rootTransactionItem === null || rootTransactionItem === void 0 ? void 0 : rootTransactionItem.qty); }), switchMap(salesTransactionItem => {
|
1450
|
-
var _a;
|
1451
|
-
return this.patch$(Object.assign(Object.assign({}, salesTransactionItem), { id: (_a = rootTransactionItem === null || rootTransactionItem === void 0 ? void 0 : rootTransactionItem.id) !== null && _a !== void 0 ? _a : salesTransactionItem.id }));
|
1452
|
-
}));
|
1453
|
-
}
|
1454
|
-
}
|
1455
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1456
|
-
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
1457
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
|
1458
|
-
type: Injectable
|
1459
|
-
}], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }, { type: GuidedSellingService }]; } });
|
1460
|
-
|
1461
|
-
class ConfigurationStateService {
|
1462
|
-
constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService, pcmApiService) {
|
1463
|
-
this.configurationRuntimeService = configurationRuntimeService;
|
1464
|
-
this.configurationService = configurationService;
|
1465
|
-
this.flowStateService = flowStateService;
|
1466
|
-
this.flowInfoService = flowInfoService;
|
1467
|
-
this.flowConfigurationService = flowConfigurationService;
|
1468
|
-
this.flowStateApiService = flowStateApiService;
|
1469
|
-
this.salesTransactionService = salesTransactionService;
|
1470
|
-
this.salesTransactionApiService = salesTransactionApiService;
|
1471
|
-
this.toastService = toastService;
|
1472
|
-
this.pcmApiService = pcmApiService;
|
1473
|
-
this.isInitialized$ = new BehaviorSubject(false);
|
1474
|
-
this.canceledConfiguration$ = new Subject();
|
1475
|
-
this.NOT_INITIALIZED = Symbol();
|
1476
|
-
this.EXECUTION_BUFFER_TIME = 100;
|
1477
|
-
this.executedFunctions = {};
|
1478
|
-
this.stateId = null;
|
1479
|
-
this.ownerId = '';
|
1480
|
-
this.subscriptions = {};
|
1481
|
-
this.configurationStore = {};
|
1482
|
-
this.executionInProgress$ = new BehaviorSubject(false);
|
1483
|
-
this.statefulRequestStream$ = new Subject();
|
1484
|
-
this.statelessExecutionRequest$ = null;
|
1485
|
-
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
1486
|
-
}
|
1487
|
-
get isExecutionInProgress$() {
|
1488
|
-
return this.executionInProgress$.asObservable();
|
1489
|
-
}
|
1490
|
-
init$() {
|
1491
|
-
let request$;
|
1492
|
-
if (this.flowStateService.stateId && this.isStatefulConfiguration) {
|
1493
|
-
request$ = this.initStateful$();
|
1494
|
-
}
|
1495
|
-
else {
|
1496
|
-
request$ = this.configurationService.init$();
|
1497
|
-
}
|
1498
|
-
return request$.pipe(take(1), tap(() => {
|
1499
|
-
this.isInitialized$.next(true);
|
1500
|
-
this.canceledConfiguration$ = new Subject();
|
1501
|
-
}));
|
1502
|
-
}
|
1503
|
-
cleanup() {
|
1504
|
-
Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
|
1505
|
-
this.subscriptions = {};
|
1506
|
-
if (this.stateId) {
|
1507
|
-
this.cancelConfiguration();
|
1508
|
-
}
|
1509
|
-
this.configurationStore = {};
|
1510
|
-
this.executedFunctions = {};
|
1511
|
-
this.configurationService.reset();
|
1512
|
-
this.configurationRuntimeService.reset();
|
1513
|
-
}
|
1514
|
-
execute$(exec) {
|
1515
|
-
const request = this.execToRequest(exec);
|
1516
|
-
return this.executeRequest$(request).pipe(map(result => {
|
1517
|
-
// Keep only requested results
|
1518
|
-
const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
|
1519
|
-
var _a;
|
1520
|
-
if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
|
1521
|
-
trunk[requestId] = result;
|
1522
|
-
}
|
1523
|
-
return trunk;
|
1524
|
-
}, {});
|
1525
|
-
return actualSelectors;
|
1526
|
-
}));
|
1527
|
-
}
|
1528
|
-
dispatch$(actionName, inputData = {}) {
|
1529
|
-
const exec = {
|
1530
|
-
actions: [{ name: actionName, inputData }],
|
1531
|
-
};
|
1532
|
-
const request = this.execToRequest(exec);
|
1533
|
-
const executionRequest$ = this.executeRequest$(request);
|
1534
|
-
if (this.isStatefulConfiguration) {
|
1535
|
-
return executionRequest$;
|
1536
|
-
}
|
1537
|
-
// prevent parallel configuration requests in stateless mode
|
1538
|
-
if (!this.statelessExecutionRequest$) {
|
1539
|
-
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay(), take(1), finalize(() => (this.statelessExecutionRequest$ = null)));
|
1540
|
-
}
|
1541
|
-
return this.statelessExecutionRequest$;
|
1542
|
-
}
|
1543
|
-
select$(selectorName, inputData = {}) {
|
1544
|
-
const requestId = UUID.UUID();
|
1545
|
-
const request = this.execToRequest({
|
1546
|
-
selectors: {
|
1547
|
-
[requestId]: {
|
1548
|
-
name: selectorName,
|
1549
|
-
inputData,
|
1550
|
-
},
|
1551
|
-
},
|
1552
|
-
});
|
1553
|
-
return this.executeRequest$(request).pipe(map(response => response.selectors[requestId]));
|
1554
|
-
}
|
1555
|
-
subscribe$(selectorName, inputData = {}, options) {
|
1556
|
-
const requestId = UUID.UUID();
|
1557
|
-
let subscription = this.subscriptions[requestId];
|
1558
|
-
if (!subscription) {
|
1559
|
-
const request = this.execToRequest({
|
1560
|
-
selectors: {
|
1561
|
-
[requestId]: {
|
1562
|
-
name: selectorName,
|
1563
|
-
inputData,
|
1564
|
-
},
|
1565
|
-
},
|
1566
|
-
});
|
1567
|
-
subscription = {
|
1568
|
-
request,
|
1569
|
-
data$: new BehaviorSubject(this.NOT_INITIALIZED),
|
1570
|
-
};
|
1571
|
-
this.subscriptions[requestId] = subscription;
|
1572
|
-
if (!(options === null || options === void 0 ? void 0 : options.cold)) {
|
1573
|
-
this.executeRequest$(request).subscribe();
|
1574
|
-
}
|
1575
|
-
}
|
1576
|
-
return subscription.data$.pipe(filter(data => data != this.NOT_INITIALIZED), map(data => data), distinctUntilChanged(), finalize(() => {
|
1577
|
-
var _a;
|
1578
|
-
if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
|
1579
|
-
delete this.subscriptions[requestId];
|
1580
|
-
}
|
1581
|
-
}), takeUntil(this.canceledConfiguration$));
|
1582
|
-
}
|
1583
|
-
saveConfiguration() {
|
1584
|
-
var _a, _b;
|
1585
|
-
if (this.isStatefulConfiguration) {
|
1586
|
-
return this.flowStateApiService.saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '').pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(r => ({ id: r.quoteId })));
|
1587
|
-
}
|
1588
|
-
const state = this.salesTransactionService.state;
|
1589
|
-
if (!state) {
|
1590
|
-
return of({ id: '' });
|
1591
|
-
}
|
1592
|
-
const { standalone } = this.flowInfoService.flow.properties;
|
1593
|
-
const transactionContext = this.salesTransactionService.state;
|
1594
|
-
const configurationRoot = this.configurationService.root;
|
1595
|
-
if (!transactionContext || !configurationRoot) {
|
1596
|
-
return of({ id: '' });
|
1597
|
-
}
|
1598
|
-
const stateItems = transactionContext.salesTransaction.salesTransactionItems;
|
1599
|
-
const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
|
1600
|
-
let salesTransactionItems;
|
1601
|
-
if (isNewTransactionItem) {
|
1602
|
-
salesTransactionItems = [...stateItems, configurationRoot];
|
1603
|
-
}
|
1604
|
-
else {
|
1605
|
-
salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
|
1606
|
-
}
|
1607
|
-
const newState = Object.assign(Object.assign({}, transactionContext), { salesTransaction: Object.assign(Object.assign({}, transactionContext.salesTransaction), { salesTransactionItems }) });
|
1608
|
-
if (standalone) {
|
1609
|
-
const request = {
|
1610
|
-
transactionContext: newState,
|
1611
|
-
flowId: this.flowInfoService.flow.id,
|
1612
|
-
};
|
1613
|
-
return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
|
1614
|
-
}
|
1615
|
-
return this.flowConfigurationService.calculate$(newState).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(() => ({ id: '' })));
|
1616
|
-
}
|
1617
|
-
cancelConfiguration() {
|
1618
|
-
var _a, _b;
|
1619
|
-
if (!this.isInitialized$.value) {
|
1620
|
-
return of(undefined);
|
1621
|
-
}
|
1622
|
-
this.canceledConfiguration$.next();
|
1623
|
-
this.canceledConfiguration$.complete();
|
1624
|
-
this.subscriptions = {};
|
1625
|
-
this.isInitialized$.next(false);
|
1626
|
-
if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
|
1627
|
-
return of(undefined);
|
1628
|
-
}
|
1629
|
-
return this.flowStateApiService.cancelConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '');
|
1630
|
-
}
|
1631
|
-
get isStatefulConfiguration() {
|
1632
|
-
var _a, _b;
|
1633
|
-
return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) !== null && _b !== void 0 ? _b : false;
|
1634
|
-
}
|
1635
|
-
initStateful$() {
|
1636
|
-
var _a, _b, _c, _d;
|
1637
|
-
this.ownerId = (_b = (_a = this.configurationRuntimeService.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : '';
|
1638
|
-
const { productId, transactionItemId } = this.flowInfoService.context;
|
1639
|
-
if (!productId || !this.flowStateService.stateId) {
|
1640
|
-
return of(undefined);
|
1641
|
-
}
|
1642
|
-
const container = this.configurationRuntimeService.uiDefinitionContainer;
|
1643
|
-
let request$;
|
1644
|
-
if (!transactionItemId) {
|
1645
|
-
request$ = this.pcmApiService.fetchPCMByProductId(productId).pipe(switchMap(pcm => {
|
1646
|
-
var _a, _b, _c;
|
1647
|
-
return this.flowStateApiService.newConfiguration(this.flowStateService.stateId || '', {
|
1648
|
-
transactionItem: generateTransactionItem(pcm, (_a = this.configurationService.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.id),
|
1649
|
-
actionsOverride: (_b = container === null || container === void 0 ? void 0 : container.actions) === null || _b === void 0 ? void 0 : _b.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
1650
|
-
selectorsOverride: (_c = container === null || container === void 0 ? void 0 : container.selectors) === null || _c === void 0 ? void 0 : _c.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
1651
|
-
});
|
1652
|
-
}));
|
1653
|
-
}
|
1654
|
-
else {
|
1655
|
-
request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
|
1656
|
-
transactionItemId,
|
1657
|
-
actionsOverride: (_c = container === null || container === void 0 ? void 0 : container.actions) === null || _c === void 0 ? void 0 : _c.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
1658
|
-
selectorsOverride: (_d = container === null || container === void 0 ? void 0 : container.selectors) === null || _d === void 0 ? void 0 : _d.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
|
1659
|
-
});
|
1660
|
-
}
|
1661
|
-
return request$.pipe(map(r => {
|
1662
|
-
this.stateId = r.stateId;
|
1663
|
-
return undefined;
|
1664
|
-
}));
|
1665
|
-
}
|
1666
|
-
execToRequest(exec) {
|
1667
|
-
var _a;
|
1668
|
-
return {
|
1669
|
-
actions: (_a = exec.actions) === null || _a === void 0 ? void 0 : _a.map(action => {
|
1670
|
-
var _a;
|
1671
|
-
return ({
|
1672
|
-
apiName: action.name,
|
1673
|
-
ownerId: this.ownerId,
|
1674
|
-
inputData: (_a = action.inputData) !== null && _a !== void 0 ? _a : {},
|
1675
|
-
});
|
1676
|
-
}),
|
1677
|
-
selectors: exec.selectors &&
|
1678
|
-
Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
|
1679
|
-
var _a;
|
1680
|
-
return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId: this.ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
|
1681
|
-
}, {}),
|
1682
|
-
};
|
1683
|
-
}
|
1684
|
-
handleSelectorsResponse(selectors) {
|
1685
|
-
Object.entries(selectors).forEach(([requestId, selectorResult]) => {
|
1686
|
-
var _a;
|
1687
|
-
if (!selectorResult.success) {
|
1688
|
-
this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
|
1689
|
-
}
|
1690
|
-
const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
|
1691
|
-
if (subscription$) {
|
1692
|
-
subscription$.next(selectorResult);
|
1693
|
-
}
|
1694
|
-
});
|
1695
|
-
}
|
1696
|
-
executeRequest$(req, forceSubscriptions) {
|
1697
|
-
var _a;
|
1698
|
-
const fullRequest = cloneDeep(req);
|
1699
|
-
if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
|
1700
|
-
for (const subscription of Object.values(this.subscriptions)) {
|
1701
|
-
fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
|
1702
|
-
}
|
1703
|
-
}
|
1704
|
-
let execution$;
|
1705
|
-
if (this.isStatefulConfiguration) {
|
1706
|
-
execution$ = this.executeStateful$(fullRequest);
|
1707
|
-
}
|
1708
|
-
else {
|
1709
|
-
execution$ = this.executeStateless$(fullRequest);
|
1710
|
-
}
|
1711
|
-
return execution$.pipe(tap(result => this.handleSelectorsResponse(result.selectors)));
|
1712
|
-
}
|
1713
|
-
executeStateless$(request) {
|
1714
|
-
this.executionInProgress$.next(true);
|
1715
|
-
return this.configurationService.state$.pipe(first(), switchMap(state => {
|
1716
|
-
var _a;
|
1717
|
-
// Apply actions and execute configuration/price call
|
1718
|
-
// No need to run configuration if no actions in the request
|
1719
|
-
if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
1720
|
-
return of(undefined);
|
1721
|
-
}
|
1722
|
-
request.actions.forEach(action => {
|
1723
|
-
var _a;
|
1724
|
-
state = (_a = this.executeActionScript(state, action)) !== null && _a !== void 0 ? _a : state;
|
1725
|
-
});
|
1726
|
-
return this.configurationService.configure$(state);
|
1727
|
-
}), map(() => {
|
1728
|
-
// Run selectors and apply them to the state
|
1729
|
-
const configurationState = this.configurationService.state;
|
1730
|
-
if (!configurationState) {
|
1731
|
-
return { stateId: '', selectors: {} };
|
1732
|
-
}
|
1733
|
-
return this.runStatelessSelectors(request, configurationState);
|
1734
|
-
}), tap(() => this.executionInProgress$.next(false)), catchError(error => {
|
1735
|
-
const configurationState = this.configurationService.previousState;
|
1736
|
-
if (configurationState) {
|
1737
|
-
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
1738
|
-
this.handleSelectorsResponse(selectorsResult.selectors);
|
1739
|
-
}
|
1740
|
-
this.executionInProgress$.next(false);
|
1741
|
-
if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
|
1742
|
-
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
1743
|
-
}
|
1744
|
-
return throwError(() => error);
|
1745
|
-
}));
|
1746
|
-
}
|
1747
|
-
initBufferedRequest$() {
|
1748
|
-
return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
|
1749
|
-
if (!this.flowStateService.stateId || !this.stateId) {
|
1750
|
-
throw 'Stateful session is not initialized';
|
1751
|
-
}
|
1752
|
-
// merge buffered requests
|
1753
|
-
const request = {
|
1754
|
-
actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
|
1755
|
-
selectors: requests
|
1756
|
-
.map(({ selectors }) => selectors)
|
1757
|
-
.filter(isDefined)
|
1758
|
-
.reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
|
1759
|
-
};
|
1760
|
-
this.executionInProgress$.next(true);
|
1761
|
-
return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request);
|
1762
|
-
}), tap(({ stateId }) => (this.stateId = stateId)), share(), tap(() => this.executionInProgress$.next(false)), catchError(e => {
|
1763
|
-
this.executionInProgress$.next(false);
|
1764
|
-
return throwError(() => e);
|
1765
|
-
}));
|
1766
|
-
}
|
1767
|
-
executeStateful$(request) {
|
1768
|
-
return this.executionInProgress$.pipe(filter(inProgress => !inProgress), take(1), switchMap(() =>
|
1769
|
-
// make sure stream switches to statefulExecutionRequest$ before pushing an execution request
|
1770
|
-
combineLatest([
|
1771
|
-
this.statefulExecutionRequest$,
|
1772
|
-
of(undefined).pipe(tap(() => this.statefulRequestStream$.next(request))),
|
1773
|
-
])), map(([response]) => response), take(1));
|
1774
|
-
}
|
1775
|
-
executeActionScript(request, processor) {
|
1776
|
-
var _a;
|
1777
|
-
const { actions } = (_a = this.configurationRuntimeService.uiDefinitionContainer) !== null && _a !== void 0 ? _a : {};
|
1778
|
-
const configurationProcessor = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.apiName);
|
1779
|
-
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1780
|
-
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
1781
|
-
}
|
1782
|
-
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
1783
|
-
}
|
1784
|
-
executeSelectorScript(request, processor) {
|
1785
|
-
var _a;
|
1786
|
-
const { selectors } = (_a = this.configurationRuntimeService.uiDefinitionContainer) !== null && _a !== void 0 ? _a : {};
|
1787
|
-
const configurationProcessor = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.apiName);
|
1788
|
-
if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
|
1789
|
-
throw `ConfigurationProcessor ${processor.apiName} not found`;
|
1790
|
-
}
|
1791
|
-
return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
|
1792
|
-
}
|
1793
|
-
executeProcessorScript(request, configurationProcessor, inputData) {
|
1794
|
-
let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
|
1795
|
-
if (!functionToExecute) {
|
1796
|
-
const script = `${configurationProcessor.script}\nreturn transform;`;
|
1797
|
-
const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
|
1798
|
-
functionToExecute = new Function(script + sourceMap)();
|
1799
|
-
this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
|
1800
|
-
}
|
1801
|
-
return functionToExecute({
|
1802
|
-
request,
|
1803
|
-
inputData,
|
1804
|
-
flowStore: this.flowStateService.getFlowStore(),
|
1805
|
-
configurationStore: this.configurationStore,
|
1806
|
-
});
|
1807
|
-
}
|
1808
|
-
runStatelessSelectors(request, configurationState) {
|
1809
|
-
var _a;
|
1810
|
-
return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
|
1811
|
-
try {
|
1812
|
-
result.selectors[key] = {
|
1813
|
-
success: true,
|
1814
|
-
result: this.executeSelectorScript(configurationState, selector),
|
1815
|
-
};
|
1816
|
-
}
|
1817
|
-
catch (e) {
|
1818
|
-
console.error(e);
|
1819
|
-
result.selectors[key] = {
|
1820
|
-
success: false,
|
1821
|
-
errorMessage: String(e),
|
1822
|
-
};
|
1823
|
-
}
|
1824
|
-
return result;
|
1825
|
-
}, { stateId: '', selectors: {} });
|
1826
|
-
}
|
1827
|
-
}
|
1828
|
-
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1829
|
-
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|
1830
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
|
1831
|
-
type: Injectable
|
1832
|
-
}], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }, { type: i1.PCMApiService }]; } });
|
1833
|
-
|
1834
|
-
class ConfigurationModule {
|
1835
|
-
}
|
1836
|
-
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1837
|
-
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
|
1838
|
-
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
|
1839
|
-
ConfigurationService,
|
1840
|
-
ConfigurationStateService,
|
1841
|
-
ConfigurationRuntimeService,
|
1842
|
-
TestModeConfigurationService,
|
1843
|
-
GuidedSellingService,
|
1844
|
-
], imports: [ConfirmationDialogModule, ApiModule] });
|
1845
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
|
1846
|
-
type: NgModule,
|
1847
|
-
args: [{
|
1848
|
-
imports: [ConfirmationDialogModule, ApiModule],
|
1849
|
-
providers: [
|
1850
|
-
ConfigurationService,
|
1851
|
-
ConfigurationStateService,
|
1852
|
-
ConfigurationRuntimeService,
|
1853
|
-
TestModeConfigurationService,
|
1854
|
-
GuidedSellingService,
|
1855
|
-
],
|
1856
|
-
}]
|
1857
|
-
}] });
|
1858
|
-
|
1859
|
-
class FlowConfigurationModule {
|
1860
|
-
}
|
1861
|
-
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1862
|
-
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
|
1863
|
-
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService], imports: [ApiModule] });
|
1864
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
1865
|
-
type: NgModule,
|
1866
|
-
args: [{
|
1867
|
-
imports: [ApiModule],
|
1868
|
-
providers: [FlowConfigurationService],
|
1869
|
-
}]
|
1870
|
-
}] });
|
1871
|
-
|
1872
|
-
const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
|
1873
|
-
|
1874
|
-
const UI_DEFINITION_VERSION = 3;
|
1875
|
-
|
1876
|
-
const DEFAULT_FORMATTING_SETTINGS = {
|
1877
|
-
currencySymbol: DEFAULT_CURRENCY_SYMBOL,
|
1878
|
-
decimalsCount: DEFAULT_DECIMALS_COUNT,
|
1879
|
-
dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
|
1880
|
-
decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
|
1881
|
-
thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
|
1882
|
-
actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
|
1883
|
-
};
|
1884
|
-
class SdkCoreModule {
|
1885
|
-
}
|
1886
|
-
SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1887
|
-
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1888
|
-
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
|
1889
|
-
FlowInfoService,
|
1890
|
-
ProductImagesService,
|
1891
|
-
IntegrationState,
|
1892
|
-
FlowStateService,
|
1893
|
-
FlowStateConfigurationService,
|
1894
|
-
RuntimeSettingsService,
|
1895
|
-
SalesTransactionService,
|
1896
|
-
CatalogProductsService,
|
1897
|
-
{
|
1898
|
-
provide: FORMATTING_SETTINGS_TOKEN,
|
1899
|
-
useExisting: RuntimeSettingsService,
|
1900
|
-
},
|
1901
|
-
], imports: [ConfigurationModule, FlowConfigurationModule] });
|
1902
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
|
1903
|
-
type: NgModule,
|
1904
|
-
args: [{
|
1905
|
-
imports: [ConfigurationModule, FlowConfigurationModule],
|
1906
|
-
providers: [
|
1907
|
-
FlowInfoService,
|
1908
|
-
ProductImagesService,
|
1909
|
-
IntegrationState,
|
1910
|
-
FlowStateService,
|
1911
|
-
FlowStateConfigurationService,
|
1912
|
-
RuntimeSettingsService,
|
1913
|
-
SalesTransactionService,
|
1914
|
-
CatalogProductsService,
|
1915
|
-
{
|
1916
|
-
provide: FORMATTING_SETTINGS_TOKEN,
|
1917
|
-
useExisting: RuntimeSettingsService,
|
1918
|
-
},
|
1919
|
-
],
|
1920
|
-
}]
|
1921
|
-
}] });
|
1922
|
-
|
1923
|
-
class CalendarDirective {
|
1924
|
-
constructor() {
|
1925
|
-
var _a;
|
1926
|
-
this.ngControl = inject(NgControl, { host: true, optional: true });
|
1927
|
-
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
1928
|
-
this.destroy$ = new Subject();
|
1929
|
-
}
|
1930
|
-
set vlCalendar(calendar) {
|
1931
|
-
this.calendar = calendar;
|
1932
|
-
}
|
1933
|
-
ngOnDestroy() {
|
1934
|
-
this.destroy$.next();
|
1935
|
-
this.destroy$.complete();
|
1936
|
-
}
|
1937
|
-
ngOnInit() {
|
1938
|
-
var _a, _b;
|
1939
|
-
if (this.calendar) {
|
1940
|
-
this.calendar.dateFormat = (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.primengFormat) !== null && _b !== void 0 ? _b : DEFAULT_DATE_FORMAT;
|
1941
|
-
if (this.ngControl && this.ngControl.control) {
|
1942
|
-
const control = this.ngControl.control;
|
1943
|
-
control.setValue(control.value, { emitEvent: false });
|
1944
|
-
}
|
1945
|
-
}
|
1946
|
-
}
|
1947
|
-
}
|
1948
|
-
CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
1949
|
-
CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
|
1950
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
|
1951
|
-
type: Directive,
|
1952
|
-
args: [{
|
1953
|
-
selector: '[vlCalendar]',
|
1954
|
-
}]
|
1955
|
-
}], propDecorators: { vlCalendar: [{
|
1956
|
-
type: Input
|
1957
|
-
}] } });
|
1958
|
-
|
1959
|
-
class SdkDirectivesModule {
|
1960
|
-
}
|
1961
|
-
SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1962
|
-
SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
|
1963
|
-
SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
|
1964
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
|
1965
|
-
type: NgModule,
|
1966
|
-
args: [{
|
1967
|
-
declarations: [CalendarDirective],
|
1968
|
-
exports: [CalendarDirective],
|
1969
|
-
}]
|
1970
|
-
}] });
|
1971
|
-
|
1972
|
-
function filterSuccessfulExecute() {
|
1973
|
-
return (source) => source.pipe(filter((result) => result.success), map(r => r.result));
|
1974
|
-
}
|
1975
|
-
|
1976
|
-
class DatePipe {
|
1977
|
-
constructor() {
|
1978
|
-
var _a;
|
1979
|
-
this.locale = inject(LOCALE_ID);
|
1980
|
-
this.defaultOptions = inject(DATE_PIPE_DEFAULT_OPTIONS, { optional: true });
|
1981
|
-
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
1982
|
-
this.destroy$ = new Subject();
|
1983
|
-
}
|
1984
|
-
ngOnDestroy() {
|
1985
|
-
this.destroy$.next();
|
1986
|
-
this.destroy$.complete();
|
1987
|
-
}
|
1988
|
-
transform(date, type = 'date') {
|
1989
|
-
var _a, _b;
|
1990
|
-
if (!date) {
|
1991
|
-
return '';
|
1992
|
-
}
|
1993
|
-
const dateFormat = ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT;
|
1994
|
-
const formatMap = {
|
1995
|
-
date: dateFormat,
|
1996
|
-
time: DEFAULT_TIME_FORMAT,
|
1997
|
-
datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
|
1998
|
-
};
|
1999
|
-
try {
|
2000
|
-
return formatDate(date, formatMap[type], this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
|
2001
|
-
}
|
2002
|
-
catch (error) {
|
2003
|
-
return new Date(date).toString();
|
2004
|
-
}
|
2005
|
-
}
|
2006
|
-
}
|
2007
|
-
DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
2008
|
-
DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
|
2009
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
|
2010
|
-
type: Pipe,
|
2011
|
-
args: [{
|
2012
|
-
name: 'vlDate',
|
2013
|
-
}]
|
2014
|
-
}] });
|
2015
|
-
|
2016
|
-
class NumberPipe {
|
2017
|
-
constructor() {
|
2018
|
-
var _a;
|
2019
|
-
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
2020
|
-
this.destroy$ = new Subject();
|
2021
|
-
}
|
2022
|
-
ngOnDestroy() {
|
2023
|
-
this.destroy$.next();
|
2024
|
-
this.destroy$.complete();
|
2025
|
-
}
|
2026
|
-
transform(price) {
|
2027
|
-
var _a, _b, _c;
|
2028
|
-
return formatNumber(price, (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.thousandsSeparator, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.decimalSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalsCount);
|
2029
|
-
}
|
2030
|
-
}
|
2031
|
-
NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
2032
|
-
NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
|
2033
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
|
2034
|
-
type: Pipe,
|
2035
|
-
args: [{
|
2036
|
-
name: 'vlNumber',
|
2037
|
-
}]
|
2038
|
-
}] });
|
2039
|
-
|
2040
|
-
class PricePipe {
|
2041
|
-
constructor() {
|
2042
|
-
var _a;
|
2043
|
-
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
2044
|
-
this.destroy$ = new Subject();
|
2045
|
-
}
|
2046
|
-
ngOnDestroy() {
|
2047
|
-
this.destroy$.next();
|
2048
|
-
this.destroy$.complete();
|
2049
|
-
}
|
2050
|
-
transform(price) {
|
2051
|
-
var _a, _b, _c, _d;
|
2052
|
-
if (price == null || price === '') {
|
2053
|
-
return '';
|
2054
|
-
}
|
2055
|
-
return `${((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.currencySymbol) || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.thousandsSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalSeparator, (_d = this.formattingSettings) === null || _d === void 0 ? void 0 : _d.decimalsCount)}`;
|
2056
|
-
}
|
2057
|
-
}
|
2058
|
-
PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
2059
|
-
PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
|
2060
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
|
2061
|
-
type: Pipe,
|
2062
|
-
args: [{
|
2063
|
-
name: 'vlPrice',
|
2064
|
-
}]
|
2065
|
-
}] });
|
2066
|
-
|
2067
|
-
class ActionCodePipe {
|
2068
|
-
constructor() {
|
2069
|
-
var _a;
|
2070
|
-
this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
|
2071
|
-
}
|
2072
|
-
transform(actionCode) {
|
2073
|
-
var _a, _b;
|
2074
|
-
return (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.actionCodeLabels[actionCode]) !== null && _b !== void 0 ? _b : actionCode;
|
2075
|
-
}
|
2076
|
-
}
|
2077
|
-
ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
2078
|
-
ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
|
2079
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
|
2080
|
-
type: Pipe,
|
2081
|
-
args: [{
|
2082
|
-
name: 'vlActionCode',
|
2083
|
-
}]
|
2084
|
-
}] });
|
2085
|
-
|
2086
|
-
class SdkPipesModule {
|
2087
|
-
}
|
2088
|
-
SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
2089
|
-
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] });
|
2090
|
-
SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
|
2091
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
|
2092
|
-
type: NgModule,
|
2093
|
-
args: [{
|
2094
|
-
declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
|
2095
|
-
exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
|
2096
|
-
}]
|
2097
|
-
}] });
|
2098
|
-
|
2099
|
-
/**
|
2100
|
-
* Generated bundle index. Do not edit.
|
2101
|
-
*/
|
2102
|
-
|
2103
|
-
export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PCMUtils, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, flattenTransactionItem, generateTransactionItem, generateTransactionItemFromPCM, insertTransactionItem, removeTransactionItem, replaceTransactionItem, updateQuantity };
|
2104
|
-
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|