@aidc-toolkit/gs1 1.0.24-beta → 1.0.26-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/abstract-identifier-creator.d.ts +75 -0
- package/dist/abstract-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-identifier-creator.js +56 -0
- package/dist/abstract-identifier-creator.js.map +1 -0
- package/dist/abstract-identifier-validator.d.ts +95 -0
- package/dist/abstract-identifier-validator.d.ts.map +1 -0
- package/dist/abstract-identifier-validator.js +123 -0
- package/dist/abstract-identifier-validator.js.map +1 -0
- package/dist/abstract-numeric-identifier-creator.d.ts +92 -0
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-numeric-identifier-creator.js +137 -0
- package/dist/abstract-numeric-identifier-creator.js.map +1 -0
- package/dist/abstract-numeric-identifier-validator.d.ts +35 -0
- package/dist/abstract-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/abstract-numeric-identifier-validator.js +61 -0
- package/dist/abstract-numeric-identifier-validator.js.map +1 -0
- package/dist/character-set.d.ts +27 -0
- package/dist/character-set.d.ts.map +1 -0
- package/dist/character-set.js +50 -0
- package/dist/character-set.js.map +1 -0
- package/dist/check.d.ts +81 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +218 -0
- package/dist/check.js.map +1 -0
- package/dist/content-character-set.d.ts +26 -0
- package/dist/content-character-set.d.ts.map +1 -0
- package/dist/content-character-set.js +18 -0
- package/dist/content-character-set.js.map +1 -0
- package/dist/creators.d.ts +81 -0
- package/dist/creators.d.ts.map +1 -0
- package/dist/creators.js +62 -0
- package/dist/creators.js.map +1 -0
- package/dist/descriptors.d.ts +96 -0
- package/dist/descriptors.d.ts.map +1 -0
- package/dist/descriptors.js +266 -0
- package/dist/descriptors.js.map +1 -0
- package/dist/gtin-creator.d.ts +69 -0
- package/dist/gtin-creator.d.ts.map +1 -0
- package/dist/gtin-creator.js +159 -0
- package/dist/gtin-creator.js.map +1 -0
- package/dist/gtin-descriptor.d.ts +17 -0
- package/dist/gtin-descriptor.d.ts.map +1 -0
- package/dist/gtin-descriptor.js +2 -0
- package/dist/gtin-descriptor.js.map +1 -0
- package/dist/gtin-type.d.ts +39 -0
- package/dist/gtin-type.d.ts.map +1 -0
- package/dist/gtin-type.js +31 -0
- package/dist/gtin-type.js.map +1 -0
- package/dist/gtin-validator.d.ts +191 -0
- package/dist/gtin-validator.d.ts.map +1 -0
- package/dist/gtin-validator.js +450 -0
- package/dist/gtin-validator.js.map +1 -0
- package/dist/identifier-creator.d.ts +31 -0
- package/dist/identifier-creator.d.ts.map +1 -0
- package/dist/identifier-creator.js +2 -0
- package/dist/identifier-creator.js.map +1 -0
- package/dist/identifier-descriptor.d.ts +27 -0
- package/dist/identifier-descriptor.d.ts.map +1 -0
- package/dist/identifier-descriptor.js +2 -0
- package/dist/identifier-descriptor.js.map +1 -0
- package/dist/identifier-type.d.ts +62 -0
- package/dist/identifier-type.d.ts.map +1 -0
- package/dist/identifier-type.js +54 -0
- package/dist/identifier-type.js.map +1 -0
- package/dist/identifier-validator.d.ts +53 -0
- package/dist/identifier-validator.d.ts.map +1 -0
- package/dist/identifier-validator.js +2 -0
- package/dist/identifier-validator.js.map +1 -0
- package/dist/index.d.ts +52 -1588
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -4541
- package/dist/index.js.map +1 -1
- package/dist/locale/en/locale-resources.d.ts +42 -0
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/locale-resources.js +41 -0
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/locale-resources.d.ts +42 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/locale-resources.js +41 -0
- package/dist/locale/fr/locale-resources.js.map +1 -0
- package/dist/locale/i18n.d.ts +27 -0
- package/dist/locale/i18n.d.ts.map +1 -0
- package/dist/locale/i18n.js +36 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts +24 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.js +23 -0
- package/dist/non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts +22 -0
- package/dist/non-gtin-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-descriptor.js +2 -0
- package/dist/non-gtin-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-type.d.ts +7 -0
- package/dist/non-gtin-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-type.js +2 -0
- package/dist/non-gtin-numeric-identifier-type.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts +17 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.js +17 -0
- package/dist/non-gtin-numeric-identifier-validator.js.map +1 -0
- package/dist/non-numeric-identifier-creator.d.ts +45 -0
- package/dist/non-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-creator.js +84 -0
- package/dist/non-numeric-identifier-creator.js.map +1 -0
- package/dist/non-numeric-identifier-descriptor.d.ts +26 -0
- package/dist/non-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-numeric-identifier-descriptor.js +2 -0
- package/dist/non-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-numeric-identifier-type.d.ts +7 -0
- package/dist/non-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-numeric-identifier-type.js +2 -0
- package/dist/non-numeric-identifier-type.js.map +1 -0
- package/dist/non-numeric-identifier-validator.d.ts +49 -0
- package/dist/non-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-validator.js +69 -0
- package/dist/non-numeric-identifier-validator.js.map +1 -0
- package/dist/numeric-identifier-creator.d.ts +53 -0
- package/dist/numeric-identifier-creator.d.ts.map +1 -0
- package/dist/numeric-identifier-creator.js +2 -0
- package/dist/numeric-identifier-creator.js.map +1 -0
- package/dist/numeric-identifier-descriptor.d.ts +21 -0
- package/dist/numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/numeric-identifier-descriptor.js +2 -0
- package/dist/numeric-identifier-descriptor.js.map +1 -0
- package/dist/numeric-identifier-type.d.ts +31 -0
- package/dist/numeric-identifier-type.d.ts.map +1 -0
- package/dist/numeric-identifier-type.js +18 -0
- package/dist/numeric-identifier-type.js.map +1 -0
- package/dist/numeric-identifier-validator.d.ts +24 -0
- package/dist/numeric-identifier-validator.d.ts.map +1 -0
- package/dist/numeric-identifier-validator.js +2 -0
- package/dist/numeric-identifier-validator.js.map +1 -0
- package/dist/prefix-manager.d.ts +232 -0
- package/dist/prefix-manager.d.ts.map +1 -0
- package/dist/prefix-manager.js +334 -0
- package/dist/prefix-manager.js.map +1 -0
- package/dist/prefix-provider.d.ts +27 -0
- package/dist/prefix-provider.d.ts.map +1 -0
- package/dist/prefix-provider.js +2 -0
- package/dist/prefix-provider.js.map +1 -0
- package/dist/prefix-type.d.ts +26 -0
- package/dist/prefix-type.d.ts.map +1 -0
- package/dist/prefix-type.js +18 -0
- package/dist/prefix-type.js.map +1 -0
- package/dist/prefix-validator.d.ts +70 -0
- package/dist/prefix-validator.d.ts.map +1 -0
- package/dist/prefix-validator.js +208 -0
- package/dist/prefix-validator.js.map +1 -0
- package/dist/serializable-numeric-identifier-creator.d.ts +76 -0
- package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-creator.js +107 -0
- package/dist/serializable-numeric-identifier-creator.js.map +1 -0
- package/dist/serializable-numeric-identifier-descriptor.d.ts +26 -0
- package/dist/serializable-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-descriptor.js +2 -0
- package/dist/serializable-numeric-identifier-descriptor.js.map +1 -0
- package/dist/serializable-numeric-identifier-type.d.ts +6 -0
- package/dist/serializable-numeric-identifier-type.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-type.js +2 -0
- package/dist/serializable-numeric-identifier-type.js.map +1 -0
- package/dist/serializable-numeric-identifier-validator.d.ts +56 -0
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-validator.js +77 -0
- package/dist/serializable-numeric-identifier-validator.js.map +1 -0
- package/dist/validators.d.ts +96 -0
- package/dist/validators.d.ts.map +1 -0
- package/dist/validators.js +140 -0
- package/dist/validators.js.map +1 -0
- package/package.json +12 -8
- package/src/abstract-identifier-creator.ts +97 -0
- package/src/abstract-identifier-validator.ts +140 -0
- package/src/abstract-numeric-identifier-creator.ts +168 -0
- package/src/abstract-numeric-identifier-validator.ts +69 -0
- package/src/character-set.ts +10 -10
- package/src/check.ts +9 -9
- package/src/content-character-set.ts +29 -0
- package/src/creators.ts +113 -0
- package/src/descriptors.ts +332 -0
- package/src/gtin-creator.ts +10 -9
- package/src/gtin-descriptor.ts +18 -0
- package/src/gtin-type.ts +50 -0
- package/src/gtin-validator.ts +40 -64
- package/src/identifier-creator.ts +12 -76
- package/src/identifier-descriptor.ts +30 -0
- package/src/identifier-type.ts +6 -1
- package/src/identifier-validator.ts +12 -188
- package/src/index.ts +44 -19
- package/src/locale/en/locale-resources.ts +0 -1
- package/src/locale/fr/locale-resources.ts +0 -1
- package/src/locale/i18n.ts +3 -3
- package/src/locale/i18next.d.ts +1 -1
- package/src/non-gtin-numeric-identifier-creator.ts +7 -13
- package/src/non-gtin-numeric-identifier-descriptor.ts +24 -0
- package/src/non-gtin-numeric-identifier-type.ts +7 -0
- package/src/non-gtin-numeric-identifier-validator.ts +8 -42
- package/src/non-numeric-identifier-creator.ts +9 -19
- package/src/non-numeric-identifier-descriptor.ts +29 -0
- package/src/non-numeric-identifier-type.ts +7 -0
- package/src/non-numeric-identifier-validator.ts +17 -55
- package/src/numeric-identifier-creator.ts +20 -163
- package/src/numeric-identifier-descriptor.ts +23 -0
- package/src/numeric-identifier-type.ts +44 -0
- package/src/numeric-identifier-validator.ts +13 -116
- package/src/prefix-manager.ts +94 -152
- package/src/prefix-provider.ts +3 -3
- package/src/prefix-type.ts +6 -1
- package/src/prefix-validator.ts +143 -81
- package/src/serializable-numeric-identifier-creator.ts +6 -16
- package/src/serializable-numeric-identifier-descriptor.ts +29 -0
- package/src/serializable-numeric-identifier-type.ts +9 -0
- package/src/serializable-numeric-identifier-validator.ts +18 -46
- package/src/validators.ts +203 -0
- package/test/check.test.ts +1 -1
- package/test/creator.test.ts +5 -7
- package/test/gtin-creator.ts +6 -2
- package/test/gtin-validator.test.ts +7 -10
- package/test/identifier-creator.ts +6 -5
- package/test/identifier-validator.ts +2 -2
- package/test/non-gtin-numeric-identifier-creator.ts +9 -93
- package/test/non-gtin-numeric-identifier-validator.ts +3 -3
- package/test/non-numeric-identifier-creator.ts +93 -0
- package/test/non-numeric-identifier-validator.ts +3 -3
- package/test/numeric-identifier-creator.ts +11 -5
- package/test/numeric-identifier-validator.ts +5 -9
- package/test/prefix-manager.test.ts +2 -2
- package/test/serializable-numeric-identifier-creator.ts +11 -3
- package/test/serializable-numeric-identifier-validator.ts +3 -3
- package/test/setup.ts +1 -1
- package/test/sparse.test.ts +1 -1
- package/test/utility.ts +1 -1
- package/test/validator.test.ts +64 -40
- package/test/variable-measure-rcn.test.ts +1 -1
- package/tsconfig-config.json +4 -0
- package/tsconfig-src.json +8 -0
- package/tsconfig-test.json +9 -0
- package/tsconfig.json +12 -1
- package/tsup.config.ts +3 -2
- package/dist/index.cjs +0 -4624
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1588
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Exclusions } from "@aidc-toolkit/utility";
|
|
2
|
+
import { AbstractIdentifierValidator } from "./abstract-identifier-validator.js";
|
|
3
|
+
import type { IdentifierValidation } from "./identifier-validator.js";
|
|
4
|
+
import type { NonNumericIdentifierDescriptor } from "./non-numeric-identifier-descriptor.js";
|
|
5
|
+
import type { NonNumericIdentifierType } from "./non-numeric-identifier-type.js";
|
|
6
|
+
/**
|
|
7
|
+
* Non-numeric identifier validation parameters.
|
|
8
|
+
*/
|
|
9
|
+
export interface NonNumericIdentifierValidation extends IdentifierValidation {
|
|
10
|
+
/**
|
|
11
|
+
* Exclusion support for reference. Prevents non-numeric identifier from being mistaken for numeric identifier.
|
|
12
|
+
*/
|
|
13
|
+
exclusion?: typeof Exclusions.None | typeof Exclusions.AllNumeric | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Non-numeric identifier validator.
|
|
17
|
+
*/
|
|
18
|
+
export declare class NonNumericIdentifierValidator extends AbstractIdentifierValidator<NonNumericIdentifierDescriptor, NonNumericIdentifierValidation> {
|
|
19
|
+
/**
|
|
20
|
+
* Validator to ensure that an identifier (minus check character pair) is not all numeric.
|
|
21
|
+
*/
|
|
22
|
+
private static readonly NOT_ALL_NUMERIC_VALIDATOR;
|
|
23
|
+
/**
|
|
24
|
+
* True if the identifier requires a check character pair.
|
|
25
|
+
*/
|
|
26
|
+
private readonly _requiresCheckCharacterPair;
|
|
27
|
+
/**
|
|
28
|
+
* Constructor.
|
|
29
|
+
*
|
|
30
|
+
* @param identifierType
|
|
31
|
+
* Identifier type.
|
|
32
|
+
*/
|
|
33
|
+
constructor(identifierType: NonNumericIdentifierType);
|
|
34
|
+
/**
|
|
35
|
+
* Determine if the identifier requires a check character pair.
|
|
36
|
+
*/
|
|
37
|
+
get requiresCheckCharacterPair(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Validate a non-numeric identifier and throw an error if validation fails.
|
|
40
|
+
*
|
|
41
|
+
* @param identifier
|
|
42
|
+
* Identifier.
|
|
43
|
+
*
|
|
44
|
+
* @param validation
|
|
45
|
+
* Validation parameters.
|
|
46
|
+
*/
|
|
47
|
+
validate(identifier: string, validation?: NonNumericIdentifierValidation): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=non-numeric-identifier-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-numeric-identifier-validator.d.ts","sourceRoot":"","sources":["../src/non-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAmB,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAGjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAC7F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;IACxE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,UAAU,CAAC,IAAI,GAAG,OAAO,UAAU,CAAC,UAAU,GAAG,SAAS,CAAC;CACjF;AAED;;GAEG;AACH,qBAAa,6BAA8B,SAAQ,2BAA2B,CAAC,8BAA8B,EAAE,8BAA8B,CAAC;IAC1I;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAOzC;IAER;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAU;IAEtD;;;;;OAKG;gBACS,cAAc,EAAE,wBAAwB;IAQpD;;OAEG;IACH,IAAI,0BAA0B,IAAI,OAAO,CAExC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,8BAA8B,GAAG,IAAI;CAmBlF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Exclusions, RegExpValidator } from "@aidc-toolkit/utility";
|
|
2
|
+
import { AbstractIdentifierValidator } from "./abstract-identifier-validator.js";
|
|
3
|
+
import { hasValidCheckCharacterPair } from "./check.js";
|
|
4
|
+
import { IdentifierDescriptors } from "./descriptors.js";
|
|
5
|
+
import { i18nextGS1 } from "./locale/i18n.js";
|
|
6
|
+
/**
|
|
7
|
+
* Non-numeric identifier validator.
|
|
8
|
+
*/
|
|
9
|
+
export class NonNumericIdentifierValidator extends AbstractIdentifierValidator {
|
|
10
|
+
/**
|
|
11
|
+
* Validator to ensure that an identifier (minus check character pair) is not all numeric.
|
|
12
|
+
*/
|
|
13
|
+
static NOT_ALL_NUMERIC_VALIDATOR = new class extends RegExpValidator {
|
|
14
|
+
/**
|
|
15
|
+
* @inheritDoc
|
|
16
|
+
*/
|
|
17
|
+
createErrorMessage(_s) {
|
|
18
|
+
return i18nextGS1.t("Identifier.referenceCantBeAllNumeric");
|
|
19
|
+
}
|
|
20
|
+
}(/\D/);
|
|
21
|
+
/**
|
|
22
|
+
* True if the identifier requires a check character pair.
|
|
23
|
+
*/
|
|
24
|
+
_requiresCheckCharacterPair;
|
|
25
|
+
/**
|
|
26
|
+
* Constructor.
|
|
27
|
+
*
|
|
28
|
+
* @param identifierType
|
|
29
|
+
* Identifier type.
|
|
30
|
+
*/
|
|
31
|
+
constructor(identifierType) {
|
|
32
|
+
const identifierDescriptor = IdentifierDescriptors[identifierType];
|
|
33
|
+
super(identifierDescriptor);
|
|
34
|
+
this._requiresCheckCharacterPair = identifierDescriptor.requiresCheckCharacterPair;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Determine if the identifier requires a check character pair.
|
|
38
|
+
*/
|
|
39
|
+
get requiresCheckCharacterPair() {
|
|
40
|
+
return this._requiresCheckCharacterPair;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate a non-numeric identifier and throw an error if validation fails.
|
|
44
|
+
*
|
|
45
|
+
* @param identifier
|
|
46
|
+
* Identifier.
|
|
47
|
+
*
|
|
48
|
+
* @param validation
|
|
49
|
+
* Validation parameters.
|
|
50
|
+
*/
|
|
51
|
+
validate(identifier, validation) {
|
|
52
|
+
const partialIdentifier = this.requiresCheckCharacterPair ? identifier.substring(0, identifier.length - 2) : identifier;
|
|
53
|
+
super.validatePrefix(partialIdentifier);
|
|
54
|
+
if (!this.requiresCheckCharacterPair) {
|
|
55
|
+
this.referenceCreator.validate(identifier, {
|
|
56
|
+
maximumLength: this.length
|
|
57
|
+
});
|
|
58
|
+
// Validating the check character pair will also validate the characters.
|
|
59
|
+
}
|
|
60
|
+
else if (!hasValidCheckCharacterPair(this.padIdentifier(identifier))) {
|
|
61
|
+
throw new RangeError(i18nextGS1.t("Identifier.invalidCheckCharacterPair"));
|
|
62
|
+
}
|
|
63
|
+
// Check for all-numeric identifier (minus check character pair) if excluded.
|
|
64
|
+
if (validation?.exclusion === Exclusions.AllNumeric) {
|
|
65
|
+
NonNumericIdentifierValidator.NOT_ALL_NUMERIC_VALIDATOR.validate(partialIdentifier);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=non-numeric-identifier-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"non-numeric-identifier-validator.js","sourceRoot":"","sources":["../src/non-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAc9C;;GAEG;AACH,MAAM,OAAO,6BAA8B,SAAQ,2BAA2F;IAC1I;;OAEG;IACK,MAAM,CAAU,yBAAyB,GAAG,IAAI,KAAM,SAAQ,eAAe;QACjF;;WAEG;QACgB,kBAAkB,CAAC,EAAU;YAC5C,OAAO,UAAU,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC;QAChE,CAAC;KACJ,CAAC,IAAI,CAAC,C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
|
2
|
+
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
3
|
+
import type { NumericIdentifierDescriptor } from "./numeric-identifier-descriptor.js";
|
|
4
|
+
import type { NumericIdentifierValidation, NumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
5
|
+
/**
|
|
6
|
+
* Numeric identifier creator. Creates one or many numeric identifiers.
|
|
7
|
+
*
|
|
8
|
+
* @template TNumericIdentifierDescriptor
|
|
9
|
+
* Numeric identifier descriptor type.
|
|
10
|
+
*/
|
|
11
|
+
export interface NumericIdentifierCreator<TNumericIdentifierDescriptor extends NumericIdentifierDescriptor = NumericIdentifierDescriptor> extends NumericIdentifierValidator<TNumericIdentifierDescriptor>, IdentifierCreator<TNumericIdentifierDescriptor, NumericIdentifierValidation> {
|
|
12
|
+
/**
|
|
13
|
+
* Get the capacity (`10**referenceLength`).
|
|
14
|
+
*/
|
|
15
|
+
get capacity(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get the tweak for sparse creation.
|
|
18
|
+
*/
|
|
19
|
+
get tweak(): bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Set the tweak for sparse creation.
|
|
22
|
+
*/
|
|
23
|
+
set tweak(value: bigint);
|
|
24
|
+
/**
|
|
25
|
+
* Create identifier(s) with reference(s) based on numeric value(s). The value(s) is/are converted to references of
|
|
26
|
+
* the appropriate length using the numeric creator.
|
|
27
|
+
*
|
|
28
|
+
* @template TTransformerInput
|
|
29
|
+
* Transformer input type.
|
|
30
|
+
*
|
|
31
|
+
* @param valueOrValues
|
|
32
|
+
* Numeric value(s).
|
|
33
|
+
*
|
|
34
|
+
* @param sparse
|
|
35
|
+
* If true, the value(s) are mapped to a sparse sequence resistant to discovery. Default is false.
|
|
36
|
+
*
|
|
37
|
+
* @returns
|
|
38
|
+
* Identifier(s).
|
|
39
|
+
*/
|
|
40
|
+
create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
|
|
41
|
+
/**
|
|
42
|
+
* Create all identifiers for the prefix from `0` to `capacity - 1`.
|
|
43
|
+
*
|
|
44
|
+
* The implementation creates the strings only as needed using an internal generator function. Although the result
|
|
45
|
+
* is equivalent to calling `creator.create(new Sequence(0, creator.capacity))`, this method is significantly
|
|
46
|
+
* faster.
|
|
47
|
+
*
|
|
48
|
+
* @returns
|
|
49
|
+
* All identifiers for the prefix.
|
|
50
|
+
*/
|
|
51
|
+
createAll: () => Iterable<string>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=numeric-identifier-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACtF,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEjH;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB,CAAC,4BAA4B,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,0BAA0B,CAAC,4BAA4B,CAAC,EAAE,iBAAiB,CAAC,4BAA4B,EAAE,2BAA2B,CAAC;IACpR;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAAC;IAEvB;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAAC;IAEpB;;OAEG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE;IAEzB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,EAAE,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,KAAK,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAE1K;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-creator.js","sourceRoot":"","sources":["../src/numeric-identifier-creator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ContentCharacterSets } from "./content-character-set.js";
|
|
2
|
+
import type { IdentifierDescriptor } from "./identifier-descriptor.js";
|
|
3
|
+
import type { LeaderType, NumericIdentifierType } from "./numeric-identifier-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* Numeric identifier descriptor.
|
|
6
|
+
*/
|
|
7
|
+
export interface NumericIdentifierDescriptor extends IdentifierDescriptor {
|
|
8
|
+
/**
|
|
9
|
+
* @inheritDoc
|
|
10
|
+
*/
|
|
11
|
+
readonly identifierType: NumericIdentifierType;
|
|
12
|
+
/**
|
|
13
|
+
* @inheritDoc
|
|
14
|
+
*/
|
|
15
|
+
readonly referenceCharacterSet: typeof ContentCharacterSets.Numeric;
|
|
16
|
+
/**
|
|
17
|
+
* Leader type.
|
|
18
|
+
*/
|
|
19
|
+
readonly leaderType: LeaderType;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=numeric-identifier-descriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-descriptor.d.ts","sourceRoot":"","sources":["../src/numeric-identifier-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACrE;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC;IAEpE;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-descriptor.js","sourceRoot":"","sources":["../src/numeric-identifier-descriptor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IdentifierTypes } from "./identifier-type.js";
|
|
2
|
+
/**
|
|
3
|
+
* Numeric identifier type.
|
|
4
|
+
*/
|
|
5
|
+
export type NumericIdentifierType = typeof IdentifierTypes.GTIN | typeof IdentifierTypes.GLN | typeof IdentifierTypes.SSCC | typeof IdentifierTypes.GRAI | typeof IdentifierTypes.GSRN | typeof IdentifierTypes.GDTI | typeof IdentifierTypes.GSIN | typeof IdentifierTypes.GCN;
|
|
6
|
+
/**
|
|
7
|
+
* Leader type.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LeaderTypes: {
|
|
10
|
+
/**
|
|
11
|
+
* No leader.
|
|
12
|
+
*/
|
|
13
|
+
readonly None: "None";
|
|
14
|
+
/**
|
|
15
|
+
* Indicator digit (GTIN only).
|
|
16
|
+
*/
|
|
17
|
+
readonly IndicatorDigit: "Indicator digit";
|
|
18
|
+
/**
|
|
19
|
+
* Extension digit (SSCC only).
|
|
20
|
+
*/
|
|
21
|
+
readonly ExtensionDigit: "Extension digit";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Leader type key.
|
|
25
|
+
*/
|
|
26
|
+
export type LeaderTypeKey = keyof typeof LeaderTypes;
|
|
27
|
+
/**
|
|
28
|
+
* Leader type.
|
|
29
|
+
*/
|
|
30
|
+
export type LeaderType = typeof LeaderTypes[LeaderTypeKey];
|
|
31
|
+
//# sourceMappingURL=numeric-identifier-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-type.d.ts","sourceRoot":"","sources":["../src/numeric-identifier-type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,GAAG,GAC1B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,IAAI,GAC3B,OAAO,eAAe,CAAC,GAAG,CAAC;AAE/B;;GAEG;AACH,eAAO,MAAM,WAAW;IACpB;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEG,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,WAAW,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leader type.
|
|
3
|
+
*/
|
|
4
|
+
export const LeaderTypes = {
|
|
5
|
+
/**
|
|
6
|
+
* No leader.
|
|
7
|
+
*/
|
|
8
|
+
None: "None",
|
|
9
|
+
/**
|
|
10
|
+
* Indicator digit (GTIN only).
|
|
11
|
+
*/
|
|
12
|
+
IndicatorDigit: "Indicator digit",
|
|
13
|
+
/**
|
|
14
|
+
* Extension digit (SSCC only).
|
|
15
|
+
*/
|
|
16
|
+
ExtensionDigit: "Extension digit"
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=numeric-identifier-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-type.js","sourceRoot":"","sources":["../src/numeric-identifier-type.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM;IAEZ;;OAEG;IACH,cAAc,EAAE,iBAAiB;IAEjC;;OAEG;IACH,cAAc,EAAE,iBAAiB;CAC3B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
|
|
2
|
+
import type { NumericIdentifierDescriptor } from "./numeric-identifier-descriptor.js";
|
|
3
|
+
/**
|
|
4
|
+
* Numeric identifier validation parameters.
|
|
5
|
+
*/
|
|
6
|
+
export interface NumericIdentifierValidation extends IdentifierValidation {
|
|
7
|
+
/**
|
|
8
|
+
* Position offset within a larger string. Some numeric identifier types have the prefix offset by one.
|
|
9
|
+
*/
|
|
10
|
+
positionOffset?: number | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Numeric identifier validator.
|
|
14
|
+
*
|
|
15
|
+
* @template TNumericIdentifierDescriptor
|
|
16
|
+
* Numeric identifier descriptor type.
|
|
17
|
+
*/
|
|
18
|
+
export interface NumericIdentifierValidator<TNumericIdentifierDescriptor extends NumericIdentifierDescriptor = NumericIdentifierDescriptor> extends IdentifierValidator<TNumericIdentifierDescriptor, NumericIdentifierValidation> {
|
|
19
|
+
/**
|
|
20
|
+
* Get the leader type.
|
|
21
|
+
*/
|
|
22
|
+
get leaderType(): TNumericIdentifierDescriptor["leaderType"];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=numeric-identifier-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-validator.d.ts","sourceRoot":"","sources":["../src/numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACrE;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B,CAAC,4BAA4B,SAAS,2BAA2B,GAAG,2BAA2B,CAAE,SAAQ,mBAAmB,CAAC,4BAA4B,EAAE,2BAA2B,CAAC;IAC9N;;OAEG;IACH,IAAI,UAAU,IAAI,4BAA4B,CAAC,YAAY,CAAC,CAAC;CAChE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric-identifier-validator.js","sourceRoot":"","sources":["../src/numeric-identifier-validator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { GTINCreator } from "./gtin-creator.js";
|
|
2
|
+
import { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
|
|
3
|
+
import { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator.js";
|
|
4
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
5
|
+
import { type PrefixType } from "./prefix-type.js";
|
|
6
|
+
import { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator.js";
|
|
7
|
+
/**
|
|
8
|
+
* Prefix manager. This is the core class for identifier creation.
|
|
9
|
+
*
|
|
10
|
+
* A prefix manager may be constructed for any {@link PrefixType | prefix type}. Construction may be done directly or
|
|
11
|
+
* via the static {@linkcode PrefixManager.get | get()} method, which allows for caching and reuse. As most applications
|
|
12
|
+
* work with a limited number of prefixes for creating identifiers, caching and reuse may be a more efficient option.
|
|
13
|
+
*
|
|
14
|
+
* The prefix type and prefix are normalized before the prefix manager is constructed, so they may not match the input
|
|
15
|
+
* values. For example, the GS1 Company Prefix 0614141 is equivalent to U.P.C. Company Prefix 614141; both result in a
|
|
16
|
+
* prefix manager with prefix type equal to {@linkcode PrefixTypes.UPCCompanyPrefix} and prefix equal to "614141".
|
|
17
|
+
*
|
|
18
|
+
* To support the creation of sparse identifiers, a prefix manager maintains a {@link tweakFactor | tweak factor} which
|
|
19
|
+
* is used, along with a type-specific multiplier, as the tweak when creating numeric identifiers. The default tweak
|
|
20
|
+
* factor is the numeric value of the GS1 Company Prefix representation of the prefix preceded by '1' to ensure
|
|
21
|
+
* uniqueness (i.e., so that prefixes 0 N1 N2 N3... and N1 N2 N3... produce different tweak factors). This is usually
|
|
22
|
+
* sufficient for obfuscation, but as the sparse creation algorithm is reversible and as the GS1 Company Prefix is
|
|
23
|
+
* discoverable via {@link https://www.gs1.org/services/verified-by-gs1 | Verified by GS1}, a user-defined tweak factor
|
|
24
|
+
* should be used if a higher degree of obfuscation is required. When using a tweak factor other than the default, care
|
|
25
|
+
* should be taken to restore it when resuming the application. A tweak factor of 0 creates a straight sequence.
|
|
26
|
+
*/
|
|
27
|
+
export declare class PrefixManager implements PrefixProvider {
|
|
28
|
+
/**
|
|
29
|
+
* Cached prefix managers, keyed by GS1 Company Prefix.
|
|
30
|
+
*/
|
|
31
|
+
private static readonly PREFIX_MANAGERS_MAP;
|
|
32
|
+
/**
|
|
33
|
+
* Creator tweak factors. Different numeric identifier types have different tweak factors so that sparse creation
|
|
34
|
+
* generates different sequences for each.
|
|
35
|
+
*/
|
|
36
|
+
private static readonly CREATOR_TWEAK_FACTORS;
|
|
37
|
+
/**
|
|
38
|
+
* Normalized prefix type.
|
|
39
|
+
*/
|
|
40
|
+
private readonly _prefixType;
|
|
41
|
+
/**
|
|
42
|
+
* Normalized prefix.
|
|
43
|
+
*/
|
|
44
|
+
private readonly _prefix;
|
|
45
|
+
/**
|
|
46
|
+
* Prefix as GS1 Company Prefix.
|
|
47
|
+
*/
|
|
48
|
+
private readonly _gs1CompanyPrefix;
|
|
49
|
+
/**
|
|
50
|
+
* U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix}.
|
|
51
|
+
*/
|
|
52
|
+
private readonly _upcCompanyPrefix;
|
|
53
|
+
/**
|
|
54
|
+
* GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix}.
|
|
55
|
+
*/
|
|
56
|
+
private readonly _gs18Prefix;
|
|
57
|
+
/**
|
|
58
|
+
* Default tweak factor.
|
|
59
|
+
*/
|
|
60
|
+
private readonly _defaultTweakFactor;
|
|
61
|
+
/**
|
|
62
|
+
* Tweak factor.
|
|
63
|
+
*/
|
|
64
|
+
private _tweakFactor;
|
|
65
|
+
/**
|
|
66
|
+
* Cached identifier creators.
|
|
67
|
+
*/
|
|
68
|
+
private readonly _identifierCreators;
|
|
69
|
+
/**
|
|
70
|
+
* Constructor.
|
|
71
|
+
*
|
|
72
|
+
* @param prefixType
|
|
73
|
+
* Prefix type.
|
|
74
|
+
*
|
|
75
|
+
* @param prefix
|
|
76
|
+
* Prefix.
|
|
77
|
+
*/
|
|
78
|
+
constructor(prefixType: PrefixType, prefix: string);
|
|
79
|
+
/**
|
|
80
|
+
* Get the prefix type.
|
|
81
|
+
*/
|
|
82
|
+
get prefixType(): PrefixType;
|
|
83
|
+
/**
|
|
84
|
+
* Get the prefix.
|
|
85
|
+
*/
|
|
86
|
+
get prefix(): string;
|
|
87
|
+
/**
|
|
88
|
+
* Get the GS1 Company Prefix.
|
|
89
|
+
*/
|
|
90
|
+
get gs1CompanyPrefix(): string;
|
|
91
|
+
/**
|
|
92
|
+
* Get the U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
|
|
93
|
+
*/
|
|
94
|
+
get upcCompanyPrefix(): string | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Get the GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
|
|
97
|
+
*/
|
|
98
|
+
get gs18Prefix(): string | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Set the tweak for an identifier creator if it's a numeric identifier creator.
|
|
101
|
+
*
|
|
102
|
+
* @param identifierCreator
|
|
103
|
+
* Identifier creator.
|
|
104
|
+
*/
|
|
105
|
+
private setCreatorTweak;
|
|
106
|
+
/**
|
|
107
|
+
* Get the tweak factor.
|
|
108
|
+
*/
|
|
109
|
+
get tweakFactor(): bigint;
|
|
110
|
+
/**
|
|
111
|
+
* Set the tweak factor.
|
|
112
|
+
*
|
|
113
|
+
* @param value
|
|
114
|
+
* Tweak factor.
|
|
115
|
+
*/
|
|
116
|
+
set tweakFactor(value: number | bigint);
|
|
117
|
+
/**
|
|
118
|
+
* Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
|
|
119
|
+
*/
|
|
120
|
+
resetTweakFactor(): void;
|
|
121
|
+
/**
|
|
122
|
+
* Get a prefix manager.
|
|
123
|
+
*
|
|
124
|
+
* @param prefixType
|
|
125
|
+
* Prefix type.
|
|
126
|
+
*
|
|
127
|
+
* @param prefix
|
|
128
|
+
* Prefix.
|
|
129
|
+
*
|
|
130
|
+
* @returns
|
|
131
|
+
* Prefix manager with normalized prefix type and prefix.
|
|
132
|
+
*/
|
|
133
|
+
static get(prefixType: PrefixType, prefix: string): PrefixManager;
|
|
134
|
+
/**
|
|
135
|
+
* Get an identifier creator.
|
|
136
|
+
*
|
|
137
|
+
* @template TIdentifierType
|
|
138
|
+
* Identifier type type.
|
|
139
|
+
*
|
|
140
|
+
* @param identifierType
|
|
141
|
+
* Identifier type used to construct identifier creator.
|
|
142
|
+
*
|
|
143
|
+
* @param constructorParameter
|
|
144
|
+
* Second constructor parameter passed to constructor callback alongside this.
|
|
145
|
+
*
|
|
146
|
+
* @param ConstructorCallback
|
|
147
|
+
* Constructor callback.
|
|
148
|
+
*
|
|
149
|
+
* @returns
|
|
150
|
+
* Identifier creator.
|
|
151
|
+
*/
|
|
152
|
+
private getIdentifierCreator;
|
|
153
|
+
/**
|
|
154
|
+
* Get non-GTIN numeric identifier creator.
|
|
155
|
+
*
|
|
156
|
+
* @param identifierType
|
|
157
|
+
* Identifier type used to construct identifier creator.
|
|
158
|
+
*
|
|
159
|
+
* @returns
|
|
160
|
+
* Identifier creator.
|
|
161
|
+
*/
|
|
162
|
+
private getNonGTINNumericIdentifierCreator;
|
|
163
|
+
/**
|
|
164
|
+
* Get serialized numeric identifier creator.
|
|
165
|
+
*
|
|
166
|
+
* @param identifierType
|
|
167
|
+
* Identifier type used to construct identifier creator.
|
|
168
|
+
*
|
|
169
|
+
* @returns
|
|
170
|
+
* Identifier creator.
|
|
171
|
+
*/
|
|
172
|
+
private getSerializableNumericIdentifierCreator;
|
|
173
|
+
/**
|
|
174
|
+
* Get non-numeric identifier creator.
|
|
175
|
+
*
|
|
176
|
+
* @param identifierType
|
|
177
|
+
* Identifier type used to construct identifier creator.
|
|
178
|
+
*
|
|
179
|
+
* @returns
|
|
180
|
+
* Identifier creator.
|
|
181
|
+
*/
|
|
182
|
+
private getNonNumericIdentifierCreator;
|
|
183
|
+
/**
|
|
184
|
+
* Get GTIN creator.
|
|
185
|
+
*/
|
|
186
|
+
get gtinCreator(): GTINCreator;
|
|
187
|
+
/**
|
|
188
|
+
* Get GLN creator.
|
|
189
|
+
*/
|
|
190
|
+
get glnCreator(): NonGTINNumericIdentifierCreator;
|
|
191
|
+
/**
|
|
192
|
+
* Get SSCC creator.
|
|
193
|
+
*/
|
|
194
|
+
get ssccCreator(): NonGTINNumericIdentifierCreator;
|
|
195
|
+
/**
|
|
196
|
+
* Get GRAI creator.
|
|
197
|
+
*/
|
|
198
|
+
get graiCreator(): SerializableNumericIdentifierCreator;
|
|
199
|
+
/**
|
|
200
|
+
* Get GIAI creator.
|
|
201
|
+
*/
|
|
202
|
+
get giaiCreator(): NonNumericIdentifierCreator;
|
|
203
|
+
/**
|
|
204
|
+
* Get GSRN creator.
|
|
205
|
+
*/
|
|
206
|
+
get gsrnCreator(): NonGTINNumericIdentifierCreator;
|
|
207
|
+
/**
|
|
208
|
+
* Get GDTI creator.
|
|
209
|
+
*/
|
|
210
|
+
get gdtiCreator(): SerializableNumericIdentifierCreator;
|
|
211
|
+
/**
|
|
212
|
+
* Get GINC creator.
|
|
213
|
+
*/
|
|
214
|
+
get gincCreator(): NonNumericIdentifierCreator;
|
|
215
|
+
/**
|
|
216
|
+
* Get GSIN creator.
|
|
217
|
+
*/
|
|
218
|
+
get gsinCreator(): NonGTINNumericIdentifierCreator;
|
|
219
|
+
/**
|
|
220
|
+
* Get GCN creator.
|
|
221
|
+
*/
|
|
222
|
+
get gcnCreator(): SerializableNumericIdentifierCreator;
|
|
223
|
+
/**
|
|
224
|
+
* Get CPID creator.
|
|
225
|
+
*/
|
|
226
|
+
get cpidCreator(): NonNumericIdentifierCreator;
|
|
227
|
+
/**
|
|
228
|
+
* Get GMN creator.
|
|
229
|
+
*/
|
|
230
|
+
get gmnCreator(): NonNumericIdentifierCreator;
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=prefix-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-manager.d.ts","sourceRoot":"","sources":["../src/prefix-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,OAAO,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,oCAAoC,EAAE,MAAM,8CAA8C,CAAC;AAGpG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,aAAc,YAAW,cAAc;IAChD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAoC;IAE/E;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAS3C;IAEF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC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