@aidc-toolkit/gs1 1.0.22-beta → 1.0.24-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/dist/index.cjs +4624 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1588 -0
- package/dist/index.d.ts +1588 -36
- package/dist/index.js +4541 -19
- package/dist/index.js.map +1 -1
- package/package.json +4 -8
- package/src/character-set.ts +16 -1
- package/src/check.ts +2 -2
- package/src/gtin-creator.ts +4 -4
- package/src/gtin-validator.ts +6 -6
- package/src/identifier-creator.ts +3 -3
- package/src/identifier-validator.ts +4 -4
- package/src/index.ts +19 -19
- package/src/locale/en/{locale-strings.ts → locale-resources.ts} +1 -1
- package/src/locale/fr/{locale-strings.ts → locale-resources.ts} +2 -2
- package/src/locale/i18n.ts +6 -8
- package/src/locale/i18next.d.ts +4 -4
- package/src/non-gtin-numeric-identifier-creator.ts +4 -4
- package/src/non-gtin-numeric-identifier-validator.ts +3 -3
- package/src/non-numeric-identifier-creator.ts +6 -6
- package/src/non-numeric-identifier-validator.ts +6 -6
- package/src/numeric-identifier-creator.ts +3 -3
- package/src/numeric-identifier-validator.ts +5 -5
- package/src/prefix-manager.ts +36 -35
- package/src/prefix-provider.ts +1 -1
- package/src/prefix-validator.ts +2 -2
- package/src/serializable-numeric-identifier-creator.ts +4 -4
- package/src/serializable-numeric-identifier-validator.ts +5 -5
- package/test/creator.test.ts +3 -3
- package/test/gtin-creator.ts +1 -1
- package/test/gtin-validator.test.ts +1 -1
- package/test/identifier-creator.ts +4 -4
- package/test/non-gtin-numeric-identifier-creator.ts +1 -1
- package/test/non-gtin-numeric-identifier-validator.ts +1 -1
- package/test/non-numeric-identifier-validator.ts +2 -2
- package/test/numeric-identifier-creator.ts +1 -1
- package/test/numeric-identifier-validator.ts +1 -1
- package/test/prefix-manager.test.ts +1 -1
- package/test/serializable-numeric-identifier-creator.ts +1 -1
- package/test/serializable-numeric-identifier-validator.ts +2 -2
- package/test/validator.test.ts +4 -4
- package/tsup.config.ts +3 -0
- package/typedoc.json +1 -3
- package/dist/character-set.d.ts +0 -22
- package/dist/character-set.d.ts.map +0 -1
- package/dist/character-set.js +0 -36
- package/dist/character-set.js.map +0 -1
- package/dist/check.d.ts +0 -81
- package/dist/check.d.ts.map +0 -1
- package/dist/check.js +0 -218
- package/dist/check.js.map +0 -1
- package/dist/gtin-creator.d.ts +0 -68
- package/dist/gtin-creator.d.ts.map +0 -1
- package/dist/gtin-creator.js +0 -158
- package/dist/gtin-creator.js.map +0 -1
- package/dist/gtin-validator.d.ts +0 -202
- package/dist/gtin-validator.d.ts.map +0 -1
- package/dist/gtin-validator.js +0 -470
- package/dist/gtin-validator.js.map +0 -1
- package/dist/identifier-creator.d.ts +0 -72
- package/dist/identifier-creator.d.ts.map +0 -1
- package/dist/identifier-creator.js +0 -50
- package/dist/identifier-creator.js.map +0 -1
- package/dist/identifier-type.d.ts +0 -58
- package/dist/identifier-type.d.ts.map +0 -1
- package/dist/identifier-type.js +0 -54
- package/dist/identifier-type.js.map +0 -1
- package/dist/identifier-validator.d.ts +0 -174
- package/dist/identifier-validator.d.ts.map +0 -1
- package/dist/identifier-validator.js +0 -145
- package/dist/identifier-validator.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.d.ts +0 -42
- package/dist/locale/en/locale-strings.d.ts.map +0 -1
- package/dist/locale/en/locale-strings.js +0 -42
- package/dist/locale/en/locale-strings.js.map +0 -1
- package/dist/locale/fr/locale-strings.d.ts +0 -42
- package/dist/locale/fr/locale-strings.d.ts.map +0 -1
- package/dist/locale/fr/locale-strings.js +0 -42
- package/dist/locale/fr/locale-strings.js.map +0 -1
- package/dist/locale/i18n.d.ts +0 -27
- package/dist/locale/i18n.d.ts.map +0 -1
- package/dist/locale/i18n.js +0 -37
- package/dist/locale/i18n.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-creator.js +0 -30
- package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-gtin-numeric-identifier-validator.js +0 -40
- package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
- package/dist/non-numeric-identifier-creator.d.ts +0 -55
- package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-creator.js +0 -93
- package/dist/non-numeric-identifier-creator.js.map +0 -1
- package/dist/non-numeric-identifier-validator.d.ts +0 -78
- package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/non-numeric-identifier-validator.js +0 -95
- package/dist/non-numeric-identifier-validator.js.map +0 -1
- package/dist/numeric-identifier-creator.d.ts +0 -121
- package/dist/numeric-identifier-creator.d.ts.map +0 -1
- package/dist/numeric-identifier-creator.js +0 -135
- package/dist/numeric-identifier-creator.js.map +0 -1
- package/dist/numeric-identifier-validator.d.ts +0 -76
- package/dist/numeric-identifier-validator.d.ts.map +0 -1
- package/dist/numeric-identifier-validator.js +0 -84
- package/dist/numeric-identifier-validator.js.map +0 -1
- package/dist/prefix-manager.d.ts +0 -224
- package/dist/prefix-manager.d.ts.map +0 -1
- package/dist/prefix-manager.js +0 -369
- package/dist/prefix-manager.js.map +0 -1
- package/dist/prefix-provider.d.ts +0 -27
- package/dist/prefix-provider.d.ts.map +0 -1
- package/dist/prefix-provider.js +0 -2
- package/dist/prefix-provider.js.map +0 -1
- package/dist/prefix-type.d.ts +0 -22
- package/dist/prefix-type.d.ts.map +0 -1
- package/dist/prefix-type.js +0 -18
- package/dist/prefix-type.js.map +0 -1
- package/dist/prefix-validator.d.ts +0 -58
- package/dist/prefix-validator.d.ts.map +0 -1
- package/dist/prefix-validator.js +0 -154
- package/dist/prefix-validator.js.map +0 -1
- package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
- package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-creator.js +0 -116
- package/dist/serializable-numeric-identifier-creator.js.map +0 -1
- package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
- package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
- package/dist/serializable-numeric-identifier-validator.js +0 -99
- package/dist/serializable-numeric-identifier-validator.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CharacterSetCreator, Sequence } from "@aidc-toolkit/utility";
|
|
2
2
|
import { describe, expect, test } from "vitest";
|
|
3
3
|
import { hasValidCheckDigit, IdentifierTypes, LeaderTypes, type NumericIdentifierCreator } from "../src";
|
|
4
|
-
import { testIdentifierCreatorCallback } from "./identifier-creator
|
|
4
|
+
import { testIdentifierCreatorCallback } from "./identifier-creator";
|
|
5
5
|
|
|
6
6
|
export function testNumericIdentifierCreator(creator: NumericIdentifierCreator, preTestCallback?: () => void, postTestCallback?: () => void): void {
|
|
7
7
|
describe(creator.identifierType === IdentifierTypes.GTIN ? `${creator.identifierType}-${creator.length}` : creator.identifierType, () => {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type NumericIdentifierValidator,
|
|
9
9
|
type PrefixType
|
|
10
10
|
} from "../src";
|
|
11
|
-
import { validateIdentifierValidator } from "./identifier-validator
|
|
11
|
+
import { validateIdentifierValidator } from "./identifier-validator";
|
|
12
12
|
|
|
13
13
|
export function validateNumericIdentifierValidator(validator: NumericIdentifierValidator, isCreator: boolean, identifierType: IdentifierType, prefixType: PrefixType, length: number, leaderType: LeaderType): void {
|
|
14
14
|
validateIdentifierValidator(validator, identifierType, prefixType, length);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
2
|
import { PrefixManager, PrefixTypes } from "../src";
|
|
3
|
-
import { validateIdentifierCreators } from "./identifier-creator
|
|
3
|
+
import { validateIdentifierCreators } from "./identifier-creator";
|
|
4
4
|
|
|
5
5
|
describe("Prefix manager", () => {
|
|
6
6
|
let prefixManager: PrefixManager;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expect, test } from "vitest";
|
|
2
2
|
import { ContentCharacterSets, type SerializableNumericIdentifierCreator } from "../src";
|
|
3
|
-
import { testNonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator
|
|
3
|
+
import { testNonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator";
|
|
4
4
|
|
|
5
5
|
export function testSerializableNumericIdentifierCreator(creator: SerializableNumericIdentifierCreator): void {
|
|
6
6
|
testNonGTINNumericIdentifierCreator(creator, undefined, () => {
|
|
@@ -6,8 +6,8 @@ import type {
|
|
|
6
6
|
SerializableNumericIdentifierCreator,
|
|
7
7
|
SerializableNumericIdentifierValidator
|
|
8
8
|
} from "../src";
|
|
9
|
-
import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator
|
|
10
|
-
import { creatorFor } from "./utility
|
|
9
|
+
import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator";
|
|
10
|
+
import { creatorFor } from "./utility";
|
|
11
11
|
|
|
12
12
|
export function validateSerializableNumericIdentifierValidator(validator: SerializableNumericIdentifierValidator, isCreator: boolean, identifierType: IdentifierType, length: number, leaderType: LeaderType, serialLength: number, serialCharacterSet: ContentCharacterSet): void {
|
|
13
13
|
validateNonGTINNumericIdentifierValidator(validator, isCreator, identifierType, length, leaderType);
|
package/test/validator.test.ts
CHANGED
|
@@ -21,10 +21,10 @@ import {
|
|
|
21
21
|
PrefixTypes,
|
|
22
22
|
SSCC_VALIDATOR
|
|
23
23
|
} from "../src";
|
|
24
|
-
import { validateGTINValidator } from "./gtin-validator.test
|
|
25
|
-
import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator
|
|
26
|
-
import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator
|
|
27
|
-
import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator
|
|
24
|
+
import { validateGTINValidator } from "./gtin-validator.test";
|
|
25
|
+
import { validateNonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator";
|
|
26
|
+
import { validateNonNumericIdentifierValidator } from "./non-numeric-identifier-validator";
|
|
27
|
+
import { validateSerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator";
|
|
28
28
|
|
|
29
29
|
describe("Validators", () => {
|
|
30
30
|
test("GTIN", () => {
|
package/tsup.config.ts
ADDED
package/typedoc.json
CHANGED
package/dist/character-set.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { CharacterSetCreator, type CharacterSetValidator } from "@aidc-toolkit/utility";
|
|
2
|
-
/**
|
|
3
|
-
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
4
|
-
* General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
5
|
-
*/
|
|
6
|
-
export declare const AI82_CREATOR: CharacterSetCreator;
|
|
7
|
-
/**
|
|
8
|
-
* GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
|
|
9
|
-
* GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
10
|
-
*/
|
|
11
|
-
export declare const AI82_VALIDATOR: CharacterSetValidator;
|
|
12
|
-
/**
|
|
13
|
-
* GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
14
|
-
* General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
15
|
-
*/
|
|
16
|
-
export declare const AI39_CREATOR: CharacterSetCreator;
|
|
17
|
-
/**
|
|
18
|
-
* GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
|
|
19
|
-
* GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
20
|
-
*/
|
|
21
|
-
export declare const AI39_VALIDATOR: CharacterSetValidator;
|
|
22
|
-
//# sourceMappingURL=character-set.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,qBAAqB,EAAc,MAAM,uBAAuB,CAAC;AAEpG;;;GAGG;AACH,eAAO,MAAM,YAAY,qBASA,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,YAAY,qBAKA,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAmB,qBAAqB,CAAC"}
|
package/dist/character-set.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CharacterSetCreator, Exclusions } from "@aidc-toolkit/utility";
|
|
2
|
-
/**
|
|
3
|
-
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
4
|
-
* General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
5
|
-
*/
|
|
6
|
-
export const AI82_CREATOR = new CharacterSetCreator([
|
|
7
|
-
"!", "\"", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
|
|
8
|
-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
9
|
-
":", ";", "<", "=", ">", "?",
|
|
10
|
-
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
11
|
-
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
12
|
-
"_",
|
|
13
|
-
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
|
14
|
-
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
|
15
|
-
], Exclusions.AllNumeric);
|
|
16
|
-
/**
|
|
17
|
-
* GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
|
|
18
|
-
* GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
19
|
-
*/
|
|
20
|
-
export const AI82_VALIDATOR = AI82_CREATOR;
|
|
21
|
-
/**
|
|
22
|
-
* GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs | GS1
|
|
23
|
-
* General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
24
|
-
*/
|
|
25
|
-
export const AI39_CREATOR = new CharacterSetCreator([
|
|
26
|
-
"#", "-", "/",
|
|
27
|
-
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
28
|
-
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
29
|
-
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
30
|
-
], Exclusions.AllNumeric);
|
|
31
|
-
/**
|
|
32
|
-
* GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link https://www.gs1.org/genspecs |
|
|
33
|
-
* GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
34
|
-
*/
|
|
35
|
-
export const AI39_VALIDATOR = AI39_CREATOR;
|
|
36
|
-
//# sourceMappingURL=character-set.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"character-set.js","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA8B,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEpG;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,mBAAmB,CAAC;IAChD,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAChE,GAAG,EAAE,G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AAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC/D,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;CAClE,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;AAE1B;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,YAAqC,CAAC"}
|
package/dist/check.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calculate the check digit sum for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs |
|
|
3
|
-
* GS1 General Specifications}.
|
|
4
|
-
*
|
|
5
|
-
* @param exchangeWeights
|
|
6
|
-
* If true, start the weights at 1 instead of 3 on the right.
|
|
7
|
-
*
|
|
8
|
-
* @param s
|
|
9
|
-
* Numeric string.
|
|
10
|
-
*
|
|
11
|
-
* @returns
|
|
12
|
-
* Accumulated sum of each digit multiplied by the weight at its position.
|
|
13
|
-
*/
|
|
14
|
-
export declare function checkDigitSum(exchangeWeights: boolean, s: string): number;
|
|
15
|
-
/**
|
|
16
|
-
* Calculate the check digit for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs | GS1
|
|
17
|
-
* General Specifications}.
|
|
18
|
-
*
|
|
19
|
-
* @param s
|
|
20
|
-
* Numeric string.
|
|
21
|
-
*
|
|
22
|
-
* @returns
|
|
23
|
-
* Check digit 0-9 as a string.
|
|
24
|
-
*/
|
|
25
|
-
export declare function checkDigit(s: string): string;
|
|
26
|
-
/**
|
|
27
|
-
* Determine if a numeric string has a valid check digit.
|
|
28
|
-
*
|
|
29
|
-
* @param s
|
|
30
|
-
* Numeric string with check digit.
|
|
31
|
-
*
|
|
32
|
-
* @returns
|
|
33
|
-
* True if the check digit is valid.
|
|
34
|
-
*/
|
|
35
|
-
export declare function hasValidCheckDigit(s: string): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Calculate the price or weight check digit for a four-or five-digit numeric string as per section 7.9.3 of the {@link
|
|
38
|
-
* https://www.gs1.org/genspecs | GS1 General Specifications}.
|
|
39
|
-
*
|
|
40
|
-
* @param s
|
|
41
|
-
* Numeric string exactly four or five characters long.
|
|
42
|
-
*
|
|
43
|
-
* @returns
|
|
44
|
-
* Check digit 0-9 as a string.
|
|
45
|
-
*/
|
|
46
|
-
export declare function priceOrWeightCheckDigit(s: string): string;
|
|
47
|
-
/**
|
|
48
|
-
* Determine if a price or weight check digit is valid for numeric string.
|
|
49
|
-
*
|
|
50
|
-
* @param s
|
|
51
|
-
* Numeric string exactly four or five characters long.
|
|
52
|
-
*
|
|
53
|
-
* @param checkDigit
|
|
54
|
-
* Price or weight check digit.
|
|
55
|
-
*
|
|
56
|
-
* @returns
|
|
57
|
-
* True if the check digit is valid.
|
|
58
|
-
*/
|
|
59
|
-
export declare function isValidPriceOrWeightCheckDigit(s: string, checkDigit: string): boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Calculate the check character for a GS1 AI encodable character set 82 string as per section 7.9.5 of the {@link
|
|
62
|
-
* https://www.gs1.org/genspecs | GS1 General Specifications}.
|
|
63
|
-
*
|
|
64
|
-
* @param s
|
|
65
|
-
* GS1 AI encodable character set 82 string.
|
|
66
|
-
*
|
|
67
|
-
* @returns
|
|
68
|
-
* Check character pair.
|
|
69
|
-
*/
|
|
70
|
-
export declare function checkCharacterPair(s: string): string;
|
|
71
|
-
/**
|
|
72
|
-
* Determine if a GS1 AI encodable character set 82 string has a valid check character pair.
|
|
73
|
-
*
|
|
74
|
-
* @param s
|
|
75
|
-
* GS1 AI encodable character set 82 string with check character pair.
|
|
76
|
-
*
|
|
77
|
-
* @returns
|
|
78
|
-
* True if the check character pair is valid.
|
|
79
|
-
*/
|
|
80
|
-
export declare function hasValidCheckCharacterPair(s: string): boolean;
|
|
81
|
-
//# sourceMappingURL=check.d.ts.map
|
package/dist/check.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,eAAe,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAkBzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAGrD;AA+BD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAmBzD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAErF;AAiBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CA4BpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAI7D"}
|
package/dist/check.js
DELETED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
import { NUMERIC_CREATOR, utilityNS } from "@aidc-toolkit/utility";
|
|
2
|
-
import { AI82_CREATOR } from "./character-set.js";
|
|
3
|
-
import { i18nextGS1 } from "./locale/i18n.js";
|
|
4
|
-
/**
|
|
5
|
-
* Results of multiplying digits by 3.
|
|
6
|
-
*/
|
|
7
|
-
const THREE_WEIGHT_RESULTS = [
|
|
8
|
-
0, 3, 6, 9, 12, 15, 18, 21, 24, 27
|
|
9
|
-
];
|
|
10
|
-
/**
|
|
11
|
-
* Results of multiplying digits by 2, subtracting tens digit, and extracting units digit.
|
|
12
|
-
*/
|
|
13
|
-
const TWO_MINUS_WEIGHT_RESULTS = [
|
|
14
|
-
0, 2, 4, 6, 8, 9, 1, 3, 5, 7
|
|
15
|
-
];
|
|
16
|
-
/**
|
|
17
|
-
* Results of multiplying digits by 5, adding tens digit, and extracting units digit.
|
|
18
|
-
*/
|
|
19
|
-
const FIVE_PLUS_WEIGHT_RESULTS = [
|
|
20
|
-
0, 5, 1, 6, 2, 7, 3, 8, 4, 9
|
|
21
|
-
];
|
|
22
|
-
/**
|
|
23
|
-
* Results of multiplying digits by 5, subtracting tens digit, and extracting units digit.
|
|
24
|
-
*/
|
|
25
|
-
const FIVE_MINUS_WEIGHT_RESULTS = [
|
|
26
|
-
0, 5, 9, 4, 8, 3, 7, 2, 6, 1
|
|
27
|
-
];
|
|
28
|
-
/**
|
|
29
|
-
* Inverse mapping of FIVE_MINUS_WEIGHT_RESULTS.
|
|
30
|
-
*/
|
|
31
|
-
const INVERSE_FIVE_MINUS_WEIGHT_RESULTS = [
|
|
32
|
-
0, 9, 7, 5, 3, 1, 8, 6, 4, 2
|
|
33
|
-
];
|
|
34
|
-
/**
|
|
35
|
-
* Calculate the check digit sum for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs |
|
|
36
|
-
* GS1 General Specifications}.
|
|
37
|
-
*
|
|
38
|
-
* @param exchangeWeights
|
|
39
|
-
* If true, start the weights at 1 instead of 3 on the right.
|
|
40
|
-
*
|
|
41
|
-
* @param s
|
|
42
|
-
* Numeric string.
|
|
43
|
-
*
|
|
44
|
-
* @returns
|
|
45
|
-
* Accumulated sum of each digit multiplied by the weight at its position.
|
|
46
|
-
*/
|
|
47
|
-
export function checkDigitSum(exchangeWeights, s) {
|
|
48
|
-
// Initial setting will be the opposite of that used for first character because it gets flipped before being used.
|
|
49
|
-
let weight3 = (s.length + Number(exchangeWeights)) % 2 === 0;
|
|
50
|
-
// Calculate sum of each character value multiplied by the weight at its position.
|
|
51
|
-
return NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
52
|
-
if (characterIndex === undefined) {
|
|
53
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
54
|
-
ns: utilityNS,
|
|
55
|
-
c: s.charAt(index),
|
|
56
|
-
position: index + 1
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
weight3 = !weight3;
|
|
60
|
-
return accumulator + (weight3 ? THREE_WEIGHT_RESULTS[characterIndex] : characterIndex);
|
|
61
|
-
}, 0);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Calculate the check digit for a numeric string as per section 7.9.1 of the {@link https://www.gs1.org/genspecs | GS1
|
|
65
|
-
* General Specifications}.
|
|
66
|
-
*
|
|
67
|
-
* @param s
|
|
68
|
-
* Numeric string.
|
|
69
|
-
*
|
|
70
|
-
* @returns
|
|
71
|
-
* Check digit 0-9 as a string.
|
|
72
|
-
*/
|
|
73
|
-
export function checkDigit(s) {
|
|
74
|
-
// Check digit is the difference from the equal or next of multiple of 10.
|
|
75
|
-
return NUMERIC_CREATOR.character(9 - (checkDigitSum(false, s) + 9) % 10);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Determine if a numeric string has a valid check digit.
|
|
79
|
-
*
|
|
80
|
-
* @param s
|
|
81
|
-
* Numeric string with check digit.
|
|
82
|
-
*
|
|
83
|
-
* @returns
|
|
84
|
-
* True if the check digit is valid.
|
|
85
|
-
*/
|
|
86
|
-
export function hasValidCheckDigit(s) {
|
|
87
|
-
// Check digit is valid if the check digit sum with the weights exchanged is a multiple of 10.
|
|
88
|
-
return checkDigitSum(true, s) % 10 === 0;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Calculate the price or weight sum for a numeric string.
|
|
92
|
-
*
|
|
93
|
-
* @param weightsResults
|
|
94
|
-
* Array of weight results arrays to apply to each digit.
|
|
95
|
-
*
|
|
96
|
-
* @param s
|
|
97
|
-
* Numeric string the same length as the weightsResults array.
|
|
98
|
-
*
|
|
99
|
-
* @returns
|
|
100
|
-
* Accumulated sum of the weight result for each digit at the digit's position.
|
|
101
|
-
*/
|
|
102
|
-
function priceOrWeightSum(weightsResults, s) {
|
|
103
|
-
// Calculate sum of each weight result for each digit at its position.
|
|
104
|
-
return NUMERIC_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
105
|
-
if (characterIndex === undefined) {
|
|
106
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPositionOfComponent", {
|
|
107
|
-
ns: utilityNS,
|
|
108
|
-
c: s.charAt(index),
|
|
109
|
-
position: index + 1,
|
|
110
|
-
component: i18nextGS1.t("Check.priceOrWeightComponent")
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
// Add the weight result of the character index to the accumulator.
|
|
114
|
-
return accumulator + weightsResults[index][characterIndex];
|
|
115
|
-
}, 0);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Calculate the price or weight check digit for a four-or five-digit numeric string as per section 7.9.3 of the {@link
|
|
119
|
-
* https://www.gs1.org/genspecs | GS1 General Specifications}.
|
|
120
|
-
*
|
|
121
|
-
* @param s
|
|
122
|
-
* Numeric string exactly four or five characters long.
|
|
123
|
-
*
|
|
124
|
-
* @returns
|
|
125
|
-
* Check digit 0-9 as a string.
|
|
126
|
-
*/
|
|
127
|
-
export function priceOrWeightCheckDigit(s) {
|
|
128
|
-
let checkDigit;
|
|
129
|
-
switch (s.length) {
|
|
130
|
-
case 4:
|
|
131
|
-
checkDigit = NUMERIC_CREATOR.character(priceOrWeightSum([TWO_MINUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, THREE_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS], s) * 3 % 10);
|
|
132
|
-
break;
|
|
133
|
-
case 5:
|
|
134
|
-
checkDigit = NUMERIC_CREATOR.character(INVERSE_FIVE_MINUS_WEIGHT_RESULTS[9 - (priceOrWeightSum([FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS, FIVE_MINUS_WEIGHT_RESULTS, FIVE_PLUS_WEIGHT_RESULTS, TWO_MINUS_WEIGHT_RESULTS], s) + 9) % 10]);
|
|
135
|
-
break;
|
|
136
|
-
default:
|
|
137
|
-
throw new RangeError(i18nextGS1.t("Check.lengthOfStringForPriceOrWeightMustBeExactly", {
|
|
138
|
-
length: s.length
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
return checkDigit;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Determine if a price or weight check digit is valid for numeric string.
|
|
145
|
-
*
|
|
146
|
-
* @param s
|
|
147
|
-
* Numeric string exactly four or five characters long.
|
|
148
|
-
*
|
|
149
|
-
* @param checkDigit
|
|
150
|
-
* Price or weight check digit.
|
|
151
|
-
*
|
|
152
|
-
* @returns
|
|
153
|
-
* True if the check digit is valid.
|
|
154
|
-
*/
|
|
155
|
-
export function isValidPriceOrWeightCheckDigit(s, checkDigit) {
|
|
156
|
-
return priceOrWeightCheckDigit(s) === checkDigit;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Weights for check character pair calculation.
|
|
160
|
-
*/
|
|
161
|
-
const CHECK_CHARACTER_WEIGHTS = [
|
|
162
|
-
107, 103, 101, 97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2
|
|
163
|
-
];
|
|
164
|
-
/**
|
|
165
|
-
* Characters used to build check character pair.
|
|
166
|
-
*/
|
|
167
|
-
const CHECK_CHARACTERS = [
|
|
168
|
-
"2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H",
|
|
169
|
-
"J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
170
|
-
];
|
|
171
|
-
/**
|
|
172
|
-
* Calculate the check character for a GS1 AI encodable character set 82 string as per section 7.9.5 of the {@link
|
|
173
|
-
* https://www.gs1.org/genspecs | GS1 General Specifications}.
|
|
174
|
-
*
|
|
175
|
-
* @param s
|
|
176
|
-
* GS1 AI encodable character set 82 string.
|
|
177
|
-
*
|
|
178
|
-
* @returns
|
|
179
|
-
* Check character pair.
|
|
180
|
-
*/
|
|
181
|
-
export function checkCharacterPair(s) {
|
|
182
|
-
// Weights are applied from right to left.
|
|
183
|
-
const weightIndexStart = CHECK_CHARACTER_WEIGHTS.length - s.length;
|
|
184
|
-
if (weightIndexStart < 0) {
|
|
185
|
-
throw new RangeError(i18nextGS1.t("Check.lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo", {
|
|
186
|
-
length: s.length,
|
|
187
|
-
maximumLength: CHECK_CHARACTER_WEIGHTS.length
|
|
188
|
-
}));
|
|
189
|
-
}
|
|
190
|
-
// Calculate sum of each character value multiplied by the weight at its position, mod 1021.
|
|
191
|
-
const checkCharacterPairSum = AI82_CREATOR.characterIndexes(s).reduce((accumulator, characterIndex, index) => {
|
|
192
|
-
if (characterIndex === undefined) {
|
|
193
|
-
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
194
|
-
ns: utilityNS,
|
|
195
|
-
c: s.charAt(index),
|
|
196
|
-
position: index + 1
|
|
197
|
-
}));
|
|
198
|
-
}
|
|
199
|
-
return accumulator + characterIndex * CHECK_CHARACTER_WEIGHTS[weightIndexStart + index];
|
|
200
|
-
}, 0) % 1021;
|
|
201
|
-
const checkCharacterPairSumMod32 = checkCharacterPairSum % 32;
|
|
202
|
-
// Check character pair is the concatenation of the character at position sum div 32 and the character at the position sum mod 32.
|
|
203
|
-
return CHECK_CHARACTERS[(checkCharacterPairSum - checkCharacterPairSumMod32) / 32] + CHECK_CHARACTERS[checkCharacterPairSumMod32];
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Determine if a GS1 AI encodable character set 82 string has a valid check character pair.
|
|
207
|
-
*
|
|
208
|
-
* @param s
|
|
209
|
-
* GS1 AI encodable character set 82 string with check character pair.
|
|
210
|
-
*
|
|
211
|
-
* @returns
|
|
212
|
-
* True if the check character pair is valid.
|
|
213
|
-
*/
|
|
214
|
-
export function hasValidCheckCharacterPair(s) {
|
|
215
|
-
const checkCharacterPairIndex = s.length - 2;
|
|
216
|
-
return checkCharacterPair(s.substring(0, checkCharacterPairIndex)) === s.substring(checkCharacterPairIndex);
|
|
217
|
-
}
|
|
218
|
-
//# sourceMappingURL=check.js.map
|
package/dist/check.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,oBAAoB,GAAsB;IAC5C,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;CACrC,CAAC;AAEF;;GAEG;AACH,MAAM,wBAAwB,GAAsB;IAChD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,wBAAwB,GAAsB;IAChD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,yBAAyB,GAAsB;IACjD,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CA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,UAAU,0BAA0B,CAAC,CAAS;IAChD,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAE7C,OAAO,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;AAChH,CAAC"}
|
package/dist/gtin-creator.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { type TransformerInput, type TransformerOutput } from "@aidc-toolkit/utility";
|
|
2
|
-
import { type GTINType, GTINValidator } from "./gtin-validator.js";
|
|
3
|
-
import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
4
|
-
import type { PrefixProvider } from "./prefix-provider";
|
|
5
|
-
declare const GTINCreator_base: import("ts-mixer/dist/types/types.js").Class<any[], GTINValidator & AbstractNumericIdentifierCreator, typeof GTINValidator & typeof AbstractNumericIdentifierCreator>;
|
|
6
|
-
/**
|
|
7
|
-
* GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; no applicable to GTIN-14 type.
|
|
8
|
-
*/
|
|
9
|
-
export declare class GTINCreator extends GTINCreator_base {
|
|
10
|
-
/**
|
|
11
|
-
* Validation parameters for required indicator digit.
|
|
12
|
-
*/
|
|
13
|
-
private static readonly REQUIRED_INDICATOR_DIGIT_VALIDATION;
|
|
14
|
-
/**
|
|
15
|
-
* Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
|
|
16
|
-
* provider type.
|
|
17
|
-
*
|
|
18
|
-
* @param prefixProvider
|
|
19
|
-
* Prefix provider.
|
|
20
|
-
*
|
|
21
|
-
* @param gtinType
|
|
22
|
-
* GTIN type.
|
|
23
|
-
*/
|
|
24
|
-
constructor(prefixProvider: PrefixProvider, gtinType: GTINType);
|
|
25
|
-
/**
|
|
26
|
-
* @inheritDoc
|
|
27
|
-
*/
|
|
28
|
-
get prefix(): string;
|
|
29
|
-
/**
|
|
30
|
-
* Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
|
|
31
|
-
* converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
|
|
32
|
-
*
|
|
33
|
-
* @template TTransformerInput
|
|
34
|
-
* Transformer input type.
|
|
35
|
-
*
|
|
36
|
-
* @param indicatorDigit
|
|
37
|
-
* Indicator digit.
|
|
38
|
-
*
|
|
39
|
-
* @param valueOrValues
|
|
40
|
-
* Numeric value(s).
|
|
41
|
-
*
|
|
42
|
-
* @param sparse
|
|
43
|
-
* If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
44
|
-
*
|
|
45
|
-
* @returns
|
|
46
|
-
* GTIN-14(s).
|
|
47
|
-
*/
|
|
48
|
-
createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
|
|
49
|
-
/**
|
|
50
|
-
* Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode
|
|
51
|
-
* GTINValidator.parseVariableMeasureRCN} for format details.
|
|
52
|
-
*
|
|
53
|
-
* @param format
|
|
54
|
-
* Format.
|
|
55
|
-
*
|
|
56
|
-
* @param itemReference
|
|
57
|
-
* Item reference.
|
|
58
|
-
*
|
|
59
|
-
* @param priceOrWeight
|
|
60
|
-
* Price or weight (whole number only).
|
|
61
|
-
*
|
|
62
|
-
* @returns
|
|
63
|
-
* RCN-12 or RCN-13.
|
|
64
|
-
*/
|
|
65
|
-
static createVariableMeasureRCN(format: string, itemReference: number, priceOrWeight: number): string;
|
|
66
|
-
}
|
|
67
|
-
export {};
|
|
68
|
-
//# sourceMappingURL=gtin-creator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gtin-creator.d.ts","sourceRoot":"","sources":["../src/gtin-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,KAAK,QAAQ,EAAa,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;;AAExD;;GAEG;AACH,qBAAa,WAAY,SAAQ,gBAAsD;IACnF;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mCAAmC,CAIzD;IAEF;;;;;;;;;OASG;gBACS,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ;IAM9D;;OAEG;IACH,IAAa,MAAM,IAAI,MAAM,CAE5B;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,UAAQ,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAUjM;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;CAmGxG"}
|