@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.
@@ -269,26 +269,6 @@ class FlowInfoService {
269
269
  init$(flowId, routeQueryParams) {
270
270
  return this.initFlow$(flowId, routeQueryParams).pipe(switchMap(() => this.initFlowTemplates$()));
271
271
  }
272
- initTestFlow$(productId) {
273
- this.contextSubj$.next({
274
- mode: 'QUOTE',
275
- headerId: '0Q0-test-quote-id',
276
- productId,
277
- });
278
- this.flowSubj$.next({
279
- id: 'preview-flow-id',
280
- properties: {
281
- entryPath: '/product',
282
- queryParams: {},
283
- transformOrchestration: '',
284
- contextDefinition: '',
285
- queryOrchestration: '',
286
- saveOrchestration: '',
287
- },
288
- version: 2,
289
- });
290
- return of(undefined);
291
- }
292
272
  updateContext(update) {
293
273
  this.contextSubj$.next(Object.assign(Object.assign({}, this.context), update));
294
274
  }
@@ -376,11 +356,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
376
356
  } });
377
357
 
378
358
  class TestModeConfigurationService {
379
- constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService) {
359
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService) {
380
360
  this.flowInfoService = flowInfoService;
381
361
  this.configurationService = configurationService;
382
362
  this.configurationRuntimeService = configurationRuntimeService;
383
363
  this.salesTransactionService = salesTransactionService;
364
+ this.runtimeSettingsService = runtimeSettingsService;
384
365
  this.isInitialized = false;
385
366
  }
386
367
  initTestMode$(uiDefinitionContainer, options) {
@@ -391,14 +372,17 @@ class TestModeConfigurationService {
391
372
  return of(undefined);
392
373
  }
393
374
  this.configurationService.reset();
394
- const { productId, quoteId } = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
375
+ const { productId, quoteId, flowId } = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
395
376
  if (!productId) {
396
377
  return throwError(() => 'Unable to start the Configuration Preview: Product is missing.');
397
378
  }
398
379
  if (!quoteId) {
399
380
  return throwError(() => `Unable to start the Configuration Preview: Quote is missing.`);
400
381
  }
401
- return this.flowInfoService.initTestFlow$(productId).pipe(switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
382
+ if (!flowId) {
383
+ return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
384
+ }
385
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
402
386
  if (options === null || options === void 0 ? void 0 : options.customizationMode) {
403
387
  return of(undefined);
404
388
  }
@@ -406,29 +390,36 @@ class TestModeConfigurationService {
406
390
  }), tap(() => (this.isInitialized = true)), map(noop));
407
391
  }
408
392
  initConfiguration$(quoteId) {
409
- this.salesTransactionService.setState(this.getTestSalesTransaction(quoteId));
393
+ this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
410
394
  return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
411
395
  ? this.configurationService.configureRequest$(this.configurationService.state)
412
396
  : of(undefined)), map(noop));
413
397
  }
414
- getTestSalesTransaction(quoteId) {
398
+ getTestTransactionContext(quoteId) {
415
399
  const testTransaction = {
416
400
  id: quoteId,
417
401
  businessObjectType: 'Quote',
418
402
  salesTransactionItems: [],
419
403
  };
420
- return testTransaction;
404
+ return {
405
+ salesTransaction: testTransaction,
406
+ transactionId: quoteId,
407
+ businessObjectType: 'Quote',
408
+ childNodes: {},
409
+ id: UUID.UUID(),
410
+ tagAttributes: {},
411
+ };
421
412
  }
422
413
  checkInitialized(uiDefinitionContainer) {
423
414
  var _a;
424
415
  return this.isInitialized && !!((_a = uiDefinitionContainer.source.properties) === null || _a === void 0 ? void 0 : _a.persistTestState);
425
416
  }
426
417
  }
427
- 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 });
418
+ 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 });
428
419
  TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
429
420
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
430
421
  type: Injectable
431
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }]; } });
422
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
432
423
 
