@aidc-toolkit/gs1 1.0.42-beta → 1.0.43

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.
Files changed (227) hide show
  1. package/dist/index.cjs +19 -0
  2. package/dist/index.d.cts +2205 -0
  3. package/dist/index.d.ts +2205 -63
  4. package/dist/index.js +3 -36
  5. package/package.json +4 -4
  6. package/src/gcp-length.ts +55 -18
  7. package/test/gcp-length.test.ts +12 -7
  8. package/tsconfig-src.tsbuildinfo +1 -1
  9. package/dist/abstract-identifier-creator.d.ts +0 -41
  10. package/dist/abstract-identifier-creator.d.ts.map +0 -1
  11. package/dist/abstract-identifier-creator.js +0 -73
  12. package/dist/abstract-identifier-creator.js.map +0 -1
  13. package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts +0 -36
  14. package/dist/abstract-non-gtin-numeric-identifier-creator.d.ts.map +0 -1
  15. package/dist/abstract-non-gtin-numeric-identifier-creator.js +0 -37
  16. package/dist/abstract-non-gtin-numeric-identifier-creator.js.map +0 -1
  17. package/dist/abstract-numeric-identifier-creator.d.ts +0 -34
  18. package/dist/abstract-numeric-identifier-creator.d.ts.map +0 -1
  19. package/dist/abstract-numeric-identifier-creator.js +0 -154
  20. package/dist/abstract-numeric-identifier-creator.js.map +0 -1
  21. package/dist/character-set.d.ts +0 -27
  22. package/dist/character-set.d.ts.map +0 -1
  23. package/dist/character-set.js +0 -83
  24. package/dist/character-set.js.map +0 -1
  25. package/dist/check.d.ts +0 -81
  26. package/dist/check.d.ts.map +0 -1
  27. package/dist/check.js +0 -218
  28. package/dist/check.js.map +0 -1
  29. package/dist/content-character-set-creators.d.ts +0 -4
  30. package/dist/content-character-set-creators.d.ts.map +0 -1
  31. package/dist/content-character-set-creators.js +0 -9
  32. package/dist/content-character-set-creators.js.map +0 -1
  33. package/dist/content-character-set.d.ts +0 -26
  34. package/dist/content-character-set.d.ts.map +0 -1
  35. package/dist/content-character-set.js +0 -18
  36. package/dist/content-character-set.js.map +0 -1
  37. package/dist/gcp-length-cache.d.ts +0 -86
  38. package/dist/gcp-length-cache.d.ts.map +0 -1
  39. package/dist/gcp-length-cache.js +0 -237
  40. package/dist/gcp-length-cache.js.map +0 -1
  41. package/dist/gcp-length-data.d.ts +0 -108
  42. package/dist/gcp-length-data.d.ts.map +0 -1
  43. package/dist/gcp-length-data.js +0 -53
  44. package/dist/gcp-length-data.js.map +0 -1
  45. package/dist/gcp-length-tree.d.ts +0 -33
  46. package/dist/gcp-length-tree.d.ts.map +0 -1
  47. package/dist/gcp-length-tree.js +0 -13
  48. package/dist/gcp-length-tree.js.map +0 -1
  49. package/dist/gcp-length.d.ts +0 -75
  50. package/dist/gcp-length.d.ts.map +0 -1
  51. package/dist/gcp-length.js +0 -357
  52. package/dist/gcp-length.js.map +0 -1
  53. package/dist/gtin-creator.d.ts +0 -47
  54. package/dist/gtin-creator.d.ts.map +0 -1
  55. package/dist/gtin-creator.js +0 -64
  56. package/dist/gtin-creator.js.map +0 -1
  57. package/dist/gtin-descriptor.d.ts +0 -22
  58. package/dist/gtin-descriptor.d.ts.map +0 -1
  59. package/dist/gtin-descriptor.js +0 -2
  60. package/dist/gtin-descriptor.js.map +0 -1
  61. package/dist/gtin-length.d.ts +0 -64
  62. package/dist/gtin-length.d.ts.map +0 -1
  63. package/dist/gtin-length.js +0 -36
  64. package/dist/gtin-length.js.map +0 -1
  65. package/dist/gtin-type.d.ts +0 -26
  66. package/dist/gtin-type.d.ts.map +0 -1
  67. package/dist/gtin-type.js +0 -7
  68. package/dist/gtin-type.js.map +0 -1
  69. package/dist/gtin-validator.d.ts +0 -132
  70. package/dist/gtin-validator.d.ts.map +0 -1
  71. package/dist/gtin-validator.js +0 -349
  72. package/dist/gtin-validator.js.map +0 -1
  73. package/dist/identifier-creator.d.ts +0 -31
  74. package/dist/identifier-creator.d.ts.map +0 -1
  75. package/dist/identifier-creator.js +0 -2
  76. package/dist/identifier-creator.js.map +0 -1
  77. package/dist/identifier-creators.d.ts +0 -118
  78. package/dist/identifier-creators.d.ts.map +0 -1
  79. package/dist/identifier-creators.js +0 -92
  80. package/dist/identifier-creators.js.map +0 -1
  81. package/dist/identifier-descriptor.d.ts +0 -27
  82. package/dist/identifier-descriptor.d.ts.map +0 -1
  83. package/dist/identifier-descriptor.js +0 -2
  84. package/dist/identifier-descriptor.js.map +0 -1
  85. package/dist/identifier-descriptors.d.ts +0 -106
  86. package/dist/identifier-descriptors.d.ts.map +0 -1
  87. package/dist/identifier-descriptors.js +0 -262
  88. package/dist/identifier-descriptors.js.map +0 -1
  89. package/dist/identifier-extension.d.ts +0 -82
  90. package/dist/identifier-extension.d.ts.map +0 -1
  91. package/dist/identifier-extension.js +0 -79
  92. package/dist/identifier-extension.js.map +0 -1
  93. package/dist/identifier-type.d.ts +0 -62
  94. package/dist/identifier-type.d.ts.map +0 -1
  95. package/dist/identifier-type.js +0 -54
  96. package/dist/identifier-type.js.map +0 -1
  97. package/dist/identifier-validator.d.ts +0 -85
  98. package/dist/identifier-validator.d.ts.map +0 -1
  99. package/dist/identifier-validator.js +0 -107
  100. package/dist/identifier-validator.js.map +0 -1
  101. package/dist/identifier-validators.d.ts +0 -131
  102. package/dist/identifier-validators.d.ts.map +0 -1
  103. package/dist/identifier-validators.js +0 -167
  104. package/dist/identifier-validators.js.map +0 -1
  105. package/dist/index.d.ts.map +0 -1
  106. package/dist/index.js.map +0 -1
  107. package/dist/leader-type.d.ts +0 -26
  108. package/dist/leader-type.d.ts.map +0 -1
  109. package/dist/leader-type.js +0 -18
  110. package/dist/leader-type.js.map +0 -1
  111. package/dist/locale/en/locale-resources.d.ts +0 -48
  112. package/dist/locale/en/locale-resources.d.ts.map +0 -1
  113. package/dist/locale/en/locale-resources.js +0 -47
  114. package/dist/locale/en/locale-resources.js.map +0 -1
  115. package/dist/locale/fr/locale-resources.d.ts +0 -48
  116. package/dist/locale/fr/locale-resources.d.ts.map +0 -1
  117. package/dist/locale/fr/locale-resources.js +0 -47
  118. package/dist/locale/fr/locale-resources.js.map +0 -1
  119. package/dist/locale/i18n.d.ts +0 -27
  120. package/dist/locale/i18n.d.ts.map +0 -1
  121. package/dist/locale/i18n.js +0 -35
  122. package/dist/locale/i18n.js.map +0 -1
  123. package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -12
  124. package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
  125. package/dist/non-gtin-numeric-identifier-creator.js +0 -2
  126. package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
  127. package/dist/non-gtin-numeric-identifier-descriptor.d.ts +0 -22
  128. package/dist/non-gtin-numeric-identifier-descriptor.d.ts.map +0 -1
  129. package/dist/non-gtin-numeric-identifier-descriptor.js +0 -2
  130. package/dist/non-gtin-numeric-identifier-descriptor.js.map +0 -1
  131. package/dist/non-gtin-numeric-identifier-type.d.ts +0 -26
  132. package/dist/non-gtin-numeric-identifier-type.d.ts.map +0 -1
  133. package/dist/non-gtin-numeric-identifier-type.js +0 -8
  134. package/dist/non-gtin-numeric-identifier-type.js.map +0 -1
  135. package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -12
  136. package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
  137. package/dist/non-gtin-numeric-identifier-validator.js +0 -10
  138. package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
  139. package/dist/non-numeric-identifier-creator.d.ts +0 -40
  140. package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
  141. package/dist/non-numeric-identifier-creator.js +0 -82
  142. package/dist/non-numeric-identifier-creator.js.map +0 -1
  143. package/dist/non-numeric-identifier-descriptor.d.ts +0 -26
  144. package/dist/non-numeric-identifier-descriptor.d.ts.map +0 -1
  145. package/dist/non-numeric-identifier-descriptor.js +0 -2
  146. package/dist/non-numeric-identifier-descriptor.js.map +0 -1
  147. package/dist/non-numeric-identifier-type.d.ts +0 -26
  148. package/dist/non-numeric-identifier-type.d.ts.map +0 -1
  149. package/dist/non-numeric-identifier-type.js +0 -8
  150. package/dist/non-numeric-identifier-type.js.map +0 -1
  151. package/dist/non-numeric-identifier-validator.d.ts +0 -41
  152. package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
  153. package/dist/non-numeric-identifier-validator.js +0 -69
  154. package/dist/non-numeric-identifier-validator.js.map +0 -1
  155. package/dist/non-serializable-numeric-identifier-creator.d.ts +0 -10
  156. package/dist/non-serializable-numeric-identifier-creator.d.ts.map +0 -1
  157. package/dist/non-serializable-numeric-identifier-creator.js +0 -8
  158. package/dist/non-serializable-numeric-identifier-creator.js.map +0 -1
  159. package/dist/non-serializable-numeric-identifier-descriptor.d.ts +0 -12
  160. package/dist/non-serializable-numeric-identifier-descriptor.d.ts.map +0 -1
  161. package/dist/non-serializable-numeric-identifier-descriptor.js +0 -2
  162. package/dist/non-serializable-numeric-identifier-descriptor.js.map +0 -1
  163. package/dist/non-serializable-numeric-identifier-type.d.ts +0 -26
  164. package/dist/non-serializable-numeric-identifier-type.d.ts.map +0 -1
  165. package/dist/non-serializable-numeric-identifier-type.js +0 -7
  166. package/dist/non-serializable-numeric-identifier-type.js.map +0 -1
  167. package/dist/non-serializable-numeric-identifier-validator.d.ts +0 -16
  168. package/dist/non-serializable-numeric-identifier-validator.d.ts.map +0 -1
  169. package/dist/non-serializable-numeric-identifier-validator.js +0 -17
  170. package/dist/non-serializable-numeric-identifier-validator.js.map +0 -1
  171. package/dist/numeric-identifier-creator.d.ts +0 -53
  172. package/dist/numeric-identifier-creator.d.ts.map +0 -1
  173. package/dist/numeric-identifier-creator.js +0 -2
  174. package/dist/numeric-identifier-creator.js.map +0 -1
  175. package/dist/numeric-identifier-descriptor.d.ts +0 -22
  176. package/dist/numeric-identifier-descriptor.d.ts.map +0 -1
  177. package/dist/numeric-identifier-descriptor.js +0 -2
  178. package/dist/numeric-identifier-descriptor.js.map +0 -1
  179. package/dist/numeric-identifier-type.d.ts +0 -26
  180. package/dist/numeric-identifier-type.d.ts.map +0 -1
  181. package/dist/numeric-identifier-type.js +0 -7
  182. package/dist/numeric-identifier-type.js.map +0 -1
  183. package/dist/numeric-identifier-validator.d.ts +0 -38
  184. package/dist/numeric-identifier-validator.d.ts.map +0 -1
  185. package/dist/numeric-identifier-validator.js +0 -61
  186. package/dist/numeric-identifier-validator.js.map +0 -1
  187. package/dist/prefix-manager.d.ts +0 -151
  188. package/dist/prefix-manager.d.ts.map +0 -1
  189. package/dist/prefix-manager.js +0 -297
  190. package/dist/prefix-manager.js.map +0 -1
  191. package/dist/prefix-provider.d.ts +0 -27
  192. package/dist/prefix-provider.d.ts.map +0 -1
  193. package/dist/prefix-provider.js +0 -2
  194. package/dist/prefix-provider.js.map +0 -1
  195. package/dist/prefix-type.d.ts +0 -26
  196. package/dist/prefix-type.d.ts.map +0 -1
  197. package/dist/prefix-type.js +0 -18
  198. package/dist/prefix-type.js.map +0 -1
  199. package/dist/prefix-validator.d.ts +0 -71
  200. package/dist/prefix-validator.d.ts.map +0 -1
  201. package/dist/prefix-validator.js +0 -204
  202. package/dist/prefix-validator.js.map +0 -1
  203. package/dist/serializable-numeric-identifier-creator.d.ts +0 -48
  204. package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
  205. package/dist/serializable-numeric-identifier-creator.js +0 -93
  206. package/dist/serializable-numeric-identifier-creator.js.map +0 -1
  207. package/dist/serializable-numeric-identifier-descriptor.d.ts +0 -26
  208. package/dist/serializable-numeric-identifier-descriptor.d.ts.map +0 -1
  209. package/dist/serializable-numeric-identifier-descriptor.js +0 -2
  210. package/dist/serializable-numeric-identifier-descriptor.js.map +0 -1
  211. package/dist/serializable-numeric-identifier-type.d.ts +0 -26
  212. package/dist/serializable-numeric-identifier-type.d.ts.map +0 -1
  213. package/dist/serializable-numeric-identifier-type.js +0 -8
  214. package/dist/serializable-numeric-identifier-type.js.map +0 -1
  215. package/dist/serializable-numeric-identifier-validator.d.ts +0 -67
  216. package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
  217. package/dist/serializable-numeric-identifier-validator.js +0 -97
  218. package/dist/serializable-numeric-identifier-validator.js.map +0 -1
  219. package/dist/variable-measure.d.ts +0 -68
  220. package/dist/variable-measure.d.ts.map +0 -1
  221. package/dist/variable-measure.js +0 -210
  222. package/dist/variable-measure.js.map +0 -1
  223. package/dist/verified-by-gs1.d.ts +0 -22
  224. package/dist/verified-by-gs1.d.ts.map +0 -1
  225. package/dist/verified-by-gs1.js +0 -46
  226. package/dist/verified-by-gs1.js.map +0 -1
  227. package/src/gcp-length-tree.ts +0 -39
