isahaq-barcode 1.0.0 → 1.2.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,195 +1,195 @@
1
- /**
2
- * Barcode Types - Supported barcode types and their configurations
3
- */
4
-
5
- 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
- };
102
-
103
- /**
104
- * Get all supported barcode types
105
- * @returns {Array} Array of all barcode types
106
- */
107
- static getAll() {
108
- return Object.values(this.TYPES);
109
- }
110
-
111
- /**
112
- * Get barcode types by category
113
- * @param {string} category - The category name
114
- * @returns {Array} Array of barcode types in the category
115
- */
116
- static getByCategory(category) {
117
- return this.CATEGORIES[category.toUpperCase()] || [];
118
- }
119
-
120
- /**
121
- * Get all categories
122
- * @returns {Array} Array of category names
123
- */
124
- static getCategories() {
125
- return Object.keys(this.CATEGORIES);
126
- }
127
-
128
- /**
129
- * Check if a barcode type is valid
130
- * @param {string} type - The barcode type to check
131
- * @returns {boolean} True if valid
132
- */
133
- static isValid(type) {
134
- return Object.values(this.TYPES).includes(type);
135
- }
136
-
137
- /**
138
- * Get barcode type configuration
139
- * @param {string} type - The barcode type
140
- * @returns {Object} Configuration object
141
- */
142
- 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' },
166
- };
167
-
168
- return (
169
- configs[type] || { minLength: 1, maxLength: 100, charset: 'Unknown' }
170
- );
171
- }
172
-
173
- /**
174
- * Get barcode type description
175
- * @param {string} type - The barcode type
176
- * @returns {string} Description
177
- */
178
- 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',
189
- };
190
-
191
- return descriptions[type] || 'Unknown barcode type';
192
- }
193
- }
194
-
195
- module.exports = { BarcodeTypes };
1
+ /**
2
+ * Barcode Types - Supported barcode types and their configurations
3
+ */
4
+
5
+ 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
+ };
102
+
103
+ /**
104
+ * Get all supported barcode types
105
+ * @returns {Array} Array of all barcode types
106
+ */
107
+ static getAll() {
108
+ return Object.values(this.TYPES);
109
+ }
110
+
111
+ /**
112
+ * Get barcode types by category
113
+ * @param {string} category - The category name
114
+ * @returns {Array} Array of barcode types in the category
115
+ */
116
+ static getByCategory(category) {
117
+ return this.CATEGORIES[category.toUpperCase()] || [];
118
+ }
119
+
120
+ /**
121
+ * Get all categories
122
+ * @returns {Array} Array of category names
123
+ */
124
+ static getCategories() {
125
+ return Object.keys(this.CATEGORIES);
126
+ }
127
+
128
+ /**
129
+ * Check if a barcode type is valid
130
+ * @param {string} type - The barcode type to check
131
+ * @returns {boolean} True if valid
132
+ */
133
+ static isValid(type) {
134
+ return Object.values(this.TYPES).includes(type);
135
+ }
136
+
137
+ /**
138
+ * Get barcode type configuration
139
+ * @param {string} type - The barcode type
140
+ * @returns {Object} Configuration object
141
+ */
142
+ 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' },
166
+ };
167
+
168
+ return (
169
+ configs[type] || { minLength: 1, maxLength: 100, charset: 'Unknown' }
170
+ );
171
+ }
172
+
173
+ /**
174
+ * Get barcode type description
175
+ * @param {string} type - The barcode type
176
+ * @returns {string} Description
177
+ */
178
+ 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',
189
+ };
190
+
191
+ return descriptions[type] || 'Unknown barcode type';
192
+ }
193
+ }
194
+
195
+ module.exports = { BarcodeTypes };