433
424
  class SalesTransactionService {
434
425
  get isInitialized$() {
@@ -441,7 +432,7 @@ class SalesTransactionService {
441
432
  var _a, _b;
442
433
  this.hasUnsavedChangesSubj$.next(value);
443
434
  if (!this.hasUnsavedChanges) {
444
- this.initialState = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransactionItems) !== null && _b !== void 0 ? _b : [];
435
+ this.initialState = (_b = (_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems) !== null && _b !== void 0 ? _b : [];
445
436
  }
446
437
  }
447
438
  get hasUnsavedChanges() {
@@ -452,10 +443,9 @@ class SalesTransactionService {
452
443
  }
453
444
  get hasProducts() {
454
445
  var _a;
455
- return Boolean((_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransactionItems.length);
446
+ return Boolean((_a = this.state) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems.length);
456
447
  }
457
- constructor(flowInfoService, salesTransactionApiService) {
458
- this.flowInfoService = flowInfoService;
448
+ constructor(salesTransactionApiService) {
459
449
  this.salesTransactionApiService = salesTransactionApiService;
460
450
  this.stateSubj$ = new BehaviorSubject(null);
461
451
  this.isInitializedSubj$ = new BehaviorSubject(false);
@@ -465,7 +455,7 @@ class SalesTransactionService {
465
455
  this.state$ = this.stateSubj$.asObservable().pipe(filter(isDefined));
466
456
  }
467
457
  init(headerId, params) {
468
- return this.salesTransactionApiService.getState(headerId, params).pipe(tap(res => this.stateSubj$.next(res.salesTransaction)), map(res => res.salesTransaction));
458
+ return this.salesTransactionApiService.getState(headerId, params).pipe(tap(res => this.stateSubj$.next(res)));
469
459
  }
470
460
  finalizeInit() {
471
461
  this.isInitializedSubj$.next(true);
@@ -483,21 +473,24 @@ class SalesTransactionService {
483
473
  this.stateSubj$.next(state);
484
474
  }
485
475
  }
486
- 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 });
476
+ SalesTransactionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, deps: [{ token: i1.SalesTransactionApiService }], target: i0.ɵɵFactoryTarget.Injectable });
487
477
  SalesTransactionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService });
488
478
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SalesTransactionService, decorators: [{
489
479
  type: Injectable
490
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: i1.SalesTransactionApiService }]; } });
480
+ }], ctorParameters: function () { return [{ type: i1.SalesTransactionApiService }]; } });
491
481
 
492
482
  class FlowConfigurationService {
493
- constructor(orchestrationsApiService, salesTransactionService) {
483
+ constructor(orchestrationsApiService, salesTransactionService, flowInfoService) {
494
484
  this.orchestrationsApiService = orchestrationsApiService;
495
485
  this.salesTransactionService = salesTransactionService;
486
+ this.flowInfoService = flowInfoService;
496
487
  this.updatedSubj$ = new Subject();
497
488
  this.updated$ = this.updatedSubj$.asObservable();
498
489
  }
499
490
  calculate$(state) {
500
- return this.orchestrationsApiService.apply$({ salesTransaction: state }).pipe(tap(result => this.salesTransactionService.setState(result.salesTransaction)), map(noop));
491
+ return this.orchestrationsApiService
492
+ .apply$({ transactionContext: state, flowId: this.flowInfoService.flow.id })
493
+ .pipe(tap(result => this.salesTransactionService.setState(result)), map(noop));
501
494
  }
502
495
  calculate(state) {
503
496
  this.calculate$(state).subscribe();
@@ -506,7 +499,7 @@ class FlowConfigurationService {
506
499
  var _a;
507
500
  const state = this.salesTransactionService.state;
508
501
  const initialState = this.salesTransactionService.getInitialState();
509
- const currentState = (_a = state === null || state === void 0 ? void 0 : state.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
502
+ const currentState = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
510
503
  const currentItemIndex = currentState.findIndex(({ id }) => id === transactionItemId);
511
504
  const currentItem = currentState[currentItemIndex];
512
505
  const initialItem = initialState.find(({ integrationId }) => integrationId === (currentItem === null || currentItem === void 0 ? void 0 : currentItem.integrationId));
@@ -515,9 +508,7 @@ class FlowConfigurationService {
515
508
  }
516
509
  const updatedState = cloneDeep(currentState);
517
510
  updatedState.splice(currentItemIndex, 1, initialItem);
518
- return of([]).pipe(tap(() => {
519
- this.salesTransactionService.setState(Object.assign(Object.assign({}, state), { salesTransactionItems: updatedState }));
520
- }), switchMap(() => this.calculate$(Object.assign(Object.assign({}, state), { salesTransactionItems: updatedState }))), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
511
+ return of([]).pipe(map(() => (Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), tap(newState => this.salesTransactionService.setState(newState)), switchMap(newState => this.calculate$(newState)), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
521
512
  }
522
513
  revert(transactionItemId) {
523
514
  this.revert$(transactionItemId).subscribe();
@@ -527,7 +518,7 @@ class FlowConfigurationService {
527
518
  if (!state) {
528
519
  return of(null);
529
520
  }
530
- return of([]).pipe(map(() => state.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, state), { salesTransactionItems: updatedState }))), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
521
+ return of([]).pipe(map(() => state.salesTransaction.salesTransactionItems.filter(({ id }) => !ids.includes(id))), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: updatedState }) }))), map(() => this.salesTransactionService.state), tap(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
531
522
  }
532
523
  delete(ids) {
533
524
  this.delete$(ids).subscribe();
@@ -547,11 +538,11 @@ class FlowConfigurationService {
547
538
  };
548
539
  }
549
540
  }
550
- 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 });
541
+ 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 });
551
542
  FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