package/dist/index.d.ts CHANGED
@@ -1,63 +1,2205 @@
1
- /*!
2
- * Copyright © 2024-2026 Dolphin Data Development Ltd. and AIDC Toolkit
3
- * contributors
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * https://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- export * from "./locale/i18n.js";
18
- export * from "./character-set.js";
19
- export * from "./check.js";
20
- export * from "./prefix-type.js";
21
- export type * from "./prefix-provider.js";
22
- export * from "./prefix-validator.js";
23
- export * from "./content-character-set.js";
24
- export * from "./identifier-type.js";
25
- export * from "./leader-type.js";
26
- export * from "./numeric-identifier-type.js";
27
- export * from "./gtin-type.js";
28
- export * from "./non-gtin-numeric-identifier-type.js";
29
- export * from "./non-serializable-numeric-identifier-type.js";
30
- export * from "./serializable-numeric-identifier-type.js";
31
- export * from "./non-numeric-identifier-type.js";
32
- export type * from "./identifier-descriptor.js";
33
- export type * from "./numeric-identifier-descriptor.js";
34
- export * from "./gtin-length.js";
35
- export type * from "./gtin-descriptor.js";
36
- export type * from "./non-gtin-numeric-identifier-descriptor.js";
37
- export type * from "./non-serializable-numeric-identifier-descriptor.js";
38
- export type * from "./serializable-numeric-identifier-descriptor.js";
39
- export type * from "./non-numeric-identifier-descriptor.js";
40
- export * from "./identifier-descriptors.js";
41
- export * from "./identifier-validator.js";
42
- export * from "./numeric-identifier-validator.js";
43
- export { GTINLevels, type GTINLevelKey, type GTINLevel, GTINValidator } from "./gtin-validator.js";
44
- export * from "./non-gtin-numeric-identifier-validator.js";
45
- export * from "./non-serializable-numeric-identifier-validator.js";
46
- export * from "./serializable-numeric-identifier-validator.js";
47
- export * from "./non-numeric-identifier-validator.js";
48
- export * from "./identifier-validators.js";
49
- export * from "./verified-by-gs1.js";
50
- export type * from "./identifier-creator.js";
51
- export type * from "./numeric-identifier-creator.js";
52
- export * from "./gtin-creator.js";
53
- export type * from "./non-gtin-numeric-identifier-creator.js";
54
- export * from "./non-serializable-numeric-identifier-creator.js";
55
- export * from "./serializable-numeric-identifier-creator.js";
56
- export * from "./non-numeric-identifier-creator.js";
57
- export * from "./identifier-creators.js";
58
- export * from "./variable-measure.js";
59
- export * from "./prefix-manager.js";
60
- export * from "./gcp-length-data.js";
61
- export * from "./gcp-length-cache.js";
62
- export * from "./gcp-length.js";
63
- //# sourceMappingURL=index.d.ts.map
1
+ import { I18nEnvironment, Hyperlink, AbstractConstructor, AppData, Cache, AppDataStorage } from '@aidc-toolkit/core';
2
+ import { Resource, i18n, ParseKeys } from 'i18next';
3
+ import { CharacterSetCreator, CharacterSetValidator, CharacterSetValidation, StringValidation, StringValidator, Exclusions, TransformerInput, TransformerOutput } from '@aidc-toolkit/utility';
4
+
5
+ declare const _default: {
6
+ AI64CharacterSetValidator: {
7
+ lengthMustBeMultipleOf4: string;
8
+ };
9
+ Check: {
10
+ lengthOfStringForPriceOrWeightMustBeExactly: string;
11
+ priceOrWeightComponent: string;
12
+ lengthOfStringForCheckCharacterPairMustBeLessThanOrEqualTo: string;
13
+ };
14
+ Identifier: {
15
+ identifierTypeLength: string;
16
+ invalidCheckDigit: string;
17
+ invalidGTINLength: string;
18
+ invalidGTIN14Length: string;
19
+ invalidZeroSuppressedGTIN12: string;
20
+ invalidZeroSuppressibleGTIN12: string;
21
+ invalidZeroSuppressedGTIN12AsGTIN13: string;
22
+ invalidZeroSuppressedGTIN12AsGTIN14: string;
23
+ invalidGTINAtRetail: string;
24
+ invalidGTINAtOtherThanRetail: string;
25
+ invalidRCNLength: string;
26
+ invalidVariableMeasureRCNFormat: string;
27
+ invalidVariableMeasureRCNPrefix: string;
28
+ invalidVariableMeasurePriceOrWeight: string;
29
+ indicatorDigit: string;
30
+ serialComponent: string;
31
+ reference: string;
32
+ referenceCantBeAllNumeric: string;
33
+ invalidCheckCharacterPair: string;
34
+ };
35
+ Prefix: {
36
+ gs1CompanyPrefix: string;
37
+ upcCompanyPrefix: string;
38
+ gs18Prefix: string;
39
+ gs1CompanyPrefixCantStartWith0: string;
40
+ gs1CompanyPrefixCantStartWith00000: string;
41
+ gs1CompanyPrefixCantStartWith000000: string;
42
+ upcCompanyPrefixCantStartWith0000: string;
43
+ gs18PrefixCantStartWith0: string;
44
+ identifierTypeNotSupportedByGS18Prefix: string;
45
+ };
46
+ GCPLength: {
47
+ gs1CompanyPrefixLengthDataFileNotFound: string;
48
+ gs1CompanyPrefixLengthDataNotLoaded: string;
49
+ };
50
+ };
51
+
52
+ declare const gs1NS = "aidct_gs1";
53
+ /**
54
+ * Locale strings type is extracted from the English locale strings object.
55
+ */
56
+ type GS1LocaleResources = typeof _default;
57
+ /**
58
+ * GS1 resource bundle.
59
+ */
60
+ declare const gs1ResourceBundle: Resource;
61
+ declare const i18nextGS1: i18n;
62
+ /**
63
+ * Initialize internationalization.
64
+ *
65
+ * @param environment
66
+ * Environment in which the application is running.
67
+ *
68
+ * @param debug
69
+ * Debug setting.
70
+ *
71
+ * @returns
72
+ * GS1 resource bundle.
73
+ */
74
+ declare function i18nGS1Init(environment: I18nEnvironment, debug?: boolean): Promise<Resource>;
75
+
76
+ /**
77
+ * GS1 AI encodable character set 82 creator as defined in section 7.11 of the {@link
78
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
79
+ */
80
+ declare const AI82_CREATOR: CharacterSetCreator;
81
+ /**
82
+ * GS1 AI encodable character set 82 validator as defined in section 7.11 of the {@link
83
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
84
+ */
85
+ declare const AI82_VALIDATOR: CharacterSetValidator;
86
+ /**
87
+ * GS1 AI encodable character set 39 creator as defined in section 7.11 of the {@link
88
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
89
+ */
90
+ declare const AI39_CREATOR: CharacterSetCreator;
91
+ /**
92
+ * GS1 AI encodable character set 39 validator as defined in section 7.11 of the {@link
93
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Supports {@linkcode Exclusions.AllNumeric}.
94
+ */
95
+ declare const AI39_VALIDATOR: CharacterSetValidator;
96
+ /**
97
+ * GS1 AI encodable character set 64 validator as defined in section 7.11 of the {@link
98
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Doesn't support any exclusions.
99
+ */
100
+ declare const AI64_VALIDATOR: CharacterSetValidator;
101
+
102
+ /**
103
+ * Calculate the check digit sum for a numeric string as per section 7.9.1 of the {@link
104
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
105
+ *
106
+ * @param exchangeWeights
107
+ * If true, start the weights at 1 instead of 3 on the right.
108
+ *
109
+ * @param s
110
+ * Numeric string.
111
+ *
112
+ * @returns
113
+ * Accumulated sum of each digit multiplied by the weight at its position.
114
+ */
115
+ declare function checkDigitSum(exchangeWeights: boolean, s: string): number;
116
+ /**
117
+ * Calculate the check digit for a numeric string as per section 7.9.1 of the {@link
118
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
119
+ *
120
+ * @param s
121
+ * Numeric string.
122
+ *
123
+ * @returns
124
+ * Check digit 0-9 as a string.
125
+ */
126
+ declare function checkDigit(s: string): string;
127
+ /**
128
+ * Determine if a numeric string has a valid check digit.
129
+ *
130
+ * @param s
131
+ * Numeric string with check digit.
132
+ *
133
+ * @returns
134
+ * True if the check digit is valid.
135
+ */
136
+ declare function hasValidCheckDigit(s: string): boolean;
137
+ /**
138
+ * 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
139
+ * {@link https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
140
+ *
141
+ * @param s
142
+ * Numeric string exactly four or five characters long.
143
+ *
144
+ * @returns
145
+ * Check digit 0-9 as a string.
146
+ */
147
+ declare function priceOrWeightCheckDigit(s: string): string;
148
+ /**
149
+ * Determine if a price or weight check digit is valid for numeric string.
150
+ *
151
+ * @param s
152
+ * Numeric string exactly four or five characters long.
153
+ *
154
+ * @param checkDigit
155
+ * Price or weight check digit.
156
+ *
157
+ * @returns
158
+ * True if the check digit is valid.
159
+ */
160
+ declare function isValidPriceOrWeightCheckDigit(s: string, checkDigit: string): boolean;
161
+ /**
162
+ * Calculate the check character for a GS1 AI encodable character set 82 string as per section 7.9.5 of the {@link
163
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
164
+ *
165
+ * @param s
166
+ * GS1 AI encodable character set 82 string.
167
+ *
168
+ * @returns
169
+ * Check character pair.
170
+ */
171
+ declare function checkCharacterPair(s: string): string;
172
+ /**
173
+ * Determine if a GS1 AI encodable character set 82 string has a valid check character pair.
174
+ *
175
+ * @param s
176
+ * GS1 AI encodable character set 82 string with check character pair.
177
+ *
178
+ * @returns
179
+ * True if the check character pair is valid.
180
+ */
181
+ declare function hasValidCheckCharacterPair(s: string): boolean;
182
+
183
+ /**
184
+ * Prefix types.
185
+ */
186
+ declare const PrefixTypes: {
187
+ /**
188
+ * GS1 Company Prefix.
189
+ */
190
+ readonly GS1CompanyPrefix: "GS1 Company Prefix";
191
+ /**
192
+ * U.P.C. Company Prefix.
193
+ */
194
+ readonly UPCCompanyPrefix: "U.P.C. Company Prefix";
195
+ /**
196
+ * GS1-8 Prefix.
197
+ */
198
+ readonly GS18Prefix: "GS1-8 Prefix";
199
+ };
200
+ /**
201
+ * Prefix type key.
202
+ */
203
+ type PrefixTypeKey = keyof typeof PrefixTypes;
204
+ /**
205
+ * Prefix type.
206
+ */
207
+ type PrefixType = typeof PrefixTypes[PrefixTypeKey];
208
+
209
+ /**
210
+ * Prefix provider.
211
+ */
212
+ interface PrefixProvider {
213
+ /**
214
+ * Prefix type.
215
+ */
216
+ readonly prefixType: PrefixType;
217
+ /**
218
+ * Prefix appropriate to the prefix type.
219
+ */
220
+ readonly prefix: string;
221
+ /**
222
+ * Prefix as GS1 Company Prefix.
223
+ */
224
+ readonly gs1CompanyPrefix: string;
225
+ /**
226
+ * Prefix as U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
227
+ */
228
+ readonly upcCompanyPrefix: string | undefined;
229
+ /**
230
+ * Prefix as GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
231
+ */
232
+ readonly gs18Prefix: string | undefined;
233
+ }
234
+
235
+ /**
236
+ * Prefix validation parameters.
237
+ */
238
+ interface PrefixValidation extends CharacterSetValidation {
239
+ /**
240
+ * Minimum length.
241
+ */
242
+ minimumLength: number;
243
+ /**
244
+ * Maximum length.
245
+ */
246
+ maximumLength: number;
247
+ /**
248
+ * Callback to localized prefix type name.
249
+ */
250
+ component: () => string;
251
+ }
252
+ /**
253
+ * Prefix validator.
254
+ */
255
+ declare const PrefixValidator: {
256
+ readonly GS1_COMPANY_PREFIX_MINIMUM_LENGTH: 4;
257
+ readonly GS1_COMPANY_PREFIX_MAXIMUM_LENGTH: 12;
258
+ readonly UPC_COMPANY_PREFIX_MINIMUM_LENGTH: 5;
259
+ readonly UPC_COMPANY_PREFIX_MAXIMUM_LENGTH: 11;
260
+ readonly GS1_8_PREFIX_MINIMUM_LENGTH: 2;
261
+ readonly GS1_8_PREFIX_MAXIMUM_LENGTH: 7;
262
+ /**
263
+ * Validate a prefix.
264
+ *
265
+ * @param prefixType
266
+ * Prefix type.
267
+ *
268
+ * @param allowUPCCompanyPrefix
269
+ * If true, a U.P.C. Company Prefix expressed as a GS1 Company Prefix is permitted.
270
+ *
271
+ * @param allowGS18Prefix
272
+ * If true, a GS1-8 Prefix expressed as a GS1 Company Prefix is permitted.
273
+ *
274
+ * @param prefix
275
+ * Prefix.
276
+ *
277
+ * @param isFromIdentifier
278
+ * If true, the prefix is from an identifier and should be trimmed before its character set is validated.
279
+ *
280
+ * @param isNumericIdentifier
281
+ * If true, the prefix is from a numeric identifier and its character set will be validated by the caller.
282
+ *
283
+ * @param errorMessageParseKey
284
+ * Parse key for error message when validating GS1 Company Prefix type.
285
+ */
286
+ readonly validate: (prefixType: PrefixType, allowUPCCompanyPrefix: boolean, allowGS18Prefix: boolean, prefix: string, isFromIdentifier?: boolean, isNumericIdentifier?: boolean, errorMessageParseKey?: ParseKeys) => void;
287
+ /**
288
+ * Normalize a prefix.
289
+ *
290
+ * @param prefixType
291
+ * Prefix type.
292
+ *
293
+ * @param prefix
294
+ * Prefix.
295
+ *
296
+ * @returns
297
+ * Prefix provider with normalized prefix type and prefix.
298
+ */
299
+ readonly normalize: (prefixType: PrefixType, prefix: string) => PrefixProvider;
300
+ };
301
+
302
+ /**
303
+ * Character sets supported by the reference portion of an identifier or the serial component of a numeric identifier.
304
+ */
305
+ declare const ContentCharacterSets: {
306
+ /**
307
+ * Numeric.
308
+ */
309
+ readonly Numeric: "Numeric";
310
+ /**
311
+ * GS1 AI encodable character set 82.
312
+ */
313
+ readonly AI82: "AI82";
314
+ /**
315
+ * GS1 AI encodable character set 39.
316
+ */
317
+ readonly AI39: "AI39";
318
+ };
319
+ /**
320
+ * Content character set key.
321
+ */
322
+ type ContentCharacterSetKey = keyof typeof ContentCharacterSets;
323
+ /**
324
+ * Content character set.
325
+ */
326
+ type ContentCharacterSet = typeof ContentCharacterSets[ContentCharacterSetKey];
327
+
328
+ /**
329
+ * Identifier types.
330
+ */
331
+ declare const IdentifierTypes: {
332
+ /**
333
+ * Global Trade Item Number.
334
+ */
335
+ readonly GTIN: "GTIN";
336
+ /**
337
+ * Global Location Number.
338
+ */
339
+ readonly GLN: "GLN";
340
+ /**
341
+ * Serial Shipping Container Code.
342
+ */
343
+ readonly SSCC: "SSCC";
344
+ /**
345
+ * Global Returnable Asset Identifier.
346
+ */
347
+ readonly GRAI: "GRAI";
348
+ /**
349
+ * Global Individual Asset Identifier.
350
+ */
351
+ readonly GIAI: "GIAI";
352
+ /**
353
+ * Global Service Relation Number.
354
+ */
355
+ readonly GSRN: "GSRN";
356
+ /**
357
+ * Global Document Type Identifier.
358
+ */
359
+ readonly GDTI: "GDTI";
360
+ /**
361
+ * Global Identification Number for Consignment.
362
+ */
363
+ readonly GINC: "GINC";
364
+ /**
365
+ * Global Shipment Identification Number.
366
+ */
367
+ readonly GSIN: "GSIN";
368
+ /**
369
+ * Global Coupon Number.
370
+ */
371
+ readonly GCN: "GCN";
372
+ /**
373
+ * Component/Part Identifier.
374
+ */
375
+ readonly CPID: "CPID";
376
+ /**
377
+ * Global Model Number.
378
+ */
379
+ readonly GMN: "GMN";
380
+ };
381
+ /**
382
+ * Identifier type key.
383
+ */
384
+ type IdentifierTypeKey = keyof typeof IdentifierTypes;
385
+ /**
386
+ * Identifier type.
387
+ */
388
+ type IdentifierType = typeof IdentifierTypes[IdentifierTypeKey];
389
+
390
+ /**
391
+ * Leader type.
392
+ */
393
+ declare const LeaderTypes: {
394
+ /**
395
+ * No leader.
396
+ */
397
+ readonly None: "None";
398
+ /**
399
+ * Indicator digit (GTIN only).
400
+ */
401
+ readonly IndicatorDigit: "Indicator digit";
402
+ /**
403
+ * Extension digit (SSCC only).
404
+ */
405
+ readonly ExtensionDigit: "Extension digit";
406
+ };
407
+ /**
408
+ * Leader type key.
409
+ */
410
+ type LeaderTypeKey = keyof typeof LeaderTypes;
411
+ /**
412
+ * Leader type.
413
+ */
414
+ type LeaderType = typeof LeaderTypes[LeaderTypeKey];
415
+
416
+ /**
417
+ * Numeric identifier types.
418
+ */
419
+ declare const NumericIdentifierTypes: Pick<{
420
+ readonly GTIN: "GTIN";
421
+ readonly GLN: "GLN";
422
+ readonly SSCC: "SSCC";
423
+ readonly GRAI: "GRAI";
424
+ readonly GIAI: "GIAI";
425
+ readonly GSRN: "GSRN";
426
+ readonly GDTI: "GDTI";
427
+ readonly GINC: "GINC";
428
+ readonly GSIN: "GSIN";
429
+ readonly GCN: "GCN";
430
+ readonly CPID: "CPID";
431
+ readonly GMN: "GMN";
432
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">;
433
+ /**
434
+ * Numeric identifier type key.
435
+ */
436
+ type NumericIdentifierTypeKey = keyof typeof NumericIdentifierTypes;
437
+ /**
438
+ * Numeric identifier type.
439
+ */
440
+ type NumericIdentifierType = typeof NumericIdentifierTypes[NumericIdentifierTypeKey];
441
+
442
+ /**
443
+ * GTIN types.
444
+ */
445
+ declare const GTINTypes: Pick<Pick<{
446
+ readonly GTIN: "GTIN";
447
+ readonly GLN: "GLN";
448
+ readonly SSCC: "SSCC";
449
+ readonly GRAI: "GRAI";
450
+ readonly GIAI: "GIAI";
451
+ readonly GSRN: "GSRN";
452
+ readonly GDTI: "GDTI";
453
+ readonly GINC: "GINC";
454
+ readonly GSIN: "GSIN";
455
+ readonly GCN: "GCN";
456
+ readonly CPID: "CPID";
457
+ readonly GMN: "GMN";
458
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">, "GTIN">;
459
+ /**
460
+ * GTIN type key.
461
+ */
462
+ type GTINTypeKey = keyof typeof GTINTypes;
463
+ /**
464
+ * GTIN type.
465
+ */
466
+ type GTINType = typeof GTINTypes[GTINTypeKey];
467
+
468
+ /**
469
+ * Non-GTIN numeric identifier types.
470
+ */
471
+ declare const NonGTINNumericIdentifierTypes: Omit<Pick<{
472
+ readonly GTIN: "GTIN";
473
+ readonly GLN: "GLN";
474
+ readonly SSCC: "SSCC";
475
+ readonly GRAI: "GRAI";
476
+ readonly GIAI: "GIAI";
477
+ readonly GSRN: "GSRN";
478
+ readonly GDTI: "GDTI";
479
+ readonly GINC: "GINC";
480
+ readonly GSIN: "GSIN";
481
+ readonly GCN: "GCN";
482
+ readonly CPID: "CPID";
483
+ readonly GMN: "GMN";
484
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">, "GTIN">;
485
+ /**
486
+ * Non-GTIN numeric identifier type key.
487
+ */
488
+ type NonGTINNumericIdentifierTypeKey = keyof typeof NonGTINNumericIdentifierTypes;
489
+ /**
490
+ * Non-GTIN numeric identifier type.
491
+ */
492
+ type NonGTINNumericIdentifierType = typeof NonGTINNumericIdentifierTypes[NonGTINNumericIdentifierTypeKey];
493
+
494
+ /**
495
+ * Non-serializable numeric identifier types.
496
+ */
497
+ declare const NonSerializableNumericIdentifierTypes: Pick<Omit<Pick<{
498
+ readonly GTIN: "GTIN";
499
+ readonly GLN: "GLN";
500
+ readonly SSCC: "SSCC";
501
+ readonly GRAI: "GRAI";
502
+ readonly GIAI: "GIAI";
503
+ readonly GSRN: "GSRN";
504
+ readonly GDTI: "GDTI";
505
+ readonly GINC: "GINC";
506
+ readonly GSIN: "GSIN";
507
+ readonly GCN: "GCN";
508
+ readonly CPID: "CPID";
509
+ readonly GMN: "GMN";
510
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">, "GTIN">, "GLN" | "SSCC" | "GSRN" | "GSIN">;
511
+ /**
512
+ * Non-serializable numeric identifier type key.
513
+ */
514
+ type NonSerializableNumericIdentifierTypeKey = keyof typeof NonSerializableNumericIdentifierTypes;
515
+ /**
516
+ * Non-serializable numeric identifier type.
517
+ */
518
+ type NonSerializableNumericIdentifierType = typeof NonSerializableNumericIdentifierTypes[NonSerializableNumericIdentifierTypeKey];
519
+
520
+ /**
521
+ * Serializable numeric identifier types.
522
+ */
523
+ declare const SerializableNumericIdentifierTypes: Omit<Omit<Pick<{
524
+ readonly GTIN: "GTIN";
525
+ readonly GLN: "GLN";
526
+ readonly SSCC: "SSCC";
527
+ readonly GRAI: "GRAI";
528
+ readonly GIAI: "GIAI";
529
+ readonly GSRN: "GSRN";
530
+ readonly GDTI: "GDTI";
531
+ readonly GINC: "GINC";
532
+ readonly GSIN: "GSIN";
533
+ readonly GCN: "GCN";
534
+ readonly CPID: "CPID";
535
+ readonly GMN: "GMN";
536
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">, "GTIN">, "GLN" | "SSCC" | "GSRN" | "GSIN">;
537
+ /**
538
+ * Serializable numeric identifier type key.
539
+ */
540
+ type SerializableNumericIdentifierTypeKey = keyof typeof SerializableNumericIdentifierTypes;
541
+ /**
542
+ * Serializable numeric identifier type.
543
+ */
544
+ type SerializableNumericIdentifierType = typeof SerializableNumericIdentifierTypes[SerializableNumericIdentifierTypeKey];
545
+
546
+ /**
547
+ * Non-numeric identifier types.
548
+ */
549
+ declare const NonNumericIdentifierTypes: Omit<{
550
+ readonly GTIN: "GTIN";
551
+ readonly GLN: "GLN";
552
+ readonly SSCC: "SSCC";
553
+ readonly GRAI: "GRAI";
554
+ readonly GIAI: "GIAI";
555
+ readonly GSRN: "GSRN";
556
+ readonly GDTI: "GDTI";
557
+ readonly GINC: "GINC";
558
+ readonly GSIN: "GSIN";
559
+ readonly GCN: "GCN";
560
+ readonly CPID: "CPID";
561
+ readonly GMN: "GMN";
562
+ }, "GTIN" | "GLN" | "SSCC" | "GRAI" | "GSRN" | "GDTI" | "GSIN" | "GCN">;
563
+ /**
564
+ * Non-numeric identifier type key.
565
+ */
566
+ type NonNumericIdentifierTypeKey = keyof typeof NonNumericIdentifierTypes;
567
+ /**
568
+ * Non-numeric identifier type.
569
+ */
570
+ type NonNumericIdentifierType = typeof NonNumericIdentifierTypes[NonNumericIdentifierTypeKey];
571
+
572
+ /**
573
+ * Identifier descriptor. Instantiations of this type are used to parameterize validators and creators.
574
+ */
575
+ interface IdentifierDescriptor {
576
+ /**
577
+ * Identifier type. Per the GS1 General Specifications, the identifier type determines the remaining properties.
578
+ */
579
+ readonly identifierType: IdentifierType;
580
+ /**
581
+ * Prefix type supported by the identifier type. For all identifier types except the GTIN, this is a GS1 Company
582
+ * Prefix. For the GTIN, the prefix type determines the length.
583
+ */
584
+ readonly prefixType: PrefixType;
585
+ /**
586
+ * Length. For numeric identifier types, the length is fixed; for non-numeric identifier types, the length is the
587
+ * maximum.
588
+ */
589
+ readonly length: number;
590
+ /**
591
+ * Reference character set.
592
+ */
593
+ readonly referenceCharacterSet: ContentCharacterSet;
594
+ }
595
+
596
+ /**
597
+ * Numeric identifier descriptor.
598
+ */
599
+ interface NumericIdentifierDescriptor extends IdentifierDescriptor {
600
+ /**
601
+ * @inheritDoc
602
+ */
603
+ readonly identifierType: NumericIdentifierType;
604
+ /**
605
+ * @inheritDoc
606
+ */
607
+ readonly referenceCharacterSet: typeof ContentCharacterSets.Numeric;
608
+ /**
609
+ * Leader type.
610
+ */
611
+ readonly leaderType: LeaderType;
612
+ }
613
+
614
+ /**
615
+ * GTIN lengths. The numeric values are equal to the lengths of the GTINs.
616
+ */
617
+ declare const GTINLengths: {
618
+ /**
619
+ * GTIN-13.
620
+ */
621
+ readonly GTIN13: 13;
622
+ /**
623
+ * GTIN-12.
624
+ */
625
+ readonly GTIN12: 12;
626
+ /**
627
+ * GTIN-8.
628
+ */
629
+ readonly GTIN8: 8;
630
+ /**
631
+ * GTIN-14.
632
+ */
633
+ readonly GTIN14: 14;
634
+ };
635
+ /**
636
+ * GTIN length key.
637
+ */
638
+ type GTINLengthKey = keyof typeof GTINLengths;
639
+ /**
640
+ * GTIN length.
641
+ */
642
+ type GTINLength = typeof GTINLengths[GTINLengthKey];
643
+ /**
644
+ * GTIN base lengths (all except GTIN-14).
645
+ */
646
+ declare const GTINBaseLengths: Omit<{
647
+ /**
648
+ * GTIN-13.
649
+ */
650
+ readonly GTIN13: 13;
651
+ /**
652
+ * GTIN-12.
653
+ */
654
+ readonly GTIN12: 12;
655
+ /**
656
+ * GTIN-8.
657
+ */
658
+ readonly GTIN8: 8;
659
+ /**
660
+ * GTIN-14.
661
+ */
662
+ readonly GTIN14: 14;
663
+ }, "GTIN14">;
664
+ /**
665
+ * GTIN base length key.
666
+ */
667
+ type GTINBaseLengthKey = keyof typeof GTINBaseLengths;
668
+ /**
669
+ * GTIN length.
670
+ */
671
+ type GTINBaseLength = typeof GTINBaseLengths[GTINBaseLengthKey];
672
+ /**
673
+ * GTIN base lengths by prefix type. Used to determine the GTIN length supported by a prefix type.
674
+ */
675
+ declare const GTIN_BASE_TYPES: Readonly<Record<PrefixType, GTINBaseLength>>;
676
+
677
+ /**
678
+ * GTIN descriptor.
679
+ */
680
+ interface GTINDescriptor extends NumericIdentifierDescriptor {
681
+ /**
682
+ * @inheritDoc
683
+ */
684
+ readonly identifierType: GTINType;
685
+ /**
686
+ * @inheritDoc
687
+ */
688
+ readonly length: GTINBaseLength;
689
+ /**
690
+ * @inheritDoc
691
+ */
692
+ readonly leaderType: typeof LeaderTypes.IndicatorDigit;
693
+ }
694
+
695
+ /**
696
+ * Non-GTIN numeric identifier descriptor.
697
+ */
698
+ interface NonGTINNumericIdentifierDescriptor extends NumericIdentifierDescriptor {
699
+ /**
700
+ * @inheritDoc
701
+ */
702
+ readonly identifierType: NonGTINNumericIdentifierType;
703
+ /**
704
+ * @inheritDoc
705
+ */
706
+ readonly prefixType: typeof PrefixTypes.GS1CompanyPrefix;
707
+ /**
708
+ * @inheritDoc
709
+ */
710
+ readonly leaderType: Exclude<LeaderType, typeof LeaderTypes.IndicatorDigit>;
711
+ }
712
+
713
+ /**
714
+ * Non-serializable numeric identifier descriptor.
715
+ */
716
+ interface NonSerializableNumericIdentifierDescriptor extends NonGTINNumericIdentifierDescriptor {
717
+ /**
718
+ * @inheritDoc
719
+ */
720
+ readonly leaderType: typeof LeaderTypes.None | typeof LeaderTypes.ExtensionDigit;
721
+ }
722
+
723
+ /**
724
+ * Serializable numeric identifier descriptor.
725
+ */
726
+ interface SerializableNumericIdentifierDescriptor extends NonGTINNumericIdentifierDescriptor {
727
+ /**
728
+ * @inheritDoc
729
+ */
730
+ readonly identifierType: SerializableNumericIdentifierType;
731
+ /**
732
+ * @inheritDoc
733
+ */
734
+ readonly leaderType: typeof LeaderTypes.None;
735
+ /**
736
+ * Serial component length.
737
+ */
738
+ readonly serialComponentLength: number;
739
+ /**
740
+ * Serial component character set.
741
+ */
742
+ readonly serialComponentCharacterSet: ContentCharacterSet;
743
+ }
744
+
745
+ /**
746
+ * Non-numeric identifier descriptor.
747
+ */
748
+ interface NonNumericIdentifierDescriptor extends IdentifierDescriptor {
749
+ /**
750
+ * @inheritDoc
751
+ */
752
+ readonly identifierType: NonNumericIdentifierType;
753
+ /**
754
+ * @inheritDoc
755
+ */
756
+ readonly prefixType: typeof PrefixTypes.GS1CompanyPrefix;
757
+ /**
758
+ * @inheritDoc
759
+ */
760
+ readonly referenceCharacterSet: Exclude<ContentCharacterSet, typeof ContentCharacterSets.Numeric>;
761
+ /**
762
+ * True if identifier requires a check character pair.
763
+ */
764
+ readonly requiresCheckCharacterPair: boolean;
765
+ }
766
+
767
+ /**
768
+ * Identifier extension type based on identifier type type.
769
+ *
770
+ * @template TIdentifierType
771
+ * Identifier type type.
772
+ */
773
+ type IdentifierTypeExtension<TIdentifierType extends IdentifierType, TIdentifierExtension extends IdentifierDescriptor, TNumericIdentifierExtension extends TIdentifierExtension & NumericIdentifierDescriptor, TGTINExtension extends TNumericIdentifierExtension & GTINDescriptor, TNonGTINNumericIdentifierExtension extends TNumericIdentifierExtension & NonGTINNumericIdentifierDescriptor, TNonSerializableNumericIdentifierExtension extends TNonGTINNumericIdentifierExtension & NonSerializableNumericIdentifierDescriptor, TSerializableNumericIdentifierExtension extends TNonGTINNumericIdentifierExtension & SerializableNumericIdentifierDescriptor, TNonNumericIdentifierExtension extends TIdentifierExtension & NonNumericIdentifierDescriptor> = TIdentifierType extends NumericIdentifierType ? TIdentifierType extends GTINType ? TGTINExtension : TIdentifierType extends NonGTINNumericIdentifierType ? TIdentifierType extends NonSerializableNumericIdentifierType ? TNonSerializableNumericIdentifierExtension : TIdentifierType extends SerializableNumericIdentifierType ? TSerializableNumericIdentifierExtension : TNonGTINNumericIdentifierExtension : TNumericIdentifierExtension : TIdentifierType extends NonNumericIdentifierType ? TNonNumericIdentifierExtension : TIdentifierExtension;
774
+
775
+ /**
776
+ * Identifier descriptor type based on identifier type type.
777
+ *
778
+ * @template TIdentifierType
779
+ * Identifier type type.
780
+ */
781
+ type IdentifierTypeDescriptor<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<TIdentifierType, IdentifierDescriptor, NumericIdentifierDescriptor, GTINDescriptor, NonGTINNumericIdentifierDescriptor, NonSerializableNumericIdentifierDescriptor, SerializableNumericIdentifierDescriptor, NonNumericIdentifierDescriptor>;
782
+ /**
783
+ * Identifier descriptors entry type based on identifier type type.
784
+ *
785
+ * @template TIdentifierType
786
+ * Identifier type type.
787
+ */
788
+ type IdentifierDescriptorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends GTINType ? Readonly<Record<GTINBaseLength, GTINDescriptor>> : IdentifierTypeDescriptor<TIdentifierType>;
789
+ /**
790
+ * Identifier descriptors record type.
791
+ */
792
+ type IdentifierDescriptorsRecord = {
793
+ readonly [TIdentifierType in IdentifierType]: IdentifierDescriptorsEntry<TIdentifierType>;
794
+ };
795
+ /**
796
+ * Identifier descriptors for all identifier types.
797
+ */
798
+ declare const IdentifierDescriptors: IdentifierDescriptorsRecord;
799
+ /**
800
+ * Determine if identifier descriptors or descriptor is GTIN descriptors.
801
+ *
802
+ * @param identifierDescriptorsOrDescriptor
803
+ * Identifier descriptors or descriptor.
804
+ *
805
+ * @returns
806
+ * True if GTIN descriptors.
807
+ */
808
+ declare function isGTINDescriptors(identifierDescriptorsOrDescriptor: IdentifierDescriptorsEntry<IdentifierType>): identifierDescriptorsOrDescriptor is Readonly<Record<GTINBaseLength, GTINDescriptor>>;
809
+ /**
810
+ * Determine if identifier descriptor is a numeric identifier descriptor.
811
+ *
812
+ * @param identifierDescriptor
813
+ * Identifier descriptor.
814
+ *
815
+ * @returns
816
+ * True if identifier descriptor is a numeric identifier descriptor.
817
+ */
818
+ declare function isNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NumericIdentifierDescriptor;
819
+ /**
820
+ * Determine if identifier descriptor is a GTIN descriptor.
821
+ *
822
+ * @param identifierDescriptor
823
+ * Identifier descriptor.
824
+ *
825
+ * @returns
826
+ * True if identifier descriptor is a GTIN descriptor.
827
+ */
828
+ declare function isGTINDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is GTINDescriptor;
829
+ /**
830
+ * Determine if identifier descriptor is a non-GTIN numeric identifier descriptor.
831
+ *
832
+ * @param identifierDescriptor
833
+ * Identifier descriptor.
834
+ *
835
+ * @returns
836
+ * True if identifier descriptor is a non-GTIN numeric identifier descriptor.
837
+ */
838
+ declare function isNonGTINNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonGTINNumericIdentifierDescriptor;
839
+ /**
840
+ * Determine if identifier descriptor is a non-serializable numeric identifier descriptor.
841
+ *
842
+ * @param identifierDescriptor
843
+ * Identifier descriptor.
844
+ *
845
+ * @returns
846
+ * True if identifier descriptor is a non-serializable numeric identifier descriptor.
847
+ */
848
+ declare function isNonSerializableNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonSerializableNumericIdentifierDescriptor;
849
+ /**
850
+ * Determine if identifier descriptor is a serializable numeric identifier descriptor.
851
+ *
852
+ * @param identifierDescriptor
853
+ * Identifier descriptor.
854
+ *
855
+ * @returns
856
+ * True if identifier descriptor is a serializable numeric identifier descriptor.
857
+ */
858
+ declare function isSerializableNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is SerializableNumericIdentifierDescriptor;
859
+ /**
860
+ * Determine if identifier descriptor is a non-numeric identifier descriptor.
861
+ *
862
+ * @param identifierDescriptor
863
+ * Identifier descriptor.
864
+ *
865
+ * @returns
866
+ * True if identifier descriptor is a non-numeric identifier descriptor.
867
+ */
868
+ declare function isNonNumericIdentifierDescriptor(identifierDescriptor: IdentifierDescriptor): identifierDescriptor is NonNumericIdentifierDescriptor;
869
+
870
+ /**
871
+ * Identifier validation parameters.
872
+ */
873
+ interface IdentifierValidation extends StringValidation {
874
+ }
875
+ /**
876
+ * Identifier validator. Validates an identifier against its definition in section 3 of the {@link
877
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}. Implements common functionality for an
878
+ * identifier validator.
879
+ *
880
+ * @template TIdentifierType
881
+ * Identifier type type.
882
+ *
883
+ * @template TIdentifierValidation
884
+ * Identifier validation type.
885
+ */
886
+ declare abstract class IdentifierValidator<TIdentifierType extends IdentifierType = IdentifierType, TIdentifierValidation extends IdentifierValidation = IdentifierValidation> implements IdentifierDescriptor, StringValidator<TIdentifierValidation> {
887
+ #private;
888
+ /**
889
+ * Constructor.
890
+ *
891
+ * @param identifierDescriptor
892
+ * Identifier descriptor.
893
+ */
894
+ protected constructor(identifierDescriptor: IdentifierTypeDescriptor<TIdentifierType>);
895
+ /**
896
+ * Get the identifier type. Per the GS1 General Specifications, the identifier type determines the remaining
897
+ * properties.
898
+ */
899
+ get identifierType(): IdentifierTypeDescriptor<TIdentifierType>["identifierType"];
900
+ /**
901
+ * Get the prefix type supported by the identifier type. For all identifier types except the GTIN, this is a GS1
902
+ * Company Prefix. For the GTIN, the prefix type determines the length.
903
+ */
904
+ get prefixType(): IdentifierTypeDescriptor<TIdentifierType>["prefixType"];
905
+ /**
906
+ * Get the length. For numeric identifier types, the length is fixed; for alphanumeric identifier types, the length
907
+ * is the maximum.
908
+ */
909
+ get length(): IdentifierTypeDescriptor<TIdentifierType>["length"];
910
+ /**
911
+ * Get the reference character set.
912
+ */
913
+ get referenceCharacterSet(): IdentifierTypeDescriptor<TIdentifierType>["referenceCharacterSet"];
914
+ /**
915
+ * Get the reference creator.
916
+ */
917
+ get referenceCreator(): CharacterSetCreator;
918
+ /**
919
+ * Pad an identifier on the left with zero-value character for validation purposes. This is done to align an
920
+ * identifier with a position offset for any error message that may be thrown by the reference validator.
921
+ *
922
+ * @param identifier
923
+ * Identifier.
924
+ *
925
+ * @param positionOffset
926
+ * Position offset within a larger string.
927
+ *
928
+ * @returns
929
+ * Padded identifier.
930
+ */
931
+ protected padIdentifier(identifier: string, positionOffset?: number): string;
932
+ /**
933
+ * Validate the prefix within an identifier.
934
+ *
935
+ * @param partialIdentifier
936
+ * Partial identifier.
937
+ */
938
+ protected validatePrefix(partialIdentifier: string): void;
939
+ /**
940
+ * Validate an identifier and throw an error if validation fails.
941
+ *
942
+ * @param identifier
943
+ * Identifier.
944
+ *
945
+ * @param validation
946
+ * Identifier validation parameters.
947
+ */
948
+ abstract validate(identifier: string, validation?: TIdentifierValidation): void;
949
+ }
950
+
951
+ /**
952
+ * Numeric identifier validation parameters.
953
+ */
954
+ interface NumericIdentifierValidation extends IdentifierValidation {
955
+ /**
956
+ * Position offset within a larger string. Some numeric identifier types have the prefix offset by one.
957
+ */
958
+ positionOffset?: number | undefined;
959
+ }
960
+ /**
961
+ * Numeric identifier validator.
962
+ *
963
+ * @template TNumericIdentifierType
964
+ * Numeric identifier type type.
965
+ */
966
+ declare abstract class NumericIdentifierValidator<TNumericIdentifierType extends NumericIdentifierType = NumericIdentifierType> extends IdentifierValidator<TNumericIdentifierType, NumericIdentifierValidation> implements NumericIdentifierDescriptor {
967
+ #private;
968
+ /**
969
+ * Constructor.
970
+ *
971
+ * @param identifierDescriptor
972
+ * Identifier descriptor.
973
+ */
974
+ constructor(identifierDescriptor: IdentifierTypeDescriptor<TNumericIdentifierType>);
975
+ /**
976
+ * @inheritDoc
977
+ */
978
+ get leaderType(): IdentifierTypeDescriptor<TNumericIdentifierType>["leaderType"];
979
+ /**
980
+ * @inheritDoc
981
+ */
982
+ validate(identifier: string, validation?: NumericIdentifierValidation): void;
983
+ }
984
+
985
+ /**
986
+ * Levels at which GTIN is to be validated.
987
+ */
988
+ declare const GTINLevels: {
989
+ /**
990
+ * Any level (level is ignored).
991
+ */
992
+ readonly Any: 0;
993
+ /**
994
+ * Retail consumer trade item level, supporting GTIN-13, GTIN-12 (optionally zero-suppressed), and GTIN-8.
995
+ */
996
+ readonly RetailConsumer: 1;
997
+ /**
998
+ * Other than retail consumer trade item level, supporting GTIN-13, GTIN-12 (not zero-suppressed), and GTIN-14.
999
+ */
1000
+ readonly OtherThanRetailConsumer: 2;
1001
+ };
1002
+ /**
1003
+ * GTIN level key.
1004
+ */
1005
+ type GTINLevelKey = keyof typeof GTINLevels;
1006
+ /**
1007
+ * GTIN level.
1008
+ */
1009
+ type GTINLevel = typeof GTINLevels[GTINLevelKey];
1010
+ /**
1011
+ * GTIN validator.
1012
+ */
1013
+ declare class GTINValidator extends NumericIdentifierValidator<GTINType> implements GTINDescriptor {
1014
+ #private;
1015
+ /**
1016
+ * Constructor.
1017
+ *
1018
+ * @param gtinBaseLength
1019
+ * GTIN base length (all except GTIN-14).
1020
+ */
1021
+ constructor(gtinBaseLength: GTINBaseLength);
1022
+ /**
1023
+ * @inheritDoc
1024
+ */
1025
+ get prefixType(): PrefixType;
1026
+ /**
1027
+ * @inheritDoc
1028
+ */
1029
+ protected validatePrefix(partialIdentifier: string): void;
1030
+ /**
1031
+ * Zero suppress a GTIN-12.
1032
+ *
1033
+ * @param gtin12
1034
+ * GTIN-12.
1035
+ *
1036
+ * @returns
1037
+ * Zero-suppressed GTIN-12.
1038
+ */
1039
+ static zeroSuppress(gtin12: string): string;
1040
+ /**
1041
+ * Zero expand a zero-suppressed GTIN-12.
1042
+ *
1043
+ * @param zeroSuppressedGTIN12
1044
+ * Zero-suppressed GTIN-12.
1045
+ *
1046
+ * @returns
1047
+ * GTIN-12.
1048
+ */
1049
+ static zeroExpand(zeroSuppressedGTIN12: string): string;
1050
+ /**
1051
+ * Convert a GTIN of any length to a GTIN-14 with an optional indicator digit.
1052
+ *
1053
+ * @param indicatorDigit
1054
+ * Indicator digit. If blank, assumes "0" if the GTIN is not already a GTIN-14.
1055
+ *
1056
+ * @param gtin
1057
+ * GTIN.
1058
+ *
1059
+ * @returns
1060
+ * GTIN-14.
1061
+ */
1062
+ static convertToGTIN14(indicatorDigit: string, gtin: string): string;
1063
+ /**
1064
+ * Normalize a GTIN of any length.
1065
+ * - A GTIN-14 that starts with six zeros or a GTIN-13 that starts with five zeros is normalized to GTIN-8.
1066
+ * - A GTIN-14 that starts with two zeros or a GTIN-13 that starts with one zero is normalized to GTIN-12.
1067
+ * - A GTIN-14 that starts with one zero is normalized to GTIN-13.
1068
+ * - Otherwise, the GTIN is unchanged.
1069
+ *
1070
+ * @param gtin
1071
+ * GTIN.
1072
+ *
1073
+ * @returns
1074
+ * Normalized GTIN.
1075
+ */
1076
+ static normalize(gtin: string): string;
1077
+ /**
1078
+ * Validate any GTIN, optionally against a level.
1079
+ *
1080
+ * @param gtin
1081
+ * GTIN.
1082
+ *
1083
+ * @param gtinLevel
1084
+ * Level at which GTIN is to be validated.
1085
+ */
1086
+ static validateAny(gtin: string, gtinLevel?: GTINLevel): void;
1087
+ /**
1088
+ * Validate a GTIN-14.
1089
+ *
1090
+ * @param gtin14
1091
+ * GTIN-14.
1092
+ */
1093
+ static validateGTIN14(gtin14: string): void;
1094
+ }
1095
+
1096
+ /**
1097
+ * Non-GTIN numeric identifier validator.
1098
+ *
1099
+ * @template TNonGTINNumericIdentifierType
1100
+ * Non-GTIN numeric identifier type type.
1101
+ */
1102
+ declare abstract class NonGTINNumericIdentifierValidator<TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NumericIdentifierValidator<TNonGTINNumericIdentifierType> implements NonGTINNumericIdentifierDescriptor {
1103
+ }
1104
+
1105
+ /**
1106
+ * Non-serializable numeric identifier validator.
1107
+ */
1108
+ declare class NonSerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator<NonSerializableNumericIdentifierType> implements NonSerializableNumericIdentifierDescriptor {
1109
+ /**
1110
+ * Constructor.
1111
+ *
1112
+ * @param identifierType
1113
+ * Identifier type.
1114
+ */
1115
+ constructor(identifierType: NonSerializableNumericIdentifierType);
1116
+ }
1117
+
1118
+ /**
1119
+ * Serializable numeric identifier split.
1120
+ */
1121
+ interface SerializableNumericIdentifierSplit {
1122
+ /**
1123
+ * Base identifier.
1124
+ */
1125
+ baseIdentifier: string;
1126
+ /**
1127
+ * Serial component.
1128
+ */
1129
+ serialComponent: string;
1130
+ }
1131
+ /**
1132
+ * Serializable numeric identifier validator. Validates both serialized and non-serialized forms of numeric identifiers
1133
+ * that support serialization.
1134
+ */
1135
+ declare class SerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator<SerializableNumericIdentifierType> implements SerializableNumericIdentifierDescriptor {
1136
+ #private;
1137
+ /**
1138
+ * Constructor.
1139
+ *
1140
+ * @param identifierType
1141
+ * Identifier type.
1142
+ */
1143
+ constructor(identifierType: SerializableNumericIdentifierType);
1144
+ /**
1145
+ * Get the serial component length.
1146
+ */
1147
+ get serialComponentLength(): number;
1148
+ /**
1149
+ * Get the serial component character set.
1150
+ */
1151
+ get serialComponentCharacterSet(): ContentCharacterSet;
1152
+ /**
1153
+ * Get the serial component validation parameters.
1154
+ */
1155
+ protected get serialComponentValidation(): CharacterSetValidation;
1156
+ /**
1157
+ * Get the serial component creator.
1158
+ */
1159
+ get serialComponentCreator(): CharacterSetCreator;
1160
+ /**
1161
+ * @inheritDoc
1162
+ */
1163
+ validate(identifier: string, validation?: IdentifierValidation): void;
1164
+ /**
1165
+ * Split a serializable numeric identifier into its component parts.
1166
+ *
1167
+ * @param identifier
1168
+ * Identifier.
1169
+ *
1170
+ * @param validation
1171
+ * Identifier validation parameters.
1172
+ *
1173
+ * @returns
1174
+ * Base identifier and serial component (possibly empty) as object.
1175
+ */
1176
+ split(identifier: string, validation?: IdentifierValidation): SerializableNumericIdentifierSplit;
1177
+ }
1178
+
1179
+ /**
1180
+ * Non-numeric identifier validation parameters.
1181
+ */
1182
+ interface NonNumericIdentifierValidation extends IdentifierValidation {
1183
+ /**
1184
+ * Exclusion support for reference. Prevents non-numeric identifier from being mistaken for numeric identifier.
1185
+ */
1186
+ exclusion?: typeof Exclusions.None | typeof Exclusions.AllNumeric | undefined;
1187
+ }
1188
+ /**
1189
+ * Non-numeric identifier validator.
1190
+ */
1191
+ declare class NonNumericIdentifierValidator extends IdentifierValidator<NonNumericIdentifierType, NonNumericIdentifierValidation> implements NonNumericIdentifierDescriptor {
1192
+ #private;
1193
+ /**
1194
+ * Constructor.
1195
+ *
1196
+ * @param identifierType
1197
+ * Identifier type.
1198
+ */
1199
+ constructor(identifierType: NonNumericIdentifierType);
1200
+ /**
1201
+ * Determine if the identifier requires a check character pair.
1202
+ */
1203
+ get requiresCheckCharacterPair(): boolean;
1204
+ /**
1205
+ * Validate a non-numeric identifier and throw an error if validation fails.
1206
+ *
1207
+ * @param identifier
1208
+ * Identifier.
1209
+ *
1210
+ * @param validation
1211
+ * Validation parameters.
1212
+ */
1213
+ validate(identifier: string, validation?: NonNumericIdentifierValidation): void;
1214
+ }
1215
+
1216
+ /**
1217
+ * Identifier validator type based on identifier type type.
1218
+ *
1219
+ * @template TIdentifierType
1220
+ * Identifier type type.
1221
+ */
1222
+ type IdentifierTypeValidator<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<TIdentifierType, IdentifierValidator, NumericIdentifierValidator, GTINValidator, NonGTINNumericIdentifierValidator, NonSerializableNumericIdentifierValidator, SerializableNumericIdentifierValidator, NonNumericIdentifierValidator>;
1223
+ /**
1224
+ * Identifier validators entry type based on identifier type type.
1225
+ *
1226
+ * @template TIdentifierType
1227
+ * Identifier type type.
1228
+ */
1229
+ type IdentifierValidatorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends GTINType ? Readonly<Record<GTINBaseLength, GTINValidator>> : IdentifierTypeValidator<TIdentifierType>;
1230
+ /**
1231
+ * Identifier validators record type.
1232
+ */
1233
+ type IdentifierValidatorsRecord = {
1234
+ [TIdentifierType in IdentifierType]: IdentifierValidatorsEntry<TIdentifierType>;
1235
+ };
1236
+ /**
1237
+ * Identifier validators for all identifier types.
1238
+ */
1239
+ declare const IdentifierValidators: Readonly<IdentifierValidatorsRecord>;
1240
+ /**
1241
+ * GTIN validator constructor type.
1242
+ */
1243
+ type GTINValidatorConstructor = new (gtinBaseLength: GTINBaseLength) => GTINValidator;
1244
+ /**
1245
+ * Non-GTIN validator constructor type.
1246
+ *
1247
+ * @template TIdentifierType
1248
+ * Identifier type type.
1249
+ */
1250
+ type NonGTINValidatorConstructor<TIdentifierType extends Exclude<IdentifierType, GTINType>> = new (identifierType: TIdentifierType) => IdentifierValidatorsRecord[TIdentifierType];
1251
+ /**
1252
+ * Identifier validator constructors entry type based on identifier type type.
1253
+ *
1254
+ * @template TIdentifierType
1255
+ * Identifier type type.
1256
+ */
1257
+ type IdentifierValidatorConstructorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends GTINType ? GTINValidatorConstructor : NonGTINValidatorConstructor<Exclude<TIdentifierType, GTINType>>;
1258
+ /**
1259
+ * Identifier validator constructors record type.
1260
+ */
1261
+ type IdentifierValidatorConstructorsRecord = {
1262
+ readonly [TIdentifierType in IdentifierType]: IdentifierValidatorConstructorsEntry<TIdentifierType>;
1263
+ };
1264
+ declare const IdentifierValidatorConstructors: IdentifierValidatorConstructorsRecord;
1265
+ /**
1266
+ * Determine if identifier validators or validator is GTIN validators.
1267
+ *
1268
+ * @param identifierValidatorsOrValidator
1269
+ * Identifier validators or validator.
1270
+ *
1271
+ * @returns
1272
+ * True if GTIN validators.
1273
+ */
1274
+ declare function isGTINValidators(identifierValidatorsOrValidator: IdentifierValidatorsEntry<IdentifierType>): identifierValidatorsOrValidator is Readonly<Record<GTINBaseLength, GTINValidator>>;
1275
+ /**
1276
+ * Determine if identifier validator is a numeric identifier validator.
1277
+ *
1278
+ * @param identifierValidator
1279
+ * Identifier validator.
1280
+ *
1281
+ * @returns
1282
+ * True if identifier validator is a numeric identifier validator.
1283
+ */
1284
+ declare function isNumericIdentifierValidator(identifierValidator: IdentifierValidator): identifierValidator is NumericIdentifierValidator;
1285
+ /**
1286
+ * Determine if identifier validator is a GTIN validator.
1287
+ *
1288
+ * @param identifierValidator
1289
+ * Identifier validator.
1290
+ *
1291
+ * @returns
1292
+ * True if identifier validator is a GTIN validator.
1293
+ */
1294
+ declare function isGTINValidator(identifierValidator: IdentifierValidator): identifierValidator is GTINValidator;
1295
+ /**
1296
+ * Determine if identifier validator is a non-GTIN numeric identifier validator.
1297
+ *
1298
+ * @param identifierValidator
1299
+ * Identifier validator.
1300
+ *
1301
+ * @returns
1302
+ * True if identifier validator is a non-GTIN numeric identifier validator.
1303
+ */
1304
+ declare function isNonGTINNumericIdentifierValidator(identifierValidator: IdentifierValidator): identifierValidator is NonGTINNumericIdentifierValidator;
1305
+ /**
1306
+ * Determine if identifier validator is a non-serializable numeric identifier validator.
1307
+ *
1308
+ * @param identifierValidator
1309
+ * Identifier validator.
1310
+ *
1311
+ * @returns
1312
+ * True if identifier validator is a non-serializable numeric identifier validator.
1313
+ */
1314
+ declare function isNonSerializableNumericIdentifierValidator(identifierValidator: IdentifierValidator): identifierValidator is NonSerializableNumericIdentifierValidator;
1315
+ /**
1316
+ * Determine if identifier validator is a serializable numeric identifier validator.
1317
+ *
1318
+ * @param identifierValidator
1319
+ * Identifier validator.
1320
+ *
1321
+ * @returns
1322
+ * True if identifier validator is a serializable numeric identifier validator.
1323
+ */
1324
+ declare function isSerializableNumericIdentifierValidator(identifierValidator: IdentifierValidator): identifierValidator is SerializableNumericIdentifierValidator;
1325
+ /**
1326
+ * Determine if identifier validator is a non-numeric identifier validator.
1327
+ *
1328
+ * @param identifierValidator
1329
+ * Identifier validator.
1330
+ *
1331
+ * @returns
1332
+ * True if identifier validator is a non-numeric identifier validator.
1333
+ */
1334
+ declare function isNonNumericIdentifierValidator(identifierValidator: IdentifierValidator): identifierValidator is NonNumericIdentifierValidator;
1335
+
1336
+ /**
1337
+ * Create a Verified by GS1 hyperlink.
1338
+ *
1339
+ * @param identifierType
1340
+ * Identifier type.
1341
+ *
1342
+ * @param identifier
1343
+ * Identifier.
1344
+ *
1345
+ * @param text
1346
+ * Text for hyperlink. If not provided, the identifier is used.
1347
+ *
1348
+ * @param details
1349
+ * Details to display when hovering over hyperlink.
1350
+ *
1351
+ * @returns
1352
+ * Verified by GS1 hyperlink.
1353
+ */
1354
+ declare function verifiedByGS1(identifierType: IdentifierType, identifier: string, text?: string | undefined, details?: string): Hyperlink;
1355
+
1356
+ /**
1357
+ * Identifier creator. Creates an identifier based on its definition in section 3 of the {@link
1358
+ * https://ref.gs1.org/standards/genspecs/ | GS1 General Specifications}.
1359
+ *
1360
+ * Keys are created based on a prefix defined in a prefix provider to which the identifier creator is bound.
1361
+ *
1362
+ * @template TIdentifierType
1363
+ * Identifier type type.
1364
+ *
1365
+ * @template TIdentifierValidation
1366
+ * Identifier validation type.
1367
+ */
1368
+ interface IdentifierCreator<TIdentifierType extends IdentifierType = IdentifierType, TIdentifierValidation extends IdentifierValidation = IdentifierValidation> extends IdentifierValidator<TIdentifierType, TIdentifierValidation> {
1369
+ /**
1370
+ * Get the prefix provider to which this identifier creator is bound.
1371
+ */
1372
+ get prefixProvider(): PrefixProvider;
1373
+ /**
1374
+ * Get the prefix, equivalent to calling {@linkcode PrefixProvider.prefix | prefixProvider.prefix} for a GTIN or
1375
+ * {@linkcode PrefixProvider.gs1CompanyPrefix | prefixProvider.gs1CompanyPrefix} for all other identifier types.
1376
+ */
1377
+ get prefix(): string;
1378
+ /**
1379
+ * Get the reference length.
1380
+ */
1381
+ get referenceLength(): number;
1382
+ }
1383
+
1384
+ /**
1385
+ * Numeric identifier creator. Creates one or many numeric identifiers.
1386
+ *
1387
+ * @template TNumericIdentifierType
1388
+ * Numeric identifier type type.
1389
+ */
1390
+ interface NumericIdentifierCreator<TNumericIdentifierType extends NumericIdentifierType = NumericIdentifierType> extends NumericIdentifierValidator<TNumericIdentifierType>, IdentifierCreator<TNumericIdentifierType, NumericIdentifierValidation> {
1391
+ /**
1392
+ * Get the capacity (`10**referenceLength`).
1393
+ */
1394
+ get capacity(): number;
1395
+ /**
1396
+ * Get the tweak for sparse creation.
1397
+ */
1398
+ get tweak(): bigint;
1399
+ /**
1400
+ * Set the tweak for sparse creation.
1401
+ */
1402
+ set tweak(value: bigint);
1403
+ /**
1404
+ * Create identifier(s) with reference(s) based on numeric value(s). The value(s) is/are converted to references of
1405
+ * the appropriate length using {@linkcode NUMERIC_CREATOR}.
1406
+ *
1407
+ * @template TTransformerInput
1408
+ * Transformer input type.
1409
+ *
1410
+ * @param valueOrValues
1411
+ * Numeric value(s).
1412
+ *
1413
+ * @param sparse
1414
+ * If true, the value(s) are mapped to a sparse sequence resistant to discovery. Default is false.
1415
+ *
1416
+ * @returns
1417
+ * Identifier(s).
1418
+ */
1419
+ create: <TTransformerInput extends TransformerInput<number | bigint>>(valueOrValues: TTransformerInput, sparse?: boolean) => TransformerOutput<TTransformerInput, string>;
1420
+ /**
1421
+ * Create all identifiers for the prefix from `0` to `capacity - 1`.
1422
+ *
1423
+ * The implementation creates the strings only as needed using an internal generator function. Although the result
1424
+ * is equivalent to calling `creator.create(new Sequence(0, creator.capacity))`, this method is significantly
1425
+ * faster.
1426
+ *
1427
+ * @returns
1428
+ * All identifiers for the prefix.
1429
+ */
1430
+ createAll: () => Iterable<string>;
1431
+ }
1432
+
1433
+ /**
1434
+ * Numeric identifier creator constructor type, which delegates to a numeric identifier validator constructor.
1435
+ *
1436
+ * @template TNumericIdentifierType
1437
+ * Numeric identifier type type.
1438
+ *
1439
+ * @template TNumericIdentifierValidator
1440
+ * Numeric identifier validator type.
1441
+ */
1442
+ type NumericIdentifierCreatorConstructor<TNumericIdentifierType extends NumericIdentifierType, TNumericIdentifierValidator extends NumericIdentifierValidator<TNumericIdentifierType>> = AbstractConstructor<[
1443
+ prefixProvider: PrefixProvider,
1444
+ prefix: string,
1445
+ ...args: ConstructorParameters<IdentifierValidatorConstructorsEntry<TNumericIdentifierType>>
1446
+ ], TNumericIdentifierValidator & NumericIdentifierCreator<TNumericIdentifierType>>;
1447
+
1448
+ declare const GTINCreator_base: NumericIdentifierCreatorConstructor<"GTIN", GTINValidator>;
1449
+ /**
1450
+ * GTIN creator. Applicable to GTIN-13, GTIN-12, and GTIN-8 types; not applicable to GTIN-14 type.
1451
+ */
1452
+ declare class GTINCreator extends GTINCreator_base {
1453
+ #private;
1454
+ /**
1455
+ * Constructor.
1456
+ *
1457
+ * @param prefixProvider
1458
+ * Prefix provider.
1459
+ *
1460
+ * @param gtinBaseLength
1461
+ * GTIN base length (all except GTIN-14).
1462
+ */
1463
+ constructor(prefixProvider: PrefixProvider, gtinBaseLength: GTINBaseLength);
1464
+ /**
1465
+ * @inheritDoc
1466
+ */
1467
+ get prefix(): string;
1468
+ /**
1469
+ * Create GTIN-14(s) with an indicator digit and reference(s) based on numeric value(s). The value(s) is/are
1470
+ * converted to reference(s) of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1471
+ *
1472
+ * @template TTransformerInput
1473
+ * Transformer input type.
1474
+ *
1475
+ * @param indicatorDigit
1476
+ * Indicator digit.
1477
+ *
1478
+ * @param valueOrValues
1479
+ * Numeric value(s).
1480
+ *
1481
+ * @param sparse
1482
+ * If true, the value(s) is/are mapped to a sparse sequence resistant to discovery. Default is false.
1483
+ *
1484
+ * @returns
1485
+ * GTIN-14(s).
1486
+ */
1487
+ createGTIN14<TTransformerInput extends TransformerInput<number | bigint>>(indicatorDigit: string, valueOrValues: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1488
+ }
1489
+
1490
+ /**
1491
+ * Non-GTIN numeric identifier creator. Creates one or many non-GTIN numeric identifiers.
1492
+ *
1493
+ * @template TNonGTINNumericIdentifierType
1494
+ * Non-GTIN numeric identifier type type.
1495
+ */
1496
+ interface NonGTINNumericIdentifierCreator<TNonGTINNumericIdentifierType extends NonGTINNumericIdentifierType = NonGTINNumericIdentifierType> extends NonGTINNumericIdentifierValidator<TNonGTINNumericIdentifierType>, NumericIdentifierCreator<TNonGTINNumericIdentifierType> {
1497
+ }
1498
+
1499
+ declare const NonSerializableNumericIdentifierCreator_base: abstract new (...args: [prefixProvider: PrefixProvider, identifierType: "GLN"] | [prefixProvider: PrefixProvider, identifierType: "SSCC"] | [prefixProvider: PrefixProvider, identifierType: "GSRN"] | [prefixProvider: PrefixProvider, identifierType: "GSIN"]) => NonSerializableNumericIdentifierValidator & NonGTINNumericIdentifierCreator<NonSerializableNumericIdentifierType>;
1500
+ /**
1501
+ * Non-serializable numeric identifier creator.
1502
+ */
1503
+ declare class NonSerializableNumericIdentifierCreator extends NonSerializableNumericIdentifierCreator_base {
1504
+ }
1505
+
1506
+ declare const SerializableNumericIdentifierCreator_base: abstract new (...args: [prefixProvider: PrefixProvider, identifierType: "GRAI"] | [prefixProvider: PrefixProvider, identifierType: "GDTI"] | [prefixProvider: PrefixProvider, identifierType: "GCN"]) => SerializableNumericIdentifierValidator & NonGTINNumericIdentifierCreator<SerializableNumericIdentifierType>;
1507
+ /**
1508
+ * Serializable numeric identifier creator.
1509
+ */
1510
+ declare class SerializableNumericIdentifierCreator extends SerializableNumericIdentifierCreator_base {
1511
+ #private;
1512
+ /**
1513
+ * Create serialized identifier(s) with a reference based on a numeric value concatenated with serial component(s).
1514
+ * The value is converted to a reference of the appropriate length using {@linkcode NUMERIC_CREATOR}.
1515
+ *
1516
+ * @template TTransformerInput
1517
+ * Transformer input type.
1518
+ *
1519
+ * @param value
1520
+ * Numeric value of the reference.
1521
+ *
1522
+ * @param serialComponentOrComponents
1523
+ * Serial component(s).
1524
+ *
1525
+ * @param sparse
1526
+ * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
1527
+ *
1528
+ * @returns
1529
+ * Serialized identifiers.
1530
+ */
1531
+ createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
1532
+ /**
1533
+ * Concatenate a base identifier with serial component(s).
1534
+ *
1535
+ * @template TTransformerInput
1536
+ * Transformer input type.
1537
+ *
1538
+ * @param baseIdentifier
1539
+ * Base identifier.
1540
+ *
1541
+ * @param serialComponentOrComponents
1542
+ * Serial component(s).
1543
+ *
1544
+ * @returns
1545
+ * Serialized identifier(s).
1546
+ */
1547
+ concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentifier: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1548
+ }
1549
+
1550
+ /**
1551
+ * Identifier creator constructor type, which delegates to an identifier validator constructor.
1552
+ *
1553
+ * @template TIdentifierType
1554
+ * Identifier type type.
1555
+ *
1556
+ * @template TIdentifierValidation
1557
+ * Identifier validation type.
1558
+ *
1559
+ * @template TIdentifierValidator
1560
+ * Identifier validator type.
1561
+ */
1562
+ type IdentifierCreatorConstructor<TIdentifierType extends IdentifierType, TIdentifierValidation extends IdentifierValidation, TIdentifierValidator extends IdentifierValidator<TIdentifierType, TIdentifierValidation>> = AbstractConstructor<[
1563
+ prefixProvider: PrefixProvider,
1564
+ prefix: string,
1565
+ checkAllowance: number,
1566
+ ...args: ConstructorParameters<IdentifierValidatorConstructorsEntry<TIdentifierType>>
1567
+ ], TIdentifierValidator & IdentifierCreator<TIdentifierType, TIdentifierValidation>>;
1568
+
1569
+ declare const NonNumericIdentifierCreator_base: IdentifierCreatorConstructor<NonNumericIdentifierType, NonNumericIdentifierValidation, NonNumericIdentifierValidator>;
1570
+ /**
1571
+ * Non-numeric identifier creator.
1572
+ */
1573
+ declare class NonNumericIdentifierCreator extends NonNumericIdentifierCreator_base {
1574
+ #private;
1575
+ /**
1576
+ * Constructor.
1577
+ *
1578
+ * @param prefixProvider
1579
+ * Prefix provider.
1580
+ *
1581
+ * @param identifierType
1582
+ * Identifier type.
1583
+ */
1584
+ constructor(prefixProvider: PrefixProvider, identifierType: NonNumericIdentifierType);
1585
+ /**
1586
+ * Get the reference validation parameters.
1587
+ */
1588
+ protected get referenceValidation(): CharacterSetValidation;
1589
+ /**
1590
+ * Create identifier(s) with reference(s).
1591
+ *
1592
+ * @template TTransformerInput
1593
+ * Transformer input type.
1594
+ *
1595
+ * @param referenceOrReferences
1596
+ * Reference(s).
1597
+ *
1598
+ * @returns
1599
+ * Identifier(s).
1600
+ */
1601
+ create<TTransformerInput extends TransformerInput<string>>(referenceOrReferences: TTransformerInput): TransformerOutput<TTransformerInput, string>;
1602
+ }
1603
+
1604
+ /**
1605
+ * Identifier creator type based on identifier type type.
1606
+ *
1607
+ * @template TIdentifierType
1608
+ * Identifier type type.
1609
+ */
1610
+ type IdentifierTypeCreator<TIdentifierType extends IdentifierType> = IdentifierTypeExtension<TIdentifierType, IdentifierCreator, NumericIdentifierCreator, GTINCreator, NonGTINNumericIdentifierCreator, NonSerializableNumericIdentifierCreator, SerializableNumericIdentifierCreator, NonNumericIdentifierCreator>;
1611
+ /**
1612
+ * Identifier creators entry type based on identifier type type.
1613
+ *
1614
+ * @template TIdentifierType
1615
+ * Identifier type type.
1616
+ */
1617
+ type IdentifierCreatorsEntry<TIdentifierType extends IdentifierType> = IdentifierTypeCreator<TIdentifierType>;
1618
+ /**
1619
+ * Identifier creators record type.
1620
+ */
1621
+ type IdentifierCreatorsRecord = {
1622
+ [TIdentifierType in IdentifierType]: IdentifierCreatorsEntry<TIdentifierType>;
1623
+ };
1624
+ /**
1625
+ * GTIN creator constructor type.
1626
+ */
1627
+ type GTINCreatorConstructor = new (prefixProvider: PrefixProvider, gtinBaseLength: GTINBaseLength) => GTINCreator;
1628
+ /**
1629
+ * Non-GTIN creator constructor type.
1630
+ *
1631
+ * @template TIdentifierType
1632
+ * Identifier type type.
1633
+ */
1634
+ type NonGTINCreatorConstructor<TIdentifierType extends Exclude<IdentifierType, GTINType>> = new (prefixProvider: PrefixProvider, identifierType: TIdentifierType) => IdentifierCreatorsRecord[TIdentifierType];
1635
+ /**
1636
+ * Identifier creator constructors entry type based on identifier type type.
1637
+ *
1638
+ * @template TIdentifierType
1639
+ * Identifier type type.
1640
+ */
1641
+ type IdentifierCreatorConstructorsEntry<TIdentifierType extends IdentifierType> = TIdentifierType extends GTINType ? GTINCreatorConstructor : NonGTINCreatorConstructor<Exclude<TIdentifierType, GTINType>>;
1642
+ /**
1643
+ * Identifier creator constructors record type.
1644
+ */
1645
+ type IdentifierCreatorConstructorsRecord = {
1646
+ readonly [TIdentifierType in IdentifierType]: IdentifierCreatorConstructorsEntry<TIdentifierType>;
1647
+ };
1648
+ declare const IdentifierCreatorConstructors: IdentifierCreatorConstructorsRecord;
1649
+ /**
1650
+ * Determine if identifier creator is a numeric identifier creator.
1651
+ *
1652
+ * @param identifierCreator
1653
+ * Identifier creator.
1654
+ *
1655
+ * @returns
1656
+ * True if identifier creator is a numeric identifier creator.
1657
+ */
1658
+ declare function isNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NumericIdentifierCreator;
1659
+ /**
1660
+ * Determine if identifier creator is a GTIN creator.
1661
+ *
1662
+ * @param identifierCreator
1663
+ * Identifier creator.
1664
+ *
1665
+ * @returns
1666
+ * True if identifier creator is a GTIN creator.
1667
+ */
1668
+ declare function isGTINCreator(identifierCreator: IdentifierCreator): identifierCreator is GTINCreator;
1669
+ /**
1670
+ * Determine if identifier creator is a non-GTIN numeric identifier creator.
1671
+ *
1672
+ * @param identifierCreator
1673
+ * Identifier creator.
1674
+ *
1675
+ * @returns
1676
+ * True if identifier creator is a non-GTIN numeric identifier creator.
1677
+ */
1678
+ declare function isNonGTINNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonGTINNumericIdentifierCreator;
1679
+ /**
1680
+ * Determine if identifier creator is a non-serializable numeric identifier creator.
1681
+ *
1682
+ * @param identifierCreator
1683
+ * Identifier creator.
1684
+ *
1685
+ * @returns
1686
+ * True if identifier creator is a non-serializable numeric identifier creator.
1687
+ */
1688
+ declare function isNonSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonSerializableNumericIdentifierCreator;
1689
+ /**
1690
+ * Determine if identifier creator is a serializable numeric identifier creator.
1691
+ *
1692
+ * @param identifierCreator
1693
+ * Identifier creator.
1694
+ *
1695
+ * @returns
1696
+ * True if identifier creator is a serializable numeric identifier creator.
1697
+ */
1698
+ declare function isSerializableNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is SerializableNumericIdentifierCreator;
1699
+ /**
1700
+ * Determine if identifier creator is a non-numeric identifier creator.
1701
+ *
1702
+ * @param identifierCreator
1703
+ * Identifier creator.
1704
+ *
1705
+ * @returns
1706
+ * True if identifier creator is a non-numeric identifier creator.
1707
+ */
1708
+ declare function isNonNumericIdentifierCreator(identifierCreator: IdentifierCreator): identifierCreator is NonNumericIdentifierCreator;
1709
+
1710
+ /**
1711
+ * Restricted Circulation Number reference.
1712
+ */
1713
+ interface RCNReference {
1714
+ /**
1715
+ * Item reference.
1716
+ */
1717
+ itemReference: number;
1718
+ /**
1719
+ * Price or weight (whole number only).
1720
+ */
1721
+ priceOrWeight: number;
1722
+ }
1723
+ /**
1724
+ * Variable measure trade item support functions.
1725
+ */
1726
+ declare class VariableMeasure {
1727
+ /**
1728
+ * Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
1729
+ * 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
1730
+ *
1731
+ * - '2' - The first character of the RCN.
1732
+ * - '0'-'9' - The second character of the RCN (RCN-13 only).
1733
+ * - 'I' - One or more, in sequence, for the item reference.
1734
+ * - 'P' - One or more, in sequence, for the price or weight.
1735
+ * - 'V' - Zero or one, for the price or weight check digit.
1736
+ * - 'C' - The check digit of the entire RCN.
1737
+ *
1738
+ * The 'I', 'P', and 'V' formats may be in any order.
1739
+ *
1740
+ * Some examples:
1741
+ *
1742
+ * - `2IIIIIVPPPPC` - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
1743
+ * or weight.
1744
+ * - `23IIIIVPPPPPC` - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
1745
+ * or weight.
1746
+ * - `2IIIIIIPPPPC` - RCN-12 with a six-digit item reference and a four-digit price or eight.
1747
+ * - `29IIIIIPPPPPC` - RCN-13 with a five-digit item reference and a five-digit price or weight.
1748
+ *
1749
+ * @param format
1750
+ * Format.
1751
+ *
1752
+ * @param rcn
1753
+ * RCN.
1754
+ *
1755
+ * @returns
1756
+ * RCN reference.
1757
+ */
1758
+ static parseRCN(format: string, rcn: string): RCNReference;
1759
+ /**
1760
+ * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode parseRCN}
1761
+ * for format details.
1762
+ *
1763
+ * @param format
1764
+ * Format.
1765
+ *
1766
+ * @param itemReference
1767
+ * Item reference.
1768
+ *
1769
+ * @param priceOrWeight
1770
+ * Price or weight (whole number only).
1771
+ *
1772
+ * @returns
1773
+ * RCN-12 or RCN-13.
1774
+ */
1775
+ static createRCN(format: string, itemReference: number, priceOrWeight: number): string;
1776
+ }
1777
+
1778
+ /**
1779
+ * Prefix manager. This is the core class for identifier creation.
1780
+ *
1781
+ * A prefix manager may be constructed for any {@link PrefixType | prefix type}. Construction may be done directly or
1782
+ * via the static {@linkcode PrefixManager.get | get()} method, which allows for caching and reuse. As most applications
1783
+ * work with a limited number of prefixes for creating identifiers, caching and reuse may be a more efficient option.
1784
+ *
1785
+ * The prefix type and prefix are normalized before the prefix manager is constructed, so they may not match the input
1786
+ * values. For example, the GS1 Company Prefix 0614141 is equivalent to U.P.C. Company Prefix 614141; both result in a
1787
+ * prefix manager with prefix type equal to {@linkcode PrefixTypes.UPCCompanyPrefix} and prefix equal to "614141".
1788
+ *
1789
+ * To support the creation of sparse identifiers, a prefix manager maintains a {@link tweakFactor | tweak factor} which
1790
+ * is used, along with a type-specific multiplier, as the tweak when creating numeric identifiers. The default tweak
1791
+ * factor is the numeric value of the GS1 Company Prefix representation of the prefix preceded by '1' to ensure
1792
+ * uniqueness (i.e., so that prefixes 0 N1 N2 N3... and N1 N2 N3... produce different tweak factors). This is usually
1793
+ * sufficient for obfuscation, but as the sparse creation algorithm is reversible and as the GS1 Company Prefix is
1794
+ * discoverable via {@link https://www.gs1.org/services/verified-by-gs1 | Verified by GS1}, a user-defined tweak factor
1795
+ * should be used if a higher degree of obfuscation is required. When using a tweak factor other than the default, care
1796
+ * should be taken to restore it when resuming the application. A tweak factor of 0 creates a straight sequence.
1797
+ */
1798
+ declare class PrefixManager implements PrefixProvider {
1799
+ #private;
1800
+ /**
1801
+ * Constructor.
1802
+ *
1803
+ * @param prefixType
1804
+ * Prefix type.
1805
+ *
1806
+ * @param prefix
1807
+ * Prefix.
1808
+ */
1809
+ constructor(prefixType: PrefixType, prefix: string);
1810
+ /**
1811
+ * Get the prefix type.
1812
+ */
1813
+ get prefixType(): PrefixType;
1814
+ /**
1815
+ * Get the prefix.
1816
+ */
1817
+ get prefix(): string;
1818
+ /**
1819
+ * Get the GS1 Company Prefix.
1820
+ */
1821
+ get gs1CompanyPrefix(): string;
1822
+ /**
1823
+ * Get the U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
1824
+ */
1825
+ get upcCompanyPrefix(): string | undefined;
1826
+ /**
1827
+ * Get the GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
1828
+ */
1829
+ get gs18Prefix(): string | undefined;
1830
+ /**
1831
+ * Get the tweak factor.
1832
+ */
1833
+ get tweakFactor(): bigint;
1834
+ /**
1835
+ * Set the tweak factor.
1836
+ *
1837
+ * @param value
1838
+ * Tweak factor.
1839
+ */
1840
+ set tweakFactor(value: number | bigint);
1841
+ /**
1842
+ * Reset the tweak factor to its default (numeric value of the GS1 Company Prefix preceded by '1').
1843
+ */
1844
+ resetTweakFactor(): void;
1845
+ /**
1846
+ * Get a prefix manager.
1847
+ *
1848
+ * @param prefixType
1849
+ * Prefix type.
1850
+ *
1851
+ * @param prefix
1852
+ * Prefix.
1853
+ *
1854
+ * @returns
1855
+ * Prefix manager with normalized prefix type and prefix.
1856
+ */
1857
+ static get(prefixType: PrefixType, prefix: string): PrefixManager;
1858
+ /**
1859
+ * Get an identifier creator.
1860
+ *
1861
+ * @template TIdentifierType
1862
+ * Identifier type type.
1863
+ *
1864
+ * @param identifierType
1865
+ * Identifier type for which to retrieve or construct identifier creator.
1866
+ *
1867
+ * @returns
1868
+ * Identifier creator.
1869
+ */
1870
+ getIdentifierCreator<TIdentifierType extends IdentifierType>(identifierType: TIdentifierType): IdentifierCreatorsRecord[TIdentifierType];
1871
+ /**
1872
+ * Get GTIN creator.
1873
+ */
1874
+ get gtinCreator(): GTINCreator;
1875
+ /**
1876
+ * Get GLN creator.
1877
+ */
1878
+ get glnCreator(): NonSerializableNumericIdentifierCreator;
1879
+ /**
1880
+ * Get SSCC creator.
1881
+ */
1882
+ get ssccCreator(): NonSerializableNumericIdentifierCreator;
1883
+ /**
1884
+ * Get GRAI creator.
1885
+ */
1886
+ get graiCreator(): SerializableNumericIdentifierCreator;
1887
+ /**
1888
+ * Get GIAI creator.
1889
+ */
1890
+ get giaiCreator(): NonNumericIdentifierCreator;
1891
+ /**
1892
+ * Get GSRN creator.
1893
+ */
1894
+ get gsrnCreator(): NonSerializableNumericIdentifierCreator;
1895
+ /**
1896
+ * Get GDTI creator.
1897
+ */
1898
+ get gdtiCreator(): SerializableNumericIdentifierCreator;
1899
+ /**
1900
+ * Get GINC creator.
1901
+ */
1902
+ get gincCreator(): NonNumericIdentifierCreator;
1903
+ /**
1904
+ * Get GSIN creator.
1905
+ */
1906
+ get gsinCreator(): NonSerializableNumericIdentifierCreator;
1907
+ /**
1908
+ * Get GCN creator.
1909
+ */
1910
+ get gcnCreator(): SerializableNumericIdentifierCreator;
1911
+ /**
1912
+ * Get CPID creator.
1913
+ */
1914
+ get cpidCreator(): NonNumericIdentifierCreator;
1915
+ /**
1916
+ * Get GMN creator.
1917
+ */
1918
+ get gmnCreator(): NonNumericIdentifierCreator;
1919
+ }
1920
+
1921
+ /**
1922
+ * GS1 Company Prefix length header.
1923
+ */
1924
+ interface GCPLengthHeader {
1925
+ /**
1926
+ * Date/time the data was last updated.
1927
+ */
1928
+ readonly dateTime: Date;
1929
+ /**
1930
+ * Disclaimer.
1931
+ */
1932
+ readonly disclaimer: string;
1933
+ }
1934
+ /**
1935
+ * Determine if application data object is GS1 Company Prefix length header.
1936
+ *
1937
+ * @param appData
1938
+ * Application data object.
1939
+ *
1940
+ * @returns
1941
+ * True if application data object is GS1 Company Prefix length header.
1942
+ */
1943
+ declare function isGCPLengthHeader(appData: AppData | undefined): appData is GCPLengthHeader;
1944
+ /**
1945
+ * GS1 Company Prefix length data.
1946
+ */
1947
+ interface GCPLengthData extends GCPLengthHeader {
1948
+ /**
1949
+ * Tree data in binary form.
1950
+ */
1951
+ readonly data: Uint8Array;
1952
+ }
1953
+ /**
1954
+ * Determine if application data object is GS1 Company Prefix length data.
1955
+ *
1956
+ * @param appData
1957
+ * Application data object.
1958
+ *
1959
+ * @returns
1960
+ * True if application data object is GS1 Company Prefix length data.
1961
+ */
1962
+ declare function isGCPLengthData(appData: AppData | undefined): appData is GCPLengthData;
1963
+ /**
1964
+ * GS1 Company Prefix length application data.
1965
+ */
1966
+ interface GCPLengthAppData {
1967
+ /**
1968
+ * Next check date/time.
1969
+ */
1970
+ nextCheckDateTime: Date | undefined;
1971
+ /**
1972
+ * GS1 Company Prefix length data.
1973
+ */
1974
+ gcpLengthData: GCPLengthData | undefined;
1975
+ }
1976
+ /**
1977
+ * Determine if application data object is GS1 Company Prefix length application data.
1978
+ *
1979
+ * @param appData
1980
+ * Application data object.
1981
+ *
1982
+ * @returns
1983
+ * True if application data object is GS1 Company Prefix length application data.
1984
+ */
1985
+ declare function isGCPLengthAppData(appData: AppData | undefined): appData is GCPLengthAppData;
1986
+ /**
1987
+ * GS1 Company Prefix length JSON source file format.
1988
+ */
1989
+ interface GCPLengthSourceJSON {
1990
+ /**
1991
+ * Disclaimer.
1992
+ */
1993
+ _disclaimer: string[];
1994
+ /**
1995
+ * Format list.
1996
+ */
1997
+ GCPPrefixFormatList: {
1998
+ /**
1999
+ * ISO data/time the table was last updated.
2000
+ */
2001
+ date: string;
2002
+ /**
2003
+ * Entries.
2004
+ */
2005
+ entry: Array<{
2006
+ /**
2007
+ * Identification key prefix start.
2008
+ */
2009
+ prefix: string;
2010
+ /**
2011
+ * Length of GS1 Company Prefix.
2012
+ */
2013
+ gcpLength: number;
2014
+ }>;
2015
+ };
2016
+ }
2017
+ /**
2018
+ * Determine if application data object is GS1 Company Prefix length source JSON.
2019
+ *
2020
+ * @param appData
2021
+ * Application data object.
2022
+ *
2023
+ * @returns
2024
+ * True if application data object is GS1 Company Prefix length source JSON.
2025
+ */
2026
+ declare function isGCPLengthSourceJSON(appData: AppData | undefined): appData is GCPLengthSourceJSON;
2027
+
2028
+ /**
2029
+ * GS1 Company Prefix length cache.
2030
+ */
2031
+ declare abstract class GCPLengthCache extends Cache<GCPLengthData, GCPLengthData | GCPLengthSourceJSON> {
2032
+ #private;
2033
+ /**
2034
+ * Storage key for full application data object.
2035
+ */
2036
+ static APP_DATA_STORAGE_KEY: string;
2037
+ /**
2038
+ * Storage key for next check date/time.
2039
+ */
2040
+ static NEXT_CHECK_DATE_TIME_STORAGE_KEY: string;
2041
+ /**
2042
+ * Storage key for header information (date/time and disclaimer).
2043
+ */
2044
+ static HEADER_STORAGE_KEY: string;
2045
+ /**
2046
+ * Storage key for data only.
2047
+ */
2048
+ static DATA_STORAGE_KEY: string;
2049
+ /**
2050
+ * Constructor.
2051
+ *
2052
+ * @param appDataStorage
2053
+ * Application data storage.
2054
+ */
2055
+ constructor(appDataStorage: AppDataStorage<boolean>);
2056
+ /**
2057
+ * Get the application data storage.
2058
+ */
2059
+ get appDataStorage(): AppDataStorage<boolean>;
2060
+ /**
2061
+ * @inheritDoc
2062
+ */
2063
+ get nextCheckDateTime(): Promise<Date | undefined>;
2064
+ /**
2065
+ * @inheritDoc
2066
+ */
2067
+ get cacheDateTime(): Promise<Date | undefined>;
2068
+ /**
2069
+ * @inheritDoc
2070
+ */
2071
+ get cacheData(): Promise<GCPLengthData>;
2072
+ /**
2073
+ * @inheritDoc
2074
+ */
2075
+ update(nextCheckDateTime: Date, _cacheDateTime?: Date, cacheData?: GCPLengthData): Promise<void>;
2076
+ }
2077
+ /**
2078
+ * GS1 Company Prefix length cache with remote source. This class provides access to the data from a remote source, by
2079
+ * default the AIDC Toolkit website. If any error occurs, the next check date/time is set to the current date/time plus
2080
+ * ten minutes to prevent the network from being overloaded.
2081
+ *
2082
+ * The data on the AIDC Toolkit website is updated regularly with the data provided by GS1, and it's stored in binary
2083
+ * format for faster retrieval.
2084
+ */
2085
+ declare class RemoteGCPLengthCache extends GCPLengthCache {
2086
+ #private;
2087
+ /**
2088
+ * Default base URL pointing to AIDC Toolkit website data directory.
2089
+ */
2090
+ static DEFAULT_BASE_URL: string;
2091
+ /**
2092
+ * Constructor.
2093
+ *
2094
+ * @param appDataStorage
2095
+ * Application data storage.
2096
+ *
2097
+ * @param baseURL
2098
+ * Base URL. The URL must not end with a slash and must host the `gcp-length-header.json` and `gcp-length-data.bin`
2099
+ * files.
2100
+ */
2101
+ constructor(appDataStorage: AppDataStorage<boolean>, baseURL?: string);
2102
+ /**
2103
+ * @inheritDoc
2104
+ */
2105
+ get sourceDateTime(): Promise<Date>;
2106
+ /**
2107
+ * @inheritDoc
2108
+ */
2109
+ get sourceData(): Promise<GCPLengthData>;
2110
+ }
2111
+
2112
+ /**
2113
+ * Leaf of GS1 Company Prefix length tree.
2114
+ */
2115
+ interface Leaf {
2116
+ readonly length: number;
2117
+ }
2118
+ /**
2119
+ * Branch of GS1 Company Prefix length tree.
2120
+ */
2121
+ interface Branch {
2122
+ readonly childNodes: ReadonlyArray<Node | undefined>;
2123
+ }
2124
+ /**
2125
+ * Root of GS1 Company Prefix length tree.
2126
+ */
2127
+ interface Root extends GCPLengthHeader, Branch {
2128
+ }
2129
+ /**
2130
+ * Node in GS1 Company Prefix length tree.
2131
+ */
2132
+ type Node = Branch | Leaf;
2133
+ /**
2134
+ * Interim branch of GS1 Company Prefix length tree with writeable child nodes.
2135
+ */
2136
+ interface InterimBranch {
2137
+ readonly childNodes: Array<InterimBranch | Leaf | undefined>;
2138
+ }
2139
+ /**
2140
+ * GS1 Company Prefix length service. The constructor takes a {@linkcode GCPLengthCache} object, which is responsible
2141
+ * for managing the cache and source.
2142
+ *
2143
+ * The first step is to load the GS1 Company Prefix length data. This is done using the
2144
+ * {@linkcode GCPLength.load | load()} method, which works as follows:
2145
+ *
2146
+ * - If the next check date/time is in the future, the method returns immediately, regardless of whether any data is
2147
+ * available. It does this to prevent a large number of requests to the source in the event of a failure.
2148
+ * - Otherwise, if the cache date/time is undefined or less than the source date/time, it loads from the source,
2149
+ * converts the data if necessary, and updates the cache.
2150
+ * - Otherwise, it continues with the cached data.
2151
+ * - The next check date/time is updated to the later of the source date/time plus one week and the current date/time
2152
+ * plus one day.
2153
+ *
2154
+ * The base class implementation of the `GCPLengthCache` manages only the cache itself, and it requires an
2155
+ * application-provided storage implementation. The source is expected to be either a {@linkcode GCPLengthData} object
2156
+ * (created via another cache implementation) or a {@linkcode GCPLengthSourceJSON} object, which is the format of the
2157
+ * file provided by GS1.
2158
+ *
2159
+ * Once the data is loaded, the {@linkcode GCPLength.lengthOf | lengthOf()} method can be used to get the length of a
2160
+ * GS1 Company Prefix for an identifier type and identifier.
2161
+ */
2162
+ declare class GCPLength {
2163
+ #private;
2164
+ /**
2165
+ * Constructor.
2166
+ *
2167
+ * @param gcpLengthCache
2168
+ * GS1 Company Prefix length cache.
2169
+ */
2170
+ constructor(gcpLengthCache: GCPLengthCache);
2171
+ /**
2172
+ * Get the GS1 Company Prefix length tree root.
2173
+ *
2174
+ * @returns
2175
+ * GS1 Company Prefix length tree root.
2176
+ */
2177
+ get root(): Root;
2178
+ /**
2179
+ * Get the date/time the GS1 Company Prefix length data was last updated.
2180
+ */
2181
+ get dateTime(): Date;
2182
+ /**
2183
+ * Get the disclaimer for the GS1 Company Prefix length data.
2184
+ */
2185
+ get disclaimer(): string;
2186
+ /**
2187
+ * Load the GS1 Company Prefix length data.
2188
+ */
2189
+ load(): Promise<void>;
2190
+ /**
2191
+ * Get the length of a GS1 Company Prefix for an identifier.
2192
+ *
2193
+ * @param identifierType
2194
+ * Identifier type.
2195
+ *
2196
+ * @param identifier
2197
+ * Identifier.
2198
+ *
2199
+ * @returns
2200
+ * Length of GS1 Company Prefix, 0 if not a GS1 Company Prefix, or -1 if not found.
2201
+ */
2202
+ lengthOf(identifierType: IdentifierType, identifier: string): number;
2203
+ }
2204
+
2205
+ export { AI39_CREATOR, AI39_VALIDATOR, AI64_VALIDATOR, AI82_CREATOR, AI82_VALIDATOR, type ContentCharacterSet, type ContentCharacterSetKey, ContentCharacterSets, GCPLength, type GCPLengthAppData, GCPLengthCache, type GCPLengthData, type GCPLengthHeader, type GCPLengthSourceJSON, type GS1LocaleResources, type GTINBaseLength, type GTINBaseLengthKey, GTINBaseLengths, GTINCreator, type GTINCreatorConstructor, type GTINDescriptor, type GTINLength, type GTINLengthKey, GTINLengths, type GTINLevel, type GTINLevelKey, GTINLevels, type GTINType, type GTINTypeKey, GTINTypes, GTINValidator, type GTINValidatorConstructor, GTIN_BASE_TYPES, type IdentifierCreator, IdentifierCreatorConstructors, type IdentifierCreatorConstructorsEntry, type IdentifierCreatorConstructorsRecord, type IdentifierCreatorsEntry, type IdentifierCreatorsRecord, type IdentifierDescriptor, IdentifierDescriptors, type IdentifierDescriptorsEntry, type IdentifierDescriptorsRecord, type IdentifierType, type IdentifierTypeCreator, type IdentifierTypeDescriptor, type IdentifierTypeKey, type IdentifierTypeValidator, IdentifierTypes, type IdentifierValidation, IdentifierValidator, IdentifierValidatorConstructors, type IdentifierValidatorConstructorsEntry, type IdentifierValidatorConstructorsRecord, IdentifierValidators, type IdentifierValidatorsEntry, type IdentifierValidatorsRecord, type InterimBranch, type LeaderType, type LeaderTypeKey, LeaderTypes, type NonGTINCreatorConstructor, type NonGTINNumericIdentifierCreator, type NonGTINNumericIdentifierDescriptor, type NonGTINNumericIdentifierType, type NonGTINNumericIdentifierTypeKey, NonGTINNumericIdentifierTypes, NonGTINNumericIdentifierValidator, type NonGTINValidatorConstructor, NonNumericIdentifierCreator, type NonNumericIdentifierDescriptor, type NonNumericIdentifierType, type NonNumericIdentifierTypeKey, NonNumericIdentifierTypes, type NonNumericIdentifierValidation, NonNumericIdentifierValidator, NonSerializableNumericIdentifierCreator, type NonSerializableNumericIdentifierDescriptor, type NonSerializableNumericIdentifierType, type NonSerializableNumericIdentifierTypeKey, NonSerializableNumericIdentifierTypes, NonSerializableNumericIdentifierValidator, type NumericIdentifierCreator, type NumericIdentifierDescriptor, type NumericIdentifierType, type NumericIdentifierTypeKey, NumericIdentifierTypes, type NumericIdentifierValidation, NumericIdentifierValidator, PrefixManager, type PrefixProvider, type PrefixType, type PrefixTypeKey, PrefixTypes, type PrefixValidation, PrefixValidator, type RCNReference, RemoteGCPLengthCache, SerializableNumericIdentifierCreator, type SerializableNumericIdentifierDescriptor, type SerializableNumericIdentifierSplit, type SerializableNumericIdentifierType, type SerializableNumericIdentifierTypeKey, SerializableNumericIdentifierTypes, SerializableNumericIdentifierValidator, VariableMeasure, checkCharacterPair, checkDigit, checkDigitSum, gs1NS, gs1ResourceBundle, hasValidCheckCharacterPair, hasValidCheckDigit, i18nGS1Init, i18nextGS1, isGCPLengthAppData, isGCPLengthData, isGCPLengthHeader, isGCPLengthSourceJSON, isGTINCreator, isGTINDescriptor, isGTINDescriptors, isGTINValidator, isGTINValidators, isNonGTINNumericIdentifierCreator, isNonGTINNumericIdentifierDescriptor, isNonGTINNumericIdentifierValidator, isNonNumericIdentifierCreator, isNonNumericIdentifierDescriptor, isNonNumericIdentifierValidator, isNonSerializableNumericIdentifierCreator, isNonSerializableNumericIdentifierDescriptor, isNonSerializableNumericIdentifierValidator, isNumericIdentifierCreator, isNumericIdentifierDescriptor, isNumericIdentifierValidator, isSerializableNumericIdentifierCreator, isSerializableNumericIdentifierDescriptor, isSerializableNumericIdentifierValidator, isValidPriceOrWeightCheckDigit, priceOrWeightCheckDigit, verifiedByGS1 };