@veloceapps/sdk 10.0.0-31 → 10.0.0-33
Sign up to get free protection for your applications and to get access to all the features.
- package/core/modules/configuration/services/configuration-state.service.d.ts +1 -0
- package/core/modules/configuration/services/configuration.service.d.ts +2 -0
- package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +26 -19
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +13 -2
- package/fesm2015/veloceapps-sdk-core.mjs +37 -19
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +36 -18
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -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
|
}
|
@@ -2336,7 +2347,7 @@ class ConfigurationStateService {
|
|
2336
2347
|
if (!request.actions?.length) {
|
2337
2348
|
return of(undefined);
|
2338
2349
|
}
|
2339
|
-
let configurationRequest = this.configurationService.generateRequest();
|
2350
|
+
let configurationRequest = this.configurationService.generateRequest(false);
|
2340
2351
|
request.actions.forEach(action => {
|
2341
2352
|
configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
|
2342
2353
|
});
|
@@ -2348,24 +2359,13 @@ class ConfigurationStateService {
|
|
2348
2359
|
if (!configurationState) {
|
2349
2360
|
return { stateId: '', selectors: {} };
|
2350
2361
|
}
|
2351
|
-
|
2352
|
-
try {
|
2353
|
-
result.selectors[key] = {
|
2354
|
-
success: true,
|
2355
|
-
result: this.executeSelectorScript(configurationState, selector),
|
2356
|
-
};
|
2357
|
-
}
|
2358
|
-
catch (e) {
|
2359
|
-
console.error(e);
|
2360
|
-
result.selectors[key] = {
|
2361
|
-
success: false,
|
2362
|
-
errorMessage: String(e),
|
2363
|
-
};
|
2364
|
-
}
|
2365
|
-
return result;
|
2366
|
-
}, { stateId: '', selectors: {} });
|
2367
|
-
return selectorsResult;
|
2362
|
+
return this.runStatelessSelectors(request, configurationState);
|
2368
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
|
+
}
|
2369
2369
|
this.executionInProgress$.next(false);
|
2370
2370
|
if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
|
2371
2371
|
this.toastService.add({ severity: ToastType.error, summary: String(error) });
|
@@ -2432,6 +2432,24 @@ class ConfigurationStateService {
|
|
2432
2432
|
configurationStore: this.configurationStore,
|
2433
2433
|
});
|
2434
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
|
+
}
|
2435
2453
|
}
|
2436
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 });
|
2437
2455
|
ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
|