@aidc-toolkit/gs1 1.0.24-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.
- package/dist/index.cjs +562 -373
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +776 -415
- package/dist/index.d.ts +776 -415
- package/dist/index.js +549 -363
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/abstract-identifier-creator.ts +97 -0
- package/src/abstract-identifier-validator.ts +140 -0
- package/src/abstract-numeric-identifier-creator.ts +168 -0
- package/src/abstract-numeric-identifier-validator.ts +69 -0
- package/src/character-set.ts +10 -10
- package/src/check.ts +7 -7
- package/src/content-character-set.ts +29 -0
- package/src/creators.ts +113 -0
- package/src/descriptors.ts +332 -0
- package/src/gtin-creator.ts +7 -6
- package/src/gtin-descriptor.ts +18 -0
- package/src/gtin-type.ts +50 -0
- package/src/gtin-validator.ts +36 -60
- package/src/identifier-creator.ts +11 -75
- package/src/identifier-descriptor.ts +30 -0
- package/src/identifier-type.ts +6 -1
- package/src/identifier-validator.ts +12 -188
- package/src/index.ts +29 -5
- package/src/locale/en/locale-resources.ts +0 -1
- package/src/locale/fr/locale-resources.ts +0 -1
- package/src/non-gtin-numeric-identifier-creator.ts +5 -11
- package/src/non-gtin-numeric-identifier-descriptor.ts +24 -0
- package/src/non-gtin-numeric-identifier-type.ts +7 -0
- package/src/non-gtin-numeric-identifier-validator.ts +8 -42
- package/src/non-numeric-identifier-creator.ts +5 -15
- package/src/non-numeric-identifier-descriptor.ts +29 -0
- package/src/non-numeric-identifier-type.ts +7 -0
- package/src/non-numeric-identifier-validator.ts +15 -53
- package/src/numeric-identifier-creator.ts +20 -163
- package/src/numeric-identifier-descriptor.ts +23 -0
- package/src/numeric-identifier-type.ts +44 -0
- package/src/numeric-identifier-validator.ts +13 -116
- package/src/prefix-manager.ts +84 -142
- package/src/prefix-provider.ts +2 -2
- package/src/prefix-type.ts +6 -1
- package/src/prefix-validator.ts +141 -79
- package/src/serializable-numeric-identifier-creator.ts +4 -14
- package/src/serializable-numeric-identifier-descriptor.ts +29 -0
- package/src/serializable-numeric-identifier-type.ts +9 -0
- package/src/serializable-numeric-identifier-validator.ts +17 -45
- package/src/validators.ts +203 -0
- package/test/creator.test.ts +2 -4
- package/test/gtin-creator.ts +5 -1
- package/test/gtin-validator.test.ts +5 -8
- package/test/identifier-creator.ts +1 -0
- package/test/identifier-validator.ts +2 -2
- package/test/non-gtin-numeric-identifier-creator.ts +8 -92
- package/test/non-gtin-numeric-identifier-validator.ts +1 -1
- package/test/non-numeric-identifier-creator.ts +93 -0
- package/test/numeric-identifier-creator.ts +9 -3
- package/test/numeric-identifier-validator.ts +3 -7
- package/test/serializable-numeric-identifier-creator.ts +10 -2
- package/test/validator.test.ts +59 -35
package/src/prefix-manager.ts
CHANGED
|
@@ -1,57 +1,39 @@
|
|
|
1
|
+
import { type IdentifierCreatorsRecord, isNumericIdentifierCreator } from "./creators";
|
|
1
2
|
import { GTINCreator } from "./gtin-creator";
|
|
2
|
-
import {
|
|
3
|
+
import { GTIN_BASE_TYPES } from "./gtin-type";
|
|
3
4
|
import type { IdentifierCreator } from "./identifier-creator";
|
|
4
5
|
import { type IdentifierType, IdentifierTypes } from "./identifier-type";
|
|
5
6
|
import { i18nextGS1 } from "./locale/i18n";
|
|
6
7
|
import { NonGTINNumericIdentifierCreator } from "./non-gtin-numeric-identifier-creator";
|
|
7
|
-
import {
|
|
8
|
-
GLN_VALIDATOR,
|
|
9
|
-
GSIN_VALIDATOR,
|
|
10
|
-
GSRN_VALIDATOR,
|
|
11
|
-
type NonGTINNumericIdentifierValidator,
|
|
12
|
-
SSCC_VALIDATOR
|
|
13
|
-
} from "./non-gtin-numeric-identifier-validator";
|
|
8
|
+
import type { NonGTINNumericIdentifierType } from "./non-gtin-numeric-identifier-type";
|
|
14
9
|
import { NonNumericIdentifierCreator } from "./non-numeric-identifier-creator";
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
GIAI_VALIDATOR,
|
|
18
|
-
GINC_VALIDATOR,
|
|
19
|
-
GMN_VALIDATOR,
|
|
20
|
-
type NonNumericIdentifierValidator
|
|
21
|
-
} from "./non-numeric-identifier-validator";
|
|
22
|
-
import type { AbstractNumericIdentifierCreator } from "./numeric-identifier-creator";
|
|
23
|
-
import type { NumericIdentifierType } from "./numeric-identifier-validator";
|
|
10
|
+
import type { NonNumericIdentifierType } from "./non-numeric-identifier-type";
|
|
11
|
+
import type { NumericIdentifierType } from "./numeric-identifier-type";
|
|
24
12
|
import type { PrefixProvider } from "./prefix-provider";
|
|
25
13
|
import { type PrefixType, PrefixTypes } from "./prefix-type";
|
|
26
14
|
import { PrefixValidator } from "./prefix-validator";
|
|
27
15
|
import { SerializableNumericIdentifierCreator } from "./serializable-numeric-identifier-creator";
|
|
28
|
-
import {
|
|
29
|
-
GCN_VALIDATOR,
|
|
30
|
-
GDTI_VALIDATOR,
|
|
31
|
-
GRAI_VALIDATOR,
|
|
32
|
-
type SerializableNumericIdentifierValidator
|
|
33
|
-
} from "./serializable-numeric-identifier-validator";
|
|
16
|
+
import type { SerializableNumericIdentifierType } from "./serializable-numeric-identifier-type";
|
|
34
17
|
|
|
35
18
|
/**
|
|
36
19
|
* Prefix manager. This is the core class for identifier creation.
|
|
37
20
|
*
|
|
38
|
-
* A prefix manager may be
|
|
39
|
-
*
|
|
21
|
+
* A prefix manager may be constructed for any {@link PrefixType | prefix type}. Construction may be done directly or
|
|
22
|
+
* via the static {@linkcode PrefixManager.get | get()} method, which allows for caching and reuse. As most applications
|
|
23
|
+
* work with a limited number of prefixes for creating identifiers, caching and reuse may be a more efficient option.
|
|
40
24
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* prefix equal to "614141".
|
|
25
|
+
* The prefix type and prefix are normalized before the prefix manager is constructed, so they may not match the input
|
|
26
|
+
* values. For example, the GS1 Company Prefix 0614141 is equivalent to U.P.C. Company Prefix 614141; both result in a
|
|
27
|
+
* prefix manager with prefix type equal to {@linkcode PrefixTypes.UPCCompanyPrefix} and prefix equal to "614141".
|
|
45
28
|
*
|
|
46
|
-
* To support the creation of sparse identifiers, a prefix manager maintains a {@link tweakFactor | tweak
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* sequence.
|
|
29
|
+
* To support the creation of sparse identifiers, a prefix manager maintains a {@link tweakFactor | tweak factor} which
|
|
30
|
+
* is used, along with a type-specific multiplier, as the tweak when creating numeric identifiers. The default tweak
|
|
31
|
+
* factor is the numeric value of the GS1 Company Prefix representation of the prefix preceded by '1' to ensure
|
|
32
|
+
* uniqueness (i.e., so that prefixes 0 N1 N2 N3... and N1 N2 N3... produce different tweak factors). This is usually
|
|
33
|
+
* sufficient for obfuscation, but as the sparse creation algorithm is reversible and as the GS1 Company Prefix is
|
|
34
|
+
* discoverable via {@link https://www.gs1.org/services/verified-by-gs1 | Verified by GS1}, a user-defined tweak factor
|
|
35
|
+
* should be used if a higher degree of obfuscation is required. When using a tweak factor other than the default, care
|
|
36
|
+
* should be taken to restore it when resuming the application. A tweak factor of 0 creates a straight sequence.
|
|
55
37
|
*/
|
|
56
38
|
export class PrefixManager implements PrefixProvider {
|
|
57
39
|
/**
|
|
@@ -90,12 +72,12 @@ export class PrefixManager implements PrefixProvider {
|
|
|
90
72
|
private readonly _gs1CompanyPrefix: string;
|
|
91
73
|
|
|
92
74
|
/**
|
|
93
|
-
* U.P.C. Company Prefix if prefix type is {@
|
|
75
|
+
* U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix}.
|
|
94
76
|
*/
|
|
95
77
|
private readonly _upcCompanyPrefix: string | undefined;
|
|
96
78
|
|
|
97
79
|
/**
|
|
98
|
-
* GS1-8 Prefix if prefix type is {@
|
|
80
|
+
* GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix}.
|
|
99
81
|
*/
|
|
100
82
|
private readonly _gs18Prefix: string | undefined;
|
|
101
83
|
|
|
@@ -112,30 +94,25 @@ export class PrefixManager implements PrefixProvider {
|
|
|
112
94
|
/**
|
|
113
95
|
* Cached identifier creators.
|
|
114
96
|
*/
|
|
115
|
-
private readonly _identifierCreators: Partial<
|
|
97
|
+
private readonly _identifierCreators: Partial<IdentifierCreatorsRecord> = {};
|
|
116
98
|
|
|
117
99
|
/**
|
|
118
100
|
* Constructor.
|
|
119
101
|
*
|
|
120
|
-
* @param
|
|
121
|
-
*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
} else {
|
|
135
|
-
this._prefixType = PrefixTypes.GS18Prefix;
|
|
136
|
-
this._gs18Prefix = gs1CompanyPrefix.substring(5);
|
|
137
|
-
this._prefix = this._gs18Prefix;
|
|
138
|
-
}
|
|
102
|
+
* @param prefixType
|
|
103
|
+
* Prefix type.
|
|
104
|
+
*
|
|
105
|
+
* @param prefix
|
|
106
|
+
* Prefix.
|
|
107
|
+
*/
|
|
108
|
+
constructor(prefixType: PrefixType, prefix: string) {
|
|
109
|
+
const normalizedPrefixProvider = PrefixValidator.normalize(prefixType, prefix);
|
|
110
|
+
|
|
111
|
+
this._prefixType = normalizedPrefixProvider.prefixType;
|
|
112
|
+
this._prefix = normalizedPrefixProvider.prefix;
|
|
113
|
+
this._gs1CompanyPrefix = normalizedPrefixProvider.gs1CompanyPrefix;
|
|
114
|
+
this._upcCompanyPrefix = normalizedPrefixProvider.upcCompanyPrefix;
|
|
115
|
+
this._gs18Prefix = normalizedPrefixProvider.gs18Prefix;
|
|
139
116
|
|
|
140
117
|
// Default tweak factor is the numeric value of the GS1 Company Prefix preceded by '1'.
|
|
141
118
|
this._defaultTweakFactor = BigInt(`1${this.gs1CompanyPrefix}`);
|
|
@@ -165,14 +142,14 @@ export class PrefixManager implements PrefixProvider {
|
|
|
165
142
|
}
|
|
166
143
|
|
|
167
144
|
/**
|
|
168
|
-
* Get the U.P.C. Company Prefix if prefix type is {@
|
|
145
|
+
* Get the U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
|
|
169
146
|
*/
|
|
170
147
|
get upcCompanyPrefix(): string | undefined {
|
|
171
148
|
return this._upcCompanyPrefix;
|
|
172
149
|
}
|
|
173
150
|
|
|
174
151
|
/**
|
|
175
|
-
* Get the GS1-8 Prefix if prefix type is {@
|
|
152
|
+
* Get the GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
|
|
176
153
|
*/
|
|
177
154
|
get gs18Prefix(): string | undefined {
|
|
178
155
|
return this._gs18Prefix;
|
|
@@ -181,16 +158,13 @@ export class PrefixManager implements PrefixProvider {
|
|
|
181
158
|
/**
|
|
182
159
|
* Set the tweak for an identifier creator if it's a numeric identifier creator.
|
|
183
160
|
*
|
|
184
|
-
* @param
|
|
161
|
+
* @param identifierCreator
|
|
185
162
|
* Identifier creator.
|
|
186
163
|
*/
|
|
187
|
-
private setCreatorTweak(
|
|
188
|
-
if (
|
|
189
|
-
// eslint-disable-next-line
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion,no-param-reassign -- Type is known by testing identifier type. Method purpose is to set the tweak.
|
|
193
|
-
(creator as AbstractNumericIdentifierCreator).tweak = this.tweakFactor * creatorTweakFactor;
|
|
164
|
+
private setCreatorTweak(identifierCreator: IdentifierCreator): void {
|
|
165
|
+
if (isNumericIdentifierCreator(identifierCreator)) {
|
|
166
|
+
// eslint-disable-next-line no-param-reassign -- Method purpose is to set the tweak.
|
|
167
|
+
identifierCreator.tweak = this.tweakFactor * PrefixManager.CREATOR_TWEAK_FACTORS[identifierCreator.identifierType];
|
|
194
168
|
}
|
|
195
169
|
}
|
|
196
170
|
|
|
@@ -239,33 +213,14 @@ export class PrefixManager implements PrefixProvider {
|
|
|
239
213
|
* Prefix manager with normalized prefix type and prefix.
|
|
240
214
|
*/
|
|
241
215
|
static get(prefixType: PrefixType, prefix: string): PrefixManager {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
let gs1CompanyPrefix: string;
|
|
216
|
+
// Normalization will occur in constructor as well, but it's necessary here for the map.
|
|
217
|
+
const normalizedPrefixProvider = PrefixValidator.normalize(prefixType, prefix);
|
|
245
218
|
|
|
246
|
-
|
|
247
|
-
case PrefixTypes.GS1CompanyPrefix:
|
|
248
|
-
gs1CompanyPrefix = prefix;
|
|
249
|
-
break;
|
|
250
|
-
|
|
251
|
-
case PrefixTypes.UPCCompanyPrefix:
|
|
252
|
-
gs1CompanyPrefix = "0" + prefix;
|
|
253
|
-
break;
|
|
254
|
-
|
|
255
|
-
case PrefixTypes.GS18Prefix:
|
|
256
|
-
gs1CompanyPrefix = "00000" + prefix;
|
|
257
|
-
break;
|
|
258
|
-
|
|
259
|
-
// eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- Method may be called by unsafe means.
|
|
260
|
-
default:
|
|
261
|
-
throw new RangeError(i18nextGS1.t("Prefix.invalidPrefixType"));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
let prefixManager = PrefixManager.PREFIX_MANAGERS_MAP.get(gs1CompanyPrefix);
|
|
219
|
+
let prefixManager = PrefixManager.PREFIX_MANAGERS_MAP.get(normalizedPrefixProvider.gs1CompanyPrefix);
|
|
265
220
|
|
|
266
221
|
if (prefixManager === undefined) {
|
|
267
|
-
prefixManager = new PrefixManager(
|
|
268
|
-
PrefixManager.PREFIX_MANAGERS_MAP.set(gs1CompanyPrefix, prefixManager);
|
|
222
|
+
prefixManager = new PrefixManager(normalizedPrefixProvider.prefixType, normalizedPrefixProvider.prefix);
|
|
223
|
+
PrefixManager.PREFIX_MANAGERS_MAP.set(normalizedPrefixProvider.gs1CompanyPrefix, prefixManager);
|
|
269
224
|
}
|
|
270
225
|
|
|
271
226
|
return prefixManager;
|
|
@@ -274,18 +229,23 @@ export class PrefixManager implements PrefixProvider {
|
|
|
274
229
|
/**
|
|
275
230
|
* Get an identifier creator.
|
|
276
231
|
*
|
|
232
|
+
* @template TIdentifierType
|
|
233
|
+
* Identifier type type.
|
|
234
|
+
*
|
|
277
235
|
* @param identifierType
|
|
278
|
-
* Identifier type.
|
|
236
|
+
* Identifier type used to construct identifier creator.
|
|
279
237
|
*
|
|
280
|
-
* @param
|
|
238
|
+
* @param constructorParameter
|
|
239
|
+
* Second constructor parameter passed to constructor callback alongside this.
|
|
240
|
+
*
|
|
241
|
+
* @param ConstructorCallback
|
|
281
242
|
* Constructor callback.
|
|
282
243
|
*
|
|
283
244
|
* @returns
|
|
284
245
|
* Identifier creator.
|
|
285
246
|
*/
|
|
286
|
-
private getIdentifierCreator<
|
|
287
|
-
|
|
288
|
-
let creator = this._identifierCreators[identifierType] as TIdentifierCreator | undefined;
|
|
247
|
+
private getIdentifierCreator<TIdentifierType extends IdentifierType, TConstructorParameter>(identifierType: TIdentifierType, constructorParameter: TConstructorParameter, ConstructorCallback: new (prefixProvider: PrefixProvider, constructorParameter: TConstructorParameter) => IdentifierCreatorsRecord[TIdentifierType]): IdentifierCreatorsRecord[TIdentifierType] {
|
|
248
|
+
let creator: IdentifierCreatorsRecord[TIdentifierType] | undefined = this._identifierCreators[identifierType];
|
|
289
249
|
|
|
290
250
|
if (creator === undefined) {
|
|
291
251
|
if (this.prefixType === PrefixTypes.GS18Prefix && identifierType !== IdentifierTypes.GTIN) {
|
|
@@ -294,7 +254,7 @@ export class PrefixManager implements PrefixProvider {
|
|
|
294
254
|
}));
|
|
295
255
|
}
|
|
296
256
|
|
|
297
|
-
creator =
|
|
257
|
+
creator = new ConstructorCallback(this, constructorParameter);
|
|
298
258
|
|
|
299
259
|
this.setCreatorTweak(creator);
|
|
300
260
|
|
|
@@ -307,141 +267,123 @@ export class PrefixManager implements PrefixProvider {
|
|
|
307
267
|
/**
|
|
308
268
|
* Get non-GTIN numeric identifier creator.
|
|
309
269
|
*
|
|
310
|
-
* @param
|
|
311
|
-
*
|
|
270
|
+
* @param identifierType
|
|
271
|
+
* Identifier type used to construct identifier creator.
|
|
312
272
|
*
|
|
313
273
|
* @returns
|
|
314
274
|
* Identifier creator.
|
|
315
275
|
*/
|
|
316
|
-
private getNonGTINNumericIdentifierCreator(
|
|
317
|
-
return this.getIdentifierCreator(
|
|
276
|
+
private getNonGTINNumericIdentifierCreator(identifierType: Exclude<NonGTINNumericIdentifierType, SerializableNumericIdentifierType>): NonGTINNumericIdentifierCreator {
|
|
277
|
+
return this.getIdentifierCreator(identifierType, identifierType, NonGTINNumericIdentifierCreator);
|
|
318
278
|
}
|
|
319
279
|
|
|
320
280
|
/**
|
|
321
281
|
* Get serialized numeric identifier creator.
|
|
322
282
|
*
|
|
323
|
-
* @param
|
|
324
|
-
*
|
|
283
|
+
* @param identifierType
|
|
284
|
+
* Identifier type used to construct identifier creator.
|
|
325
285
|
*
|
|
326
286
|
* @returns
|
|
327
287
|
* Identifier creator.
|
|
328
288
|
*/
|
|
329
|
-
private getSerializableNumericIdentifierCreator(
|
|
330
|
-
return this.getIdentifierCreator(
|
|
289
|
+
private getSerializableNumericIdentifierCreator(identifierType: SerializableNumericIdentifierType): SerializableNumericIdentifierCreator {
|
|
290
|
+
return this.getIdentifierCreator(identifierType, identifierType, SerializableNumericIdentifierCreator);
|
|
331
291
|
}
|
|
332
292
|
|
|
333
293
|
/**
|
|
334
294
|
* Get non-numeric identifier creator.
|
|
335
295
|
*
|
|
336
|
-
* @param
|
|
337
|
-
*
|
|
296
|
+
* @param identifierType
|
|
297
|
+
* Identifier type used to construct identifier creator.
|
|
338
298
|
*
|
|
339
299
|
* @returns
|
|
340
300
|
* Identifier creator.
|
|
341
301
|
*/
|
|
342
|
-
private getNonNumericIdentifierCreator(
|
|
343
|
-
return this.getIdentifierCreator(
|
|
302
|
+
private getNonNumericIdentifierCreator(identifierType: NonNumericIdentifierType): NonNumericIdentifierCreator {
|
|
303
|
+
return this.getIdentifierCreator(identifierType, identifierType, NonNumericIdentifierCreator);
|
|
344
304
|
}
|
|
345
305
|
|
|
346
306
|
/**
|
|
347
307
|
* Get GTIN creator.
|
|
348
308
|
*/
|
|
349
309
|
get gtinCreator(): GTINCreator {
|
|
350
|
-
return this.getIdentifierCreator(IdentifierTypes.GTIN,
|
|
351
|
-
let gtinType: GTINType;
|
|
352
|
-
|
|
353
|
-
switch (this.prefixType) {
|
|
354
|
-
case PrefixTypes.GS1CompanyPrefix:
|
|
355
|
-
gtinType = GTINTypes.GTIN13;
|
|
356
|
-
break;
|
|
357
|
-
|
|
358
|
-
case PrefixTypes.UPCCompanyPrefix:
|
|
359
|
-
gtinType = GTINTypes.GTIN12;
|
|
360
|
-
break;
|
|
361
|
-
|
|
362
|
-
case PrefixTypes.GS18Prefix:
|
|
363
|
-
gtinType = GTINTypes.GTIN8;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
return new GTINCreator(this, gtinType);
|
|
368
|
-
});
|
|
310
|
+
return this.getIdentifierCreator(IdentifierTypes.GTIN, GTIN_BASE_TYPES[this.prefixType], GTINCreator);
|
|
369
311
|
}
|
|
370
312
|
|
|
371
313
|
/**
|
|
372
314
|
* Get GLN creator.
|
|
373
315
|
*/
|
|
374
316
|
get glnCreator(): NonGTINNumericIdentifierCreator {
|
|
375
|
-
return this.getNonGTINNumericIdentifierCreator(
|
|
317
|
+
return this.getNonGTINNumericIdentifierCreator(IdentifierTypes.GLN);
|
|
376
318
|
}
|
|
377
319
|
|
|
378
320
|
/**
|
|
379
321
|
* Get SSCC creator.
|
|
380
322
|
*/
|
|
381
323
|
get ssccCreator(): NonGTINNumericIdentifierCreator {
|
|
382
|
-
return this.getNonGTINNumericIdentifierCreator(
|
|
324
|
+
return this.getNonGTINNumericIdentifierCreator(IdentifierTypes.SSCC);
|
|
383
325
|
}
|
|
384
326
|
|
|
385
327
|
/**
|
|
386
328
|
* Get GRAI creator.
|
|
387
329
|
*/
|
|
388
330
|
get graiCreator(): SerializableNumericIdentifierCreator {
|
|
389
|
-
return this.getSerializableNumericIdentifierCreator(
|
|
331
|
+
return this.getSerializableNumericIdentifierCreator(IdentifierTypes.GRAI);
|
|
390
332
|
}
|
|
391
333
|
|
|
392
334
|
/**
|
|
393
335
|
* Get GIAI creator.
|
|
394
336
|
*/
|
|
395
337
|
get giaiCreator(): NonNumericIdentifierCreator {
|
|
396
|
-
return this.getNonNumericIdentifierCreator(
|
|
338
|
+
return this.getNonNumericIdentifierCreator(IdentifierTypes.GIAI);
|
|
397
339
|
}
|
|
398
340
|
|
|
399
341
|
/**
|
|
400
342
|
* Get GSRN creator.
|
|
401
343
|
*/
|
|
402
344
|
get gsrnCreator(): NonGTINNumericIdentifierCreator {
|
|
403
|
-
return this.getNonGTINNumericIdentifierCreator(
|
|
345
|
+
return this.getNonGTINNumericIdentifierCreator(IdentifierTypes.GSRN);
|
|
404
346
|
}
|
|
405
347
|
|
|
406
348
|
/**
|
|
407
349
|
* Get GDTI creator.
|
|
408
350
|
*/
|
|
409
351
|
get gdtiCreator(): SerializableNumericIdentifierCreator {
|
|
410
|
-
return this.getSerializableNumericIdentifierCreator(
|
|
352
|
+
return this.getSerializableNumericIdentifierCreator(IdentifierTypes.GDTI);
|
|
411
353
|
}
|
|
412
354
|
|
|
413
355
|
/**
|
|
414
356
|
* Get GINC creator.
|
|
415
357
|
*/
|
|
416
358
|
get gincCreator(): NonNumericIdentifierCreator {
|
|
417
|
-
return this.getNonNumericIdentifierCreator(
|
|
359
|
+
return this.getNonNumericIdentifierCreator(IdentifierTypes.GINC);
|
|
418
360
|
}
|
|
419
361
|
|
|
420
362
|
/**
|
|
421
363
|
* Get GSIN creator.
|
|
422
364
|
*/
|
|
423
365
|
get gsinCreator(): NonGTINNumericIdentifierCreator {
|
|
424
|
-
return this.getNonGTINNumericIdentifierCreator(
|
|
366
|
+
return this.getNonGTINNumericIdentifierCreator(IdentifierTypes.GSIN);
|
|
425
367
|
}
|
|
426
368
|
|
|
427
369
|
/**
|
|
428
370
|
* Get GCN creator.
|
|
429
371
|
*/
|
|
430
372
|
get gcnCreator(): SerializableNumericIdentifierCreator {
|
|
431
|
-
return this.getSerializableNumericIdentifierCreator(
|
|
373
|
+
return this.getSerializableNumericIdentifierCreator(IdentifierTypes.GCN);
|
|
432
374
|
}
|
|
433
375
|
|
|
434
376
|
/**
|
|
435
377
|
* Get CPID creator.
|
|
436
378
|
*/
|
|
437
379
|
get cpidCreator(): NonNumericIdentifierCreator {
|
|
438
|
-
return this.getNonNumericIdentifierCreator(
|
|
380
|
+
return this.getNonNumericIdentifierCreator(IdentifierTypes.CPID);
|
|
439
381
|
}
|
|
440
382
|
|
|
441
383
|
/**
|
|
442
384
|
* Get GMN creator.
|
|
443
385
|
*/
|
|
444
386
|
get gmnCreator(): NonNumericIdentifierCreator {
|
|
445
|
-
return this.getNonNumericIdentifierCreator(
|
|
387
|
+
return this.getNonNumericIdentifierCreator(IdentifierTypes.GMN);
|
|
446
388
|
}
|
|
447
389
|
}
|
package/src/prefix-provider.ts
CHANGED
|
@@ -20,12 +20,12 @@ export interface PrefixProvider {
|
|
|
20
20
|
readonly gs1CompanyPrefix: string;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* Prefix as U.P.C. Company Prefix if prefix type is {@
|
|
23
|
+
* Prefix as U.P.C. Company Prefix if prefix type is {@linkcode PrefixTypes.UPCCompanyPrefix} or undefined if not.
|
|
24
24
|
*/
|
|
25
25
|
readonly upcCompanyPrefix: string | undefined;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* Prefix as GS1-8 Prefix if prefix type is {@
|
|
28
|
+
* Prefix as GS1-8 Prefix if prefix type is {@linkcode PrefixTypes.GS18Prefix} or undefined if not.
|
|
29
29
|
*/
|
|
30
30
|
readonly gs18Prefix: string | undefined;
|
|
31
31
|
}
|
package/src/prefix-type.ts
CHANGED
|
@@ -18,7 +18,12 @@ export const PrefixTypes = {
|
|
|
18
18
|
GS18Prefix: "GS1-8 Prefix"
|
|
19
19
|
} as const;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Prefix type key.
|
|
23
|
+
*/
|
|
24
|
+
export type PrefixTypeKey = keyof typeof PrefixTypes;
|
|
25
|
+
|
|
21
26
|
/**
|
|
22
27
|
* Prefix type.
|
|
23
28
|
*/
|
|
24
|
-
export type PrefixType = typeof PrefixTypes[
|
|
29
|
+
export type PrefixType = typeof PrefixTypes[PrefixTypeKey];
|