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