@veloceapps/sdk 10.0.0-37 → 10.0.0-39

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