@commercetools/sync-actions 8.0.1 → 8.2.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.
- package/CHANGELOG.md +14 -0
- package/dist/commercetools-sync-actions.cjs.js +754 -33
- package/dist/commercetools-sync-actions.esm.js +905 -165
- package/dist/commercetools-sync-actions.umd.js +1 -1
- package/dist/commercetools-sync-actions.umd.min.js +1 -1
- package/dist/declarations/index.d.ts +2 -0
- package/dist/declarations/product-tailoring/product-tailoring-actions.d.ts +21 -0
- package/dist/declarations/product-tailoring/product-tailoring.d.ts +4 -0
- package/dist/declarations/standalone-variants/standalone-variant-actions.d.ts +47 -0
- package/dist/declarations/standalone-variants/standalone-variants.d.ts +5 -0
- package/dist/declarations/types/types-actions.d.ts +1 -1
- package/dist/declarations/utils/array-actions-utils.d.ts +6 -0
- package/dist/declarations/utils/extract-matching-pairs.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5953,7 +5953,7 @@ var require_lodash3 = __commonJS({
|
|
|
5953
5953
|
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
|
|
5954
5954
|
return value === proto;
|
|
5955
5955
|
}
|
|
5956
|
-
function
|
|
5956
|
+
function forEach6(collection, iteratee) {
|
|
5957
5957
|
var func = isArray(collection) ? arrayEach : baseEach;
|
|
5958
5958
|
return func(collection, typeof iteratee == "function" ? iteratee : identity);
|
|
5959
5959
|
}
|
|
@@ -5987,7 +5987,7 @@ var require_lodash3 = __commonJS({
|
|
|
5987
5987
|
function identity(value) {
|
|
5988
5988
|
return value;
|
|
5989
5989
|
}
|
|
5990
|
-
module2.exports =
|
|
5990
|
+
module2.exports = forEach6;
|
|
5991
5991
|
}
|
|
5992
5992
|
});
|
|
5993
5993
|
|
|
@@ -6299,7 +6299,7 @@ var require_lodash4 = __commonJS({
|
|
|
6299
6299
|
}
|
|
6300
6300
|
return "";
|
|
6301
6301
|
}
|
|
6302
|
-
function
|
|
6302
|
+
function uniqWith3(array, comparator) {
|
|
6303
6303
|
return array && array.length ? baseUniq(array, void 0, comparator) : [];
|
|
6304
6304
|
}
|
|
6305
6305
|
function eq(value, other) {
|
|
@@ -6315,7 +6315,7 @@ var require_lodash4 = __commonJS({
|
|
|
6315
6315
|
}
|
|
6316
6316
|
function noop() {
|
|
6317
6317
|
}
|
|
6318
|
-
module2.exports =
|
|
6318
|
+
module2.exports = uniqWith3;
|
|
6319
6319
|
}
|
|
6320
6320
|
});
|
|
6321
6321
|
|
|
@@ -6653,7 +6653,7 @@ var require_lodash5 = __commonJS({
|
|
|
6653
6653
|
}
|
|
6654
6654
|
return "";
|
|
6655
6655
|
}
|
|
6656
|
-
var
|
|
6656
|
+
var intersection3 = baseRest(function(arrays) {
|
|
6657
6657
|
var mapped = arrayMap(arrays, castArrayLikeObject);
|
|
6658
6658
|
return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
|
|
6659
6659
|
});
|
|
@@ -6680,7 +6680,7 @@ var require_lodash5 = __commonJS({
|
|
|
6680
6680
|
function isObjectLike(value) {
|
|
6681
6681
|
return !!value && typeof value == "object";
|
|
6682
6682
|
}
|
|
6683
|
-
module2.exports =
|
|
6683
|
+
module2.exports = intersection3;
|
|
6684
6684
|
}
|
|
6685
6685
|
});
|
|
6686
6686
|
|
|
@@ -7017,7 +7017,7 @@ var require_lodash6 = __commonJS({
|
|
|
7017
7017
|
}
|
|
7018
7018
|
return "";
|
|
7019
7019
|
}
|
|
7020
|
-
var
|
|
7020
|
+
var without3 = baseRest(function(array, values) {
|
|
7021
7021
|
return isArrayLikeObject(array) ? baseDifference(array, values) : [];
|
|
7022
7022
|
});
|
|
7023
7023
|
function eq(value, other) {
|
|
@@ -7043,7 +7043,7 @@ var require_lodash6 = __commonJS({
|
|
|
7043
7043
|
function isObjectLike(value) {
|
|
7044
7044
|
return !!value && typeof value == "object";
|
|
7045
7045
|
}
|
|
7046
|
-
module2.exports =
|
|
7046
|
+
module2.exports = without3;
|
|
7047
7047
|
}
|
|
7048
7048
|
});
|
|
7049
7049
|
|
|
@@ -40122,12 +40122,14 @@ __export(index_exports, {
|
|
|
40122
40122
|
createSyncOrders: () => orders_default,
|
|
40123
40123
|
createSyncProductDiscounts: () => product_discounts_default,
|
|
40124
40124
|
createSyncProductSelections: () => product_selections_default,
|
|
40125
|
+
createSyncProductTailoring: () => product_tailoring_default,
|
|
40125
40126
|
createSyncProductTypes: () => product_types_default,
|
|
40126
40127
|
createSyncProducts: () => products_default,
|
|
40127
40128
|
createSyncProjects: () => projects_default,
|
|
40128
40129
|
createSyncRecurringOrders: () => recurring_orders_default,
|
|
40129
40130
|
createSyncShippingMethods: () => shipping_methods_default,
|
|
40130
40131
|
createSyncStandalonePrices: () => prices_default,
|
|
40132
|
+
createSyncStandaloneVariants: () => createSyncStandaloneVariants,
|
|
40131
40133
|
createSyncStates: () => states_default,
|
|
40132
40134
|
createSyncStores: () => stores_default,
|
|
40133
40135
|
createSyncSubscriptions: () => subscriptions_default,
|
|
@@ -41055,9 +41057,15 @@ function findMatchingPairs(diff2, before = [], now = [], identifier = "id") {
|
|
|
41055
41057
|
return result;
|
|
41056
41058
|
}
|
|
41057
41059
|
|
|
41058
|
-
// src/
|
|
41060
|
+
// src/utils/array-actions-utils.ts
|
|
41059
41061
|
var REGEX_NUMBER3 = new RegExp(/^\d+$/);
|
|
41060
41062
|
var REGEX_UNDERSCORE_NUMBER3 = new RegExp(/^_\d+$/);
|
|
41063
|
+
var getIsAddAction = (key, resource) => REGEX_NUMBER3.test(key) && Array.isArray(resource) && resource.length;
|
|
41064
|
+
var getIsUpdateAction = (key, resource) => REGEX_NUMBER3.test(key) && Object.keys(resource).length;
|
|
41065
|
+
var getIsRemoveAction = (key, resource) => REGEX_UNDERSCORE_NUMBER3.test(key) && Number(resource[2]) === 0;
|
|
41066
|
+
var getIsItemMovedAction = (key, resource) => REGEX_UNDERSCORE_NUMBER3.test(key) && Number(resource[2]) === 3;
|
|
41067
|
+
|
|
41068
|
+
// src/products/product-actions.ts
|
|
41061
41069
|
var baseActionsList4 = [
|
|
41062
41070
|
{ action: "changeName", key: "name" },
|
|
41063
41071
|
{ action: "changeSlug", key: "slug" },
|
|
@@ -41082,10 +41090,6 @@ var referenceActionsList4 = [
|
|
|
41082
41090
|
{ action: "setTaxCategory", key: "taxCategory" },
|
|
41083
41091
|
{ action: "transitionState", key: "state" }
|
|
41084
41092
|
];
|
|
41085
|
-
var getIsAddAction = (key, resource) => REGEX_NUMBER3.test(key) && Array.isArray(resource) && resource.length;
|
|
41086
|
-
var getIsUpdateAction = (key, resource) => REGEX_NUMBER3.test(key) && Object.keys(resource).length;
|
|
41087
|
-
var getIsRemoveAction = (key, resource) => REGEX_UNDERSCORE_NUMBER3.test(key) && Number(resource[2]) === 0;
|
|
41088
|
-
var getIsItemMovedAction = (key, resource) => REGEX_UNDERSCORE_NUMBER3.test(key) && Number(resource[2]) === 3;
|
|
41089
41093
|
function _buildSkuActions(variantDiff, oldVariant) {
|
|
41090
41094
|
if ({}.hasOwnProperty.call(variantDiff, "sku")) {
|
|
41091
41095
|
const newValue = getDeltaValue(variantDiff.sku);
|
|
@@ -43566,8 +43570,589 @@ var product_selections_default = (actionGroupList) => {
|
|
|
43566
43570
|
return { buildActions };
|
|
43567
43571
|
};
|
|
43568
43572
|
|
|
43569
|
-
// src/
|
|
43573
|
+
// src/product-tailoring/product-tailoring-actions.ts
|
|
43574
|
+
var import_lodash14 = __toESM(require_lodash3());
|
|
43575
|
+
var import_lodash15 = __toESM(require_lodash4());
|
|
43576
|
+
var import_lodash16 = __toESM(require_lodash5());
|
|
43577
|
+
var import_lodash17 = __toESM(require_lodash6());
|
|
43570
43578
|
var baseActionsList21 = [
|
|
43579
|
+
{ action: "setName", key: "name" },
|
|
43580
|
+
{ action: "setSlug", key: "slug" },
|
|
43581
|
+
{ action: "setDescription", key: "description" }
|
|
43582
|
+
];
|
|
43583
|
+
var metaActionsList3 = [
|
|
43584
|
+
{ action: "setMetaTitle", key: "metaTitle" },
|
|
43585
|
+
{ action: "setMetaDescription", key: "metaDescription" },
|
|
43586
|
+
{ action: "setMetaKeywords", key: "metaKeywords" }
|
|
43587
|
+
];
|
|
43588
|
+
var baseAssetActionsList2 = [
|
|
43589
|
+
{ action: "setAssetKey", key: "key", actionKey: "assetKey" },
|
|
43590
|
+
{ action: "changeAssetName", key: "name" },
|
|
43591
|
+
{ action: "setAssetDescription", key: "description" },
|
|
43592
|
+
{ action: "setAssetTags", key: "tags" },
|
|
43593
|
+
{ action: "setAssetSources", key: "sources" }
|
|
43594
|
+
];
|
|
43595
|
+
function _buildAttributeValue2(diffedValue, oldAttributeValue, newAttributeValue) {
|
|
43596
|
+
let value;
|
|
43597
|
+
if (Array.isArray(diffedValue))
|
|
43598
|
+
value = getDeltaValue(diffedValue, oldAttributeValue);
|
|
43599
|
+
else if (typeof diffedValue === "string")
|
|
43600
|
+
value = getDeltaValue(diffedValue, oldAttributeValue);
|
|
43601
|
+
else if (diffedValue.centAmount || diffedValue.currencyCode)
|
|
43602
|
+
value = {
|
|
43603
|
+
centAmount: diffedValue.centAmount ? getDeltaValue(diffedValue.centAmount) : newAttributeValue.centAmount,
|
|
43604
|
+
currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : newAttributeValue.currencyCode
|
|
43605
|
+
};
|
|
43606
|
+
else if (diffedValue.key) value = getDeltaValue(diffedValue.key);
|
|
43607
|
+
else if (typeof diffedValue === "object")
|
|
43608
|
+
if ({}.hasOwnProperty.call(diffedValue, "_t") && diffedValue._t === "a") {
|
|
43609
|
+
value = newAttributeValue;
|
|
43610
|
+
} else {
|
|
43611
|
+
const updatedValue = Object.keys(diffedValue).reduce(
|
|
43612
|
+
(acc, lang) => {
|
|
43613
|
+
const patchedValue = getDeltaValue(
|
|
43614
|
+
diffedValue[lang],
|
|
43615
|
+
acc[lang]
|
|
43616
|
+
);
|
|
43617
|
+
return Object.assign(acc, { [lang]: patchedValue });
|
|
43618
|
+
},
|
|
43619
|
+
__spreadValues({}, oldAttributeValue)
|
|
43620
|
+
);
|
|
43621
|
+
value = updatedValue;
|
|
43622
|
+
}
|
|
43623
|
+
return value;
|
|
43624
|
+
}
|
|
43625
|
+
function _buildNewSetAttributeAction2(variantId, attr, sameForAllAttributeNames) {
|
|
43626
|
+
const attributeName = attr && attr.name;
|
|
43627
|
+
if (!attributeName) return void 0;
|
|
43628
|
+
let action = {
|
|
43629
|
+
action: "setAttribute",
|
|
43630
|
+
variantId,
|
|
43631
|
+
name: attributeName,
|
|
43632
|
+
value: attr.value
|
|
43633
|
+
};
|
|
43634
|
+
if (sameForAllAttributeNames.indexOf(attributeName) !== -1) {
|
|
43635
|
+
action = __spreadProps(__spreadValues({}, action), { action: "setAttributeInAllVariants" });
|
|
43636
|
+
delete action.variantId;
|
|
43637
|
+
}
|
|
43638
|
+
return action;
|
|
43639
|
+
}
|
|
43640
|
+
function _buildSetAttributeAction2(diffedValue, oldVariant, attribute, sameForAllAttributeNames) {
|
|
43641
|
+
if (!attribute || !diffedValue) return void 0;
|
|
43642
|
+
let action = {
|
|
43643
|
+
action: "setAttribute",
|
|
43644
|
+
variantId: oldVariant.id,
|
|
43645
|
+
name: attribute.name,
|
|
43646
|
+
value: null
|
|
43647
|
+
};
|
|
43648
|
+
const oldAttribute = (oldVariant.attributes || []).find(
|
|
43649
|
+
(a) => a.name === attribute.name
|
|
43650
|
+
);
|
|
43651
|
+
if (sameForAllAttributeNames.indexOf(attribute.name) !== -1) {
|
|
43652
|
+
action = __spreadProps(__spreadValues({}, action), { action: "setAttributeInAllVariants" });
|
|
43653
|
+
delete action.variantId;
|
|
43654
|
+
}
|
|
43655
|
+
action.value = _buildAttributeValue2(
|
|
43656
|
+
diffedValue,
|
|
43657
|
+
oldAttribute == null ? void 0 : oldAttribute.value,
|
|
43658
|
+
attribute.value
|
|
43659
|
+
);
|
|
43660
|
+
return action;
|
|
43661
|
+
}
|
|
43662
|
+
function _buildNewSetProductAttributeAction2(attr) {
|
|
43663
|
+
const attributeName = attr && attr.name;
|
|
43664
|
+
if (!attributeName) return void 0;
|
|
43665
|
+
return {
|
|
43666
|
+
action: "setProductAttribute",
|
|
43667
|
+
name: attributeName,
|
|
43668
|
+
value: attr.value
|
|
43669
|
+
};
|
|
43670
|
+
}
|
|
43671
|
+
function _buildSetProductAttributeAction2(diffedValue, oldProductData, newAttribute) {
|
|
43672
|
+
if (!newAttribute || !diffedValue) return void 0;
|
|
43673
|
+
const action = {
|
|
43674
|
+
action: "setProductAttribute",
|
|
43675
|
+
name: newAttribute.name,
|
|
43676
|
+
value: null
|
|
43677
|
+
};
|
|
43678
|
+
const oldAttribute = (oldProductData.attributes || []).find(
|
|
43679
|
+
(a) => a.name === newAttribute.name
|
|
43680
|
+
) || {};
|
|
43681
|
+
action.value = _buildAttributeValue2(
|
|
43682
|
+
diffedValue,
|
|
43683
|
+
oldAttribute.value,
|
|
43684
|
+
newAttribute.value
|
|
43685
|
+
);
|
|
43686
|
+
return action;
|
|
43687
|
+
}
|
|
43688
|
+
function _buildVariantImagesAction2(diffedImages, oldVariant = {}, newVariant = {}) {
|
|
43689
|
+
const actions = [];
|
|
43690
|
+
const matchingImagePairs = findMatchingPairs(
|
|
43691
|
+
diffedImages,
|
|
43692
|
+
oldVariant.images,
|
|
43693
|
+
newVariant.images,
|
|
43694
|
+
"url"
|
|
43695
|
+
);
|
|
43696
|
+
(0, import_lodash14.default)(diffedImages, (image, key) => {
|
|
43697
|
+
const { oldObj, newObj } = extractMatchingPairs(
|
|
43698
|
+
matchingImagePairs,
|
|
43699
|
+
key,
|
|
43700
|
+
oldVariant.images,
|
|
43701
|
+
newVariant.images
|
|
43702
|
+
);
|
|
43703
|
+
if (REGEX_NUMBER3.test(key)) {
|
|
43704
|
+
if (Array.isArray(image) && image.length)
|
|
43705
|
+
actions.push({
|
|
43706
|
+
action: "addExternalImage",
|
|
43707
|
+
variantId: oldVariant.id,
|
|
43708
|
+
image: getDeltaValue(image)
|
|
43709
|
+
});
|
|
43710
|
+
else if (typeof image === "object") {
|
|
43711
|
+
if ({}.hasOwnProperty.call(image, "url") && image.url.length === 2) {
|
|
43712
|
+
actions.push({
|
|
43713
|
+
action: "removeImage",
|
|
43714
|
+
variantId: oldVariant.id,
|
|
43715
|
+
imageUrl: oldObj.url
|
|
43716
|
+
});
|
|
43717
|
+
actions.push({
|
|
43718
|
+
action: "addExternalImage",
|
|
43719
|
+
variantId: oldVariant.id,
|
|
43720
|
+
image: newObj
|
|
43721
|
+
});
|
|
43722
|
+
} else if ({}.hasOwnProperty.call(image, "label") && (image.label.length === 1 || image.label.length === 2))
|
|
43723
|
+
actions.push({
|
|
43724
|
+
action: "setImageLabel",
|
|
43725
|
+
variantId: oldVariant.id,
|
|
43726
|
+
imageUrl: oldObj.url,
|
|
43727
|
+
label: getDeltaValue(image.label)
|
|
43728
|
+
});
|
|
43729
|
+
}
|
|
43730
|
+
} else if (REGEX_UNDERSCORE_NUMBER3.test(key)) {
|
|
43731
|
+
if (Array.isArray(image) && image.length === 3) {
|
|
43732
|
+
if (Number(image[2]) === 3)
|
|
43733
|
+
actions.push({
|
|
43734
|
+
action: "moveImageToPosition",
|
|
43735
|
+
variantId: oldVariant.id,
|
|
43736
|
+
imageUrl: oldObj.url,
|
|
43737
|
+
position: Number(image[1])
|
|
43738
|
+
});
|
|
43739
|
+
else if (Number(image[2]) === 0)
|
|
43740
|
+
actions.push({
|
|
43741
|
+
action: "removeImage",
|
|
43742
|
+
variantId: oldVariant.id,
|
|
43743
|
+
imageUrl: oldObj.url
|
|
43744
|
+
});
|
|
43745
|
+
}
|
|
43746
|
+
}
|
|
43747
|
+
});
|
|
43748
|
+
return actions;
|
|
43749
|
+
}
|
|
43750
|
+
function toAssetIdentifier3(asset) {
|
|
43751
|
+
return asset.id ? { assetId: asset.id } : { assetKey: asset.key };
|
|
43752
|
+
}
|
|
43753
|
+
function toVariantIdentifier2(variant) {
|
|
43754
|
+
const { id, sku } = variant;
|
|
43755
|
+
return id ? { variantId: id } : { sku };
|
|
43756
|
+
}
|
|
43757
|
+
function _buildVariantChangeAssetOrderAction2(diffAssets, oldVariant, newVariant) {
|
|
43758
|
+
const isAssetOrderChanged = Object.entries(diffAssets).find(
|
|
43759
|
+
(entry) => getIsItemMovedAction(entry[0], entry[1])
|
|
43760
|
+
);
|
|
43761
|
+
if (!isAssetOrderChanged) return [];
|
|
43762
|
+
const assetIdsBefore = (oldVariant.assets || []).map((_) => _.id);
|
|
43763
|
+
const assetIdsCurrent = (newVariant.assets || []).map((_) => _.id).filter((_) => _ !== void 0);
|
|
43764
|
+
const assetIdsToKeep = (0, import_lodash16.default)(assetIdsCurrent, assetIdsBefore);
|
|
43765
|
+
const assetIdsToRemove = (0, import_lodash17.default)(assetIdsBefore, ...assetIdsToKeep);
|
|
43766
|
+
return [
|
|
43767
|
+
__spreadValues({
|
|
43768
|
+
action: "changeAssetOrder",
|
|
43769
|
+
assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
|
|
43770
|
+
}, toVariantIdentifier2(oldVariant))
|
|
43771
|
+
];
|
|
43772
|
+
}
|
|
43773
|
+
function _buildVariantAssetsActions2(diffAssets, oldVariant, newVariant) {
|
|
43774
|
+
const assetActions = [];
|
|
43775
|
+
const matchingAssetPairs = findMatchingPairs(
|
|
43776
|
+
diffAssets,
|
|
43777
|
+
oldVariant.assets,
|
|
43778
|
+
newVariant.assets
|
|
43779
|
+
);
|
|
43780
|
+
(0, import_lodash14.default)(diffAssets, (asset, key) => {
|
|
43781
|
+
const { oldObj: oldAsset, newObj: newAsset } = extractMatchingPairs(
|
|
43782
|
+
matchingAssetPairs,
|
|
43783
|
+
key,
|
|
43784
|
+
oldVariant.assets,
|
|
43785
|
+
newVariant.assets
|
|
43786
|
+
);
|
|
43787
|
+
if (getIsAddAction(key, asset)) {
|
|
43788
|
+
const action = __spreadValues({
|
|
43789
|
+
action: "addAsset",
|
|
43790
|
+
asset: getDeltaValue(asset)
|
|
43791
|
+
}, toVariantIdentifier2(newVariant));
|
|
43792
|
+
const actionWithPosition = __spreadProps(__spreadValues({}, action), {
|
|
43793
|
+
position: Number(key)
|
|
43794
|
+
});
|
|
43795
|
+
assetActions.push(oldVariant.assets ? actionWithPosition : action);
|
|
43796
|
+
return;
|
|
43797
|
+
}
|
|
43798
|
+
if (getIsUpdateAction(key, asset)) {
|
|
43799
|
+
const basicActions = buildBaseAttributesActions({
|
|
43800
|
+
actions: baseAssetActionsList2,
|
|
43801
|
+
diff: asset,
|
|
43802
|
+
oldObj: oldAsset,
|
|
43803
|
+
newObj: newAsset
|
|
43804
|
+
}).map((action) => {
|
|
43805
|
+
if (action.action === "setAssetKey") {
|
|
43806
|
+
return __spreadProps(__spreadValues(__spreadValues({}, action), toVariantIdentifier2(oldVariant)), {
|
|
43807
|
+
assetId: oldAsset.id
|
|
43808
|
+
});
|
|
43809
|
+
}
|
|
43810
|
+
return __spreadValues(__spreadValues(__spreadValues({}, action), toVariantIdentifier2(oldVariant)), toAssetIdentifier3(oldAsset));
|
|
43811
|
+
});
|
|
43812
|
+
assetActions.push(...basicActions);
|
|
43813
|
+
if (asset.custom) {
|
|
43814
|
+
const customActions = actionsMapCustom(asset, newAsset, oldAsset, __spreadValues(__spreadValues({
|
|
43815
|
+
actions: {
|
|
43816
|
+
setCustomType: "setAssetCustomType",
|
|
43817
|
+
setCustomField: "setAssetCustomField"
|
|
43818
|
+
}
|
|
43819
|
+
}, toVariantIdentifier2(oldVariant)), toAssetIdentifier3(oldAsset)));
|
|
43820
|
+
assetActions.push(...customActions);
|
|
43821
|
+
}
|
|
43822
|
+
return;
|
|
43823
|
+
}
|
|
43824
|
+
if (getIsRemoveAction(key, asset)) {
|
|
43825
|
+
assetActions.push(__spreadValues(__spreadValues({
|
|
43826
|
+
action: "removeAsset"
|
|
43827
|
+
}, toAssetIdentifier3(oldAsset)), toVariantIdentifier2(oldVariant)));
|
|
43828
|
+
}
|
|
43829
|
+
});
|
|
43830
|
+
const changedAssetOrderAction = _buildVariantChangeAssetOrderAction2(
|
|
43831
|
+
diffAssets,
|
|
43832
|
+
oldVariant,
|
|
43833
|
+
newVariant
|
|
43834
|
+
);
|
|
43835
|
+
return [...changedAssetOrderAction, ...assetActions];
|
|
43836
|
+
}
|
|
43837
|
+
function _buildVariantAttributesActions2(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
|
|
43838
|
+
const actions = [];
|
|
43839
|
+
if (!attributes) return actions;
|
|
43840
|
+
(0, import_lodash14.default)(attributes, (value, key) => {
|
|
43841
|
+
if (REGEX_NUMBER3.test(key)) {
|
|
43842
|
+
if (Array.isArray(value)) {
|
|
43843
|
+
const { id } = oldVariant;
|
|
43844
|
+
const deltaValue = getDeltaValue(value);
|
|
43845
|
+
const setAction = _buildNewSetAttributeAction2(
|
|
43846
|
+
id,
|
|
43847
|
+
deltaValue,
|
|
43848
|
+
sameForAllAttributeNames
|
|
43849
|
+
);
|
|
43850
|
+
if (setAction) actions.push(setAction);
|
|
43851
|
+
} else if (newVariant.attributes) {
|
|
43852
|
+
const setAction = _buildSetAttributeAction2(
|
|
43853
|
+
value.value,
|
|
43854
|
+
oldVariant,
|
|
43855
|
+
newVariant.attributes[key],
|
|
43856
|
+
sameForAllAttributeNames
|
|
43857
|
+
);
|
|
43858
|
+
if (setAction) actions.push(setAction);
|
|
43859
|
+
}
|
|
43860
|
+
} else if (REGEX_UNDERSCORE_NUMBER3.test(key))
|
|
43861
|
+
if (Array.isArray(value)) {
|
|
43862
|
+
if (value.length === 3 && value[2] === 3) return;
|
|
43863
|
+
const { id } = oldVariant;
|
|
43864
|
+
let deltaValue = getDeltaValue(value);
|
|
43865
|
+
if (!deltaValue)
|
|
43866
|
+
if (value[0] && value[0].name) deltaValue = { name: value[0].name };
|
|
43867
|
+
else deltaValue = void 0;
|
|
43868
|
+
const setAction = _buildNewSetAttributeAction2(
|
|
43869
|
+
id,
|
|
43870
|
+
deltaValue,
|
|
43871
|
+
sameForAllAttributeNames
|
|
43872
|
+
);
|
|
43873
|
+
if (setAction) actions.push(setAction);
|
|
43874
|
+
} else {
|
|
43875
|
+
const index = key.substring(1);
|
|
43876
|
+
if (newVariant.attributes) {
|
|
43877
|
+
const setAction = _buildSetAttributeAction2(
|
|
43878
|
+
value.value,
|
|
43879
|
+
oldVariant,
|
|
43880
|
+
newVariant.attributes[index],
|
|
43881
|
+
sameForAllAttributeNames
|
|
43882
|
+
);
|
|
43883
|
+
if (setAction) actions.push(setAction);
|
|
43884
|
+
}
|
|
43885
|
+
}
|
|
43886
|
+
});
|
|
43887
|
+
return actions;
|
|
43888
|
+
}
|
|
43889
|
+
function _buildProductAttributesActions2(diffedAttributes, oldProductData, newProductData) {
|
|
43890
|
+
const actions = [];
|
|
43891
|
+
if (!diffedAttributes) return actions;
|
|
43892
|
+
(0, import_lodash14.default)(diffedAttributes, (value, key) => {
|
|
43893
|
+
if (REGEX_NUMBER3.test(key)) {
|
|
43894
|
+
if (Array.isArray(value)) {
|
|
43895
|
+
const setAction = _buildNewSetProductAttributeAction2(
|
|
43896
|
+
getDeltaValue(value)
|
|
43897
|
+
);
|
|
43898
|
+
if (setAction) actions.push(setAction);
|
|
43899
|
+
} else if (newProductData.attributes) {
|
|
43900
|
+
const setAction = _buildSetProductAttributeAction2(
|
|
43901
|
+
value["value"],
|
|
43902
|
+
oldProductData,
|
|
43903
|
+
newProductData.attributes[key]
|
|
43904
|
+
);
|
|
43905
|
+
if (setAction) actions.push(setAction);
|
|
43906
|
+
}
|
|
43907
|
+
} else if (REGEX_UNDERSCORE_NUMBER3.test(key)) {
|
|
43908
|
+
if (Array.isArray(value)) {
|
|
43909
|
+
if (value.length === 3 && value[2] === 3) return;
|
|
43910
|
+
let deltaValue = getDeltaValue(value);
|
|
43911
|
+
if (!deltaValue)
|
|
43912
|
+
if (value[0] && value[0].name) deltaValue = { name: value[0].name };
|
|
43913
|
+
else deltaValue = void 0;
|
|
43914
|
+
const setAction = _buildNewSetProductAttributeAction2(
|
|
43915
|
+
deltaValue
|
|
43916
|
+
);
|
|
43917
|
+
if (setAction) actions.push(setAction);
|
|
43918
|
+
} else {
|
|
43919
|
+
const index = key.substring(1);
|
|
43920
|
+
if (newProductData.attributes) {
|
|
43921
|
+
const setAction = _buildSetProductAttributeAction2(
|
|
43922
|
+
value["value"],
|
|
43923
|
+
oldProductData,
|
|
43924
|
+
newProductData.attributes[index]
|
|
43925
|
+
);
|
|
43926
|
+
if (setAction) actions.push(setAction);
|
|
43927
|
+
}
|
|
43928
|
+
}
|
|
43929
|
+
}
|
|
43930
|
+
});
|
|
43931
|
+
return actions;
|
|
43932
|
+
}
|
|
43933
|
+
function actionsMapBase21(diff2, oldObj, newObj, config = {}) {
|
|
43934
|
+
return buildBaseAttributesActions({
|
|
43935
|
+
actions: baseActionsList21,
|
|
43936
|
+
diff: diff2,
|
|
43937
|
+
oldObj,
|
|
43938
|
+
newObj,
|
|
43939
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString,
|
|
43940
|
+
shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties
|
|
43941
|
+
});
|
|
43942
|
+
}
|
|
43943
|
+
function actionsMapMeta3(diff2, oldObj, newObj, config = {}) {
|
|
43944
|
+
return buildBaseAttributesActions({
|
|
43945
|
+
actions: metaActionsList3,
|
|
43946
|
+
diff: diff2,
|
|
43947
|
+
oldObj,
|
|
43948
|
+
newObj,
|
|
43949
|
+
shouldOmitEmptyString: config.shouldOmitEmptyString,
|
|
43950
|
+
shouldUnsetOmittedProperties: config.shouldUnsetOmittedProperties
|
|
43951
|
+
});
|
|
43952
|
+
}
|
|
43953
|
+
function actionsMapAddVariants2(diff2, oldObj, newObj) {
|
|
43954
|
+
const handler = createBuildArrayActions("variants", {
|
|
43955
|
+
[ADD_ACTIONS]: (newObject) => __spreadProps(__spreadValues({}, newObject), {
|
|
43956
|
+
action: "addVariant"
|
|
43957
|
+
})
|
|
43958
|
+
});
|
|
43959
|
+
return handler(diff2, oldObj, newObj);
|
|
43960
|
+
}
|
|
43961
|
+
function actionsMapRemoveVariants2(diff2, oldObj, newObj) {
|
|
43962
|
+
const handler = createBuildArrayActions("variants", {
|
|
43963
|
+
[REMOVE_ACTIONS]: ({ id, sku }) => __spreadValues({
|
|
43964
|
+
action: "removeVariant"
|
|
43965
|
+
}, id ? { id } : { sku })
|
|
43966
|
+
});
|
|
43967
|
+
return handler(diff2, oldObj, newObj);
|
|
43968
|
+
}
|
|
43969
|
+
function actionsMapImages2(diff2, oldObj, newObj, variantHashMap) {
|
|
43970
|
+
let actions = [];
|
|
43971
|
+
const { variants } = diff2;
|
|
43972
|
+
if (variants)
|
|
43973
|
+
(0, import_lodash14.default)(variants, (variant, key) => {
|
|
43974
|
+
const { oldObj: oldVariant, newObj: newVariant } = extractMatchingPairs(
|
|
43975
|
+
variantHashMap,
|
|
43976
|
+
key,
|
|
43977
|
+
oldObj.variants,
|
|
43978
|
+
newObj.variants
|
|
43979
|
+
);
|
|
43980
|
+
if (REGEX_UNDERSCORE_NUMBER3.test(key) || REGEX_NUMBER3.test(key)) {
|
|
43981
|
+
const vActions = _buildVariantImagesAction2(
|
|
43982
|
+
variant.images,
|
|
43983
|
+
oldVariant,
|
|
43984
|
+
newVariant
|
|
43985
|
+
);
|
|
43986
|
+
actions = actions.concat(vActions);
|
|
43987
|
+
}
|
|
43988
|
+
});
|
|
43989
|
+
return actions;
|
|
43990
|
+
}
|
|
43991
|
+
function actionsMapAssets3(diff2, oldObj, newObj, variantHashMap) {
|
|
43992
|
+
let allAssetsActions = [];
|
|
43993
|
+
const { variants } = diff2;
|
|
43994
|
+
if (variants)
|
|
43995
|
+
(0, import_lodash14.default)(variants, (variant, key) => {
|
|
43996
|
+
const { oldObj: oldVariant, newObj: newVariant } = extractMatchingPairs(
|
|
43997
|
+
variantHashMap,
|
|
43998
|
+
key,
|
|
43999
|
+
oldObj.variants,
|
|
44000
|
+
newObj.variants
|
|
44001
|
+
);
|
|
44002
|
+
if (variant.assets && (REGEX_UNDERSCORE_NUMBER3.test(key) || REGEX_NUMBER3.test(key))) {
|
|
44003
|
+
const assetActions = _buildVariantAssetsActions2(
|
|
44004
|
+
variant.assets,
|
|
44005
|
+
oldVariant,
|
|
44006
|
+
newVariant
|
|
44007
|
+
);
|
|
44008
|
+
allAssetsActions = allAssetsActions.concat(assetActions);
|
|
44009
|
+
}
|
|
44010
|
+
});
|
|
44011
|
+
return allAssetsActions;
|
|
44012
|
+
}
|
|
44013
|
+
function actionsMapProductAttributes2(diff2, oldObj, newObj) {
|
|
44014
|
+
return _buildProductAttributesActions2(diff2.attributes, oldObj, newObj);
|
|
44015
|
+
}
|
|
44016
|
+
function actionsMapVariantAttributes(diff2, oldObj, newObj, sameForAllAttributeNames = [], variantHashMap) {
|
|
44017
|
+
let actions = [];
|
|
44018
|
+
const { variants } = diff2;
|
|
44019
|
+
if (variants)
|
|
44020
|
+
(0, import_lodash14.default)(variants, (variant, key) => {
|
|
44021
|
+
const { oldObj: oldVariant, newObj: newVariant } = extractMatchingPairs(
|
|
44022
|
+
variantHashMap,
|
|
44023
|
+
key,
|
|
44024
|
+
oldObj.variants,
|
|
44025
|
+
newObj.variants
|
|
44026
|
+
);
|
|
44027
|
+
if (REGEX_NUMBER3.test(key) && !Array.isArray(variant)) {
|
|
44028
|
+
const { attributes } = variant;
|
|
44029
|
+
const attrActions = _buildVariantAttributesActions2(
|
|
44030
|
+
attributes,
|
|
44031
|
+
oldVariant,
|
|
44032
|
+
newVariant,
|
|
44033
|
+
sameForAllAttributeNames
|
|
44034
|
+
);
|
|
44035
|
+
actions = actions.concat(attrActions);
|
|
44036
|
+
}
|
|
44037
|
+
});
|
|
44038
|
+
return (0, import_lodash15.default)(
|
|
44039
|
+
actions,
|
|
44040
|
+
(a, b) => a.action === b.action && a.name === b.name && a.variantId === b.variantId
|
|
44041
|
+
);
|
|
44042
|
+
}
|
|
44043
|
+
|
|
44044
|
+
// src/product-tailoring/product-tailoring.ts
|
|
44045
|
+
function createProductTailoringMapActions(mapActionGroup, syncActionConfig) {
|
|
44046
|
+
return function doMapActions(diff2, newObj, oldObj, options = {}) {
|
|
44047
|
+
const allActions = [];
|
|
44048
|
+
const { publish, staged } = newObj;
|
|
44049
|
+
const variantHashMap = findMatchingPairs(
|
|
44050
|
+
diff2.variants,
|
|
44051
|
+
oldObj.variants,
|
|
44052
|
+
newObj.variants
|
|
44053
|
+
);
|
|
44054
|
+
const config = __spreadValues(__spreadValues({}, syncActionConfig), options);
|
|
44055
|
+
allActions.push(
|
|
44056
|
+
mapActionGroup(
|
|
44057
|
+
"base",
|
|
44058
|
+
() => actionsMapBase21(diff2, oldObj, newObj, config)
|
|
44059
|
+
)
|
|
44060
|
+
);
|
|
44061
|
+
allActions.push(
|
|
44062
|
+
mapActionGroup(
|
|
44063
|
+
"meta",
|
|
44064
|
+
() => actionsMapMeta3(diff2, oldObj, newObj, config)
|
|
44065
|
+
)
|
|
44066
|
+
);
|
|
44067
|
+
allActions.push(
|
|
44068
|
+
mapActionGroup(
|
|
44069
|
+
"variants",
|
|
44070
|
+
() => actionsMapAddVariants2(diff2, oldObj, newObj)
|
|
44071
|
+
)
|
|
44072
|
+
);
|
|
44073
|
+
allActions.push(
|
|
44074
|
+
mapActionGroup(
|
|
44075
|
+
"variants",
|
|
44076
|
+
() => actionsMapRemoveVariants2(diff2, oldObj, newObj)
|
|
44077
|
+
)
|
|
44078
|
+
);
|
|
44079
|
+
allActions.push(
|
|
44080
|
+
mapActionGroup(
|
|
44081
|
+
"images",
|
|
44082
|
+
() => actionsMapImages2(
|
|
44083
|
+
diff2,
|
|
44084
|
+
oldObj,
|
|
44085
|
+
newObj,
|
|
44086
|
+
variantHashMap
|
|
44087
|
+
)
|
|
44088
|
+
)
|
|
44089
|
+
);
|
|
44090
|
+
allActions.push(
|
|
44091
|
+
mapActionGroup(
|
|
44092
|
+
"assets",
|
|
44093
|
+
() => actionsMapAssets3(
|
|
44094
|
+
diff2,
|
|
44095
|
+
oldObj,
|
|
44096
|
+
newObj,
|
|
44097
|
+
variantHashMap
|
|
44098
|
+
)
|
|
44099
|
+
)
|
|
44100
|
+
);
|
|
44101
|
+
allActions.push(
|
|
44102
|
+
mapActionGroup(
|
|
44103
|
+
"attributes",
|
|
44104
|
+
() => actionsMapProductAttributes2(
|
|
44105
|
+
diff2,
|
|
44106
|
+
oldObj,
|
|
44107
|
+
newObj
|
|
44108
|
+
)
|
|
44109
|
+
)
|
|
44110
|
+
);
|
|
44111
|
+
allActions.push(
|
|
44112
|
+
mapActionGroup(
|
|
44113
|
+
"attributes",
|
|
44114
|
+
() => actionsMapVariantAttributes(
|
|
44115
|
+
diff2,
|
|
44116
|
+
oldObj,
|
|
44117
|
+
newObj,
|
|
44118
|
+
options.sameForAllAttributeNames || [],
|
|
44119
|
+
variantHashMap
|
|
44120
|
+
)
|
|
44121
|
+
)
|
|
44122
|
+
);
|
|
44123
|
+
if (publish === true || staged === false)
|
|
44124
|
+
return allActions.flat().map((action) => __spreadProps(__spreadValues({}, action), {
|
|
44125
|
+
staged: false
|
|
44126
|
+
}));
|
|
44127
|
+
return allActions.flat();
|
|
44128
|
+
};
|
|
44129
|
+
}
|
|
44130
|
+
function prepareVariantsForDiff(before, now) {
|
|
44131
|
+
const [beforeCopy, nowCopy] = copyEmptyArrayProps(
|
|
44132
|
+
before,
|
|
44133
|
+
now
|
|
44134
|
+
);
|
|
44135
|
+
const ensureVariants = (obj) => __spreadProps(__spreadValues({}, obj), {
|
|
44136
|
+
variants: (obj == null ? void 0 : obj.variants) || []
|
|
44137
|
+
});
|
|
44138
|
+
return [ensureVariants(beforeCopy), ensureVariants(nowCopy)];
|
|
44139
|
+
}
|
|
44140
|
+
var product_tailoring_default = (actionGroupList, syncActionConfig) => {
|
|
44141
|
+
const mapActionGroup = createMapActionGroup(actionGroupList);
|
|
44142
|
+
const doMapActions = createProductTailoringMapActions(
|
|
44143
|
+
mapActionGroup,
|
|
44144
|
+
syncActionConfig
|
|
44145
|
+
);
|
|
44146
|
+
const buildActions = createBuildActions(
|
|
44147
|
+
diff,
|
|
44148
|
+
doMapActions,
|
|
44149
|
+
prepareVariantsForDiff
|
|
44150
|
+
);
|
|
44151
|
+
return { buildActions };
|
|
44152
|
+
};
|
|
44153
|
+
|
|
44154
|
+
// src/prices/prices-actions.ts
|
|
44155
|
+
var baseActionsList22 = [
|
|
43571
44156
|
{ action: "changeValue", key: "value" },
|
|
43572
44157
|
{ action: "setDiscountedPrice", key: "discounted" },
|
|
43573
44158
|
// TODO: Later add more accurate actions `addPriceTier`, `removePriceTier`
|
|
@@ -43577,9 +44162,9 @@ var baseActionsList21 = [
|
|
|
43577
44162
|
{ action: "setValidUntil", key: "validUntil" },
|
|
43578
44163
|
{ action: "changeActive", key: "active" }
|
|
43579
44164
|
];
|
|
43580
|
-
function
|
|
44165
|
+
function actionsMapBase22(diff2, oldObj, newObj, config = {}) {
|
|
43581
44166
|
return buildBaseAttributesActions({
|
|
43582
|
-
actions:
|
|
44167
|
+
actions: baseActionsList22,
|
|
43583
44168
|
diff: diff2,
|
|
43584
44169
|
oldObj,
|
|
43585
44170
|
newObj,
|
|
@@ -43594,7 +44179,7 @@ function createPriceMapActions(mapActionGroup, syncActionConfig) {
|
|
|
43594
44179
|
return function doMapActions(diff2, newObj, oldObj) {
|
|
43595
44180
|
const baseActions = mapActionGroup(
|
|
43596
44181
|
"base",
|
|
43597
|
-
() =>
|
|
44182
|
+
() => actionsMapBase22(diff2, oldObj, newObj, syncActionConfig)
|
|
43598
44183
|
);
|
|
43599
44184
|
const customActions = mapActionGroup(
|
|
43600
44185
|
"custom",
|
|
@@ -43615,14 +44200,14 @@ var prices_default = (actionGroupList, syncActionConfig) => {
|
|
|
43615
44200
|
|
|
43616
44201
|
// src/attribute-groups/attribute-groups-actions.ts
|
|
43617
44202
|
var hasAttribute = (attributes, newValue) => attributes.some((attribute) => attribute.key === newValue.key);
|
|
43618
|
-
var
|
|
44203
|
+
var baseActionsList23 = [
|
|
43619
44204
|
{ action: "changeName", key: "name" },
|
|
43620
44205
|
{ action: "setKey", key: "key" },
|
|
43621
44206
|
{ action: "setDescription", key: "description" }
|
|
43622
44207
|
];
|
|
43623
|
-
function
|
|
44208
|
+
function actionsMapBase23(diff2, oldObj, newObj, config = {}) {
|
|
43624
44209
|
return buildBaseAttributesActions({
|
|
43625
|
-
actions:
|
|
44210
|
+
actions: baseActionsList23,
|
|
43626
44211
|
diff: diff2,
|
|
43627
44212
|
oldObj,
|
|
43628
44213
|
newObj,
|
|
@@ -43668,7 +44253,7 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
43668
44253
|
allActions.push(
|
|
43669
44254
|
mapActionGroup(
|
|
43670
44255
|
"base",
|
|
43671
|
-
() =>
|
|
44256
|
+
() => actionsMapBase23(diff2, oldObj, newObj, syncActionConfig)
|
|
43672
44257
|
)
|
|
43673
44258
|
);
|
|
43674
44259
|
allActions.push(
|
|
@@ -43698,15 +44283,15 @@ var attribute_groups_default = (actionGroupList, syncActionConfig) => {
|
|
|
43698
44283
|
};
|
|
43699
44284
|
|
|
43700
44285
|
// src/api-extensions/api-extensions-actions.ts
|
|
43701
|
-
var
|
|
44286
|
+
var baseActionsList24 = [
|
|
43702
44287
|
{ action: "setKey", key: "key" },
|
|
43703
44288
|
{ action: "changeTriggers", key: "triggers" },
|
|
43704
44289
|
{ action: "setTimeoutInMs", key: "timeoutInMs" },
|
|
43705
44290
|
{ action: "changeDestination", key: "destination" }
|
|
43706
44291
|
];
|
|
43707
|
-
var
|
|
44292
|
+
var actionsMapBase24 = (diff2, oldObj, newObj, config) => {
|
|
43708
44293
|
return buildBaseAttributesActions({
|
|
43709
|
-
actions:
|
|
44294
|
+
actions: baseActionsList24,
|
|
43710
44295
|
diff: diff2,
|
|
43711
44296
|
oldObj,
|
|
43712
44297
|
newObj,
|
|
@@ -43721,7 +44306,7 @@ var createApiExtensionsMapActions = (mapActionGroup, syncActionConfig) => {
|
|
|
43721
44306
|
allActions.push(
|
|
43722
44307
|
mapActionGroup(
|
|
43723
44308
|
"base",
|
|
43724
|
-
() =>
|
|
44309
|
+
() => actionsMapBase24(diff2, oldObj, newObj, syncActionConfig)
|
|
43725
44310
|
)
|
|
43726
44311
|
);
|
|
43727
44312
|
return allActions.flat();
|
|
@@ -43738,7 +44323,7 @@ var api_extensions_default = (actionGroupList, syncActionConfig) => {
|
|
|
43738
44323
|
};
|
|
43739
44324
|
|
|
43740
44325
|
// src/business-units/business-units-actions.ts
|
|
43741
|
-
var
|
|
44326
|
+
var baseActionsList25 = [
|
|
43742
44327
|
{
|
|
43743
44328
|
action: "setStores",
|
|
43744
44329
|
key: "stores"
|
|
@@ -43774,9 +44359,9 @@ var actionsMapAssociates = (diff2, oldObj, newObj) => {
|
|
|
43774
44359
|
});
|
|
43775
44360
|
return handler(diff2, oldObj, newObj);
|
|
43776
44361
|
};
|
|
43777
|
-
var
|
|
44362
|
+
var actionsMapBase25 = (diff2, oldObj, newObj, config) => {
|
|
43778
44363
|
return buildBaseAttributesActions({
|
|
43779
|
-
actions:
|
|
44364
|
+
actions: baseActionsList25,
|
|
43780
44365
|
diff: diff2,
|
|
43781
44366
|
oldObj,
|
|
43782
44367
|
newObj,
|
|
@@ -43791,7 +44376,7 @@ var createCustomerMapActions2 = (mapActionGroup, syncActionConfig) => {
|
|
|
43791
44376
|
allActions.push(
|
|
43792
44377
|
mapActionGroup(
|
|
43793
44378
|
"base",
|
|
43794
|
-
() =>
|
|
44379
|
+
() => actionsMapBase25(
|
|
43795
44380
|
diff2,
|
|
43796
44381
|
oldObj,
|
|
43797
44382
|
newObj,
|
|
@@ -43866,15 +44451,15 @@ var business_units_default = (actionGroupList, syncActionConfig) => {
|
|
|
43866
44451
|
};
|
|
43867
44452
|
|
|
43868
44453
|
// src/subscriptions/subscriptions-actions.ts
|
|
43869
|
-
var
|
|
44454
|
+
var baseActionsList26 = [
|
|
43870
44455
|
{ action: "setKey", key: "key" },
|
|
43871
44456
|
{ action: "setMessages", key: "messages" },
|
|
43872
44457
|
{ action: "setChanges", key: "changes" },
|
|
43873
44458
|
{ action: "changeDestination", key: "destination" }
|
|
43874
44459
|
];
|
|
43875
|
-
var
|
|
44460
|
+
var actionsMapBase26 = (diff2, oldObj, newObj, config) => {
|
|
43876
44461
|
return buildBaseAttributesActions({
|
|
43877
|
-
actions:
|
|
44462
|
+
actions: baseActionsList26,
|
|
43878
44463
|
diff: diff2,
|
|
43879
44464
|
oldObj,
|
|
43880
44465
|
newObj,
|
|
@@ -43889,7 +44474,7 @@ var createSubscriptionsMapActions = (mapActionGroup, syncActionConfig) => {
|
|
|
43889
44474
|
allActions.push(
|
|
43890
44475
|
mapActionGroup(
|
|
43891
44476
|
"base",
|
|
43892
|
-
() =>
|
|
44477
|
+
() => actionsMapBase26(
|
|
43893
44478
|
diff2,
|
|
43894
44479
|
oldObj,
|
|
43895
44480
|
newObj,
|
|
@@ -43913,6 +44498,140 @@ var subscriptions_default = (actionGroupList, syncActionConfig = {}) => {
|
|
|
43913
44498
|
return { buildActions };
|
|
43914
44499
|
};
|
|
43915
44500
|
|
|
44501
|
+
// src/standalone-variants/standalone-variant-actions.ts
|
|
44502
|
+
function convertAttributeToUpdateActionShape(attribute) {
|
|
44503
|
+
const { name, value } = attribute;
|
|
44504
|
+
return __spreadValues({
|
|
44505
|
+
name
|
|
44506
|
+
}, typeof value !== "undefined" ? {
|
|
44507
|
+
value: JSON.stringify(value)
|
|
44508
|
+
} : {});
|
|
44509
|
+
}
|
|
44510
|
+
function _buildStagedAction(actionName, payload, config = {}) {
|
|
44511
|
+
const action = __spreadValues({
|
|
44512
|
+
action: actionName
|
|
44513
|
+
}, payload);
|
|
44514
|
+
if (config.staged !== false) {
|
|
44515
|
+
action.staged = true;
|
|
44516
|
+
}
|
|
44517
|
+
return action;
|
|
44518
|
+
}
|
|
44519
|
+
function _buildKeyAction(variantDiff, oldVariant) {
|
|
44520
|
+
if ({}.hasOwnProperty.call(variantDiff, "key")) {
|
|
44521
|
+
const newValue = getDeltaValue(
|
|
44522
|
+
variantDiff.key
|
|
44523
|
+
);
|
|
44524
|
+
if (!newValue && !oldVariant.key) return null;
|
|
44525
|
+
return {
|
|
44526
|
+
action: "setKey",
|
|
44527
|
+
key: newValue || void 0
|
|
44528
|
+
};
|
|
44529
|
+
}
|
|
44530
|
+
return null;
|
|
44531
|
+
}
|
|
44532
|
+
function _buildSkuAction(variantDiff, oldVariant, config = {}) {
|
|
44533
|
+
if ({}.hasOwnProperty.call(variantDiff, "sku")) {
|
|
44534
|
+
const newValue = getDeltaValue(
|
|
44535
|
+
variantDiff.sku
|
|
44536
|
+
);
|
|
44537
|
+
if (!newValue && !oldVariant.sku) return null;
|
|
44538
|
+
return _buildStagedAction("setSku", { sku: newValue || void 0 }, config);
|
|
44539
|
+
}
|
|
44540
|
+
return null;
|
|
44541
|
+
}
|
|
44542
|
+
function _buildPublishAction(oldVariant, newVariant) {
|
|
44543
|
+
if (oldVariant.published !== true && newVariant.published === true) {
|
|
44544
|
+
return { action: "publish" };
|
|
44545
|
+
}
|
|
44546
|
+
if (oldVariant.published === true && newVariant.published !== true) {
|
|
44547
|
+
return { action: "unpublish" };
|
|
44548
|
+
}
|
|
44549
|
+
return null;
|
|
44550
|
+
}
|
|
44551
|
+
function actionsMapBase27(diff2, oldVariant, newVariant, config = {}) {
|
|
44552
|
+
const actions = [];
|
|
44553
|
+
if (!oldVariant || !diff2) {
|
|
44554
|
+
return actions;
|
|
44555
|
+
}
|
|
44556
|
+
const keyAction = _buildKeyAction(diff2, oldVariant);
|
|
44557
|
+
if (keyAction) {
|
|
44558
|
+
actions.push(keyAction);
|
|
44559
|
+
}
|
|
44560
|
+
const skuAction = _buildSkuAction(diff2, oldVariant, config);
|
|
44561
|
+
if (skuAction) {
|
|
44562
|
+
actions.push(skuAction);
|
|
44563
|
+
}
|
|
44564
|
+
const publishAction = _buildPublishAction(oldVariant, newVariant);
|
|
44565
|
+
if (publishAction) {
|
|
44566
|
+
actions.push(publishAction);
|
|
44567
|
+
}
|
|
44568
|
+
return actions;
|
|
44569
|
+
}
|
|
44570
|
+
function actionsMapAttributes3(diff2, _oldVariant, newVariant, config = {}) {
|
|
44571
|
+
if (!(diff2 == null ? void 0 : diff2.attributes)) {
|
|
44572
|
+
return [];
|
|
44573
|
+
}
|
|
44574
|
+
const attributes = (newVariant.attributes || []).map(
|
|
44575
|
+
convertAttributeToUpdateActionShape
|
|
44576
|
+
);
|
|
44577
|
+
return [_buildStagedAction("setAttributes", { attributes }, config)];
|
|
44578
|
+
}
|
|
44579
|
+
function actionsMapImages3(diff2, _oldVariant, newVariant, config = {}) {
|
|
44580
|
+
if (!(diff2 == null ? void 0 : diff2.images)) {
|
|
44581
|
+
return [];
|
|
44582
|
+
}
|
|
44583
|
+
const images = newVariant.images || [];
|
|
44584
|
+
return [_buildStagedAction("setImages", { images }, config)];
|
|
44585
|
+
}
|
|
44586
|
+
function actionsMapAssets4(diff2, _oldVariant, newVariant, config = {}) {
|
|
44587
|
+
if (!(diff2 == null ? void 0 : diff2.assets)) {
|
|
44588
|
+
return [];
|
|
44589
|
+
}
|
|
44590
|
+
const assets = newVariant.assets || [];
|
|
44591
|
+
return [_buildStagedAction("setAssets", { assets }, config)];
|
|
44592
|
+
}
|
|
44593
|
+
|
|
44594
|
+
// src/standalone-variants/standalone-variants.ts
|
|
44595
|
+
function createStandaloneVariantsMapActions(mapActionGroup, syncActionConfig) {
|
|
44596
|
+
return function doMapActions(diff2, newObj, oldObj) {
|
|
44597
|
+
const allActions = [];
|
|
44598
|
+
allActions.push(
|
|
44599
|
+
...mapActionGroup(
|
|
44600
|
+
"base",
|
|
44601
|
+
() => actionsMapBase27(diff2, oldObj, newObj, syncActionConfig)
|
|
44602
|
+
)
|
|
44603
|
+
);
|
|
44604
|
+
allActions.push(
|
|
44605
|
+
...mapActionGroup(
|
|
44606
|
+
"attributes",
|
|
44607
|
+
() => actionsMapAttributes3(diff2, oldObj, newObj, syncActionConfig)
|
|
44608
|
+
)
|
|
44609
|
+
);
|
|
44610
|
+
allActions.push(
|
|
44611
|
+
...mapActionGroup(
|
|
44612
|
+
"images",
|
|
44613
|
+
() => actionsMapImages3(diff2, oldObj, newObj, syncActionConfig)
|
|
44614
|
+
)
|
|
44615
|
+
);
|
|
44616
|
+
allActions.push(
|
|
44617
|
+
...mapActionGroup(
|
|
44618
|
+
"assets",
|
|
44619
|
+
() => actionsMapAssets4(diff2, oldObj, newObj, syncActionConfig)
|
|
44620
|
+
)
|
|
44621
|
+
);
|
|
44622
|
+
return allActions;
|
|
44623
|
+
};
|
|
44624
|
+
}
|
|
44625
|
+
function createSyncStandaloneVariants(actionGroupList, syncActionConfig = {}) {
|
|
44626
|
+
const mapActionGroup = createMapActionGroup(actionGroupList);
|
|
44627
|
+
const doMapActions = createStandaloneVariantsMapActions(
|
|
44628
|
+
mapActionGroup,
|
|
44629
|
+
syncActionConfig
|
|
44630
|
+
);
|
|
44631
|
+
const buildActions = createBuildActions(diff, doMapActions);
|
|
44632
|
+
return { buildActions };
|
|
44633
|
+
}
|
|
44634
|
+
|
|
43916
44635
|
// src/utils/types.ts
|
|
43917
44636
|
var types_exports = {};
|
|
43918
44637
|
__reExport(types_exports, __toESM(require_commercetools_platform_sdk_cjs()));
|
|
@@ -43934,12 +44653,14 @@ __reExport(index_exports, types_exports, module.exports);
|
|
|
43934
44653
|
createSyncOrders,
|
|
43935
44654
|
createSyncProductDiscounts,
|
|
43936
44655
|
createSyncProductSelections,
|
|
44656
|
+
createSyncProductTailoring,
|
|
43937
44657
|
createSyncProductTypes,
|
|
43938
44658
|
createSyncProducts,
|
|
43939
44659
|
createSyncProjects,
|
|
43940
44660
|
createSyncRecurringOrders,
|
|
43941
44661
|
createSyncShippingMethods,
|
|
43942
44662
|
createSyncStandalonePrices,
|
|
44663
|
+
createSyncStandaloneVariants,
|
|
43943
44664
|
createSyncStates,
|
|
43944
44665
|
createSyncStores,
|
|
43945
44666
|
createSyncSubscriptions,
|