@aidc-toolkit/gs1 1.0.23-beta → 1.0.25-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 (155) hide show
  1. package/dist/index.cjs +4813 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1949 -0
  4. package/dist/index.d.ts +1949 -36
  5. package/dist/index.js +4727 -19
  6. package/dist/index.js.map +1 -1
  7. package/package.json +8 -12
  8. package/src/abstract-identifier-creator.ts +97 -0
  9. package/src/abstract-identifier-validator.ts +140 -0
  10. package/{dist/numeric-identifier-creator.js → src/abstract-numeric-identifier-creator.ts} +61 -28
  11. package/src/abstract-numeric-identifier-validator.ts +69 -0
  12. package/src/character-set.ts +24 -9
  13. package/src/check.ts +9 -9
  14. package/src/content-character-set.ts +29 -0
  15. package/src/creators.ts +113 -0
  16. package/src/descriptors.ts +332 -0
  17. package/src/gtin-creator.ts +9 -8
  18. package/src/gtin-descriptor.ts +18 -0
  19. package/src/gtin-type.ts +50 -0
  20. package/src/gtin-validator.ts +40 -64
  21. package/src/identifier-creator.ts +11 -75
  22. package/src/identifier-descriptor.ts +30 -0
  23. package/src/identifier-type.ts +6 -1
  24. package/src/identifier-validator.ts +12 -188
  25. package/src/index.ts +43 -19
  26. package/src/locale/en/locale-resources.ts +0 -1
  27. package/src/locale/fr/locale-resources.ts +0 -1
  28. package/src/locale/i18n.ts +3 -5
  29. package/src/locale/i18next.d.ts +1 -1
  30. package/src/non-gtin-numeric-identifier-creator.ts +6 -12
  31. package/src/non-gtin-numeric-identifier-descriptor.ts +24 -0
  32. package/src/non-gtin-numeric-identifier-type.ts +7 -0
  33. package/src/non-gtin-numeric-identifier-validator.ts +8 -42
  34. package/src/non-numeric-identifier-creator.ts +8 -18
  35. package/src/non-numeric-identifier-descriptor.ts +29 -0
  36. package/src/non-numeric-identifier-type.ts +7 -0
  37. package/src/non-numeric-identifier-validator.ts +17 -55
  38. package/src/numeric-identifier-creator.ts +20 -163
  39. package/src/numeric-identifier-descriptor.ts +23 -0
  40. package/src/numeric-identifier-type.ts +44 -0
  41. package/src/numeric-identifier-validator.ts +13 -116
  42. package/src/prefix-manager.ts +94 -152
  43. package/src/prefix-provider.ts +3 -3
  44. package/src/prefix-type.ts +6 -1
  45. package/src/prefix-validator.ts +143 -81
  46. package/src/serializable-numeric-identifier-creator.ts +5 -15
  47. package/src/serializable-numeric-identifier-descriptor.ts +29 -0
  48. package/src/serializable-numeric-identifier-type.ts +9 -0
  49. package/src/serializable-numeric-identifier-validator.ts +18 -46
  50. package/src/validators.ts +203 -0
  51. package/test/creator.test.ts +4 -6
  52. package/test/gtin-creator.ts +6 -2
  53. package/test/gtin-validator.test.ts +6 -9
  54. package/test/identifier-creator.ts +5 -4
  55. package/test/identifier-validator.ts +2 -2
  56. package/test/non-gtin-numeric-identifier-creator.ts +9 -93
  57. package/test/non-gtin-numeric-identifier-validator.ts +2 -2
  58. package/test/non-numeric-identifier-creator.ts +93 -0
  59. package/test/non-numeric-identifier-validator.ts +2 -2
  60. package/test/numeric-identifier-creator.ts +11 -5
  61. package/test/numeric-identifier-validator.ts +4 -8
  62. package/test/prefix-manager.test.ts +1 -1
  63. package/test/serializable-numeric-identifier-creator.ts +11 -3
  64. package/test/serializable-numeric-identifier-validator.ts +2 -2
  65. package/test/validator.test.ts +63 -39
  66. package/tsup.config.ts +3 -0
  67. package/typedoc.json +1 -3
  68. package/dist/character-set.d.ts +0 -22
  69. package/dist/character-set.d.ts.map +0 -1
  70. package/dist/character-set.js +0 -36
  71. package/dist/character-set.js.map +0 -1
  72. package/dist/check.d.ts +0 -81
  73. package/dist/check.d.ts.map +0 -1
  74. package/dist/check.js +0 -218
  75. package/dist/check.js.map +0 -1
  76. package/dist/gtin-creator.d.ts +0 -68
  77. package/dist/gtin-creator.d.ts.map +0 -1
  78. package/dist/gtin-creator.js +0 -158
  79. package/dist/gtin-creator.js.map +0 -1
  80. package/dist/gtin-validator.d.ts +0 -202
  81. package/dist/gtin-validator.d.ts.map +0 -1
  82. package/dist/gtin-validator.js +0 -470
  83. package/dist/gtin-validator.js.map +0 -1
  84. package/dist/identifier-creator.d.ts +0 -72
  85. package/dist/identifier-creator.d.ts.map +0 -1
  86. package/dist/identifier-creator.js +0 -50
  87. package/dist/identifier-creator.js.map +0 -1
  88. package/dist/identifier-type.d.ts +0 -58
  89. package/dist/identifier-type.d.ts.map +0 -1
  90. package/dist/identifier-type.js +0 -54
  91. package/dist/identifier-type.js.map +0 -1
  92. package/dist/identifier-validator.d.ts +0 -174
  93. package/dist/identifier-validator.d.ts.map +0 -1
  94. package/dist/identifier-validator.js +0 -145
  95. package/dist/identifier-validator.js.map +0 -1
  96. package/dist/index.d.ts.map +0 -1
  97. package/dist/locale/en/locale-resources.d.ts +0 -43
  98. package/dist/locale/en/locale-resources.d.ts.map +0 -1
  99. package/dist/locale/en/locale-resources.js +0 -42
  100. package/dist/locale/en/locale-resources.js.map +0 -1
  101. package/dist/locale/fr/locale-resources.d.ts +0 -43
  102. package/dist/locale/fr/locale-resources.d.ts.map +0 -1
  103. package/dist/locale/fr/locale-resources.js +0 -42
  104. package/dist/locale/fr/locale-resources.js.map +0 -1
  105. package/dist/locale/i18n.d.ts +0 -27
  106. package/dist/locale/i18n.d.ts.map +0 -1
  107. package/dist/locale/i18n.js +0 -37
  108. package/dist/locale/i18n.js.map +0 -1
  109. package/dist/non-gtin-numeric-identifier-creator.d.ts +0 -30
  110. package/dist/non-gtin-numeric-identifier-creator.d.ts.map +0 -1
  111. package/dist/non-gtin-numeric-identifier-creator.js +0 -30
  112. package/dist/non-gtin-numeric-identifier-creator.js.map +0 -1
  113. package/dist/non-gtin-numeric-identifier-validator.d.ts +0 -41
  114. package/dist/non-gtin-numeric-identifier-validator.d.ts.map +0 -1
  115. package/dist/non-gtin-numeric-identifier-validator.js +0 -40
  116. package/dist/non-gtin-numeric-identifier-validator.js.map +0 -1
  117. package/dist/non-numeric-identifier-creator.d.ts +0 -55
  118. package/dist/non-numeric-identifier-creator.d.ts.map +0 -1
  119. package/dist/non-numeric-identifier-creator.js +0 -93
  120. package/dist/non-numeric-identifier-creator.js.map +0 -1
  121. package/dist/non-numeric-identifier-validator.d.ts +0 -78
  122. package/dist/non-numeric-identifier-validator.d.ts.map +0 -1
  123. package/dist/non-numeric-identifier-validator.js +0 -95
  124. package/dist/non-numeric-identifier-validator.js.map +0 -1
  125. package/dist/numeric-identifier-creator.d.ts +0 -121
  126. package/dist/numeric-identifier-creator.d.ts.map +0 -1
  127. package/dist/numeric-identifier-creator.js.map +0 -1
  128. package/dist/numeric-identifier-validator.d.ts +0 -76
  129. package/dist/numeric-identifier-validator.d.ts.map +0 -1
  130. package/dist/numeric-identifier-validator.js +0 -84
  131. package/dist/numeric-identifier-validator.js.map +0 -1
  132. package/dist/prefix-manager.d.ts +0 -224
  133. package/dist/prefix-manager.d.ts.map +0 -1
  134. package/dist/prefix-manager.js +0 -369
  135. package/dist/prefix-manager.js.map +0 -1
  136. package/dist/prefix-provider.d.ts +0 -27
  137. package/dist/prefix-provider.d.ts.map +0 -1
  138. package/dist/prefix-provider.js +0 -2
  139. package/dist/prefix-provider.js.map +0 -1
  140. package/dist/prefix-type.d.ts +0 -22
  141. package/dist/prefix-type.d.ts.map +0 -1
  142. package/dist/prefix-type.js +0 -18
  143. package/dist/prefix-type.js.map +0 -1
  144. package/dist/prefix-validator.d.ts +0 -58
  145. package/dist/prefix-validator.d.ts.map +0 -1
  146. package/dist/prefix-validator.js +0 -154
  147. package/dist/prefix-validator.js.map +0 -1
  148. package/dist/serializable-numeric-identifier-creator.d.ts +0 -86
  149. package/dist/serializable-numeric-identifier-creator.d.ts.map +0 -1
  150. package/dist/serializable-numeric-identifier-creator.js +0 -116
  151. package/dist/serializable-numeric-identifier-creator.js.map +0 -1
  152. package/dist/serializable-numeric-identifier-validator.d.ts +0 -79
  153. package/dist/serializable-numeric-identifier-validator.d.ts.map +0 -1
  154. package/dist/serializable-numeric-identifier-validator.js +0 -99
  155. package/dist/serializable-numeric-identifier-validator.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"prefix-validator.js","sourceRoot":"","sources":["../src/prefix-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAsBhE;;GAEG;AACH,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAE5C;;GAEG;AACH,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,6BAA6B,GAA+B;IAC9D,aAAa,EAAE,iCAAiC;IAChD,aAAa,EAAE,iCAAiC;IAChD,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,mDAAmD,GAA+B;IACpF,aAAa,EAAE,iCAAiC,GAAG,CAAC;IACpD,aAAa,EAAE,iCAAiC,GAAG,CAAC;IACpD,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,6CAA6C,GAA+B;IAC9E,aAAa,EAAE,2BAA2B,GAAG,CAAC;IAC9C,aAAa,EAAE,2BAA2B,GAAG,CAAC;IAC9C,SAAS,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC;CAC3D,CAAC;AAEF;;GAEG;AACH,MAAM,6BAA6B,GAA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Input, type TransformerOutput } from "@aidc-toolkit/utility";
2
- import type { IdentifierType } from "./identifier-type.js";
3
- import type { ContentCharacterSet } from "./identifier-validator.js";
4
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
5
- import type { PrefixProvider } from "./prefix-provider";
6
- import { SerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
7
- declare const SerializableNumericIdentifierCreator_base: import("ts-mixer/dist/types/types.js").Class<any[], SerializableNumericIdentifierValidator & AbstractNumericIdentifierCreator, typeof SerializableNumericIdentifierValidator & typeof AbstractNumericIdentifierCreator>;
8
- /**
9
- * Serializable numeric identifier creator.
10
- */
11
- export declare class SerializableNumericIdentifierCreator extends SerializableNumericIdentifierCreator_base {
12
- /**
13
- * Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
14
- * provider type.
15
- *
16
- * @param prefixProvider
17
- * Prefix provider.
18
- *
19
- * @param identifierType
20
- * Identifier type.
21
- *
22
- * @param length
23
- * Length.
24
- *
25
- * @param serialComponentLength
26
- * Serial component length.
27
- *
28
- * @param serialComponentCharacterSet
29
- * Serial component character set.
30
- */
31
- constructor(prefixProvider: PrefixProvider, identifierType: IdentifierType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
32
- /**
33
- * Concatenate a validated base identifier with serial component(s).
34
- *
35
- * @template TTransformerInput
36
- * Transformer input type.
37
- *
38
- * @param baseIdentifier
39
- * Base identifier.
40
- *
41
- * @param serialComponentOrComponents
42
- * Serial component(s).
43
- *
44
- * @returns
45
- * Serialized identifier(s).
46
- */
47
- private concatenateValidated;
48
- /**
49
- * Create serialized identifier(s) with a reference based on a numeric value concatenated with serial component(s).
50
- * The value is converted to a reference of the appropriate length using a numeric creator.
51
- *
52
- * @template TTransformerInput
53
- * Transformer input type.
54
- *
55
- * @param value
56
- * Numeric value of the reference.
57
- *
58
- * @param serialComponentOrComponents
59
- * Serial component(s).
60
- *
61
- * @param sparse
62
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
63
- *
64
- * @returns
65
- * Serialized identifiers.
66
- */
67
- createSerialized<TTransformerInput extends TransformerInput<string>>(value: number, serialComponentOrComponents: TTransformerInput, sparse?: boolean): TransformerOutput<TTransformerInput, string>;
68
- /**
69
- * Concatenate a base identifier with serial component(s).
70
- *
71
- * @template TTransformerInput
72
- * Transformer input type.
73
- *
74
- * @param baseIdentifier
75
- * Base identifier.
76
- *
77
- * @param serialComponentOrComponents
78
- * Serial component(s).
79
- *
80
- * @returns
81
- * Serialized identifier(s).
82
- */
83
- concatenate<TTransformerInput extends TransformerInput<string>>(baseIdentifier: string, serialComponentOrComponents: TTransformerInput): TransformerOutput<TTransformerInput, string>;
84
- }
85
- export {};
86
- //# sourceMappingURL=serializable-numeric-identifier-creator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializable-numeric-identifier-creator.d.ts","sourceRoot":"","sources":["../src/serializable-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,sCAAsC,EAAE,MAAM,gDAAgD,CAAC;;AAExG;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,yCAA+E;IACrI;;;;;;;;;;;;;;;;;;OAkBG;gBACS,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,2BAA2B,EAAE,mBAAmB;IAM3K;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAgC5B;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;IAInM;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,iBAAiB,SAAS,gBAAgB,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,2BAA2B,EAAE,iBAAiB,GAAG,iBAAiB,CAAC,iBAAiB,EAAE,MAAM,CAAC;CAKxL"}
@@ -1,116 +0,0 @@
1
- import { mapIterable } from "@aidc-toolkit/utility";
2
- import { Mixin } from "ts-mixer";
3
- import { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator.js";
4
- import { SerializableNumericIdentifierValidator } from "./serializable-numeric-identifier-validator.js";
5
- /**
6
- * Serializable numeric identifier creator.
7
- */
8
- export class SerializableNumericIdentifierCreator extends Mixin(SerializableNumericIdentifierValidator, AbstractNumericIdentifierCreator) {
9
- /**
10
- * Constructor. Typically called internally by a prefix manager but may be called by other code with another prefix
11
- * provider type.
12
- *
13
- * @param prefixProvider
14
- * Prefix provider.
15
- *
16
- * @param identifierType
17
- * Identifier type.
18
- *
19
- * @param length
20
- * Length.
21
- *
22
- * @param serialComponentLength
23
- * Serial component length.
24
- *
25
- * @param serialComponentCharacterSet
26
- * Serial component character set.
27
- */
28
- constructor(prefixProvider, identifierType, length, serialComponentLength, serialComponentCharacterSet) {
29
- super(identifierType, length, serialComponentLength, serialComponentCharacterSet);
30
- this.init(prefixProvider, prefixProvider.gs1CompanyPrefix);
31
- }
32
- /**
33
- * Concatenate a validated base identifier with serial component(s).
34
- *
35
- * @template TTransformerInput
36
- * Transformer input type.
37
- *
38
- * @param baseIdentifier
39
- * Base identifier.
40
- *
41
- * @param serialComponentOrComponents
42
- * Serial component(s).
43
- *
44
- * @returns
45
- * Serialized identifier(s).
46
- */
47
- concatenateValidated(baseIdentifier, serialComponentOrComponents) {
48
- // TODO Refactor type when https://github.com/microsoft/TypeScript/pull/56941 released.
49
- let result;
50
- const serialComponentCreator = this.serialComponentCreator;
51
- const serialComponentValidation = this.serialComponentValidation;
52
- /**
53
- * Validate a serial component and concatenate it to the base identifier.
54
- *
55
- * @param serialComponent
56
- * Serial component.
57
- *
58
- * @returns
59
- * Serialized identifier.
60
- */
61
- function validateAndConcatenate(serialComponent) {
62
- serialComponentCreator.validate(serialComponent, serialComponentValidation);
63
- return baseIdentifier + serialComponent;
64
- }
65
- if (typeof serialComponentOrComponents !== "object") {
66
- result = validateAndConcatenate(serialComponentOrComponents);
67
- }
68
- else {
69
- result = mapIterable(serialComponentOrComponents, validateAndConcatenate);
70
- }
71
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- Type determination is handled above.
72
- return result;
73
- }
74
- /**
75
- * Create serialized identifier(s) with a reference based on a numeric value concatenated with serial component(s).
76
- * The value is converted to a reference of the appropriate length using a numeric creator.
77
- *
78
- * @template TTransformerInput
79
- * Transformer input type.
80
- *
81
- * @param value
82
- * Numeric value of the reference.
83
- *
84
- * @param serialComponentOrComponents
85
- * Serial component(s).
86
- *
87
- * @param sparse
88
- * If true, the value is mapped to a sparse sequence resistant to discovery. Default is false.
89
- *
90
- * @returns
91
- * Serialized identifiers.
92
- */
93
- createSerialized(value, serialComponentOrComponents, sparse) {
94
- return this.concatenateValidated(this.create(value, sparse), serialComponentOrComponents);
95
- }
96
- /**
97
- * Concatenate a base identifier with serial component(s).
98
- *
99
- * @template TTransformerInput
100
- * Transformer input type.
101
- *
102
- * @param baseIdentifier
103
- * Base identifier.
104
- *
105
- * @param serialComponentOrComponents
106
- * Serial component(s).
107
- *
108
- * @returns
109
- * Serialized identifier(s).
110
- */
111
- concatenate(baseIdentifier, serialComponentOrComponents) {
112
- this.validate(baseIdentifier);
113
- return this.concatenateValidated(baseIdentifier, serialComponentOrComponents);
114
- }
115
- }
116
- //# sourceMappingURL=serializable-numeric-identifier-creator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializable-numeric-identifier-creator.js","sourceRoot":"","sources":["../src/serializable-numeric-identifier-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiD,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AAEnF,OAAO,EAAE,sCAAsC,EAAE,MAAM,gDAAgD,CAAC;AAExG;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,KAAK,CAAC,sCAAsC,EAAE,gCAAgC,CAAC;IACrI;;;;;;;;;;;;;;;;;;OAkBG;IACH,YAAY,cAA8B,EAAE,cAA8B,EAAE,MAAc,EAAE,qBAA6B,EAAE,2BAAgD;QACvK,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,qBAAqB,EAAE,2BAA2B,CAAC,CAAC;QAElF,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACK,oBAAoB,CAAqD,cAAsB,EAAE,2BAA8C;QACnJ,uFAAuF;QACvF,IAAI,MAAiC,CAAC;QAEtC,MAAM,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAC3D,MAAM,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC;QAEjE;;;;;;;;WAQG;QACH,SAAS,sBAAsB,CAAC,eAAuB;YACnD,sBAAsB,CAAC,QAAQ,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;YAE5E,OAAO,cAAc,GAAG,eAAe,CAAC;QAC5C,CAAC;QAED,IAAI,OAAO,2BAA2B,KAAK,QAAQ,EAAE,CAAC;YAClD,MAAM,GAAG,sBAAsB,CAAC,2BAA2B,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,WAAW,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;QAC9E,CAAC;QAED,+GAA+G;QAC/G,OAAO,MAAsD,CAAC;IAClE,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAqD,KAAa,EAAE,2BAA8C,EAAE,MAAgB;QAChJ,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,2BAA2B,CAAC,CAAC;IAC9F,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAqD,cAAsB,EAAE,2BAA8C;QAClI,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC;IAClF,CAAC;CACJ"}
@@ -1,79 +0,0 @@
1
- import type { CharacterSetCreator, CharacterSetValidation } from "@aidc-toolkit/utility";
2
- import { type IdentifierType, IdentifierTypes } from "./identifier-type.js";
3
- import { type ContentCharacterSet, type IdentifierValidation } from "./identifier-validator.js";
4
- import { type NonGTINNumericIdentifierType, NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
5
- /**
6
- * Serializable numeric identifier type.
7
- */
8
- export type SerializableNumericIdentifierType = Exclude<NonGTINNumericIdentifierType, typeof IdentifierTypes.GLN | typeof IdentifierTypes.SSCC | typeof IdentifierTypes.GSRN | typeof IdentifierTypes.GSIN>;
9
- /**
10
- * Serializable numeric identifier validator. Validates both serialized and non-serialized forms of
11
- * numeric identifiers that support serialization.
12
- */
13
- export declare class SerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator {
14
- /**
15
- * Serial component length.
16
- */
17
- private readonly _serialComponentLength;
18
- /**
19
- * Serial component character set.
20
- */
21
- private readonly _serialComponentCharacterSet;
22
- /**
23
- * Serial component validation parameters.
24
- */
25
- private readonly _serialComponentValidation;
26
- /**
27
- * Serial component creator.
28
- */
29
- private readonly _serialComponentCreator;
30
- /**
31
- * Constructor.
32
- *
33
- * @param identifierType
34
- * Identifier type.
35
- *
36
- * @param length
37
- * Length.
38
- *
39
- * @param serialComponentLength
40
- * Serial component length.
41
- *
42
- * @param serialComponentCharacterSet
43
- * Serial component character set.
44
- */
45
- constructor(identifierType: IdentifierType, length: number, serialComponentLength: number, serialComponentCharacterSet: ContentCharacterSet);
46
- /**
47
- * Get the serial component length.
48
- */
49
- get serialComponentLength(): number;
50
- /**
51
- * Get the serial component character set.
52
- */
53
- get serialComponentCharacterSet(): ContentCharacterSet;
54
- /**
55
- * Get the serial component validation parameters.
56
- */
57
- protected get serialComponentValidation(): CharacterSetValidation;
58
- /**
59
- * Get the serial component creator.
60
- */
61
- get serialComponentCreator(): CharacterSetCreator;
62
- /**
63
- * @inheritDoc
64
- */
65
- validate(identifier: string, validation?: IdentifierValidation): void;
66
- }
67
- /**
68
- * GRAI validator.
69
- */
70
- export declare const GRAI_VALIDATOR: SerializableNumericIdentifierValidator;
71
- /**
72
- * GDTI validator.
73
- */
74
- export declare const GDTI_VALIDATOR: SerializableNumericIdentifierValidator;
75
- /**
76
- * GCN validator.
77
- */
78
- export declare const GCN_VALIDATOR: SerializableNumericIdentifierValidator;
79
- //# sourceMappingURL=serializable-numeric-identifier-validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"serializable-numeric-identifier-validator.d.ts","sourceRoot":"","sources":["../src/serializable-numeric-identifier-validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,KAAK,cAAc,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,KAAK,mBAAmB,EAAwB,KAAK,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtH,OAAO,EACH,KAAK,4BAA4B,EACjC,iCAAiC,EACpC,MAAM,4CAA4C,CAAC;AAGpD;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG,OAAO,CAAC,4BAA4B,EAAE,OAAO,eAAe,CAAC,GAAG,GAAG,OAAO,eAAe,CAAC,IAAI,GAAG,OAAO,eAAe,CAAC,IAAI,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAE5M;;;GAGG;AACH,qBAAa,sCAAuC,SAAQ,iCAAiC;IACzF;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAS;IAEhD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAsB;IAEnE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAyB;IAEpE;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAsB;IAE9D;;;;;;;;;;;;;;OAcG;gBACS,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,2BAA2B,EAAE,mBAAmB;IAe3I;;OAEG;IACH,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAED;;OAEG;IACH,IAAI,2BAA2B,IAAI,mBAAmB,CAErD;IAED;;OAEG;IACH,SAAS,KAAK,yBAAyB,IAAI,sBAAsB,CAEhE;IAED;;OAEG;IACH,IAAI,sBAAsB,IAAI,mBAAmB,CAEhD;IAED;;OAEG;IACM,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,oBAAoB,GAAG,IAAI;CAOjF;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,wCAAsG,CAAC;AAElI;;GAEG;AACH,eAAO,MAAM,cAAc,wCAAsG,CAAC;AAElI;;GAEG;AACH,eAAO,MAAM,aAAa,wCAAwG,CAAC"}
@@ -1,99 +0,0 @@
1
- import { IdentifierTypes } from "./identifier-type.js";
2
- import { ContentCharacterSets } from "./identifier-validator.js";
3
- import { i18nextGS1 } from "./locale/i18n.js";
4
- import { NonGTINNumericIdentifierValidator } from "./non-gtin-numeric-identifier-validator.js";
5
- import { LeaderTypes } from "./numeric-identifier-validator.js";
6
- /**
7
- * Serializable numeric identifier validator. Validates both serialized and non-serialized forms of
8
- * numeric identifiers that support serialization.
9
- */
10
- export class SerializableNumericIdentifierValidator extends NonGTINNumericIdentifierValidator {
11
- /**
12
- * Serial component length.
13
- */
14
- _serialComponentLength;
15
- /**
16
- * Serial component character set.
17
- */
18
- _serialComponentCharacterSet;
19
- /**
20
- * Serial component validation parameters.
21
- */
22
- _serialComponentValidation;
23
- /**
24
- * Serial component creator.
25
- */
26
- _serialComponentCreator;
27
- /**
28
- * Constructor.
29
- *
30
- * @param identifierType
31
- * Identifier type.
32
- *
33
- * @param length
34
- * Length.
35
- *
36
- * @param serialComponentLength
37
- * Serial component length.
38
- *
39
- * @param serialComponentCharacterSet
40
- * Serial component character set.
41
- */
42
- constructor(identifierType, length, serialComponentLength, serialComponentCharacterSet) {
43
- super(identifierType, length, LeaderTypes.None);
44
- this._serialComponentLength = serialComponentLength;
45
- this._serialComponentCharacterSet = serialComponentCharacterSet;
46
- this._serialComponentValidation = {
47
- minimumLength: 1,
48
- maximumLength: serialComponentLength,
49
- component: () => i18nextGS1.t("Identifier.serialComponent")
50
- };
51
- this._serialComponentCreator = SerializableNumericIdentifierValidator.creatorFor(serialComponentCharacterSet);
52
- }
53
- /**
54
- * Get the serial component length.
55
- */
56
- get serialComponentLength() {
57
- return this._serialComponentLength;
58
- }
59
- /**
60
- * Get the serial component character set.
61
- */
62
- get serialComponentCharacterSet() {
63
- return this._serialComponentCharacterSet;
64
- }
65
- /**
66
- * Get the serial component validation parameters.
67
- */
68
- get serialComponentValidation() {
69
- return this._serialComponentValidation;
70
- }
71
- /**
72
- * Get the serial component creator.
73
- */
74
- get serialComponentCreator() {
75
- return this._serialComponentCreator;
76
- }
77
- /**
78
- * @inheritDoc
79
- */
80
- validate(identifier, validation) {
81
- super.validate(identifier.substring(0, this.length), validation);
82
- if (identifier.length > this.length) {
83
- this.serialComponentCreator.validate(identifier.substring(this.length), this._serialComponentValidation);
84
- }
85
- }
86
- }
87
- /**
88
- * GRAI validator.
89
- */
90
- export const GRAI_VALIDATOR = new SerializableNumericIdentifierValidator(IdentifierTypes.GRAI, 13, 16, ContentCharacterSets.AI82);
91
- /**
92
- * GDTI validator.
93
- */
94
- export const GDTI_VALIDATOR = new SerializableNumericIdentifierValidator(IdentifierTypes.GDTI, 13, 17, ContentCharacterSets.AI82);
95
- /**
96
- * GCN validator.
97
- */
98
- export const GCN_VALIDATOR = new SerializableNumericIdentifierValidator(IdentifierTypes.GCN, 13, 12, ContentCharacterSets.Numeric);
99
- //# 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,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAA4B,oBAAoB,EAA6B,MAAM,2BAA2B,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAEH,iCAAiC,EACpC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAOhE;;;GAGG;AACH,MAAM,OAAO,sCAAuC,SAAQ,iCAAiC;IACzF;;OAEG;IACc,sBAAsB,CAAS;IAEhD;;OAEG;IACc,4BAA4B,CAAsB;IAEnE;;OAEG;IACc,0BAA0B,CAAyB;IAEpE;;OAEG;IACc,uBAAuB,CAAsB;IAE9D;;;;;;;;;;;;;;OAcG;IACH,YAAY,cAA8B,EAAE,MAAc,EAAE,qBAA6B,EAAE,2BAAgD;QACvI,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC,sBAAsB,GAAG,qBAAqB,CAA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