@softwear/latestcollectioncore 1.0.71 → 1.0.73
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 +1 -0
- package/dist/consts.d.ts +6 -6
- package/dist/consts.js +6 -5
- package/dist/findSkuByBarcode.d.ts +10 -0
- package/dist/findSkuByBarcode.js +47 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/buildPropertyMappingFn.ts +1 -0
- package/src/consts.ts +6 -5
- package/src/findSkuByBarcode.ts +34 -0
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
- package/test/ean13.spec.js +10 -8
- package/test/findSkuByBarcode.spec.js +23 -0
- package/test/{sizeToMap.js → sizeToMap.spec.js} +3 -0
|
@@ -17,6 +17,7 @@ const mappingPairs = [
|
|
|
17
17
|
{ category: 'CustomSize', from: 'sizeSupplier', to: '_customsize' },
|
|
18
18
|
{ category: 'Size', from: 'sizeSupplier', to: 'size' },
|
|
19
19
|
{ category: 'Gender', from: 'articleGroupSupplier', to: '_gender', mustMatch: true },
|
|
20
|
+
{ category: 'GenderSupplier', from: 'genderSupplier', to: '_gender', mustMatch: true },
|
|
20
21
|
{ category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true, defaultMappingSource: 'ermmapping' },
|
|
21
22
|
];
|
|
22
23
|
const evaluateFromExpr = function (sku, from) {
|
package/dist/consts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const MAPPING_CATEGORIES: readonly ["BTEGroup", "Collection", "ColorCode", "ColorDescription", "CustomSize", "DTBGroup", "ERM", "Gender", "FedasGroup", "ProductGroup", "Size", "SubSize"];
|
|
1
|
+
declare const MAPPING_CATEGORIES: readonly ["BTEGroup", "Collection", "ColorCode", "ColorDescription", "CustomSize", "DTBGroup", "ERM", "Gender", "GenderSupplier", "FedasGroup", "ProductGroup", "Size", "SubSize"];
|
|
2
2
|
declare const SUBSCRIPTION_LIMITS: {
|
|
3
3
|
readonly data_only: {
|
|
4
4
|
readonly maxBarcodes: 1000;
|
|
@@ -8,17 +8,17 @@ declare const SUBSCRIPTION_LIMITS: {
|
|
|
8
8
|
readonly starter: {
|
|
9
9
|
readonly maxBarcodes: 1000;
|
|
10
10
|
readonly maxDownloadBarcodes: 1000;
|
|
11
|
-
readonly maxCustomers:
|
|
11
|
+
readonly maxCustomers: 100;
|
|
12
12
|
};
|
|
13
13
|
readonly small: {
|
|
14
|
-
readonly maxBarcodes:
|
|
15
|
-
readonly maxDownloadBarcodes:
|
|
16
|
-
readonly maxCustomers:
|
|
14
|
+
readonly maxBarcodes: 50000;
|
|
15
|
+
readonly maxDownloadBarcodes: 2500;
|
|
16
|
+
readonly maxCustomers: 5000;
|
|
17
17
|
};
|
|
18
18
|
readonly medium: {
|
|
19
19
|
readonly maxBarcodes: 100000;
|
|
20
20
|
readonly maxDownloadBarcodes: 5000;
|
|
21
|
-
readonly maxCustomers:
|
|
21
|
+
readonly maxCustomers: 7500;
|
|
22
22
|
};
|
|
23
23
|
readonly large: {
|
|
24
24
|
readonly maxBarcodes: 250000;
|
package/dist/consts.js
CHANGED
|
@@ -10,6 +10,7 @@ const MAPPING_CATEGORIES = [
|
|
|
10
10
|
'DTBGroup',
|
|
11
11
|
'ERM',
|
|
12
12
|
'Gender',
|
|
13
|
+
'GenderSupplier',
|
|
13
14
|
'FedasGroup',
|
|
14
15
|
'ProductGroup',
|
|
15
16
|
'Size',
|
|
@@ -25,17 +26,17 @@ const SUBSCRIPTION_LIMITS = {
|
|
|
25
26
|
starter: {
|
|
26
27
|
maxBarcodes: 1000,
|
|
27
28
|
maxDownloadBarcodes: 1000,
|
|
28
|
-
maxCustomers:
|
|
29
|
+
maxCustomers: 100,
|
|
29
30
|
},
|
|
30
31
|
small: {
|
|
31
|
-
maxBarcodes:
|
|
32
|
-
maxDownloadBarcodes:
|
|
33
|
-
maxCustomers:
|
|
32
|
+
maxBarcodes: 50000,
|
|
33
|
+
maxDownloadBarcodes: 2500,
|
|
34
|
+
maxCustomers: 5000,
|
|
34
35
|
},
|
|
35
36
|
medium: {
|
|
36
37
|
maxBarcodes: 100000,
|
|
37
38
|
maxDownloadBarcodes: 5000,
|
|
38
|
-
maxCustomers:
|
|
39
|
+
maxCustomers: 7500,
|
|
39
40
|
},
|
|
40
41
|
large: {
|
|
41
42
|
maxBarcodes: 250000,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MarkedSkuI } from './types';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Find a sku by 12 or 13 digit barcode.
|
|
5
|
+
* 12-digit US UPC barcodes can be shorthand for a 13-digit barcodes in the DB
|
|
6
|
+
* According to the UPC/EAN standard, US barcodes can omit the first 0 when printed
|
|
7
|
+
*/
|
|
8
|
+
export default function (barcodeToFind: string, skus: {
|
|
9
|
+
[barcode: string]: MarkedSkuI;
|
|
10
|
+
}): MarkedSkuI | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Find a sku by 12 or 13 digit barcode.
|
|
6
|
+
* 12-digit US UPC barcodes can be shorthand for a 13-digit barcodes in the DB
|
|
7
|
+
* According to the UPC/EAN standard, US barcodes can omit the first 0 when printed
|
|
8
|
+
*/
|
|
9
|
+
function default_1(barcodeToFind, skus) {
|
|
10
|
+
if (skus[barcodeToFind])
|
|
11
|
+
return skus[barcodeToFind];
|
|
12
|
+
if (barcodeToFind.length == 13 && barcodeToFind.substring(0, 1) == '2') {
|
|
13
|
+
// This is an internally generated barcode.
|
|
14
|
+
// We have some weird errors from the past where incorrect barcodes were generated (wrong check digit.)
|
|
15
|
+
// When these barcodes were printed in our legacy software, noone noticed. Now, when LC prints these barcodes, the printer
|
|
16
|
+
// corrects the check digit. This results in a scan of a barcode that does not appear in the DB.
|
|
17
|
+
// However, we know which barcode we need because we can ignore the check digit.
|
|
18
|
+
const prefix = barcodeToFind.substring(0, 12);
|
|
19
|
+
if (skus[prefix + '0'])
|
|
20
|
+
return skus[prefix + '0'];
|
|
21
|
+
if (skus[prefix + '1'])
|
|
22
|
+
return skus[prefix + '1'];
|
|
23
|
+
if (skus[prefix + '2'])
|
|
24
|
+
return skus[prefix + '2'];
|
|
25
|
+
if (skus[prefix + '3'])
|
|
26
|
+
return skus[prefix + '3'];
|
|
27
|
+
if (skus[prefix + '4'])
|
|
28
|
+
return skus[prefix + '4'];
|
|
29
|
+
if (skus[prefix + '5'])
|
|
30
|
+
return skus[prefix + '5'];
|
|
31
|
+
if (skus[prefix + '6'])
|
|
32
|
+
return skus[prefix + '6'];
|
|
33
|
+
if (skus[prefix + '7'])
|
|
34
|
+
return skus[prefix + '7'];
|
|
35
|
+
if (skus[prefix + '8'])
|
|
36
|
+
return skus[prefix + '8'];
|
|
37
|
+
if (skus[prefix + '9'])
|
|
38
|
+
return skus[prefix + '9'];
|
|
39
|
+
}
|
|
40
|
+
if (barcodeToFind.length != 12)
|
|
41
|
+
return null;
|
|
42
|
+
const barcode13 = '0' + barcodeToFind;
|
|
43
|
+
if (skus[barcode13])
|
|
44
|
+
return skus[barcode13];
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
exports.default = default_1;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export { default as getPreferedPropertyMappings } from './getPreferedPropertyMap
|
|
|
6
6
|
export { default as hashBrand } from './hashBrand';
|
|
7
7
|
export { default as hasOnlyDigits } from './hasOnlyDigits';
|
|
8
8
|
export { default as sizeToMap } from './sizeToMap';
|
|
9
|
+
export { default as findSkuByBarcode } from './findSkuByBarcode';
|
|
9
10
|
export * from './types';
|
|
10
11
|
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.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.isean13 = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = void 0;
|
|
20
|
+
exports.findSkuByBarcode = exports.sizeToMap = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.isean13 = 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");
|
|
@@ -34,5 +34,7 @@ var hasOnlyDigits_1 = require("./hasOnlyDigits");
|
|
|
34
34
|
Object.defineProperty(exports, "hasOnlyDigits", { enumerable: true, get: function () { return __importDefault(hasOnlyDigits_1).default; } });
|
|
35
35
|
var sizeToMap_1 = require("./sizeToMap");
|
|
36
36
|
Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
|
|
37
|
+
var findSkuByBarcode_1 = require("./findSkuByBarcode");
|
|
38
|
+
Object.defineProperty(exports, "findSkuByBarcode", { enumerable: true, get: function () { return __importDefault(findSkuByBarcode_1).default; } });
|
|
37
39
|
__exportStar(require("./types"), exports);
|
|
38
40
|
__exportStar(require("./consts"), exports);
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ const mappingPairs = [
|
|
|
16
16
|
{ category: 'CustomSize', from: 'sizeSupplier', to: '_customsize' },
|
|
17
17
|
{ category: 'Size', from: 'sizeSupplier', to: 'size' },
|
|
18
18
|
{ category: 'Gender', from: 'articleGroupSupplier', to: '_gender', mustMatch: true },
|
|
19
|
+
{ category: 'GenderSupplier', from: 'genderSupplier', to: '_gender', mustMatch: true },
|
|
19
20
|
{ category: 'ERM', from: ['_gender', 'articleGroup'], to: '_erm-code', mustMatch: true, defaultMappingSource: 'ermmapping' },
|
|
20
21
|
]
|
|
21
22
|
|
package/src/consts.ts
CHANGED
|
@@ -7,6 +7,7 @@ const MAPPING_CATEGORIES = [
|
|
|
7
7
|
'DTBGroup',
|
|
8
8
|
'ERM',
|
|
9
9
|
'Gender',
|
|
10
|
+
'GenderSupplier',
|
|
10
11
|
'FedasGroup',
|
|
11
12
|
'ProductGroup',
|
|
12
13
|
'Size',
|
|
@@ -21,17 +22,17 @@ const SUBSCRIPTION_LIMITS = {
|
|
|
21
22
|
starter: {
|
|
22
23
|
maxBarcodes: 1000,
|
|
23
24
|
maxDownloadBarcodes: 1000,
|
|
24
|
-
maxCustomers:
|
|
25
|
+
maxCustomers: 100,
|
|
25
26
|
},
|
|
26
27
|
small: {
|
|
27
|
-
maxBarcodes:
|
|
28
|
-
maxDownloadBarcodes:
|
|
29
|
-
maxCustomers:
|
|
28
|
+
maxBarcodes: 50000,
|
|
29
|
+
maxDownloadBarcodes: 2500,
|
|
30
|
+
maxCustomers: 5000,
|
|
30
31
|
},
|
|
31
32
|
medium: {
|
|
32
33
|
maxBarcodes: 100000,
|
|
33
34
|
maxDownloadBarcodes: 5000,
|
|
34
|
-
maxCustomers:
|
|
35
|
+
maxCustomers: 7500,
|
|
35
36
|
},
|
|
36
37
|
large: {
|
|
37
38
|
maxBarcodes: 250000,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { MarkedSkuI } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Find a sku by 12 or 13 digit barcode.
|
|
6
|
+
* 12-digit US UPC barcodes can be shorthand for a 13-digit barcodes in the DB
|
|
7
|
+
* According to the UPC/EAN standard, US barcodes can omit the first 0 when printed
|
|
8
|
+
*/
|
|
9
|
+
export default function (barcodeToFind: string, skus: { [barcode: string]: MarkedSkuI }): MarkedSkuI | null {
|
|
10
|
+
if (skus[barcodeToFind]) return skus[barcodeToFind]
|
|
11
|
+
if (barcodeToFind.length == 13 && barcodeToFind.substring(0, 1) == '2') {
|
|
12
|
+
// This is an internally generated barcode.
|
|
13
|
+
// We have some weird errors from the past where incorrect barcodes were generated (wrong check digit.)
|
|
14
|
+
// When these barcodes were printed in our legacy software, noone noticed. Now, when LC prints these barcodes, the printer
|
|
15
|
+
// corrects the check digit. This results in a scan of a barcode that does not appear in the DB.
|
|
16
|
+
// However, we know which barcode we need because we can ignore the check digit.
|
|
17
|
+
const prefix = barcodeToFind.substring(0, 12)
|
|
18
|
+
if (skus[prefix + '0']) return skus[prefix + '0']
|
|
19
|
+
if (skus[prefix + '1']) return skus[prefix + '1']
|
|
20
|
+
if (skus[prefix + '2']) return skus[prefix + '2']
|
|
21
|
+
if (skus[prefix + '3']) return skus[prefix + '3']
|
|
22
|
+
if (skus[prefix + '4']) return skus[prefix + '4']
|
|
23
|
+
if (skus[prefix + '5']) return skus[prefix + '5']
|
|
24
|
+
if (skus[prefix + '6']) return skus[prefix + '6']
|
|
25
|
+
if (skus[prefix + '7']) return skus[prefix + '7']
|
|
26
|
+
if (skus[prefix + '8']) return skus[prefix + '8']
|
|
27
|
+
if (skus[prefix + '9']) return skus[prefix + '9']
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (barcodeToFind.length != 12) return null
|
|
31
|
+
const barcode13 = '0' + barcodeToFind
|
|
32
|
+
if (skus[barcode13]) return skus[barcode13]
|
|
33
|
+
return null
|
|
34
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -6,5 +6,6 @@ export { default as getPreferedPropertyMappings } from './getPreferedPropertyMap
|
|
|
6
6
|
export { default as hashBrand } from './hashBrand'
|
|
7
7
|
export { default as hasOnlyDigits } from './hasOnlyDigits'
|
|
8
8
|
export { default as sizeToMap } from './sizeToMap'
|
|
9
|
+
export { default as findSkuByBarcode } from './findSkuByBarcode'
|
|
9
10
|
export * from './types'
|
|
10
11
|
export * from './consts'
|
package/src/types.ts
CHANGED
package/test/ean13.spec.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
const { ean13 } = require(
|
|
2
|
-
const { expect } = require(
|
|
1
|
+
const { ean13 } = require('../dist/index')
|
|
2
|
+
const { expect } = require('chai')
|
|
3
3
|
|
|
4
|
-
const should = require(
|
|
4
|
+
const should = require('chai').should()
|
|
5
5
|
|
|
6
|
-
describe(
|
|
7
|
-
it(
|
|
6
|
+
describe('ean13 function', function () {
|
|
7
|
+
it('should fail validation for anything shorter than 12 digits', function () {
|
|
8
8
|
should.throw(() => {
|
|
9
|
-
ean13(
|
|
9
|
+
ean13('123')
|
|
10
10
|
})
|
|
11
11
|
})
|
|
12
|
-
it(
|
|
13
|
-
expect(ean13(
|
|
12
|
+
it('should calculate a valid check digit', function () {
|
|
13
|
+
expect(ean13('123456789012')).to.equal(1234567890128)
|
|
14
|
+
expect(ean13('201480005032')).to.equal(2014800050323)
|
|
15
|
+
expect(ean13('201480000006')).to.equal(2014800000069)
|
|
14
16
|
})
|
|
15
17
|
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const { findSkuByBarcode } = require('../dist/index')
|
|
2
|
+
const { expect } = require('chai')
|
|
3
|
+
|
|
4
|
+
describe('findSkuByBarcode function', function () {
|
|
5
|
+
it('should return null for any barcode shorter than 12 digits', function () {
|
|
6
|
+
expect(findSkuByBarcode('12345678901', {})).to.equal(null)
|
|
7
|
+
})
|
|
8
|
+
it('should return the sku at the first check if exist', function () {
|
|
9
|
+
expect(findSkuByBarcode('1234567890123', { 1234567890123: { id: '1234567890123' } })).to.deep.equal({ id: '1234567890123' })
|
|
10
|
+
})
|
|
11
|
+
it('should return the sku at the second check if exist, 13 digits, begins with 2', function () {
|
|
12
|
+
expect(findSkuByBarcode('2234567890123', { 2234567890127: { id: '2234567890127' } })).to.deep.equal({ id: '2234567890127' })
|
|
13
|
+
})
|
|
14
|
+
it('should return null because the sku doesn not exist', function () {
|
|
15
|
+
expect(findSkuByBarcode('2234567890123', {})).to.equal(null)
|
|
16
|
+
})
|
|
17
|
+
it('should return the sku at the third check if exist, 12 digits', function () {
|
|
18
|
+
expect(findSkuByBarcode('123456789012', { '0123456789012': { id: '0123456789012' } })).to.deep.equal({ id: '0123456789012' })
|
|
19
|
+
})
|
|
20
|
+
it('should return the null because the sku does not exist, 12 digits', function () {
|
|
21
|
+
expect(findSkuByBarcode('123456789012', {})).to.deep.equal(null)
|
|
22
|
+
})
|
|
23
|
+
})
|
|
@@ -14,4 +14,7 @@ describe('sizeToMap function', function () {
|
|
|
14
14
|
it('should return the input as uppercase', function () {
|
|
15
15
|
expect(sizeToMap('xxl')).to.equal('XXL')
|
|
16
16
|
})
|
|
17
|
+
it('should return input when no change needed', function () {
|
|
18
|
+
expect(sizeToMap('33/34')).to.equal('33/34')
|
|
19
|
+
})
|
|
17
20
|
})
|