@veloceapps/sdk 11.0.0-98 → 12.0.0-0

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 (41) hide show
  1. package/cms/vendor-map.d.ts +6 -2
  2. package/core/modules/configuration/services/configuration-state.service.d.ts +3 -2
  3. package/core/modules/configuration/services/guided-selling.service.d.ts +1 -1
  4. package/core/modules/configuration/services/test-mode-configuration.service.d.ts +4 -1
  5. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  6. package/core/services/flow-info.service.d.ts +5 -5
  7. package/core/services/flow-state-configuration.service.d.ts +7 -2
  8. package/core/utils/index.d.ts +1 -0
  9. package/core/utils/pcm.utils.d.ts +5 -0
  10. package/core/utils/transaction-item.utils.d.ts +5 -2
  11. package/esm2020/cms/vendor-map.mjs +7 -3
  12. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +21 -18
  13. package/esm2020/core/modules/configuration/services/configuration.service.mjs +4 -6
  14. package/esm2020/core/modules/configuration/services/guided-selling.service.mjs +9 -9
  15. package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +34 -11
  16. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  17. package/esm2020/core/services/flow-info.service.mjs +14 -14
  18. package/esm2020/core/services/flow-state-configuration.service.mjs +70 -33
  19. package/esm2020/core/utils/index.mjs +2 -1
  20. package/esm2020/core/utils/pcm.utils.mjs +15 -0
  21. package/esm2020/core/utils/transaction-item.utils.mjs +82 -6
  22. package/esm2020/src/guards/product-unload.guard.mjs +4 -2
  23. package/esm2020/src/pages/product/product.component.mjs +37 -10
  24. package/esm2020/src/resolvers/ui-definition.resolver.mjs +7 -5
  25. package/esm2020/src/services/flow-router.service.mjs +10 -10
  26. package/fesm2015/veloceapps-sdk-cms.mjs +5 -1
  27. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  28. package/fesm2015/veloceapps-sdk-core.mjs +221 -77
  29. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  30. package/fesm2015/veloceapps-sdk.mjs +49 -19
  31. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  32. package/fesm2020/veloceapps-sdk-cms.mjs +5 -1
  33. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  34. package/fesm2020/veloceapps-sdk-core.mjs +231 -84
  35. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  36. package/fesm2020/veloceapps-sdk.mjs +48 -19
  37. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  38. package/package.json +4 -4
  39. package/src/pages/product/product.component.d.ts +12 -3
  40. package/src/resolvers/ui-definition.resolver.d.ts +1 -1
  41. package/src/services/flow-router.service.d.ts +3 -3
@@ -146,6 +146,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
146
146
  }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
147
147
 
148
148
  class FlowInfoService {
149
+ constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
150
+ this.runtimeSettingsService = runtimeSettingsService;
151
+ this.templatesAdminApiService = templatesAdminApiService;
152
+ this.customizationService = customizationService;
153
+ this.defaultTemplates = {
154
+ flowEngine: 'Flow Engine',
155
+ };
156
+ this.flowSubj$ = new BehaviorSubject(null);
157
+ this.templatesSubj$ = new BehaviorSubject({});
158
+ this.contextSubj$ = new BehaviorSubject(null);
159
+ this.flow$ = this.flowSubj$.asObservable();
160
+ this.templates$ = this.templatesSubj$.asObservable();
161
+ }
149
162
  get flow() {
150
163
  if (!this.flowSubj$.value) {
151
164
  throw new Error(`Flow not initialized yet`);
@@ -173,19 +186,6 @@ class FlowInfoService {
173
186
  get isStateful() {
174
187
  return !!this.flow?.properties.stateful;
175
188
  }
176
- constructor(runtimeSettingsService, templatesAdminApiService, customizationService) {
177
- this.runtimeSettingsService = runtimeSettingsService;
178
- this.templatesAdminApiService = templatesAdminApiService;
179
- this.customizationService = customizationService;
180
- this.defaultTemplates = {
181
- flowEngine: 'Flow Engine',
182
- };
183
- this.flowSubj$ = new BehaviorSubject(null);
184
- this.templatesSubj$ = new BehaviorSubject({});
185
- this.contextSubj$ = new BehaviorSubject(null);
186
- this.flow$ = this.flowSubj$.asObservable();
187
- this.templates$ = this.templatesSubj$.asObservable();
188
- }
189
189
  reset() {
190
190
  this.flowSubj$.next(null);
191
191
  this.templatesSubj$.next({});
@@ -282,6 +282,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
282
282
  args: [FLOW_CUSTOMIZATION]
283
283
  }] }]; } });
