@aidc-toolkit/gs1 1.0.25-beta → 1.0.27-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 +79 -0
- package/dist/abstract-identifier-creator.js.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts +42 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js +40 -0
- package/dist/abstract-non-gtin-numeric-identifier-creator.js.map +1 -0
- package/dist/abstract-numeric-identifier-creator.d.ts +43 -0
- package/dist/abstract-numeric-identifier-creator.d.ts.map +1 -0
- package/dist/abstract-numeric-identifier-creator.js +160 -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 +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-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/gtin-creator.d.ts +64 -0
- package/dist/gtin-creator.d.ts.map +1 -0
- package/dist/gtin-creator.js +156 -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 +177 -0
- package/dist/gtin-validator.d.ts.map +1 -0
- package/dist/gtin-validator.js +443 -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 +90 -0
- package/dist/identifier-creators.d.ts.map +1 -0
- package/dist/identifier-creators.js +74 -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 +88 -0
- package/dist/identifier-validator.d.ts.map +1 -0
- package/dist/identifier-validator.js +110 -0
- package/dist/identifier-validator.js.map +1 -0
- package/dist/identifier-validators.d.ts +106 -0
- package/dist/identifier-validators.d.ts.map +1 -0
- package/dist/identifier-validators.js +153 -0
- package/dist/identifier-validators.js.map +1 -0
- package/dist/index.d.ts +58 -1949
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -4727
- package/dist/index.js.map +1 -1
- 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 +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 +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 +7 -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 +136 -0
- package/dist/prefix-manager.d.ts.map +1 -0
- package/dist/prefix-manager.js +339 -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 +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 +41 -0
- package/dist/serializable-numeric-identifier-validator.d.ts.map +1 -0
- package/dist/serializable-numeric-identifier-validator.js +78 -0
- package/dist/serializable-numeric-identifier-validator.js.map +1 -0
- package/package.json +11 -8
- package/src/abstract-identifier-creator.ts +157 -76
- package/src/abstract-non-gtin-numeric-identifier-creator.ts +86 -0
- package/src/abstract-numeric-identifier-creator.ts +205 -136
- package/src/check.ts +2 -2
- package/src/content-character-set-creators.ts +9 -0
- package/src/gtin-creator.ts +20 -19
- package/src/gtin-descriptor.ts +10 -4
- package/src/gtin-length.ts +61 -0
- package/src/gtin-type.ts +6 -37
- package/src/gtin-validator.ts +39 -46
- package/src/identifier-creator.ts +6 -6
- package/src/{creators.ts → identifier-creators.ts} +45 -31
- package/src/identifier-descriptor.ts +3 -3
- package/src/{descriptors.ts → identifier-descriptors.ts} +65 -63
- package/src/identifier-extension.ts +155 -0
- package/src/identifier-validator.ts +94 -11
- package/src/{validators.ts → identifier-validators.ts} +56 -41
- package/src/index.ts +50 -43
- package/src/leader-type.ts +29 -0
- package/src/locale/i18n.ts +3 -3
- package/src/locale/i18next.d.ts +1 -1
- package/src/non-gtin-numeric-identifier-creator.ts +8 -23
- package/src/non-gtin-numeric-identifier-descriptor.ts +4 -4
- package/src/non-gtin-numeric-identifier-type.ts +14 -3
- package/src/non-gtin-numeric-identifier-validator.ts +7 -15
- package/src/non-numeric-identifier-creator.ts +21 -16
- package/src/non-numeric-identifier-descriptor.ts +4 -4
- package/src/non-numeric-identifier-type.ts +14 -3
- package/src/non-numeric-identifier-validator.ts +12 -13
- package/src/non-serializable-numeric-identifier-creator.ts +12 -0
- package/src/non-serializable-numeric-identifier-descriptor.ts +7 -0
- package/src/non-serializable-numeric-identifier-type.ts +22 -0
- package/src/non-serializable-numeric-identifier-validator.ts +19 -0
- package/src/numeric-identifier-creator.ts +9 -8
- package/src/numeric-identifier-descriptor.ts +4 -3
- package/src/numeric-identifier-type.ts +17 -35
- package/src/numeric-identifier-validator.ts +62 -7
- package/src/prefix-manager.ts +79 -76
- package/src/prefix-provider.ts +1 -1
- package/src/prefix-validator.ts +3 -3
- package/src/serializable-numeric-identifier-creator.ts +13 -27
- package/src/serializable-numeric-identifier-descriptor.ts +4 -4
- package/src/serializable-numeric-identifier-type.ts +14 -5
- package/src/serializable-numeric-identifier-validator.ts +22 -21
- package/test/check.test.ts +1 -1
- package/test/creator.test.ts +5 -5
- package/test/gtin-creator.ts +10 -3
- package/test/gtin-validator.test.ts +10 -12
- package/test/identifier-creator.ts +12 -12
- package/test/identifier-validator.ts +1 -1
- package/test/non-gtin-numeric-identifier-creator.ts +3 -3
- package/test/non-gtin-numeric-identifier-validator.ts +8 -3
- package/test/non-numeric-identifier-creator.ts +1 -1
- package/test/non-numeric-identifier-validator.ts +3 -3
- package/test/non-serializable-numeric-identifier-creator.ts +64 -0
- package/test/non-serializable-numeric-identifier-validator.ts +6 -0
- package/test/numeric-identifier-creator.ts +9 -4
- package/test/numeric-identifier-validator.ts +2 -2
- package/test/prefix-manager.test.ts +2 -2
- package/test/serializable-numeric-identifier-creator.ts +2 -2
- 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 +16 -15
- package/test/variable-measure-rcn.test.ts +24 -24
- 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 -4813
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1949
- package/src/abstract-identifier-validator.ts +0 -140
- package/src/abstract-numeric-identifier-validator.ts +0 -69
|
@@ -1,97 +1,178 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { PrefixProvider } from "./prefix-provider";
|
|
1
|
+
import type { IdentifierCreator } from "./identifier-creator.js";
|
|
2
|
+
import type { IdentifierType } from "./identifier-type.js";
|
|
3
|
+
import type { IdentifierValidation, IdentifierValidator } from "./identifier-validator.js";
|
|
4
|
+
import type { IdentifierTypeValidator } from "./identifier-validators.js";
|
|
5
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* PrefixProvider | prefix provider}.
|
|
8
|
+
* Identifier extension constructor type.
|
|
10
9
|
*
|
|
11
|
-
* @template
|
|
12
|
-
*
|
|
10
|
+
* @template TConstructorArguments
|
|
11
|
+
* Constructor arguments types.
|
|
12
|
+
*
|
|
13
|
+
* @template TConstructorInstance
|
|
14
|
+
* Constructor instance type.
|
|
15
|
+
*/
|
|
16
|
+
export type IdentifierExtensionConstructor<
|
|
17
|
+
TConstructorArguments extends unknown[],
|
|
18
|
+
TConstructorInstance
|
|
19
|
+
> = abstract new (...args: TConstructorArguments) => TConstructorInstance;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Identifier validator constructor type.
|
|
23
|
+
*
|
|
24
|
+
* @template TConstructorArguments
|
|
25
|
+
* Constructor arguments types.
|
|
26
|
+
*
|
|
27
|
+
* @template TIdentifierType
|
|
28
|
+
* Identifier type type.
|
|
13
29
|
*
|
|
14
30
|
* @template TIdentifierValidation
|
|
15
31
|
* Identifier validation type.
|
|
32
|
+
*
|
|
33
|
+
* @template TIdentifierValidator
|
|
34
|
+
* Identifier validator type.
|
|
16
35
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private _referenceLength!: number;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Initialize the prefix provider. This method is in lieu of a constructor due to the mixin architecture.
|
|
30
|
-
*
|
|
31
|
-
* @param prefixProvider
|
|
32
|
-
* Prefix provider.
|
|
33
|
-
*
|
|
34
|
-
* @param prefix
|
|
35
|
-
* Prefix within prefix provider to use to calculate reference length.
|
|
36
|
-
*
|
|
37
|
-
* @param checkAllowance
|
|
38
|
-
* Number of characters to allow for check digit or check character pair.
|
|
39
|
-
*/
|
|
40
|
-
protected init(prefixProvider: PrefixProvider, prefix: string, checkAllowance: number): void {
|
|
41
|
-
this._prefixProvider = prefixProvider;
|
|
36
|
+
export type IdentifierValidatorConstructor<
|
|
37
|
+
TConstructorArguments extends unknown[],
|
|
38
|
+
TIdentifierType extends IdentifierType,
|
|
39
|
+
TIdentifierValidation extends IdentifierValidation,
|
|
40
|
+
TIdentifierValidator extends IdentifierValidator<TIdentifierType, TIdentifierValidation> = IdentifierTypeValidator<TIdentifierType>
|
|
41
|
+
> = IdentifierExtensionConstructor<
|
|
42
|
+
TConstructorArguments,
|
|
43
|
+
TIdentifierValidator
|
|
44
|
+
>;
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Identifier creator constructor type, which delegates to an identifier validator constructor.
|
|
48
|
+
*
|
|
49
|
+
* @template TConstructorArguments
|
|
50
|
+
* Constructor arguments types.
|
|
51
|
+
*
|
|
52
|
+
* @template TIdentifierType
|
|
53
|
+
* Identifier type type.
|
|
54
|
+
*
|
|
55
|
+
* @template TIdentifierValidation
|
|
56
|
+
* Identifier validation type.
|
|
57
|
+
*
|
|
58
|
+
* @template TIdentifierValidator
|
|
59
|
+
* Identifier validator type.
|
|
60
|
+
*/
|
|
61
|
+
export type IdentifierCreatorConstructor<
|
|
62
|
+
TConstructorArguments extends unknown[],
|
|
63
|
+
TIdentifierType extends IdentifierType,
|
|
64
|
+
TIdentifierValidation extends IdentifierValidation,
|
|
65
|
+
TIdentifierValidator extends IdentifierValidator<TIdentifierType, TIdentifierValidation>
|
|
66
|
+
> = IdentifierExtensionConstructor<
|
|
67
|
+
[prefixProvider: PrefixProvider, prefix: string, checkAllowance: number, ...args: TConstructorArguments],
|
|
68
|
+
TIdentifierValidator & IdentifierCreator<TIdentifierType, TIdentifierValidation>
|
|
69
|
+
>;
|
|
46
70
|
|
|
71
|
+
/**
|
|
72
|
+
* Mixin implementation of {@linkcode IdentifierCreator} with an appropriate identifier validator base.
|
|
73
|
+
*
|
|
74
|
+
* @template TConstructorArguments
|
|
75
|
+
* Constructor arguments types.
|
|
76
|
+
*
|
|
77
|
+
* @template TIdentifierType
|
|
78
|
+
* Identifier type type.
|
|
79
|
+
*
|
|
80
|
+
* @template TIdentifierValidation
|
|
81
|
+
* Identifier validation type.
|
|
82
|
+
*
|
|
83
|
+
* @template TIdentifierValidatorConstructor
|
|
84
|
+
* Identifier validator constructor type.
|
|
85
|
+
*
|
|
86
|
+
* @param IdentifierValidatorBase
|
|
87
|
+
* Identifier validator base.
|
|
88
|
+
*
|
|
89
|
+
* @returns
|
|
90
|
+
* Identifier creator class.
|
|
91
|
+
*/
|
|
92
|
+
export function MixinAbstractIdentifierCreator<
|
|
93
|
+
TConstructorArguments extends unknown[],
|
|
94
|
+
TIdentifierType extends IdentifierType,
|
|
95
|
+
TIdentifierValidation extends IdentifierValidation,
|
|
96
|
+
TIdentifierValidatorConstructor extends IdentifierValidatorConstructor<
|
|
97
|
+
TConstructorArguments,
|
|
98
|
+
TIdentifierType,
|
|
99
|
+
TIdentifierValidation
|
|
100
|
+
>
|
|
101
|
+
>(IdentifierValidatorBase: TIdentifierValidatorConstructor): IdentifierCreatorConstructor<
|
|
102
|
+
TConstructorArguments,
|
|
103
|
+
TIdentifierType,
|
|
104
|
+
TIdentifierValidation,
|
|
105
|
+
IdentifierTypeValidator<TIdentifierType>
|
|
106
|
+
> {
|
|
47
107
|
/**
|
|
48
|
-
*
|
|
108
|
+
* Abstract numeric identifier creator. Implements common functionality for a numeric identifier creator, mixed in
|
|
109
|
+
* with a matching numeric identifier validator.
|
|
49
110
|
*/
|
|
50
|
-
abstract
|
|
111
|
+
abstract class AbstractIdentifierCreator extends (IdentifierValidatorBase as IdentifierValidatorConstructor<
|
|
112
|
+
TConstructorArguments,
|
|
113
|
+
TIdentifierType,
|
|
114
|
+
TIdentifierValidation,
|
|
115
|
+
IdentifierValidator<TIdentifierType, TIdentifierValidation>
|
|
116
|
+
>) implements IdentifierCreator<TIdentifierType, TIdentifierValidation> {
|
|
117
|
+
/**
|
|
118
|
+
* Prefix provider.
|
|
119
|
+
*/
|
|
120
|
+
readonly #prefixProvider: PrefixProvider;
|
|
51
121
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Reference length.
|
|
124
|
+
*/
|
|
125
|
+
readonly #referenceLength: number;
|
|
56
126
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Constructor.
|
|
129
|
+
*
|
|
130
|
+
* @param prefixProvider
|
|
131
|
+
* Prefix provider.
|
|
132
|
+
*
|
|
133
|
+
* @param prefix
|
|
134
|
+
* Prefix within prefix provider to use to calculate reference length.
|
|
135
|
+
*
|
|
136
|
+
* @param checkAllowance
|
|
137
|
+
* Number of characters to allow for check digit or check character pair.
|
|
138
|
+
*
|
|
139
|
+
* @param args
|
|
140
|
+
* Originating constructor arguments.
|
|
141
|
+
*/
|
|
142
|
+
constructor(prefixProvider: PrefixProvider, prefix: string, checkAllowance: number, ...args: TConstructorArguments) {
|
|
143
|
+
super(...args);
|
|
61
144
|
|
|
62
|
-
|
|
63
|
-
* @inheritDoc
|
|
64
|
-
*/
|
|
65
|
-
abstract get referenceCharacterSet(): TIdentifierDescriptor["referenceCharacterSet"];
|
|
145
|
+
this.#prefixProvider = prefixProvider;
|
|
66
146
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
abstract get referenceCreator(): CharacterSetCreator;
|
|
147
|
+
// Reference length allows for prefix and optionally check digit or check character pair.
|
|
148
|
+
this.#referenceLength = this.length - prefix.length - checkAllowance;
|
|
149
|
+
}
|
|
71
150
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
151
|
+
/**
|
|
152
|
+
* @inheritDoc
|
|
153
|
+
*/
|
|
154
|
+
get prefixProvider(): PrefixProvider {
|
|
155
|
+
return this.#prefixProvider;
|
|
156
|
+
}
|
|
78
157
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
158
|
+
/**
|
|
159
|
+
* @inheritDoc
|
|
160
|
+
*/
|
|
161
|
+
get prefix(): string {
|
|
162
|
+
return this.prefixProvider.gs1CompanyPrefix;
|
|
163
|
+
}
|
|
85
164
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
165
|
+
/**
|
|
166
|
+
* @inheritDoc
|
|
167
|
+
*/
|
|
168
|
+
get referenceLength(): number {
|
|
169
|
+
return this.#referenceLength;
|
|
170
|
+
}
|
|
91
171
|
}
|
|
92
172
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
174
|
+
return AbstractIdentifierCreator as IdentifierExtensionConstructor<
|
|
175
|
+
ConstructorParameters<typeof AbstractIdentifierCreator>,
|
|
176
|
+
IdentifierTypeValidator<TIdentifierType> & AbstractIdentifierCreator
|
|
177
|
+
>;
|
|
97
178
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { IdentifierExtensionConstructor, IdentifierValidatorConstructor } from "./abstract-identifier-creator.js";
|
|
2
|
+
import {
|
|
3
|
+
MixinAbstractNumericIdentifierCreator,
|
|
4
|
+
type NumericIdentifierCreatorConstructor
|
|
5
|
+
} from "./abstract-numeric-identifier-creator.js";
|
|
6
|
+
import type { IdentifierTypeValidator } from "./identifier-validators.js";
|
|
7
|
+
import type { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator.js";
|
|
8
|
+
import type { NonGTINNumericIdentifierType } from "./non-gtin-numeric-identifier-type.js";
|
|
9
|
+
import type { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
|
|
10
|
+
import type { NumericIdentifierValidation } from "./numeric-identifier-validator.js";
|
|
11
|
+
import type { PrefixProvider } from "./prefix-provider.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Non-GTIN numeric identifier creator constructor type, which delegates to a non-GTIN numeric identifier validator
|
|
15
|
+
* constructor.
|
|
16
|
+
*
|
|
17
|
+
* @template TNonGTINNumericIdentifierType
|
|
18
|
+
* Non-GTIN numeric identifier type type.
|
|
19
|
+
*
|
|
20
|
+
* @template TNonGTINNumericIdentifierValidator
|
|
21
|
+
* Non-GTIN numeric identifier validator type.
|
|
22
|
+
*/
|
|
23
|
+
type NonGTINNumericIdentifierCreatorConstructor<
|
|
24
|
+
TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType,
|
|
25
|
+
TNonGTINNumericIdentifierValidator extends NonGTINNumericIdentifierValidator<TNonGTINNumericIdentifierType>
|
|
26
|
+
> = IdentifierExtensionConstructor<
|
|
27
|
+
[prefixProvider: PrefixProvider, identifierType: TNonGTINNumericIdentifierType],
|
|
28
|
+
TNonGTINNumericIdentifierValidator & NonGTINNumericIdentifierCreator<TNonGTINNumericIdentifierType>
|
|
29
|
+
>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Mixin implementation of {@linkcode NonGTINNumericIdentifierCreator} with an appropriate non-GTIN numeric identifier
|
|
33
|
+
* validator base.
|
|
34
|
+
*
|
|
35
|
+
* @template TNonGTINNumericIdentifierType
|
|
36
|
+
* Non-GTIN numeric identifier type type.
|
|
37
|
+
*
|
|
38
|
+
* @template TNonGTINNumericIdentifierValidatorConstructor
|
|
39
|
+
* Non-GTIN numeric identifier validator constructor type.
|
|
40
|
+
*
|
|
41
|
+
* @param NonGTINNumericIdentifierValidatorBase
|
|
42
|
+
* Non-GTIN numeric identifier validator base.
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
* Non-GTIN numeric identifier creator class.
|
|
46
|
+
*/
|
|
47
|
+
export function MixinAbstractNonGTINNumericIdentifierCreator<
|
|
48
|
+
TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType,
|
|
49
|
+
TNonGTINNumericIdentifierValidatorConstructor extends IdentifierValidatorConstructor<
|
|
50
|
+
[TNonGTINNumericIdentifierType],
|
|
51
|
+
TNonGTINNumericIdentifierType,
|
|
52
|
+
NumericIdentifierValidation
|
|
53
|
+
>
|
|
54
|
+
>(NonGTINNumericIdentifierValidatorBase: TNonGTINNumericIdentifierValidatorConstructor): NonGTINNumericIdentifierCreatorConstructor<
|
|
55
|
+
TNonGTINNumericIdentifierType,
|
|
56
|
+
IdentifierTypeValidator<TNonGTINNumericIdentifierType>
|
|
57
|
+
> {
|
|
58
|
+
/**
|
|
59
|
+
* Abstract non-GTIN numeric identifier creator. Implements common functionality for a non-GTIN numeric identifier
|
|
60
|
+
* creator, mixed in with a matching non-GTIN numeric identifier validator.
|
|
61
|
+
*/
|
|
62
|
+
abstract class AbstractNonGTINNumericIdentifierCreator extends (MixinAbstractNumericIdentifierCreator(NonGTINNumericIdentifierValidatorBase) as NumericIdentifierCreatorConstructor<
|
|
63
|
+
[TNonGTINNumericIdentifierType],
|
|
64
|
+
TNonGTINNumericIdentifierType,
|
|
65
|
+
NonGTINNumericIdentifierValidator<TNonGTINNumericIdentifierType>
|
|
66
|
+
>) implements NonGTINNumericIdentifierCreator<TNonGTINNumericIdentifierType> {
|
|
67
|
+
/**
|
|
68
|
+
* Constructor.
|
|
69
|
+
*
|
|
70
|
+
* @param prefixProvider
|
|
71
|
+
* Prefix provider.
|
|
72
|
+
*
|
|
73
|
+
* @param identifierType
|
|
74
|
+
* Identifier type.
|
|
75
|
+
*/
|
|
76
|
+
constructor(prefixProvider: PrefixProvider, identifierType: TNonGTINNumericIdentifierType) {
|
|
77
|
+
super(prefixProvider, prefixProvider.gs1CompanyPrefix, identifierType);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Base class was upcast to type with statically known members for mixin, downcast result.
|
|
82
|
+
return AbstractNonGTINNumericIdentifierCreator as IdentifierExtensionConstructor<
|
|
83
|
+
ConstructorParameters<typeof AbstractNonGTINNumericIdentifierCreator>,
|
|
84
|
+
IdentifierTypeValidator<TNonGTINNumericIdentifierType> & AbstractNonGTINNumericIdentifierCreator
|
|
85
|
+
>;
|
|
86
|
+
}
|