@veloceapps/sdk 10.0.0-9 → 11.0.0-1

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 (37) hide show
  1. package/cms/cms.actions.d.ts +0 -12
  2. package/cms/vendor-map.d.ts +4 -6
  3. package/core/modules/configuration/services/configuration-state.service.d.ts +1 -0
  4. package/core/modules/configuration/services/configuration.service.d.ts +2 -0
  5. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +4 -1
  6. package/esm2020/cms/cms.actions.mjs +1 -17
  7. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +3 -3
  8. package/esm2020/cms/vendor-map.mjs +6 -6
  9. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +29 -22
  10. package/esm2020/core/modules/configuration/services/configuration.service.mjs +13 -2
  11. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +16 -5
  12. package/esm2020/core/services/flow-info.service.mjs +1 -3
  13. package/esm2020/core/services/flow-state.service.mjs +5 -5
  14. package/esm2020/src/flow.component.mjs +4 -5
  15. package/esm2020/src/flow.module.mjs +5 -10
  16. package/esm2020/src/services/flow-dialog.service.mjs +1 -30
  17. package/fesm2015/veloceapps-sdk-cms.mjs +6 -24
  18. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  19. package/fesm2015/veloceapps-sdk-core.mjs +57 -31
  20. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  21. package/fesm2015/veloceapps-sdk.mjs +57 -248
  22. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  23. package/fesm2020/veloceapps-sdk-cms.mjs +6 -24
  24. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  25. package/fesm2020/veloceapps-sdk-core.mjs +55 -30
  26. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  27. package/fesm2020/veloceapps-sdk.mjs +57 -248
  28. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  29. package/package.json +4 -4
  30. package/src/flow.module.d.ts +2 -3
  31. package/src/services/flow-dialog.service.d.ts +0 -4
  32. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +0 -129
  33. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +0 -19
  34. package/esm2020/src/services/doc-gen.service.mjs +0 -34
  35. package/src/components/doc-gen/doc-gen.component.d.ts +0 -26
  36. package/src/components/doc-gen/doc-gen.module.d.ts +0 -9
  37. package/src/services/doc-gen.service.d.ts +0 -13
@@ -260,8 +260,6 @@ class FlowInfoService {
260
260
  return UITemplateType.SHOPPING_CART;
261
261
  case 'catalog':
262
262
  return UITemplateType.CATALOG;
263
- case 'docGen':
264
- return UITemplateType.DOCGEN;
265
263
  case 'guidedSelling':
266
264
  return UITemplateType.GUIDED_SELLING;
267
265
  case 'flowHeader':
@@ -652,8 +650,8 @@ class FlowStateService {
652
650
  else {
653
651
  const quoteDraft = this.quoteDraftService.quoteDraft;
654
652
  if (quoteDraft) {
655
- return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
656
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
653
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
654
+ this.contextService.update({ properties: { VELOCE_PRISM__VersionId__c: versionId } });
657
655
  }));
658
656
  }
659
657
  }
@@ -668,8 +666,8 @@ class FlowStateService {
668
666
  else {
669
667
  const quoteDraft = this.quoteDraftService.quoteDraft;
670
668
  if (quoteDraft) {
671
- return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ configurationId }) => {
672
- this.contextService.update({ properties: { ConfigurationId: configurationId } });
669
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(tap$1(({ versionId }) => {
670
+ this.contextService.update({ properties: { VELOCE_PRISM__VersionId__c: versionId } });
673
671
  }));
674
672
  }
675
673
  }
