@veloceapps/sdk 10.0.0-9 → 11.0.0-0

Sign up to get free protection for your applications and to get access to all the features.
@@ -617,8 +617,8 @@ class FlowStateService {
617
617
  else {
618
618
  const quoteDraft = this.quoteDraftService.quoteDraft;
619
619
  if (quoteDraft) {
620
- return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
621
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
620
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
621
+ this.contextService.update({ properties: { VELOCE_PRISM__VersionId__c: versionId } });
622
622
  }));
623
623
  }
624
624
  }
@@ -633,8 +633,8 @@ class FlowStateService {
633
633
  else {
634
634
  const quoteDraft = this.quoteDraftService.quoteDraft;
635
635
  if (quoteDraft) {
636
- return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
637
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
636
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
637
+ this.contextService.update({ properties: { VELOCE_PRISM__VersionId__c: versionId } });
638
638
  }));
639
639
  }
640
640
  }
@@ -1434,6 +1434,7 @@ class ConfigurationService {
1434
1434
  this.runtimeSettings = runtimeSettings;
1435
1435
  this.mode = ConfigurationMode.SEARCH;
1436
1436
  this.configurationState = new BehaviorSubject(null);
1437
+ this.previousConfigurationState = new BehaviorSubject(null);
1437
1438
  this.isLoadingSubj$ = new BehaviorSubject(false);
1438
1439
  this.isLoading$ = this.isLoadingSubj$.asObservable();
1439
1440
  this.hasUnsavedChanges = false;
@@ -1443,6 +1444,7 @@ class ConfigurationService {
1443
1444
  this.runtimeService.reset();
1444
1445
  this.configurableRamp = undefined;
1445
1446
  this.configurationState.next(null);
1447
+ this.previousConfigurationState.next(null);
1446
1448
  }
1447
1449
  patch$(lineItem, options) {
1448
1450
  const source = this.getSnapshot();
@@ -1499,6 +1501,9 @@ class ConfigurationService {
1499
1501
  get stateSnapshot() {
1500
1502
  return this.configurationState.value;
1501
1503
  }
1504
+ get previousStateSnapshot() {
1505
+ return this.previousConfigurationState.value;
1506
+ }
1502
1507
  get contextSnapshot() {
1503
1508
  return this.contextService.resolve();
1504
1509
  }
@@ -1549,11 +1554,17 @@ class ConfigurationService {
1549
1554
  var _a;
1550
1555
  this.contextService.update(result.context);
1551
1556
  this.configurationState.next(result);
1557
+ this.previousConfigurationState.next(cloneDeep(result));
1552
1558
  if ((_a = result.deletedLineItems) === null || _a === void 0 ? void 0 : _a.length) {
1553
1559
  this.showInactiveProductsConfirmation();
1554
1560
  }
1555
1561
  this.configurableRamp = result.lineItem;
1556
1562
  }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
1563
+ const resetState = this.previousConfigurationState.value;
1564
+ if (resetState) {
1565
+ this.previousConfigurationState.next(cloneDeep(resetState));
1566
+ this.configurationState.next(resetState);
1567
+ }
1557
1568
  if (error.error) {
1558
1569
  return extractErrorDetails(error.error).join('. ');
1559
1570
  }
@@ -1601,7 +1612,7 @@ class ConfigurationService {
1601
1612
  var _a;
1602
1613
  const runtimeContext = this.getRuntimeContext();
1603
1614
  const uiDefinitionProperties = this.getUIDefinitionProperties();
1604
- let lineItem = cloneDeep(this.configurableRamp);
1615
+ let lineItem = this.configurableRamp;
1605
1616
  if (!lineItem) {
1606
1617
  const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
1607
1618
  lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
@@ -1658,17 +1669,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1658
1669
  }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1659
1670
 
1660
1671
  class FlowConfigurationService {
1661
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1672
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
1662
1673
  this.proceduresApiService = proceduresApiService;
1663
1674
  this.contextService = contextService;
1664
1675
  this.quoteDraftService = quoteDraftService;
1665
1676
  this.updateService = updateService;
1666
1677
  this.configurationService = configurationService;
1678
+ this.flowInfoService = flowInfoService;
1667
1679
  this.updatedSubj$ = new Subject();
1668
1680
  this.updated$ = this.updatedSubj$.asObservable();
1669
1681
  }
1670
1682
  calculate$(quoteDraft) {
1671
- return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1683
+ return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
1672
1684
  // sort the result current state based on the quote draft initial state
1673
1685
  const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1674
1686
  result.currentState = result.currentState
@@ -1793,12 +1805,21 @@ class FlowConfigurationService {
1793
1805
  }));
1794
1806
  };
1795
1807
  }
1808
+ extendedApply$(quoteDraft) {
1809
+ var _a;
1810
+ const request = Object.assign({}, quoteDraft);
1811
+ const procedureName = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.procedureName;
1812
+ if (procedureName) {
1813
+ request.procedureName = procedureName;
1814
+ }
1815
+ return this.proceduresApiService.apply$(request);
1816
+ }
1796
1817
  }