284
284
 
285
+ class PCMUtils {
286
+ static mapByPrcId(pcm) {
287
+ const map = {};
288
+ if (pcm.productRelatedComponent) {
289
+ map[pcm.productRelatedComponent.id] = pcm;
290
+ }
291
+ for (const group of pcm.productComponentGroups) {
292
+ for (const gc of group.components) {
293
+ Object.assign(map, PCMUtils.mapByPrcId(gc));
294
+ }
295
+ }
296
+ return map;
297
+ }
298
+ }
299
+
285
300
  const findTransactionItem = (id, items) => {
286
301
  return findTransactionItemWithComparator(items, (ti) => ti.id === id);
287
302
  };
@@ -333,11 +348,86 @@ const replaceTransactionItem = (item, replaceTo) => {
333
348
  children: item.children.map(ti => replaceTransactionItem(ti, replaceTo)),
334
349
  };
335
350
  };
336
- const generateTransactionItem = (productId) => {
337
- return {
338
- id: UUID.UUID(),
339
- productId,
351
+ const generateTransactionItem = (option, salesTransactionId, qty, parentTi) => {
352
+ const newItem = generateTransactionItemFromPCM(option, salesTransactionId, parentTi);
353
+ // propagate Proportional quantities to children
354
+ const updatedNewItem = updateQuantity(newItem, qty ?? newItem.qty, option, parentTi?.qty);
355
+ return updatedNewItem;
356
+ };
357
+ const generateTransactionItemFromPCM = (option, salesTransactionId, parentTi) => {
358
+ const childId = UUID.UUID();
359
+ const newItem = {
360
+ id: childId,
361
+ productId: option.id,
362
+ productName: option.name,
363
+ productCode: option.productCode,
364
+ productRelatedComponentId: option.productRelatedComponent?.id,
365
+ stiAttributes: [],
366
+ attributes: {
367
+ ParentReference: salesTransactionId,
368
+ ItemPath: option.id,
369
+ SalesTransactionItemSource: childId,
370
+ SalesTransactionItemParent: salesTransactionId,
371
+ ProductSellingModel: option.productSellingModelOptions?.[0]?.productSellingModel.id,
372
+ },
373
+ qty: option.productRelatedComponent?.quantity ?? 1,
374
+ };
375
+ if (parentTi) {
376
+ newItem.parentId = parentTi.id;
377
+ }
378
+ newItem.children = option.productComponentGroups.reduce((acc, group) => {
379
+ group.components.forEach(component => {
380
+ if (component.productRelatedComponent?.isComponentRequired ||
381
+ component.productRelatedComponent?.isDefaultComponent) {
382
+ acc.push(generateTransactionItemFromPCM(component, salesTransactionId, newItem));
383
+ }
384
+ });
385
+ return acc;
386
+ }, []);
387
+ return newItem;
388
+ };
389
+ const flattenTransactionItem = (ti) => {
390
+ const result = [];
391
+ const traverse = (item) => {
392
+ if (!item)
393
+ return;
394
+ result.push(item);
395
+ if (Array.isArray(item.children) && item.children.length) {
396
+ for (const child of item.children) {
397
+ traverse(child);
398
+ }
399
+ }
340
400
  };
401
+ traverse(ti);
402
+ return result;
403
+ };
404
+ const updateQuantity = (ti, qty, pcm, parentQty = 1) => {
405
+ const pcmMap = PCMUtils.mapByPrcId(pcm);
406
+ const calcNewQty = (item, parentPrevQty, parentNewQty, parentPcm, inputQty, isDirectChange) => {
407
+ const scaleMethod = parentPcm?.productRelatedComponent?.quantityScaleMethod;
408
+ if (isDirectChange) {
409
+ return scaleMethod === 'Proportional' ? parentPrevQty * inputQty : inputQty;
410
+ }
411
+ else {
412
+ return scaleMethod === 'Proportional' ? (item.qty / parentPrevQty) * parentNewQty : item.qty;
413
+ }
414
+ };
415
+ const updateItem = (item, parentPrevQty, parentNewQty, isDirectChange) => {
416
+ const pcm = pcmMap[item.productRelatedComponentId];
417
+ let nextQty = item.qty;
418
+ if (item.id === ti.id || isDirectChange) {
419
+ nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, true);
420
+ }
421
+ else if (parentPrevQty !== parentNewQty) {
422
+ nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, false);
423
+ }
424
+ return {
425
+ ...item,
426
+ qty: nextQty,
427
+ children: item.children.map(child => updateItem(child, item.qty, nextQty, false)),
428
+ };
429
+ };
430
+ return updateItem(ti, parentQty, parentQty, false);
341
431
  };