@@ -1333,6 +1331,7 @@ class ConfigurationService {
1333
1331
  this.runtimeSettings = runtimeSettings;
1334
1332
  this.mode = ConfigurationMode.SEARCH;
1335
1333
  this.configurationState = new BehaviorSubject(null);
1334
+ this.previousConfigurationState = new BehaviorSubject(null);
1336
1335
  this.isLoadingSubj$ = new BehaviorSubject(false);
1337
1336
  this.isLoading$ = this.isLoadingSubj$.asObservable();
1338
1337
  this.hasUnsavedChanges = false;
@@ -1342,6 +1341,7 @@ class ConfigurationService {
1342
1341
  this.runtimeService.reset();
1343
1342
  this.configurableRamp = undefined;
1344
1343
  this.configurationState.next(null);
1344
+ this.previousConfigurationState.next(null);
1345
1345
  }
1346
1346
  patch$(lineItem, options) {
1347
1347
  const source = this.getSnapshot();
@@ -1397,6 +1397,9 @@ class ConfigurationService {
1397
1397
  get stateSnapshot() {
1398
1398
  return this.configurationState.value;
1399
1399
  }
1400
+ get previousStateSnapshot() {
1401
+ return this.previousConfigurationState.value;
1402
+ }
1400
1403
  get contextSnapshot() {
1401
1404
  return this.contextService.resolve();
1402
1405
  }
@@ -1442,11 +1445,17 @@ class ConfigurationService {
1442
1445
  return configure$.pipe(tap(result => {
1443
1446
  this.contextService.update(result.context);
1444
1447
  this.configurationState.next(result);
1448
+ this.previousConfigurationState.next(cloneDeep(result));
1445
1449
  if (result.deletedLineItems?.length) {
1446
1450
  this.showInactiveProductsConfirmation();
1447
1451
  }
1448
1452
  this.configurableRamp = result.lineItem;
1449
1453
  }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
1454
+ const resetState = this.previousConfigurationState.value;
1455
+ if (resetState) {
1456
+ this.previousConfigurationState.next(cloneDeep(resetState));
1457
+ this.configurationState.next(resetState);
1458
+ }
1450
1459
  if (error.error) {
1451
1460
  return extractErrorDetails(error.error).join('. ');
1452
1461
  }
@@ -1492,7 +1501,7 @@ class ConfigurationService {
1492
1501
  generateLineItem() {
1493
1502
  const runtimeContext = this.getRuntimeContext();
1494
1503
  const uiDefinitionProperties = this.getUIDefinitionProperties();
1495
- let lineItem = cloneDeep(this.configurableRamp);
1504
+ let lineItem = this.configurableRamp;
1496
1505
  if (!lineItem) {
1497
1506
  const { initializationProps } = this.runtimeService ?? {};
1498
1507
  lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
@@ -1682,17 +1691,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1682
1691
  }] });
1683
1692
 
1684
1693
  class FlowConfigurationService {
1685
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1694
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
1686
1695
  this.proceduresApiService = proceduresApiService;
1687
1696
  this.contextService = contextService;
1688
1697
  this.quoteDraftService = quoteDraftService;
1689
1698
  this.updateService = updateService;
1690
1699
  this.configurationService = configurationService;
1700
+ this.flowInfoService = flowInfoService;
1691
1701
  this.updatedSubj$ = new Subject();
1692
1702
  this.updated$ = this.updatedSubj$.asObservable();
1693
1703
  }
1694
1704
  calculate$(quoteDraft) {
1695
- return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1705
+ return this.extendedApply$(quoteDraft).pipe(tap$1(result => {
1696
1706
  // sort the result current state based on the quote draft initial state
1697
1707
  const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1698
1708
  result.currentState = result.currentState
@@ -1812,12 +1822,20 @@ class FlowConfigurationService {
1812
1822
  }));
1813
1823
  };
1814
1824
  }
1825
+ extendedApply$(quoteDraft) {
1826
+ const request = { ...quoteDraft };
1827
+ const procedureName = this.flowInfoService.flow?.properties.procedureName;
1828
+ if (procedureName) {
1829
+ request.procedureName = procedureName;
1830
+ }
1831
+ return this.proceduresApiService.apply$(request);
1832
+ }
1815
1833
  }
1816
- 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 });
1834
+ 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 });
1817
1835
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1818
1836
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1819
1837
  type: Injectable
1820
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1838
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
1821
1839
 
1822
1840
  class FlowConfigurationModule {
1823
1841
  }
@@ -2327,7 +2345,7 @@ class ConfigurationStateService {
2327
2345
  if (!request.actions?.length) {
2328
2346
  return of(undefined);
2329
2347
  }
2330
- let configurationRequest = this.configurationService.generateRequest();
2348
+ let configurationRequest = this.configurationService.generateRequest(false);
2331
2349
  request.actions.forEach(action => {
2332
2350
  configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
2333
2351
  });
@@ -2335,28 +2353,17 @@ class ConfigurationStateService {
2335
2353
  return this.configurationService.configureRequest$(configurationRequest);
2336
2354
  }), map$1(() => {
2337
2355
  // Run selectors and apply them to the state
2338
- const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2356
+ const configurationState = this.configurationService.stateSnapshot;
2339
2357
  if (!configurationState) {
2340
2358
  return { stateId: '', selectors: {} };
2341
2359
  }
2342
- const selectorsResult = EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
2343
- try {
2344
- result.selectors[key] = {
2345
- success: true,
2346
- result: this.executeSelectorScript(configurationState, selector),
2347
- };
2348
- }
2349
- catch (e) {
2350
- console.error(e);
2351
- result.selectors[key] = {
2352
- success: false,
2353
- errorMessage: String(e),
2354
- };
2355
- }
2356
- return result;
2357
- }, { stateId: '', selectors: {} });
2358
- return selectorsResult;
2360
+ return this.runStatelessSelectors(request, configurationState);
2359
2361
  }), tap$1(() => this.executionInProgress$.next(false)), catchError(error => {
2362
+ const configurationState = this.configurationService.previousStateSnapshot;
2363
+ if (configurationState) {
2364
+ const selectorsResult = this.runStatelessSelectors(request, configurationState);
2365
+ this.handleSelectorsResponse(selectorsResult.selectors);
2366
+ }
2360
2367
  this.executionInProgress$.next(false);
2361
2368
  if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
2362
2369
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
@@ -2423,6 +2430,24 @@ class ConfigurationStateService {
2423
2430
  configurationStore: this.configurationStore,
2424
2431
  });
2425
2432
  }
2433
+ runStatelessSelectors(request, configurationState) {
2434
+ return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
2435
+ try {
2436
+ result.selectors[key] = {
2437
+ success: true,
2438
+ result: this.executeSelectorScript(configurationState, selector),
2439
+ };
2440
+ }
2441
+ catch (e) {
2442
+ console.error(e);
2443
+ result.selectors[key] = {
2444
+ success: false,
2445
+ errorMessage: String(e),
2446
+ };
2447
+ }
2448
+ return result;
2449
+ }, { stateId: '', selectors: {} });
2450
+ }
2426
2451
  }
2427
2452
  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 });
2428
2453
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });