@veloceapps/sdk 7.0.2-72 → 7.0.2-73
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/components/preview/preview.component.d.ts +6 -9
- package/cms/components/preview/preview.types.d.ts +5 -0
- package/cms/services/resources.service.d.ts +9 -0
- package/cms/vendor-map.d.ts +2 -1
- package/core/modules/configuration/index.d.ts +1 -0
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +4 -3
- package/core/modules/configuration/services/configuration.service.d.ts +6 -4
- package/core/modules/configuration/services/configuration.state.d.ts +30 -0
- package/core/modules/configuration/services/runtime-context.service.d.ts +1 -1
- package/core/types/runtime.types.d.ts +2 -2
- package/esm2020/cms/components/preview/preview.component.mjs +17 -37
- package/esm2020/cms/components/preview/preview.types.mjs +1 -1
- package/esm2020/cms/services/resources.service.mjs +19 -1
- package/esm2020/cms/vendor-map.mjs +3 -2
- package/esm2020/core/modules/configuration/configuration.module.mjs +4 -1
- package/esm2020/core/modules/configuration/index.mjs +2 -1
- package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +27 -19
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +41 -29
- package/esm2020/core/modules/configuration/services/configuration.state.mjs +142 -0
- package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +10 -11
- package/esm2020/core/services/quote-draft.service.mjs +1 -1
- package/esm2020/core/types/runtime.types.mjs +1 -1
- package/esm2020/src/components/doc-gen/doc-gen.component.mjs +1 -1
- package/esm2020/src/components/guided-selling/guided-selling.component.mjs +1 -1
- package/esm2020/src/pages/assets/assets.component.mjs +1 -1
- package/esm2020/src/pages/catalog/catalog.component.mjs +1 -1
- package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +4 -4
- package/esm2020/src/pages/product/product.component.mjs +50 -66
- package/esm2020/src/pages/remote/remote.component.mjs +19 -19
- package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +1 -1
- package/esm2020/src/types/flow-customization.types.mjs +1 -1
- package/fesm2015/veloceapps-sdk-cms.mjs +44 -43
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +214 -59
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk.mjs +67 -80
- package/fesm2015/veloceapps-sdk.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +42 -43
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +206 -55
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk.mjs +64 -76
- package/fesm2020/veloceapps-sdk.mjs.map +1 -1
- package/package.json +1 -1
- package/src/pages/product/product.component.d.ts +10 -21
- package/src/pages/remote/remote.component.d.ts +3 -4
- package/src/types/flow-customization.types.d.ts +3 -3
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
|
|
3
|
-
import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, getSupportedDateFormats, DEFAULT_DECIMALS_COUNT, parseJsonSafely, formatNumber } from '@veloceapps/core';
|
|
4
|
-
import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1,
|
|
3
|
+
import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, getUIDefinitionProperties, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, getSupportedDateFormats, DEFAULT_DECIMALS_COUNT, parseJsonSafely, formatNumber } from '@veloceapps/core';
|
|
4
|
+
import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, switchMap as switchMap$1, of, tap as tap$1, map as map$2, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
|
|
5
5
|
import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
|
|
6
6
|
import * as i1 from '@veloceapps/api';
|
|
7
7
|
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
|
8
8
|
import { merge, flatten, sortBy, map as map$1, isEqual, transform, omit, cloneDeep, uniq } from 'lodash';
|
|
9
9
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
10
|
+
import * as i4 from '@veloceapps/components';
|
|
10
11
|
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
|
11
12
|
import * as i5 from 'primeng/api';
|
|
12
13
|
import * as i6 from 'primeng/dynamicdialog';
|
|
@@ -125,31 +126,30 @@ class RuntimeContextService {
|
|
|
125
126
|
}
|
|
126
127
|
getRuntimeContext(productId, offeringId) {
|
|
127
128
|
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
|
|
128
|
-
var _a
|
|
129
|
-
const
|
|
129
|
+
var _a;
|
|
130
|
+
const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
|
|
130
131
|
const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
|
|
131
132
|
const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
|
|
133
|
+
const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
|
|
132
134
|
return {
|
|
133
135
|
modelId: runtimeData.modelId,
|
|
134
|
-
|
|
136
|
+
uiDefinitionContainer: uiDefinitionContainer,
|
|
135
137
|
runtimeModel: runtimeModel,
|
|
136
138
|
runtimeMode: RuntimeMode.PROD,
|
|
137
139
|
productId: productId,
|
|
138
140
|
productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
|
|
139
141
|
offeringId: offeringId,
|
|
140
142
|
properties: {
|
|
141
|
-
PricingEnabled:
|
|
142
|
-
PriceListId:
|
|
143
|
+
PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
|
|
144
|
+
PriceListId: uiDefinitionProperties.priceList,
|
|
143
145
|
},
|
|
144
146
|
};
|
|
145
147
|
}));
|
|
146
148
|
}
|
|
147
|
-
|
|
149
|
+
getUIDefinitionContainer(runtimeData) {
|
|
148
150
|
var _a;
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
.filter((uiDefinition) => !isLegacyUIDefinition(uiDefinition));
|
|
152
|
-
return (_a = uiDefinitions.find(uiDef => uiDef.primary)) !== null && _a !== void 0 ? _a : uiDefinitions[0];
|
|
151
|
+
const containers = runtimeData.uiDefinitions.filter(container => !isLegacyUIDefinition(container.source));
|
|
152
|
+
return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -172,43 +172,51 @@ class ConfigurationRuntimeService {
|
|
|
172
172
|
this.initializationProps = undefined;
|
|
173
173
|
this.uiDefinitionProperties = {};
|
|
174
174
|
}
|
|
175
|
-
initTestMode(
|
|
176
|
-
var _a
|
|
177
|
-
this.uiDefinitionProperties = (
|
|
178
|
-
const uiDefinitionExternals = (
|
|
175
|
+
initTestMode(uiDefinitionContainer) {
|
|
176
|
+
var _a;
|
|
177
|
+
this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
|
|
178
|
+
const uiDefinitionExternals = (_a = uiDefinitionContainer.source.externals) !== null && _a !== void 0 ? _a : {};
|
|
179
179
|
return combineLatest([
|
|
180
|
-
this.apiService.getRuntimeDataByModelId(modelId),
|
|
180
|
+
this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
|
|
181
181
|
this.contextService.create('TestId', ConfigurationContextMode.TEST),
|
|
182
|
-
]).pipe(first(),
|
|
182
|
+
]).pipe(first(), map(([runtimeData, context]) => {
|
|
183
183
|
var _a;
|
|
184
|
+
this.contextService.update({
|
|
185
|
+
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: uiDefinitionContainer.modelId, RuntimeMode: ConfigurationContextMode.TEST, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: this.uiDefinitionProperties.priceList, offeringId: this.uiDefinitionProperties.offeringId, standalone: 'true' }), uiDefinitionExternals),
|
|
186
|
+
});
|
|
184
187
|
this._runtimeContext = {
|
|
185
|
-
modelId: modelId,
|
|
188
|
+
modelId: uiDefinitionContainer.modelId,
|
|
186
189
|
runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
|
|
187
190
|
runtimeMode: RuntimeMode.TEST,
|
|
191
|
+
uiDefinitionContainer,
|
|
188
192
|
};
|
|
189
|
-
this.
|
|
190
|
-
|
|
191
|
-
});
|
|
192
|
-
this._isInitialized = true;
|
|
193
|
-
}));
|
|
193
|
+
return this._runtimeContext;
|
|
194
|
+
}), tap(() => (this._isInitialized = true)));
|
|
194
195
|
}
|
|
195
196
|
init(props) {
|
|
196
197
|
this.initializationProps = props;
|
|
197
198
|
const context = this.contextService.resolve();
|
|
198
199
|
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
|
|
199
|
-
var _a, _b
|
|
200
|
-
this.uiDefinitionProperties = (
|
|
201
|
-
const { PriceListId } = (
|
|
200
|
+
var _a, _b;
|
|
201
|
+
this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
|
|
202
|
+
const { PriceListId } = (_a = context.properties) !== null && _a !== void 0 ? _a : {};
|
|
202
203
|
const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
|
203
204
|
this.id15to18('AccountId', mergeContext.properties);
|
|
204
205
|
this._runtimeContext = mergeContext;
|
|
205
|
-
if (context.properties && ((
|
|
206
|
+
if (context.properties && ((_b = this._runtimeContext.properties) === null || _b === void 0 ? void 0 : _b.StartDate)) {
|
|
206
207
|
this.contextService.update({
|
|
207
208
|
properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
|
|
208
209
|
});
|
|
209
210
|
}
|
|
210
|
-
this.
|
|
211
|
-
}));
|
|
211
|
+
return this._runtimeContext;
|
|
212
|
+
}), tap(() => (this._isInitialized = true)));
|
|
213
|
+
}
|
|
214
|
+
overrideUIDefinition(uiDefinitionContainer) {
|
|
215
|
+
if (!this._runtimeContext) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
|
|
219
|
+
this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
|
|
212
220
|
}
|
|
213
221
|
id15to18(propertyName, source) {
|
|
214
222
|
if (!source) {
|
|
@@ -708,10 +716,18 @@ class ConfigurationService {
|
|
|
708
716
|
return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
|
|
709
717
|
}
|
|
710
718
|
getRuntimeModel() {
|
|
711
|
-
|
|
719
|
+
const runtimeModel = this.runtimeService.runtimeModel;
|
|
720
|
+
if (!runtimeModel) {
|
|
721
|
+
throw new Error('Runtime model not initialized');
|
|
722
|
+
}
|
|
723
|
+
return runtimeModel;
|
|
712
724
|
}
|
|
713
725
|
getRuntimeContext() {
|
|
714
|
-
|
|
726
|
+
const runtimeContext = this.runtimeService.runtimeContext;
|
|
727
|
+
if (!runtimeContext) {
|
|
728
|
+
throw new Error('Runtime context not initialized');
|
|
729
|
+
}
|
|
730
|
+
return runtimeContext;
|
|
715
731
|
}
|
|
716
732
|
get contextSnapshot() {
|
|
717
733
|
return this.contextService.resolve();
|
|
@@ -732,38 +748,27 @@ class ConfigurationService {
|
|
|
732
748
|
return this.pricePlans.value;
|
|
733
749
|
}
|
|
734
750
|
configure() {
|
|
735
|
-
|
|
751
|
+
return this.configureRequest$(this.generateRequest());
|
|
752
|
+
}
|
|
753
|
+
configureRequest$(configurationRequest) {
|
|
754
|
+
var _a;
|
|
736
755
|
const runtimeContext = this.getRuntimeContext();
|
|
737
756
|
const runtimeModel = this.getRuntimeModel();
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
const uiDefinitionProperties = Object.assign(Object.assign({}, ((_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
|
|
742
|
-
let lineItem = this.configurableRamp;
|
|
743
|
-
if (!lineItem) {
|
|
744
|
-
const { initializationProps } = (_d = this.runtimeService) !== null && _d !== void 0 ? _d : {};
|
|
745
|
-
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
|
746
|
-
// Set default attributes
|
|
747
|
-
if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
|
|
748
|
-
const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
|
749
|
-
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
const configurationRequest = this.createRequest(lineItem);
|
|
753
|
-
const mainPricingEnabled = (_e = runtimeContext.properties) === null || _e === void 0 ? void 0 : _e.PricingEnabled;
|
|
757
|
+
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
758
|
+
const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
|
|
754
759
|
const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
|
755
|
-
return this.configurationApiService
|
|
756
|
-
.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
|
|
757
|
-
.pipe(map(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
|
|
760
|
+
return this.configurationApiService.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled }).pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
|
|
758
761
|
this.contextService.update(context !== null && context !== void 0 ? context : {});
|
|
759
762
|
this.charges.next(charges !== null && charges !== void 0 ? charges : {});
|
|
760
763
|
this.pricePlans.next(pricePlans !== null && pricePlans !== void 0 ? pricePlans : {});
|
|
764
|
+
if (lineItem) {
|
|
765
|
+
this.lineItem.next(lineItem);
|
|
766
|
+
}
|
|
761
767
|
if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
|
|
762
768
|
this.showInactiveProductsConfirmation();
|
|
763
769
|
}
|
|
764
|
-
|
|
765
|
-
}))
|
|
766
|
-
.pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
|
|
770
|
+
this.configurableRamp = lineItem;
|
|
771
|
+
}), map(({ lineItem }) => lineItem), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
|
|
767
772
|
}
|
|
768
773
|
configureExternal$(props) {
|
|
769
774
|
return this.runtimeService
|
|
@@ -785,20 +790,36 @@ class ConfigurationService {
|
|
|
785
790
|
throw error;
|
|
786
791
|
}));
|
|
787
792
|
}
|
|
788
|
-
|
|
789
|
-
var _a;
|
|
793
|
+
generateRequest() {
|
|
794
|
+
var _a, _b;
|
|
795
|
+
const runtimeContext = this.getRuntimeContext();
|
|
796
|
+
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
|
797
|
+
let lineItem = this.configurableRamp;
|
|
798
|
+
if (!lineItem) {
|
|
799
|
+
const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
|
|
800
|
+
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
|
|
801
|
+
// Set default attributes
|
|
802
|
+
if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
|
|
803
|
+
const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
|
|
804
|
+
lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
790
807
|
let request = {
|
|
791
808
|
lineItem,
|
|
792
809
|
mode: this.mode,
|
|
793
810
|
step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
|
|
794
811
|
attributeDomainMode: 'ALL',
|
|
795
812
|
context: this.contextService.resolve(),
|
|
796
|
-
lineItems: ((
|
|
813
|
+
lineItems: ((_b = this.quoteDraftService.quoteDraft) === null || _b === void 0 ? void 0 : _b.currentState) || [],
|
|
797
814
|
asset: this.getAsset(),
|
|
798
815
|
};
|
|
799
816
|
request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
|
800
817
|
return request;
|
|
801
818
|
}
|
|
819
|
+
getUIDefinitionProperties() {
|
|
820
|
+
var _a;
|
|
821
|
+
return Object.assign(Object.assign({}, getUIDefinitionProperties(this.getRuntimeContext().uiDefinitionContainer)), ((_a = this.runtimeService.uiDefinitionProperties) !== null && _a !== void 0 ? _a : {}));
|
|
822
|
+
}
|
|
802
823
|
showInactiveProductsConfirmation() {
|
|
803
824
|
const confirmationConfig = {
|
|
804
825
|
title: ' ',
|
|
@@ -838,6 +859,138 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
838
859
|
type: Injectable
|
|
839
860
|
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
|
|
840
861
|
|
|
862
|
+
class ConfigurationState {
|
|
863
|
+
constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
|
|
864
|
+
this.statefulConfigurationApiService = statefulConfigurationApiService;
|
|
865
|
+
this.runtimeService = runtimeService;
|
|
866
|
+
this.configurationService = configurationService;
|
|
867
|
+
this.toastService = toastService;
|
|
868
|
+
this.stateSubj$ = new BehaviorSubject({});
|
|
869
|
+
this.state$ = this.stateSubj$.asObservable();
|
|
870
|
+
this.stateId = null;
|
|
871
|
+
}
|
|
872
|
+
init$() {
|
|
873
|
+
return this.configurationService.configure().pipe(switchMap$1(() => {
|
|
874
|
+
var _a, _b;
|
|
875
|
+
if (!this.isStatefulConfiguration) {
|
|
876
|
+
return of(undefined);
|
|
877
|
+
}
|
|
878
|
+
const { actions, selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
|
879
|
+
return this.statefulConfigurationApiService.init({
|
|
880
|
+
request: this.configurationService.generateRequest(),
|
|
881
|
+
actions: actions === null || actions === void 0 ? void 0 : actions.map(action => ({ name: action.apiName, script: action.script })),
|
|
882
|
+
selectors: selectors === null || selectors === void 0 ? void 0 : selectors.map(selector => ({ name: selector.apiName, script: selector.script })),
|
|
883
|
+
});
|
|
884
|
+
}), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
|
|
885
|
+
}
|
|
886
|
+
cleanup() {
|
|
887
|
+
this.stateId = null;
|
|
888
|
+
this.configurationService.reset();
|
|
889
|
+
this.stateSubj$.next({});
|
|
890
|
+
}
|
|
891
|
+
execute$(req) {
|
|
892
|
+
if (this.isStatefulConfiguration) {
|
|
893
|
+
return this.executeStateful$(req);
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
return this.executeStateless$(req);
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
dispatch$(actionName, inputData) {
|
|
900
|
+
return this.execute$({ actions: [{ name: actionName, inputData }] });
|
|
901
|
+
}
|
|
902
|
+
select$(selectorName, inputData) {
|
|
903
|
+
const requestId = UUID.UUID();
|
|
904
|
+
return this.execute$({
|
|
905
|
+
selectors: {
|
|
906
|
+
[requestId]: {
|
|
907
|
+
name: selectorName,
|
|
908
|
+
inputData,
|
|
909
|
+
},
|
|
910
|
+
},
|
|
911
|
+
}).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
|
|
912
|
+
}
|
|
913
|
+
get isStatefulConfiguration() {
|
|
914
|
+
var _a;
|
|
915
|
+
return (_a = this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled) !== null && _a !== void 0 ? _a : false;
|
|
916
|
+
}
|
|
917
|
+
executeStateless$(request) {
|
|
918
|
+
return of(undefined).pipe(switchMap$1(() => {
|
|
919
|
+
var _a;
|
|
920
|
+
// Apply actions and execute configuration/price call
|
|
921
|
+
// No need to run configuration if no actions in the request
|
|
922
|
+
if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
923
|
+
return of(undefined);
|
|
924
|
+
}
|
|
925
|
+
let configurationRequest = this.configurationService.generateRequest();
|
|
926
|
+
request.actions.forEach(action => {
|
|
927
|
+
var _a;
|
|
928
|
+
configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
|
|
929
|
+
});
|
|
930
|
+
return this.configurationService.configureRequest$(configurationRequest);
|
|
931
|
+
}), tap$1(() => {
|
|
932
|
+
if (!request.selectors) {
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
935
|
+
// Run selectors and apply them to the state
|
|
936
|
+
const finalConfigurationRequest = this.configurationService.generateRequest();
|
|
937
|
+
const selectorsResult = EntityUtil.entries(request.selectors).reduce((trunk, [key, selector]) => {
|
|
938
|
+
trunk[key] = this.executeSelectorScript(finalConfigurationRequest, selector);
|
|
939
|
+
return trunk;
|
|
940
|
+
}, {});
|
|
941
|
+
this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.value), selectorsResult));
|
|
942
|
+
}), map$2(() => undefined));
|
|
943
|
+
}
|
|
944
|
+
executeStateful$(request) {
|
|
945
|
+
if (!this.stateId) {
|
|
946
|
+
return of(undefined);
|
|
947
|
+
}
|
|
948
|
+
return this.statefulConfigurationApiService.execute(this.stateId, request).pipe(tap$1(response => {
|
|
949
|
+
this.stateId = response.stateId;
|
|
950
|
+
const updatedState = this.stateSubj$.value;
|
|
951
|
+
EntityUtil.entries(response.selectors).forEach(([key, value]) => {
|
|
952
|
+
if (!value.success) {
|
|
953
|
+
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
|
954
|
+
this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
|
|
955
|
+
}
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
updatedState[key] = value.result;
|
|
959
|
+
});
|
|
960
|
+
this.stateSubj$.next(updatedState);
|
|
961
|
+
}), map$2(() => undefined));
|
|
962
|
+
}
|
|
963
|
+
executeActionScript(request, processor) {
|
|
964
|
+
var _a, _b, _c;
|
|
965
|
+
const { actions } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
|
966
|
+
const script = (_c = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
|
|
967
|
+
if (!script) {
|
|
968
|
+
return null;
|
|
969
|
+
}
|
|
970
|
+
return this.executeProcessorScript(request, script, processor.inputData);
|
|
971
|
+
}
|
|
972
|
+
executeSelectorScript(request, processor) {
|
|
973
|
+
var _a, _b, _c;
|
|
974
|
+
const { selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
|
|
975
|
+
const script = (_c = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
|
|
976
|
+
if (!script) {
|
|
977
|
+
return null;
|
|
978
|
+
}
|
|
979
|
+
return this.executeProcessorScript(request, script, processor.inputData);
|
|
980
|
+
}
|
|
981
|
+
executeProcessorScript(request, script, inputData) {
|
|
982
|
+
return new Function(`${script}\nreturn transform;`)()({
|
|
983
|
+
request,
|
|
984
|
+
inputData: inputData,
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i4.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
989
|
+
ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState });
|
|
990
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, decorators: [{
|
|
991
|
+
type: Injectable
|
|
992
|
+
}], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
|
|
993
|
+
|
|
841
994
|
function extractMetadata(uiDefinition) {
|
|
842
995
|
return omit(uiDefinition, [
|
|
843
996
|
'children',
|
|
@@ -1133,6 +1286,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
|
|
|
1133
1286
|
ConfigurationRuntimeService,
|
|
1134
1287
|
RuntimeContextService,
|
|
1135
1288
|
ConfigurationService,
|
|
1289
|
+
ConfigurationState,
|
|
1136
1290
|
], imports: [ConfirmationDialogModule] });
|
|
1137
1291
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
|
|
1138
1292
|
type: NgModule,
|
|
@@ -1145,6 +1299,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
1145
1299
|
ConfigurationRuntimeService,
|
|
1146
1300
|
RuntimeContextService,
|
|
1147
1301
|
ConfigurationService,
|
|
1302
|
+
ConfigurationState,
|
|
1148
1303
|
],
|
|
1149
1304
|
}]
|
|
1150
1305
|
}] });
|
|
@@ -1566,5 +1721,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
1566
1721
|
* Generated bundle index. Do not edit.
|
|
1567
1722
|
*/
|
|
1568
1723
|
|
|
1569
|
-
export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
|
1724
|
+
export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
|
|
1570
1725
|
//# sourceMappingURL=veloceapps-sdk-core.mjs.map
|