342
432
 
343
433
  class TransactionItemWorker {
@@ -378,8 +468,8 @@ class GuidedSellingService {
378
468
  orchestrationName: data.orchestrationName,
379
469
  })
380
470
  .pipe(map(transactionContext => {
381
- const guidedSellingNode = transactionContext.childNodes['GuidedSelling']?.[0];
382
- const guidedSellingResult = guidedSellingNode?.tagAttributes?.['result'] || {};
471
+ const guidedSellingNode = transactionContext.nodes['GuidedSelling']?.[0];
472
+ const guidedSellingResult = guidedSellingNode?.attributes?.['result'] || {};
383
473
  this.guidedSellingResult$.next(guidedSellingResult);
384
474
  return guidedSellingResult;
385
475
  }));
@@ -392,24 +482,24 @@ class GuidedSellingService {
392
482
  id: UUID.UUID(),
393
483
  businessObjectType: 'Quote',
394
484
  salesTransactionItems: [],
395
- tagAttributes: {},
485
+ attributes: {},
396
486
  };
397
487
  return {
398
488
  salesTransaction: testTransaction,
399
489
  transactionId: UUID.UUID(),
400
490
  businessObjectType: 'Quote',
401
- childNodes: {
491
+ nodes: {
402
492
  GuidedSelling: [
403
493
  {
404
494
  id: UUID.UUID(),
405
- tagAttributes: {},
406
- childNodes: {},
495
+ attributes: {},
496
+ nodes: {},
407
497
  properties: { guidedSellingAttributes },
408
498
  },
409
499
  ],
410
500
  },
411
501
  id: UUID.UUID(),
412
- tagAttributes: {},
502
+ attributes: {},
413
503
  };
414
504
  }
415
505
  }
@@ -467,15 +557,13 @@ class ConfigurationService {
467
557
  transactionItem = salesTransactionItems.find(item => item.productId === productId);
468
558
  }
469
559
  if (!transactionItem) {
470
- transactionItem = generateTransactionItem(productId);
471
- if (typeof newProductQty === 'number' && newProductQty > 0) {
472
- transactionItem.qty = newProductQty;
473
- }
560
+ const quantity = typeof newProductQty === 'number' && newProductQty > 0 ? newProductQty : undefined;
561
+ transactionItem = generateTransactionItem(this.getPCMModel(), this.state?.salesTransaction.id, quantity);
474
562
  isRootGenerated = true;
475
563
  }
