isahaq-barcode 1.9.0 → 2.0.0

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.
@@ -1,128 +1,507 @@
1
1
  /**
2
2
  * Barcode Types - Supported barcode types and their configurations
3
+ *
4
+ * Every type listed here maps to a real symbology encoder (bwip-js / BWIPP),
5
+ * so `isValid(type) === true` guarantees the type can actually be generated.
3
6
  */
4
7
 
8
+ /**
9
+ * Single source of truth for the supported symbologies.
10
+ *
11
+ * - `bcid` bwip-js/BWIPP symbology id used for encoding
12
+ * - `encode` extra encoder options required by that symbology
13
+ * - `category` grouping used by getByCategory()/getCategories()
14
+ * - `minLength`/`maxLength`/`charset` are used by the Validator
15
+ */
16
+ const REGISTRY = {
17
+ // Linear Barcodes
18
+ code128: {
19
+ bcid: 'code128',
20
+ name: 'Code 128',
21
+ category: 'LINEAR',
22
+ description: 'Code 128 - High-density linear barcode',
23
+ minLength: 1,
24
+ maxLength: 80,
25
+ charset: 'ASCII',
26
+ },
27
+ code128a: {
28
+ bcid: 'code128',
29
+ name: 'Code 128 A',
30
+ category: 'LINEAR',
31
+ description: 'Code 128 Subset A - Uppercase and control characters',
32
+ minLength: 1,
33
+ maxLength: 80,
34
+ charset: 'ASCII A',
35
+ },
36
+ code128b: {
37
+ bcid: 'code128',
38
+ name: 'Code 128 B',
39
+ category: 'LINEAR',
40
+ description: 'Code 128 Subset B - Full printable ASCII',
41
+ minLength: 1,
42
+ maxLength: 80,
43
+ charset: 'ASCII B',
44
+ },
45
+ code128c: {
46
+ bcid: 'code128',
47
+ name: 'Code 128 C',
48
+ category: 'LINEAR',
49
+ description: 'Code 128 Subset C - Numeric pairs (double density)',
50
+ minLength: 2,
51
+ maxLength: 80,
52
+ charset: 'Numeric',
53
+ },
54
+ code128auto: {
55
+ bcid: 'code128',
56
+ name: 'Code 128 Auto',
57
+ category: 'LINEAR',
58
+ description: 'Code 128 with automatic subset selection',
59
+ minLength: 1,
60
+ maxLength: 80,
61
+ charset: 'ASCII',
62
+ },
63
+ code39: {
64
+ bcid: 'code39',
65
+ name: 'Code 39',
66
+ category: 'LINEAR',
67
+ description: 'Code 39 - Alphanumeric barcode',
68
+ minLength: 1,
69
+ maxLength: 43,
70
+ charset: '0-9, A-Z, space, -.$/+%',
71
+ },
72
+ code39extended: {
73
+ bcid: 'code39ext',
74
+ name: 'Code 39 Extended',
75
+ category: 'LINEAR',
76
+ description: 'Code 39 Extended - Full ASCII via shift characters',
77
+ minLength: 1,
78
+ maxLength: 43,
79
+ charset: 'Extended ASCII',
80
+ },
81
+ code39checksum: {
82
+ bcid: 'code39',
83
+ encode: { includecheck: true },
84
+ name: 'Code 39 + Checksum',
85
+ category: 'LINEAR',
86
+ description: 'Code 39 with mod-43 check character',
87
+ minLength: 1,
88
+ maxLength: 43,
89
+ charset: '0-9, A-Z, space, -.$/+%',
90
+ },
91
+ code39auto: {
92
+ bcid: 'code39',
93
+ name: 'Code 39 Auto',
94
+ category: 'LINEAR',
95
+ description: 'Code 39 with automatic character handling',
96
+ minLength: 1,
97
+ maxLength: 43,
98
+ charset: '0-9, A-Z, space, -.$/+%',
99
+ },
100
+ code93: {
101
+ bcid: 'code93',
102
+ // Code 93 mandates the two C/K check characters
103
+ encode: { includecheck: true },
104
+ name: 'Code 93',
105
+ category: 'LINEAR',
106
+ description: 'Code 93 - Compact alphanumeric barcode',
107
+ minLength: 1,
108
+ maxLength: 43,
109
+ charset: '0-9, A-Z, -.$/+%',
110
+ },
111
+ code25: {
112
+ bcid: 'code2of5',
113
+ name: 'Code 25',
114
+ category: 'LINEAR',
115
+ description: 'Code 2 of 5 - Numeric only barcode',
116
+ minLength: 1,
117
+ maxLength: 40,
118
+ charset: 'Numeric',
119
+ },
120
+ code25auto: {
121
+ bcid: 'code2of5',
122
+ name: 'Code 25 Auto',
123
+ category: 'LINEAR',
124
+ description: 'Code 2 of 5 with automatic handling',
125
+ minLength: 1,
126
+ maxLength: 40,
127
+ charset: 'Numeric',
128
+ },
129
+ code32: {
130
+ bcid: 'code32',
131
+ name: 'Code 32',
132
+ category: 'LINEAR',
133
+ description: 'Code 32 - Italian pharmacode',
134
+ minLength: 8,
135
+ maxLength: 9,
136
+ charset: 'Numeric',
137
+ },
138
+ standard25: {
139
+ bcid: 'industrial2of5',
140
+ name: 'Standard 2 of 5',
141
+ category: 'LINEAR',
142
+ description: 'Standard (Industrial) 2 of 5 - Numeric only',
143
+ minLength: 1,
144
+ maxLength: 40,
145
+ charset: 'Numeric',
146
+ },
147
+ standard25checksum: {
148
+ bcid: 'industrial2of5',
149
+ encode: { includecheck: true },
150
+ name: 'Standard 2 of 5 + Checksum',
151
+ category: 'LINEAR',
152
+ description: 'Standard 2 of 5 with check digit',
153
+ minLength: 1,
154
+ maxLength: 40,
155
+ charset: 'Numeric',
156
+ },
157
+ interleaved25: {
158
+ bcid: 'interleaved2of5',
159
+ name: 'Interleaved 2 of 5',
160
+ category: 'LINEAR',
161
+ description: 'Interleaved 2 of 5 - Numeric, even number of digits',
162
+ minLength: 2,
163
+ maxLength: 40,
164
+ charset: 'Numeric',
165
+ },
166
+ interleaved25checksum: {
167
+ bcid: 'interleaved2of5',
168
+ encode: { includecheck: true },
169
+ name: 'Interleaved 2 of 5 + Checksum',
170
+ category: 'LINEAR',
171
+ description: 'Interleaved 2 of 5 with check digit',
172
+ minLength: 2,
173
+ maxLength: 40,
174
+ charset: 'Numeric',
175
+ },
176
+ interleaved25auto: {
177
+ bcid: 'interleaved2of5',
178
+ encode: { includecheck: true },
179
+ name: 'Interleaved 2 of 5 Auto',
180
+ category: 'LINEAR',
181
+ description: 'Interleaved 2 of 5 with automatic check digit padding',
182
+ minLength: 1,
183
+ maxLength: 40,
184
+ charset: 'Numeric',
185
+ },
186
+ msi: {
187
+ bcid: 'msi',
188
+ name: 'MSI',
189
+ category: 'LINEAR',
190
+ description: 'MSI (Modified Plessey) - Numeric only',
191
+ minLength: 1,
192
+ maxLength: 40,
193
+ charset: 'Numeric',
194
+ },
195
+ msichecksum: {
196
+ bcid: 'msi',
197
+ encode: { includecheck: true },
198
+ name: 'MSI + Checksum',
199
+ category: 'LINEAR',
200
+ description: 'MSI with mod-10 check digit',
201
+ minLength: 1,
202
+ maxLength: 40,
203
+ charset: 'Numeric',
204
+ },
205
+ msiauto: {
206
+ bcid: 'msi',
207
+ encode: { includecheck: true },
208
+ name: 'MSI Auto',
209
+ category: 'LINEAR',
210
+ description: 'MSI with automatic check digit',
211
+ minLength: 1,
212
+ maxLength: 40,
213
+ charset: 'Numeric',
214
+ },
215
+
216
+ // EAN/UPC Family
217
+ ean13: {
218
+ bcid: 'ean13',
219
+ encode: { guardwhitespace: true },
220
+ name: 'EAN-13',
221
+ category: 'EAN_UPC',
222
+ description: 'EAN-13 - European Article Number',
223
+ minLength: 12,
224
+ maxLength: 13,
225
+ charset: 'Numeric',
226
+ },
227
+ ean8: {
228
+ bcid: 'ean8',
229
+ encode: { guardwhitespace: true },
230
+ name: 'EAN-8',
231
+ category: 'EAN_UPC',
232
+ description: 'EAN-8 - European Article Number (short)',
233
+ minLength: 7,
234
+ maxLength: 8,
235
+ charset: 'Numeric',
236
+ },
237
+ ean2: {
238
+ bcid: 'ean2',
239
+ encode: { guardwhitespace: true },
240
+ name: 'EAN-2',
241
+ category: 'EAN_UPC',
242
+ description: 'EAN-2 - Two digit add-on',
243
+ minLength: 2,
244
+ maxLength: 2,
245
+ charset: 'Numeric',
246
+ },
247
+ ean5: {
248
+ bcid: 'ean5',
249
+ encode: { guardwhitespace: true },
250
+ name: 'EAN-5',
251
+ category: 'EAN_UPC',
252
+ description: 'EAN-5 - Five digit add-on',
253
+ minLength: 5,
254
+ maxLength: 5,
255
+ charset: 'Numeric',
256
+ },
257
+ upca: {
258
+ bcid: 'upca',
259
+ encode: { guardwhitespace: true },
260
+ name: 'UPC-A',
261
+ category: 'EAN_UPC',
262
+ description: 'UPC-A - Universal Product Code',
263
+ minLength: 11,
264
+ maxLength: 12,
265
+ charset: 'Numeric',
266
+ },
267
+ upce: {
268
+ bcid: 'upce',
269
+ encode: { guardwhitespace: true },
270
+ name: 'UPC-E',
271
+ category: 'EAN_UPC',
272
+ description: 'UPC-E - Universal Product Code (compressed)',
273
+ minLength: 7,
274
+ maxLength: 8,
275
+ charset: 'Numeric',
276
+ },
277
+ itf14: {
278
+ bcid: 'itf14',
279
+ name: 'ITF-14',
280
+ category: 'EAN_UPC',
281
+ description: 'ITF-14 - Shipping container code',
282
+ minLength: 13,
283
+ maxLength: 14,
284
+ charset: 'Numeric',
285
+ },
286
+
287
+ // Postal Barcodes
288
+ postnet: {
289
+ bcid: 'postnet',
290
+ name: 'POSTNET',
291
+ category: 'POSTAL',
292
+ description: 'POSTNET - US Postal Service numeric code',
293
+ minLength: 5,
294
+ maxLength: 11,
295
+ charset: 'Numeric',
296
+ },
297
+ planet: {
298
+ bcid: 'planet',
299
+ name: 'PLANET',
300
+ category: 'POSTAL',
301
+ description: 'PLANET - US Postal Service tracking code',
302
+ minLength: 11,
303
+ maxLength: 13,
304
+ charset: 'Numeric',
305
+ },
306
+ rms4cc: {
307
+ bcid: 'royalmail',
308
+ name: 'RM4SCC',
309
+ category: 'POSTAL',
310
+ description: 'RM4SCC - Royal Mail 4-state customer code',
311
+ minLength: 1,
312
+ maxLength: 20,
313
+ charset: '0-9, A-Z',
314
+ },
315
+ kix: {
316
+ bcid: 'kix',
317
+ name: 'KIX',
318
+ category: 'POSTAL',
319
+ description: 'KIX - Dutch Post code',
320
+ minLength: 1,
321
+ maxLength: 20,
322
+ charset: '0-9, A-Z',
323
+ },
324
+ imb: {
325
+ bcid: 'onecode',
326
+ name: 'Intelligent Mail',
327
+ category: 'POSTAL',
328
+ description: 'USPS Intelligent Mail (OneCode) barcode',
329
+ minLength: 20,
330
+ maxLength: 31,
331
+ charset: 'Numeric',
332
+ },
333
+
334
+ // Specialized Barcodes
335
+ codabar: {
336
+ bcid: 'rationalizedCodabar',
337
+ name: 'Codabar',
338
+ category: 'SPECIALIZED',
339
+ description: 'Codabar - Numeric with A-D start/stop characters',
340
+ minLength: 1,
341
+ maxLength: 60,
342
+ charset: '0-9, -$:/.+, A-D start/stop',
343
+ },
344
+ code11: {
345
+ bcid: 'code11',
346
+ name: 'Code 11',
347
+ category: 'SPECIALIZED',
348
+ description: 'Code 11 - Telecommunications barcode',
349
+ minLength: 1,
350
+ maxLength: 40,
351
+ charset: '0-9, -',
352
+ },
353
+ pharmacode: {
354
+ bcid: 'pharmacode',
355
+ name: 'Pharmacode',
356
+ category: 'SPECIALIZED',
357
+ description: 'Pharmacode - Pharmaceutical binary code (3-131070)',
358
+ minLength: 1,
359
+ maxLength: 6,
360
+ charset: 'Numeric',
361
+ },
362
+ pharmacodetwotracks: {
363
+ bcid: 'pharmacode2',
364
+ name: 'Two-track Pharmacode',
365
+ category: 'SPECIALIZED',
366
+ description: 'Two-track Pharmacode - Pharmaceutical code (4-64570080)',
367
+ minLength: 1,
368
+ maxLength: 8,
369
+ charset: 'Numeric',
370
+ },
371
+
372
+ // 2D Matrix Codes
373
+ qrcode: {
374
+ bcid: 'qrcode',
375
+ name: 'QR Code',
376
+ category: 'MATRIX_2D',
377
+ description: 'QR Code - 2D matrix barcode',
378
+ minLength: 1,
379
+ maxLength: 2953,
380
+ charset: 'Unicode',
381
+ },
382
+ datamatrix: {
383
+ bcid: 'datamatrix',
384
+ name: 'Data Matrix',
385
+ category: 'MATRIX_2D',
386
+ description: 'Data Matrix - 2D matrix barcode',
387
+ minLength: 1,
388
+ maxLength: 2335,
389
+ charset: 'Unicode',
390
+ },
391
+ aztec: {
392
+ bcid: 'azteccode',
393
+ name: 'Aztec Code',
394
+ category: 'MATRIX_2D',
395
+ description: 'Aztec Code - 2D matrix barcode',
396
+ minLength: 1,
397
+ maxLength: 3832,
398
+ charset: 'Unicode',
399
+ },
400
+ pdf417: {
401
+ bcid: 'pdf417',
402
+ name: 'PDF417',
403
+ category: 'MATRIX_2D',
404
+ description: 'PDF417 - 2D stacked barcode',
405
+ minLength: 1,
406
+ maxLength: 1850,
407
+ charset: 'Unicode',
408
+ },
409
+ microqr: {
410
+ bcid: 'microqrcode',
411
+ name: 'Micro QR Code',
412
+ category: 'MATRIX_2D',
413
+ description: 'Micro QR Code - Compact 2D matrix barcode',
414
+ minLength: 1,
415
+ maxLength: 35,
416
+ charset: 'Alphanumeric',
417
+ },
418
+ maxicode: {
419
+ bcid: 'maxicode',
420
+ encode: { mode: 4 },
421
+ name: 'MaxiCode',
422
+ category: 'MATRIX_2D',
423
+ description: 'MaxiCode - UPS fixed-size 2D barcode',
424
+ minLength: 1,
425
+ maxLength: 93,
426
+ charset: 'ASCII',
427
+ },
428
+
429
+ // Stacked Linear Codes
430
+ code16k: {
431
+ bcid: 'code16k',
432
+ name: 'Code 16K',
433
+ category: 'STACKED',
434
+ description: 'Code 16K - Stacked Code 128 rows',
435
+ minLength: 1,
436
+ maxLength: 154,
437
+ charset: 'ASCII',
438
+ },
439
+ code49: {
440
+ bcid: 'code49',
441
+ name: 'Code 49',
442
+ category: 'STACKED',
443
+ description: 'Code 49 - Stacked alphanumeric barcode',
444
+ minLength: 1,
445
+ maxLength: 49,
446
+ charset: '0-9, A-Z, -.$/+%',
447
+ },
448
+ };
449
+
450
+ /**
451
+ * Type constant name (CODE128) -> type id (code128)
452
+ */
453
+ const TYPES = Object.keys(REGISTRY).reduce((acc, type) => {
454
+ acc[type.toUpperCase()] = type;
455
+ return acc;
456
+ }, {});
457
+
458
+ /**
459
+ * Category -> type ids
460
+ */
461
+ const CATEGORIES = Object.entries(REGISTRY).reduce((acc, [type, info]) => {
462
+ acc[info.category] = acc[info.category] || [];
463
+ acc[info.category].push(type);
464
+ return acc;
465
+ }, {});
466
+
5
467
  class BarcodeTypes {
6
- static TYPES = {
7
- // Linear Barcodes
8
- CODE128: 'code128',
9
- CODE128A: 'code128a',
10
- CODE128B: 'code128b',
11
- CODE128C: 'code128c',
12
- CODE128AUTO: 'code128auto',
13
- CODE39: 'code39',
14
- CODE39EXTENDED: 'code39extended',
15
- CODE39CHECKSUM: 'code39checksum',
16
- CODE39AUTO: 'code39auto',
17
- CODE93: 'code93',
18
- CODE25: 'code25',
19
- CODE25AUTO: 'code25auto',
20
- CODE32: 'code32',
21
- STANDARD25: 'standard25',
22
- STANDARD25CHECKSUM: 'standard25checksum',
23
- INTERLEAVED25: 'interleaved25',
24
- INTERLEAVED25CHECKSUM: 'interleaved25checksum',
25
- INTERLEAVED25AUTO: 'interleaved25auto',
26
- MSI: 'msi',
27
- MSICHECKSUM: 'msichecksum',
28
- MSIAUTO: 'msiauto',
29
-
30
- // EAN/UPC Family
31
- EAN13: 'ean13',
32
- EAN8: 'ean8',
33
- EAN2: 'ean2',
34
- EAN5: 'ean5',
35
- UPCA: 'upca',
36
- UPCE: 'upce',
37
- ITF14: 'itf14',
38
-
39
- // Postal Barcodes
40
- POSTNET: 'postnet',
41
- PLANET: 'planet',
42
- RMS4CC: 'rms4cc',
43
- KIX: 'kix',
44
- IMB: 'imb',
45
-
46
- // Specialized Barcodes
47
- CODABAR: 'codabar',
48
- CODE11: 'code11',
49
- PHARMACODE: 'pharmacode',
50
- PHARMACODETWOTRACKS: 'pharmacodetwotracks',
51
-
52
- // 2D Matrix Codes
53
- QRCODE: 'qrcode',
54
- DATAMATRIX: 'datamatrix',
55
- AZTEC: 'aztec',
56
- PDF417: 'pdf417',
57
- MICROQR: 'microqr',
58
- MAXICODE: 'maxicode',
59
-
60
- // Stacked Linear Codes
61
- CODE16K: 'code16k',
62
- CODE49: 'code49',
63
- };
64
-
65
- static CATEGORIES = {
66
- LINEAR: [
67
- 'code128',
68
- 'code128a',
69
- 'code128b',
70
- 'code128c',
71
- 'code128auto',
72
- 'code39',
73
- 'code39extended',
74
- 'code39checksum',
75
- 'code39auto',
76
- 'code93',
77
- 'code25',
78
- 'code25auto',
79
- 'code32',
80
- 'standard25',
81
- 'standard25checksum',
82
- 'interleaved25',
83
- 'interleaved25checksum',
84
- 'interleaved25auto',
85
- 'msi',
86
- 'msichecksum',
87
- 'msiauto',
88
- ],
89
- EAN_UPC: ['ean13', 'ean8', 'ean2', 'ean5', 'upca', 'upce', 'itf14'],
90
- POSTAL: ['postnet', 'planet', 'rms4cc', 'kix', 'imb'],
91
- SPECIALIZED: ['codabar', 'code11', 'pharmacode', 'pharmacodetwotracks'],
92
- MATRIX_2D: [
93
- 'qrcode',
94
- 'datamatrix',
95
- 'aztec',
96
- 'pdf417',
97
- 'microqr',
98
- 'maxicode',
99
- ],
100
- STACKED: ['code16k', 'code49'],
101
- };
468
+ static TYPES = TYPES;
469
+ static CATEGORIES = CATEGORIES;
102
470
 
103
471
  /**
104
472
  * Get all supported barcode types
105
- * @returns {Array} Array of all barcode types
473
+ * @returns {string[]} Array of all barcode types
106
474
  */
107
475
  static getAll() {
108
- return Object.values(this.TYPES);
476
+ return Object.keys(REGISTRY);
477
+ }
478
+
479
+ /**
480
+ * Get all supported barcode types (alias of getAll)
481
+ * @returns {string[]} Array of all barcode types
482
+ */
483
+ static getTypes() {
484
+ return this.getAll();
109
485
  }
110
486
 
111
487
  /**
112
488
  * Get barcode types by category
113
- * @param {string} category - The category name
114
- * @returns {Array} Array of barcode types in the category
489
+ * @param {string} category - The category name (linear, ean_upc, postal, ...)
490
+ * @returns {string[]} Array of barcode types in the category
115
491
  */
116
492
  static getByCategory(category) {
117
- return this.CATEGORIES[category.toUpperCase()] || [];
493
+ if (!category) {
494
+ return [];
495
+ }
496
+ return CATEGORIES[String(category).toUpperCase()] || [];
118
497
  }
119
498
 
120
499
  /**
121
500
  * Get all categories
122
- * @returns {Array} Array of category names
501
+ * @returns {string[]} Array of category names
123
502
  */
124
503
  static getCategories() {
125
- return Object.keys(this.CATEGORIES);
504
+ return Object.keys(CATEGORIES);
126
505
  }
127
506
 
128
507
  /**
@@ -131,43 +510,24 @@ class BarcodeTypes {
131
510
  * @returns {boolean} True if valid
132
511
  */
133
512
  static isValid(type) {
134
- return Object.values(this.TYPES).includes(type);
513
+ return typeof type === 'string' && Object.hasOwn(REGISTRY, type);
135
514
  }
136
515
 
137
516
  /**
138
- * Get barcode type configuration
517
+ * Get barcode type configuration used for validation
139
518
  * @param {string} type - The barcode type
140
- * @returns {Object} Configuration object
519
+ * @returns {{minLength: number, maxLength: number, charset: string}} Configuration
141
520
  */
142
521
  static getConfig(type) {
143
- const configs = {
144
- code128: { minLength: 1, maxLength: 80, charset: 'ASCII' },
145
- code128a: { minLength: 1, maxLength: 80, charset: 'ASCII A' },
146
- code128b: { minLength: 1, maxLength: 80, charset: 'ASCII B' },
147
- code128c: { minLength: 2, maxLength: 80, charset: 'Numeric' },
148
- code39: {
149
- minLength: 1,
150
- maxLength: 43,
151
- charset: '0-9, A-Z, space, -.$/+%',
152
- },
153
- code39extended: {
154
- minLength: 1,
155
- maxLength: 43,
156
- charset: 'Extended ASCII',
157
- },
158
- code93: { minLength: 1, maxLength: 43, charset: '0-9, A-Z, -.$/+%' },
159
- ean13: { minLength: 12, maxLength: 13, charset: 'Numeric' },
160
- ean8: { minLength: 7, maxLength: 8, charset: 'Numeric' },
161
- upca: { minLength: 11, maxLength: 12, charset: 'Numeric' },
162
- upce: { minLength: 6, maxLength: 8, charset: 'Numeric' },
163
- qrcode: { minLength: 1, maxLength: 2953, charset: 'Unicode' },
164
- datamatrix: { minLength: 1, maxLength: 2335, charset: 'Unicode' },
165
- pdf417: { minLength: 1, maxLength: 1850, charset: 'Unicode' },
522
+ const info = REGISTRY[type];
523
+ if (!info) {
524
+ return { minLength: 1, maxLength: 100, charset: 'Unknown' };
525
+ }
526
+ return {
527
+ minLength: info.minLength,
528
+ maxLength: info.maxLength,
529
+ charset: info.charset,
166
530
  };
167
-
168
- return (
169
- configs[type] || { minLength: 1, maxLength: 100, charset: 'Unknown' }
170
- );
171
531
  }
172
532
 
173
533
  /**
@@ -176,19 +536,50 @@ class BarcodeTypes {
176
536
  * @returns {string} Description
177
537
  */
178
538
  static getDescription(type) {
179
- const descriptions = {
180
- code128: 'Code 128 - High-density linear barcode',
181
- code39: 'Code 39 - Alphanumeric barcode',
182
- ean13: 'EAN-13 - European Article Number',
183
- ean8: 'EAN-8 - European Article Number (short)',
184
- upca: 'UPC-A - Universal Product Code',
185
- upce: 'UPC-E - Universal Product Code (compressed)',
186
- qrcode: 'QR Code - 2D matrix barcode',
187
- datamatrix: 'Data Matrix - 2D matrix barcode',
188
- pdf417: 'PDF417 - 2D stacked barcode',
539
+ return REGISTRY[type] ? REGISTRY[type].description : 'Unknown barcode type';
540
+ }
541
+
542
+ /**
543
+ * Get full information about a barcode type
544
+ * @param {string} type - The barcode type
545
+ * @returns {Object|null} Type information, or null when the type is unknown
546
+ */
547
+ static getTypeInfo(type) {
548
+ const info = REGISTRY[type];
549
+ if (!info) {
550
+ return null;
551
+ }
552
+
553
+ return {
554
+ type,
555
+ name: info.name,
556
+ description: info.description,
557
+ category: info.category,
558
+ symbology: info.bcid,
559
+ minLength: info.minLength,
560
+ maxLength: info.maxLength,
561
+ charset: info.charset,
189
562
  };
563
+ }
190
564
 
191
- return descriptions[type] || 'Unknown barcode type';
565
+ /**
566
+ * Get the underlying symbology id (bwip-js bcid) for a type
567
+ * @param {string} type - The barcode type
568
+ * @returns {string|null} Symbology id
569
+ */
570
+ static getSymbology(type) {
571
+ return REGISTRY[type] ? REGISTRY[type].bcid : null;
572
+ }
573
+
574
+ /**
575
+ * Get encoder options required by a type (check digits, guard bars, ...)
576
+ * @param {string} type - The barcode type
577
+ * @returns {Object} Encoder options
578
+ */
579
+ static getEncodeOptions(type) {
580
+ return REGISTRY[type] && REGISTRY[type].encode
581
+ ? { ...REGISTRY[type].encode }
582
+ : {};
192
583
  }
193
584
  }
194
585