@softwear/latestcollectioncore 1.0.65 → 1.0.67
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 +6 -9
- package/dist/getPreferedPropertyMappings.js +4 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/sizeToMap.d.ts +1 -0
- package/dist/sizeToMap.js +8 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/sizeToMap.ts +4 -0
- package/test/sizeToMap.js +17 -0
- package/tsconfig.json +1 -1
|
@@ -26,7 +26,7 @@ function default_1(brands, strategy) {
|
|
|
26
26
|
brands.forEach(({ id, propertyMapping }) => {
|
|
27
27
|
if (!indexedByBrandPropertyMapping[id])
|
|
28
28
|
indexedByBrandPropertyMapping[id] = {};
|
|
29
|
-
propertyMapping
|
|
29
|
+
propertyMapping?.forEach((mapping) => {
|
|
30
30
|
if (!indexedByBrandPropertyMapping[id][mapping.category])
|
|
31
31
|
indexedByBrandPropertyMapping[id][mapping.category] = {};
|
|
32
32
|
indexedByBrandPropertyMapping[id][mapping.category][mapping.from] = mapping.to;
|
|
@@ -37,9 +37,8 @@ function default_1(brands, strategy) {
|
|
|
37
37
|
const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
|
|
38
38
|
const mapping = indexedByBrandPropertyMapping[brand];
|
|
39
39
|
mappingPairs.forEach((pair) => {
|
|
40
|
-
var _a;
|
|
41
40
|
const from = evaluateFromExpr(sku, pair.from) || '';
|
|
42
|
-
const to =
|
|
41
|
+
const to = mapping?.[pair.category]?.[from];
|
|
43
42
|
if (!from || !to)
|
|
44
43
|
return;
|
|
45
44
|
if (sku[pair.to] == to || from == sku[pair.to])
|
|
@@ -52,11 +51,10 @@ function default_1(brands, strategy) {
|
|
|
52
51
|
const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
|
|
53
52
|
const mapping = indexedByBrandPropertyMapping[brand];
|
|
54
53
|
mappingPairs.forEach((pair) => {
|
|
55
|
-
var _a, _b, _c, _d, _e;
|
|
56
54
|
const from = evaluateFromExpr(sku, pair.from) || '';
|
|
57
|
-
const redirectedMappingSource =
|
|
55
|
+
const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource;
|
|
58
56
|
const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
|
|
59
|
-
const to =
|
|
57
|
+
const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.[''];
|
|
60
58
|
if (to == undefined)
|
|
61
59
|
sku[pair.to] = '***';
|
|
62
60
|
});
|
|
@@ -66,13 +64,12 @@ function default_1(brands, strategy) {
|
|
|
66
64
|
const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
|
|
67
65
|
const mapping = indexedByBrandPropertyMapping[brand];
|
|
68
66
|
mappingPairs.forEach((pair) => {
|
|
69
|
-
var _a, _b, _c, _d, _e;
|
|
70
67
|
if (sku[pair.to])
|
|
71
68
|
return; // Do not replace sku-level-user-supplied values
|
|
72
69
|
const from = evaluateFromExpr(sku, pair.from);
|
|
73
|
-
const redirectedMappingSource =
|
|
70
|
+
const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource;
|
|
74
71
|
const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
|
|
75
|
-
const to =
|
|
72
|
+
const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.[''];
|
|
76
73
|
if (!from && !to)
|
|
77
74
|
return;
|
|
78
75
|
if (pair.mustMatch) {
|
|
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// This function combined the 3 levels of property mapping into one mapping object
|
|
4
4
|
// Each level can be opted in/out in the tenantPreferences defined in the activeConfig parameter
|
|
5
5
|
function default_1(activeConfig, metaBrandSetting, dataProviderBrandSetting, tenantBrandSetting) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7
6
|
let allMappings = [];
|
|
8
|
-
if (
|
|
7
|
+
if (activeConfig?.products?.applyLatestCollectionMapping?.value)
|
|
9
8
|
allMappings = metaBrandSetting;
|
|
10
|
-
if (
|
|
9
|
+
if (activeConfig?.products?.applyDataProviderMapping?.value)
|
|
11
10
|
activeConfig.products.applyDataProviderMapping.value.forEach((provider) => {
|
|
12
|
-
allMappings = allMappings.concat(dataProviderBrandSetting.filter((s) => s.dataProvider == provider).map((s) => (
|
|
11
|
+
allMappings = allMappings.concat(dataProviderBrandSetting.filter((s) => s.dataProvider == provider).map((s) => ({ ...s, id: s.id.split(":")[0] })));
|
|
13
12
|
});
|
|
14
|
-
if (
|
|
13
|
+
if (activeConfig?.products?.applyTenantMapping?.value)
|
|
15
14
|
allMappings = allMappings.concat(tenantBrandSetting);
|
|
16
15
|
return allMappings;
|
|
17
16
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { default as ean13 } from './ean13';
|
|
|
4
4
|
export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings';
|
|
5
5
|
export { default as hashBrand } from './hashBrand';
|
|
6
6
|
export { default as hasOnlyDigits } from './hasOnlyDigits';
|
|
7
|
+
export { default as sizeToMap } from './sizeToMap';
|
|
7
8
|
export * from './types';
|
|
8
9
|
export * from './consts';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
|
|
20
|
+
exports.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
|
|
21
21
|
var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
|
|
22
22
|
Object.defineProperty(exports, "buildPropertyMappingFn", { enumerable: true, get: function () { return __importDefault(buildPropertyMappingFn_1).default; } });
|
|
23
23
|
var deepCopy_1 = require("./deepCopy");
|
|
@@ -30,5 +30,7 @@ var hashBrand_1 = require("./hashBrand");
|
|
|
30
30
|
Object.defineProperty(exports, "hashBrand", { enumerable: true, get: function () { return __importDefault(hashBrand_1).default; } });
|
|
31
31
|
var hasOnlyDigits_1 = require("./hasOnlyDigits");
|
|
32
32
|
Object.defineProperty(exports, "hasOnlyDigits", { enumerable: true, get: function () { return __importDefault(hasOnlyDigits_1).default; } });
|
|
33
|
+
var sizeToMap_1 = require("./sizeToMap");
|
|
34
|
+
Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
|
|
33
35
|
__exportStar(require("./types"), exports);
|
|
34
36
|
__exportStar(require("./consts"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (size: string): string;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,5 +4,6 @@ export { default as ean13 } from './ean13'
|
|
|
4
4
|
export { default as getPreferedPropertyMappings } from './getPreferedPropertyMappings'
|
|
5
5
|
export { default as hashBrand } from './hashBrand'
|
|
6
6
|
export { default as hasOnlyDigits } from './hasOnlyDigits'
|
|
7
|
+
export { default as sizeToMap } from './sizeToMap'
|
|
7
8
|
export * from './types'
|
|
8
9
|
export * from './consts'
|
package/src/sizeToMap.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { sizeToMap } = require('../dist/index')
|
|
2
|
+
const { expect } = require('chai')
|
|
3
|
+
|
|
4
|
+
describe('sizeToMap function', function () {
|
|
5
|
+
it('should return an empty string on non-string inputs', function () {
|
|
6
|
+
expect(sizeToMap(3)).to.equal('')
|
|
7
|
+
})
|
|
8
|
+
it('should return the input with spaces spaces', function () {
|
|
9
|
+
expect(sizeToMap(' 65 B ')).to.equal('65B')
|
|
10
|
+
})
|
|
11
|
+
it("should return the input with comma's replaced with dots", function () {
|
|
12
|
+
expect(sizeToMap('32,32')).to.equal('32.32')
|
|
13
|
+
})
|
|
14
|
+
it('should return the input as uppercase', function () {
|
|
15
|
+
expect(sizeToMap('xxl')).to.equal('XXL')
|
|
16
|
+
})
|
|
17
|
+
})
|
package/tsconfig.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
4
|
/* Basic Options */
|
|
5
5
|
// "incremental": true, /* Enable incremental compilation */
|
|
6
|
-
"target": "
|
|
6
|
+
"target": "es2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
|
|
7
7
|
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
|
|
8
8
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
9
9
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|