476
564
  const guidedSellingResult = this.guidedSellingService.guidedSellingResult;
477
565
  if (transactionItem && Object.keys(guidedSellingResult).length && isRootGenerated) {
478
- transactionItem.attributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
566
+ transactionItem.stiAttributes = Object.entries(guidedSellingResult).map(([attributeName, value]) => ({
479
567
  attributeName,
480
568
  value,
481
569
  }));
@@ -695,12 +783,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
695
783
  }], ctorParameters: function () { return [{ type: i1.OrchestrationsApiService }, { type: SalesTransactionService }, { type: FlowInfoService }]; } });
696
784
 
697
785
  class TestModeConfigurationService {
698
- constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService) {
786
+ constructor(flowInfoService, configurationService, configurationRuntimeService, salesTransactionService, runtimeSettingsService, sfApiService) {
699
787
  this.flowInfoService = flowInfoService;
700
788
  this.configurationService = configurationService;
701
789
  this.configurationRuntimeService = configurationRuntimeService;
702
790
  this.salesTransactionService = salesTransactionService;
703
791
  this.runtimeSettingsService = runtimeSettingsService;
792
+ this.sfApiService = sfApiService;
704
793
  this.isInitialized = false;
705
794
  }
706
795
  initTestMode$(uiDefinitionContainer, options) {
@@ -720,7 +809,7 @@ class TestModeConfigurationService {
720
809
  if (!flowId) {
721
810
  return throwError(() => `Unable to start the Configuration Preview: Flow is missing.`);
722
811
  }
723
- return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
812
+ return this.runtimeSettingsService.create().pipe(switchMap(() => this.flowInfoService.init$(flowId, { productId, headerId: quoteId, testMode: true })), switchMap(() => this.configurationRuntimeService.init$({ productId })), tap(pcmModel => (this.pcmModel = pcmModel)), switchMap(() => {
724
813
  if (options?.customizationMode) {
725
814
  return of(undefined);
726
815
  }
@@ -728,35 +817,55 @@ class TestModeConfigurationService {
728
817
  }), tap(() => (this.isInitialized = true)), map(noop));
729
818
  }
730
819
  initConfiguration$(quoteId) {
731
- this.salesTransactionService.setState(this.getTestTransactionContext(quoteId));
732
- return this.configurationService.init$().pipe(switchMap(() => this.configurationService.state
820
+ return this.getPriceBookId(quoteId).pipe(map(priceBookId => this.getTestTransactionContext(quoteId, priceBookId)), tap(state => this.salesTransactionService.setState(state)), switchMap(() => this.configurationService.init$()), switchMap(() => this.configurationService.state
733
821
  ? this.configurationService.configure$(this.configurationService.state)
734
822
  : of(undefined)), map(noop));
735
823
  }
736
- getTestTransactionContext(quoteId) {
824
+ getPriceBookId(quoteId) {
825
+ return this.sfApiService
826
+ .query({ count: 1, fields: ['Pricebook2Id'], rawCondition: `Id = '${quoteId}'` }, 'Quote')
827
+ .pipe(map(r => r?.[0]?.Pricebook2Id ?? null));
828
+ }
829
+ getTestTransactionContext(quoteId, priceBookId) {
830
+ const dateStr = new Date().toISOString().split('T')[0] ?? '';
737
831
  const testTransaction = {
738
832
  id: quoteId,
739
833
  businessObjectType: 'Quote',
740
834
  salesTransactionItems: [],
835
+ salesTransactionName: 'Test Quote',
836
+ account: '',
837
+ quoteAccount: '',
838
+ pricebook: '',
839
+ status: 'Draft',
840
+ totalAmount: 0,
841
+ subtotal: 0,
842
+ activatedDate: dateStr,
843
+ effectiveDate: dateStr,
844
+ startDate: dateStr,
845
+ attributes: {},
846
+ nodes: {},
741
847
  };
848
+ if (priceBookId) {
849
+ testTransaction.pricebook = priceBookId;
850
+ }
742
851
  return {
743
852
  salesTransaction: testTransaction,
744
853
  transactionId: quoteId,
745
854
  businessObjectType: 'Quote',
746
- childNodes: {},
855
+ nodes: {},
747
856
  id: UUID.UUID(),
748
- tagAttributes: {},
857
+ attributes: {},
749
858
  };
750
859
  }
751
860
  checkInitialized(uiDefinitionContainer) {
752
861
  return this.isInitialized && !!uiDefinitionContainer.source.properties?.persistTestState;
753
862
  }
754
863
  }
755
- 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 });
864
+ 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 }, { token: i1.SalesforceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
756
865
  TestModeConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService });
757
866
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: TestModeConfigurationService, decorators: [{
758
867
  type: Injectable
759
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }]; } });
868
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: ConfigurationService }, { type: ConfigurationRuntimeService }, { type: SalesTransactionService }, { type: RuntimeSettingsService }, { type: i1.SalesforceApiService }]; } });
760
869
 