1797
- 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 });
1818
+ 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 });
1798
1819
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1799
1820
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1800
1821
  type: Injectable
1801
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1822
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
1802
1823
 
1803
1824
  class FlowConfigurationModule {
1804
1825
  }
@@ -2311,7 +2332,7 @@ class ConfigurationStateService {
2311
2332
  if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
2312
2333
  return of(undefined);
2313
2334
  }
2314
- let configurationRequest = this.configurationService.generateRequest();
2335
+ let configurationRequest = this.configurationService.generateRequest(false);
2315
2336
  request.actions.forEach(action => {
2316
2337
  var _a;
2317
2338
  configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
@@ -2319,30 +2340,18 @@ class ConfigurationStateService {
2319
2340
  configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
2320
2341
  return this.configurationService.configureRequest$(configurationRequest);
2321
2342
  }), map$1(() => {
2322
- var _a;
2323
2343
  // Run selectors and apply them to the state
2324
- const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2344
+ const configurationState = this.configurationService.stateSnapshot;
2325
2345
  if (!configurationState) {
2326
2346
  return { stateId: '', selectors: {} };
2327
2347
  }
2328
- const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2329
- try {
2330
- result.selectors[key] = {
2331
- success: true,
2332
- result: this.executeSelectorScript(configurationState, selector),
2333
- };
2334
- }
2335
- catch (e) {
2336
- console.error(e);
2337
- result.selectors[key] = {
2338
- success: false,
2339
- errorMessage: String(e),
2340
- };
2341
- }
2342
- return result;
2343
- }, { stateId: '', selectors: {} });
2344
- return selectorsResult;
2348
+ return this.runStatelessSelectors(request, configurationState);
2345
2349
  }), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
2350
+ const configurationState = this.configurationService.previousStateSnapshot;
2351
+ if (configurationState) {
2352
+ const selectorsResult = this.runStatelessSelectors(request, configurationState);
2353
+ this.handleSelectorsResponse(selectorsResult.selectors);
2354
+ }
2346
2355
  this.executionInProgress$.next(false);
2347
2356
  if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
2348
2357
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
@@ -2411,6 +2420,25 @@ class ConfigurationStateService {
2411
2420
  configurationStore: this.configurationStore,
2412
2421
  });
2413
2422
  }
2423
+ runStatelessSelectors(request, configurationState) {
2424
+ var _a;
2425
+ return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2426
+ try {
2427
+ result.selectors[key] = {
2428
+ success: true,
2429
+ result: this.executeSelectorScript(configurationState, selector),
2430
+ };
2431
+ }
2432
+ catch (e) {
2433
+ console.error(e);
2434
+ result.selectors[key] = {
2435
+ success: false,
2436
+ errorMessage: String(e),
2437
+ };
2438
+ }
2439
+ return result;
2440
+ }, { stateId: '', selectors: {} });
2441
+ }
2414
2442
  }
2415
2443
  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 });
2416
2444
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });