@veloceapps/sdk 10.0.0-8 → 11.0.0-0
Sign up to get free protection for your applications and to get access to all the features.
- package/cms/vendor-map.d.ts +3 -2
- package/core/modules/configuration/services/configuration-state.service.d.ts +1 -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-tools-panel/element-tools-panel.component.mjs +3 -3
- package/esm2020/cms/vendor-map.mjs +5 -4
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +29 -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 +4 -3
- package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +57 -29
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-cms.mjs +4 -3
- package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +55 -28
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +4 -4
@@ -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: { VELOCE_PRISM__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: { VELOCE_PRISM__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
|
}
|
@@ -2327,7 +2347,7 @@ class ConfigurationStateService {
|
|
2327
2347
|
if (!request.actions?.length) {
|
2328
2348
|
return of(undefined);
|
2329
2349
|
}
|
2330
|
-
let configurationRequest = this.configurationService.generateRequest();
|
2350
|
+
let configurationRequest = this.configurationService.generateRequest(false);
|
2331
2351
|
request.actions.forEach(action => {
|
2332
2352
|
configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
|
2333
2353
|
});
|
@@ -2335,28 +2355,17 @@ class ConfigurationStateService {
|
|
2335
2355
|
return this.configurationService.configureRequest$(configurationRequest);
|
2336
2356
|
}), map$1(() => {
|
2337
2357
|
// Run selectors and apply them to the state
|
2338
|
-
const configurationState =
|
2358
|
+
const configurationState = this.configurationService.stateSnapshot;
|
2339
2359
|
if (!configurationState) {
|
2340
2360
|
return { stateId: '', selectors: {} };
|
2341
2361
|
}
|
2342
|
-
|
2343
|
-
try {
|
2344
|
-
result.selectors[key] = {
|
2345
|
-
success: true,
|
2346
|
-
result: this.executeSelectorScript(configurationState, selector),
|
2347
|
-
};
|
2348
|
-
}
|
2349
|
-
catch (e) {
|
2350
|
-
console.error(e);
|
2351
|
-
result.selectors[key] = {
|
2352
|
-
success: false,
|
2353
|
-
errorMessage: String(e),
|
2354
|
-
};
|
2355
|
-
}
|
2356
|
-
return result;
|
2357
|
-
}, { stateId: '', selectors: {} });
|
2358
|
-
return selectorsResult;
|
2362
|
+
return this.runStatelessSelectors(request, configurationState);
|
2359
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
|
+
}
|
2360
2369
|
this.executionInProgress$.next(false);
|
2361
2370
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2362
2371
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
@@ -2423,6 +2432,24 @@ class ConfigurationStateService {
|
|
2423
2432
|
configurationStore: this.configurationStore,
|
2424
2433
|
});
|
2425
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
|
+
}
|
2426
2453
|
}
|
2427
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 });
|
2428
2455
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|