@crystaldesign/product-handler 26.5.0-beta.4 → 26.5.0-beta.40
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.
- package/build/cjs/index.js +210 -112
- package/build/esm/index.js +206 -113
- package/build/types/product-handler/src/applyProductHeaderOverrides.d.ts +12 -0
- package/build/types/product-handler/src/applyProductHeaderOverrides.d.ts.map +1 -0
- package/build/types/product-handler/src/index.d.ts +2 -0
- package/build/types/product-handler/src/index.d.ts.map +1 -1
- package/build/types/product-handler/src/productMergeFieldRegistry.d.ts +19 -0
- package/build/types/product-handler/src/productMergeFieldRegistry.d.ts.map +1 -0
- package/build/types/product-handler/src/types.d.ts +19 -0
- package/build/types/product-handler/src/types.d.ts.map +1 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -22,6 +22,81 @@ import axios from 'axios';
|
|
|
22
22
|
globalThis.process = { env:env };
|
|
23
23
|
})();
|
|
24
24
|
|
|
25
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
26
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
27
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
28
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
|
+
/** Root paths that are materialized from `headerValues` + `overrideValues`. Extend when adding merge rules. */
|
|
31
|
+
var PRODUCT_MERGE_FIELD_KEYS = ['customData'];
|
|
32
|
+
function isPlainObject(value) {
|
|
33
|
+
return value !== null && _typeof(value) === 'object' && !Array.isArray(value);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Deep-merge plain objects; nested plain objects merge, scalars and arrays are replaced by the override branch. */
|
|
37
|
+
function deepMergeRecords(base, override) {
|
|
38
|
+
var out = _objectSpread$1({}, base);
|
|
39
|
+
for (var _i = 0, _Object$keys = Object.keys(override); _i < _Object$keys.length; _i++) {
|
|
40
|
+
var key = _Object$keys[_i];
|
|
41
|
+
var b = base[key];
|
|
42
|
+
var o = override[key];
|
|
43
|
+
if (isPlainObject(b) && isPlainObject(o)) {
|
|
44
|
+
out[key] = deepMergeRecords(b, o);
|
|
45
|
+
} else {
|
|
46
|
+
out[key] = o;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
function mergeCustomDataMaterialized(product) {
|
|
52
|
+
var _product$headerValues, _product$headerValues2, _product$overrideValu, _product$overrideValu2;
|
|
53
|
+
var base = (_product$headerValues = (_product$headerValues2 = product.headerValues) === null || _product$headerValues2 === void 0 ? void 0 : _product$headerValues2.customData) !== null && _product$headerValues !== void 0 ? _product$headerValues : {};
|
|
54
|
+
var ov = (_product$overrideValu = (_product$overrideValu2 = product.overrideValues) === null || _product$overrideValu2 === void 0 ? void 0 : _product$overrideValu2.customData) !== null && _product$overrideValu !== void 0 ? _product$overrideValu : {};
|
|
55
|
+
var merged = deepMergeRecords(base, ov);
|
|
56
|
+
return _objectSpread$1(_objectSpread$1({}, product), {}, {
|
|
57
|
+
customData: merged
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var mergeStrategies = {
|
|
61
|
+
customData: mergeCustomDataMaterialized
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Materializes merge-fähige Root-Felder from `headerValues` (Basis) and `overrideValues` (Overrides).
|
|
66
|
+
* When neither `headerValues` nor `overrideValues` is set, returns the product unchanged (legacy documents).
|
|
67
|
+
*/
|
|
68
|
+
function applyProductHeaderOverrides(product) {
|
|
69
|
+
if (product.headerValues === undefined && product.overrideValues === undefined) {
|
|
70
|
+
return product;
|
|
71
|
+
}
|
|
72
|
+
var next = _objectSpread$1({}, product);
|
|
73
|
+
var _iterator = _createForOfIteratorHelper(PRODUCT_MERGE_FIELD_KEYS),
|
|
74
|
+
_step;
|
|
75
|
+
try {
|
|
76
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
77
|
+
var field = _step.value;
|
|
78
|
+
next = mergeStrategies[field](next);
|
|
79
|
+
}
|
|
80
|
+
} catch (err) {
|
|
81
|
+
_iterator.e(err);
|
|
82
|
+
} finally {
|
|
83
|
+
_iterator.f();
|
|
84
|
+
}
|
|
85
|
+
return next;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Root-JSON-Patch-Prefixe (mit `/`), die auf `overrideValues` umgebogen werden. */
|
|
89
|
+
function getMergeableRootJsonPatchPrefixes() {
|
|
90
|
+
return PRODUCT_MERGE_FIELD_KEYS.map(function (k) {
|
|
91
|
+
return "/".concat(k);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** JSON-Patch-Ziel unter `overrideValues` für ein merge-fähiges Feld (z. B. `customData` → `/overrideValues/customData`). */
|
|
96
|
+
function mergeFieldKeyToOverrideValuesPath(fieldKey) {
|
|
97
|
+
return "/overrideValues/".concat(fieldKey);
|
|
98
|
+
}
|
|
99
|
+
|
|
25
100
|
var _excluded = ["value"];
|
|
26
101
|
var _ProductHandlerAbstract;
|
|
27
102
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -238,7 +313,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
238
313
|
_ref3,
|
|
239
314
|
_baseProduct$configur5,
|
|
240
315
|
_baseProduct20;
|
|
241
|
-
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, getUniqueNewDivaNr, products, baseProduct, variantProducts, isDifferentHash, _basket$OrderSets$map, _baseProduct$configur, _baseProduct$configur2, basketHashes, productHashes, _baseProduct$configur3, _baseProduct$configur4, _basket$OrderSets$map2, myDivaNr, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$, opts, _i, initializedOptMap;
|
|
316
|
+
var basket, divaNr, catalogData, productData, classificationFields, fieldConfiguration, customBaseFields, classificationConfig, _ref2$availableLangua, availableLanguages, _ref2$currentLang, currentLang, getUniqueNewDivaNr, products, baseProduct, variantProducts, isDifferentHash, _basket$OrderSets$map, _baseProduct$configur, _baseProduct$configur2, basketHashes, productHashes, _baseProduct$configur3, _baseProduct$configur4, _basket$OrderSets$map2, myDivaNr, dataByBasket, oldClassificationData, i, variant, key, oldUniqueHash, configuration, baseData, metaData, metaData_locales, _this$parseMetaDataAn, classificationData, customData, optMap, _ProductHandlerAbstra, shortDescription, shortDescriptionModified, variantData, variantDataModified, addedProducts, removedProducts, optFields, initialSelectedFields, usedVariantIds, newVariantPosition, variantPositions, currentVariantPos, _basket$OrderSets$0$C2, differingOPTs, _variantData$0$config, _variantData$, _sourceConfiguration$, _sourceConfiguration$2, sourceConfiguration, orderLines, variantBasketDatas, opts, _i, initializedOptMap;
|
|
242
317
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
243
318
|
while (1) switch (_context2.prev = _context2.next) {
|
|
244
319
|
case 0:
|
|
@@ -468,20 +543,27 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
468
543
|
_ref7[1];
|
|
469
544
|
return opt.replace('OPT', '');
|
|
470
545
|
});
|
|
471
|
-
if (variantData) {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
var
|
|
476
|
-
|
|
546
|
+
if (variantData || baseData.configuration) {
|
|
547
|
+
sourceConfiguration = (_variantData$0$config = (_variantData$ = variantData[0]) === null || _variantData$ === void 0 ? void 0 : _variantData$.configuration) !== null && _variantData$0$config !== void 0 ? _variantData$0$config : baseData.configuration;
|
|
548
|
+
orderLines = (_sourceConfiguration$ = sourceConfiguration === null || sourceConfiguration === void 0 || (_sourceConfiguration$2 = sourceConfiguration.OrderSets) === null || _sourceConfiguration$2 === void 0 || (_sourceConfiguration$2 = _sourceConfiguration$2[0]) === null || _sourceConfiguration$2 === void 0 ? void 0 : _sourceConfiguration$2.OrderLines) !== null && _sourceConfiguration$ !== void 0 ? _sourceConfiguration$ : [];
|
|
549
|
+
variantBasketDatas = orderLines.flatMap(function (ol) {
|
|
550
|
+
var _ol$VariantBasketData;
|
|
551
|
+
return ((_ol$VariantBasketData = ol === null || ol === void 0 ? void 0 : ol.VariantBasketDatas) !== null && _ol$VariantBasketData !== void 0 ? _ol$VariantBasketData : []).filter(function (v) {
|
|
552
|
+
var _v$OPT;
|
|
553
|
+
return !((_v$OPT = v.OPT) !== null && _v$OPT !== void 0 && _v$OPT.endsWith('_val'));
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
optFields = variantBasketDatas.map(function (vd) {
|
|
557
|
+
var _catalogData, _vd$OptionOCD, _ref8, _option$Name;
|
|
558
|
+
var option = (_catalogData = catalogData) === null || _catalogData === void 0 || (_catalogData = _catalogData[0]) === null || _catalogData === void 0 || (_catalogData = _catalogData.options) === null || _catalogData === void 0 ? void 0 : _catalogData[(_vd$OptionOCD = vd.OptionOCD) !== null && _vd$OptionOCD !== void 0 ? _vd$OptionOCD : 'OPT' + vd.OPT];
|
|
477
559
|
return {
|
|
478
|
-
field: option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
|
|
560
|
+
field: option !== null && option !== void 0 && option.OptionOCD ? option.OptionOCD.substring(3) : vd.OPT,
|
|
479
561
|
type: 'string',
|
|
480
|
-
title: (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPT,
|
|
562
|
+
title: (_ref8 = (_option$Name = option === null || option === void 0 ? void 0 : option.Name) !== null && _option$Name !== void 0 ? _option$Name : vd.OPTName) !== null && _ref8 !== void 0 ? _ref8 : vd.OPT,
|
|
481
563
|
readOnly: true,
|
|
482
564
|
fieldType: 'OPT'
|
|
483
565
|
};
|
|
484
|
-
})
|
|
566
|
+
});
|
|
485
567
|
//remove duplicates
|
|
486
568
|
opts = {};
|
|
487
569
|
for (_i = optFields.length - 1; _i >= 0; _i--) {
|
|
@@ -590,7 +672,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
590
672
|
}
|
|
591
673
|
}
|
|
592
674
|
if (fieldConfiguration !== null && fieldConfiguration !== void 0 && fieldConfiguration.delivery) {
|
|
593
|
-
var _baseProduct$delivery, _baseProduct$delivery2, _baseProduct$delivery3, _baseProduct$delivery4, _baseProduct$delivery5, _baseProduct$delivery6, _baseProduct$delivery7, _baseProduct$delivery8, _baseProduct$delivery9, _baseProduct$delivery10,
|
|
675
|
+
var _baseProduct$delivery, _baseProduct$delivery2, _baseProduct$delivery3, _baseProduct$delivery4, _baseProduct$delivery5, _baseProduct$delivery6, _baseProduct$delivery7, _baseProduct$delivery8, _baseProduct$delivery9, _baseProduct$delivery10, _ref9, _baseProduct$delivery11, _baseProduct$delivery12, _fieldConfiguration$d, _ref10, _baseProduct$delivery13, _baseProduct$delivery14, _fieldConfiguration$d2, _ref11, _baseProduct$delivery15, _baseProduct$delivery16, _fieldConfiguration$d3;
|
|
594
676
|
var config = {
|
|
595
677
|
addedPackageWeight: 0,
|
|
596
678
|
addedPackageHeight: 0,
|
|
@@ -637,9 +719,9 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
637
719
|
}).filter(function (f) {
|
|
638
720
|
return f;
|
|
639
721
|
})))),
|
|
640
|
-
deliveryTime: (
|
|
641
|
-
deliveryPrice: (
|
|
642
|
-
installationPrice: (
|
|
722
|
+
deliveryTime: (_ref9 = (_baseProduct$delivery11 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery12 = baseProduct.delivery) === null || _baseProduct$delivery12 === void 0 ? void 0 : _baseProduct$delivery12.deliveryTime) !== null && _baseProduct$delivery11 !== void 0 ? _baseProduct$delivery11 : (_fieldConfiguration$d = fieldConfiguration.delivery) === null || _fieldConfiguration$d === void 0 ? void 0 : _fieldConfiguration$d.defaultDeliveryTime) !== null && _ref9 !== void 0 ? _ref9 : 0,
|
|
723
|
+
deliveryPrice: (_ref10 = (_baseProduct$delivery13 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery14 = baseProduct.delivery) === null || _baseProduct$delivery14 === void 0 ? void 0 : _baseProduct$delivery14.deliveryPrice) !== null && _baseProduct$delivery13 !== void 0 ? _baseProduct$delivery13 : (_fieldConfiguration$d2 = fieldConfiguration.delivery) === null || _fieldConfiguration$d2 === void 0 ? void 0 : _fieldConfiguration$d2.defaultDeliveryPrice) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
724
|
+
installationPrice: (_ref11 = (_baseProduct$delivery15 = baseProduct === null || baseProduct === void 0 || (_baseProduct$delivery16 = baseProduct.delivery) === null || _baseProduct$delivery16 === void 0 ? void 0 : _baseProduct$delivery16.installationPrice) !== null && _baseProduct$delivery15 !== void 0 ? _baseProduct$delivery15 : (_fieldConfiguration$d3 = fieldConfiguration.delivery) === null || _fieldConfiguration$d3 === void 0 ? void 0 : _fieldConfiguration$d3.defaultInstallationPrice) !== null && _ref11 !== void 0 ? _ref11 : 0
|
|
643
725
|
};
|
|
644
726
|
}
|
|
645
727
|
var ismanual = (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.calculatedPrice) !== (baseProduct === null || baseProduct === void 0 ? void 0 : baseProduct.addedPrice);
|
|
@@ -788,11 +870,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
788
870
|
key: "mapCategory",
|
|
789
871
|
value: function mapCategory(value, translations) {
|
|
790
872
|
var _translations$find2;
|
|
791
|
-
var
|
|
873
|
+
var _ref12 = (_translations$find2 = translations === null || translations === void 0 ? void 0 : translations.find(function (t) {
|
|
792
874
|
return t.value == value;
|
|
793
875
|
})) !== null && _translations$find2 !== void 0 ? _translations$find2 : {};
|
|
794
|
-
|
|
795
|
-
var translation = _objectWithoutProperties(
|
|
876
|
+
_ref12.value;
|
|
877
|
+
var translation = _objectWithoutProperties(_ref12, _excluded);
|
|
796
878
|
if (Object.keys(translation).length) {
|
|
797
879
|
return translation;
|
|
798
880
|
}
|
|
@@ -821,13 +903,13 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
821
903
|
}, {
|
|
822
904
|
key: "prepareData",
|
|
823
905
|
value: function () {
|
|
824
|
-
var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(
|
|
906
|
+
var _prepareData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref13) {
|
|
825
907
|
var _this3 = this;
|
|
826
|
-
var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap,
|
|
908
|
+
var basket, baseData, classificationData, variantData, removedProducts, removedMedia, classificationFields, fieldConfiguration, optMap, _ref13$oldClassificat, oldClassificationData, originProductId, products, originProduct, mediasToSave, sapEinaLifNr, sapEineEkgrp, _originProduct$custom, _originProduct$custom2, _originProduct$custom3, _originProduct$custom4, result, _this$closeModal, _originProduct$percen, _originProduct$discou, _baseData$variantId, _originProduct$create, _originProduct$create2, _originProduct$create3, baseProduct, j, mediaRef, _this$openModal, _this$t, _j, _this$openModal2, _this$t2, _loop, _j2, mediasForProducts, _loop2, productId;
|
|
827
909
|
return _regeneratorRuntime.wrap(function _callee3$(_context5) {
|
|
828
910
|
while (1) switch (_context5.prev = _context5.next) {
|
|
829
911
|
case 0:
|
|
830
|
-
basket =
|
|
912
|
+
basket = _ref13.basket, baseData = _ref13.baseData, classificationData = _ref13.classificationData, variantData = _ref13.variantData, removedProducts = _ref13.removedProducts, removedMedia = _ref13.removedMedia, classificationFields = _ref13.classificationFields, fieldConfiguration = _ref13.fieldConfiguration, optMap = _ref13.optMap, _ref13$oldClassificat = _ref13.oldClassificationData, oldClassificationData = _ref13$oldClassificat === void 0 ? {} : _ref13$oldClassificat, originProductId = _ref13.originProductId;
|
|
831
913
|
products = [];
|
|
832
914
|
originProduct = undefined;
|
|
833
915
|
mediasToSave = [];
|
|
@@ -850,8 +932,8 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
850
932
|
}
|
|
851
933
|
throw new Error('Origin Product not found');
|
|
852
934
|
case 11:
|
|
853
|
-
sapEinaLifNr = originProduct.customData.SAP_EINA_LIFNR.value;
|
|
854
|
-
sapEineEkgrp = originProduct.customData.SAP_EINE_EKGRP.value;
|
|
935
|
+
sapEinaLifNr = (_originProduct$custom = (_originProduct$custom2 = originProduct.customData.SAP) === null || _originProduct$custom2 === void 0 ? void 0 : _originProduct$custom2.SAP_EINA_LIFNR) !== null && _originProduct$custom !== void 0 ? _originProduct$custom : originProduct.customData.SAP_EINA_LIFNR.value;
|
|
936
|
+
sapEineEkgrp = (_originProduct$custom3 = (_originProduct$custom4 = originProduct.customData.SAP) === null || _originProduct$custom4 === void 0 ? void 0 : _originProduct$custom4.SAP_EINE_EKGRP) !== null && _originProduct$custom3 !== void 0 ? _originProduct$custom3 : originProduct.customData.SAP_EINE_EKGRP.value;
|
|
855
937
|
if (!(!sapEinaLifNr || !sapEineEkgrp)) {
|
|
856
938
|
_context5.next = 16;
|
|
857
939
|
break;
|
|
@@ -874,11 +956,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
874
956
|
}
|
|
875
957
|
this.trimStrings(baseData);
|
|
876
958
|
//the base product is constructed, based on baseData and classification data
|
|
877
|
-
baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev,
|
|
959
|
+
baseProduct = _objectSpread(_objectSpread(_objectSpread({}, baseData), Object.entries(classificationData || {}).reduce(function (prev, _ref14) {
|
|
878
960
|
var _fieldConfiguration$c;
|
|
879
|
-
var
|
|
880
|
-
key =
|
|
881
|
-
value =
|
|
961
|
+
var _ref15 = _slicedToArray(_ref14, 2),
|
|
962
|
+
key = _ref15[0],
|
|
963
|
+
value = _ref15[1];
|
|
882
964
|
prev["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$c = fieldConfiguration.classMap[key]) === null || _fieldConfiguration$c === void 0 ? void 0 : _fieldConfiguration$c.values);
|
|
883
965
|
return prev;
|
|
884
966
|
}, {})), {}, {
|
|
@@ -890,11 +972,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
890
972
|
});
|
|
891
973
|
if (!originProduct && baseData.customData) {
|
|
892
974
|
//convert all customData to objects with value and translations, if they exists
|
|
893
|
-
Object.entries(baseData.customData).forEach(function (
|
|
975
|
+
Object.entries(baseData.customData).forEach(function (_ref16) {
|
|
894
976
|
var _baseProduct$customDa;
|
|
895
|
-
var
|
|
896
|
-
key =
|
|
897
|
-
value =
|
|
977
|
+
var _ref17 = _slicedToArray(_ref16, 2),
|
|
978
|
+
key = _ref17[0],
|
|
979
|
+
value = _ref17[1];
|
|
898
980
|
if (!((_baseProduct$customDa = baseProduct.customData[key]) !== null && _baseProduct$customDa !== void 0 && _baseProduct$customDa.value)) {
|
|
899
981
|
var _fieldConfiguration$a;
|
|
900
982
|
baseProduct.customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a = fieldConfiguration.additional) === null || _fieldConfiguration$a === void 0 || (_fieldConfiguration$a = _fieldConfiguration$a[key]) === null || _fieldConfiguration$a === void 0 ? void 0 : _fieldConfiguration$a.values);
|
|
@@ -903,16 +985,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
903
985
|
}
|
|
904
986
|
if (optMap) {
|
|
905
987
|
//save to class fields the information to which opt it maps
|
|
906
|
-
Object.entries(optMap).filter(function (
|
|
907
|
-
var
|
|
908
|
-
|
|
909
|
-
var value =
|
|
988
|
+
Object.entries(optMap).filter(function (_ref18) {
|
|
989
|
+
var _ref19 = _slicedToArray(_ref18, 2);
|
|
990
|
+
_ref19[0];
|
|
991
|
+
var value = _ref19[1];
|
|
910
992
|
return value;
|
|
911
|
-
}).forEach(function (
|
|
993
|
+
}).forEach(function (_ref20) {
|
|
912
994
|
var _baseProduct21;
|
|
913
|
-
var
|
|
914
|
-
key =
|
|
915
|
-
value =
|
|
995
|
+
var _ref21 = _slicedToArray(_ref20, 2),
|
|
996
|
+
key = _ref21[0],
|
|
997
|
+
value = _ref21[1];
|
|
916
998
|
return baseProduct["dc_".concat(key)] = _objectSpread(_objectSpread({}, (_baseProduct21 = baseProduct["dc_".concat(key)]) !== null && _baseProduct21 !== void 0 ? _baseProduct21 : {}), {}, {
|
|
917
999
|
opt: value.field
|
|
918
1000
|
});
|
|
@@ -987,11 +1069,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
987
1069
|
case 3:
|
|
988
1070
|
varinatBase = {};
|
|
989
1071
|
classData = {};
|
|
990
|
-
Object.entries(vd).forEach(function (
|
|
1072
|
+
Object.entries(vd).forEach(function (_ref22) {
|
|
991
1073
|
var _optMap$key;
|
|
992
|
-
var
|
|
993
|
-
key =
|
|
994
|
-
value =
|
|
1074
|
+
var _ref23 = _slicedToArray(_ref22, 2),
|
|
1075
|
+
key = _ref23[0],
|
|
1076
|
+
value = _ref23[1];
|
|
995
1077
|
//save those fields that are specified as class fields
|
|
996
1078
|
if (classificationFields !== null && classificationFields !== void 0 && classificationFields.includes(key) && (value || optMap !== null && optMap !== void 0 && (_optMap$key = optMap[key]) !== null && _optMap$key !== void 0 && _optMap$key.field)) {
|
|
997
1079
|
classData["dc_".concat(key)] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 ? void 0 : fieldConfiguration.classMap[key].values);
|
|
@@ -1005,16 +1087,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1005
1087
|
});
|
|
1006
1088
|
if (optMap) {
|
|
1007
1089
|
//save to class fields the information to which opt it maps
|
|
1008
|
-
Object.entries(optMap).filter(function (
|
|
1009
|
-
var
|
|
1010
|
-
|
|
1011
|
-
var value =
|
|
1090
|
+
Object.entries(optMap).filter(function (_ref24) {
|
|
1091
|
+
var _ref25 = _slicedToArray(_ref24, 2);
|
|
1092
|
+
_ref25[0];
|
|
1093
|
+
var value = _ref25[1];
|
|
1012
1094
|
return value;
|
|
1013
|
-
}).forEach(function (
|
|
1095
|
+
}).forEach(function (_ref26) {
|
|
1014
1096
|
var _oldClassificationDat, _oldClassificationDat2, _value$field, _value$field2, _value$field3, _value$field4;
|
|
1015
|
-
var
|
|
1016
|
-
key =
|
|
1017
|
-
value =
|
|
1097
|
+
var _ref27 = _slicedToArray(_ref26, 2),
|
|
1098
|
+
key = _ref27[0],
|
|
1099
|
+
value = _ref27[1];
|
|
1018
1100
|
return classData["dc_".concat(key)] = _objectSpread(_objectSpread(_objectSpread({}, (_oldClassificationDat = (_oldClassificationDat2 = oldClassificationData[vd._id]) === null || _oldClassificationDat2 === void 0 ? void 0 : _oldClassificationDat2["dc_".concat(key)]) !== null && _oldClassificationDat !== void 0 ? _oldClassificationDat : {}), classData["dc_".concat(key)]), {}, {
|
|
1019
1101
|
opt: value.field,
|
|
1020
1102
|
opv: (_value$field = vd[value.field]) === null || _value$field === void 0 ? void 0 : _value$field.codex,
|
|
@@ -1030,11 +1112,11 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1030
1112
|
if (vd.customData) {
|
|
1031
1113
|
customData = {};
|
|
1032
1114
|
//convert all customData to objects with value and translations, if they exists
|
|
1033
|
-
Object.entries(vd.customData).forEach(function (
|
|
1115
|
+
Object.entries(vd.customData).forEach(function (_ref28) {
|
|
1034
1116
|
var _vd$customData, _fieldConfiguration$a2;
|
|
1035
|
-
var
|
|
1036
|
-
key =
|
|
1037
|
-
value =
|
|
1117
|
+
var _ref29 = _slicedToArray(_ref28, 2),
|
|
1118
|
+
key = _ref29[0],
|
|
1119
|
+
value = _ref29[1];
|
|
1038
1120
|
if (!((_vd$customData = vd.customData) !== null && _vd$customData !== void 0 && (_vd$customData = _vd$customData[key]) !== null && _vd$customData !== void 0 && _vd$customData.value)) customData[key] = _this3.mapClass(value, fieldConfiguration === null || fieldConfiguration === void 0 || (_fieldConfiguration$a2 = fieldConfiguration.additional) === null || _fieldConfiguration$a2 === void 0 || (_fieldConfiguration$a2 = _fieldConfiguration$a2[key]) === null || _fieldConfiguration$a2 === void 0 ? void 0 : _fieldConfiguration$a2.values);
|
|
1039
1121
|
});
|
|
1040
1122
|
}
|
|
@@ -1068,6 +1150,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1068
1150
|
},
|
|
1069
1151
|
SAP_EINE_EKGRP: {
|
|
1070
1152
|
value: sapEineEkgrp
|
|
1153
|
+
},
|
|
1154
|
+
SAP: {
|
|
1155
|
+
SAP_EINA_LIFNR: sapEinaLifNr,
|
|
1156
|
+
SAP_EINE_EKGRP: sapEineEkgrp
|
|
1071
1157
|
}
|
|
1072
1158
|
}) : customData,
|
|
1073
1159
|
modelInfoPageWeight: baseProduct.modelInfoPageWeight,
|
|
@@ -1212,12 +1298,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1212
1298
|
}, {
|
|
1213
1299
|
key: "saveProducts",
|
|
1214
1300
|
value: function () {
|
|
1215
|
-
var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(
|
|
1301
|
+
var _saveProducts = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref30) {
|
|
1216
1302
|
var products, removedProducts, awaitPDF, _this$closeModal2, savedProducts, _this$closeModal3;
|
|
1217
1303
|
return _regeneratorRuntime.wrap(function _callee4$(_context6) {
|
|
1218
1304
|
while (1) switch (_context6.prev = _context6.next) {
|
|
1219
1305
|
case 0:
|
|
1220
|
-
products =
|
|
1306
|
+
products = _ref30.products, removedProducts = _ref30.removedProducts, awaitPDF = _ref30.awaitPDF;
|
|
1221
1307
|
if (this.jwt) {
|
|
1222
1308
|
_context6.next = 3;
|
|
1223
1309
|
break;
|
|
@@ -1283,24 +1369,24 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1283
1369
|
var _basket$OrderSets$0$C3, _variantProduct$confi, _variantProduct$confi2, _variantProduct$order, _classificationFields;
|
|
1284
1370
|
var _this$parseClassifica = this.parseClassificationFields(variantProduct),
|
|
1285
1371
|
parsedProduct = _this$parseClassifica.product;
|
|
1286
|
-
var
|
|
1372
|
+
var _ref31 = (basket === null || basket === void 0 || (_basket$OrderSets$0$C3 = basket.OrderSets[0].ConfigVariants) === null || _basket$OrderSets$0$C3 === void 0 ? void 0 : _basket$OrderSets$0$C3.find(function (vd) {
|
|
1287
1373
|
return vd.VariantID === cv;
|
|
1288
1374
|
})) || {
|
|
1289
1375
|
VariantBasketDatas: ProductHandlerAbstract.getVariantBasketDatasByOrderlines((_variantProduct$confi = variantProduct === null || variantProduct === void 0 || (_variantProduct$confi2 = variantProduct.configuration) === null || _variantProduct$confi2 === void 0 ? void 0 : _variantProduct$confi2.OrderSets[0].OrderLines) !== null && _variantProduct$confi !== void 0 ? _variantProduct$confi : [], catalogData)
|
|
1290
1376
|
},
|
|
1291
|
-
VariantID =
|
|
1292
|
-
SetImage =
|
|
1293
|
-
Set2DImage =
|
|
1294
|
-
SetPrice =
|
|
1295
|
-
VariantBasketDatas =
|
|
1296
|
-
BBox =
|
|
1297
|
-
MetaData =
|
|
1298
|
-
MetaData_locales =
|
|
1299
|
-
Variant =
|
|
1300
|
-
SetHash =
|
|
1301
|
-
Diva3DProject =
|
|
1302
|
-
VariantDescription_locales =
|
|
1303
|
-
VariantDescription =
|
|
1377
|
+
VariantID = _ref31.VariantID,
|
|
1378
|
+
SetImage = _ref31.SetImage,
|
|
1379
|
+
Set2DImage = _ref31.Set2DImage,
|
|
1380
|
+
SetPrice = _ref31.SetPrice,
|
|
1381
|
+
VariantBasketDatas = _ref31.VariantBasketDatas,
|
|
1382
|
+
BBox = _ref31.BBox,
|
|
1383
|
+
MetaData = _ref31.MetaData,
|
|
1384
|
+
MetaData_locales = _ref31.MetaData_locales,
|
|
1385
|
+
Variant = _ref31.Variant,
|
|
1386
|
+
SetHash = _ref31.SetHash,
|
|
1387
|
+
Diva3DProject = _ref31.Diva3DProject,
|
|
1388
|
+
VariantDescription_locales = _ref31.VariantDescription_locales,
|
|
1389
|
+
VariantDescription = _ref31.VariantDescription;
|
|
1304
1390
|
//total and summary price are currently not avialable per varinat,
|
|
1305
1391
|
//most of the time the prices will allways be the same and since we currently not support varinats for multiple sets
|
|
1306
1392
|
//we use the addedPrice of the baseData as long as the calculatedPrice is the same as the SetPrice of the variant
|
|
@@ -1439,10 +1525,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1439
1525
|
key: "initOpvMap",
|
|
1440
1526
|
value: function initOpvMap(optFields, classificationConfig, savedOptMap) {
|
|
1441
1527
|
var optMap = {};
|
|
1442
|
-
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (
|
|
1443
|
-
var
|
|
1444
|
-
c =
|
|
1445
|
-
optMapping =
|
|
1528
|
+
Object.entries((classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap) || {}).forEach(function (_ref32) {
|
|
1529
|
+
var _ref33 = _slicedToArray(_ref32, 2),
|
|
1530
|
+
c = _ref33[0],
|
|
1531
|
+
optMapping = _ref33[1].optMapping;
|
|
1446
1532
|
var optField;
|
|
1447
1533
|
if (savedOptMap !== null && savedOptMap !== void 0 && savedOptMap[c]) {
|
|
1448
1534
|
optField = optFields.find(function (opt) {
|
|
@@ -1503,16 +1589,16 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1503
1589
|
var _classificationConfig;
|
|
1504
1590
|
//add metadata defined as classification to classificationdata
|
|
1505
1591
|
var metadataAsClassification = {};
|
|
1506
|
-
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (
|
|
1507
|
-
var
|
|
1508
|
-
key =
|
|
1592
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref34) {
|
|
1593
|
+
var _ref35 = _slicedToArray(_ref34, 1),
|
|
1594
|
+
key = _ref35[0];
|
|
1509
1595
|
return classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.classMap[key];
|
|
1510
1596
|
})
|
|
1511
1597
|
//if it is defiend as multi field, use full array otherwise only first element of array
|
|
1512
|
-
.forEach(function (
|
|
1513
|
-
var
|
|
1514
|
-
key =
|
|
1515
|
-
value =
|
|
1598
|
+
.forEach(function (_ref36) {
|
|
1599
|
+
var _ref37 = _slicedToArray(_ref36, 2),
|
|
1600
|
+
key = _ref37[0],
|
|
1601
|
+
value = _ref37[1];
|
|
1516
1602
|
return metadataAsClassification[key] = classificationConfig.classMap[key].multi ? value : value === null || value === void 0 ? void 0 : value[0];
|
|
1517
1603
|
});
|
|
1518
1604
|
|
|
@@ -1522,14 +1608,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1522
1608
|
optMap = _this$parseClassifica2.optMap;
|
|
1523
1609
|
var classificationData = _objectSpread(_objectSpread({}, metadataAsClassification), productClassification);
|
|
1524
1610
|
var customData = {};
|
|
1525
|
-
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (
|
|
1526
|
-
var
|
|
1527
|
-
key =
|
|
1611
|
+
Object.entries(metaData !== null && metaData !== void 0 ? metaData : {}).filter(function (_ref38) {
|
|
1612
|
+
var _ref39 = _slicedToArray(_ref38, 1),
|
|
1613
|
+
key = _ref39[0];
|
|
1528
1614
|
return !(classificationConfig !== null && classificationConfig !== void 0 && classificationConfig.classMap[key]);
|
|
1529
|
-
}).forEach(function (
|
|
1530
|
-
var
|
|
1531
|
-
key =
|
|
1532
|
-
value =
|
|
1615
|
+
}).forEach(function (_ref40) {
|
|
1616
|
+
var _ref41 = _slicedToArray(_ref40, 2),
|
|
1617
|
+
key = _ref41[0],
|
|
1618
|
+
value = _ref41[1];
|
|
1533
1619
|
var langs = {};
|
|
1534
1620
|
if (metaData_locales !== null && metaData_locales !== void 0 && metaData_locales[key]) {
|
|
1535
1621
|
for (var i = 0; i < metaData_locales[key].length; i++) {
|
|
@@ -1561,14 +1647,14 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1561
1647
|
|
|
1562
1648
|
//repare customData
|
|
1563
1649
|
//if it is defiend as multi field, use full array otherwise only first element of array
|
|
1564
|
-
Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (
|
|
1565
|
-
var
|
|
1566
|
-
key =
|
|
1650
|
+
Object.entries((_classificationConfig = classificationConfig === null || classificationConfig === void 0 ? void 0 : classificationConfig.additional) !== null && _classificationConfig !== void 0 ? _classificationConfig : []).filter(function (_ref42) {
|
|
1651
|
+
var _ref43 = _slicedToArray(_ref42, 1),
|
|
1652
|
+
key = _ref43[0];
|
|
1567
1653
|
return customData[key] != undefined;
|
|
1568
|
-
}).forEach(function (
|
|
1569
|
-
var
|
|
1570
|
-
key =
|
|
1571
|
-
value =
|
|
1654
|
+
}).forEach(function (_ref44) {
|
|
1655
|
+
var _ref45 = _slicedToArray(_ref44, 2),
|
|
1656
|
+
key = _ref45[0],
|
|
1657
|
+
value = _ref45[1];
|
|
1572
1658
|
if (value.multi && !Array.isArray(customData[key])) {
|
|
1573
1659
|
customData[key] = [customData[key]];
|
|
1574
1660
|
} else if (!value.multi && Array.isArray(customData[key])) {
|
|
@@ -1787,13 +1873,20 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1787
1873
|
key: "apiGetCatalogDataIDM",
|
|
1788
1874
|
value: function () {
|
|
1789
1875
|
var _apiGetCatalogDataIDM = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(serieNo, language, catalogId) {
|
|
1790
|
-
var _cat$Properties, _cat$detailInfos$filt, _cat$detailInfos;
|
|
1791
|
-
var fullUrl, response, cat, actCatalogInfoData;
|
|
1876
|
+
var _this$organization, _cat$Properties, _cat$detailInfos$filt, _cat$detailInfos;
|
|
1877
|
+
var organizationId, fullUrl, response, cat, actCatalogInfoData;
|
|
1792
1878
|
return _regeneratorRuntime.wrap(function _callee8$(_context10) {
|
|
1793
1879
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1794
1880
|
case 0:
|
|
1795
|
-
|
|
1796
|
-
|
|
1881
|
+
organizationId = (_this$organization = this.organization) === null || _this$organization === void 0 ? void 0 : _this$organization._id;
|
|
1882
|
+
if (organizationId) {
|
|
1883
|
+
_context10.next = 3;
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
throw new Error('organizationId is required to load IDM catalog data');
|
|
1887
|
+
case 3:
|
|
1888
|
+
fullUrl = this.enricherService + '/live/' + organizationId + '/packages/' + catalogId + '/series/' + serieNo;
|
|
1889
|
+
_context10.next = 6;
|
|
1797
1890
|
return fetch(fullUrl, {
|
|
1798
1891
|
headers: _objectSpread(_objectSpread({}, this.getHeaders()), {}, {
|
|
1799
1892
|
'Content-Type': 'application/json'
|
|
@@ -1804,21 +1897,21 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1804
1897
|
}
|
|
1805
1898
|
return res.json();
|
|
1806
1899
|
});
|
|
1807
|
-
case
|
|
1900
|
+
case 6:
|
|
1808
1901
|
response = _context10.sent;
|
|
1809
1902
|
if (!response.Error) {
|
|
1810
|
-
_context10.next =
|
|
1903
|
+
_context10.next = 9;
|
|
1811
1904
|
break;
|
|
1812
1905
|
}
|
|
1813
1906
|
throw new Error(response.Error);
|
|
1814
|
-
case
|
|
1907
|
+
case 9:
|
|
1815
1908
|
cat = response;
|
|
1816
1909
|
if (cat) {
|
|
1817
|
-
_context10.next =
|
|
1910
|
+
_context10.next = 12;
|
|
1818
1911
|
break;
|
|
1819
1912
|
}
|
|
1820
1913
|
throw new Error('serieNo: ' + serieNo + ' not found');
|
|
1821
|
-
case
|
|
1914
|
+
case 12:
|
|
1822
1915
|
actCatalogInfoData = {
|
|
1823
1916
|
lang: language,
|
|
1824
1917
|
guid: cat._id,
|
|
@@ -1847,7 +1940,7 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
1847
1940
|
documents: []
|
|
1848
1941
|
};
|
|
1849
1942
|
return _context10.abrupt("return", actCatalogInfoData);
|
|
1850
|
-
case
|
|
1943
|
+
case 14:
|
|
1851
1944
|
case "end":
|
|
1852
1945
|
return _context10.stop();
|
|
1853
1946
|
}
|
|
@@ -2218,12 +2311,12 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2218
2311
|
}, {
|
|
2219
2312
|
key: "apiLoadProductVariantsGrouped",
|
|
2220
2313
|
value: function () {
|
|
2221
|
-
var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(
|
|
2222
|
-
var limit, skip, fields,
|
|
2314
|
+
var _apiLoadProductVariantsGrouped = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref46) {
|
|
2315
|
+
var limit, skip, fields, _ref46$search, search, sort, favorites, abortController, fullUrl, headers, promise;
|
|
2223
2316
|
return _regeneratorRuntime.wrap(function _callee15$(_context17) {
|
|
2224
2317
|
while (1) switch (_context17.prev = _context17.next) {
|
|
2225
2318
|
case 0:
|
|
2226
|
-
limit =
|
|
2319
|
+
limit = _ref46.limit, skip = _ref46.skip, fields = _ref46.fields, _ref46$search = _ref46.search, search = _ref46$search === void 0 ? [] : _ref46$search, sort = _ref46.sort, favorites = _ref46.favorites, abortController = _ref46.abortController;
|
|
2227
2320
|
fullUrl = this.catalogService + '/v1/products/groups' + '?organizationId=' + this.organization._id + (this._organization.parentOrganizationIds ? '&parentOrganizationIds=' + this._organization.parentOrganizationIds.join(',') : '') + (limit ? '&limit=' + limit : '') + (skip ? '&skip=' + skip : '') + (fields ? '&fileds=' + DivaUtils.fixedEncodeURIComponent('{' + fields.join(',') + '}') : '') + (search.length ? '&search=' + DivaUtils.fixedEncodeURIComponent(this.parseFilter(search)) : '') + (sort ? '&sort=' + DivaUtils.fixedEncodeURIComponent(sort) : '') + (favorites ? '&favorites=true' : '');
|
|
2228
2321
|
headers = {
|
|
2229
2322
|
'Content-Type': 'application/json'
|
|
@@ -2607,10 +2700,10 @@ var ProductHandlerAbstract = /*#__PURE__*/function () {
|
|
|
2607
2700
|
return Object.assign.apply(Object, [target].concat(_toConsumableArray(sources.filter(function (s) {
|
|
2608
2701
|
return s;
|
|
2609
2702
|
}).map(function (x) {
|
|
2610
|
-
return Object.fromEntries(Object.entries(x).filter(function (
|
|
2611
|
-
var
|
|
2612
|
-
|
|
2613
|
-
var value =
|
|
2703
|
+
return Object.fromEntries(Object.entries(x).filter(function (_ref47) {
|
|
2704
|
+
var _ref48 = _slicedToArray(_ref47, 2);
|
|
2705
|
+
_ref48[0];
|
|
2706
|
+
var value = _ref48[1];
|
|
2614
2707
|
return value !== undefined;
|
|
2615
2708
|
}));
|
|
2616
2709
|
}))));
|
|
@@ -2917,4 +3010,4 @@ _defineProperty(ProductHandlerAbstract, "standardBaseDataFields", [{
|
|
|
2917
3010
|
}]);
|
|
2918
3011
|
_defineProperty(ProductHandlerAbstract, "baseDataFields", _ProductHandlerAbstract.standardBaseDataFields.concat(_ProductHandlerAbstract.generalBaseDataFields));
|
|
2919
3012
|
|
|
2920
|
-
export { ProductHandlerAbstract, TRANSLATED_FILEDS };
|
|
3013
|
+
export { PRODUCT_MERGE_FIELD_KEYS, ProductHandlerAbstract, TRANSLATED_FILEDS, applyProductHeaderOverrides, deepMergeRecords, getMergeableRootJsonPatchPrefixes, mergeFieldKeyToOverrideValuesPath };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProductDataAbstract } from './types';
|
|
2
|
+
/** Root paths that are materialized from `headerValues` + `overrideValues`. Extend when adding merge rules. */
|
|
3
|
+
export declare const PRODUCT_MERGE_FIELD_KEYS: readonly ["customData"];
|
|
4
|
+
export type ProductMergeFieldKey = (typeof PRODUCT_MERGE_FIELD_KEYS)[number];
|
|
5
|
+
/** Deep-merge plain objects; nested plain objects merge, scalars and arrays are replaced by the override branch. */
|
|
6
|
+
export declare function deepMergeRecords(base: Record<string, any>, override: Record<string, any>): Record<string, any>;
|
|
7
|
+
/**
|
|
8
|
+
* Materializes merge-fähige Root-Felder from `headerValues` (Basis) and `overrideValues` (Overrides).
|
|
9
|
+
* When neither `headerValues` nor `overrideValues` is set, returns the product unchanged (legacy documents).
|
|
10
|
+
*/
|
|
11
|
+
export declare function applyProductHeaderOverrides(product: ProductDataAbstract): ProductDataAbstract;
|
|
12
|
+
//# sourceMappingURL=applyProductHeaderOverrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"applyProductHeaderOverrides.d.ts","sourceRoot":"","sources":["../../../../src/applyProductHeaderOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,+GAA+G;AAC/G,eAAO,MAAM,wBAAwB,yBAA0B,CAAC;AAEhE,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAM7E,oHAAoH;AACpH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAY9G;AAeD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,mBAAmB,GAAG,mBAAmB,CAU7F"}
|
|
@@ -4,6 +4,8 @@ import { UserData, FilterObject, Modal, Media } from '@crystaldesign/diva-core';
|
|
|
4
4
|
import { BasketData, Discount, OrderLineData, ProductConfigurationOrderLine, VariantItemData } from '@crystaldesign/basket-model';
|
|
5
5
|
import { BaseValueField, CatalogInfoData, ClassificationData, ClassificationField, ClassType, Field, FieldConfiguraton, MediaAbstract, OPTValueField, ProductDataAbstract, Value, DataSourceApi } from './types';
|
|
6
6
|
export * from './types';
|
|
7
|
+
export * from './applyProductHeaderOverrides';
|
|
8
|
+
export * from './productMergeFieldRegistry';
|
|
7
9
|
export interface CreateAndSaveParams {
|
|
8
10
|
basket: BasketData;
|
|
9
11
|
catalogData?: CatalogInfoData[];
|