@veloceapps/sdk 10.0.0-5 → 10.0.0-50
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/modules/runtime/services/runtime.service.d.ts +3 -1
- package/cms/utils/index.d.ts +1 -0
- package/cms/utils/inject.d.ts +1 -0
- package/cms/utils/ui-definition.utils.d.ts +1 -0
- package/cms/vendor-map.d.ts +4 -2
- package/core/modules/configuration/services/configuration-state.service.d.ts +2 -0
- package/core/modules/configuration/services/configuration.service.d.ts +2 -0
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +4 -1
- package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -2
- package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
- package/esm2020/cms/modules/runtime/services/runtime.service.mjs +3 -1
- package/esm2020/cms/utils/index.mjs +2 -1
- package/esm2020/cms/utils/inject.mjs +27 -0
- package/esm2020/cms/utils/ui-definition.utils.mjs +13 -1
- package/esm2020/cms/vendor-map.mjs +7 -4
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +38 -22
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +13 -2
- package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +16 -5
- package/esm2020/core/services/flow-state.service.mjs +5 -5
- package/fesm2015/veloceapps-sdk-cms.mjs +45 -5
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +67 -30
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +44 -4
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +65 -29
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -652,8 +652,8 @@ class FlowStateService {
|
|
652
652
|
else {
|
653
653
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
654
654
|
if (quoteDraft) {
|
655
|
-
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({
|
656
|
-
this.contextService.update({ properties: {
|
655
|
+
return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
|
656
|
+
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
657
657
|
}));
|
658
658
|
}
|
659
659
|
}
|
@@ -668,8 +668,8 @@ class FlowStateService {
|
|
668
668
|
else {
|
669
669
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
670
670
|
if (quoteDraft) {
|
671
|
-
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({
|
672
|
-
this.contextService.update({ properties: {
|
671
|
+
return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
|
672
|
+
this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
|
673
673
|
}));
|
674
674
|
}
|
675
675
|
}
|
@@ -1333,6 +1333,7 @@ class ConfigurationService {
|
|
1333
1333
|
this.runtimeSettings = runtimeSettings;
|
1334
1334
|
this.mode = ConfigurationMode.SEARCH;
|
1335
1335
|
this.configurationState = new BehaviorSubject(null);
|
1336
|
+
this.previousConfigurationState = new BehaviorSubject(null);
|
1336
1337
|
this.isLoadingSubj$ = new BehaviorSubject(false);
|
1337
1338
|
this.isLoading$ = this.isLoadingSubj$.asObservable();
|
1338
1339
|
this.hasUnsavedChanges = false;
|
@@ -1342,6 +1343,7 @@ class ConfigurationService {
|
|
1342
1343
|
this.runtimeService.reset();
|
1343
1344
|
this.configurableRamp = undefined;
|
1344
1345
|
this.configurationState.next(null);
|
1346
|
+
this.previousConfigurationState.next(null);
|
1345
1347
|
}
|
1346
1348
|
patch$(lineItem, options) {
|
1347
1349
|
const source = this.getSnapshot();
|
@@ -1397,6 +1399,9 @@ class ConfigurationService {
|
|
1397
1399
|
get stateSnapshot() {
|
1398
1400
|
return this.configurationState.value;
|
1399
1401
|
}
|
1402
|
+
get previousStateSnapshot() {
|
1403
|
+
return this.previousConfigurationState.value;
|
1404
|
+
}
|
1400
1405
|
get contextSnapshot() {
|
1401
1406
|
return this.contextService.resolve();
|
1402
1407
|
}
|
@@ -1442,11 +1447,17 @@ class ConfigurationService {
|
|
1442
1447
|
return configure$.pipe(tap(result => {
|
1443
1448
|
this.contextService.update(result.context);
|
1444
1449
|
this.configurationState.next(result);
|
1450
|
+
this.previousConfigurationState.next(cloneDeep(result));
|
1445
1451
|
if (result.deletedLineItems?.length) {
|
1446
1452
|
this.showInactiveProductsConfirmation();
|
1447
1453
|
}
|
1448
1454
|
this.configurableRamp = result.lineItem;
|
1449
1455
|
}), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
|
1456
|
+
const resetState = this.previousConfigurationState.value;
|
1457
|
+
if (resetState) {
|
1458
|
+
this.previousConfigurationState.next(cloneDeep(resetState));
|
1459
|
+
this.configurationState.next(resetState);
|
1460
|
+
}
|
1450
1461
|
if (error.error) {
|
1451
1462
|
return extractErrorDetails(error.error).join('. ');
|
1452
1463
|
}
|
@@ -1492,7 +1503,7 @@ class ConfigurationService {
|
|
1492
1503
|
generateLineItem() {
|
1493
1504
|
const runtimeContext = this.getRuntimeContext();
|
1494
1505
|
const uiDefinitionProperties = this.getUIDefinitionProperties();
|
1495
|
-
let lineItem =
|
1506
|
+
let lineItem = this.configurableRamp;
|
1496
1507
|
if (!lineItem) {
|
1497
1508
|
const { initializationProps } = this.runtimeService ?? {};
|
1498
1509
|
lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
|
@@ -1682,17 +1693,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
|
|
1682
1693
|
}] });
|
1683
1694
|
|
1684
1695
|
class FlowConfigurationService {
|
1685
|
-
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
|
1696
|
+
constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
|
1686
1697
|
this.proceduresApiService = proceduresApiService;
|
1687
1698
|
this.contextService = contextService;
|
1688
1699
|
this.quoteDraftService = quoteDraftService;
|
1689
1700
|
this.updateService = updateService;
|
1690
1701
|
this.configurationService = configurationService;
|
1702
|
+
this.flowInfoService = flowInfoService;
|
1691
1703
|
this.updatedSubj$ = new Subject();
|
1692
1704
|
this.updated$ = this.updatedSubj$.asObservable();
|
1693
1705
|
}
|
1694
1706
|
calculate$(quoteDraft) {
|
1695
|
-
return this.
|
1707
|
+
return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
|
1696
1708
|
// sort the result current state based on the quote draft initial state
|
1697
1709
|
const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
|
1698
1710
|
result.currentState = result.currentState
|
@@ -1812,12 +1824,20 @@ class FlowConfigurationService {
|
|
1812
1824
|
}));
|
1813
1825
|
};
|
1814
1826
|
}
|
1827
|
+
extendedApply$(quoteDraft) {
|
1828
|
+
const request = { ...quoteDraft };
|
1829
|
+
const procedureName = this.flowInfoService.flow?.properties.procedureName;
|
1830
|
+
if (procedureName) {
|
1831
|
+
request.procedureName = procedureName;
|
1832
|
+
}
|
1833
|
+
return this.proceduresApiService.apply$(request);
|
1834
|
+
}
|
1815
1835
|
}
|
1816
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1836
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1817
1837
|
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
|
1818
1838
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
1819
1839
|
type: Injectable
|
1820
|
-
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1840
|
+
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
|
1821
1841
|
|
1822
1842
|
class FlowConfigurationModule {
|
1823
1843
|
}
|
@@ -2089,6 +2109,7 @@ class ConfigurationStateService {
|
|
2089
2109
|
this.configurationStore = {};
|
2090
2110
|
this.executionInProgress$ = new BehaviorSubject(false);
|
2091
2111
|
this.statefulRequestStream$ = new Subject();
|
2112
|
+
this.statelessExecutionRequest$ = null;
|
2092
2113
|
this.statefulExecutionRequest$ = this.initBufferedRequest$();
|
2093
2114
|
}
|
2094
2115
|
get isExecutionInProgress$() {
|
@@ -2135,7 +2156,15 @@ class ConfigurationStateService {
|
|
2135
2156
|
actions: [{ name: actionName, inputData }],
|
2136
2157
|
};
|
2137
2158
|
const request = this.execToRequest(exec);
|
2138
|
-
|
2159
|
+
const executionRequest$ = this.executeRequest$(request);
|
2160
|
+
if (this.isStatefulConfiguration) {
|
2161
|
+
return executionRequest$;
|
2162
|
+
}
|
2163
|
+
// prevent parallel configuration requests in stateless mode
|
2164
|
+
if (!this.statelessExecutionRequest$) {
|
2165
|
+
this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay$1(), take$1(1), finalize(() => (this.statelessExecutionRequest$ = null)));
|
2166
|
+
}
|
2167
|
+
return this.statelessExecutionRequest$;
|
2139
2168
|
}
|
2140
2169
|
select$(selectorName, inputData = {}) {
|
2141
2170
|
const requestId = UUID.UUID();
|
@@ -2318,7 +2347,7 @@ class ConfigurationStateService {
|
|
2318
2347
|
if (!request.actions?.length) {
|
2319
2348
|
return of(undefined);
|
2320
2349
|
}
|
2321
|
-
let configurationRequest = this.configurationService.generateRequest();
|
2350
|
+
let configurationRequest = this.configurationService.generateRequest(false);
|
2322
2351
|
request.actions.forEach(action => {
|
2323
2352
|
configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
|
2324
2353
|
});
|
@@ -2326,28 +2355,17 @@ class ConfigurationStateService {
|
|
2326
2355
|
return this.configurationService.configureRequest$(configurationRequest);
|
2327
2356
|
}), map$1(() => {
|
2328
2357
|
// Run selectors and apply them to the state
|
2329
|
-
const configurationState =
|
2358
|
+
const configurationState = this.configurationService.stateSnapshot;
|
2330
2359
|
if (!configurationState) {
|
2331
2360
|
return { stateId: '', selectors: {} };
|
2332
2361
|
}
|
2333
|
-
|
2334
|
-
try {
|
2335
|
-
result.selectors[key] = {
|
2336
|
-
success: true,
|
2337
|
-
result: this.executeSelectorScript(configurationState, selector),
|
2338
|
-
};
|
2339
|
-
}
|
2340
|
-
catch (e) {
|
2341
|
-
console.error(e);
|
2342
|
-
result.selectors[key] = {
|
2343
|
-
success: false,
|
2344
|
-
errorMessage: String(e),
|
2345
|
-
};
|
2346
|
-
}
|
2347
|
-
return result;
|
2348
|
-
}, { stateId: '', selectors: {} });
|
2349
|
-
return selectorsResult;
|
2362
|
+
return this.runStatelessSelectors(request, configurationState);
|
2350
2363
|
}), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
|
2364
|
+
const configurationState = this.configurationService.previousStateSnapshot;
|
2365
|
+
if (configurationState) {
|
2366
|
+
const selectorsResult = this.runStatelessSelectors(request, configurationState);
|
2367
|
+
this.handleSelectorsResponse(selectorsResult.selectors);
|
2368
|
+
}
|
2351
2369
|
this.executionInProgress$.next(false);
|
2352
2370
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2353
2371
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
@@ -2414,6 +2432,24 @@ class ConfigurationStateService {
|
|
2414
2432
|
configurationStore: this.configurationStore,
|
2415
2433
|
});
|
2416
2434
|
}
|
2435
|
+
runStatelessSelectors(request, configurationState) {
|
2436
|
+
return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
|
2437
|
+
try {
|
2438
|
+
result.selectors[key] = {
|
2439
|
+
success: true,
|
2440
|
+
result: this.executeSelectorScript(configurationState, selector),
|
2441
|
+
};
|
2442
|
+
}
|
2443
|
+
catch (e) {
|
2444
|
+
console.error(e);
|
2445
|
+
result.selectors[key] = {
|
2446
|
+
success: false,
|
2447
|
+
errorMessage: String(e),
|
2448
|
+
};
|
2449
|
+
}
|
2450
|
+
return result;
|
2451
|
+
}, { stateId: '', selectors: {} });
|
2452
|
+
}
|
2417
2453
|
}
|
2418
2454
|
ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
2419
2455
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|