761
870
  class FlowStateService {
762
871
  constructor(flowConfiguration, flowInfoService, flowStateApiService, processorsApiService, salesTransactionApiService, salesTransactionService, toastService, customizationService) {
@@ -1158,12 +1267,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1158
1267
  }] }]; } });
1159
1268
 
1160
1269
  class FlowStateConfigurationService {
1161
- constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService) {
1270
+ constructor(flowInfoService, flowStateService, configurationService, salesTransactionService, flowConfigurationService, pcmApiService) {
1162
1271
  this.flowInfoService = flowInfoService;
1163
1272
  this.flowStateService = flowStateService;
1164
1273
  this.configurationService = configurationService;
1165
1274
  this.salesTransactionService = salesTransactionService;
1166
1275
  this.flowConfigurationService = flowConfigurationService;
1276
+ this.pcmApiService = pcmApiService;
1277
+ this.pcmCache = {};
1278
+ }
1279
+ updateQuantity$(props) {
1280
+ const allItems = this.salesTransactionService.state?.salesTransaction?.salesTransactionItems ?? [];
1281
+ const ti = allItems.find(item => item.id === props.id);
1282
+ if (!ti) {
1283
+ return of(undefined);
1284
+ }
1285
+ return this.getPCMProduct$(ti.productId).pipe(map(pcm => updateQuantity(ti, props.qty, pcm)), switchMap(updatedTi => {
1286
+ const state = this.salesTransactionService.state;
1287
+ if (!state) {
1288
+ return of(undefined);
1289
+ }
1290
+ const updatedState = {
1291
+ ...state,
1292
+ salesTransaction: {
1293
+ ...state.salesTransaction,
1294
+ salesTransactionItems: state.salesTransaction.salesTransactionItems.map(item => {
1295
+ return updatedTi.id === item.id ? updatedTi : item;
1296
+ }),
1297
+ },
1298
+ };
1299
+ return this.flowConfigurationService.calculate$(updatedState);
1300
+ }), switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1167
1301
  }
1168
1302
  addToCart$(props) {
1169
1303
  let request$;
@@ -1184,47 +1318,57 @@ class FlowStateConfigurationService {
1184
1318
  return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(noop));
1185
1319
  }
1186
1320
  configureExternal$(props) {
1187
- const { state } = this.salesTransactionService;
1188
- if (!state) {
1189
- return of();
1190
- }
1191
- const stateToConfigure = {
1192
- ...state,
1193
- salesTransaction: {
1194
- ...state.salesTransaction,
1195
- salesTransactionItems: [
1196
- {
1197
- ...generateTransactionItem(props.productId),
1198
- qty: props.qty ?? 1,
1199
- attributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
1200
- attributeName,
1201
- value,
1202
- })),
1203
- },
1204
- ],
1205
- },
1206
- };
1207
- return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1208
- const state = this.salesTransactionService.state;
1209
- const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1210
- if (!state || !addedProduct) {
1321
+ return this.getPCMProduct$(props.productId).pipe(switchMap(pcm => {
1322
+ const { state } = this.salesTransactionService;
1323
+ if (!state) {
1211
1324
  return of();
1212
1325
  }
1213
- return this.flowConfigurationService.calculate$({
1326
+ const stateToConfigure = {
1214
1327
  ...state,
1215
1328
  salesTransaction: {
1216
1329
  ...state.salesTransaction,
1217
- salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
1330
+ salesTransactionItems: [
1331
+ {
1332
+ ...generateTransactionItem(pcm, this.configurationService.state?.salesTransaction.id, props.qty ?? 1),
1333
+ stiAttributes: Object.entries(props.attributesMap ?? {}).map(([attributeName, value]) => ({
1334
+ attributeName,
1335
+ value,
1336
+ })),
1337
+ },
1338
+ ],
1218
1339
  },
1219
- });
1340
+ };
1341
+ return this.configurationService.justConfigureRequest$(stateToConfigure).pipe(switchMap(configurationResult => {
1342
+ const state = this.salesTransactionService.state;
1343
+ const addedProduct = configurationResult.salesTransaction.salesTransactionItems[0];
1344
+ if (!state || !addedProduct) {
1345
+ return of();
1346
+ }
1347
+ return this.flowConfigurationService.calculate$({
1348
+ ...state,
1349
+ salesTransaction: {
1350
+ ...state.salesTransaction,
1351
+ salesTransactionItems: [...state.salesTransaction.salesTransactionItems, addedProduct],
1352
+ },
1353
+ });
1354
+ }));
1220
1355
  }));
1221
1356
  }