552
543
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
553
544
  type: Injectable
554
- }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }]; } });
545
+ }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
555
546
 
556
547
  class FlowStateService {
557
548
  constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
@@ -1101,11 +1092,11 @@ class ConfigurationService {
1101
1092
  return this.previousConfigurationStateSubj$.getValue();
1102
1093
  }
1103
1094
  get root$() {
1104
- return this.state$.pipe(map$1(state => state.salesTransactionItems[0]), filter$1(isDefined));
1095
+ return this.state$.pipe(map$1(state => state.salesTransaction.salesTransactionItems[0]), filter$1(isDefined));
1105
1096
  }
1106
1097
  get root() {
1107
1098
  var _a, _b;
1108
- return (_b = (_a = this.configurationStateSubj$.getValue()) === null || _a === void 0 ? void 0 : _a.salesTransactionItems[0]) !== null && _b !== void 0 ? _b : null;
1099
+ return (_b = (_a = this.configurationStateSubj$.getValue()) === null || _a === void 0 ? void 0 : _a.salesTransaction.salesTransactionItems[0]) !== null && _b !== void 0 ? _b : null;
1109
1100
  }
1110
1101
  constructor(flowInfoService, messageService, configurationRuntimeService, salesTransactionService, orchestrationsApiService) {
1111
1102
  this.flowInfoService = flowInfoService;
@@ -1125,18 +1116,19 @@ class ConfigurationService {
1125
1116
  this.previousConfigurationStateSubj$.next(null);
1126
1117
  }
1127
1118
  init$() {
1128
- var _a;
1119
+ var _a, _b;
1129
1120
  const { state } = this.salesTransactionService;
1130
1121
  const { productId, transactionItemId } = this.flowInfoService.context;
1131
1122
  if (!state) {
1132
1123
  return of(undefined);
1133
1124
  }
1134
- let transactionItem = state === null || state === void 0 ? void 0 : state.salesTransactionItems.find(item => item.id === transactionItemId);
1125
+ const salesTransactionItems = (_a = state === null || state === void 0 ? void 0 : state.salesTransaction.salesTransactionItems) !== null && _a !== void 0 ? _a : [];
1126
+ let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
1135
1127
  if (!transactionItem && productId) {
1136
1128
  transactionItem =
1137
- (_a = state.salesTransactionItems.find(item => item.productId === productId)) !== null && _a !== void 0 ? _a : generateTransactionItem(productId);
1129
+ (_b = salesTransactionItems.find(item => item.productId === productId)) !== null && _b !== void 0 ? _b : generateTransactionItem(productId);
1138
1130
  }
1139
- const configurationState = Object.assign(Object.assign({}, state), { salesTransactionItems: transactionItem ? [transactionItem] : [] });
1131
+ const configurationState = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: transactionItem ? [transactionItem] : [] }) });
1140
1132
  this.configurationStateSubj$.next(configurationState);
1141
1133
  this.previousConfigurationStateSubj$.next(configurationState);
