@veloceapps/sdk 11.0.0-53 → 11.0.0-54

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.
@@ -194,26 +194,6 @@ class FlowInfoService {
194
194
  init$(flowId, routeQueryParams) {
195
195
  return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
196
196
  }
197
- initTestFlow$(productId) {
198
- this.contextSubj$.next({
199
- mode: 'QUOTE',
200
- headerId: '0Q0-test-quote-id',
201
- productId,
202
- });
203
- this.flowSubj$.next({
204
- id: 'preview-flow-id',
205
- properties: {
206
- entryPath: '/product',
207
- queryParams: {},
208
- transformOrchestration: '',
209
- contextDefinition: '',
210
- queryOrchestration: '',
211
- saveOrchestration: '',
212
- },
213
- version: 2,
214
- });
215
- return of(undefined);
216
- }
217
197
  updateContext(update) {
218
198
  this.contextSubj$.next({
219
199
  ...this.context,
@@ -394,10 +374,10 @@ class ConfigurationService {
394
374
  return this.previousConfigurationStateSubj$.getValue();
395
375
  }
396
376
  get root$() {
397
- return this.state$.pipe(map$1(state => state.salesTransactionItems[0]), filter$1(isDefined));
377
+ return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
398
378
  }
399
379
  get root() {
400
- return this.configurationStateSubj$.getValue()?.salesTransactionItems[0] ?? null;
380
+ return this.configurationStateSubj$.getValue()?.salesTransaction.salesTransactionItems[0] ?? null;
401
381
  }
402
382
  constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService) {
403
383
  this.flowInfoService = flowInfoService;
@@ -422,14 +402,18 @@ class ConfigurationService {
422
402
  if (!state) {
423
403
  return of(undefined);
424
404
  }
425
- let transactionItem = state?.salesTransactionItems.find(item => item.id === transactionItemId);
405
+ const salesTransactionItems = state?.salesTransaction.salesTransactionItems ?? [];
406
+ let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
426
407
  if (!transactionItem && productId) {
427
408
  transactionItem =
428
- state.salesTransactionItems.find(item => item.productId === productId) ?? generateTransactionItem(productId);
409
+ salesTransactionItems.find(item => item.productId === productId) ?? generateTransactionItem(productId);
429
410
  }
430
411
  const configurationState = {
431
412
  ...state,
432
- salesTransactionItems: transactionItem ? [transactionItem] : [],
413
+ salesTransaction: {
414
+ ...state.salesTransaction,
415
+ salesTransactionItems: transactionItem ? [transactionItem] : [],
416
+ },
433
417
  };
434
418
  this.configurationStateSubj$.next(configurationState);
435
419
  this.previousConfigurationStateSubj$.next(configurationState);
@@ -444,11 +428,14 @@ class ConfigurationService {
444
428
  return throwError(() => new Error(`Root SalesTransactionItem not found`));
445
429
  }
446
430
  const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
447
- const newSalesTransaction = {
431
+ const newTransactionContext = {
448
432
  ...state,
449
- salesTransactionItems: [newRoot],
433
+ salesTransaction: {
434
+ ...state.salesTransaction,
435
+ salesTransactionItems: [newRoot],
436
+ },
450
437
  };
451
- return this.configureRequest$(newSalesTransaction).pipe(catchError(error => {
438
+ return this.configureRequest$(newTransactionContext).pipe(catchError(error => {
452
439
  console.error(error);
453
440
  if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
454
441
  this.messageService.add({ severity: 'error', summary: error });
@@ -463,15 +450,15 @@ class ConfigurationService {
463
450
  patch(transactionItem) {
464
451
  this.patch$(transactionItem).subscribe();
465
452
  }
466
- configureRequest$(salesTransaction) {
453
+ configureRequest$(transactionContext) {
467
454
  const request = {
468
- salesTransaction,
455
+ transactionContext,
456
+ flowId: this.flowInfoService.flow.id,
469
457
  };
470
458
  this.isLoadingSubj$.next(true);
471
459
  return this.orchestrationsApiService.apply$(request).pipe(tap$1(result => {
472
- const newState = result.salesTransaction;
473
- this.configurationStateSubj$.next(newState);
474
- this.previousConfigurationStateSubj$.next(cloneDeep(newState));
460
+ this.configurationStateSubj$.next(result);
461
+ this.previousConfigurationStateSubj$.next(cloneDeep(result));
475
462
  }), map$1(response => response.salesTransaction), catchError(error => throwError(() => {
476
463
  const resetState = this.previousConfigurationStateSubj$.getValue();
477
464
  if (resetState) {
@@ -507,11 +494,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
507
494
  }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i2.MessageService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: i1.OrchestrationsApiService }]; } });
508
495
 
509
496
  class TestModeConfigurationService {
510
- constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService) {
497
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService) {
511
498
  this.flowInfoService = flowInfoService;
512
499
  this.configurationService = configurationService;
513
500
  this.configurationRuntimeService = configurationRuntimeService;
514
501
  this.salesTransactionService = salesTransactionService;
502
+ this.runtimeSettingsService = runtimeSettingsService;
515
503
  this.isInitialized = false;
516
504
  }
517
505
  initTestMode$(uiDefinitionContainer, options) {
@@ -521,14 +509,17 @@ class TestModeConfigurationService {
521
509
  return of(undefined);
522
510
  }
523
511
  this.configurationService.reset();
524
- const { productId, quoteId } = uiDefinitionContainer.source.properties ?? {};
512
+ const { productId, quoteId, flowId } = uiDefinitionContainer.source.properties ?? {};
525
513
  if (!productId) {
526
514
  return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
527
515
  }
528
516
  if (!quoteId) {
529
517
  return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
530
518
  }
531
- return this.flowInfoService.initTestFlow$(productId).pipe(switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
519
+ if (!flowId) {
520
+ return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
521
+ }
522
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
532
523
  if (options?.customizationMode) {
533
524
  return of(undefined);
534
525
  }
@@ -536,28 +527,35 @@ class TestModeConfigurationService {
536
527
  }), tap(() => (this.isInitialized = true)), map(noop));
537
528
  }
538
529
  initConfiguration$(quoteId) {
539
- this.salesTransactionService.setState(this.getTestSalesTransaction(quoteId));
530
+ this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
540
531
  return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
541
532
  ? this.configurationService.configureRequest$(this.configurationService.state)
542
533
  : of(undefined)), map(noop));
543
534
  }
544
- getTestSalesTransaction(quoteId) {
535
+ getTestTransactionContext(quoteId) {
545
536
  const testTransaction = {
546
537
  id: quoteId,
547
538
  businessObjectType: 'Quote',
548
539
  salesTransactionItems: [],
549
540
  };
550
- return testTransaction;
541
+ return {
542
+ salesTransaction: testTransaction,
543
+ transactionId: quoteId,
544
+ businessObjectType: 'Quote',
545
+ childNodes: {},
546
+ id: UUID.UUID(),
547
+ tagAttributes: {},
548
+ };
551
549
  }
552
550
  checkInitialized(uiDefinitionContainer) {
553
551
  return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
554
552
  }
555
553
  }
556
- TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }], target: i0.ɵɵFactoryTarget.Injectable });
554
+ TestModeConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, deps: [{ token: FlowInfoService }, { token: ConfigurationService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
557
555
  TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
558
556
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
559
557
  type: Injectable
560
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }]; } });
558
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
561
559
 
562
560
  class SalesTransactionService {
563
561
  get isInitialized$() {
@@ -569,7 +567,7 @@ class SalesTransactionService {
569
567
  set hasUnsavedChanges(value) {
570
568
  this.hasUnsavedChangesSubj$.next(value);
571
569
  if (!this.hasUnsavedChanges) {
572
- this.initialState = this.state?.salesTransactionItems ?? [];
570
+ this.initialState = this.state?.salesTransaction.salesTransactionItems ?? [];
573
571
  }
574
572
  }
575
573
  get hasUnsavedChanges() {
@@ -579,10 +577,9 @@ class SalesTransactionService {
579
577
  return this.stateSubj$.getValue();
580
578
  }
581
579
  get hasProducts() {
582
- return Boolean(this.state?.salesTransactionItems.length);
580
+ return Boolean(this.state?.salesTransaction.salesTransactionItems.length);
583
581
  }
584
- constructor(flowInfoService, salesTransactionApiService) {
585
- this.flowInfoService = flowInfoService;
582
+ constructor(salesTransactionApiService) {
586
583
  this.salesTransactionApiService = salesTransactionApiService;
587
584
  this.stateSubj$ = new BehaviorSubject(null);
588
585
  this.isInitializedSubj$ = new BehaviorSubject(false);
@@ -592,7 +589,7 @@ class SalesTransactionService {
592
589
  this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
593
590
  }
594
591
  init(headerId, params) {
595
- return this.salesTransactionApiService.getState(headerId, params).pipe(tap(res => this.stateSubj$.next(res.salesTransaction)), map(res => res.salesTransaction));
592
+ return this.salesTransactionApiService.getState(headerId, params).pipe(tap(res => this.stateSubj$.next(res)));
596
593
  }
597
594
  finalizeInit() {
598
595
  this.isInitializedSubj$.next(true);
@@ -610,21 +607,24 @@ class SalesTransactionService {
610
607
  this.stateSubj$.next(state);
611
608
  }
612
609
  }
613
- SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: FlowInfoService }, { token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
610
+ SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
614
611
  SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
615
612
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
616
613
  type: Injectable
617
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i1.SalesTransactionApiService }]; } });
614
+ }], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
618
615
 
619
616
  class FlowConfigurationService {
620
- constructor(orchestrationsApiService, salesTransactionService) {
617
+ constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
621
618
  this.orchestrationsApiService = orchestrationsApiService;
622
619
  this.salesTransactionService = salesTransactionService;
620
+ this.flowInfoService = flowInfoService;
623
621
  this.updatedSubj$ = new Subject();
624
622
  this.updated$ = this.updatedSubj$.asObservable();
625
623
  }
626
624
  calculate$(state) {
627
- return this.orchestrationsApiService.apply$({ salesTransaction: state }).pipe(tap(result => this.salesTransactionService.setState(result.salesTransaction)), map(noop));
625
+ return this.orchestrationsApiService
626
+ .apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
627
+ .pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
628
628
  }
629
629
  calculate(state) {
630
630
  this.calculate$(state).subscribe();
@@ -632,7 +632,7 @@ class FlowConfigurationService {
632
632
  revert$(transactionItemId) {
633
633
  const state = this.salesTransactionService.state;
634
634
  const initialState = this.salesTransactionService.getInitialState();
635
- const currentState = state?.salesTransactionItems ?? [];
635
+ const currentState = state?.salesTransaction.salesTransactionItems ?? [];
636
636
  const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
637
637
  const currentItem = currentState[currentItemIndex];
638
638
  const initialItem = initialState.find(({ integrationId }) => integrationId === currentItem?.integrationId);
@@ -641,9 +641,10 @@ class FlowConfigurationService {
641
641
  }
642
642
  const updatedState = cloneDeep(currentState);
643
643
  updatedState.splice(currentItemIndex, 1, initialItem);
644
- return of([]).pipe(tap(() => {
645
- this.salesTransactionService.setState({ ...state, salesTransactionItems: updatedState });
646
- }), switchMap(() => this.calculate$({ ...state, salesTransactionItems: updatedState })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
644
+ return of([]).pipe(map(() => ({
645
+ ...state,
646
+ salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
647
+ })), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
647
648
  }
648
649
  revert(transactionItemId) {
649
650
  this.revert$(transactionItemId).subscribe();
@@ -653,7 +654,10 @@ class FlowConfigurationService {
653
654
  if (!state) {
654
655
  return of(null);
655
656
  }
656
- return of([]).pipe(map(() => state.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({ ...state, salesTransactionItems: updatedState })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
657
+ return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$({
658
+ ...state,
659
+ salesTransaction: { ...state.salesTransaction, salesTransactionItems: updatedState },
660
+ })), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
657
661
  }
658
662
  delete(ids) {
659
663
  this.delete$(ids).subscribe();
@@ -673,11 +677,11 @@ class FlowConfigurationService {
673
677
  };
674
678
  }
675
679
  }
676
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }], target: i0.ɵɵFactoryTarget.Injectable });
680
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.OrchestrationsApiService }, { token: SalesTransactionService }, { token: FlowInfoService }], target: i0.ɵɵFactoryTarget.Injectable });
677
681
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
678
682
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
679
683
  type: Injectable
680
- }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }]; } });
684
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
681
685
 