1357
+ getPCMProduct$(productId) {
1358
+ const cached = this.pcmCache[productId];
1359
+ if (cached) {
1360
+ return of(cached);
1361
+ }
1362
+ return this.pcmApiService
1363
+ .fetchPCMByProductId(productId)
1364
+ .pipe(tap(pcmProduct => (this.pcmCache[productId] = pcmProduct)));
1365
+ }
1222
1366
  }
1223
- FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1367
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowStateService }, { token: ConfigurationService }, { token: SalesTransactionService }, { token: FlowConfigurationService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1224
1368
  FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1225
1369
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1226
1370
  type: Injectable
1227
- }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }]; } });
1371
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowStateService }, { type: ConfigurationService }, { type: SalesTransactionService }, { type: FlowConfigurationService }, { type: i1.PCMApiService }]; } });
1228
1372
 
1229
1373
  class IntegrationState {
1230
1374
  constructor() {
@@ -1306,7 +1450,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1306
1450
  }] });
1307
1451
 
1308
1452
  class ConfigurationStateService {
1309
- constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService) {
1453
+ constructor(configurationRuntimeService, configurationService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, salesTransactionService, salesTransactionApiService, toastService, pcmApiService) {
1310
1454
  this.configurationRuntimeService = configurationRuntimeService;
1311
1455
  this.configurationService = configurationService;
1312
1456
  this.flowStateService = flowStateService;
@@ -1316,6 +1460,7 @@ class ConfigurationStateService {
1316
1460
  this.salesTransactionService = salesTransactionService;
1317
1461
  this.salesTransactionApiService = salesTransactionApiService;
1318
1462
  this.toastService = toastService;
1463
+ this.pcmApiService = pcmApiService;
1319
1464
  this.isInitialized$ = new BehaviorSubject(false);
1320
1465
  this.canceledConfiguration$ = new Subject();
1321
1466
  this.NOT_INITIALIZED = Symbol();
@@ -1433,13 +1578,6 @@ class ConfigurationStateService {
1433
1578
  return of({ id: '' });
1434
1579
  }
1435
1580
  const { standalone } = this.flowInfoService.flow.properties;
1436
- if (standalone) {
1437
- const request = {
1438
- transactionContext: state,
1439
- flowId: this.flowInfoService.flow.id,
1440
- };
1441
- return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
1442
- }
1443
1581
  const transactionContext = this.salesTransactionService.state;
1444
1582
  const configurationRoot = this.configurationService.root;
1445
1583
  if (!transactionContext || !configurationRoot) {
@@ -1461,6 +1599,13 @@ class ConfigurationStateService {
1461
1599
  salesTransactionItems,
1462
1600
  },
1463
1601
  };
1602
+ if (standalone) {
1603
+ const request = {
1604
+ transactionContext: newState,
1605
+ flowId: this.flowInfoService.flow.id,
1606
+ };
1607
+ return this.salesTransactionApiService.save(request).pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map(() => r))), map(id => ({ id })));
1608
+ }
1464
1609
  return this.flowConfigurationService.calculate$(newState).pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map(() => ({ id: '' })));
