@aidc-toolkit/gs1 1.0.43 → 1.0.45-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 +41 -0
- package/dist/abstract-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-identifier-creator.js +73 -0
- package/dist/abstract-identifier-creator.js.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts +36 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js +37 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/abstract-numeric-identifier-creator.d.ts +34 -0
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-numeric-identifier-creator.js +154 -0
- package/dist/abstract-numeric-identifier-creator.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 +83 -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-creators.d.ts +4 -0
- package/dist/content-character-set-creators.d.ts.map +1 -0
- package/dist/content-character-set-creators.js +9 -0
- package/dist/content-character-set-creators.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/gcp-length-cache.d.ts +89 -0
- package/dist/gcp-length-cache.d.ts.map +1 -0
- package/dist/gcp-length-cache.js +240 -0
- package/dist/gcp-length-cache.js.map +1 -0
- package/dist/gcp-length-data.d.ts +108 -0
- package/dist/gcp-length-data.d.ts.map +1 -0
- package/dist/gcp-length-data.js +53 -0
- package/dist/gcp-length-data.js.map +1 -0
- package/dist/gcp-length.d.ts +97 -0
- package/dist/gcp-length.d.ts.map +1 -0
- package/dist/gcp-length.js +368 -0
- package/dist/gcp-length.js.map +1 -0
- package/dist/gtin-creator.d.ts +47 -0
- package/dist/gtin-creator.d.ts.map +1 -0
- package/dist/gtin-creator.js +64 -0
- package/dist/gtin-creator.js.map +1 -0
- package/dist/gtin-descriptor.d.ts +22 -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-length.d.ts +64 -0
- package/dist/gtin-length.d.ts.map +1 -0
- package/dist/gtin-length.js +36 -0
- package/dist/gtin-length.js.map +1 -0
- package/dist/gtin-type.d.ts +26 -0
- package/dist/gtin-type.d.ts.map +1 -0
- package/dist/gtin-type.js +7 -0
- package/dist/gtin-type.js.map +1 -0
- package/dist/gtin-validator.d.ts +132 -0
- package/dist/gtin-validator.d.ts.map +1 -0
- package/dist/gtin-validator.js +349 -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-creators.d.ts +118 -0
- package/dist/identifier-creators.d.ts.map +1 -0
- package/dist/identifier-creators.js +92 -0
- package/dist/identifier-creators.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-descriptors.d.ts +106 -0
- package/dist/identifier-descriptors.d.ts.map +1 -0
- package/dist/identifier-descriptors.js +262 -0
- package/dist/identifier-descriptors.js.map +1 -0
- package/dist/identifier-extension.d.ts +82 -0
- package/dist/identifier-extension.d.ts.map +1 -0
- package/dist/identifier-extension.js +79 -0
- package/dist/identifier-extension.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 +85 -0
- package/dist/identifier-validator.d.ts.map +1 -0
- package/dist/identifier-validator.js +107 -0
- package/dist/identifier-validator.js.map +1 -0
- package/dist/identifier-validators.d.ts +131 -0
- package/dist/identifier-validators.d.ts.map +1 -0
- package/dist/identifier-validators.js +167 -0
- package/dist/identifier-validators.js.map +1 -0
- package/dist/index.d.ts +63 -2205
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -0
- package/dist/leader-type.d.ts +26 -0
- package/dist/leader-type.d.ts.map +1 -0
- package/dist/leader-type.js +18 -0
- package/dist/leader-type.js.map +1 -0
- package/dist/locale/en/locale-resources.d.ts +48 -0
- package/dist/locale/en/locale-resources.d.ts.map +1 -0
- package/dist/locale/en/locale-resources.js +47 -0
- package/dist/locale/en/locale-resources.js.map +1 -0
- package/dist/locale/fr/locale-resources.d.ts +48 -0
- package/dist/locale/fr/locale-resources.d.ts.map +1 -0
- package/dist/locale/fr/locale-resources.js +47 -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 +35 -0
- package/dist/locale/i18n.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts +12 -0
- package/dist/non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-creator.js +2 -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 +26 -0
- package/dist/non-gtin-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-type.js +8 -0
- package/dist/non-gtin-numeric-identifier-type.js.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts +12 -0
- package/dist/non-gtin-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-gtin-numeric-identifier-validator.js +10 -0
- package/dist/non-gtin-numeric-identifier-validator.js.map +1 -0
- package/dist/non-numeric-identifier-creator.d.ts +40 -0
- package/dist/non-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-numeric-identifier-creator.js +82 -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 +26 -0
- package/dist/non-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-numeric-identifier-type.js +8 -0
- package/dist/non-numeric-identifier-type.js.map +1 -0
- package/dist/non-numeric-identifier-validator.d.ts +41 -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/non-serializable-numeric-identifier-creator.d.ts +10 -0
- package/dist/non-serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-creator.js +8 -0
- package/dist/non-serializable-numeric-identifier-creator.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-descriptor.d.ts +12 -0
- package/dist/non-serializable-numeric-identifier-descriptor.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-descriptor.js +2 -0
- package/dist/non-serializable-numeric-identifier-descriptor.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-type.d.ts +26 -0
- package/dist/non-serializable-numeric-identifier-type.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-type.js +7 -0
- package/dist/non-serializable-numeric-identifier-type.js.map +1 -0
- package/dist/non-serializable-numeric-identifier-validator.d.ts +16 -0
- package/dist/non-serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/non-serializable-numeric-identifier-validator.js +17 -0
- package/dist/non-serializable-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 +22 -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 +26 -0
- package/dist/numeric-identifier-type.d.ts.map +1 -0
- package/dist/numeric-identifier-type.js +7 -0
- package/dist/numeric-identifier-type.js.map +1 -0
- package/dist/numeric-identifier-validator.d.ts +38 -0
- package/dist/numeric-identifier-validator.d.ts.map +1 -0
- package/dist/numeric-identifier-validator.js +61 -0
- package/dist/numeric-identifier-validator.js.map +1 -0
- package/dist/prefix-manager.d.ts +151 -0
- package/dist/prefix-manager.d.ts.map +1 -0
- package/dist/prefix-manager.js +297 -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 +71 -0
- package/dist/prefix-validator.d.ts.map +1 -0
- package/dist/prefix-validator.js +204 -0
- package/dist/prefix-validator.js.map +1 -0
- package/dist/serializable-numeric-identifier-creator.d.ts +48 -0
- package/dist/serializable-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-creator.js +93 -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 +26 -0
- package/dist/serializable-numeric-identifier-type.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-type.js +8 -0
- package/dist/serializable-numeric-identifier-type.js.map +1 -0
- package/dist/serializable-numeric-identifier-validator.d.ts +67 -0
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-validator.js +97 -0
- package/dist/serializable-numeric-identifier-validator.js.map +1 -0
- package/dist/variable-measure.d.ts +68 -0
- package/dist/variable-measure.d.ts.map +1 -0
- package/dist/variable-measure.js +210 -0
- package/dist/variable-measure.js.map +1 -0
- package/dist/verified-by-gs1.d.ts +22 -0
- package/dist/verified-by-gs1.d.ts.map +1 -0
- package/dist/verified-by-gs1.js +46 -0
- package/dist/verified-by-gs1.js.map +1 -0
- package/package.json +4 -4
- package/src/gcp-length-cache.ts +7 -2
- package/tsconfig-src.tsbuildinfo +1 -1
- package/dist/index.cjs +0 -19
- package/dist/index.d.cts +0 -2205
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AbstractConstructor } from "@aidc-toolkit/core";
|
|
2
|
+
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
3
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
4
|
+
import type { IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
|
|
5
|
+
import type { IdentifierTypeValidator, IdentifierValidatorConstructorsEntry } from "./identifier-validators.js";
|
|
6
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
7
|
+
/**
|
|
8
|
+
* Identifier creator constructor type, which delegates to an identifier validator constructor.
|
|
9
|
+
*
|
|
10
|
+
* @template TIdentifierType
|
|
11
|
+
* Identifier type type.
|
|
12
|
+
*
|
|
13
|
+
* @template TIdentifierValidation
|
|
14
|
+
* Identifier validation type.
|
|
15
|
+
*
|
|
16
|
+
* @template TIdentifierValidator
|
|
17
|
+
* Identifier validator type.
|
|
18
|
+
*/
|
|
19
|
+
export type IdentifierCreatorConstructor<TIdentifierType extends IdentifierType, TIdentifierValidation extends IdentifierValidation, TIdentifierValidator extends IdentifierValidator<TIdentifierType, TIdentifierValidation>> = AbstractConstructor<[
|
|
20
|
+
prefixProvider: PrefixProvider,
|
|
21
|
+
prefix: string,
|
|
22
|
+
checkAllowance: number,
|
|
23
|
+
...args: ConstructorParameters<IdentifierValidatorConstructorsEntry<TIdentifierType>>
|
|
24
|
+
], TIdentifierValidator & IdentifierCreator<TIdentifierType, TIdentifierValidation>>;
|
|
25
|
+
/**
|
|
26
|
+
* Mixin implementation of {@linkcode IdentifierCreator} with an appropriate identifier validator base.
|
|
27
|
+
*
|
|
28
|
+
* @template TIdentifierType
|
|
29
|
+
* Identifier type type.
|
|
30
|
+
*
|
|
31
|
+
* @template TIdentifierValidation
|
|
32
|
+
* Identifier validation type.
|
|
33
|
+
*
|
|
34
|
+
* @param IdentifierValidatorConstructor
|
|
35
|
+
* Identifier validator base.
|
|
36
|
+
*
|
|
37
|
+
* @returns
|
|
38
|
+
* Identifier creator class.
|
|
39
|
+
*/
|
|
40
|
+
export declare function MixinAbstractIdentifierCreator<TIdentifierType extends IdentifierType, TIdentifierValidation extends IdentifierValidation>(IdentifierValidatorConstructor: AbstractConstructor<ConstructorParameters<IdentifierValidatorConstructorsEntry<TIdentifierType>>, IdentifierTypeValidator<TIdentifierType>>): IdentifierCreatorConstructor<TIdentifierType, TIdentifierValidation, IdentifierTypeValidator<TIdentifierType>>;
|
|
41
|
+
//# sourceMappingURL=abstract-identifier-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-identifier-creator.d.ts","sourceRoot":"","sources":["../src/abstract-identifier-creator.ts"],"names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|
|
4
|
+
* @template TIdentifierType
|
|
5
|
+
* Identifier type type.
|
|
6
|
+
*
|
|
7
|
+
* @template TIdentifierValidation
|
|
8
|
+
* Identifier validation type.
|
|
9
|
+
*
|
|
10
|
+
* @param IdentifierValidatorConstructor
|
|
11
|
+
* Identifier validator base.
|
|
12
|
+
*
|
|
13
|
+
* @returns
|
|
14
|
+
* Identifier creator class.
|
|
15
|
+
*/
|
|
16
|
+
export function MixinAbstractIdentifierCreator(IdentifierValidatorConstructor) {
|
|
17
|
+
/**
|
|
18
|
+
* Abstract numeric identifier creator. Implements common functionality for a numeric identifier creator, mixed in
|
|
19
|
+
* with a matching numeric identifier validator.
|
|
20
|
+
*/
|
|
21
|
+
class AbstractIdentifierCreator extends IdentifierValidatorConstructor {
|
|
22
|
+
/**
|
|
23
|
+
* Prefix provider.
|
|
24
|
+
*/
|
|
25
|
+
#prefixProvider;
|
|
26
|
+
/**
|
|
27
|
+
* Reference length.
|
|
28
|
+
*/
|
|
29
|
+
#referenceLength;
|
|
30
|
+
/**
|
|
31
|
+
* Constructor.
|
|
32
|
+
*
|
|
33
|
+
* @param prefixProvider
|
|
34
|
+
* Prefix provider.
|
|
35
|
+
*
|
|
36
|
+
* @param prefix
|
|
37
|
+
* Prefix within prefix provider to use to calculate reference length.
|
|
38
|
+
*
|
|
39
|
+
* @param checkAllowance
|
|
40
|
+
* Number of characters to allow for check digit or check character pair.
|
|
41
|
+
*
|
|
42
|
+
* @param args
|
|
43
|
+
* Originating constructor arguments.
|
|
44
|
+
*/
|
|
45
|
+
constructor(prefixProvider, prefix, checkAllowance, ...args) {
|
|
46
|
+
super(...args);
|
|
47
|
+
this.#prefixProvider = prefixProvider;
|
|
48
|
+
// Reference length allows for prefix and optionally check digit or check character pair.
|
|
49
|
+
this.#referenceLength = this.length - prefix.length - checkAllowance;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @inheritDoc
|
|
53
|
+
*/
|
|
54
|
+
get prefixProvider() {
|
|
55
|
+
return this.#prefixProvider;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
get prefix() {
|
|
61
|
+
return this.prefixProvider.gs1CompanyPrefix;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @inheritDoc
|
|
65
|
+
*/
|
|
66
|
+
get referenceLength() {
|
|
67
|
+
return this.#referenceLength;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
71
|
+
return AbstractIdentifierCreator;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=abstract-identifier-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-identifier-creator.js","sourceRoot":"","sources":["../src/abstract-identifier-creator.ts"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,8BAA8B,CAG5C,8BAGD;IAKG;;;OAGG;IACH,MAAe,yBAA0B,SACrC,8BAIH;QACG;;WAEG;QACM,eAAe,CAAiB;QAEzC;;WAEG;QACM,gBAAgB,CAAS;QAElC;;;;;;;;;;;;;;WAcG;QACH,YAAY,cAA8B,EAAE,MAAc,EAAE,cAAsB,EAAE,GAAG,IAAkF;YACrK,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAEf,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;YAEtC,yFAAyF;YACzF,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC;QACzE,CAAC;QAED;;WAEG;QACH,IAAI,cAAc;YACd,OAAO,IAAI,CAAC,eAAe,CAAC;QAChC,CAAC;QAED;;WAEG;QACH,IAAI,MAAM;YACN,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC;QAChD,CAAC;QAED;;WAEG;QACH,IAAI,eAAe;YACf,OAAO,IAAI,CAAC,gBAAgB,CAAC;QACjC,CAAC;KACJ;IAED,kKAAkK;IAClK,OAAO,yBAGN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AbstractConstructor } from "@aidc-toolkit/core";
|
|
2
|
+
import type { IdentifierTypeValidator, IdentifierValidatorConstructorsEntry } from "./identifier-validators.js";
|
|
3
|
+
import type { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
|
|
4
|
+
import type { NonGTINNumericIdentifierType } from "./non-gtin-numeric-identifier-type.js";
|
|
5
|
+
import type { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
|
|
6
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
7
|
+
/**
|
|
8
|
+
* Non-GTIN numeric identifier creator constructor type, which delegates to a non-GTIN numeric identifier validator
|
|
9
|
+
* constructor.
|
|
10
|
+
*
|
|
11
|
+
* @template TNonGTINNumericIdentifierType
|
|
12
|
+
* Non-GTIN numeric identifier type type.
|
|
13
|
+
*
|
|
14
|
+
* @template TNonGTINNumericIdentifierValidator
|
|
15
|
+
* Non-GTIN numeric identifier validator type.
|
|
16
|
+
*/
|
|
17
|
+
type NonGTINNumericIdentifierCreatorConstructor<TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType, TNonGTINNumericIdentifierValidator extends NonGTINNumericIdentifierValidator<TNonGTINNumericIdentifierType>> = AbstractConstructor<[
|
|
18
|
+
prefixProvider: PrefixProvider,
|
|
19
|
+
...args: ConstructorParameters<IdentifierValidatorConstructorsEntry<TNonGTINNumericIdentifierType>>
|
|
20
|
+
], TNonGTINNumericIdentifierValidator & NonGTINNumericIdentifierCreator<TNonGTINNumericIdentifierType>>;
|
|
21
|
+
/**
|
|
22
|
+
* Mixin implementation of {@linkcode NonGTINNumericIdentifierCreator} with an appropriate non-GTIN numeric identifier
|
|
23
|
+
* validator base.
|
|
24
|
+
*
|
|
25
|
+
* @template TNonGTINNumericIdentifierType
|
|
26
|
+
* Non-GTIN numeric identifier type type.
|
|
27
|
+
*
|
|
28
|
+
* @param NonGTINNumericIdentifierValidatorConstructor
|
|
29
|
+
* Non-GTIN numeric identifier validator constructor.
|
|
30
|
+
*
|
|
31
|
+
* @returns
|
|
32
|
+
* Non-GTIN numeric identifier creator class.
|
|
33
|
+
*/
|
|
34
|
+
export declare function MixinAbstractNonGTINNumericIdentifierCreator<TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType>(NonGTINNumericIdentifierValidatorConstructor: AbstractConstructor<ConstructorParameters<IdentifierValidatorConstructorsEntry<TNonGTINNumericIdentifierType>>, IdentifierTypeValidator<TNonGTINNumericIdentifierType>>): NonGTINNumericIdentifierCreatorConstructor<TNonGTINNumericIdentifierType, IdentifierTypeValidator<TNonGTINNumericIdentifierType>>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=abstract-non-gtin-numeric-identifier-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-non-gtin-numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/abstract-non-gtin-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC;AAChH,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAC1F,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AACpG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;;GASG;AACH,KAAK,0CAA0C,CAC3C,6BAA6B,SAAS,4BAA4B,EAClE,kCAAkC,SAAS,iCAAiC,CAAC,6BAA6B,CAAC,IAC3G,mBAAmB,CACnB;IAAC,cAAc,EAAE,cAAc;IAAE,GAAG,IAAI,EAAE,qBAAqB,CAAC,oCAAoC,CAAC,6BAA6B,CAAC,CAAC;CAAC,EACrI,kCAAkC,GAAG,+BAA+B,CAAC,6BAA6B,CAAC,CACtG,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,4CAA4C,CACxD,6BAA6B,SAAS,4BAA4B,EACpE,4CAA4C,EAAE,mBAAmB,CAC/D,qBAAqB,CAAC,oCAAoC,CAAC,6BAA6B,CAAC,CAAC,EAC1F,uBAAuB,CAAC,6BAA6B,CAAC,CACzD,GAAG,0CAA0C,CAC1C,6BAA6B,EAC7B,uBAAuB,CAAC,6BAA6B,CAAC,CACzD,CA8BA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { MixinAbstractNumericIdentifierCreator } from "./abstract-numeric-identifier-creator.js";
|
|
2
|
+
/**
|
|
3
|
+
* Mixin implementation of {@linkcode NonGTINNumericIdentifierCreator} with an appropriate non-GTIN numeric identifier
|
|
4
|
+
* validator base.
|
|
5
|
+
*
|
|
6
|
+
* @template TNonGTINNumericIdentifierType
|
|
7
|
+
* Non-GTIN numeric identifier type type.
|
|
8
|
+
*
|
|
9
|
+
* @param NonGTINNumericIdentifierValidatorConstructor
|
|
10
|
+
* Non-GTIN numeric identifier validator constructor.
|
|
11
|
+
*
|
|
12
|
+
* @returns
|
|
13
|
+
* Non-GTIN numeric identifier creator class.
|
|
14
|
+
*/
|
|
15
|
+
export function MixinAbstractNonGTINNumericIdentifierCreator(NonGTINNumericIdentifierValidatorConstructor) {
|
|
16
|
+
/**
|
|
17
|
+
* Abstract non-GTIN numeric identifier creator. Implements common functionality for a non-GTIN numeric identifier
|
|
18
|
+
* creator, mixed in with a matching non-GTIN numeric identifier validator.
|
|
19
|
+
*/
|
|
20
|
+
class AbstractNonGTINNumericIdentifierCreator extends MixinAbstractNumericIdentifierCreator(NonGTINNumericIdentifierValidatorConstructor) {
|
|
21
|
+
/**
|
|
22
|
+
* Constructor.
|
|
23
|
+
*
|
|
24
|
+
* @param prefixProvider
|
|
25
|
+
* Prefix provider.
|
|
26
|
+
*
|
|
27
|
+
* @param args
|
|
28
|
+
* Originating constructor arguments.
|
|
29
|
+
*/
|
|
30
|
+
constructor(prefixProvider, ...args) {
|
|
31
|
+
super(prefixProvider, prefixProvider.gs1CompanyPrefix, ...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
35
|
+
return AbstractNonGTINNumericIdentifierCreator;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=abstract-non-gtin-numeric-identifier-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-non-gtin-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/abstract-non-gtin-numeric-identifier-creator.ts"],"names":[],"mappings":"AACA,OAAO,EACH,qCAAqC,EAExC,MAAM,0CAA0C,CAAC;AAyBlD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4CAA4C,CAE1D,4CAGD;IAIG;;;OAGG;IACH,MAAe,uCAAwC,SACnD,qCAAqC,CAAC,4CAA4C,CAIrF;QACG;;;;;;;;WAQG;QACH,YAAY,cAA8B,EAAE,GAAG,IAAgG;YAC3I,KAAK,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,EAAE,GAAG,IAAI,CAAC,CAAC;QACpE,CAAC;KACJ;IAED,kKAAkK;IAClK,OAAO,uCAGN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AbstractConstructor } from "@aidc-toolkit/core";
|
|
2
|
+
import type { IdentifierTypeValidator, IdentifierValidatorConstructorsEntry } from "./identifier-validators.js";
|
|
3
|
+
import type { NumericIdentifierCreator } from "./numeric-identifier-creator.js";
|
|
4
|
+
import type { NumericIdentifierType } from "./numeric-identifier-type.js";
|
|
5
|
+
import type { NumericIdentifierValidator } from "./numeric-identifier-validator.js";
|
|
6
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
7
|
+
/**
|
|
8
|
+
* Numeric identifier creator constructor type, which delegates to a numeric identifier validator constructor.
|
|
9
|
+
*
|
|
10
|
+
* @template TNumericIdentifierType
|
|
11
|
+
* Numeric identifier type type.
|
|
12
|
+
*
|
|
13
|
+
* @template TNumericIdentifierValidator
|
|
14
|
+
* Numeric identifier validator type.
|
|
15
|
+
*/
|
|
16
|
+
export type NumericIdentifierCreatorConstructor<TNumericIdentifierType extends NumericIdentifierType, TNumericIdentifierValidator extends NumericIdentifierValidator<TNumericIdentifierType>> = AbstractConstructor<[
|
|
17
|
+
prefixProvider: PrefixProvider,
|
|
18
|
+
prefix: string,
|
|
19
|
+
...args: ConstructorParameters<IdentifierValidatorConstructorsEntry<TNumericIdentifierType>>
|
|
20
|
+
], TNumericIdentifierValidator & NumericIdentifierCreator<TNumericIdentifierType>>;
|
|
21
|
+
/**
|
|
22
|
+
* Mixin implementation of {@linkcode NumericIdentifierCreator} with an appropriate numeric identifier validator base.
|
|
23
|
+
*
|
|
24
|
+
* @template TNumericIdentifierType
|
|
25
|
+
* Numeric identifier type type.
|
|
26
|
+
*
|
|
27
|
+
* @param NumericIdentifierValidatorConstructor
|
|
28
|
+
* Numeric identifier validator base.
|
|
29
|
+
*
|
|
30
|
+
* @returns
|
|
31
|
+
* Numeric identifier creator class.
|
|
32
|
+
*/
|
|
33
|
+
export declare function MixinAbstractNumericIdentifierCreator<TNumericIdentifierType extends NumericIdentifierType>(NumericIdentifierValidatorConstructor: AbstractConstructor<ConstructorParameters<IdentifierValidatorConstructorsEntry<TNumericIdentifierType>>, IdentifierTypeValidator<TNumericIdentifierType>>): NumericIdentifierCreatorConstructor<TNumericIdentifierType, IdentifierTypeValidator<TNumericIdentifierType>>;
|
|
34
|
+
//# sourceMappingURL=abstract-numeric-identifier-creator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/abstract-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAU9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,oCAAoC,EAAE,MAAM,4BAA4B,CAAC;AAEhH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,KAAK,EAA+B,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AACjH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;;;;;;;GAQG;AACH,MAAM,MAAM,mCAAmC,CAC3C,sBAAsB,SAAS,qBAAqB,EACpD,2BAA2B,SAAS,0BAA0B,CAAC,sBAAsB,CAAC,IACtF,mBAAmB,CACnB;IAAC,cAAc,EAAE,cAAc;IAAE,MAAM,EAAE,MAAM;IAAE,GAAG,IAAI,EAAE,qBAAqB,CAAC,oCAAoC,CAAC,sBAAsB,CAAC,CAAC;CAAC,EAC9I,2BAA2B,GAAG,wBAAwB,CAAC,sBAAsB,CAAC,CACjF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,qCAAqC,CACjD,sBAAsB,SAAS,qBAAqB,EACtD,qCAAqC,EAAE,mBAAmB,CACxD,qBAAqB,CAAC,oCAAoC,CAAC,sBAAsB,CAAC,CAAC,EACnF,uBAAuB,CAAC,sBAAsB,CAAC,CAClD,GAAG,mCAAmC,CACnC,sBAAsB,EACtB,uBAAuB,CAAC,sBAAsB,CAAC,CAClD,CAqKA"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { CharacterSetCreator, Exclusions, NUMERIC_CREATOR } from "@aidc-toolkit/utility";
|
|
2
|
+
import { MixinAbstractIdentifierCreator } from "./abstract-identifier-creator.js";
|
|
3
|
+
import { checkDigit, checkDigitSum } from "./check.js";
|
|
4
|
+
import { LeaderTypes } from "./leader-type.js";
|
|
5
|
+
/**
|
|
6
|
+
* Mixin implementation of {@linkcode NumericIdentifierCreator} with an appropriate numeric identifier validator base.
|
|
7
|
+
*
|
|
8
|
+
* @template TNumericIdentifierType
|
|
9
|
+
* Numeric identifier type type.
|
|
10
|
+
*
|
|
11
|
+
* @param NumericIdentifierValidatorConstructor
|
|
12
|
+
* Numeric identifier validator base.
|
|
13
|
+
*
|
|
14
|
+
* @returns
|
|
15
|
+
* Numeric identifier creator class.
|
|
16
|
+
*/
|
|
17
|
+
export function MixinAbstractNumericIdentifierCreator(NumericIdentifierValidatorConstructor) {
|
|
18
|
+
/**
|
|
19
|
+
* Abstract numeric identifier creator. Implements common functionality for a numeric identifier creator, mixed in
|
|
20
|
+
* with a matching numeric identifier validator.
|
|
21
|
+
*/
|
|
22
|
+
class AbstractNumericIdentifierCreator extends MixinAbstractIdentifierCreator(NumericIdentifierValidatorConstructor) {
|
|
23
|
+
/**
|
|
24
|
+
* Capacity.
|
|
25
|
+
*/
|
|
26
|
+
#capacity;
|
|
27
|
+
/**
|
|
28
|
+
* Tweak for sparse creation.
|
|
29
|
+
*/
|
|
30
|
+
#tweak = 0n;
|
|
31
|
+
/**
|
|
32
|
+
* Constructor.
|
|
33
|
+
*
|
|
34
|
+
* @param prefixProvider
|
|
35
|
+
* Prefix provider.
|
|
36
|
+
*
|
|
37
|
+
* @param prefix
|
|
38
|
+
* Prefix within prefix provider to use to calculate reference length.
|
|
39
|
+
*
|
|
40
|
+
* @param args
|
|
41
|
+
* Originating constructor arguments.
|
|
42
|
+
*/
|
|
43
|
+
constructor(prefixProvider, prefix, ...args) {
|
|
44
|
+
super(prefixProvider, prefix, 1, ...args);
|
|
45
|
+
// Capacity is always in number range.
|
|
46
|
+
this.#capacity = Number(CharacterSetCreator.powerOf10(this.referenceLength));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* @inheritDoc
|
|
50
|
+
*/
|
|
51
|
+
get capacity() {
|
|
52
|
+
return this.#capacity;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @inheritDoc
|
|
56
|
+
*/
|
|
57
|
+
get tweak() {
|
|
58
|
+
return this.#tweak;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
set tweak(value) {
|
|
64
|
+
this.#tweak = value;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Build an identifier from a reference by merging it with the prefix and adding the check digit.
|
|
68
|
+
*
|
|
69
|
+
* @param reference
|
|
70
|
+
* Identifier reference.
|
|
71
|
+
*
|
|
72
|
+
* @returns
|
|
73
|
+
* Identifier.
|
|
74
|
+
*/
|
|
75
|
+
#buildIdentifier(reference) {
|
|
76
|
+
const partialIdentifier = this.leaderType === LeaderTypes.ExtensionDigit ? reference.substring(0, 1) + this.prefix + reference.substring(1) : this.prefix + reference;
|
|
77
|
+
return partialIdentifier + checkDigit(partialIdentifier);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @inheritDoc
|
|
81
|
+
*/
|
|
82
|
+
create(valueOrValues, sparse = false) {
|
|
83
|
+
return NUMERIC_CREATOR.create(this.referenceLength, valueOrValues, Exclusions.None, sparse ? this.tweak : undefined, reference => this.#buildIdentifier(reference));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Create all identifiers from a partial identifier. Call is recursive until remaining reference
|
|
87
|
+
* length is 0.
|
|
88
|
+
*
|
|
89
|
+
* @param partialIdentifier
|
|
90
|
+
* Partial identifier. Initial value is `this.prefix`.
|
|
91
|
+
*
|
|
92
|
+
* @param remainingReferenceLength
|
|
93
|
+
* Remaining reference length. Initial value is `this.referenceLength`.
|
|
94
|
+
*
|
|
95
|
+
* @param extensionWeight
|
|
96
|
+
* If this value is not zero, the identifier has an extension digit, this call is setting it, and this value is
|
|
97
|
+
* applied to the calculation of the check digit.
|
|
98
|
+
*
|
|
99
|
+
* @param weight
|
|
100
|
+
* If the extension weight is zero, this value is applied to the calculation of the check digit.
|
|
101
|
+
*
|
|
102
|
+
* @param partialCheckDigitSum
|
|
103
|
+
* Partial check digit sum for the partial identifier.
|
|
104
|
+
*
|
|
105
|
+
* @yields
|
|
106
|
+
* Identifier.
|
|
107
|
+
*/
|
|
108
|
+
static *createAllPartial(partialIdentifier, remainingReferenceLength, extensionWeight, weight, partialCheckDigitSum) {
|
|
109
|
+
if (remainingReferenceLength === 0) {
|
|
110
|
+
// Finalize check digit calculation and append.
|
|
111
|
+
yield partialIdentifier + NUMERIC_CREATOR.character(9 - (partialCheckDigitSum + 9) % 10);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const nextRemainingReferenceLength = remainingReferenceLength - 1;
|
|
115
|
+
let nextPartialCheckDigitSum = partialCheckDigitSum;
|
|
116
|
+
if (extensionWeight !== 0) {
|
|
117
|
+
// Apply every digit to the extension digit.
|
|
118
|
+
for (const c of NUMERIC_CREATOR.characterSet) {
|
|
119
|
+
yield* AbstractNumericIdentifierCreator.createAllPartial(c + partialIdentifier, nextRemainingReferenceLength, 0, weight, nextPartialCheckDigitSum);
|
|
120
|
+
nextPartialCheckDigitSum += extensionWeight;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
const nextWeight = 4 - weight;
|
|
125
|
+
// Apply every digit to the current character in the identifier.
|
|
126
|
+
for (const c of NUMERIC_CREATOR.characterSet) {
|
|
127
|
+
yield* AbstractNumericIdentifierCreator.createAllPartial(partialIdentifier + c, nextRemainingReferenceLength, 0, nextWeight, nextPartialCheckDigitSum);
|
|
128
|
+
nextPartialCheckDigitSum += weight;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* @inheritDoc
|
|
135
|
+
*/
|
|
136
|
+
createAll() {
|
|
137
|
+
const hasExtensionDigit = this.leaderType === LeaderTypes.ExtensionDigit;
|
|
138
|
+
const prefix = this.prefix;
|
|
139
|
+
const length = this.length;
|
|
140
|
+
const referenceLength = this.referenceLength;
|
|
141
|
+
// Start weight is for reference excluding extension digit, which has its weight calculated separately.
|
|
142
|
+
const startWeight = 3 - 2 * ((referenceLength + 1 - Number(hasExtensionDigit)) % 2);
|
|
143
|
+
// Returning separate Iterable object makes iteration repeatable.
|
|
144
|
+
return {
|
|
145
|
+
[Symbol.iterator]() {
|
|
146
|
+
return AbstractNumericIdentifierCreator.createAllPartial(prefix, referenceLength, hasExtensionDigit ? 3 - 2 * length % 2 : 0, startWeight, checkDigitSum(startWeight === 3, prefix));
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
152
|
+
return AbstractNumericIdentifierCreator;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=abstract-numeric-identifier-creator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/abstract-numeric-identifier-creator.ts"],"names":[],"mappings":"AACA,OAAO,EACH,mBAAmB,EACnB,UAAU,EACV,eAAe,EAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAqC,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAuB/C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,qCAAqC,CAEnD,qCAGD;IAIG;;;OAGG;IACH,MAAe,gCAAiC,SAC5C,8BAA8B,CAAC,qCAAqC,CAKvE;QACG;;WAEG;QACM,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AI,CAAC,UAAU,KAAK,WAAW,CAAC,cAAc,CAAC;YACzE,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC3B,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;YAE7C,uGAAuG;YACvG,MAAM,WAAW,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAEpF,iEAAiE;YACjE,OAAO;gBACH,CAAC,MAAM,CAAC,QAAQ,CAAC;oBACb,OAAO,gCAAgC,CAAC,gBAAgB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;gBACzL,CAAC;aACJ,CAAC;QACN,CAAC;KACJ;IAED,kKAAkK;IAClK,OAAO,gCAMN,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CharacterSetCreator, CharacterSetValidator } from "@aidc-toolkit/utility";
|
|
2
|
+
/**
|
|
3
|
+
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link
|
|
4
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 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
|
|
9
|
+
* https://ref.gs1.org/standards/genspecs/ | 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
|
|
14
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 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
|
|
19
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
20
|
+
*/
|
|
21
|
+
export declare const AI39_VALIDATOR: CharacterSetValidator;
|
|
22
|
+
/**
|
|
23
|
+
* GS1 AI encodable character set 64 validator as defined in section 7.11 of the {@link
|
|
24
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Doesn't support any exclusions.
|
|
25
|
+
*/
|
|
26
|
+
export declare const AI64_VALIDATOR: CharacterSetValidator;
|
|
27
|
+
//# sourceMappingURL=character-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-set.d.ts","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EAEnB,qBAAqB,EAExB,MAAM,uBAAuB,CAAC;AAG/B;;;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;AAiDpE;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,qBAAuD,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { CharacterSetCreator, CharacterSetValidator, Exclusions, utilityNS } from "@aidc-toolkit/utility";
|
|
2
|
+
import { i18nextGS1 } from "./locale/i18n.js";
|
|
3
|
+
/**
|
|
4
|
+
* GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link
|
|
5
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
6
|
+
*/
|
|
7
|
+
export const AI82_CREATOR = new CharacterSetCreator([
|
|
8
|
+
"!", "\"", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
|
|
9
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
10
|
+
":", ";", "<", "=", ">", "?",
|
|
11
|
+
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
12
|
+
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
13
|
+
"_",
|
|
14
|
+
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
|
15
|
+
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
|
16
|
+
], Exclusions.AllNumeric);
|
|
17
|
+
/**
|
|
18
|
+
* GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link
|
|
19
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
20
|
+
*/
|
|
21
|
+
export const AI82_VALIDATOR = AI82_CREATOR;
|
|
22
|
+
/**
|
|
23
|
+
* GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link
|
|
24
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
25
|
+
*/
|
|
26
|
+
export const AI39_CREATOR = new CharacterSetCreator([
|
|
27
|
+
"#", "-", "/",
|
|
28
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
29
|
+
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
30
|
+
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
31
|
+
], Exclusions.AllNumeric);
|
|
32
|
+
/**
|
|
33
|
+
* GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link
|
|
34
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
|
|
35
|
+
*/
|
|
36
|
+
export const AI39_VALIDATOR = AI39_CREATOR;
|
|
37
|
+
/**
|
|
38
|
+
* GS1 AI encodable character set 64 validator with additional base64 validation of length (multiple of 4) and position
|
|
39
|
+
* of equal sign (last or last two characters).
|
|
40
|
+
*/
|
|
41
|
+
class AI64CharacterSetValidator extends CharacterSetValidator {
|
|
42
|
+
/**
|
|
43
|
+
* Constructor.
|
|
44
|
+
*/
|
|
45
|
+
constructor() {
|
|
46
|
+
super(([
|
|
47
|
+
"-",
|
|
48
|
+
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
49
|
+
"=",
|
|
50
|
+
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
|
|
51
|
+
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
|
|
52
|
+
"_",
|
|
53
|
+
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
|
|
54
|
+
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
|
|
55
|
+
]));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @inheritDoc
|
|
59
|
+
*/
|
|
60
|
+
validate(s, validation) {
|
|
61
|
+
super.validate(s, validation);
|
|
62
|
+
const length = s.length;
|
|
63
|
+
if (length % 4 !== 0) {
|
|
64
|
+
throw new RangeError(i18nextGS1.t("AI64CharacterSetValidator.lengthMustBeMultipleOf4", {
|
|
65
|
+
length
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
const equalIndex = s.search(/={1,2}/u);
|
|
69
|
+
if (equalIndex !== -1 && equalIndex < length - 2) {
|
|
70
|
+
throw new RangeError(i18nextGS1.t("CharacterSetValidator.invalidCharacterAtPosition", {
|
|
71
|
+
ns: utilityNS,
|
|
72
|
+
c: "=",
|
|
73
|
+
position: equalIndex
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* GS1 AI encodable character set 64 validator as defined in section 7.11 of the {@link
|
|
80
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Doesn't support any exclusions.
|
|
81
|
+
*/
|
|
82
|
+
export const AI64_VALIDATOR = new AI64CharacterSetValidator();
|
|
83
|
+
//# sourceMappingURL=character-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character-set.js","sourceRoot":"","sources":["../src/character-set.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EAEnB,qBAAqB,EACrB,UAAU,EAAE,SAAS,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;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,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAChD,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;IAC5B,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,G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AC,CAAC,CAAC;QACR,CAAC;QAED,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAEvC,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI,UAAU,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,kDAAkD,EAAE;gBAClF,EAAE,EAAE,SAAS;gBACb,CAAC,EAAE,GAAG;gBACN,QAAQ,EAAE,UAAU;aACvB,CAAC,CAAC,CAAC;QACR,CAAC;IACL,CAAC;CACJ;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAA0B,IAAI,yBAAyB,EAAE,CAAC"}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculate the check digit sum for a numeric string as per section 7.9.1 of the {@link
|
|
3
|
+
* https://ref.gs1.org/standards/genspecs/ | 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
|
|
17
|
+
* https://ref.gs1.org/standards/genspecs/ | GS1 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 sections 7.9.2-7.9.4 of the
|
|
38
|
+
* {@link https://ref.gs1.org/standards/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://ref.gs1.org/standards/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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|