@veloceapps/sdk 7.0.2-2 → 7.0.2-21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/cms/cms.actions.d.ts +7 -1
  2. package/cms/components/element-children/element-children.component.d.ts +3 -1
  3. package/cms/components/element-tools-panel/element-tools-panel.component.d.ts +14 -0
  4. package/cms/components/preview/preview.module.d.ts +2 -1
  5. package/cms/components/preview/preview.types.d.ts +4 -0
  6. package/cms/injection-tokens.d.ts +1 -3
  7. package/cms/modules/runtime/services/compilation.service.d.ts +2 -1
  8. package/cms/modules/runtime/services/runtime-editor.service.d.ts +6 -4
  9. package/cms/modules/runtime/types/runtime.actions.d.ts +5 -2
  10. package/cms/plugins/element-hover.plugin.d.ts +32 -0
  11. package/cms/plugins/script.plugin.d.ts +0 -3
  12. package/cms/types/common.types.d.ts +11 -1
  13. package/cms/types/index.d.ts +2 -0
  14. package/cms/types/layouts.types.d.ts +28 -2
  15. package/cms/types/pages.types.d.ts +1 -0
  16. package/cms/utils/elements-resolver.d.ts +5 -1
  17. package/cms/utils/script.utils.d.ts +2 -0
  18. package/cms/vendor-map.d.ts +7 -5
  19. package/core/modules/configuration/services/configuration.service.d.ts +3 -3
  20. package/core/types/ui-definition.types.d.ts +7 -2
  21. package/core/utils/line-item.utils.d.ts +4 -2
  22. package/core/utils/line-item.worker.d.ts +2 -2
  23. package/esm2020/cms/cms.actions.mjs +11 -2
  24. package/esm2020/cms/cms.elements.mjs +14 -3
  25. package/esm2020/cms/cms.layouts.mjs +39 -1
  26. package/esm2020/cms/components/element-children/element-children.component.mjs +11 -6
  27. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +2 -2
  28. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +35 -0
  29. package/esm2020/cms/components/preview/preview.module.mjs +22 -4
  30. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  31. package/esm2020/cms/injection-tokens.mjs +1 -2
  32. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +3 -3
  33. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +5 -3
  34. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +2 -2
  35. package/esm2020/cms/modules/runtime/types/runtime.actions.mjs +1 -1
  36. package/esm2020/cms/plugins/element-hover.plugin.mjs +112 -0
  37. package/esm2020/cms/plugins/script.plugin.mjs +6 -40
  38. package/esm2020/cms/services/integration.state.mjs +3 -6
  39. package/esm2020/cms/services/io-provider.service.mjs +7 -5
  40. package/esm2020/cms/types/common.types.mjs +1 -1
  41. package/esm2020/cms/types/index.mjs +3 -1
  42. package/esm2020/cms/types/layouts.types.mjs +70 -1
  43. package/esm2020/cms/types/pages.types.mjs +2 -0
  44. package/esm2020/cms/utils/elements-resolver.mjs +22 -8
  45. package/esm2020/cms/utils/script.utils.mjs +42 -0
  46. package/esm2020/cms/vendor-map.mjs +3 -2
  47. package/esm2020/core/modules/configuration/services/configuration.service.mjs +6 -5
  48. package/esm2020/core/types/ui-definition.types.mjs +1 -1
  49. package/esm2020/core/utils/line-item.utils.mjs +35 -16
  50. package/esm2020/core/utils/line-item.worker.mjs +5 -5
  51. package/esm2020/src/components/header/header.component.mjs +15 -3
  52. package/esm2020/src/flow-routing.module.mjs +1 -1
  53. package/fesm2015/veloceapps-sdk-cms.mjs +343 -108
  54. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  55. package/fesm2015/veloceapps-sdk-core.mjs +46 -24
  56. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  57. package/fesm2015/veloceapps-sdk.mjs +15 -2
  58. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  59. package/fesm2020/veloceapps-sdk-cms.mjs +424 -122
  60. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  61. package/fesm2020/veloceapps-sdk-core.mjs +46 -24
  62. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  63. package/fesm2020/veloceapps-sdk.mjs +14 -2
  64. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  65. package/package.json +1 -1
@@ -243,15 +243,22 @@ const removeLineItem = (lineItem, idToRemove) => {
243
243
  })
244
244
  .filter(r => !!r) });
245
245
  };
246
- const replaceLineItem = (lineItem, replaceTo) => {
246
+ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false) => {
247
247
  if (lineItem.id === replaceTo.id) {
248
- return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
248
+ if (!skipCardinalityCalculation) {
249
+ return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
250
+ }
251
+ else {
252
+ return Object.assign({}, replaceTo);
253
+ }
249
254
  }
250
- return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo)) });
255
+ return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)) });
251
256
  };