682
686
  class FlowStateService {
683
687
  constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
@@ -1329,22 +1333,26 @@ class ConfigurationStateService {
1329
1333
  if (standalone) {
1330
1334
  return this.salesTransactionApiService.upsert(state);
1331
1335
  }
1332
- const salesTransaction = this.salesTransactionService.state;
1336
+ const transactionContext = this.salesTransactionService.state;
1333
1337
  const configurationRoot = this.configurationService.root;
1334
- if (!salesTransaction || !configurationRoot) {
1338
+ if (!transactionContext || !configurationRoot) {
1335
1339
  return of({ id: '' });
1336
1340
  }
1337
- const isNewTransactionItem = salesTransaction.salesTransactionItems.every(li => li.id !== configurationRoot.id);
1341
+ const stateItems = transactionContext.salesTransaction.salesTransactionItems;
1342
+ const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
1338
1343
  let salesTransactionItems;
1339
1344
  if (isNewTransactionItem) {
1340
- salesTransactionItems = [...salesTransaction.salesTransactionItems, configurationRoot];
1345
+ salesTransactionItems = [...stateItems, configurationRoot];
1341
1346
  }
1342
1347
  else {
1343
- salesTransactionItems = salesTransaction.salesTransactionItems.map(ti => ti.id === configurationRoot.id ? configurationRoot : ti);
1348
+ salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
1344
1349
  }
1345
1350
  const newState = {
1346
- ...salesTransaction,
1347
- salesTransactionItems,
1351
+ ...transactionContext,
1352
+ salesTransaction: {
1353
+ ...transactionContext.salesTransaction,
1354
+ salesTransactionItems,
1355
+ },
1348
1356
  };
1349
1357
  return this.flowConfigurationService.calculate$(newState).pipe(map(() => ({ id: '' })));
1350
1358
  }