@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.
@@ -336,8 +336,9 @@ class FlowInfoService {
336
336
  if (!flow) {
337
337
  return of(undefined);
338
338
  }
339
+ const isLegacy = !!flow && flow?.properties.stateful == null;
339
340
  let flowTemplates$ = of(undefined);
340
- if (!this.isLegacy) {
341
+ if (!isLegacy) {
341
342
  flowTemplates$ = this.initFlowTemplates$(flow).pipe(map(() => undefined));
342
343
  }
343
344
  return flowTemplates$.pipe(tap(() => {
@@ -797,8 +798,8 @@ class FlowStateService {
797
798
  else {
798
799
  const quoteDraft = this.quoteDraftService.quoteDraft;
799
800
  if (quoteDraft) {
800
- return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ versionId }) => {
801
- this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
801
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(tap(({ configurationId }) => {
802
+ this.contextService.update({ properties: { ConfigurationId: configurationId } });
802
803
  }));
803
804
  }
804
805
  }
@@ -813,8 +814,8 @@ class FlowStateService {
813
814
  else {
814
815
  const quoteDraft = this.quoteDraftService.quoteDraft;
815
816
  if (quoteDraft) {
816
- return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ versionId }) => {
817
- this.contextService.update({ properties: { VELOCPQ__VersionId__c: versionId } });
817
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(tap(({ configurationId }) => {
818
+ this.contextService.update({ properties: { ConfigurationId: configurationId } });
818
819
  }));
819
820
  }
820
821
  }
@@ -1373,7 +1374,6 @@ class ConfigurationService {
1373
1374
  this.runtimeSettings = runtimeSettings;
1374
1375
  this.mode = ConfigurationMode.SEARCH;
1375
1376
  this.configurationState = new BehaviorSubject(null);
1376
- this.previousConfigurationState = new BehaviorSubject(null);
1377
1377
  this.isLoadingSubj$ = new BehaviorSubject(false);
1378
1378
  this.isLoading$ = this.isLoadingSubj$.asObservable();
1379
1379
  this.hasUnsavedChanges = false;
@@ -1383,7 +1383,6 @@ class ConfigurationService {
1383
1383
  this.runtimeService.reset();
1384
1384
  this.configurableRamp = undefined;
1385
1385
  this.configurationState.next(null);
1386
- this.previousConfigurationState.next(null);
1387
1386
  }
1388
1387
  patch$(lineItem, options) {
1389
1388
  const source = this.getSnapshot();
@@ -1439,9 +1438,6 @@ class ConfigurationService {
1439
1438
  get stateSnapshot() {
1440
1439
  return this.configurationState.value;
1441
1440
  }
1442
- get previousStateSnapshot() {
1443
- return this.previousConfigurationState.value;
1444
- }
1445
1441
  get contextSnapshot() {
1446
1442
  return this.contextService.resolve();
1447
1443
  }
@@ -1487,17 +1483,11 @@ class ConfigurationService {
1487
1483
  return configure$.pipe(tap$1(result => {
1488
1484
  this.contextService.update(result.context);
1489
1485
  this.configurationState.next(result);
1490
- this.previousConfigurationState.next(cloneDeep(result));
1491
1486
  if (result.deletedLineItems?.length) {
1492
1487
  this.showInactiveProductsConfirmation();
1493
1488
  }
1494
1489
  this.configurableRamp = result.lineItem;
1495
1490
  }), map$1(({ lineItem }) => lineItem), catchError$1(error => throwError(() => {
1496
- const resetState = this.previousConfigurationState.value;
1497
- if (resetState) {
1498
- this.previousConfigurationState.next(cloneDeep(resetState));
1499
- this.configurationState.next(resetState);
1500
- }
1501
1491
  if (error.error) {
1502
1492
  return extractErrorDetails(error.error).join('. ');
1503
1493
  }
@@ -1543,7 +1533,7 @@ class ConfigurationService {
1543
1533
  generateLineItem() {
1544
1534
  const runtimeContext = this.getRuntimeContext();
1545
1535
  const uiDefinitionProperties = this.getUIDefinitionProperties();
1546
- let lineItem = this.configurableRamp;
1536
+ let lineItem = cloneDeep(this.configurableRamp);
1547
1537
  if (!lineItem) {
1548
1538
  const { initializationProps } = this.runtimeService ?? {};
1549
1539
  lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps?.defaultQty);
@@ -1733,18 +1723,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1733
1723
  }] });
1734
1724
 
1735
1725
  class FlowConfigurationService {
1736
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService, flowInfoService) {
1726
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1737
1727
  this.proceduresApiService = proceduresApiService;
1738
1728
  this.contextService = contextService;
1739
1729
  this.quoteDraftService = quoteDraftService;
1740
1730
  this.updateService = updateService;
1741
1731
  this.configurationService = configurationService;
1742
- this.flowInfoService = flowInfoService;
1743
1732
  this.updatedSubj$ = new Subject();
1744
1733
  this.updated$ = this.updatedSubj$.asObservable();
1745
1734
  }
1746
1735
  calculate$(quoteDraft) {
1747
- return this.extendedApply$(quoteDraft).pipe(tap(result => {
1736
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap(result => {
1748
1737
  // sort the result current state based on the quote draft initial state
1749
1738
  const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1750
1739
  result.currentState = result.currentState
@@ -1864,20 +1853,12 @@ class FlowConfigurationService {
1864
1853
  }));
1865
1854
  };
1866
1855
  }
1867
- extendedApply$(quoteDraft) {
1868
- const request = { ...quoteDraft };
1869
- const procedureName = this.flowInfoService.flow?.properties.procedureName;
1870
- if (procedureName) {
1871
- request.procedureName = procedureName;
1872
- }
1873
- return this.proceduresApiService.apply$(request);
1874
- }
1875
1856
  }
1876
- 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 });
1857
+ 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 });
1877
1858
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1878
1859
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1879
1860
  type: Injectable
1880
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }, { type: FlowInfoService }]; } });
1861
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1881
1862
 
1882
1863
  class FlowConfigurationModule {
1883
1864
  }
@@ -2387,7 +2368,7 @@ class ConfigurationStateService {
2387
2368
  if (!request.actions?.length) {
2388
2369
  return of(undefined);
2389
2370
  }
2390
- let configurationRequest = this.configurationService.generateRequest(false);
2371
+ let configurationRequest = this.configurationService.generateRequest();
2391
2372
  request.actions.forEach(action => {
2392
2373
  configurationRequest = this.executeActionScript(configurationRequest, action) ?? configurationRequest;
2393
2374
  });
@@ -2395,17 +2376,28 @@ class ConfigurationStateService {
2395
2376
  return this.configurationService.configureRequest$(configurationRequest);
2396
2377
  }), map(() => {
2397
2378
  // Run selectors and apply them to the state
2398
- const configurationState = this.configurationService.stateSnapshot;
2379
+ const configurationState = cloneDeep(this.configurationService.stateSnapshot);
2399
2380
  if (!configurationState) {
2400
2381
  return { stateId: '', selectors: {} };
2401
2382
  }
2402
- return this.runStatelessSelectors(request, configurationState);
2383
+ const selectorsResult = EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
2384
+ try {
2385
+ result.selectors[key] = {
2386
+ success: true,
2387
+ result: this.executeSelectorScript(configurationState, selector),
2388
+ };
2389
+ }
2390
+ catch (e) {
2391
+ console.error(e);
2392
+ result.selectors[key] = {
2393
+ success: false,
2394
+ errorMessage: String(e),
2395
+ };
2396
+ }
2397
+ return result;
2398
+ }, { stateId: '', selectors: {} });
2399
+ return selectorsResult;
2403
2400
  }), tap(() => this.executionInProgress$.next(false)), catchError(error => {
2404
- const configurationState = this.configurationService.previousStateSnapshot;
2405
- if (configurationState) {
2406
- const selectorsResult = this.runStatelessSelectors(request, configurationState);
2407
- this.handleSelectorsResponse(selectorsResult.selectors);
2408
- }
2409
2401
  this.executionInProgress$.next(false);
2410
2402
  if (!this.configurationRuntimeService.uiDefinitionProperties.suppressToastMessages) {
2411
2403
  this.toastService.add({ severity: ToastType.error, summary: String(error) });
@@ -2472,24 +2464,6 @@ class ConfigurationStateService {
2472
2464
  configurationStore: this.configurationStore,
2473
2465
  });
2474
2466
  }
2475
- runStatelessSelectors(request, configurationState) {
2476
- return EntityUtil.entries(request.selectors ?? {}).reduce((result, [key, selector]) => {
2477
- try {
2478
- result.selectors[key] = {
2479
- success: true,
2480
- result: this.executeSelectorScript(configurationState, selector),
2481
- };
2482
- }
2483
- catch (e) {
2484
- console.error(e);
2485
- result.selectors[key] = {
2486
- success: false,
2487
- errorMessage: String(e),
2488
- };
2489
- }
2490
- return result;
2491
- }, { stateId: '', selectors: {} });
2492
- }
2493
2467
  }
2494
2468
  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 });
2495
2469
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });