@aidc-toolkit/gs1 0.9.16-beta → 0.9.17-beta
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/gs1.iml +9 -0
- package/package.json +4 -6
- package/test/check.test.ts +1 -1
- package/test/idkey.test.ts +32 -32
- package/typedoc.json +1 -3
package/gs1.iml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aidc-toolkit/gs1",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.17-beta",
|
|
4
4
|
"description": "GS1 AIDC Toolkit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,22 +19,20 @@
|
|
|
19
19
|
"url": "https://www.linkedin.com/in/kdean"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"update-aidc-toolkit": "npm update @aidc-toolkit/dev @aidc-toolkit/core @aidc-toolkit/utility",
|
|
23
22
|
"lint": "eslint",
|
|
24
23
|
"build:core": "rimraf dist && tsc --project",
|
|
25
24
|
"build:dev": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build-dev.json",
|
|
26
25
|
"build:release": "npm run build:core -- node_modules/@aidc-toolkit/dev/tsconfig-build.json",
|
|
27
26
|
"build:doc": "npm run build:dev",
|
|
28
|
-
"publish-dev": "publish-dev",
|
|
29
27
|
"test": "vitest run"
|
|
30
28
|
},
|
|
31
29
|
"devDependencies": {
|
|
32
|
-
"@aidc-toolkit/dev": "^0.9.
|
|
30
|
+
"@aidc-toolkit/dev": "^0.9.17-beta",
|
|
33
31
|
"vitest": "^3.0.7"
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
|
-
"@aidc-toolkit/core": "^0.9.
|
|
37
|
-
"@aidc-toolkit/utility": "^0.9.
|
|
34
|
+
"@aidc-toolkit/core": "^0.9.17-beta",
|
|
35
|
+
"@aidc-toolkit/utility": "^0.9.17-beta",
|
|
38
36
|
"i18next": "^24.2.2",
|
|
39
37
|
"ts-mixer": "^6.0.4"
|
|
40
38
|
}
|
package/test/check.test.ts
CHANGED
package/test/idkey.test.ts
CHANGED
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
type SerializableNumericIdentificationKeyCreator,
|
|
41
41
|
type SerializableNumericIdentificationKeyValidator,
|
|
42
42
|
SSCC_VALIDATOR
|
|
43
|
-
} from "../src
|
|
43
|
+
} from "../src";
|
|
44
44
|
|
|
45
45
|
await i18nGS1Init(I18NEnvironment.CLI);
|
|
46
46
|
|
|
@@ -427,20 +427,20 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
427
427
|
expect(creator.referenceLength).toBe(referenceLength);
|
|
428
428
|
expect(creator.capacity).toBe(Number(CharacterSetCreator.powerOf10(referenceLength)));
|
|
429
429
|
|
|
430
|
-
const sequenceIterator =
|
|
430
|
+
const sequenceIterator = creator.create(new Sequence(0, referenceCount))[Symbol.iterator]();
|
|
431
431
|
|
|
432
|
-
let
|
|
432
|
+
let index = 0;
|
|
433
433
|
|
|
434
|
-
|
|
434
|
+
for (const identificationKey of creator.createAll()) {
|
|
435
435
|
validate(identificationKey, index, false);
|
|
436
436
|
|
|
437
437
|
expect(Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
438
438
|
expect(sequenceIterator.next().value).toBe(identificationKey);
|
|
439
439
|
|
|
440
|
-
|
|
441
|
-
}
|
|
440
|
+
index++;
|
|
441
|
+
}
|
|
442
442
|
|
|
443
|
-
expect(
|
|
443
|
+
expect(index).toBe(referenceCount);
|
|
444
444
|
expect(sequenceIterator.next().value).toBeUndefined();
|
|
445
445
|
|
|
446
446
|
const randomValues = new Array<number>();
|
|
@@ -464,9 +464,9 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
464
464
|
|
|
465
465
|
const sequenceSet = new Set<string>();
|
|
466
466
|
|
|
467
|
-
let
|
|
467
|
+
let index = 0;
|
|
468
468
|
|
|
469
|
-
|
|
469
|
+
for (const identificationKey of creator.create(new Sequence(0, sparseReferenceCount), true)) {
|
|
470
470
|
validate(identificationKey, index, true);
|
|
471
471
|
|
|
472
472
|
sequential &&= Number((hasExtensionDigit ? identificationKey.charAt(0) : "") + identificationKey.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
@@ -474,11 +474,11 @@ function testNumericIdentificationKeyCreator(creator: NumericIdentificationKeyCr
|
|
|
474
474
|
expect(sequenceSet.has(identificationKey)).toBe(false);
|
|
475
475
|
sequenceSet.add(identificationKey);
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
}
|
|
477
|
+
index++;
|
|
478
|
+
}
|
|
479
479
|
|
|
480
480
|
expect(sequential).toBe(false);
|
|
481
|
-
expect(
|
|
481
|
+
expect(index).toBe(sparseReferenceCount);
|
|
482
482
|
|
|
483
483
|
const randomValues = new Array<number>();
|
|
484
484
|
const identificationKeys = new Array<string>();
|
|
@@ -565,17 +565,17 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
test("GTIN-14 straight", () => {
|
|
568
|
-
let
|
|
568
|
+
let index = 0;
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
for (const gtin of creator.createGTIN14("5", new Sequence(0, referenceCount))) {
|
|
571
571
|
expect(Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd))).toBe(index);
|
|
572
572
|
|
|
573
573
|
validate(gtin, index, false);
|
|
574
574
|
|
|
575
|
-
|
|
576
|
-
}
|
|
575
|
+
index++;
|
|
576
|
+
}
|
|
577
577
|
|
|
578
|
-
expect(
|
|
578
|
+
expect(index).toBe(referenceCount);
|
|
579
579
|
|
|
580
580
|
const randomValues = new Array<number>();
|
|
581
581
|
const identificationKeys = new Array<string>();
|
|
@@ -598,9 +598,9 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
598
598
|
|
|
599
599
|
const sequenceSet = new Set<string>();
|
|
600
600
|
|
|
601
|
-
let
|
|
601
|
+
let index = 0;
|
|
602
602
|
|
|
603
|
-
|
|
603
|
+
for (const gtin of creator.createGTIN14("5", new Sequence(0, sparseReferenceCount), true)) {
|
|
604
604
|
sequential &&= Number(gtin.substring(referenceSubstringStart, referenceSubstringEnd)) === index;
|
|
605
605
|
|
|
606
606
|
validate(gtin, index, true);
|
|
@@ -608,11 +608,11 @@ function testGTINCreator(creator: GTINCreator): void {
|
|
|
608
608
|
expect(sequenceSet.has(gtin)).toBe(false);
|
|
609
609
|
sequenceSet.add(gtin);
|
|
610
610
|
|
|
611
|
-
|
|
612
|
-
}
|
|
611
|
+
index++;
|
|
612
|
+
}
|
|
613
613
|
|
|
614
614
|
expect(sequential).toBe(false);
|
|
615
|
-
expect(
|
|
615
|
+
expect(index).toBe(sparseReferenceCount);
|
|
616
616
|
|
|
617
617
|
const randomValues = new Array<number>();
|
|
618
618
|
const identificationKeys = new Array<string>();
|
|
@@ -943,9 +943,9 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
943
943
|
test("Straight", () => {
|
|
944
944
|
expect(creator.referenceLength).toBe(referenceLength);
|
|
945
945
|
|
|
946
|
-
let
|
|
946
|
+
let index = 0;
|
|
947
947
|
|
|
948
|
-
|
|
948
|
+
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount)))) {
|
|
949
949
|
expect(() => {
|
|
950
950
|
creator.validate(identificationKey);
|
|
951
951
|
}).not.toThrow(RangeError);
|
|
@@ -958,18 +958,18 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
958
958
|
|
|
959
959
|
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, undefined, reference => creator.create(reference)));
|
|
960
960
|
|
|
961
|
-
|
|
962
|
-
}
|
|
961
|
+
index++;
|
|
962
|
+
}
|
|
963
963
|
|
|
964
|
-
expect(
|
|
964
|
+
expect(index).toBe(referenceCount);
|
|
965
965
|
});
|
|
966
966
|
|
|
967
967
|
test("Sparse", () => {
|
|
968
968
|
let sequential = true;
|
|
969
969
|
|
|
970
|
-
let
|
|
970
|
+
let index = 0;
|
|
971
971
|
|
|
972
|
-
|
|
972
|
+
for (const identificationKey of creator.create(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, new Sequence(0, referenceCount), Exclusion.None, 123456n))) {
|
|
973
973
|
expect(() => {
|
|
974
974
|
creator.validate(identificationKey);
|
|
975
975
|
}).not.toThrow(RangeError);
|
|
@@ -984,11 +984,11 @@ function testNonNumericIdentificationKeyCreator(creator: NonNumericIdentificatio
|
|
|
984
984
|
|
|
985
985
|
expect(identificationKey).toBe(creator.referenceCreator.create(TEST_REFERENCE_LENGTH, index, Exclusion.None, 123456n, reference => creator.create(reference)));
|
|
986
986
|
|
|
987
|
-
|
|
988
|
-
}
|
|
987
|
+
index++;
|
|
988
|
+
}
|
|
989
989
|
|
|
990
990
|
expect(sequential).toBe(false);
|
|
991
|
-
expect(
|
|
991
|
+
expect(index).toBe(referenceCount);
|
|
992
992
|
});
|
|
993
993
|
|
|
994
994
|
test("Position offset", () => {
|