@softwear/latestcollectioncore 1.0.26 → 1.0.28
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/dist/buildPropertyMappingFn.js +8 -1
- package/dist/consts.d.ts +1 -1
- package/dist/consts.js +1 -1
- package/dist/getPreferedPropertyMappings.js +2 -0
- package/dist/hashBrand.js +1 -1
- package/package.json +1 -1
- package/src/buildPropertyMappingFn.ts +7 -1
- package/src/consts.ts +1 -1
- package/src/getPreferedPropertyMappings.ts +2 -0
- package/src/hashBrand.ts +1 -1
- package/test/applyPropertyMapping.spec.js +4 -0
- package/test/hashBrand.spec.js +1 -1
|
@@ -4,7 +4,7 @@ const index_1 = require("./index");
|
|
|
4
4
|
function default_1(brands) {
|
|
5
5
|
// Helper function to convert all mapping rules for given category to an indexed object
|
|
6
6
|
const indexedMapping = function (propertyMapping, category) {
|
|
7
|
-
const filteredMappings = propertyMapping.filter((mapping) => mapping.category == category && mapping.from);
|
|
7
|
+
const filteredMappings = propertyMapping.filter((mapping) => mapping.category == category && mapping.from != undefined);
|
|
8
8
|
if (filteredMappings.length == 0)
|
|
9
9
|
return undefined;
|
|
10
10
|
return filteredMappings.reduce((acc, item) => {
|
|
@@ -93,6 +93,13 @@ function default_1(brands) {
|
|
|
93
93
|
sku["_customsize"] = to;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
if (mapping.Gender) {
|
|
97
|
+
// There is nothing to map 'from'
|
|
98
|
+
// We only implement the fallback, this mapping is only usefull for brands where gender is constant
|
|
99
|
+
const to = indexedPropertyMapping[brand].Gender[""];
|
|
100
|
+
if (to && to != sku["_gender"])
|
|
101
|
+
sku["_gender"] = to;
|
|
102
|
+
}
|
|
96
103
|
return sku;
|
|
97
104
|
};
|
|
98
105
|
}
|
package/dist/consts.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const MAPPING_CATEGORIES: readonly ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize"];
|
|
1
|
+
declare const MAPPING_CATEGORIES: readonly ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize", "Gender"];
|
|
2
2
|
export { MAPPING_CATEGORIES };
|
package/dist/consts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MAPPING_CATEGORIES = void 0;
|
|
4
|
-
const MAPPING_CATEGORIES = ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize"];
|
|
4
|
+
const MAPPING_CATEGORIES = ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize", "Gender"];
|
|
5
5
|
exports.MAPPING_CATEGORIES = MAPPING_CATEGORIES;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// This function combined the 3 levels of property mapping into one mapping object
|
|
4
|
+
// Each level can be opted in/out in the tenantPreferences defined in the activeConfig parameter
|
|
3
5
|
function default_1(activeConfig, metaBrandSetting, dataProviderBrandSetting, tenantBrandSetting) {
|
|
4
6
|
var _a, _b, _c, _d, _e, _f;
|
|
5
7
|
let allMappings = [];
|
package/dist/hashBrand.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
function default_1(brand = "") {
|
|
4
4
|
if (typeof brand != "string")
|
|
5
5
|
return "";
|
|
6
|
-
const charactersToRemove = "
|
|
6
|
+
const charactersToRemove = "~.<>!@#$%^&*():'\"? ";
|
|
7
7
|
const l = brand.length;
|
|
8
8
|
let result = "";
|
|
9
9
|
for (let i = 0; i < l; i++) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { hashBrand, SkuI, MAPPING_CATEGORIES } from "./index"
|
|
|
3
3
|
export default function (brands: Array<any>): (sku: SkuI) => SkuI {
|
|
4
4
|
// Helper function to convert all mapping rules for given category to an indexed object
|
|
5
5
|
const indexedMapping = function (propertyMapping, category) {
|
|
6
|
-
const filteredMappings = propertyMapping.filter((mapping) => mapping.category == category && mapping.from)
|
|
6
|
+
const filteredMappings = propertyMapping.filter((mapping) => mapping.category == category && mapping.from != undefined)
|
|
7
7
|
|
|
8
8
|
if (filteredMappings.length == 0) return undefined
|
|
9
9
|
return filteredMappings.reduce((acc, item) => {
|
|
@@ -84,6 +84,12 @@ export default function (brands: Array<any>): (sku: SkuI) => SkuI {
|
|
|
84
84
|
if (to && to != sku["_customsize"]) sku["_customsize"] = to
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
if (mapping.Gender) {
|
|
88
|
+
// There is nothing to map 'from'
|
|
89
|
+
// We only implement the fallback, this mapping is only usefull for brands where gender is constant
|
|
90
|
+
const to = indexedPropertyMapping[brand].Gender[""]
|
|
91
|
+
if (to && to != sku["_gender"]) sku["_gender"] = to
|
|
92
|
+
}
|
|
87
93
|
return sku
|
|
88
94
|
}
|
|
89
95
|
}
|
package/src/consts.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const MAPPING_CATEGORIES = ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize"] as const
|
|
1
|
+
const MAPPING_CATEGORIES = ["ERM", "ColorCode", "ColorDescription", "Collection", "ProductGroup", "Size", "SubSize", "CustomSize", "Gender"] as const
|
|
2
2
|
|
|
3
3
|
export { MAPPING_CATEGORIES }
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// This function combined the 3 levels of property mapping into one mapping object
|
|
2
|
+
// Each level can be opted in/out in the tenantPreferences defined in the activeConfig parameter
|
|
1
3
|
export default function (activeConfig, metaBrandSetting, dataProviderBrandSetting, tenantBrandSetting) {
|
|
2
4
|
let allMappings = []
|
|
3
5
|
if (activeConfig?.products?.applyLatestCollectionMapping?.value) allMappings = metaBrandSetting
|
package/src/hashBrand.ts
CHANGED
|
@@ -134,6 +134,7 @@ const fullMapping = [
|
|
|
134
134
|
propertyMapping: [
|
|
135
135
|
{ category: "Collection", from: "SUMMER 2022", to: "22zomer" },
|
|
136
136
|
{ category: "CustomSize", from: "M", to: "medium" },
|
|
137
|
+
{ category: "Gender", from: "", to: "uni" },
|
|
137
138
|
],
|
|
138
139
|
},
|
|
139
140
|
]
|
|
@@ -219,5 +220,8 @@ describe("applyPropertyMapping", () => {
|
|
|
219
220
|
|
|
220
221
|
expect(mappedSkus[1]._customsize).to.equal(undefined)
|
|
221
222
|
expect(mappedSkus[7]._customsize).to.equal("medium")
|
|
223
|
+
|
|
224
|
+
expect(mappedSkus[1]._gender).to.equal(undefined)
|
|
225
|
+
expect(mappedSkus[7]._gender).to.equal("uni")
|
|
222
226
|
})
|
|
223
227
|
})
|
package/test/hashBrand.spec.js
CHANGED
|
@@ -12,6 +12,6 @@ describe("hashBrand function", function () {
|
|
|
12
12
|
expect(hashBrand("Marie Jo")).to.equal("mariejo")
|
|
13
13
|
})
|
|
14
14
|
it("should return the input stripped from non characters", function () {
|
|
15
|
-
expect(hashBrand("Cl
|
|
15
|
+
expect(hashBrand("Cl ~<>!@#$%.^&*():'\"? ean")).to.equal("clean")
|
|
16
16
|
})
|
|
17
17
|
})
|