@aidc-toolkit/gs1 1.0.25-beta → 1.0.26-beta

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