@softwear/latestcollectioncore 1.0.67 → 1.0.69

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.
@@ -2,9 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const index_1 = require("./index");
4
4
  // The order of the following mappingPairs is significant.
5
- // The ERM mapping relies on the Gender and ProductGroup mapping to have been evaluated first
5
+ // - If no mapping is available, we prefer colorFamily to be copied from colorSupplier, not colorCodeSupplier.
6
+ // Hence the order and mustMatch values of the first two lines.
7
+ //
8
+ // - The ERM mapping relies on the Gender and ProductGroup mapping to have been evaluated first
6
9
  const mappingPairs = [
7
- { category: 'ColorCode', from: 'colorCodeSupplier', to: 'colorFamily' },
10
+ { category: 'ColorCode', from: 'colorCodeSupplier', to: 'colorFamily', mustMatch: true },
8
11
  { category: 'ColorDescription', from: 'colorSupplier', to: 'colorFamily' },
9
12
  { category: 'ProductGroup', from: 'articleGroupSupplier', to: 'articleGroup' },
10
13
  { category: 'BTEGroup', from: 'articleGroupSupplier', to: 'BTEGROUP', mustMatch: true },
@@ -26,7 +29,7 @@ function default_1(brands, strategy) {
26
29
  brands.forEach(({ id, propertyMapping }) => {
27
30
  if (!indexedByBrandPropertyMapping[id])
28
31
  indexedByBrandPropertyMapping[id] = {};
29
- propertyMapping?.forEach((mapping) => {
32
+ propertyMapping === null || propertyMapping === void 0 ? void 0 : propertyMapping.forEach((mapping) => {
30
33
  if (!indexedByBrandPropertyMapping[id][mapping.category])
31
34
  indexedByBrandPropertyMapping[id][mapping.category] = {};
32
35
  indexedByBrandPropertyMapping[id][mapping.category][mapping.from] = mapping.to;
@@ -37,8 +40,9 @@ function default_1(brands, strategy) {
37
40
  const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
38
41
  const mapping = indexedByBrandPropertyMapping[brand];
39
42
  mappingPairs.forEach((pair) => {
43
+ var _a;
40
44
  const from = evaluateFromExpr(sku, pair.from) || '';
41
- const to = mapping?.[pair.category]?.[from];
45
+ const to = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a[from];
42
46
  if (!from || !to)
43
47
  return;
44
48
  if (sku[pair.to] == to || from == sku[pair.to])
@@ -51,10 +55,11 @@ function default_1(brands, strategy) {
51
55
  const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
52
56
  const mapping = indexedByBrandPropertyMapping[brand];
53
57
  mappingPairs.forEach((pair) => {
58
+ var _a, _b, _c, _d, _e;
54
59
  const from = evaluateFromExpr(sku, pair.from) || '';
55
- const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource;
60
+ const redirectedMappingSource = ((_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~']) || pair.defaultMappingSource;
56
61
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
57
- const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.[''];
62
+ const to = ((_b = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _b === void 0 ? void 0 : _b[from]) || ((_c = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _c === void 0 ? void 0 : _c['']) || ((_d = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _d === void 0 ? void 0 : _d[from]) || ((_e = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _e === void 0 ? void 0 : _e['']);
58
63
  if (to == undefined)
59
64
  sku[pair.to] = '***';
60
65
  });
@@ -64,12 +69,13 @@ function default_1(brands, strategy) {
64
69
  const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
65
70
  const mapping = indexedByBrandPropertyMapping[brand];
66
71
  mappingPairs.forEach((pair) => {
72
+ var _a, _b, _c, _d, _e;
67
73
  if (sku[pair.to])
68
74
  return; // Do not replace sku-level-user-supplied values
69
75
  const from = evaluateFromExpr(sku, pair.from);
70
- const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource;
76
+ const redirectedMappingSource = ((_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~']) || pair.defaultMappingSource;
71
77
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
72
- const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.[''];
78
+ const to = ((_b = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _b === void 0 ? void 0 : _b[from]) || ((_c = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _c === void 0 ? void 0 : _c['']) || ((_d = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _d === void 0 ? void 0 : _d[from]) || ((_e = redirectedMapping === null || redirectedMapping === void 0 ? void 0 : redirectedMapping[pair.category]) === null || _e === void 0 ? void 0 : _e['']);
73
79
  if (!from && !to)
74
80
  return;
75
81
  if (pair.mustMatch) {
@@ -3,14 +3,15 @@ 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;
6
7
  let allMappings = [];
7
- if (activeConfig?.products?.applyLatestCollectionMapping?.value)
8
+ if ((_b = (_a = activeConfig === null || activeConfig === void 0 ? void 0 : activeConfig.products) === null || _a === void 0 ? void 0 : _a.applyLatestCollectionMapping) === null || _b === void 0 ? void 0 : _b.value)
8
9
  allMappings = metaBrandSetting;
9
- if (activeConfig?.products?.applyDataProviderMapping?.value)
10
+ if ((_d = (_c = activeConfig === null || activeConfig === void 0 ? void 0 : activeConfig.products) === null || _c === void 0 ? void 0 : _c.applyDataProviderMapping) === null || _d === void 0 ? void 0 : _d.value)
10
11
  activeConfig.products.applyDataProviderMapping.value.forEach((provider) => {
11
- allMappings = allMappings.concat(dataProviderBrandSetting.filter((s) => s.dataProvider == provider).map((s) => ({ ...s, id: s.id.split(":")[0] })));
12
+ allMappings = allMappings.concat(dataProviderBrandSetting.filter((s) => s.dataProvider == provider).map((s) => (Object.assign(Object.assign({}, s), { id: s.id.split(":")[0] }))));
12
13
  });
13
- if (activeConfig?.products?.applyTenantMapping?.value)
14
+ if ((_f = (_e = activeConfig === null || activeConfig === void 0 ? void 0 : activeConfig.products) === null || _e === void 0 ? void 0 : _e.applyTenantMapping) === null || _f === void 0 ? void 0 : _f.value)
14
15
  allMappings = allMappings.concat(tenantBrandSetting);
15
16
  return allMappings;
16
17
  }
package/dist/sizeToMap.js CHANGED
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function default_1(size) {
4
4
  if (typeof size != 'string')
5
5
  return '';
6
- return size.replaceAll(' ', '').replaceAll(',', '.').toUpperCase();
6
+ return size.replace(/\s/g, '').replace(/,/g, '.').toUpperCase();
7
7
  }
8
8
  exports.default = default_1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,9 +1,12 @@
1
1
  import { hashBrand, SkuI, BrandSettingI, mappingStrategyE } from './index'
2
2
 
3
3
  // The order of the following mappingPairs is significant.
4
- // The ERM mapping relies on the Gender and ProductGroup mapping to have been evaluated first
4
+ // - If no mapping is available, we prefer colorFamily to be copied from colorSupplier, not colorCodeSupplier.
5
+ // Hence the order and mustMatch values of the first two lines.
6
+ //
7
+ // - The ERM mapping relies on the Gender and ProductGroup mapping to have been evaluated first
5
8
  const mappingPairs = [
6
- { category: 'ColorCode', from: 'colorCodeSupplier', to: 'colorFamily' },
9
+ { category: 'ColorCode', from: 'colorCodeSupplier', to: 'colorFamily', mustMatch: true },
7
10
  { category: 'ColorDescription', from: 'colorSupplier', to: 'colorFamily' },
8
11
  { category: 'ProductGroup', from: 'articleGroupSupplier', to: 'articleGroup' },
9
12
  { category: 'BTEGroup', from: 'articleGroupSupplier', to: 'BTEGROUP', mustMatch: true },
package/src/sizeToMap.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export default function (size: string): string {
2
2
  if (typeof size != 'string') return ''
3
- return size.replaceAll(' ', '').replaceAll(',', '.').toUpperCase()
3
+ return size.replace(/\s/g, '').replace(/,/g, '.').toUpperCase()
4
4
  }
@@ -176,7 +176,6 @@ describe('applyPreferedPropertyMappings', () => {
176
176
  collectionSupplier: 'SUMMER 2022',
177
177
  colorCodeSupplier: '100',
178
178
  size: 'S',
179
- colorFamily: '100',
180
179
  collection: 'User defined value wins',
181
180
  })
182
181
  })
@@ -16,6 +16,7 @@ const skus = [
16
16
  brand: 'levis',
17
17
  collectionSupplier: 'SUMMER 2022',
18
18
  colorCodeSupplier: '100',
19
+ colorSupplier: 'Black',
19
20
  size: 'S',
20
21
  sizeSupplier: 'S',
21
22
  articleGroupSupplier: '10000',
@@ -25,6 +26,7 @@ const skus = [
25
26
  brand: 'levis',
26
27
  collectionSupplier: 'SUMMER 2022',
27
28
  colorCodeSupplier: '100',
29
+ colorSupplier: 'Black',
28
30
  size: 'M',
29
31
  sizeSupplier: 'M',
30
32
  articleGroupSupplier: '10000',
@@ -34,6 +36,7 @@ const skus = [
34
36
  brand: 'levis',
35
37
  collectionSupplier: 'SUMMER 2022',
36
38
  colorCodeSupplier: '100',
39
+ colorSupplier: 'Black',
37
40
  size: 'L',
38
41
  sizeSupplier: 'L',
39
42
  articleGroupSupplier: '10000',
@@ -43,6 +46,7 @@ const skus = [
43
46
  brand: 'levis',
44
47
  collectionSupplier: 'SUMMER 2022',
45
48
  colorCodeSupplier: '200',
49
+ colorSupplier: 'Navy',
46
50
  size: 'S',
47
51
  sizeSupplier: 'S',
48
52
  articleGroupSupplier: '10000',
@@ -52,6 +56,7 @@ const skus = [
52
56
  brand: 'levis',
53
57
  collectionSupplier: 'SUMMER 2022',
54
58
  colorCodeSupplier: '200',
59
+ colorSupplier: 'Navy',
55
60
  size: 'M',
56
61
  sizeSupplier: 'M',
57
62
  articleGroupSupplier: '10000',
@@ -61,6 +66,7 @@ const skus = [
61
66
  brand: 'levis',
62
67
  collectionSupplier: 'SUMMER 2022',
63
68
  colorCodeSupplier: '200',
69
+ colorSupplier: 'Navy',
64
70
  size: 'L',
65
71
  sizeSupplier: 'L',
66
72
  articleGroupSupplier: '10000',
@@ -72,6 +78,7 @@ const skus = [
72
78
  collectionSupplier: 'SUMMER 2022',
73
79
  collection: 'User defined value wins',
74
80
  colorCodeSupplier: '200',
81
+ colorSupplier: 'Navy',
75
82
  colorFamily: 'Blue',
76
83
  size: 'S',
77
84
  sizeSupplier: 'S',
@@ -82,6 +89,7 @@ const skus = [
82
89
  brand: 'gstar',
83
90
  collectionSupplier: 'SUMMER 2022',
84
91
  colorCodeSupplier: '200',
92
+ colorSupplier: 'Navy',
85
93
  colorFamily: 'Blue',
86
94
  size: 'M',
87
95
  sizeSupplier: 'M',
@@ -92,6 +100,7 @@ const skus = [
92
100
  brand: 'gstar',
93
101
  collectionSupplier: 'SUMMER 2022',
94
102
  colorCodeSupplier: '200',
103
+ colorSupplier: 'Navy',
95
104
  colorFamily: 'Blue',
96
105
  size: 'L',
97
106
  sizeSupplier: 'L',
@@ -102,6 +111,7 @@ const skus = [
102
111
  brand: 'gstar',
103
112
  collectionSupplier: 'SUMMER 2022',
104
113
  colorCodeSupplier: '200',
114
+ colorSupplier: 'Navy',
105
115
  size: 'M',
106
116
  sizeSupplier: 'M',
107
117
  collection: '22zomer',
@@ -113,6 +123,7 @@ const skus = [
113
123
  brand: 'gstar',
114
124
  collectionSupplier: 'SUMMER 2022',
115
125
  colorCodeSupplier: '200',
126
+ colorSupplier: 'Navy',
116
127
  colorFamily: 'Blue',
117
128
  size: 'L',
118
129
  sizeSupplier: 'L',
@@ -244,7 +255,8 @@ describe('applyPropertyMapping', () => {
244
255
  colorCodeSupplier: '100',
245
256
  size: 'S',
246
257
  sizeSupplier: 'S',
247
- colorFamily: '100',
258
+ colorFamily: 'Black',
259
+ colorSupplier: 'Black',
248
260
  collection: 'SUMMER 2022',
249
261
  _customsize: 'S',
250
262
  articleGroup: '10000',
@@ -366,7 +378,7 @@ describe('applyPropertyMapping', () => {
366
378
  expect(mappedSkus[0]['_erm-code']).to.equal('10000 - Women - Dresses')
367
379
  })
368
380
 
369
- it('returns mapped skus on a default mapping rules', function () {
381
+ it('returns mapped skus on default mapping rules', function () {
370
382
  const mappedSkus = applyPropertyMapping(deepCopy(skus), fallbackMapping)
371
383
  expect(mappedSkus[0].colorFamily).to.equal('fallbackMapping')
372
384
  expect(mappedSkus[1].colorFamily).to.equal('fallbackMapping')
@@ -391,4 +403,9 @@ describe('applyPropertyMapping', () => {
391
403
  expect(mappedSkus[6].articleGroup).to.equal('TENANT-articleGroupMapping')
392
404
  expect(mappedSkus[10].articleGroup).to.equal('LAT-articleGroupMapping')
393
405
  })
406
+
407
+ it('returns colorFamily copied from colorSupplier on a articlegroup mapping', function () {
408
+ const mappedSkus = applyPropertyMapping(deepCopy(skus), articleGroupMapping)
409
+ expect(mappedSkus[0].colorFamily).to.equal('Black')
410
+ })
394
411
  })
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": "es2021" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
6
+ "target": "es6" /* 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. */