252
257
  const calculateCardinalityVariables = (lineItems) => {
253
258
  const cardVars = new Map();
254
- lineItems.forEach(li => {
259
+ lineItems
260
+ .filter(({ port, type }) => !!port && !!type)
261
+ .forEach(li => {
255
262
  var _a;
256
263
  const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
257
264
  cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
@@ -289,13 +296,13 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
289
296
  ];
290
297
  }, originalAttributes);
291
298
  };
292
- const patchAttributes = (rootLineItem, id, attrs) => {
299
+ const patchAttributes = (rootLineItem, id, attrs, skipCardinalityCalculation = false) => {
293
300
  const lineItem = findLineItem(id, [rootLineItem]);
294
301
  if (!lineItem) {
295
302
  return rootLineItem;
296
303
  }
297
304
  const attributes = upsertAttributes(lineItem.attributes, attrs);
298
- return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes }));
305
+ return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes }), skipCardinalityCalculation);
299
306
  };
300
307
  const getAttributeValue = (attributes, name) => { var _a; return (_a = attributes.find(attr => attr.name === name)) === null || _a === void 0 ? void 0 : _a.value; };
301
308
  const generateLineItem = (port, type, parentId, attributes = [], lineItems = []) => {
@@ -323,19 +330,31 @@ const getRecommendedPrices = (portDomain, type) => {
323
330
  const generateModifiedAssetsMap = (lineItems) => {
324
331
  return lineItems.reduce((acc, li) => {
325
332
  var _a;
326
- if (li.rampInstanceId && li.status !== 'EXIST') {
327
- let target = li;
328
- while (target && target.rampInstanceId) {
329
- target = lineItems.find(sub => sub.id === li.rampInstanceId);
330
- }
331
- const id = (_a = target === null || target === void 0 ? void 0 : target.assetId) !== null && _a !== void 0 ? _a : target === null || target === void 0 ? void 0 : target.openOrderLineItemId;
332
- if (id) {
333
- acc[id] = true;
334
- }
333
+ const isModified = isLineItemModified(li);
334
+ if (!isModified) {
335
+ return acc;
336
+ }
337
+ const target = getOriginParent(lineItems, li);
338
+ const id = (_a = target === null || target === void 0 ? void 0 : target.assetId) !== null && _a !== void 0 ? _a : target === null || target === void 0 ? void 0 : target.openOrderLineItemId;
339
+ if (id) {
340
+ acc[id] = true;
335
341
  }
336
342
  return acc;
337
343
  }, {});
338
344
  };
345
+ const getOriginParent = (lineItems, currentLineItem) => {
346
+ let target = currentLineItem;
347
+ while (target && target.rampInstanceId) {
348
+ target = lineItems.find(sub => sub.id === currentLineItem.rampInstanceId);
349
+ }
350
+ return target;
351
+ };
352
+ const isLineItemModified = (lineItem) => {
353
+ if (lineItem.actionCode === 'EXIST' && lineItem.status === 'PENDING') {
354
+ return false;
355
+ }
356
+ return lineItem.actionCode !== 'EXIST';
357
+ };
339
358
  const multiplyLineItems = (lineItem, qty, split) => {
340
359
  if (split) {
341
360
  const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
@@ -357,8 +376,10 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
357
376
  generateModifiedAssetsMap: generateModifiedAssetsMap,
358
377
  getAttributeValue: getAttributeValue,
359
378
  getAttributes: getAttributes,
379
+ getOriginParent: getOriginParent,
360
380
  getRecommendedPrices: getRecommendedPrices,
361
381
  insertLineItem: insertLineItem,
382
+ isLineItemModified: isLineItemModified,
362
383
  mapAttributes: mapAttributes,
363
384
  multiplyLineItems: multiplyLineItems,
364
385
  patchAttributes: patchAttributes,
@@ -378,11 +399,11 @@ class LineItemWorker {
378
399
  remove(id) {
379
400
  return new LineItemWorker(removeLineItem(this.li, id));
380
401
  }
381
- replace(toReplace) {
382
- return new LineItemWorker(replaceLineItem(this.li, toReplace));
402
+ replace(toReplace, skipCardinalityCalculation = false) {
403
+ return new LineItemWorker(replaceLineItem(this.li, toReplace, skipCardinalityCalculation));
383
404
  }
384
- patchAttribute(attrs, id) {
385
- return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
405
+ patchAttribute(attrs, id, skipCardinalityCalculation = false) {
406
+ return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs, skipCardinalityCalculation));
386
407
  }
387
408
  }
388
409
 
@@ -617,11 +638,12 @@ class ConfigurationService {
617
638
  this.charges.next({});
618
639
  this.pricePlans.next({});
619
640
  }
620
- patch$(lineItem) {
641
+ patch$(lineItem, options) {
621
642
  if (!this.lineItem.value) {
622
643
  return throwError(() => new Error(`Source LineItem not found`));
623
644
  }
624
- this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem).li;
645
+ const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
646
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
625
647
  return this.configure().pipe(catchError(error => {
626
648
  console.error(error);
627
649
  if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
@@ -636,8 +658,8 @@ class ConfigurationService {
636
658
  }
637
659
  }));
638
660
  }
639
- patch(lineItem) {
640
- this.patch$(lineItem).subscribe();
661
+ patch(lineItem, options) {
662
+ this.patch$(lineItem, options).subscribe();
641
663
  }
642
664
  setConfigurableRamp(lineItem) {
643
665
  this.configurableRamp = lineItem;
@@ -1228,5 +1250,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1228
1250
  * Generated bundle index. Do not edit.
1229
1251
  */
1230
1252
 
1231
- export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getRecommendedPrices, insertLineItem, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1253
+ export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1232
1254
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map