@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
@@ -1,97 +0,0 @@
1
- import { CONTENT_CHARACTER_SET_CREATORS } from "./content-character-set-creators.js";
2
- import { IdentifierDescriptors } from "./identifier-descriptors.js";
3
- import { i18nextGS1 } from "./locale/i18n.js";
4
- import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
5
- /**
6
- * Serializable numeric identifier validator. Validates both serialized and non-serialized forms of numeric identifiers
7
- * that support serialization.
8
- */
9
- export class SerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator {
10
- /**
11
- * Serial component length.
12
- */
13
- #serialComponentLength;
14
- /**
15
- * Serial component character set.
16
- */
17
- #serialComponentCharacterSet;
18
- /**
19
- * Serial component validation parameters.
20
- */
21
- #serialComponentValidation;
22
- /**
23
- * Serial component creator.
24
- */
25
- #serialComponentCreator;
26
- /**
27
- * Constructor.
28
- *
29
- * @param identifierType
30
- * Identifier type.
31
- */
32
- constructor(identifierType) {
33
- const identifierDescriptor = IdentifierDescriptors[identifierType];
34
- super(identifierDescriptor);
35
- this.#serialComponentLength = identifierDescriptor.serialComponentLength;
36
- this.#serialComponentCharacterSet = identifierDescriptor.serialComponentCharacterSet;
37
- this.#serialComponentValidation = {
38
- minimumLength: 1,
39
- maximumLength: identifierDescriptor.serialComponentLength,
40
- component: () => i18nextGS1.t("Identifier.serialComponent")
41
- };
42
- this.#serialComponentCreator = CONTENT_CHARACTER_SET_CREATORS[identifierDescriptor.serialComponentCharacterSet];
43
- }
44
- /**
45
- * Get the serial component length.
46
- */
47
- get serialComponentLength() {
48
- return this.#serialComponentLength;
49
- }
50
- /**
51
- * Get the serial component character set.
52
- */
53
- get serialComponentCharacterSet() {
54
- return this.#serialComponentCharacterSet;
55
- }
56
- /**
57
- * Get the serial component validation parameters.
58
- */
59
- get serialComponentValidation() {
60
- return this.#serialComponentValidation;
61
- }
62
- /**
63
- * Get the serial component creator.
64
- */
65
- get serialComponentCreator() {
66
- return this.#serialComponentCreator;
67
- }
68
- /**
69
- * @inheritDoc
70
- */
71
- validate(identifier, validation) {
72
- super.validate(identifier.substring(0, this.length), validation);
73
- if (identifier.length > this.length) {
74
- this.serialComponentCreator.validate(identifier.substring(this.length), this.#serialComponentValidation);
75
- }
76
- }
77
- /**
78
- * Split a serializable numeric identifier into its component parts.
79
- *
80
- * @param identifier
81
- * Identifier.
82
- *
83
- * @param validation
84
- * Identifier validation parameters.
85
- *
86
- * @returns
87
- * Base identifier and serial component (possibly empty) as object.
88
- */
89
- split(identifier, validation) {
90
- this.validate(identifier, validation);
91
- return {
92
- baseIdentifier: identifier.substring(0, this.length),
93
- serialComponent: identifier.substring(this.length)
94
- };
95
- }
96
- }
97
- //# sourceMappingURL=serializable-numeric-identifier-validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializable-numeric-identifier-validator.js","sourceRoot":"","sources":["../src/serializable-numeric-identifier-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAmB/F;;;GAGG;AACH,MAAM,OAAO,sCAAuC,SAAQ,iCAAoE;IAC5H;;OAEG;IACM,sBAAsB,CAAS;IAExC;;OAEG;IACM,4BAA4B,CAAsB;IAE3D;;OAEG;IACM,0BAA0B,CAAyB;IAE5D;;OAEG;IAC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,0BAA0B,CAAC,CAAC;QAC7G,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,UAAkB,EAAE,UAAiC;QACvD,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAEtC,OAAO;YACH,cAAc,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;YACpD,eAAe,EAAE,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SACrD,CAAC;IACN,CAAC;CACJ"}
@@ -1,68 +0,0 @@
1
- /**
2
- * Restricted Circulation Number reference.
3
- */
4
- export interface RCNReference {
5
- /**
6
- * Item reference.
7
- */
8
- itemReference: number;
9
- /**
10
- * Price or weight (whole number only).
11
- */
12
- priceOrWeight: number;
13
- }
14
- /**
15
- * Variable measure trade item support functions.
16
- */
17
- export declare class VariableMeasure {
18
- /**
19
- * Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
20
- * 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
21
- *
22
- * - '2' - The first character of the RCN.
23
- * - '0'-'9' - The second character of the RCN (RCN-13 only).
24
- * - 'I' - One or more, in sequence, for the item reference.
25
- * - 'P' - One or more, in sequence, for the price or weight.
26
- * - 'V' - Zero or one, for the price or weight check digit.
27
- * - 'C' - The check digit of the entire RCN.
28
- *
29
- * The 'I', 'P', and 'V' formats may be in any order.
30
- *
31
- * Some examples:
32
- *
33
- * - `2IIIIIVPPPPC` - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
34
- * or weight.
35
- * - `23IIIIVPPPPPC` - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
36
- * or weight.
37
- * - `2IIIIIIPPPPC` - RCN-12 with a six-digit item reference and a four-digit price or eight.
38
- * - `29IIIIIPPPPPC` - RCN-13 with a five-digit item reference and a five-digit price or weight.
39
- *
40
- * @param format
41
- * Format.
42
- *
43
- * @param rcn
44
- * RCN.
45
- *
46
- * @returns
47
- * RCN reference.
48
- */
49
- static parseRCN(format: string, rcn: string): RCNReference;
50
- /**
51
- * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode parseRCN}
52
- * for format details.
53
- *
54
- * @param format
55
- * Format.
56
- *
57
- * @param itemReference
58
- * Item reference.
59
- *
60
- * @param priceOrWeight
61
- * Price or weight (whole number only).
62
- *
63
- * @returns
64
- * RCN-12 or RCN-13.
65
- */
66
- static createRCN(format: string, itemReference: number, priceOrWeight: number): string;
67
- }
68
- //# sourceMappingURL=variable-measure.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variable-measure.d.ts","sourceRoot":"","sources":["../src/variable-measure.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AAEH,qBAAa,eAAe;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,YAAY;IAiG1D;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;CAmGzF"}
@@ -1,210 +0,0 @@
1
- import { NUMERIC_CREATOR } from "@aidc-toolkit/utility";
2
- import { checkDigit, hasValidCheckDigit, isValidPriceOrWeightCheckDigit, priceOrWeightCheckDigit } from "./check.js";
3
- import { i18nextGS1 } from "./locale/i18n.js";
4
- /**
5
- * Variable measure trade item support functions.
6
- */
7
- // eslint-disable-next-line @typescript-eslint/no-extraneous-class -- Wrapper for future functionality.
8
- export class VariableMeasure {
9
- /**
10
- * Parse a Restricted Circulation Number (RCN) using a variable measure trade item format. The format is a 12- or
11
- * 13-character string (for RCN-12 or RCN-13 respectively), containing the following:
12
- *
13
- * - '2' - The first character of the RCN.
14
- * - '0'-'9' - The second character of the RCN (RCN-13 only).
15
- * - 'I' - One or more, in sequence, for the item reference.
16
- * - 'P' - One or more, in sequence, for the price or weight.
17
- * - 'V' - Zero or one, for the price or weight check digit.
18
- * - 'C' - The check digit of the entire RCN.
19
- *
20
- * The 'I', 'P', and 'V' formats may be in any order.
21
- *
22
- * Some examples:
23
- *
24
- * - `2IIIIIVPPPPC` - RCN-12 with a five-digit item reference, a price or weight check digit, and a four-digit price
25
- * or weight.
26
- * - `23IIIIVPPPPPC` - RCN-13 with a four-digit item reference, a price or weight check digit, and a five-digit price
27
- * or weight.
28
- * - `2IIIIIIPPPPC` - RCN-12 with a six-digit item reference and a four-digit price or eight.
29
- * - `29IIIIIPPPPPC` - RCN-13 with a five-digit item reference and a five-digit price or weight.
30
- *
31
- * @param format
32
- * Format.
33
- *
34
- * @param rcn
35
- * RCN.
36
- *
37
- * @returns
38
- * RCN reference.
39
- */
40
- static parseRCN(format, rcn) {
41
- const formatLength = format.length;
42
- if (rcn.length !== formatLength) {
43
- throw new RangeError(i18nextGS1.t("Identifier.invalidRCNLength"));
44
- }
45
- let validFormat = formatLength === 12 || formatLength === 13;
46
- let validRCNPrefix = true;
47
- let buildingItemReference = false;
48
- let itemReference = "";
49
- let buildingPriceOrWeight = false;
50
- let priceOrWeight = "";
51
- let priceOrWeightCheckDigit = "";
52
- for (let index = 0; validFormat && index < formatLength; index++) {
53
- const formatChar = format.charAt(index);
54
- const rcnChar = rcn.charAt(index);
55
- if (index === 0) {
56
- validFormat = formatChar === "2";
57
- validRCNPrefix = rcnChar === "2";
58
- }
59
- else if (formatLength === 13 && index === 1) {
60
- validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
61
- validRCNPrefix = rcnChar === formatChar;
62
- }
63
- else if (index === formatLength - 1) {
64
- validFormat = formatChar === "C";
65
- }
66
- else {
67
- switch (formatChar) {
68
- case "I":
69
- if (!buildingItemReference) {
70
- // Item reference can't appear more than once.
71
- validFormat = itemReference === "";
72
- buildingItemReference = true;
73
- buildingPriceOrWeight = false;
74
- }
75
- itemReference += rcnChar;
76
- break;
77
- case "P":
78
- if (!buildingPriceOrWeight) {
79
- // Price or weight can't appear more than once.
80
- validFormat = priceOrWeight === "";
81
- buildingPriceOrWeight = true;
82
- buildingItemReference = false;
83
- }
84
- priceOrWeight += rcnChar;
85
- break;
86
- case "V":
87
- // Price or weight check digit can't appear more than once.
88
- validFormat = priceOrWeightCheckDigit === "";
89
- buildingItemReference = false;
90
- buildingPriceOrWeight = false;
91
- priceOrWeightCheckDigit = rcnChar;
92
- break;
93
- default:
94
- validFormat = false;
95
- break;
96
- }
97
- }
98
- }
99
- validFormat &&= itemReference !== "" && priceOrWeight !== "";
100
- if (!validFormat) {
101
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
102
- }
103
- if (!validRCNPrefix) {
104
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNPrefix"));
105
- }
106
- if (priceOrWeightCheckDigit !== "" && !isValidPriceOrWeightCheckDigit(priceOrWeight, priceOrWeightCheckDigit)) {
107
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasurePriceOrWeight"));
108
- }
109
- if (!hasValidCheckDigit(rcn)) {
110
- throw new RangeError(i18nextGS1.t("Identifier.invalidCheckDigit"));
111
- }
112
- return {
113
- itemReference: Number(itemReference),
114
- priceOrWeight: Number(priceOrWeight)
115
- };
116
- }
117
- /**
118
- * Create a Restricted Circulation Number (RCN) using a variable measure trade item format. See {@linkcode parseRCN}
119
- * for format details.
120
- *
121
- * @param format
122
- * Format.
123
- *
124
- * @param itemReference
125
- * Item reference.
126
- *
127
- * @param priceOrWeight
128
- * Price or weight (whole number only).
129
- *
130
- * @returns
131
- * RCN-12 or RCN-13.
132
- */
133
- static createRCN(format, itemReference, priceOrWeight) {
134
- const formatLength = format.length;
135
- let validFormat = formatLength === 12 || formatLength === 13;
136
- let rcnPrefix = "";
137
- let buildingItemReference = false;
138
- let itemReferenceString = "";
139
- let itemReferenceLength = 0;
140
- let buildingPriceOrWeight = false;
141
- let priceOrWeightString = "";
142
- let priceOrWeightLength = 0;
143
- let calculatePriceOrWeightCheckDigit = false;
144
- // RCN may be built in almost any order, so defer to builders that will be in ordered array.
145
- const rcnPrefixBuilder = (partialRCN) => partialRCN + rcnPrefix;
146
- const itemReferenceBuilder = (partialRCN) => partialRCN + itemReferenceString;
147
- const priceOrWeightBuilder = (partialRCN) => partialRCN + priceOrWeightString;
148
- const priceOrWeightCheckDigitBuilder = (partialRCN) => partialRCN + priceOrWeightCheckDigit(priceOrWeightString);
149
- const checkDigitBuilder = (partialRCN) => partialRCN + checkDigit(partialRCN);
150
- const rcnBuilders = [rcnPrefixBuilder];
151
- for (let index = 0; validFormat && index < formatLength; index++) {
152
- const formatChar = format.charAt(index);
153
- if (index === 0) {
154
- validFormat = formatChar === "2";
155
- rcnPrefix = formatChar;
156
- }
157
- else if (formatLength === 13 && index === 1) {
158
- validFormat = NUMERIC_CREATOR.characterIndex(formatChar) !== undefined;
159
- rcnPrefix += formatChar;
160
- }
161
- else if (index === formatLength - 1) {
162
- validFormat = formatChar === "C";
163
- }
164
- else {
165
- switch (formatChar) {
166
- case "I":
167
- if (!buildingItemReference) {
168
- // Item reference can't appear more than once.
169
- validFormat = itemReferenceLength === 0;
170
- buildingItemReference = true;
171
- buildingPriceOrWeight = false;
172
- rcnBuilders.push(itemReferenceBuilder);
173
- }
174
- itemReferenceLength++;
175
- break;
176
- case "P":
177
- if (!buildingPriceOrWeight) {
178
- // Price or weight can't appear more than once.
179
- validFormat = priceOrWeightLength === 0;
180
- buildingPriceOrWeight = true;
181
- buildingItemReference = false;
182
- rcnBuilders.push(priceOrWeightBuilder);
183
- }
184
- priceOrWeightLength++;
185
- break;
186
- case "V":
187
- // Price or weight check digit can't appear more than once.
188
- validFormat = !calculatePriceOrWeightCheckDigit;
189
- buildingItemReference = false;
190
- buildingPriceOrWeight = false;
191
- calculatePriceOrWeightCheckDigit = true;
192
- rcnBuilders.push(priceOrWeightCheckDigitBuilder);
193
- break;
194
- default:
195
- validFormat = false;
196
- break;
197
- }
198
- }
199
- }
200
- validFormat &&= itemReferenceLength !== 0 && priceOrWeightLength !== 0;
201
- if (!validFormat) {
202
- throw new RangeError(i18nextGS1.t("Identifier.invalidVariableMeasureRCNFormat"));
203
- }
204
- itemReferenceString = NUMERIC_CREATOR.create(itemReferenceLength, itemReference);
205
- priceOrWeightString = NUMERIC_CREATOR.create(priceOrWeightLength, priceOrWeight);
206
- rcnBuilders.push(checkDigitBuilder);
207
- return rcnBuilders.reduce((partialRCN, rcnBuilder) => rcnBuilder(partialRCN), "");
208
- }
209
- }
210
- //# sourceMappingURL=variable-measure.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variable-measure.js","sourceRoot":"","sources":["../src/variable-measure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiB9C;;GAEG;AACH,uGAAuG;AACvG,MAAM,OAAO,eAAe;IACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,MAAM,CAAC,QAAQ,CAAC,MAAc,EAAE,GAAW;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;QAEnC,IAAI,GAAG,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,WAAW,GAAG,YAAY,KAAK,EAAE,IAAI,YAAY,KAAK,EAAE,CAAC;QAC7D,IAAI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AC;wBAE9B,gCAAgC,GAAG,IAAI,CAAC;wBAExC,WAAW,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;wBACjD,MAAM;oBAEV;wBACI,WAAW,GAAG,KAAK,CAAC;wBACpB,MAAM;gBACd,CAAC;YACL,CAAC;QACL,CAAC;QAED,WAAW,KAAK,mBAAmB,KAAK,CAAC,IAAI,mBAAmB,KAAK,CAAC,CAAC;QAEvE,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC;QACrF,CAAC;QAED,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QACjF,mBAAmB,GAAG,eAAe,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAEjF,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAEpC,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;CACJ"}
@@ -1,22 +0,0 @@
1
- import type { Hyperlink } from "@aidc-toolkit/core";
2
- import { type IdentifierType } from "./identifier-type.js";
3
- /**
4
- * Create a Verified by GS1 hyperlink.
5
- *
6
- * @param identifierType
7
- * Identifier type.
8
- *
9
- * @param identifier
10
- * Identifier.
11
- *
12
- * @param text
13
- * Text for hyperlink. If not provided, the identifier is used.
14
- *
15
- * @param details
16
- * Details to display when hovering over hyperlink.
17
- *
18
- * @returns
19
- * Verified by GS1 hyperlink.
20
- */
21
- export declare function verifiedByGS1(identifierType: IdentifierType, identifier: string, text?: string | undefined, details?: string): Hyperlink;
22
- //# sourceMappingURL=verified-by-gs1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verified-by-gs1.d.ts","sourceRoot":"","sources":["../src/verified-by-gs1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,KAAK,cAAc,EAAmB,MAAM,sBAAsB,CAAC;AAK5E;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,GAAG,SAAqB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CA2BnJ"}
@@ -1,46 +0,0 @@
1
- import { GTINValidator } from "./gtin-validator.js";
2
- import { IdentifierTypes } from "./identifier-type.js";
3
- import { IdentifierValidators } from "./identifier-validators.js";
4
- const VERIFIED_BY_GS1_REFERENCE_BASE = "https://www.gs1.org/services/verified-by-gs1/results?";
5
- /**
6
- * Create a Verified by GS1 hyperlink.
7
- *
8
- * @param identifierType
9
- * Identifier type.
10
- *
11
- * @param identifier
12
- * Identifier.
13
- *
14
- * @param text
15
- * Text for hyperlink. If not provided, the identifier is used.
16
- *
17
- * @param details
18
- * Details to display when hovering over hyperlink.
19
- *
20
- * @returns
21
- * Verified by GS1 hyperlink.
22
- */
23
- // eslint-disable-next-line @typescript-eslint/no-useless-default-assignment -- Undefined is necessary to allow bypass of text.
24
- export function verifiedByGS1(identifierType, identifier, text = undefined, details) {
25
- let normalizedIdentifier;
26
- let useKeyTypeParameter;
27
- if (identifierType === IdentifierTypes.GTIN) {
28
- // Normalization will validate resulting GTIN.
29
- normalizedIdentifier = GTINValidator.normalize(identifier);
30
- useKeyTypeParameter = true;
31
- }
32
- else {
33
- const identifierValidator = IdentifierValidators[identifierType];
34
- identifierValidator.validate(identifier);
35
- normalizedIdentifier = identifier;
36
- useKeyTypeParameter = identifierType === IdentifierTypes.GLN;
37
- }
38
- const lowerCaseIdentifierType = identifierType.toLowerCase();
39
- const reference = useKeyTypeParameter ? `${VERIFIED_BY_GS1_REFERENCE_BASE}${lowerCaseIdentifierType}=${normalizedIdentifier}` : `${VERIFIED_BY_GS1_REFERENCE_BASE}key=${normalizedIdentifier}&key_type=${lowerCaseIdentifierType}`;
40
- return {
41
- reference,
42
- text: text ?? identifier,
43
- details
44
- };
45
- }
46
- //# sourceMappingURL=verified-by-gs1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verified-by-gs1.js","sourceRoot":"","sources":["../src/verified-by-gs1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,8BAA8B,GAAG,uDAAuD,CAAC;AAE/F;;;;;;;;;;;;;;;;;GAiBG;AACH,+HAA+H;AAC/H,MAAM,UAAU,aAAa,CAAC,cAA8B,EAAE,UAAkB,EAAE,OAA2B,SAAS,EAAE,OAAgB;IACpI,IAAI,oBAA4B,CAAC;IACjC,IAAI,mBAA4B,CAAC;IAEjC,IAAI,cAAc,KAAK,eAAe,CAAC,IAAI,EAAE,CAAC;QAC1C,8CAA8C;QAC9C,oBAAoB,GAAG,aAAa,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAE3D,mBAAmB,GAAG,IAAI,CAAC;IAC/B,CAAC;SAAM,CAAC;QACJ,MAAM,mBAAmB,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;QAEjE,mBAAmB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAEzC,oBAAoB,GAAG,UAAU,CAAC;QAClC,mBAAmB,GAAG,cAAc,KAAK,eAAe,CAAC,GAAG,CAAC;IACjE,CAAC;IAED,MAAM,uBAAuB,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC;IAE7D,MAAM,SAAS,GAAG,mBAAmB,CAAC,CAAC,CAAC,GAAG,8BAA8B,GAAG,uBAAuB,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAC,GAAG,8BAA8B,OAAO,oBAAoB,aAAa,uBAAuB,EAAE,CAAC;IAEnO,OAAO;QACH,SAAS;QACT,IAAI,EAAE,IAAI,IAAI,UAAU;QACxB,OAAO;KACV,CAAC;AACN,CAAC"}
@@ -1,39 +0,0 @@
1
- import type { GCPLengthHeader } from "./gcp-length-data.js";
2
-
3
- /**
4
- * Leaf of GS1 Company Prefix length tree.
5
- */
6
- export interface Leaf {
7
- readonly length: number;
8
- }
9
-
10
- /**
11
- * Branch of GS1 Company Prefix length tree.
12
- */
13
- export interface Branch {
14
- readonly childNodes: ReadonlyArray<Node | undefined>;
15
- }
16
-
17
- /**
18
- * Root of GS1 Company Prefix length tree.
19
- */
20
- export interface Root extends GCPLengthHeader, Branch {
21
- }
22
-
23
- /**
24
- * Node in GS1 Company Prefix length tree.
25
- */
26
- export type Node = Branch | Leaf;
27
-
28
- /**
29
- * Determine if a node is a leaf.
30
- *
31
- * @param node
32
- * Node.
33
- *
34
- * @returns
35
- * True if node is a leaf.
36
- */
37
- export function isLeaf(node: Node): node is Leaf {
38
- return "length" in node;
39
- }