@aidc-toolkit/gs1 1.0.39-beta → 1.0.41-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 (39) hide show
  1. package/README.md +84 -101
  2. package/dist/gcp-length-cache.d.ts +6 -1
  3. package/dist/gcp-length-cache.d.ts.map +1 -1
  4. package/dist/gcp-length-cache.js +7 -2
  5. package/dist/gcp-length-cache.js.map +1 -1
  6. package/dist/gcp-length-tree.d.ts +33 -0
  7. package/dist/gcp-length-tree.d.ts.map +1 -0
  8. package/dist/gcp-length-tree.js +13 -0
  9. package/dist/gcp-length-tree.js.map +1 -0
  10. package/dist/gcp-length.d.ts +63 -49
  11. package/dist/gcp-length.d.ts.map +1 -1
  12. package/dist/gcp-length.js +319 -262
  13. package/dist/gcp-length.js.map +1 -1
  14. package/dist/index.d.ts +2 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/locale/en/locale-resources.d.ts +2 -0
  19. package/dist/locale/en/locale-resources.d.ts.map +1 -1
  20. package/dist/locale/en/locale-resources.js +3 -1
  21. package/dist/locale/en/locale-resources.js.map +1 -1
  22. package/dist/locale/fr/locale-resources.d.ts +2 -0
  23. package/dist/locale/fr/locale-resources.d.ts.map +1 -1
  24. package/dist/locale/fr/locale-resources.js +3 -1
  25. package/dist/locale/fr/locale-resources.js.map +1 -1
  26. package/dist/prefix-manager.d.ts +0 -35
  27. package/dist/prefix-manager.d.ts.map +1 -1
  28. package/dist/prefix-manager.js +0 -56
  29. package/dist/prefix-manager.js.map +1 -1
  30. package/package.json +4 -4
  31. package/src/gcp-length-cache.ts +7 -2
  32. package/src/gcp-length-tree.ts +39 -0
  33. package/src/gcp-length.ts +348 -297
  34. package/src/index.ts +3 -1
  35. package/src/locale/en/locale-resources.ts +3 -1
  36. package/src/locale/fr/locale-resources.ts +3 -1
  37. package/src/prefix-manager.ts +0 -65
  38. package/test/gcp-length.test.ts +39 -31
  39. package/tsconfig-src.tsbuildinfo +1 -1
package/README.md CHANGED
@@ -20,20 +20,20 @@ The GS1 system supports four character sets:
20
20
  - Digits '0' to '9'.
21
21
  - Required by most GS1 identifiers.
22
22
  - Required by many GS1 Application Identifiers.
