@softwear/latestcollectioncore 1.0.60 → 1.0.62

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.
@@ -62,9 +62,11 @@ function default_1(brands, strategy) {
62
62
  const brand = sku.BRANDHASH || (0, index_1.hashBrand)(sku.brand);
63
63
  const mapping = indexedByBrandPropertyMapping[brand];
64
64
  mappingPairs.forEach((pair) => {
65
- var _a;
65
+ var _a, _b, _c, _d, _e;
66
66
  const from = sku[pair.from] || '';
67
- const to = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a[from];
67
+ const redirectedMappingSource = (_a = mapping === null || mapping === void 0 ? void 0 : mapping[pair.category]) === null || _a === void 0 ? void 0 : _a['~~'];
68
+ const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {};
69
+ 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['']);
68
70
  if (to == undefined)
69
71
  sku[pair.to] = '***';
70
72
  });
package/dist/consts.d.ts CHANGED
@@ -18,7 +18,7 @@ declare const SUBSCRIPTION_LIMITS: {
18
18
  readonly medium: {
19
19
  readonly maxBarcodes: 100000;
20
20
  readonly maxDownloadBarcodes: 5000;
21
- readonly maxCustomers: 50000;
21
+ readonly maxCustomers: 5000;
22
22
  };
23
23
  readonly large: {
24
24
  readonly maxBarcodes: 250000;
package/dist/consts.js CHANGED
@@ -35,7 +35,7 @@ const SUBSCRIPTION_LIMITS = {
35
35
  medium: {
36
36
  maxBarcodes: 100000,
37
37
  maxDownloadBarcodes: 5000,
38
- maxCustomers: 50000,
38
+ maxCustomers: 5000,
39
39
  },
40
40
  large: {
41
41
  maxBarcodes: 250000,
@@ -1,5 +1,4 @@
1
1
  /**
2
- *
3
2
  * @param value string or number
4
3
  * @returns true if input contains only digits
5
4
  */
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
- *
5
4
  * @param value string or number
6
5
  * @returns true if input contains only digits
7
6
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.60",
3
+ "version": "1.0.62",
4
4
  "description": "Core functions for LatestCollections applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -57,7 +57,10 @@ export default function (brands: Array<BrandSettingI>, strategy: mappingStrategy
57
57
  const mapping = indexedByBrandPropertyMapping[brand]
58
58
  mappingPairs.forEach((pair) => {
59
59
  const from = sku[pair.from] || ''
60
- const to = mapping?.[pair.category]?.[from]
60
+ const redirectedMappingSource = mapping?.[pair.category]?.['~~']
61
+ const redirectedMapping = redirectedMappingSource ? indexedByBrandPropertyMapping[redirectedMappingSource] : {}
62
+
63
+ const to = mapping?.[pair.category]?.[from] || mapping?.[pair.category]?.[''] || redirectedMapping?.[pair.category]?.[from] || redirectedMapping?.[pair.category]?.['']
61
64
  if (to == undefined) sku[pair.to] = '***'
62
65
  })
63
66
  return sku
package/src/consts.ts CHANGED
@@ -31,7 +31,7 @@ const SUBSCRIPTION_LIMITS = {
31
31
  medium: {
32
32
  maxBarcodes: 100000,
33
33
  maxDownloadBarcodes: 5000,
34
- maxCustomers: 50000,
34
+ maxCustomers: 5000,
35
35
  },
36
36
  large: {
37
37
  maxBarcodes: 250000,
@@ -1,5 +1,4 @@
1
1
  /**
2
- *
3
2
  * @param value string or number
4
3
  * @returns true if input contains only digits
5
4
  */
@@ -27,4 +27,15 @@ describe('hasOnlyDigits function', function () {
27
27
  expect(hasOnlyDigits({ key: 'value' })).to.equal(false)
28
28
  expect(hasOnlyDigits(new Date())).to.equal(false)
29
29
  })
30
+
31
+ it('should be fast', function () {
32
+ // This function will be called many times on large datasets
33
+ // We expect 1 million operations to take no more than 1 second on our test infrastructure
34
+ const start = parseInt(process.hrtime.bigint())
35
+ for (let i = 0; i < 1_000_000; i++) {
36
+ const result = hasOnlyDigits('' + 1234567890123 + i)
37
+ }
38
+ const end = parseInt(process.hrtime.bigint())
39
+ expect(end - start).to.be.below(1_000_000_000)
40
+ })
30
41
  })