@veloceapps/sdk 10.0.0-38 → 10.0.0-39

Sign up to get free protection for your applications and to get access to all the features.
@@ -766,8 +766,8 @@ class FlowStateService {
766
766
  else {
767
767
  const quoteDraft = this.quoteDraftService.quoteDraft;
768
768
  if (quoteDraft) {
769
- return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
770
- this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
769
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ configurationId }) => {
770
+ this.contextService.update({ properties: { ConfigurationId: configurationId } });
771
771
  }));
772
772
  }
773
773
  }
@@ -782,8 +782,8 @@ class FlowStateService {
782
782
  else {
783
783
  const quoteDraft = this.quoteDraftService.quoteDraft;
784
784
  if (quoteDraft) {
785
- return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
786
- this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
785
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ configurationId }) => {
786
+ this.contextService.update({ properties: { ConfigurationId: configurationId } });
787
787
  }));
788
788
  }
789
789
  }
@@ -1476,7 +1476,6 @@ class ConfigurationService {
1476
1476
  this.runtimeSettings = runtimeSettings;
1477
1477
  this.mode = ConfigurationMode.SEARCH;
1478
1478
  this.configurationState = new BehaviorSubject(null);
1479
- this.previousConfigurationState = new BehaviorSubject(null);
1480
1479
  this.isLoadingSubj$ = new BehaviorSubject(false);
1481
1480
  this.isLoading$ = this.isLoadingSubj$.asObservable();
1482
1481
  this.hasUnsavedChanges = false;
@@ -1486,7 +1485,6 @@ class ConfigurationService {
1486
1485
  this.runtimeService.reset();
1487
1486
  this.configurableRamp = undefined;
1488
1487
  this.configurationState.next(null);
1489
- this.previousConfigurationState.next(null);
1490
1488
  }
1491
1489
  patch$(lineItem, options) {
1492
1490
  const source = this.getSnapshot();
@@ -1543,9 +1541,6 @@ class ConfigurationService {
1543
1541
  get stateSnapshot() {
1544
1542
  return this.configurationState.value;
1545
1543
  }
1546
- get previousStateSnapshot() {
1547
- return this.previousConfigurationState.value;
1548
- }
1549
1544
  get contextSnapshot() {
1550
1545
  return this.contextService.resolve();
1551
1546
  }
@@ -1596,17 +1591,11 @@ class ConfigurationService {
1596
1591
  var _a;
1597
1592
  this.contextService.update(result.context);
1598
1593
  this.configurationState.next(result);
1599
- this.previousConfigurationState.next(cloneDeep(result));
1600
1594
  if ((_a = result.deletedLineItems) === null || _a === void 0 ? void 0 : _a.length) {
1601
1595
  this.showInactiveProductsConfirmation();
1602
1596
  }
1603
1597
  this.configurableRamp = result.lineItem;
1604
1598
  }), map$1(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
1605
- const resetState = this.previousConfigurationState.value;
1606
- if (resetState) {
1607
- this.previousConfigurationState.next(cloneDeep(resetState));
1608
- this.configurationState.next(resetState);
1609
- }
1610
1599
  if (error.error) {
1611
1600
  return extractErrorDetails(error.error).join('. ');
1612
1601
  }
@@ -1654,7 +1643,7 @@ class ConfigurationService {
1654
1643
  var _a;
1655
1644
  const runtimeContext = this.getRuntimeContext();
1656
1645
  const uiDefinitionProperties = this.getUIDefinitionProperties();
1657
- let lineItem = this.configurableRamp;
1646
+ let lineItem = cloneDeep(this.configurableRamp);
1658
1647
  if (!lineItem) {
1659
1648
  const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
1660
1649
  lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
@@ -1711,18 +1700,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1711
1700
  }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1712
1701
 
1713
1702
  class FlowConfigurationService {
1714
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
1703
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1715
1704
  this.proceduresApiService = proceduresApiService;
1716
1705
  this.contextService = contextService;
1717
1706
  this.quoteDraftService = quoteDraftService;
1718
1707
  this.updateService = updateService;
1719
1708
  this.configurationService = configurationService;
1720
- this.flowInfoService = flowInfoService;
1721
1709
  this.updatedSubj$ = new Subject();
1722
1710
  this.updated$ = this.updatedSubj$.asObservable();
1723
1711
  }
1724
1712
  calculate$(quoteDraft) {
1725
- return this.extendedApply$(quoteDraft).pipe(tap(result => {
1713
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap(result => {
1726
1714
  // sort the result current state based on the quote draft initial state
1727
1715
  const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1728
1716
  result.currentState = result.currentState
@@ -1847,21 +1835,12 @@ class FlowConfigurationService {
1847
1835
  }));
1848
1836
  };
1849
1837
  }
1850
- extendedApply$(quoteDraft) {
1851
- var _a;
1852
- const request = Object.assign({}, quoteDraft);
1853
- const procedureName = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.procedureName;
1854
- if (procedureName) {
1855
- request.procedureName = procedureName;
1856
- }
1857
- return this.proceduresApiService.apply$(request);
1858
- }
1859
1838
  }
1860
- 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 });
1839
+ 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 });
1861
1840
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1862
1841
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1863
1842
  type: Injectable
1864
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
1843
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1865
1844
 
1866
1845
  class FlowConfigurationModule {
1867
1846
  }
@@ -2374,7 +2353,7 @@ class ConfigurationStateService {
2374
2353
  if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
2375
2354
  return of(undefined);
2376
2355
  }
2377
- let configurationRequest = this.configurationService.generateRequest(false);
2356
+ let configurationRequest = this.configurationService.generateRequest();
2378
2357
  request.actions.forEach(action => {
2379
2358
  var _a;
2380
2359
  configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
@@ -2382,18 +2361,30 @@ class ConfigurationStateService {
2382
2361
  configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
2383
2362
  return this.configurationService.configureRequest$(configurationRequest);
2384
2363
  }), map(() => {
2364
+ var _a;
2385
2365
  // Run selectors and apply them to the state
2386
- const configurationState = this.configurationService.stateSnapshot;
2366
+ const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2387
2367
  if (!configurationState) {
2388
2368
  return { stateId: '', selectors: {} };
2389
2369
  }
2390
- return this.runStatelessSelectors(request, configurationState);
2370
+ const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2371
+ try {
2372
+ result.selectors[key] = {
2373
+ success: true,
2374
+ result: this.executeSelectorScript(configurationState, selector),
2375
+ };
2376
+ }
2377
+ catch (e) {
2378
+ console.error(e);
2379
+ result.selectors[key] = {
2380
+ success: false,
2381
+ errorMessage: String(e),
2382
+ };
2383
+ }
2384
+ return result;
2385
+ }, { stateId: '', selectors: {} });
2386
+ return selectorsResult;
2391
2387
  }), tap(() => this.executionInProgress$.next(false)), catchError(error => {
2392
- const configurationState = this.configurationService.previousStateSnapshot;
2393
- if (configurationState) {
2394
- const selectorsResult = this.runStatelessSelectors(request, configurationState);
2395
- this.handleSelectorsResponse(selectorsResult.selectors);
2396
- }
2397
2388
  this.executionInProgress$.next(false);
2398
2389
  if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
2399
2390
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
@@ -2462,25 +2453,6 @@ class ConfigurationStateService {
2462
2453
  configurationStore: this.configurationStore,
2463
2454
  });
2464
2455
  }
2465
- runStatelessSelectors(request, configurationState) {
2466
- var _a;
2467
- return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2468
- try {
2469
- result.selectors[key] = {
2470
- success: true,
2471
- result: this.executeSelectorScript(configurationState, selector),
2472
- };
2473
- }
2474
- catch (e) {
2475
- console.error(e);
2476
- result.selectors[key] = {
2477
- success: false,
2478
- errorMessage: String(e),
2479
- };
2480
- }
2481
- return result;
2482
- }, { stateId: '', selectors: {} });
2483
- }
2484
2456
  }
2485
2457
  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 });
2486
2458
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });