@softwear/latestcollectioncore 1.0.63 → 1.0.64

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.
@@ -14,7 +14,7 @@ const mappingPairs = [
14
14
  { category: 'CustomSize', from: 'sizeSupplier', to: '_customsize' },
15
15
  { category: 'Size', from: 'sizeSupplier', to: 'size' },
16
16
  { category: 'Gender', from: 'articleGroupSupplier', to: '_gender', mustMatch: true },
17
- { category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true },
17
+ { category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true, defaultMappingSource: 'ermmapping' },
18
18
  ];
19
19
  const evaluateFromExpr = function (sku, from) {
20
20
  if (typeof from == 'string')
@@ -72,7 +72,7 @@ function default_1(brands, strategy) {
72
72
  mappingPairs.forEach((pair) => {
73
73
  var _a, _b, _c, _d, _e;
74
74
  const from = evaluateFromExpr(sku, pair.from) || '';
75
- const redirectedMappingSource = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~'];
75
+ const redirectedMappingSource = ((_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~']) || pair.defaultMappingSource;
76
76
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
77
77
  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['']);
78
78
  if (to == undefined)
@@ -88,7 +88,7 @@ function default_1(brands, strategy) {
88
88
  if (sku[pair.to])
89
89
  return; // Do not replace sku-level-user-supplied values
90
90
  const from = evaluateFromExpr(sku, pair.from);
91
- const redirectedMappingSource = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~'];
91
+ const redirectedMappingSource = ((_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~']) || pair.defaultMappingSource;
92
92
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
93
93
  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['']);
94
94
  if (!from && !to)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.63",
3
+ "version": "1.0.64",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@ const mappingPairs = [
13
13
  { category: 'CustomSize', from: 'sizeSupplier', to: '_customsize' },
14
14
  { category: 'Size', from: 'sizeSupplier', to: 'size' },
15
15
  { category: 'Gender', from: 'articleGroupSupplier', to: '_gender', mustMatch: true },
16
- { category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true },
16
+ { category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true, defaultMappingSource: 'ermmapping' },
17
17
  ]
18
18
 
19
19
  const evaluateFromExpr = function (sku: SkuI, from: string | string[]): string {
@@ -65,7 +65,7 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
65
65
  const mapping = indexedByBrandPropertyMapping[brand]
66
66
  mappingPairs.forEach((pair) => {
67
67
  const from = evaluateFromExpr(sku, pair.from) || ''
68
- const redirectedMappingSource = mapping?.[pair.category]?.['~~']
68
+ const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource
69
69
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {}
70
70
 
71
71
  const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.['']
@@ -79,7 +79,7 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
79
79
  mappingPairs.forEach((pair) => {
80
80
  if (sku[pair.to]) return // Do not replace sku-level-user-supplied values
81
81
  const from = evaluateFromExpr(sku, pair.from)
82
- const redirectedMappingSource = mapping?.[pair.category]?.['~~']
82
+ const redirectedMappingSource = mapping?.[pair.category]?.['~~'] || pair.defaultMappingSource
83
83
  const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {}
84
84
 
85
85
  const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.['']