1465
1610
  }
1466
1611
  cancelConfiguration() {
@@ -1488,11 +1633,13 @@ class ConfigurationStateService {
1488
1633
  const container = this.configurationRuntimeService.uiDefinitionContainer;
1489
1634
  let request$;
1490
1635
  if (!transactionItemId) {
1491
- request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
1492
- transactionItem: generateTransactionItem(productId),
1493
- actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
1494
- selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
1495
- });
1636
+ request$ = this.pcmApiService.fetchPCMByProductId(productId).pipe(switchMap(pcm => {
1637
+ return this.flowStateApiService.newConfiguration(this.flowStateService.stateId || '', {
1638
+ transactionItem: generateTransactionItem(pcm, this.configurationService.state?.salesTransaction.id),
1639
+ actionsOverride: container?.actions?.map(processor => ({ ...processor, ownerId: this.ownerId })),
1640
+ selectorsOverride: container?.selectors?.map(processor => ({ ...processor, ownerId: this.ownerId })),
1641
+ });
1642
+ }));
1496
1643
  }
1497
1644
  else {
1498
1645
  request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
@@ -1657,11 +1804,11 @@ class ConfigurationStateService {
1657
1804
  }, { stateId: '', selectors: {} });
1658
1805
  }
1659
1806
  }
1660
- ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1807
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i3.FlowStateApiService }, { token: SalesTransactionService }, { token: i1.SalesTransactionApiService }, { token: i6.ToastService }, { token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1661
1808
  ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
1662
1809
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
1663
1810
  type: Injectable
1664
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }]; } });
1811
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i3.FlowStateApiService }, { type: SalesTransactionService }, { type: i1.SalesTransactionApiService }, { type: i6.ToastService }, { type: i1.PCMApiService }]; } });
1665
1812
 
1666
1813
  class ConfigurationModule {
1667
1814
  }
@@ -1922,5 +2069,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
1922
2069
  * Generated bundle index. Do not edit.
1923
2070
  */
1924
2071
 
1925
- export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, generateTransactionItem, insertTransactionItem, removeTransactionItem, replaceTransactionItem };
2072
+ export { ActionCodePipe, CalendarDirective, CatalogProductsService, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, GuidedSellingService, IntegrationState, NumberPipe, PCMUtils, PricePipe, ProductImagesService, RuntimeSettingsService, SalesTransactionService, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, TestModeConfigurationService, TransactionItemWorker, UI_DEFINITION_VERSION, extractMetadata, filterSuccessfulExecute, findTransactionItem, findTransactionItemWithComparator, flattenTransactionItem, generateTransactionItem, generateTransactionItemFromPCM, insertTransactionItem, removeTransactionItem, replaceTransactionItem, updateQuantity };
1926
2073
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map