23
- - [Validator](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_VALIDATOR.html) and [creator](https://aidc-toolkit.com/api/Utility/variables/NUMERIC_CREATOR.html) defined in the Utility package.
23
+ - [Validator](https://aidc-toolkit.com/v1.0/api/Utility/variables/NUMERIC_VALIDATOR.html) and [creator](https://aidc-toolkit.com/v1.0/api/Utility/variables/NUMERIC_CREATOR.html) defined in the Utility package.
24
24
  - GS1 AI encodable character set 82
25
25
  - Equivalent to ISO/IEC 646 Table 1 - Unique graphic character allocations.
26
26
  - Required by all non-numeric GS1 identifiers except CPID.
27
27
  - Required by many GS1 Application Identifiers.
28
- - [Validator](https://aidc-toolkit.com/api/GS1/variables/AI82_VALIDATOR.html) and [creator](https://aidc-toolkit.com/api/GS1/variables/AI82_CREATOR.html) defined in this package.
28
+ - [Validator](https://aidc-toolkit.com/v1.0/api/GS1/variables/AI82_VALIDATOR.html) and [creator](https://aidc-toolkit.com/v1.0/api/GS1/variables/AI82_CREATOR.html) defined in this package.
29
29
  - GS1 AI encodable character set 39
30
30
  - Digits '0' to '9', uppercase letters 'A' to 'Z', and the characters '#', '-', and '/'.
31
31
  - Required by the CPID GS1 identifier.
32
- - [Validator](https://aidc-toolkit.com/api/GS1/variables/AI39_VALIDATOR.html) and [creator](https://aidc-toolkit.com/api/GS1/variables/AI39_CREATOR.html) defined in this package.
32
+ - [Validator](https://aidc-toolkit.com/v1.0/api/GS1/variables/AI39_VALIDATOR.html) and [creator](https://aidc-toolkit.com/v1.0/api/GS1/variables/AI39_CREATOR.html) defined in this package.
33
33
  - GS1 AI encodable character set 64
34
34
  - Characters that result from base 64 encoding [as described in RFC 4648](https://www.rfc-editor.org/rfc/rfc4648.html#section-4).
35
35
  - Required by GS1 Application Identifier 8030 Digital Signature.
36
- - [Validator](https://aidc-toolkit.com/api/GS1/variables/AI64_VALIDATOR.html) defined in this package.
36
+ - [Validator](https://aidc-toolkit.com/v1.0/api/GS1/variables/AI64_VALIDATOR.html) defined in this package.
37
37
  - No creator is defined as creation is the base 64 process.
38
38
 
39
39
  ## Check Calculation and Validation Functions
@@ -42,23 +42,23 @@ The check calculation and validation functions are separate from the string vali
42
42
 
43
43
  ### Check Digit - GS1 Identifier
44
44
 
45
- The [`checkDigit()`](https://aidc-toolkit.com/api/GS1/functions/checkDigit.html) function calculates the check digit for a numeric GS1 identifier.
45
+ The [`checkDigit()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/checkDigit.html) function calculates the check digit for a numeric GS1 identifier.
46
46
 
47
- The [`hasValidCheckDigit()`](https://aidc-toolkit.com/api/GS1/functions/hasValidCheckDigit.html) function validates the check digit for a numeric GS1 identifier.
47
+ The [`hasValidCheckDigit()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/hasValidCheckDigit.html) function validates the check digit for a numeric GS1 identifier.
48
48
 
49
49
  ### Check Digit - Price or Weight Encoding
50
50
 
51
- The [`priceOrWeightCheckDigit()`](https://aidc-toolkit.com/api/GS1/functions/priceOrWeightCheckDigit.html) function calculates the check digit for a price or weight.
51
+ The [`priceOrWeightCheckDigit()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/priceOrWeightCheckDigit.html) function calculates the check digit for a price or weight.
52
52
 
53
- The [`isValidPriceOrWeightCheckDigit()`](https://aidc-toolkit.com/api/GS1/functions/isValidPriceOrWeightCheckDigit.html) function validates the check digit for a price or weight.
53
+ The [`isValidPriceOrWeightCheckDigit()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isValidPriceOrWeightCheckDigit.html) function validates the check digit for a price or weight.
54
54
 
55
55
  These functions are seldom used directly, as there are no use cases for prices or weights on their own. They are used by the variable measure RCN functions if the RCN format requires a price or weight check digit.
56
56
 
57
57
  ### Check Character Pair - GS1 Identifier
58
58
 
59
- The [`checkCharacterPair()`](https://aidc-toolkit.com/api/GS1/functions/checkCharacterPair.html) function calculates the check character pair for a non-numeric GS1 identifier, if supported.
59
+ The [`checkCharacterPair()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/checkCharacterPair.html) function calculates the check character pair for a non-numeric GS1 identifier, if supported.
60
60
 
61
- The [`hasValidCheckCharacterPair()`](https://aidc-toolkit.com/api/GS1/functions/hasValidCheckCharacterPair.html) function validates the check character pair for a non-numeric GS1 identifier, if supported.
61
+ The [`hasValidCheckCharacterPair()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/hasValidCheckCharacterPair.html) function validates the check character pair for a non-numeric GS1 identifier, if supported.
62
62
 
63
63
  ## GS1 Identifiers
64
64
 
@@ -68,15 +68,15 @@ At the core of the AIDC Toolkit `gs1` package is GS1 identifier validation and c
68
68
 
69
69
  Before going into the identifiers themselves, it's necessary to understand the prefix types supported by the GS1 system.
70
70
 
71
- - [GS1 Company Prefix](https://aidc-toolkit.com/api/GS1/variables/PrefixTypes.html#gs1companyprefix)
71
+ - [GS1 Company Prefix](https://aidc-toolkit.com/v1.0/api/GS1/variables/PrefixTypes.html#gs1companyprefix)
72
72
  - This is the core prefix type and the one to which all others can be converted. Every GS1 identifier contains a GS1 Company Prefix.
73
73
  - For example, using GS1 Company Prefix 9521234 and item reference 99999, you can create the 13-digit GTIN 9521234999997. Similarly, using GS1 Company Prefix 9521234 and model reference ABCDEF, you can create the GMN 9521234ABCDEFK2.
74
- - [U.P.C. Company Prefix](https://aidc-toolkit.com/api/GS1/variables/PrefixTypes.html#upccompanyprefix)
74
+ - [U.P.C. Company Prefix](https://aidc-toolkit.com/v1.0/api/GS1/variables/PrefixTypes.html#upccompanyprefix)
75
75
  - This is a special version of the GS1 Company Prefix used **only** to create 12-digit GTINs. All U.P.C. Company Prefixes are issued directly or indirectly by GS1 US to support the requirement for 12-digit GTINs in the North American marketplace.
76
76
  - For example, using U.P.C. Company Prefix 614141 and item reference 99999, you can create the 12-digit GTIN 614141999996.
77
77
  - A U.P.C. Company Prefix may be used to create other GS1 identifiers, but it must first be converted to a GS1 Company Prefix by prepending a zero.
78
78
  - For example, using U.P.C. Company Prefix 614141 and model reference ABCDEF, you can convert the prefix to GS1 Company Prefix 0614141 and create the GMN 0614141ABCDEF8P.
79
- - [GS1-8 Prefix](https://aidc-toolkit.com/api/GS1/variables/PrefixTypes.html#gs18prefix)
79
+ - [GS1-8 Prefix](https://aidc-toolkit.com/v1.0/api/GS1/variables/PrefixTypes.html#gs18prefix)
80
80
  - This is a special version of the GS1 Company Prefix used **only** to create 8-digit GTINs for special purpose applications where a trade item isn't large enough to support a 13-digit GTIN. GS1-8 Prefixes are managed by individual GS1 Member Organizations and, while they are supported within this library, they are not available to users directly.
81
81
  - A GS1-8 Prefix may **not** be used to create other GS1 identifiers.
82
82
 
@@ -92,111 +92,111 @@ If you're unsure, contact your local [GS1 Member Organization](https://www.gs1.o
92
92
 
93
93
  ### Identifier Types and Descriptors
94
94
 
95
- All identifier types are supported. Constants are defined in [`IdentifierTypes`](https://aidc-toolkit.com/api/GS1/variables/IdentifierTypes.html), which is used to define the type alias [`IdentifierType`](https://aidc-toolkit.com/api/GS1/type-aliases/IdentifierType.html).
95
+ All identifier types are supported. Constants are defined in [`IdentifierTypes`](https://aidc-toolkit.com/v1.0/api/GS1/variables/IdentifierTypes.html), which is used to define the type alias [`IdentifierType`](https://aidc-toolkit.com/v1.0/api/GS1/type-aliases/IdentifierType.html).
96
96
 
97
97
  Internally, identifier types are broken down into categories. Each category builds on the one above by adding new properties, defined in a descriptor type:
98
98
 
99
- - [Base identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/IdentifierDescriptor.html)
100
- - [Numeric identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/NumericIdentifierDescriptor.html)
101
- - [GTIN descriptor](https://aidc-toolkit.com/api/GS1/interfaces/GTINDescriptor.html) - Global Trade Item Number
99
+ - [Base identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/IdentifierDescriptor.html)
100
+ - [Numeric identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NumericIdentifierDescriptor.html)
101
+ - [GTIN descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/GTINDescriptor.html) - Global Trade Item Number
102
102
  - *GTIN-13*
103
103
  - *GTIN-12*
104
104
  - *GTIN-8*
105
- - [Non-GTIN numeric identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/NonGTINNumericIdentifierDescriptor.html)
106
- - [Non-serializable numeric identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/NonSerializableNumericIdentifierDescriptor.html)
105
+ - [Non-GTIN numeric identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NonGTINNumericIdentifierDescriptor.html)
106
+ - [Non-serializable numeric identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NonSerializableNumericIdentifierDescriptor.html)
107
107
  - *GLN* - Global Location Number
108
108
  - *SSCC* - Serial Shipping Container Code
109
109
  - *GSRN* - Global Service Relation Number
110
110
  - *GSIN* - Global Shipment Identification Number
111
- - [Serializable numeric identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/SerializableNumericIdentifierDescriptor.html)
111
+ - [Serializable numeric identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/SerializableNumericIdentifierDescriptor.html)
112
112
  - *GRAI* - Global Returnable Asset Identifier
113
113
  - *GDTI* - Global Document Type Identifier
114
114
  - *GCN* - Global Coupon Number
115
- - [Non-numeric identifier descriptor](https://aidc-toolkit.com/api/GS1/interfaces/NonNumericIdentifierDescriptor.html)
115
+ - [Non-numeric identifier descriptor](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NonNumericIdentifierDescriptor.html)
116
116
  - *GIAI* - Global Individual Asset Identifier
117
117
  - *GINC* - Global Identification Number for Consignment
118
118
  - *CPID* - Component/Part Identifier
119
119
  - *GMN* - Global Model Number
120
120
 
121
- The identifier descriptors are stored in a [record object](https://aidc-toolkit.com/api/GS1/variables/IdentifierDescriptors.html), keyed on identifier type. The GTIN entry is an array (GTIN-13, GTIN-12, and GTIN-8); all others are singletons. To deal with an unknown identifier descriptor, there are typeguards available, aligned with the categories above:
121
+ The identifier descriptors are stored in a [record object](https://aidc-toolkit.com/v1.0/api/GS1/variables/IdentifierDescriptors.html), keyed on identifier type. The GTIN entry is an array (GTIN-13, GTIN-12, and GTIN-8); all others are singletons. To deal with an unknown identifier descriptor, there are typeguards available, aligned with the categories above:
122
122
 
123
- - [`isGTINDescriptors()`](https://aidc-toolkit.com/api/GS1/functions/isGTINDescriptors.html)
123
+ - [`isGTINDescriptors()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isGTINDescriptors.html)
124
124
  - Special case to identify the GTIN descriptors array entry.
125
- - [`isNumericIdentifierDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isNumericIdentifierDescriptor.html)
126
- - [`isGTINDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isGTINDescriptor.html)
127
- - [`isNonGTINNumericIdentifierDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isNonGTINNumericIdentifierDescriptor.html)
128
- - [`isNonSerializableNumericIdentifierDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isNonSerializableNumericIdentifierDescriptor.html)
129
- - [`isSerializableNumericIdentifierDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isSerializableNumericIdentifierDescriptor.html)
130
- - [`isNonNumericIdentifierDescriptor()`](https://aidc-toolkit.com/api/GS1/functions/isNonNumericIdentifierDescriptor.html)
125
+ - [`isNumericIdentifierDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNumericIdentifierDescriptor.html)
126
+ - [`isGTINDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isGTINDescriptor.html)
127
+ - [`isNonGTINNumericIdentifierDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonGTINNumericIdentifierDescriptor.html)
128
+ - [`isNonSerializableNumericIdentifierDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonSerializableNumericIdentifierDescriptor.html)
129
+ - [`isSerializableNumericIdentifierDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isSerializableNumericIdentifierDescriptor.html)
130
+ - [`isNonNumericIdentifierDescriptor()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonNumericIdentifierDescriptor.html)
131
131
 
132
132
  ### Identifier Validation
133
133
 
134
- Every identifier descriptor interface has a corresponding identifier validator class, which implements the interface and adds validation logic. The core method is [`validate()`](https://aidc-toolkit.com/api/GS1/classes/IdentifierValidator.html#validate), which takes an identifier string and either returns if valid or throws a [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) if not.
134
+ Every identifier descriptor interface has a corresponding identifier validator class, which implements the interface and adds validation logic. The core method is [`validate()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/IdentifierValidator.html#validate), which takes an identifier string and either returns if valid or throws a [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) if not.
135
135
 
136
136
  Validation is based on the string validation functions defined in the Utility package. As such, the `validate()` method can take additional validation parameters, depending on the identifier type.
137
137
 
138
- - [Base identifier validator](https://aidc-toolkit.com/api/GS1/classes/IdentifierValidator.html)
139
- - [Numeric identifier validator](https://aidc-toolkit.com/api/GS1/classes/NumericIdentifierValidator.html)
138
+ - [Base identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/IdentifierValidator.html)
139
+ - [Numeric identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NumericIdentifierValidator.html)
140
140
  - Validation can include a position offset, but this is managed internally by derived classes.
141
- - [GTIN validator](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html)
142
- - [Non-GTIN numeric identifier validator](https://aidc-toolkit.com/api/GS1/classes/NonGTINNumericIdentifierValidator.html)
143
- - [Non-serializable numeric identifier validator](https://aidc-toolkit.com/api/GS1/classes/NonSerializableNumericIdentifierValidator.html)
144
- - [Serializable numeric identifier validator](https://aidc-toolkit.com/api/GS1/classes/SerializableNumericIdentifierValidator.html)
145
- - [Non-numeric identifier validator](https://aidc-toolkit.com/api/GS1/classes/NonNumericIdentifierValidator.html)
141
+ - [GTIN validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html)
142
+ - [Non-GTIN numeric identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonGTINNumericIdentifierValidator.html)
143
+ - [Non-serializable numeric identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonSerializableNumericIdentifierValidator.html)
144
+ - [Serializable numeric identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/SerializableNumericIdentifierValidator.html)
145
+ - [Non-numeric identifier validator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonNumericIdentifierValidator.html)
146
146
  - Validation can include exclusion of all-numeric references. The check character pair, if applicable, is not included in the all-numeric check (e.g., GMNs `9528888123423` and `952999912343X` both fail exclude all-numeric validation even though the latter has a non-numeric check character pair).
147
147
 
148
- The identifier validators are stored in a [record object](https://aidc-toolkit.com/api/GS1/variables/IdentifierValidators.html), keyed on identifier type. The GTIN entry is an array (GTIN-13, GTIN-12, and GTIN-8); all others are singletons. To deal with an unknown identifier validator, there are typeguards available, aligned with the categories above:
148
+ The identifier validators are stored in a [record object](https://aidc-toolkit.com/v1.0/api/GS1/variables/IdentifierValidators.html), keyed on identifier type. The GTIN entry is an array (GTIN-13, GTIN-12, and GTIN-8); all others are singletons. To deal with an unknown identifier validator, there are typeguards available, aligned with the categories above:
149
149
 
150
- - [`isGTINValidators()`](https://aidc-toolkit.com/api/GS1/functions/isGTINValidators.html)
150
+ - [`isGTINValidators()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isGTINValidators.html)
151
151
  - Special case to identify the GTIN validators array entry.
152
- - [`isNumericIdentifierValidator()`](https://aidc-toolkit.com/api/GS1/functions/isNumericIdentifierValidator.html)
153
- - [`isGTINValidator()`](https://aidc-toolkit.com/api/GS1/functions/isGTINValidator.html)
154
- - [`isNonGTINNumericIdentifierValidator()`](https://aidc-toolkit.com/api/GS1/functions/isNonGTINNumericIdentifierValidator.html)
155
- - [`isNonSerializableNumericIdentifierValidator()`](https://aidc-toolkit.com/api/GS1/functions/isNonSerializableNumericIdentifierValidator.html)
156
- - [`isSerializableNumericIdentifierValidator()`](https://aidc-toolkit.com/api/GS1/functions/isSerializableNumericIdentifierValidator.html)
157
- - [`isNonNumericIdentifierValidator()`](https://aidc-toolkit.com/api/GS1/functions/isNonNumericIdentifierValidator.html)
152
+ - [`isNumericIdentifierValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNumericIdentifierValidator.html)
153
+ - [`isGTINValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isGTINValidator.html)
154
+ - [`isNonGTINNumericIdentifierValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonGTINNumericIdentifierValidator.html)
155
+ - [`isNonSerializableNumericIdentifierValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonSerializableNumericIdentifierValidator.html)
156
+ - [`isSerializableNumericIdentifierValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isSerializableNumericIdentifierValidator.html)
157
+ - [`isNonNumericIdentifierValidator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonNumericIdentifierValidator.html)
158
158
 
159
159
  #### GTIN Validation
160
160
 
161
- GTIN validation is special in that there are multiple lengths of GTINs and variations in use cases that limit what GTINs may be used for what purpose. To support this, there are static functions defined in the [`GTINValidator`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html) class:
161
+ GTIN validation is special in that there are multiple lengths of GTINs and variations in use cases that limit what GTINs may be used for what purpose. To support this, there are static functions defined in the [`GTINValidator`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html) class:
162
162
 
163
- - [`zeroSuppress()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#zerosuppress) - Applies a special compression algorithm to certain GTIN-12s to suppress zeros and reduce the length to 8 digits for encoding in a UPC-E barcode.
164
- - [`zeroExpand()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#zeroexpand) - Expands a zero-suppressed GTIN-12 to its original form.
165
- - [`convertToGTIN14()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#converttogtin14) - Converts any GTIN to GTIN-14 form with an indicator digit. If the indicator digit is not provided, the default is "0", unless the input is already a GTIN-14, in which case the indicator digit is preserved.
166
- - [`normalize()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#normalize) - Normalizes a GTIN to the shortest form possible.
167
- - [`validateAny()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#validateany) - Validates a GTIN of any length and optionally against the [level at which it is used](https://aidc-toolkit.com/api/GS1/variables/GTINLevels.html).
168
- - [`validateGTIN14()`](https://aidc-toolkit.com/api/GS1/classes/GTINValidator.html#validategtin14) - The GTIN-14 doesn't have its own instance of `GTINValidator` as it is subordinate to the other lengths, so this method specifically validates a GTIN-14.
163
+ - [`zeroSuppress()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#zerosuppress) - Applies a special compression algorithm to certain GTIN-12s to suppress zeros and reduce the length to 8 digits for encoding in a UPC-E barcode.
164
+ - [`zeroExpand()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#zeroexpand) - Expands a zero-suppressed GTIN-12 to its original form.
165
+ - [`convertToGTIN14()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#converttogtin14) - Converts any GTIN to GTIN-14 form with an indicator digit. If the indicator digit is not provided, the default is "0", unless the input is already a GTIN-14, in which case the indicator digit is preserved.
166
+ - [`normalize()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#normalize) - Normalizes a GTIN to the shortest form possible.
167
+ - [`validateAny()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#validateany) - Validates a GTIN of any length and optionally against the [level at which it is used](https://aidc-toolkit.com/v1.0/api/GS1/variables/GTINLevels.html).
168
+ - [`validateGTIN14()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINValidator.html#validategtin14) - The GTIN-14 doesn't have its own instance of `GTINValidator` as it is subordinate to the other lengths, so this method specifically validates a GTIN-14.
169
169
 
170
170
  ### Identifier Creation
171
171
 
172
172
  Every identifier validator class has an extending identifier creator class which adds creation logic. To create an identifier, **you must have a properly licensed GS1 Company Prefix or U.P.C. Company Prefix**. To acquire a licence, contact your local [GS1 Member Organization](https://www.gs1.org/contact/overview).
173
173
 
174
- Creation is based on the string creation functions defined in the Utility package, with additional rules for prefixes and check digits and check character pairs. The constructor for every class takes a [`PrefixProvider`](https://aidc-toolkit.com/api/GS1/interfaces/PrefixProvider.html) object, which defines the prefix type and the prefix itself. Every class has one or more `create*()` methods whose parameters depend on the identifier type.
174
+ Creation is based on the string creation functions defined in the Utility package, with additional rules for prefixes and check digits and check character pairs. The constructor for every class takes a [`PrefixProvider`](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/PrefixProvider.html) object, which defines the prefix type and the prefix itself. Every class has one or more `create*()` methods whose parameters depend on the identifier type.
175
175
 
176
176
  Architecturally, base functionality is defined via interfaces, with only concrete classes exposed.
177
177
 
178
- - [Base identifier creator](https://aidc-toolkit.com/api/GS1/interfaces/IdentifierCreator.html)
179
- - [Numeric identifier creator](https://aidc-toolkit.com/api/GS1/interfaces/NumericIdentifierCreator.html)
180
- - [`create()`](https://aidc-toolkit.com/api/GS1/interfaces/NumericIdentifierCreator.html#create) - Create a single numeric identifier or a sequence of numeric identifiers.
181
- - [`createAll()`](https://aidc-toolkit.com/api/GS1/interfaces/NumericIdentifierCreator.html#createall) - Create all numeric identifiers for a prefix.
182
- - [GTIN creator](https://aidc-toolkit.com/api/GS1/classes/GTINCreator.html)
183
- - [`createGTIN14()`](https://aidc-toolkit.com/api/GS1/classes/GTINCreator.html#creategtin14) - Create a single GTIN-14 or a sequence of GTIN-14s.
184
- - [Non-GTIN numeric identifier creator](https://aidc-toolkit.com/api/GS1/interfaces/NonGTINNumericIdentifierCreator.html)
185
- - [Non-serializable numeric identifier creator](https://aidc-toolkit.com/api/GS1/classes/NonSerializableNumericIdentifierCreator.html)
186
- - [Serializable numeric identifier creator](https://aidc-toolkit.com/api/GS1/classes/SerializableNumericIdentifierCreator.html)
187
- - [`createSerialized()`](https://aidc-toolkit.com/api/GS1/classes/SerializableNumericIdentifierCreator.html#createserialized) - Create a single serialized numeric identifier or a sequence of serialized numeric identifiers.
188
- - [`concatenate()`](https://aidc-toolkit.com/api/GS1/classes/SerializableNumericIdentifierCreator.html#concatenate) - Concatenate a base (non-serialized) with a single serialized component or a sequence of serialized components.
189
- - [Non-numeric identifier creator](https://aidc-toolkit.com/api/GS1/classes/NonNumericIdentifierCreator.html)
190
- - [`create()`](https://aidc-toolkit.com/api/GS1/classes/NonNumericIdentifierCreator.html#create) - Create a single non-numeric identifier or a sequence of non-numeric i[numeric-identifier-creator.ts](src/numeric-identifier-creator.ts)dentifiers.
178
+ - [Base identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/IdentifierCreator.html)
179
+ - [Numeric identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NumericIdentifierCreator.html)
180
+ - [`create()`](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NumericIdentifierCreator.html#create) - Create a single numeric identifier or a sequence of numeric identifiers.
181
+ - [`createAll()`](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NumericIdentifierCreator.html#createall) - Create all numeric identifiers for a prefix.
182
+ - [GTIN creator](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINCreator.html)
183
+ - [`createGTIN14()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GTINCreator.html#creategtin14) - Create a single GTIN-14 or a sequence of GTIN-14s.
184
+ - [Non-GTIN numeric identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/NonGTINNumericIdentifierCreator.html)
185
+ - [Non-serializable numeric identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonSerializableNumericIdentifierCreator.html)
186
+ - [Serializable numeric identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/classes/SerializableNumericIdentifierCreator.html)
187
+ - [`createSerialized()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/SerializableNumericIdentifierCreator.html#createserialized) - Create a single serialized numeric identifier or a sequence of serialized numeric identifiers.
188
+ - [`concatenate()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/SerializableNumericIdentifierCreator.html#concatenate) - Concatenate a base (non-serialized) with a single serialized component or a sequence of serialized components.
189
+ - [Non-numeric identifier creator](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonNumericIdentifierCreator.html)
190
+ - [`create()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/NonNumericIdentifierCreator.html#create) - Create a single non-numeric identifier or a sequence of non-numeric i[numeric-identifier-creator.ts](src/numeric-identifier-creator.ts)dentifiers.
191
191
 
192
192
  Because identifier creators depend on a prefix, there are no instantiations of them. To deal with an unknown identifier creator, there are typeguards available, aligned with the categories above:
193
193
 
194
- - [`isNumericIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/functions/isNumericIdentifierCreator.html)
195
- - [`isGTINCreator()`](https://aidc-toolkit.com/api/GS1/functions/isGTINCreator.html)
196
- - [`isNonGTINNumericIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/functions/isNonGTINNumericIdentifierCreator.html)
197
- - [`isNonSerializableNumericIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/functions/isNonSerializableNumericIdentifierCreator.html)
198
- - [`isSerializableNumericIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/functions/isSerializableNumericIdentifierCreator.html)
199
- - [`isNonNumericIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/functions/isNonNumericIdentifierCreator.html)
194
+ - [`isNumericIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNumericIdentifierCreator.html)
195
+ - [`isGTINCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isGTINCreator.html)
196
+ - [`isNonGTINNumericIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonGTINNumericIdentifierCreator.html)
197
+ - [`isNonSerializableNumericIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonSerializableNumericIdentifierCreator.html)
198
+ - [`isSerializableNumericIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isSerializableNumericIdentifierCreator.html)
199
+ - [`isNonNumericIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/isNonNumericIdentifierCreator.html)
200
200
 
201
201
  #### Sparse Creation
202
202
 
@@ -231,7 +231,7 @@ console.log(Array.from(ssccCreator.create(new Sequence(0, 4))));
231
231
  console.log(Array.from(ssccCreator.create(new Sequence(0, 4), true)));
232
232
  ```
233
233
 
234
- Each call to `create()` returns the first four SSCCs in sequence, but the second call uses the [`EncryptionTransformer`](https://aidc-toolkit.com/api/Utility/classes/EncryptionTransformer.html) to obfuscate the sequence.
234
+ Each call to `create()` returns the first four SSCCs in sequence, but the second call uses the [`EncryptionTransformer`](https://aidc-toolkit.com/v1.0/api/Utility/classes/EncryptionTransformer.html) to obfuscate the sequence.
235
235
 
236
236
  The `create()` method for non-numeric identifiers works on a string or sequence of strings, so it doesn't support the `sparse` parameter. The obfuscation must applied to the strings before they are passed to the creator:
237
237
 
@@ -264,31 +264,31 @@ console.log(Array.from(gmnCreator.create(
264
264
  )));
265
265
  ```
266
266
 
267
- Again, each call to `create()` returns the first four GMNs in sequence (indirectly via the alphanumeric string creator), but the second call uses the [`EncryptionTransformer`](https://aidc-toolkit.com/api/Utility/classes/EncryptionTransformer.html) to obfuscate the sequence.
267
+ Again, each call to `create()` returns the first four GMNs in sequence (indirectly via the alphanumeric string creator), but the second call uses the [`EncryptionTransformer`](https://aidc-toolkit.com/v1.0/api/Utility/classes/EncryptionTransformer.html) to obfuscate the sequence.
268
268
 
269
269
  ### Prefix Manager
270
270
 
271
- The [`PrefixProvider`](https://aidc-toolkit.com/api/GS1/interfaces/PrefixProvider.html) required by every identifier creator is just an object. It has no validation logic, and the creator classes assume that its contents are correct. The [`PrefixManager`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html) class implements the `PrefixProvider` interface and provides a convenient way to access the various identifier creators. It also manages the tweak values for sparse numeric identifier creation.
271
+ The [`PrefixProvider`](https://aidc-toolkit.com/v1.0/api/GS1/interfaces/PrefixProvider.html) required by every identifier creator is just an object. It has no validation logic, and the creator classes assume that its contents are correct. The [`PrefixManager`](https://aidc-toolkit.com/v1.0/api/GS1/classes/PrefixManager.html) class implements the `PrefixProvider` interface and provides a convenient way to access the various identifier creators. It also manages the tweak values for sparse numeric identifier creation.
272
272
 
273
- There are two ways to create a `PrefixManager`, both of which take a [prefix type](https://aidc-toolkit.com/api/GS1/type-aliases/PrefixType.html) and a prefix:
273
+ There are two ways to create a `PrefixManager`, both of which take a [prefix type](https://aidc-toolkit.com/v1.0/api/GS1/type-aliases/PrefixType.html) and a prefix:
274
274
 
275
275
  - Directly via the constructor.
276
- - Indirectly via the [`PrefixManager.get()`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html#get) static method.
276
+ - Indirectly via the [`PrefixManager.get()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/PrefixManager.html#get) static method.
277
277
 
278
278
  Using the static method is preferred because guarantees that only one instance of the prefix manager is maintained for each prefix and it preserves changes to the prefix manager, such as setting the tweak factor for sparse numeric identifier creation.
279
279
 
280
280
  The default tweak factor for sparse numeric identifier creation is the numeric value of "1" plus the GS1 Company Prefix (e.g., 19521234 for GS1 Company Prefix 9521234, 10614141 for U.P.C. Company Prefix 614141). The tweak factor isn't used directly by the identifier creators; instead, it is used as a multiplier together with an internally-defined prime number per numeric identifier type so that each numeric identifier creator returns a different sequence of identifiers.
281
281
 
282
- The prefix manager maintains a cache of identifier creators, each accessible by name (e.g., `prefixManager.ssccCreator` for the SSCC creator), as well as the method [`getIdentifierCreator()`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html#getidentifiercreator) to get any identifier creator by identifier type.
282
+ The prefix manager maintains a cache of identifier creators, each accessible by name (e.g., `prefixManager.ssccCreator` for the SSCC creator), as well as the method [`getIdentifierCreator()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/PrefixManager.html#getidentifiercreator) to get any identifier creator by identifier type.
283
283
 
284
284
  ### Additional Identifier Capability
285
285
 
286
286
  #### Variable Measure
287
287
 
288
- The [`VariableMeasure`](https://aidc-toolkit.com/api/GS1/classes/VariableMeasure.html) class provides static methods to parse and create a variable measure identifiers:
288
+ The [`VariableMeasure`](https://aidc-toolkit.com/v1.0/api/GS1/classes/VariableMeasure.html) class provides static methods to parse and create a variable measure identifiers:
289
289
 
290
- - [`parseRCN()`](https://aidc-toolkit.com/api/GS1/classes/VariableMeasure.html#parsercn) - Parse a Restricted Circulation Number (RCN) into an item reference and price or weight.
291
- - [`createRCN()`](https://aidc-toolkit.com/api/GS1/classes/VariableMeasure.html#creatercn) - Create a Restricted Circulation Number (RCN) from an item reference and price or weight.
290
+ - [`parseRCN()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/VariableMeasure.html#parsercn) - Parse a Restricted Circulation Number (RCN) into an item reference and price or weight.
291
+ - [`createRCN()`](https://aidc-toolkit.com/v1.0/api/GS1/classes/VariableMeasure.html#creatercn) - Create a Restricted Circulation Number (RCN) from an item reference and price or weight.
292
292
 
293
293
  ### GS1 Services
294
294
 
@@ -296,27 +296,10 @@ GS1 provides a lookup service called [Verified by GS1](https://www.gs1.org/servi
296
296
 
297
297
  #### Verified by GS1
298
298
 
299
- The [`verifiedByGS1()`](https://aidc-toolkit.com/api/GS1/functions/verifiedByGS1.html) function creates a [`Hyperlink`](https://aidc-toolkit.com/api/Core/interfaces/Hyperlink.html) object with the appropriate path to query any GS1 identifier. The link is to a user interface, so automated retrieval of the data is not supported.
299
+ The [`verifiedByGS1()`](https://aidc-toolkit.com/v1.0/api/GS1/functions/verifiedByGS1.html) function creates a [`Hyperlink`](https://aidc-toolkit.com/v1.0/api/Core/interfaces/Hyperlink.html) object with the appropriate path to query any GS1 identifier. The link is to a user interface, so automated retrieval of the data is not supported.
300
300
 
301
301
  #### GS1 Company Prefix Length Determination
302
302
 
303
- GS1 Company Prefix length determination is required when encoding a GS1 identifier as an EPC URN. Though this is typically done by the GS1 Company Prefix licensee (who knows the length), it's occasionally required by downstream trading partners such as distributors.
303
+ GS1 Company Prefix length determination is required when encoding a GS1 identifier as an EPC URN. Although this is typically done by the GS1 Company Prefix licensee (who knows the length), it's occasionally required by downstream trading partners such as distributors.
304
304
 
305
- This functionality part of the [`PrefixManager`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html) class.
306
-
307
- The first step is to load the GS1 Company Prefix length data. This is done using [`loadGCPLengthData()`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html#loadgcplengthdata) static method, which takes a [`GCPLengthCache`](https://aidc-toolkit.com/api/GS1/classes/GCPLengthCache.html) object. The cache object is used to store the data so that it can be shared across multiple instances of the prefix manager.
308
-
309
- The `loadGCPLengthData()` method works as follows:
310
-
311
- - If the next check date/time is in the future, the method returns immediately, regardless of whether any data is available. It does this to prevent a large number of requests to the source in the event of a failure.
312
- - Otherwise, if the cache date/time is undefined or less than the source date/time, it loads from the source, converts the data if necessary, and updates the cache.
313
- - Otherwise, it continues with the cached data.
314
- - The next check date/time is updated to the later of the source date/time plus one week and the current date/time plus one day.
315
-
316
- The base class implementation of the `GCPLengthCache` manages only the cache itself, and it requires an application-provided [`AppDataStorage`](https://aidc-toolkit.com/api/Core/classes/AppDataStorage.html) storage implementation. The source is expected to be either a [`GCPLengthData`](https://aidc-toolkit.com/api/GS1/interfaces/GCPLengthData.html) object (created via another cache implementation) or a [`GCPLengthSourceJSON`](https://aidc-toolkit.com/api/GS1/interfaces/GCPLengthSourceJSON.html) object, which is the format of the file provided by GS1.
317
-
318
- The [`RemoteGCPLengthCache`](https://aidc-toolkit.com/api/GS1/classes/RemoteGCPLengthCache.html) class provides access to the data from a remote source, by default the AIDC Toolkit website. If any error occurs, the next check date/time is set to the current date/time plus ten minutes to prevent the network from being overloaded.
319
-
320
- The data on the AIDC Toolkit website is updated regularly with the data provided by GS1, and it's stored in binary format for faster retrieval.
321
-
322
- Once the data is loaded, the [`gcpLength()`](https://aidc-toolkit.com/api/GS1/classes/PrefixManager.html#gcplength) method can be used to get the length of a GS1 Company Prefix for a given identifier type.
305
+ This functionality is provided by the [`GCPLength`](https://aidc-toolkit.com/v1.0/api/GS1/classes/GCPLength.html) class.
@@ -50,7 +50,12 @@ export declare abstract class GCPLengthCache extends Cache<GCPLengthData, GCPLen
50
50
  update(nextCheckDateTime: Date, _cacheDateTime?: Date, cacheData?: GCPLengthData): Promise<void>;
51
51
  }
52
52
  /**
53
- * GS1 Company Prefix length cache with remote source.
53
+ * GS1 Company Prefix length cache with remote source. This class provides access to the data from a remote source, by
54
+ * default the AIDC Toolkit website. If any error occurs, the next check date/time is set to the current date/time plus
55
+ * ten minutes to prevent the network from being overloaded.
56
+ *
57
+ * The data on the AIDC Toolkit website is updated regularly with the data provided by GS1, and it's stored in binary
58
+ * format for faster retrieval.
54
59
  */
55
60
  export declare class RemoteGCPLengthCache extends GCPLengthCache {
56
61
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"gcp-length-cache.d.ts","sourceRoot":"","sources":["../src/gcp-length-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,cAAc,EACnB,KAAK,EAIR,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEH,KAAK,aAAa,EAElB,KAAK,mBAAmB,EAG3B,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,8BAAsB,cAAe,SAAQ,KAAK,CAAC,aAAa,EAAE,aAAa,GAAG,mBA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 Company Prefix length cache with remote source.
136
+ * GS1 Company Prefix length cache with remote source. This class provides access to the data from a remote source, by
137
+ * default the AIDC Toolkit website. If any error occurs, the next check date/time is set to the current date/time plus
138
+ * ten minutes to prevent the network from being overloaded.
139
+ *
140
+ * The data on the AIDC Toolkit website is updated regularly with the data provided by GS1, and it's stored in binary
141
+ * format for faster retrieval.
137
142
  */
138
143
  export class RemoteGCPLengthCache extends GCPLengthCache {
139
144
  /**
@@ -181,7 +186,7 @@ export class RemoteGCPLengthCache extends GCPLengthCache {
181
186
  async #getRemoteAppData(pathKey, asBinary, callback) {
182
187
  return this.#remoteAppDataStorage.read(pathKey, asBinary).then((appData) => {
183
188
  if (appData === undefined) {
184
- throw new RangeError(i18nextGS1.t("Prefix.gs1CompanyPrefixLengthDataFileNotFound", {
189
+ throw new RangeError(i18nextGS1.t("GCPLength.gs1CompanyPrefixLengthDataFileNotFound", {
185
190
  key: pathKey
186
191
  }));
187
192
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gcp-length-cache.js","sourceRoot":"","sources":["../src/gcp-length-cache.ts"],"names":[],"mappings":";AAAA,OAAO,EAGH,KAAK,EACL,IAAI,EACJ,oBAAoB,EACpB,gBAAgB,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAKH,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAgB,cAAe,SAAQ,KAAyD;IAClG;;OAEG;IACH,MAAM,CAAC,oBAAoB,GAAG,YAAY,CAAC;IAE3C;;OAEG;IACH,MAAM,CAAC,gCAAgC,GAAG,iCAAiC,CAAC;IAE5E;;OAEG;IACH,MAAM,CAAC,kBAAkB,GAAG,mBAAmB,CAAC;IAEhD;;OAEG;IACH,MAAM,CAAC,gBAAgB,GAAG,iBAAiB,CAAC;IAE5C;;OAEG;IACM,eAAe,CAA0B;IAElD;;OAEG;IAC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Ac;QACvB,kCAAkC;QAClC,OAAO,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,kBAAkB,EAAE,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE;YACtF,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,gDAAgD;gBAChD,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAChE,CAAC;YAED,IAAI,CAAC,sBAAsB,GAAG,OAAO,CAAC;YAEtC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;QAChD,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACH,IAAa,UAAU;QACnB,OAAO,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE;YACnF,MAAM,eAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC;YAEpD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;gBAChC,gDAAgD;gBAChD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACnE,CAAC;YAED,IAAI,CAAC,CAAC,OAAO,YAAY,UAAU,CAAC,EAAE,CAAC;gBACnC,gDAAgD;gBAChD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC9D,CAAC;YAED,OAAO;gBACH,GAAG,eAAe;gBAClB,IAAI,EAAE,OAAO;aAChB,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { GCPLengthHeader } from "./gcp-length-data.js";
2
+ /**
3
+ * Leaf of GS1 Company Prefix length tree.
4
+ */
5
+ export interface Leaf {
6
+ readonly length: number;
7
+ }
8
+ /**
9
+ * Branch of GS1 Company Prefix length tree.
10
+ */
11
+ export interface Branch {
12
+ readonly childNodes: ReadonlyArray<Node | undefined>;
13
+ }
14
+ /**
15
+ * Root of GS1 Company Prefix length tree.
16
+ */
17
+ export interface Root extends GCPLengthHeader, Branch {
18
+ }
19
+ /**
20
+ * Node in GS1 Company Prefix length tree.
21
+ */
22
+ export type Node = Branch | Leaf;
23
+ /**
24
+ * Determine if a node is a leaf.
25
+ *
26
+ * @param node
27
+ * Node.
28
+ *
29
+ * @returns
30
+ * True if node is a leaf.
31
+ */
32
+ export declare function isLeaf(node: Node): node is Leaf;
33
+ //# sourceMappingURL=gcp-length-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcp-length-tree.d.ts","sourceRoot":"","sources":["../src/gcp-length-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,IAAI;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,IAAK,SAAQ,eAAe,EAAE,MAAM;CACpD;AAED;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,CAAC;AAEjC;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,IAAI,IAAI,CAE/C"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Determine if a node is a leaf.
3
+ *
4
+ * @param node
5
+ * Node.
6
+ *
7
+ * @returns
8
+ * True if node is a leaf.
9
+ */
10
+ export function isLeaf(node) {
11
+ return "length" in node;
12
+ }
13
+ //# sourceMappingURL=gcp-length-tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcp-length-tree.js","sourceRoot":"","sources":["../src/gcp-length-tree.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAAC,IAAU;IAC7B,OAAO,QAAQ,IAAI,IAAI,CAAC;AAC5B,CAAC"}
@@ -1,61 +1,75 @@
1
1
  import type { GCPLengthCache } from "./gcp-length-cache.js";
2
- import { type GCPLengthHeader } from "./gcp-length-data.js";
2
+ import * as GCPLengthTree from "./gcp-length-tree.js";
3
3
  import { type IdentifierType } from "./identifier-type.js";
4
4
  /**
5
- * Leaf of GS1 Company Prefix length tree.
5
+ * Interim branch of GS1 Company Prefix length tree with writeable child nodes.
6
6
  */
7
- export interface Leaf {
8
- length: number;
7
+ export interface InterimBranch {
8
+ readonly childNodes: Array<InterimBranch | GCPLengthTree.Leaf | undefined>;
9
9
  }
10
10
  /**
11
- * Branch of GS1 Company Prefix length tree.
12
- */
13
- export interface Branch {
14
- childNodes: Array<Node | undefined>;
15
- }
16
- /**
17
- * Root of GS1 Company Prefix length tree.
18
- */
19
- export interface Root extends GCPLengthHeader, Branch {
20
- }
21
- /**
22
- * Node in GS1 Company Prefix length tree.
23
- */
24
- export type Node = Root | Branch | Leaf;
25
- /**
26
- * Determine if a node is a leaf.
11
+ * GS1 Company Prefix length service. The constructor takes a {@linkcode GCPLengthCache} object, which is responsible
12
+ * for managing the cache and source.
27
13
  *
28
- * @param node
29
- * Node.
14
+ * The first step is to load the GS1 Company Prefix length data. This is done using the
15
+ * {@linkcode GCPLength.load | load()} method, which works as follows:
30
16
  *
31
- * @returns
32
- * True if node is a leaf.
33
- */
34
- export declare function isLeaf(node: Node): node is Leaf;
35
- /**
36
- * Load the GS1 Company Prefix length data.
37
- *
38
- * @param gcpLengthCache
39
- * GS1 Company Prefix length cache.
40
- *
41
- * @returns
42
- * Root of tree.
43
- */
44
- export declare function loadData(gcpLengthCache: GCPLengthCache): Promise<Root | undefined>;
45
- /**
46
- * Get the length of a GS1 Company Prefix for an identifier.
47
- *
48
- * @param root
49
- * Root of tree.
17
+ * - If the next check date/time is in the future, the method returns immediately, regardless of whether any data is
18
+ * available. It does this to prevent a large number of requests to the source in the event of a failure.
19
+ * - Otherwise, if the cache date/time is undefined or less than the source date/time, it loads from the source,
20
+ * converts the data if necessary, and updates the cache.
21
+ * - Otherwise, it continues with the cached data.
22
+ * - The next check date/time is updated to the later of the source date/time plus one week and the current date/time
23
+ * plus one day.
50
24
  *
51
- * @param identifierType
52
- * Identifier type.
25
+ * The base class implementation of the `GCPLengthCache` manages only the cache itself, and it requires an
26
+ * application-provided storage implementation. The source is expected to be either a {@linkcode GCPLengthData} object
27
+ * (created via another cache implementation) or a {@linkcode GCPLengthSourceJSON} object, which is the format of the
28
+ * file provided by GS1.
53
29
  *
54
- * @param identifier
55
- * Identifier.
56
- *
57
- * @returns
58
- * Length of GS1 Company Prefix, 0 if not a GS1 Company Prefix, or -1 if not found.
30
+ * Once the data is loaded, the {@linkcode GCPLength.lengthOf | lengthOf()} method can be used to get the length of a
31
+ * GS1 Company Prefix for an identifier type and identifier.
59
32
  */
60
- export declare function getFor(root: Root, identifierType: IdentifierType, identifier: string): number;
33
+ export declare class GCPLength {
34
+ #private;
35
+ /**
36
+ * Constructor.
37
+ *
38
+ * @param gcpLengthCache
39
+ * GS1 Company Prefix length cache.
40
+ */
41
+ constructor(gcpLengthCache: GCPLengthCache);
42
+ /**
43
+ * Get the GS1 Company Prefix length tree root.
44
+ *
45
+ * @returns
46
+ * GS1 Company Prefix length tree root.
47
+ */
48
+ get root(): GCPLengthTree.Root;
49
+ /**
50
+ * Get the date/time the GS1 Company Prefix length data was last updated.
51
+ */
52
+ get dateTime(): Date;
53
+ /**
54
+ * Get the disclaimer for the GS1 Company Prefix length data.
55
+ */
56
+ get disclaimer(): string;
57
+ /**
58
+ * Load the GS1 Company Prefix length data.
59
+ */
60
+ load(): Promise<void>;
61
+ /**
62
+ * Get the length of a GS1 Company Prefix for an identifier.
63
+ *
64
+ * @param identifierType
65
+ * Identifier type.
66
+ *
67
+ * @param identifier
68
+ * Identifier.
69
+ *
70
+ * @returns
71
+ * Length of GS1 Company Prefix, 0 if not a GS1 Company Prefix, or -1 if not found.
72
+ */
73
+ lengthOf(identifierType: IdentifierType, identifier: string): number;
74
+ }
61
75
  //# sourceMappingURL=gcp-length.d.ts.map