1142
1134
  return of(undefined);
@@ -1150,8 +1142,8 @@ class ConfigurationService {
1150
1142
  return throwError(() => new Error(`Root SalesTransactionItem not found`));
1151
1143
  }
1152
1144
  const newRoot = new TransactionItemWorker(root).replace(transactionItem).ti;
1153
- const newSalesTransaction = Object.assign(Object.assign({}, state), { salesTransactionItems: [newRoot] });
1154
- return this.configureRequest$(newSalesTransaction).pipe(catchError$1(error => {
1145
+ const newTransactionContext = Object.assign(Object.assign({}, state), { salesTransaction: Object.assign(Object.assign({}, state.salesTransaction), { salesTransactionItems: [newRoot] }) });
1146
+ return this.configureRequest$(newTransactionContext).pipe(catchError$1(error => {
1155
1147
  console.error(error);
1156
1148
  if (!this.configurationRuntimeService.uiDefinitionProps.suppressToastMessages) {
1157
1149
  this.messageService.add({ severity: 'error', summary: error });
@@ -1166,15 +1158,15 @@ class ConfigurationService {
1166
1158
  patch(transactionItem) {
1167
1159
  this.patch$(transactionItem).subscribe();
1168
1160
  }
1169
- configureRequest$(salesTransaction) {
1161
+ configureRequest$(transactionContext) {
1170
1162
  const request = {
1171
- salesTransaction,
1163
+ transactionContext,
1164
+ flowId: this.flowInfoService.flow.id,
1172
1165
  };
1173
1166
  this.isLoadingSubj$.next(true);
1174
1167
  return this.orchestrationsApiService.apply$(request).pipe(tap$1(result => {
1175
- const newState = result.salesTransaction;
1176
- this.configurationStateSubj$.next(newState);
1177
- this.previousConfigurationStateSubj$.next(cloneDeep(newState));
1168
+ this.configurationStateSubj$.next(result);
1169
+ this.previousConfigurationStateSubj$.next(cloneDeep(result));
1178
1170
  }), map$1(response => response.salesTransaction), catchError$1(error => throwError(() => {
1179
1171
  const resetState = this.previousConfigurationStateSubj$.getValue();
1180
1172
  if (resetState) {
@@ -1343,20 +1335,21 @@ class ConfigurationStateService {
1343
1335
  if (standalone) {
1344
1336
  return this.salesTransactionApiService.upsert(state);
1345
1337
  }
1346
- const salesTransaction = this.salesTransactionService.state;
1338
+ const transactionContext = this.salesTransactionService.state;
1347
1339
  const configurationRoot = this.configurationService.root;
1348
- if (!salesTransaction || !configurationRoot) {
1340
+ if (!transactionContext || !configurationRoot) {
1349
1341
  return of({ id: '' });
1350
1342
  }
1351
- const isNewTransactionItem = salesTransaction.salesTransactionItems.every(li => li.id !== configurationRoot.id);
1343
+ const stateItems = transactionContext.salesTransaction.salesTransactionItems;
1344
+ const isNewTransactionItem = stateItems.every(ti => ti.id !== configurationRoot.id);
1352
1345
  let salesTransactionItems;
1353
1346
  if (isNewTransactionItem) {
1354
- salesTransactionItems = [...salesTransaction.salesTransactionItems, configurationRoot];
1347
+ salesTransactionItems = [...stateItems, configurationRoot];
1355
1348
  }
1356
1349
  else {
1357
- salesTransactionItems = salesTransaction.salesTransactionItems.map(ti => ti.id === configurationRoot.id ? configurationRoot : ti);
1350
+ salesTransactionItems = stateItems.map(ti => (ti.id === configurationRoot.id ? configurationRoot : ti));
1358
1351
  }
1359
- const newState = Object.assign(Object.assign({}, salesTransaction), { salesTransactionItems });
1352
+ const newState = Object.assign(Object.assign({}, transactionContext), { salesTransaction: Object.assign(Object.assign({}, transactionContext.salesTransaction), { salesTransactionItems }) });
1360
1353
  return this.flowConfigurationService.calculate$(newState).pipe(map(() => ({ id: '' })));
1361
1354
  }
1362
1355
  cancelConfiguration() {