@ripwords/myinvois-client 0.0.1
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/.prettierrc +8 -0
- package/README.md +15 -0
- package/bun.lock +369 -0
- package/dist/index.d.ts +3810 -0
- package/dist/index.js +523 -0
- package/package.json +29 -0
- package/rolldown.config.ts +10 -0
- package/src/index.ts +2 -0
- package/src/types/classification-codes.d.ts +115 -0
- package/src/types/country-code.d.ts +790 -0
- package/src/types/currencies.d.ts +383 -0
- package/src/types/documents/index.d.ts +1 -0
- package/src/types/documents/invoice-1_1.d.ts +349 -0
- package/src/types/e-invoice.d.ts +41 -0
- package/src/types/index.d.ts +11 -0
- package/src/types/msic/0X.d.ts +408 -0
- package/src/types/msic/1X.d.ts +210 -0
- package/src/types/msic/2X.d.ts +266 -0
- package/src/types/msic/3X.d.ts +114 -0
- package/src/types/msic/4X.d.ts +520 -0
- package/src/types/msic/5X.d.ts +144 -0
- package/src/types/msic/6X.d.ts +200 -0
- package/src/types/msic/7X.d.ts +132 -0
- package/src/types/msic/8X.d.ts +210 -0
- package/src/types/msic/9X.d.ts +186 -0
- package/src/types/msic-codes.d.ts +37 -0
- package/src/types/payment-modes.d.ts +41 -0
- package/src/types/signatures.d.ts +169 -0
- package/src/types/state-codes.d.ts +59 -0
- package/src/types/tax-types.d.ts +39 -0
- package/src/types/unit-types.d.ts +590 -0
- package/src/utils/MyInvoisClient.ts +95 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the allowed codes for Unit of Measurement types.
|
|
3
|
+
* Based on UN/ECE Recommendation 20, Revision 17 (2021) as per the documentation:
|
|
4
|
+
* https://sdk.myinvois.hasil.gov.my/codes/unit-types/
|
|
5
|
+
* NOTE: This list is incomplete as the provided documentation snippet omitted a large number of codes.
|
|
6
|
+
*/
|
|
7
|
+
export type UnitTypeCode =
|
|
8
|
+
| '10'
|
|
9
|
+
| '11'
|
|
10
|
+
| '13'
|
|
11
|
+
| '14'
|
|
12
|
+
| '15'
|
|
13
|
+
| '1I'
|
|
14
|
+
| '20'
|
|
15
|
+
| '21'
|
|
16
|
+
| '22'
|
|
17
|
+
| '23'
|
|
18
|
+
| '24'
|
|
19
|
+
| '25'
|
|
20
|
+
| '27'
|
|
21
|
+
| '28'
|
|
22
|
+
| '2A'
|
|
23
|
+
| '2B'
|
|
24
|
+
| '2C'
|
|
25
|
+
| '2G'
|
|
26
|
+
| '2H'
|
|
27
|
+
| '2I'
|
|
28
|
+
| '2J'
|
|
29
|
+
| '2K'
|
|
30
|
+
| '2L'
|
|
31
|
+
| '2M'
|
|
32
|
+
| '2N'
|
|
33
|
+
| '2P'
|
|
34
|
+
| '2Q'
|
|
35
|
+
| '2R'
|
|
36
|
+
| '2U'
|
|
37
|
+
| '2X'
|
|
38
|
+
| '2Y'
|
|
39
|
+
| '2Z'
|
|
40
|
+
| '33'
|
|
41
|
+
| '34'
|
|
42
|
+
| '35'
|
|
43
|
+
| '37'
|
|
44
|
+
| '38'
|
|
45
|
+
| '3B'
|
|
46
|
+
| '3C'
|
|
47
|
+
| '40'
|
|
48
|
+
| '41'
|
|
49
|
+
| '4C'
|
|
50
|
+
| '4G'
|
|
51
|
+
| '4H'
|
|
52
|
+
| '4K'
|
|
53
|
+
| '4L'
|
|
54
|
+
| '4M'
|
|
55
|
+
| '4N'
|
|
56
|
+
| '4O'
|
|
57
|
+
| '4P'
|
|
58
|
+
| '4Q'
|
|
59
|
+
| '4R'
|
|
60
|
+
| '4T'
|
|
61
|
+
| '4U'
|
|
62
|
+
| '4W'
|
|
63
|
+
| '4X'
|
|
64
|
+
| '56'
|
|
65
|
+
| '57'
|
|
66
|
+
| '58'
|
|
67
|
+
| '59'
|
|
68
|
+
| '5A'
|
|
69
|
+
| '5B'
|
|
70
|
+
| '5E'
|
|
71
|
+
| '5J'
|
|
72
|
+
| '60'
|
|
73
|
+
| '61'
|
|
74
|
+
| '74'
|
|
75
|
+
| '77'
|
|
76
|
+
| '80'
|
|
77
|
+
| '81'
|
|
78
|
+
| '85'
|
|
79
|
+
| '87'
|
|
80
|
+
| '89'
|
|
81
|
+
| '91'
|
|
82
|
+
| 'A10'
|
|
83
|
+
| 'A11'
|
|
84
|
+
| 'A12'
|
|
85
|
+
| 'A13'
|
|
86
|
+
| 'A14'
|
|
87
|
+
| 'A15'
|
|
88
|
+
| 'A16'
|
|
89
|
+
| 'A17'
|
|
90
|
+
| 'A18'
|
|
91
|
+
| 'A19'
|
|
92
|
+
| 'A2'
|
|
93
|
+
| 'A20'
|
|
94
|
+
| 'A21'
|
|
95
|
+
| 'A22'
|
|
96
|
+
| 'A23'
|
|
97
|
+
| 'A24'
|
|
98
|
+
| 'A26'
|
|
99
|
+
| 'A27'
|
|
100
|
+
| 'A28'
|
|
101
|
+
| 'A29'
|
|
102
|
+
| 'A3'
|
|
103
|
+
| 'A30'
|
|
104
|
+
| 'A31'
|
|
105
|
+
| 'A32'
|
|
106
|
+
| 'A33'
|
|
107
|
+
| 'A34'
|
|
108
|
+
| 'A35'
|
|
109
|
+
| 'A36'
|
|
110
|
+
| 'A37'
|
|
111
|
+
| 'A38'
|
|
112
|
+
| 'A39'
|
|
113
|
+
| 'A4'
|
|
114
|
+
| 'A40'
|
|
115
|
+
| 'A41'
|
|
116
|
+
| 'A42'
|
|
117
|
+
| 'A43'
|
|
118
|
+
| 'A44'
|
|
119
|
+
| 'A45'
|
|
120
|
+
| 'A47'
|
|
121
|
+
| 'A48'
|
|
122
|
+
| 'A49'
|
|
123
|
+
| 'A5'
|
|
124
|
+
| 'A53'
|
|
125
|
+
| 'A54'
|
|
126
|
+
| 'A55'
|
|
127
|
+
| 'A56'
|
|
128
|
+
| 'A59'
|
|
129
|
+
| 'A6'
|
|
130
|
+
| 'A68'
|
|
131
|
+
| 'A69'
|
|
132
|
+
| 'A7'
|
|
133
|
+
| 'A70'
|
|
134
|
+
| 'A71'
|
|
135
|
+
| 'A73'
|
|
136
|
+
| 'A74'
|
|
137
|
+
| 'A75'
|
|
138
|
+
| 'A76'
|
|
139
|
+
| 'A8'
|
|
140
|
+
| 'A84'
|
|
141
|
+
| 'A85'
|
|
142
|
+
| 'A86'
|
|
143
|
+
| 'A87'
|
|
144
|
+
| 'A88'
|
|
145
|
+
| 'A89'
|
|
146
|
+
// ... (Codes omitted in provided documentation) ...
|
|
147
|
+
| 'XQP'
|
|
148
|
+
| 'XQQ'
|
|
149
|
+
| 'XQR'
|
|
150
|
+
| 'XQS'
|
|
151
|
+
| 'XRD'
|
|
152
|
+
| 'XRG'
|
|
153
|
+
| 'XRJ'
|
|
154
|
+
| 'XRK'
|
|
155
|
+
| 'XRL'
|
|
156
|
+
| 'XRO'
|
|
157
|
+
| 'XRT'
|
|
158
|
+
| 'XRZ'
|
|
159
|
+
| 'XSA'
|
|
160
|
+
| 'XSB'
|
|
161
|
+
| 'XSC'
|
|
162
|
+
| 'XSD'
|
|
163
|
+
| 'XSE'
|
|
164
|
+
| 'XSH'
|
|
165
|
+
| 'XSI'
|
|
166
|
+
| 'XSK'
|
|
167
|
+
| 'XSL'
|
|
168
|
+
| 'XSM'
|
|
169
|
+
| 'XSO'
|
|
170
|
+
| 'XSP'
|
|
171
|
+
| 'XSS'
|
|
172
|
+
| 'XST'
|
|
173
|
+
| 'XSU'
|
|
174
|
+
| 'XSV'
|
|
175
|
+
| 'XSW'
|
|
176
|
+
| 'XSX'
|
|
177
|
+
| 'XSY'
|
|
178
|
+
| 'XSZ'
|
|
179
|
+
| 'XT1'
|
|
180
|
+
| 'XTB'
|
|
181
|
+
| 'XTC'
|
|
182
|
+
| 'XTD'
|
|
183
|
+
| 'XTE'
|
|
184
|
+
| 'XTG'
|
|
185
|
+
| 'XTI'
|
|
186
|
+
| 'XTK'
|
|
187
|
+
| 'XTL'
|
|
188
|
+
| 'XTN'
|
|
189
|
+
| 'XTO'
|
|
190
|
+
| 'XTR'
|
|
191
|
+
| 'XTS'
|
|
192
|
+
| 'XTT'
|
|
193
|
+
| 'XTU'
|
|
194
|
+
| 'XTV'
|
|
195
|
+
| 'XTW'
|
|
196
|
+
| 'XTY'
|
|
197
|
+
| 'XTZ'
|
|
198
|
+
| 'XUC'
|
|
199
|
+
| 'XUN'
|
|
200
|
+
| 'XVA'
|
|
201
|
+
| 'XVG'
|
|
202
|
+
| 'XVI'
|
|
203
|
+
| 'XVK'
|
|
204
|
+
| 'XVL'
|
|
205
|
+
| 'XVN'
|
|
206
|
+
| 'XVO'
|
|
207
|
+
| 'XVP'
|
|
208
|
+
| 'XVQ'
|
|
209
|
+
| 'XVR'
|
|
210
|
+
| 'XVS'
|
|
211
|
+
| 'XVY'
|
|
212
|
+
| 'XWA'
|
|
213
|
+
| 'XWB'
|
|
214
|
+
| 'XWC'
|
|
215
|
+
| 'XWD'
|
|
216
|
+
| 'XWF'
|
|
217
|
+
| 'XWG'
|
|
218
|
+
| 'XWH'
|
|
219
|
+
| 'XWJ'
|
|
220
|
+
| 'XWK'
|
|
221
|
+
| 'XWL'
|
|
222
|
+
| 'XWM'
|
|
223
|
+
| 'XWN'
|
|
224
|
+
| 'XWP'
|
|
225
|
+
| 'XWQ'
|
|
226
|
+
| 'XWR'
|
|
227
|
+
| 'XWS'
|
|
228
|
+
| 'XWT'
|
|
229
|
+
| 'XWU'
|
|
230
|
+
| 'XWV'
|
|
231
|
+
| 'XWW'
|
|
232
|
+
| 'XWX'
|
|
233
|
+
| 'XWY'
|
|
234
|
+
| 'XWZ'
|
|
235
|
+
| 'XXA'
|
|
236
|
+
| 'XXB'
|
|
237
|
+
| 'XXC'
|
|
238
|
+
| 'XXD'
|
|
239
|
+
| 'XXF'
|
|
240
|
+
| 'XXG'
|
|
241
|
+
| 'XXH'
|
|
242
|
+
| 'XXJ'
|
|
243
|
+
| 'XXK'
|
|
244
|
+
| 'XYA'
|
|
245
|
+
| 'XYB'
|
|
246
|
+
| 'XYC'
|
|
247
|
+
| 'XYD'
|
|
248
|
+
| 'XYF'
|
|
249
|
+
| 'XYG'
|
|
250
|
+
| 'XYH'
|
|
251
|
+
| 'XYJ'
|
|
252
|
+
| 'XYK'
|
|
253
|
+
| 'XYL'
|
|
254
|
+
| 'XYM'
|
|
255
|
+
| 'XYN'
|
|
256
|
+
| 'XYP'
|
|
257
|
+
| 'XYQ'
|
|
258
|
+
| 'XYR'
|
|
259
|
+
| 'XYS'
|
|
260
|
+
| 'XYT'
|
|
261
|
+
| 'XYV'
|
|
262
|
+
| 'XYW'
|
|
263
|
+
| 'XYX'
|
|
264
|
+
| 'XYY'
|
|
265
|
+
| 'XYZ'
|
|
266
|
+
| 'XZA'
|
|
267
|
+
| 'XZB'
|
|
268
|
+
| 'XZC'
|
|
269
|
+
| 'XZD'
|
|
270
|
+
| 'XZF'
|
|
271
|
+
| 'XZG'
|
|
272
|
+
| 'XZH'
|
|
273
|
+
| 'XZJ'
|
|
274
|
+
| 'XZK'
|
|
275
|
+
| 'XZL'
|
|
276
|
+
| 'XZM'
|
|
277
|
+
| 'XZN'
|
|
278
|
+
| 'XZP'
|
|
279
|
+
| 'XZQ'
|
|
280
|
+
| 'XZR'
|
|
281
|
+
| 'XZS'
|
|
282
|
+
| 'XZT'
|
|
283
|
+
| 'XZU'
|
|
284
|
+
| 'XZV'
|
|
285
|
+
| 'XZW'
|
|
286
|
+
| 'XZX'
|
|
287
|
+
| 'XZY'
|
|
288
|
+
| 'XZZ'
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Enum representing the allowed Unit of Measurement codes with descriptive names.
|
|
292
|
+
* Provides a more readable way to reference unit types.
|
|
293
|
+
* NOTE: This enum is incomplete as the provided documentation snippet omitted a large number of codes.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* const code = UnitTypeCodeEnum.KilogramPerSquareMetre;
|
|
297
|
+
* console.log(code); // Output: "28"
|
|
298
|
+
*/
|
|
299
|
+
export enum UnitTypeCodeEnum {
|
|
300
|
+
Group = '10',
|
|
301
|
+
Outfit = '11',
|
|
302
|
+
Ration = '13',
|
|
303
|
+
Shot = '14',
|
|
304
|
+
StickMilitary = '15',
|
|
305
|
+
FixedRate = '1I',
|
|
306
|
+
TwentyFootContainer = '20',
|
|
307
|
+
FortyFootContainer = '21',
|
|
308
|
+
DecilitrePerGram = '22',
|
|
309
|
+
GramPerCubicCentimetre = '23',
|
|
310
|
+
TheoreticalPound = '24',
|
|
311
|
+
GramPerSquareCentimetre = '25',
|
|
312
|
+
TheoreticalTon = '27',
|
|
313
|
+
KilogramPerSquareMetre = '28',
|
|
314
|
+
RadianPerSecond = '2A',
|
|
315
|
+
RadianPerSecondSquared = '2B',
|
|
316
|
+
Roentgen = '2C',
|
|
317
|
+
VoltAC = '2G',
|
|
318
|
+
VoltDC = '2H',
|
|
319
|
+
BritishThermalUnitInternationalTablePerHour = '2I',
|
|
320
|
+
CubicCentimetrePerSecond = '2J',
|
|
321
|
+
CubicFootPerHour = '2K',
|
|
322
|
+
CubicFootPerMinute = '2L',
|
|
323
|
+
CentimetrePerSecond = '2M',
|
|
324
|
+
Decibel = '2N',
|
|
325
|
+
Kilobyte = '2P',
|
|
326
|
+
Kilobecquerel = '2Q',
|
|
327
|
+
Kilocurie = '2R',
|
|
328
|
+
Megagram = '2U',
|
|
329
|
+
MetrePerMinute = '2X',
|
|
330
|
+
Milliroentgen = '2Y',
|
|
331
|
+
Millivolt = '2Z',
|
|
332
|
+
KilopascalSquareMetrePerGram = '33',
|
|
333
|
+
KilopascalPerMillimetre = '34',
|
|
334
|
+
MillilitrePerSquareCentimetreSecond = '35',
|
|
335
|
+
OuncePerSquareFoot = '37',
|
|
336
|
+
OuncePerSquareFootPer0_01inch = '38',
|
|
337
|
+
Megajoule = '3B',
|
|
338
|
+
Manmonth = '3C',
|
|
339
|
+
MillilitrePerSecond = '40',
|
|
340
|
+
MillilitrePerMinute = '41',
|
|
341
|
+
Centistokes = '4C',
|
|
342
|
+
Microlitre = '4G',
|
|
343
|
+
MicrometreMicron = '4H',
|
|
344
|
+
Milliampere = '4K',
|
|
345
|
+
Megabyte = '4L',
|
|
346
|
+
MilligramPerHour = '4M',
|
|
347
|
+
Megabecquerel = '4N',
|
|
348
|
+
Microfarad = '4O',
|
|
349
|
+
NewtonPerMetre = '4P',
|
|
350
|
+
OunceInch = '4Q',
|
|
351
|
+
OunceFoot = '4R',
|
|
352
|
+
Picofarad = '4T',
|
|
353
|
+
PoundPerHour = '4U',
|
|
354
|
+
TonUSPerHour = '4W',
|
|
355
|
+
KilolitrePerHour = '4X',
|
|
356
|
+
Sitas = '56',
|
|
357
|
+
Mesh = '57',
|
|
358
|
+
NetKilogram = '58',
|
|
359
|
+
PartPerMillion = '59',
|
|
360
|
+
BarrelUSPerMinute = '5A',
|
|
361
|
+
Batch = '5B',
|
|
362
|
+
MMSCFDay = '5E',
|
|
363
|
+
HydraulicHorsePower = '5J',
|
|
364
|
+
PercentWeight = '60',
|
|
365
|
+
PartPerBillionUS = '61',
|
|
366
|
+
Millipascal = '74',
|
|
367
|
+
MilliInch = '77',
|
|
368
|
+
PoundPerSquareInchAbsolute = '80',
|
|
369
|
+
Henry = '81',
|
|
370
|
+
FootPoundForce = '85',
|
|
371
|
+
PoundPerCubicFoot = '87',
|
|
372
|
+
Poise = '89',
|
|
373
|
+
Stokes = '91',
|
|
374
|
+
AmpereSquareMetrePerJouleSecond = 'A10',
|
|
375
|
+
Angstrom = 'A11',
|
|
376
|
+
AstronomicalUnit = 'A12',
|
|
377
|
+
Attojoule = 'A13',
|
|
378
|
+
Barn = 'A14',
|
|
379
|
+
BarnPerElectronvolt = 'A15',
|
|
380
|
+
BarnPerSteradianElectronvolt = 'A16',
|
|
381
|
+
BarnPerSteradian = 'A17',
|
|
382
|
+
BecquerelPerKilogram = 'A18',
|
|
383
|
+
BecquerelPerCubicMetre = 'A19',
|
|
384
|
+
AmperePerCentimetre = 'A2',
|
|
385
|
+
BritishThermalUnitInternationalTablePerSecondSquareFootDegreeRankine = 'A20',
|
|
386
|
+
BritishThermalUnitInternationalTablePerPoundDegreeRankine = 'A21',
|
|
387
|
+
BritishThermalUnitInternationalTablePerSecondFootDegreeRankine = 'A22',
|
|
388
|
+
BritishThermalUnitInternationalTablePerHourSquareFootDegreeRankine = 'A23',
|
|
389
|
+
CandelaPerSquareMetre = 'A24',
|
|
390
|
+
CoulombMetre = 'A26',
|
|
391
|
+
CoulombMetreSquaredPerVolt = 'A27',
|
|
392
|
+
CoulombPerCubicCentimetre = 'A28',
|
|
393
|
+
CoulombPerCubicMetre = 'A29',
|
|
394
|
+
AmperePerMillimetre = 'A3',
|
|
395
|
+
CoulombPerCubicMillimetre = 'A30',
|
|
396
|
+
CoulombPerKilogramSecond = 'A31',
|
|
397
|
+
CoulombPerMole = 'A32',
|
|
398
|
+
CoulombPerSquareCentimetre = 'A33',
|
|
399
|
+
CoulombPerSquareMetre = 'A34',
|
|
400
|
+
CoulombPerSquareMillimetre = 'A35',
|
|
401
|
+
CubicCentimetrePerMole = 'A36',
|
|
402
|
+
CubicDecimetrePerMole = 'A37',
|
|
403
|
+
CubicMetrePerCoulomb = 'A38',
|
|
404
|
+
CubicMetrePerKilogram = 'A39',
|
|
405
|
+
AmperePerSquareCentimetre = 'A4',
|
|
406
|
+
CubicMetrePerMole = 'A40',
|
|
407
|
+
AmperePerSquareMetre = 'A41',
|
|
408
|
+
CuriePerKilogram = 'A42',
|
|
409
|
+
DeadweightTonnage = 'A43',
|
|
410
|
+
Decalitre = 'A44',
|
|
411
|
+
Decametre = 'A45',
|
|
412
|
+
Decitex = 'A47',
|
|
413
|
+
DegreeRankine = 'A48',
|
|
414
|
+
Denier = 'A49',
|
|
415
|
+
AmpereSquareMetre = 'A5',
|
|
416
|
+
Electronvolt = 'A53',
|
|
417
|
+
ElectronvoltPerMetre = 'A54',
|
|
418
|
+
ElectronvoltSquareMetre = 'A55',
|
|
419
|
+
ElectronvoltSquareMetrePerKilogram = 'A56',
|
|
420
|
+
_8PartCloudCover = 'A59', // Enum member names cannot start with a number
|
|
421
|
+
AmperePerSquareMetreKelvinSquared = 'A6',
|
|
422
|
+
Exajoule = 'A68',
|
|
423
|
+
FaradPerMetre = 'A69',
|
|
424
|
+
AmperePerSquareMillimetre = 'A7',
|
|
425
|
+
Femtojoule = 'A70',
|
|
426
|
+
Femtometre = 'A71',
|
|
427
|
+
FootPerSecondSquared = 'A73',
|
|
428
|
+
FootPoundForcePerSecond = 'A74',
|
|
429
|
+
FreightTon = 'A75',
|
|
430
|
+
Gal = 'A76',
|
|
431
|
+
AmpereSecond = 'A8',
|
|
432
|
+
GigacoulombPerCubicMetre = 'A84',
|
|
433
|
+
Gigaelectronvolt = 'A85',
|
|
434
|
+
Gigahertz = 'A86',
|
|
435
|
+
Gigaohm = 'A87',
|
|
436
|
+
GigaohmMetre = 'A88',
|
|
437
|
+
Gigapascal = 'A89',
|
|
438
|
+
// ... (Codes omitted in provided documentation) ...
|
|
439
|
+
BoxWoodenNaturalWoodOrdinary = 'XQP',
|
|
440
|
+
BoxWoodenNaturalWoodWithSiftProofWalls = 'XQQ',
|
|
441
|
+
BoxPlasticExpanded = 'XQR',
|
|
442
|
+
BoxPlasticSolid = 'XQS',
|
|
443
|
+
Rod = 'XRD',
|
|
444
|
+
Ring = 'XRG',
|
|
445
|
+
RackClothingHanger = 'XRJ',
|
|
446
|
+
Rack = 'XRK',
|
|
447
|
+
Reel = 'XRL',
|
|
448
|
+
Roll = 'XRO',
|
|
449
|
+
Rednet = 'XRT',
|
|
450
|
+
RodsInBundleBunchTruss = 'XRZ',
|
|
451
|
+
Sack = 'XSA',
|
|
452
|
+
Slab = 'XSB',
|
|
453
|
+
CrateShallow = 'XSC',
|
|
454
|
+
Spindle = 'XSD',
|
|
455
|
+
SeaChest = 'XSE',
|
|
456
|
+
Sachet = 'XSH',
|
|
457
|
+
Skid = 'XSI',
|
|
458
|
+
CaseSkeleton = 'XSK',
|
|
459
|
+
Slipsheet = 'XSL',
|
|
460
|
+
Sheetmetal = 'XSM',
|
|
461
|
+
Spool = 'XSO',
|
|
462
|
+
SheetPlasticWrapping = 'XSP',
|
|
463
|
+
CaseSteel = 'XSS',
|
|
464
|
+
Sheet = 'XST',
|
|
465
|
+
Suitcase = 'XSU',
|
|
466
|
+
EnvelopeSteel = 'XSV',
|
|
467
|
+
Shrinkwrapped = 'XSW',
|
|
468
|
+
Set = 'XSX',
|
|
469
|
+
Sleeve = 'XSY',
|
|
470
|
+
SheetsInBundleBunchTruss = 'XSZ',
|
|
471
|
+
Tablet = 'XT1',
|
|
472
|
+
Tub = 'XTB',
|
|
473
|
+
TeaChest = 'XTC',
|
|
474
|
+
TubeCollapsible = 'XTD',
|
|
475
|
+
Tyre = 'XTE',
|
|
476
|
+
TankContainerGeneric = 'XTG',
|
|
477
|
+
Tierce = 'XTI',
|
|
478
|
+
TankRectangular = 'XTK',
|
|
479
|
+
TubWithLid = 'XTL',
|
|
480
|
+
Tin = 'XTN',
|
|
481
|
+
Tun = 'XTO',
|
|
482
|
+
Trunk = 'XTR',
|
|
483
|
+
Truss = 'XTS',
|
|
484
|
+
BagTote = 'XTT',
|
|
485
|
+
Tube = 'XTU',
|
|
486
|
+
TubeWithNozzle = 'XTV',
|
|
487
|
+
PalletTriwall = 'XTW',
|
|
488
|
+
TankCylindrical = 'XTY',
|
|
489
|
+
TubesInBundleBunchTruss = 'XTZ',
|
|
490
|
+
Uncaged = 'XUC',
|
|
491
|
+
Unit = 'XUN',
|
|
492
|
+
Vat = 'XVA',
|
|
493
|
+
BulkGasAt1031MbarAnd15C = 'XVG',
|
|
494
|
+
Vial = 'XVI',
|
|
495
|
+
Vanpack = 'XVK',
|
|
496
|
+
BulkLiquid = 'XVL',
|
|
497
|
+
Vehicle = 'XVN',
|
|
498
|
+
BulkSolidLargeParticlesNodules = 'XVO',
|
|
499
|
+
VacuumPacked = 'XVP',
|
|
500
|
+
BulkLiquefiedGasAtAbnormalTemperaturePressure = 'XVQ',
|
|
501
|
+
BulkSolidGranularParticlesGrains = 'XVR',
|
|
502
|
+
BulkScrapMetal = 'XVS',
|
|
503
|
+
BulkSolidFineParticlesPowders = 'XVY',
|
|
504
|
+
IntermediateBulkContainer = 'XWA',
|
|
505
|
+
Wickerbottle = 'XWB',
|
|
506
|
+
IntermediateBulkContainerSteel = 'XWC',
|
|
507
|
+
IntermediateBulkContainerAluminium = 'XWD',
|
|
508
|
+
IntermediateBulkContainerMetal = 'XWF',
|
|
509
|
+
IntermediateBulkContainerSteelPressurisedGreaterThan10Kpa = 'XWG',
|
|
510
|
+
IntermediateBulkContainerAluminiumPressurisedGreaterThan10Kpa = 'XWH',
|
|
511
|
+
IntermediateBulkContainerMetalPressure10Kpa = 'XWJ',
|
|
512
|
+
IntermediateBulkContainerSteelLiquid = 'XWK',
|
|
513
|
+
IntermediateBulkContainerAluminiumLiquid = 'XWL',
|
|
514
|
+
IntermediateBulkContainerMetalLiquid = 'XWM',
|
|
515
|
+
IntermediateBulkContainerWovenPlasticWithoutCoatLiner = 'XWN',
|
|
516
|
+
IntermediateBulkContainerWovenPlasticCoated = 'XWP',
|
|
517
|
+
IntermediateBulkContainerWovenPlasticWithLiner = 'XWQ',
|
|
518
|
+
IntermediateBulkContainerWovenPlasticCoatedAndLiner = 'XWR',
|
|
519
|
+
IntermediateBulkContainerPlasticFilm = 'XWS',
|
|
520
|
+
IntermediateBulkContainerTextileWithOutCoatLiner = 'XWT',
|
|
521
|
+
IntermediateBulkContainerNaturalWoodWithInnerLiner = 'XWU',
|
|
522
|
+
IntermediateBulkContainerTextileCoated = 'XWV',
|
|
523
|
+
IntermediateBulkContainerTextileWithLiner = 'XWW',
|
|
524
|
+
IntermediateBulkContainerTextileCoatedAndLiner = 'XWX',
|
|
525
|
+
IntermediateBulkContainerPlywoodWithInnerLiner = 'XWY',
|
|
526
|
+
IntermediateBulkContainerReconstitutedWoodWithInnerLiner = 'XWZ',
|
|
527
|
+
BagWovenPlasticWithoutInnerCoatLiner = 'XXA',
|
|
528
|
+
BagWovenPlasticSiftProof = 'XXB',
|
|
529
|
+
BagWovenPlasticWaterResistant = 'XXC',
|
|
530
|
+
BagPlasticsFilm = 'XXD',
|
|
531
|
+
BagTextileWithoutInnerCoatLiner = 'XXF',
|
|
532
|
+
BagTextileSiftProof = 'XXG',
|
|
533
|
+
BagTextileWaterResistant = 'XXH',
|
|
534
|
+
BagPaperMultiWall = 'XXJ',
|
|
535
|
+
BagPaperMultiWallWaterResistant = 'XXK',
|
|
536
|
+
CompositePackagingPlasticReceptacleInSteelDrum = 'XYA',
|
|
537
|
+
CompositePackagingPlasticReceptacleInSteelCrateBox = 'XYB',
|
|
538
|
+
CompositePackagingPlasticReceptacleInAluminiumDrum = 'XYC',
|
|
539
|
+
CompositePackagingPlasticReceptacleInAluminiumCrate = 'XYD',
|
|
540
|
+
CompositePackagingPlasticReceptacleInWoodenBox = 'XYF',
|
|
541
|
+
CompositePackagingPlasticReceptacleInPlywoodDrum = 'XYG',
|
|
542
|
+
CompositePackagingPlasticReceptacleInPlywoodBox = 'XYH',
|
|
543
|
+
CompositePackagingPlasticReceptacleInFibreDrum = 'XYJ',
|
|
544
|
+
CompositePackagingPlasticReceptacleInFibreboardBox = 'XYK',
|
|
545
|
+
CompositePackagingPlasticReceptacleInPlasticDrum = 'XYL',
|
|
546
|
+
CompositePackagingPlasticReceptacleInSolidPlasticBox = 'XYM',
|
|
547
|
+
CompositePackagingGlassReceptacleInSteelDrum = 'XYN',
|
|
548
|
+
CompositePackagingGlassReceptacleInSteelCrateBox = 'XYP',
|
|
549
|
+
CompositePackagingGlassReceptacleInAluminiumDrum = 'XYQ',
|
|
550
|
+
CompositePackagingGlassReceptacleInAluminiumCrate = 'XYR',
|
|
551
|
+
CompositePackagingGlassReceptacleInWoodenBox = 'XYS',
|
|
552
|
+
CompositePackagingGlassReceptacleInPlywoodDrum = 'XYT',
|
|
553
|
+
CompositePackagingGlassReceptacleInWickerworkHamper = 'XYV',
|
|
554
|
+
CompositePackagingGlassReceptacleInFibreDrum = 'XYW',
|
|
555
|
+
CompositePackagingGlassReceptacleInFibreboardBox = 'XYX',
|
|
556
|
+
CompositePackagingGlassReceptacleInExpandablePlasticPack = 'XYY',
|
|
557
|
+
CompositePackagingGlassReceptacleInSolidPlasticPack = 'XYZ',
|
|
558
|
+
IntermediateBulkContainerPaperMultiWall = 'XZA',
|
|
559
|
+
BagLarge = 'XZB',
|
|
560
|
+
IntermediateBulkContainerPaperMultiWallWaterResistant = 'XZC',
|
|
561
|
+
IntermediateBulkContainerRigidPlasticWithStructuralEquipmentSolids = 'XZD',
|
|
562
|
+
IntermediateBulkContainerRigidPlasticFreestandingSolids = 'XZF',
|
|
563
|
+
IntermediateBulkContainerRigidPlasticWithStructuralEquipmentPressurised = 'XZG',
|
|
564
|
+
IntermediateBulkContainerRigidPlasticFreestandingPressurised = 'XZH',
|
|
565
|
+
IntermediateBulkContainerRigidPlasticWithStructuralEquipmentLiquids = 'XZJ',
|
|
566
|
+
IntermediateBulkContainerRigidPlasticFreestandingLiquids = 'XZK',
|
|
567
|
+
IntermediateBulkContainerCompositeRigidPlasticSolids = 'XZL',
|
|
568
|
+
IntermediateBulkContainerCompositeFlexiblePlasticSolids = 'XZM',
|
|
569
|
+
IntermediateBulkContainerCompositeRigidPlasticPressurised = 'XZN',
|
|
570
|
+
IntermediateBulkContainerCompositeFlexiblePlasticPressurised = 'XZP',
|
|
571
|
+
IntermediateBulkContainerCompositeRigidPlasticLiquids = 'XZQ',
|
|
572
|
+
IntermediateBulkContainerCompositeFlexiblePlasticLiquids = 'XZR',
|
|
573
|
+
IntermediateBulkContainerComposite = 'XZS',
|
|
574
|
+
IntermediateBulkContainerFibreboard = 'XZT',
|
|
575
|
+
IntermediateBulkContainerFlexible = 'XZU',
|
|
576
|
+
IntermediateBulkContainerMetalOtherThanSteel = 'XZV',
|
|
577
|
+
IntermediateBulkContainerNaturalWood = 'XZW',
|
|
578
|
+
IntermediateBulkContainerPlywood = 'XZX',
|
|
579
|
+
IntermediateBulkContainerReconstitutedWood = 'XZY',
|
|
580
|
+
MutuallyDefined = 'XZZ',
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Interface representing a Unit of Measurement entry.
|
|
585
|
+
* Contains the code and its corresponding name.
|
|
586
|
+
*/
|
|
587
|
+
export interface UnitType {
|
|
588
|
+
code: UnitTypeCode
|
|
589
|
+
name: string
|
|
590
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ofetch } from 'ofetch'
|
|
2
|
+
|
|
3
|
+
interface TokenResponse {
|
|
4
|
+
access_token: string
|
|
5
|
+
expires_in: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class MyInvoisClient {
|
|
9
|
+
private readonly baseUrl: string
|
|
10
|
+
private readonly clientId: string
|
|
11
|
+
private readonly clientSecret: string
|
|
12
|
+
private token = ''
|
|
13
|
+
private tokenExpiration = new Date()
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
clientId: string,
|
|
17
|
+
clientSecret: string,
|
|
18
|
+
environment: 'sandbox' | 'production',
|
|
19
|
+
) {
|
|
20
|
+
this.clientId = clientId
|
|
21
|
+
this.clientSecret = clientSecret
|
|
22
|
+
|
|
23
|
+
if (environment === 'sandbox') {
|
|
24
|
+
this.baseUrl = 'https://preprod-mytax.hasil.gov.my/'
|
|
25
|
+
} else {
|
|
26
|
+
this.baseUrl = 'https://mytax.hasil.gov.my'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private async refreshToken() {
|
|
31
|
+
const tokenResponse = await ofetch<TokenResponse>(
|
|
32
|
+
`${this.baseUrl}/connect/token`,
|
|
33
|
+
{
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
37
|
+
},
|
|
38
|
+
body: {
|
|
39
|
+
grant_type: 'client_credentials',
|
|
40
|
+
client_id: this.clientId,
|
|
41
|
+
client_secret: this.clientSecret,
|
|
42
|
+
scope: 'InvoicingAPI',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
this.token = tokenResponse.access_token
|
|
48
|
+
this.tokenExpiration = new Date(
|
|
49
|
+
Date.now() + tokenResponse.expires_in * 1000,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async getToken() {
|
|
54
|
+
if (this.tokenExpiration < new Date()) {
|
|
55
|
+
await this.refreshToken()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this.token
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private async fetch<T>(
|
|
62
|
+
path: string,
|
|
63
|
+
options: Parameters<typeof ofetch>[1] = {},
|
|
64
|
+
) {
|
|
65
|
+
const token = await this.getToken()
|
|
66
|
+
|
|
67
|
+
return ofetch<T>(`${this.baseUrl}${path}`, {
|
|
68
|
+
...options,
|
|
69
|
+
headers: { ...options.headers, Authorization: `Bearer ${token}` },
|
|
70
|
+
responseType: 'json',
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Validates a TIN against a NRIC
|
|
76
|
+
*
|
|
77
|
+
* @param tin
|
|
78
|
+
* @param nric
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
async verifyTin(tin: string, nric: string) {
|
|
82
|
+
try {
|
|
83
|
+
await this.fetch<void>(
|
|
84
|
+
`/api/v1.0/taxpayer/validate/${tin}?idType=NRIC&idValue=${nric}`,
|
|
85
|
+
{
|
|
86
|
+
method: 'GET',
|
|
87
|
+
},
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return true
|
|
91
|
+
} catch {
|
|
92
|
+
return false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Base Options: */
|
|
4
|
+
"esModuleInterop": true,
|
|
5
|
+
"skipLibCheck": false,
|
|
6
|
+
"target": "ESNext",
|
|
7
|
+
"allowJs": false,
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"moduleDetection": "force",
|
|
10
|
+
"isolatedModules": true, // Often recommended for bundlers
|
|
11
|
+
/* Strictness */
|
|
12
|
+
"strict": true,
|
|
13
|
+
"noUncheckedIndexedAccess": true,
|
|
14
|
+
"noImplicitAny": true,
|
|
15
|
+
/* Bundler Behavior */
|
|
16
|
+
"moduleResolution": "Bundler", // Or "NodeNext"
|
|
17
|
+
"module": "ESNext",
|
|
18
|
+
"noEmit": true, // Rolldown handles emission
|
|
19
|
+
/* Path Resolution */
|
|
20
|
+
"baseUrl": ".", // Important for resolving paths relative to root
|
|
21
|
+
/* Type Checking */
|
|
22
|
+
"types": [
|
|
23
|
+
"bun"
|
|
24
|
+
] // Include Bun types if using Bun runtime features
|
|
25
|
+
},
|
|
26
|
+
"include": [
|
|
27
|
+
"src/**/*.ts",
|
|
28
|
+
"src/**/*.d.ts",
|
|
29
|
+
"rolldown.config.ts"
|
|
30
|
+
],
|
|
31
|
+
"exclude": [
|
|
32
|
+
"node_modules",
|
|
33
|
+
"dist"
|
|
34
|
+
]
|
|
35
|
+
}
|