@veloceapps/sdk 10.0.0-5 → 10.0.0-50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/cms/modules/runtime/services/runtime.service.d.ts +3 -1
  2. package/cms/utils/index.d.ts +1 -0
  3. package/cms/utils/inject.d.ts +1 -0
  4. package/cms/utils/ui-definition.utils.d.ts +1 -0
  5. package/cms/vendor-map.d.ts +4 -2
  6. package/core/modules/configuration/services/configuration-state.service.d.ts +2 -0
  7. package/core/modules/configuration/services/configuration.service.d.ts +2 -0
  8. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +4 -1
  9. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -2
  10. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
  11. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +3 -1
  12. package/esm2020/cms/utils/index.mjs +2 -1
  13. package/esm2020/cms/utils/inject.mjs +27 -0
  14. package/esm2020/cms/utils/ui-definition.utils.mjs +13 -1
  15. package/esm2020/cms/vendor-map.mjs +7 -4
  16. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +38 -22
  17. package/esm2020/core/modules/configuration/services/configuration.service.mjs +13 -2
  18. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +16 -5
  19. package/esm2020/core/services/flow-state.service.mjs +5 -5
  20. package/fesm2015/veloceapps-sdk-cms.mjs +45 -5
  21. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  22. package/fesm2015/veloceapps-sdk-core.mjs +67 -30
  23. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  24. package/fesm2020/veloceapps-sdk-cms.mjs +44 -4
  25. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  26. package/fesm2020/veloceapps-sdk-core.mjs +65 -29
  27. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  28. package/package.json +1 -1
@@ -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: { VELOCPQ__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: { VELOCPQ__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
  }
@@ -2060,6 +2081,7 @@ class ConfigurationStateService {
2060
2081
  this.configurationStore = {};
2061
2082
  this.executionInProgress$ = new BehaviorSubject(false);
2062
2083
  this.statefulRequestStream$ = new Subject();
2084
+ this.statelessExecutionRequest$ = null;
2063
2085
  this.statefulExecutionRequest$ = this.initBufferedRequest$();
2064
2086
  }
2065
2087
  get isExecutionInProgress$() {
@@ -2107,7 +2129,15 @@ class ConfigurationStateService {
2107
2129
  actions: [{ name: actionName, inputData }],
2108
2130
  };
2109
2131
  const request = this.execToRequest(exec);
2110
- return this.executeRequest$(request);
2132
+ const executionRequest$ = this.executeRequest$(request);
2133
+ if (this.isStatefulConfiguration) {
2134
+ return executionRequest$;
2135
+ }
2136
+ // prevent parallel configuration requests in stateless mode
2137
+ if (!this.statelessExecutionRequest$) {
2138
+ this.statelessExecutionRequest$ = executionRequest$.pipe(shareReplay$1(), take$1(1), finalize(() => (this.statelessExecutionRequest$ = null)));
2139
+ }
2140
+ return this.statelessExecutionRequest$;
2111
2141
  }
2112
2142
  select$(selectorName, inputData = {}) {
2113
2143
  const requestId = UUID.UUID();
@@ -2302,7 +2332,7 @@ class ConfigurationStateService {
2302
2332
  if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
2303
2333
  return of(undefined);
2304
2334
  }
2305
- let configurationRequest = this.configurationService.generateRequest();
2335
+ let configurationRequest = this.configurationService.generateRequest(false);
2306
2336
  request.actions.forEach(action => {
2307
2337
  var _a;
2308
2338
  configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
@@ -2310,30 +2340,18 @@ class ConfigurationStateService {
2310
2340
  configurationRequest = ConfigurationTranslatorUtils.lightenConfigurationRequest(configurationRequest);
2311
2341
  return this.configurationService.configureRequest$(configurationRequest);
2312
2342
  }), map$1(() => {
2313
- var _a;
2314
2343
  // Run selectors and apply them to the state
2315
- const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2344
+ const configurationState = this.configurationService.stateSnapshot;
2316
2345
  if (!configurationState) {
2317
2346
  return { stateId: '', selectors: {} };
2318
2347
  }
2319
- const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2320
- try {
2321
- result.selectors[key] = {
2322
- success: true,
2323
- result: this.executeSelectorScript(configurationState, selector),
2324
- };
2325
- }
2326
- catch (e) {
2327
- console.error(e);
2328
- result.selectors[key] = {
2329
- success: false,
2330
- errorMessage: String(e),
2331
- };
2332
- }
2333
- return result;
2334
- }, { stateId: '', selectors: {} });
2335
- return selectorsResult;
2348
+ return this.runStatelessSelectors(request, configurationState);
2336
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
+ }
2337
2355
  this.executionInProgress$.next(false);
2338
2356
  if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
2339
2357
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
@@ -2402,6 +2420,25 @@ class ConfigurationStateService {
2402
2420
  configurationStore: this.configurationStore,
2403
2421
  });
2404
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
+ }
2405
2442
  }
2406
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 });
2407
2444
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });