@ripwords/myinvois-client 0.1.6 → 0.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.
- package/dist/api/documentManagement.d.ts +89 -0
- package/dist/api/documentManagement.js +3 -0
- package/dist/api/documentSubmission.d.ts +92 -0
- package/dist/api/documentSubmission.js +4 -0
- package/dist/api/documentTypeManagement.d.ts +70 -0
- package/dist/api/documentTypeManagement.js +3 -0
- package/dist/api/notificationManagement.d.ts +68 -0
- package/dist/api/notificationManagement.js +3 -0
- package/dist/api/platformLogin.d.ts +68 -0
- package/dist/api/platformLogin.js +3 -0
- package/dist/api/taxpayerValidation.d.ts +79 -0
- package/dist/api/taxpayerValidation.js +3 -0
- package/dist/{certificate-DFK-788s.cjs → certificate-CxsfE91s.cjs} +1 -1
- package/dist/{certificate-DFK-788s.cjs.map → certificate-CxsfE91s.cjs.map} +1 -1
- package/dist/{document-CARHiGdp.cjs → document-vDphtJTv.cjs} +1 -1
- package/dist/{document-CARHiGdp.cjs.map → document-vDphtJTv.cjs.map} +1 -1
- package/dist/documentManagement-CIQPkmyb.js +35 -0
- package/dist/documentManagement-DQ7JEcBq.cjs +54 -0
- package/dist/documentManagement-DQ7JEcBq.cjs.map +1 -0
- package/dist/documentSubmission-BdJxIB_I.js +119 -0
- package/dist/documentSubmission-D5TC0MPC.cjs +137 -0
- package/dist/documentSubmission-D5TC0MPC.cjs.map +1 -0
- package/dist/documentTypeManagement-DXRLfTsW.cjs +41 -0
- package/dist/documentTypeManagement-DXRLfTsW.cjs.map +1 -0
- package/dist/documentTypeManagement-tojgXfm9.js +22 -0
- package/dist/{documents-i5EV868Y.d.ts → documents-BgXt86Qp.d.ts} +44 -7
- package/dist/{documents-CQy_uB6C.d.cts → documents-BqM9qOnB.d.cts} +39 -2
- package/dist/{getBaseUrl-CO7Jp27d.cjs → getBaseUrl-D2iJdUGL.cjs} +1 -1
- package/dist/{getBaseUrl-CO7Jp27d.cjs.map → getBaseUrl-D2iJdUGL.cjs.map} +1 -1
- package/dist/{index-D2_HVwCz.d.cts → index-Yr1QAbIF.d.cts} +1 -1
- package/dist/index.cjs +234 -131
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +250 -60
- package/dist/index.js +234 -131
- package/dist/index10.cjs +196 -0
- package/dist/index10.cjs.map +1 -0
- package/dist/index11.cjs +0 -34
- package/dist/index12.cjs +16 -15
- package/dist/index12.cjs.map +1 -1
- package/dist/index14.cjs +0 -13
- package/dist/index15.cjs +28 -3
- package/dist/index15.cjs.map +1 -0
- package/dist/index16.cjs +24 -12
- package/dist/index16.cjs.map +1 -0
- package/dist/index17.cjs +0 -3
- package/dist/index18.cjs +28 -334
- package/dist/index18.cjs.map +1 -1
- package/dist/index19.cjs +18 -323
- package/dist/index19.cjs.map +1 -1
- package/dist/index2.cjs +4 -61
- package/dist/index20.cjs +0 -140
- package/dist/index21.cjs +0 -3
- package/dist/index22.cjs +0 -208
- package/dist/index23.cjs +9 -105
- package/dist/index23.cjs.map +1 -1
- package/dist/index24.cjs +3 -136
- package/dist/index25.cjs +12 -63
- package/dist/index26.cjs +2 -266
- package/dist/index27.cjs +325 -75
- package/dist/index27.cjs.map +1 -1
- package/dist/index28.cjs +136 -103
- package/dist/index28.cjs.map +1 -1
- package/dist/index29.cjs +203 -68
- package/dist/index29.cjs.map +1 -1
- package/dist/index3.cjs +5 -531
- package/dist/index30.cjs +104 -107
- package/dist/index30.cjs.map +1 -1
- package/dist/index31.cjs +132 -95
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +59 -13
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +262 -33
- package/dist/index33.cjs.map +1 -1
- package/dist/index34.cjs +74 -14
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +102 -24
- package/dist/index35.cjs.map +1 -1
- package/dist/index36.cjs +68 -15
- package/dist/index36.cjs.map +1 -1
- package/dist/index37.cjs +107 -9
- package/dist/index37.cjs.map +1 -1
- package/dist/index38.cjs +95 -9
- package/dist/index38.cjs.map +1 -1
- package/dist/index39.cjs +11 -10
- package/dist/index39.cjs.map +1 -1
- package/dist/index4.cjs +4 -195
- package/dist/index40.cjs +31 -6
- package/dist/index40.cjs.map +1 -1
- package/dist/index41.cjs +12 -101
- package/dist/index41.cjs.map +1 -1
- package/dist/index42.cjs +22 -106
- package/dist/index42.cjs.map +1 -1
- package/dist/index43.cjs +13 -119
- package/dist/index43.cjs.map +1 -1
- package/dist/index44.cjs +7 -106
- package/dist/index44.cjs.map +1 -1
- package/dist/index45.cjs +7 -98
- package/dist/index45.cjs.map +1 -1
- package/dist/index46.cjs +10 -118
- package/dist/index46.cjs.map +1 -1
- package/dist/index47.cjs +6 -127
- package/dist/index47.cjs.map +1 -1
- package/dist/index48.cjs +101 -117
- package/dist/index48.cjs.map +1 -1
- package/dist/index49.cjs +106 -14
- package/dist/index49.cjs.map +1 -1
- package/dist/index5.cjs +3 -0
- package/dist/index50.cjs +119 -95
- package/dist/index50.cjs.map +1 -1
- package/dist/index51.cjs +106 -142
- package/dist/index51.cjs.map +1 -1
- package/dist/index52.cjs +98 -114
- package/dist/index52.cjs.map +1 -1
- package/dist/index53.cjs +118 -144
- package/dist/index53.cjs.map +1 -1
- package/dist/index54.cjs +127 -113
- package/dist/index54.cjs.map +1 -1
- package/dist/index55.cjs +117 -17
- package/dist/index55.cjs.map +1 -1
- package/dist/index56.cjs +14 -112
- package/dist/index56.cjs.map +1 -1
- package/dist/index57.cjs +95 -47
- package/dist/index57.cjs.map +1 -1
- package/dist/index58.cjs +142 -14
- package/dist/index58.cjs.map +1 -1
- package/dist/index59.cjs +114 -28
- package/dist/index59.cjs.map +1 -1
- package/dist/index6.cjs +2 -24
- package/dist/index60.cjs +144 -22
- package/dist/index60.cjs.map +1 -1
- package/dist/index61.cjs +113 -9
- package/dist/index61.cjs.map +1 -1
- package/dist/index61.cts.map +1 -1
- package/dist/index62.cjs +17 -8
- package/dist/index62.cjs.map +1 -1
- package/dist/index62.cts.map +1 -1
- package/dist/index63.cjs +112 -17
- package/dist/index63.cjs.map +1 -1
- package/dist/index63.cts.map +1 -1
- package/dist/index64.cjs +47 -412
- package/dist/index64.cjs.map +1 -1
- package/dist/index64.cts.map +1 -1
- package/dist/index65.cjs +14 -8
- package/dist/index65.cjs.map +1 -1
- package/dist/index65.cts.map +1 -1
- package/dist/index66.cjs +28 -9
- package/dist/index66.cjs.map +1 -1
- package/dist/index66.cts.map +1 -1
- package/dist/index67.cjs +29 -0
- package/dist/index67.cjs.map +1 -0
- package/dist/index67.cts.map +1 -0
- package/dist/index68.cjs +16 -0
- package/dist/index68.cjs.map +1 -0
- package/dist/{index60.cts.map → index68.cts.map} +1 -1
- package/dist/index69.cjs +15 -0
- package/dist/index69.cjs.map +1 -0
- package/dist/index69.cts.map +1 -0
- package/dist/index7.cjs +5 -0
- package/dist/index70.cjs +24 -0
- package/dist/index70.cjs.map +1 -0
- package/dist/index70.cts.map +1 -0
- package/dist/index71.cjs +419 -0
- package/dist/index71.cjs.map +1 -0
- package/dist/index71.cts.map +1 -0
- package/dist/index72.cjs +15 -0
- package/dist/index72.cjs.map +1 -0
- package/dist/index72.cts.map +1 -0
- package/dist/index73.cjs +16 -0
- package/dist/index73.cjs.map +1 -0
- package/dist/index73.cts.map +1 -0
- package/dist/index8.cjs +62 -0
- package/dist/{index2.cjs.map → index8.cjs.map} +1 -1
- package/dist/index9.cjs +523 -16
- package/dist/index9.cjs.map +1 -1
- package/dist/{msic-codes-C8PJVOaA.d.ts → msic-codes-CiPeemFK.d.ts} +10 -10
- package/dist/notificationManagement-CHDRVy8J.js +19 -0
- package/dist/notificationManagement-C_qrFwWL.cjs +26 -0
- package/dist/notificationManagement-C_qrFwWL.cjs.map +1 -0
- package/dist/notifications-B4l_qRj7.d.ts +62 -0
- package/dist/notifications-DdlEkprb.d.cts +63 -0
- package/dist/{platformLogin-PGzMhw1X.cjs → platformLogin-CPiPiVUh.cjs} +2 -2
- package/dist/platformLogin-CPiPiVUh.cjs.map +1 -0
- package/dist/{platformLogin-f0bNAoZI.js → platformLogin-Ck1Fge2n.js} +1 -1
- package/dist/taxpayer-D67d2zAC.d.ts +26 -0
- package/dist/taxpayer-sGkviG8J.d.cts +27 -0
- package/dist/taxpayerValidation-DI4B6kWx.js +54 -0
- package/dist/taxpayerValidation-DdeXCvPT.cjs +73 -0
- package/dist/taxpayerValidation-DdeXCvPT.cjs.map +1 -0
- package/dist/types/classification-codes.d.ts +1 -1
- package/dist/types/country-code.d.ts +1 -1
- package/dist/types/currencies.d.ts +1 -1
- package/dist/types/documents.d.ts +18 -18
- package/dist/types/e-invoice.d.ts +1 -1
- package/dist/types/index.d.ts +61 -58
- package/dist/types/msic/0X.d.ts +1 -1
- package/dist/types/msic/1X.d.ts +1 -1
- package/dist/types/msic/2X.d.ts +1 -1
- package/dist/types/msic/3X.d.ts +1 -1
- package/dist/types/msic/4X.d.ts +1 -1
- package/dist/types/msic/5X.d.ts +1 -1
- package/dist/types/msic/6X.d.ts +1 -1
- package/dist/types/msic/7X.d.ts +1 -1
- package/dist/types/msic/8X.d.ts +1 -1
- package/dist/types/msic/9X.d.ts +1 -1
- package/dist/types/msic-codes.d.ts +11 -11
- package/dist/types/notifications.d.ts +2 -0
- package/dist/types/payment-modes.d.ts +1 -1
- package/dist/types/signatures.d.ts +1 -1
- package/dist/types/state-codes.d.ts +1 -1
- package/dist/types/tax-types.d.ts +1 -1
- package/dist/types/taxpayer.d.ts +19 -0
- package/dist/types/unit/1X.d.ts +1 -1
- package/dist/types/unit/2X.d.ts +1 -1
- package/dist/types/unit/3X.d.ts +1 -1
- package/dist/types/unit/4X.d.ts +1 -1
- package/dist/types/unit/5X.d.ts +1 -1
- package/dist/types/unit/6X.d.ts +1 -1
- package/dist/types/unit/7X.d.ts +1 -1
- package/dist/types/unit/8X.d.ts +1 -1
- package/dist/types/unit/9X.d.ts +1 -1
- package/dist/types/unit/AX.d.ts +1 -1
- package/dist/types/unit/BX.d.ts +1 -1
- package/dist/types/unit/CX.d.ts +1 -1
- package/dist/types/unit/DX.d.ts +1 -1
- package/dist/types/unit/EX.d.ts +1 -1
- package/dist/types/unit/FX.d.ts +1 -1
- package/dist/types/unit/GX.d.ts +1 -1
- package/dist/types/unit/HX.d.ts +1 -1
- package/dist/types/unit/IX.d.ts +1 -1
- package/dist/types/unit/JX.d.ts +1 -1
- package/dist/types/unit/KX.d.ts +1 -1
- package/dist/types/unit/LX.d.ts +1 -1
- package/dist/types/unit/MX.d.ts +1 -1
- package/dist/types/unit/NX.d.ts +1 -1
- package/dist/types/unit/OX.d.ts +1 -1
- package/dist/types/unit/PX.d.ts +1 -1
- package/dist/types/unit/QX.d.ts +1 -1
- package/dist/types/unit/RX.d.ts +1 -1
- package/dist/types/unit/SX.d.ts +1 -1
- package/dist/types/unit/TX.d.ts +1 -1
- package/dist/types/unit/UX.d.ts +1 -1
- package/dist/types/unit/VX.d.ts +1 -1
- package/dist/types/unit/WX.d.ts +1 -1
- package/dist/types/unit/XX.d.ts +1 -1
- package/dist/types/unit/YX.d.ts +1 -1
- package/dist/types/unit/ZX.d.ts +1 -1
- package/dist/types/unit-types.d.ts +36 -36
- package/dist/types/utils.d.ts +2 -0
- package/dist/unit-types-VgYXIwTT.d.ts +55 -0
- package/dist/utils/certificate.js +1 -1
- package/dist/utils/document.d.ts +60 -57
- package/dist/utils/document.js +1 -1
- package/dist/utils/getBaseUrl.js +1 -1
- package/dist/utils/signature-diagnostics.d.ts +60 -57
- package/dist/utils/signature-diagnostics.js +1 -1
- package/dist/utils-B3mo51Zp.d.ts +4 -0
- package/dist/utils-Cdqbbzca.d.cts +5 -0
- package/package.json +5 -8
- package/.prettierrc +0 -8
- package/CHANGELOG.md +0 -152
- package/bun.lock +0 -460
- package/dist/api/platform/platformLogin.d.ts +0 -65
- package/dist/api/platform/platformLogin.js +0 -3
- package/dist/index11.cjs.map +0 -1
- package/dist/index14.cjs.map +0 -1
- package/dist/index20.cjs.map +0 -1
- package/dist/index22.cjs.map +0 -1
- package/dist/index24.cjs.map +0 -1
- package/dist/index25.cjs.map +0 -1
- package/dist/index26.cjs.map +0 -1
- package/dist/index3.cjs.map +0 -1
- package/dist/index4.cjs.map +0 -1
- package/dist/index58.cts.map +0 -1
- package/dist/index59.cts.map +0 -1
- package/dist/index6.cjs.map +0 -1
- package/dist/platformLogin-PGzMhw1X.cjs.map +0 -1
- package/dist/unit-types-B41YFOLT.d.ts +0 -55
- package/dist/utils/helpers.d.ts +0 -271
- package/dist/utils/helpers.js +0 -330
- package/myinvois-cert.conf.template +0 -23
- package/scripts/gen-cert.sh +0 -159
- package/src/api/platform/platformLogin.ts +0 -34
- package/src/index.ts +0 -530
- package/src/types/classification-codes.d.ts +0 -115
- package/src/types/country-code.d.ts +0 -790
- package/src/types/currencies.d.ts +0 -383
- package/src/types/documents.d.ts +0 -869
- package/src/types/e-invoice.d.ts +0 -41
- package/src/types/index.d.ts +0 -24
- package/src/types/msic/0X.d.ts +0 -408
- package/src/types/msic/1X.d.ts +0 -210
- package/src/types/msic/2X.d.ts +0 -266
- package/src/types/msic/3X.d.ts +0 -114
- package/src/types/msic/4X.d.ts +0 -520
- package/src/types/msic/5X.d.ts +0 -144
- package/src/types/msic/6X.d.ts +0 -200
- package/src/types/msic/7X.d.ts +0 -132
- package/src/types/msic/8X.d.ts +0 -210
- package/src/types/msic/9X.d.ts +0 -186
- package/src/types/msic-codes.d.ts +0 -31
- package/src/types/payment-modes.d.ts +0 -41
- package/src/types/signatures.d.ts +0 -169
- package/src/types/state-codes.d.ts +0 -59
- package/src/types/tax-types.d.ts +0 -39
- package/src/types/unit/1X.d.ts +0 -16
- package/src/types/unit/2X.d.ts +0 -62
- package/src/types/unit/3X.d.ts +0 -17
- package/src/types/unit/4X.d.ts +0 -44
- package/src/types/unit/5X.d.ts +0 -26
- package/src/types/unit/6X.d.ts +0 -12
- package/src/types/unit/7X.d.ts +0 -12
- package/src/types/unit/8X.d.ts +0 -15
- package/src/types/unit/9X.d.ts +0 -11
- package/src/types/unit/AX.d.ts +0 -202
- package/src/types/unit/BX.d.ts +0 -212
- package/src/types/unit/CX.d.ts +0 -238
- package/src/types/unit/DX.d.ts +0 -212
- package/src/types/unit/EX.d.ts +0 -196
- package/src/types/unit/FX.d.ts +0 -236
- package/src/types/unit/GX.d.ts +0 -254
- package/src/types/unit/HX.d.ts +0 -234
- package/src/types/unit/IX.d.ts +0 -28
- package/src/types/unit/JX.d.ts +0 -190
- package/src/types/unit/KX.d.ts +0 -284
- package/src/types/unit/LX.d.ts +0 -228
- package/src/types/unit/MX.d.ts +0 -288
- package/src/types/unit/NX.d.ts +0 -226
- package/src/types/unit/OX.d.ts +0 -34
- package/src/types/unit/PX.d.ts +0 -224
- package/src/types/unit/QX.d.ts +0 -94
- package/src/types/unit/RX.d.ts +0 -28
- package/src/types/unit/SX.d.ts +0 -56
- package/src/types/unit/TX.d.ts +0 -44
- package/src/types/unit/UX.d.ts +0 -14
- package/src/types/unit/VX.d.ts +0 -13
- package/src/types/unit/WX.d.ts +0 -34
- package/src/types/unit/XX.d.ts +0 -825
- package/src/types/unit/YX.d.ts +0 -17
- package/src/types/unit/ZX.d.ts +0 -19
- package/src/types/unit-types.d.ts +0 -86
- package/src/utils/base64.ts +0 -7
- package/src/utils/certificate.ts +0 -60
- package/src/utils/document.ts +0 -852
- package/src/utils/getBaseUrl.ts +0 -5
- package/src/utils/helpers.ts +0 -552
- package/src/utils/signature-diagnostics.ts +0 -583
- package/src/utils/validation.ts +0 -268
- package/test/MyInvoiClientWithRealData.test.ts +0 -40
- package/test/MyInvoisClient.test.ts +0 -204
- package/test/base64.test.ts +0 -43
- package/test/dynamicInvoiceFeatures.test.ts +0 -451
- package/test/signAndSubmitInvoice.test.ts +0 -452
- package/test/signature-diagnostics.test.ts +0 -130
- package/tsconfig.json +0 -39
- package/tsdown.config.ts +0 -31
- package/vitest.config.ts +0 -8
- /package/dist/{0X-CTIq3y3a.d.ts → 0X-DZnB0al0.d.ts} +0 -0
- /package/dist/{1X-BywXCqtn.d.ts → 1X-C72Wa4pk.d.ts} +0 -0
- /package/dist/{1X-Bu4oiv8D.d.ts → 1X-Dg5J6Bfg.d.ts} +0 -0
- /package/dist/{2X-3fSEGIuE.d.ts → 2X-CH89y3Af.d.ts} +0 -0
- /package/dist/{2X-DnG3FY1f.d.ts → 2X-D_qwTeDT.d.ts} +0 -0
- /package/dist/{3X-CLdmoel1.d.ts → 3X-BJHYxgxa.d.ts} +0 -0
- /package/dist/{3X-Ynjfgoll.d.ts → 3X-DryrwYRf.d.ts} +0 -0
- /package/dist/{4X-B5ePdMky.d.ts → 4X-BPMLRoDv.d.ts} +0 -0
- /package/dist/{4X-BTG6o1Gn.d.ts → 4X-BbZgoRHO.d.ts} +0 -0
- /package/dist/{5X-dhP6fyou.d.ts → 5X-Bv7M6KyG.d.ts} +0 -0
- /package/dist/{5X-CjSz1zxJ.d.ts → 5X-oQRBnO0f.d.ts} +0 -0
- /package/dist/{6X-B9KP_vEn.d.ts → 6X-B9I2XJa4.d.ts} +0 -0
- /package/dist/{6X-BHaY0TCf.d.ts → 6X-ZeZ8OB57.d.ts} +0 -0
- /package/dist/{7X-DtkQutx2.d.ts → 7X-Ckv9bbzG.d.ts} +0 -0
- /package/dist/{7X-C4eX_tAk.d.ts → 7X-Dvw2Z2VN.d.ts} +0 -0
- /package/dist/{8X-D6HTLShY.d.ts → 8X-BkgoX8dg.d.ts} +0 -0
- /package/dist/{8X-5n9seY3z.d.ts → 8X-C37BJTl6.d.ts} +0 -0
- /package/dist/{9X-CHZKsIdD.d.ts → 9X-Du0e44cq.d.ts} +0 -0
- /package/dist/{9X-Cpb6V4JC.d.ts → 9X-_XRgT2-_.d.ts} +0 -0
- /package/dist/{AX-C0w_r3PA.d.ts → AX-BSPLpkVT.d.ts} +0 -0
- /package/dist/{BX-RadlZ-6m.d.ts → BX-u4yMaIkz.d.ts} +0 -0
- /package/dist/{CX-CT1Zzb9D.d.ts → CX-BKZG0pVE.d.ts} +0 -0
- /package/dist/{DX-CtUeTKMM.d.ts → DX-CwA9WJAf.d.ts} +0 -0
- /package/dist/{EX-084Yu7Wt.d.ts → EX-BRNu1Ooi.d.ts} +0 -0
- /package/dist/{FX-BrbQM0CW.d.ts → FX-DBxjq6xY.d.ts} +0 -0
- /package/dist/{GX-gKj8iAAh.d.ts → GX-B3CvWNrP.d.ts} +0 -0
- /package/dist/{HX-9D-ZXTy5.d.ts → HX-D7FABgTv.d.ts} +0 -0
- /package/dist/{IX-DR4Fc92A.d.ts → IX-D3ZknsAB.d.ts} +0 -0
- /package/dist/{JX-DIKa9ma-.d.ts → JX-BRaZM3Gc.d.ts} +0 -0
- /package/dist/{KX-DpsJ_unT.d.ts → KX-B1K0OWoi.d.ts} +0 -0
- /package/dist/{LX-DeXPPWUX.d.ts → LX-CKRefinL.d.ts} +0 -0
- /package/dist/{MX-CKMjg_zK.d.ts → MX-DKmaeO9r.d.ts} +0 -0
- /package/dist/{NX-oYdb4NDo.d.ts → NX-CJL2Gn1U.d.ts} +0 -0
- /package/dist/{OX-Bid9es3D.d.ts → OX-Do2ap5v_.d.ts} +0 -0
- /package/dist/{PX-D7jy9CFk.d.ts → PX-_DOr_rm9.d.ts} +0 -0
- /package/dist/{QX-BFWOR4g3.d.ts → QX-HlXLkIki.d.ts} +0 -0
- /package/dist/{RX-XHgCyMV1.d.ts → RX-DVPGOVES.d.ts} +0 -0
- /package/dist/{SX-Cl8RN8oH.d.ts → SX-OGT3qwlS.d.ts} +0 -0
- /package/dist/{TX-ZymoIbtr.d.ts → TX-cPDINmZ5.d.ts} +0 -0
- /package/dist/{UX-D-Ndd1ov.d.ts → UX-Be3sqvPV.d.ts} +0 -0
- /package/dist/{VX-B-1b34r7.d.ts → VX-CoEuBNDK.d.ts} +0 -0
- /package/dist/{WX-0GuMjPNZ.d.ts → WX-DMvw__jH.d.ts} +0 -0
- /package/dist/{XX-CF2NANsy.d.ts → XX-DOA-10JW.d.ts} +0 -0
- /package/dist/{YX-B51BbNSg.d.ts → YX-F34sJ7Ik.d.ts} +0 -0
- /package/dist/{ZX-BMJS1iAv.d.ts → ZX-CDQOfsHh.d.ts} +0 -0
- /package/dist/{certificate-aooIRf9A.js → certificate-BDECQL9C.js} +0 -0
- /package/dist/{classification-codes-BKxV-rO9.d.ts → classification-codes-B1D5xbq5.d.ts} +0 -0
- /package/dist/{country-code-CQuaiQm2.d.ts → country-code-D42kAyNH.d.ts} +0 -0
- /package/dist/{currencies-BYJK-m6v.d.ts → currencies-CDveO_yz.d.ts} +0 -0
- /package/dist/{document-D6VKMAtx.js → document-BSuYbfXR.js} +0 -0
- /package/dist/{e-invoice-CmbLQkHw.d.ts → e-invoice-BxNC6V_j.d.ts} +0 -0
- /package/dist/{getBaseUrl-R3IdgCu3.js → getBaseUrl-BYkBwhQP.js} +0 -0
- /package/dist/{index-0-EvC6Nv.d.ts → index-FTgB2nM6.d.ts} +0 -0
- /package/dist/{payment-modes-BOTSRC_X.d.ts → payment-modes-NpE3OcCV.d.ts} +0 -0
- /package/dist/{signatures-W-_brwdb.d.ts → signatures-DOKNMiZI.d.ts} +0 -0
- /package/dist/{state-codes-oeFKlwXZ.d.ts → state-codes-VOFWhHA0.d.ts} +0 -0
- /package/dist/{tax-types-CsQ76JMf.d.ts → tax-types-ieqw5Ze7.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ClassificationCode } from "./classification-codes-
|
|
2
|
-
import { CurrencyCode } from "./currencies-
|
|
3
|
-
import { EInvoiceTypeCode } from "./e-invoice-
|
|
4
|
-
import { MSICCode } from "./msic-codes-
|
|
5
|
-
import { IssuerDigitalSignature } from "./signatures-
|
|
6
|
-
import { TaxTypeCode } from "./tax-types-
|
|
1
|
+
import { ClassificationCode } from "./classification-codes-B1D5xbq5.js";
|
|
2
|
+
import { CurrencyCode } from "./currencies-CDveO_yz.js";
|
|
3
|
+
import { EInvoiceTypeCode } from "./e-invoice-BxNC6V_j.js";
|
|
4
|
+
import { MSICCode } from "./msic-codes-CiPeemFK.js";
|
|
5
|
+
import { IssuerDigitalSignature } from "./signatures-DOKNMiZI.js";
|
|
6
|
+
import { TaxTypeCode } from "./tax-types-ieqw5Ze7.js";
|
|
7
7
|
|
|
8
8
|
//#region src/types/documents.d.ts
|
|
9
9
|
type RegistrationType = 'BRN' | 'NRIC' | 'PASSPORT' | 'ARMY';
|
|
@@ -853,5 +853,42 @@ interface CompleteInvoice {
|
|
|
853
853
|
/** Array of signed invoice submissions */
|
|
854
854
|
Invoice: SignedInvoiceSubmission[];
|
|
855
855
|
}
|
|
856
|
+
interface DocumentTypeVersion {
|
|
857
|
+
id: number;
|
|
858
|
+
name: string;
|
|
859
|
+
description: string;
|
|
860
|
+
activeFrom: string;
|
|
861
|
+
activeTo: string;
|
|
862
|
+
versionNumber: number;
|
|
863
|
+
status: 'draft' | 'published' | 'deactivated';
|
|
864
|
+
}
|
|
865
|
+
interface WorkflowParameter {
|
|
866
|
+
id: number;
|
|
867
|
+
parameter: string;
|
|
868
|
+
value: number;
|
|
869
|
+
activeFrom: string;
|
|
870
|
+
activeTo: string;
|
|
871
|
+
}
|
|
872
|
+
interface DocumentTypeResponse {
|
|
873
|
+
id: number;
|
|
874
|
+
invoiceTypeCode: EInvoiceTypeCode;
|
|
875
|
+
description: string;
|
|
876
|
+
activeFrom: string;
|
|
877
|
+
activeTo: string;
|
|
878
|
+
documentTypeVersions: DocumentTypeVersion[];
|
|
879
|
+
workflowParameters: WorkflowParameter[];
|
|
880
|
+
}
|
|
881
|
+
interface DocumentTypesResponse {
|
|
882
|
+
result: Omit<DocumentTypeResponse, 'workflowParameters'>[];
|
|
883
|
+
}
|
|
884
|
+
interface DocumentTypeVersionResponse {
|
|
885
|
+
invoiceTypeCode: EInvoiceTypeCode;
|
|
886
|
+
name: string;
|
|
887
|
+
description: string;
|
|
888
|
+
versionNumber: number;
|
|
889
|
+
status: 'published' | 'deactivated';
|
|
890
|
+
activeFrom: string;
|
|
891
|
+
activeTo: string;
|
|
892
|
+
}
|
|
856
893
|
//#endregion
|
|
857
|
-
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument };
|
|
894
|
+
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
|
|
@@ -853,6 +853,43 @@ interface CompleteInvoice {
|
|
|
853
853
|
/** Array of signed invoice submissions */
|
|
854
854
|
Invoice: SignedInvoiceSubmission[];
|
|
855
855
|
}
|
|
856
|
+
interface DocumentTypeVersion {
|
|
857
|
+
id: number;
|
|
858
|
+
name: string;
|
|
859
|
+
description: string;
|
|
860
|
+
activeFrom: string;
|
|
861
|
+
activeTo: string;
|
|
862
|
+
versionNumber: number;
|
|
863
|
+
status: 'draft' | 'published' | 'deactivated';
|
|
864
|
+
}
|
|
865
|
+
interface WorkflowParameter {
|
|
866
|
+
id: number;
|
|
867
|
+
parameter: string;
|
|
868
|
+
value: number;
|
|
869
|
+
activeFrom: string;
|
|
870
|
+
activeTo: string;
|
|
871
|
+
}
|
|
872
|
+
interface DocumentTypeResponse {
|
|
873
|
+
id: number;
|
|
874
|
+
invoiceTypeCode: EInvoiceTypeCode;
|
|
875
|
+
description: string;
|
|
876
|
+
activeFrom: string;
|
|
877
|
+
activeTo: string;
|
|
878
|
+
documentTypeVersions: DocumentTypeVersion[];
|
|
879
|
+
workflowParameters: WorkflowParameter[];
|
|
880
|
+
}
|
|
881
|
+
interface DocumentTypesResponse {
|
|
882
|
+
result: Omit<DocumentTypeResponse, 'workflowParameters'>[];
|
|
883
|
+
}
|
|
884
|
+
interface DocumentTypeVersionResponse {
|
|
885
|
+
invoiceTypeCode: EInvoiceTypeCode;
|
|
886
|
+
name: string;
|
|
887
|
+
description: string;
|
|
888
|
+
versionNumber: number;
|
|
889
|
+
status: 'published' | 'deactivated';
|
|
890
|
+
activeFrom: string;
|
|
891
|
+
activeTo: string;
|
|
892
|
+
}
|
|
856
893
|
//#endregion
|
|
857
|
-
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument };
|
|
858
|
-
//# sourceMappingURL=documents-
|
|
894
|
+
export { Address, Buyer, CompleteInvoice, DocumentStatus, DocumentSummary, DocumentTypeResponse, DocumentTypeVersion, DocumentTypeVersionResponse, DocumentTypesResponse, DocumentValidationResult, DocumentValidationStepResult, FinalDocumentData, GetSubmissionResponse, InvoiceLineItem, InvoiceSubmission, InvoiceV1_1, LegalMonetaryTotal, RegistrationType, ResponseDocument, SignedInfoObject, SignedInvoiceSubmission, SignedPropertiesData, SignedPropertiesObject, SigningCredentials, StandardError, SubmissionResponse, SubmissionStatus, Supplier, TaxCategory, TaxSubtotal, TaxTotal, UBLDocument, WorkflowParameter };
|
|
895
|
+
//# sourceMappingURL=documents-BqM9qOnB.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBaseUrl-
|
|
1
|
+
{"version":3,"file":"getBaseUrl-D2iJdUGL.cjs","names":["environment: 'sandbox' | 'production'"],"sources":["../src/utils/getBaseUrl.ts"],"sourcesContent":["export const getBaseUrl = (environment: 'sandbox' | 'production'): string => {\n return environment === 'sandbox'\n ? 'https://preprod-api.myinvois.hasil.gov.my'\n : 'https://api.myinvois.hasil.gov.my'\n}\n"],"mappings":";;AAAA,MAAa,aAAa,CAACA,gBAAkD;AAC3E,QAAO,gBAAgB,YACnB,8CACA;AACL"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
1
|
+
const require_documentManagement = require('./documentManagement-DQ7JEcBq.cjs');
|
|
2
|
+
require('./document-vDphtJTv.cjs');
|
|
3
|
+
const require_documentSubmission = require('./documentSubmission-D5TC0MPC.cjs');
|
|
4
|
+
const require_documentTypeManagement = require('./documentTypeManagement-DXRLfTsW.cjs');
|
|
5
|
+
const require_notificationManagement = require('./notificationManagement-C_qrFwWL.cjs');
|
|
6
|
+
const require_platformLogin = require('./platformLogin-CPiPiVUh.cjs');
|
|
7
|
+
const require_taxpayerValidation = require('./taxpayerValidation-DdeXCvPT.cjs');
|
|
8
|
+
const require_certificate = require('./certificate-CxsfE91s.cjs');
|
|
9
|
+
const require_getBaseUrl = require('./getBaseUrl-D2iJdUGL.cjs');
|
|
5
10
|
|
|
6
11
|
//#region src/index.ts
|
|
7
12
|
var MyInvoisClient = class {
|
|
@@ -63,20 +68,36 @@ var MyInvoisClient = class {
|
|
|
63
68
|
/**
|
|
64
69
|
* Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)
|
|
65
70
|
*
|
|
71
|
+
* This method verifies if a given Tax Identification Number (TIN) is valid by checking it against
|
|
72
|
+
* the provided identification type and value through the MyInvois platform's validation service.
|
|
73
|
+
*
|
|
66
74
|
* @param tin - The TIN to validate
|
|
67
|
-
* @param idType - The type of ID to validate against
|
|
75
|
+
* @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')
|
|
68
76
|
* @param idValue - The value of the ID to validate against
|
|
69
|
-
* @returns true if the TIN is valid, false otherwise
|
|
77
|
+
* @returns Promise resolving to true if the TIN is valid, false otherwise
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Validate TIN against NRIC
|
|
82
|
+
* const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');
|
|
83
|
+
* if (isValid) {
|
|
84
|
+
* console.log('TIN is valid');
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* // Validate TIN against Business Registration Number
|
|
88
|
+
* const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* - Returns false if validation fails due to network errors or invalid credentials
|
|
93
|
+
* - Debug mode provides error logging for troubleshooting validation failures
|
|
94
|
+
* - This is a non-blocking validation that won't throw exceptions on failure
|
|
70
95
|
*/
|
|
71
96
|
async verifyTin(tin, idType, idValue) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} catch (error) {
|
|
77
|
-
if (this.debug) console.error(error);
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
97
|
+
return require_taxpayerValidation.verifyTin({
|
|
98
|
+
fetch: this.fetch.bind(this),
|
|
99
|
+
debug: this.debug
|
|
100
|
+
}, tin, idType, idValue);
|
|
80
101
|
}
|
|
81
102
|
/**
|
|
82
103
|
* Submits one or more e-invoice documents to the MyInvois platform for processing.
|
|
@@ -112,104 +133,52 @@ var MyInvoisClient = class {
|
|
|
112
133
|
* - Returns HTTP 202 for successful submissions that require processing
|
|
113
134
|
*/
|
|
114
135
|
async submitDocument(documents) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
console.log("📊 Number of invoices:", completeDocument.Invoice.length);
|
|
121
|
-
}
|
|
122
|
-
const documentJson = JSON.stringify(completeDocument);
|
|
123
|
-
if (this.debug) console.log(`📏 Document JSON size: ${documentJson.length} bytes`);
|
|
124
|
-
const crypto = await import("crypto");
|
|
125
|
-
const documentHash = crypto.createHash("sha256").update(documentJson, "utf8").digest("hex");
|
|
126
|
-
const documentBase64 = Buffer.from(documentJson, "utf8").toString("base64");
|
|
127
|
-
if (this.debug) {
|
|
128
|
-
console.log(`🔒 Document hash: ${documentHash.substring(0, 16)}...`);
|
|
129
|
-
console.log(`📦 Base64 size: ${documentBase64.length} bytes`);
|
|
130
|
-
}
|
|
131
|
-
const submissionPayload = { documents: documents.map((doc) => ({
|
|
132
|
-
format: "JSON",
|
|
133
|
-
document: documentBase64,
|
|
134
|
-
documentHash,
|
|
135
|
-
codeNumber: doc.eInvoiceCodeOrNumber
|
|
136
|
-
})) };
|
|
137
|
-
if (this.debug) {
|
|
138
|
-
console.log("🚀 Submission payload structure:");
|
|
139
|
-
console.log("- Format: JSON");
|
|
140
|
-
console.log("- Documents count:", submissionPayload.documents.length);
|
|
141
|
-
console.log("- Total payload size:", JSON.stringify(submissionPayload).length, "bytes");
|
|
142
|
-
const payloadSize = JSON.stringify(submissionPayload).length;
|
|
143
|
-
if (payloadSize > 5 * 1024 * 1024) console.warn("⚠️ WARNING: Payload size exceeds 5MB limit");
|
|
144
|
-
if (documents.length > 100) console.warn("⚠️ WARNING: Document count exceeds 100 document limit");
|
|
145
|
-
if (documentJson.length > 300 * 1024) console.warn("⚠️ WARNING: Document size exceeds 300KB limit");
|
|
146
|
-
}
|
|
147
|
-
const response = await this.fetch("/api/v1.0/documentsubmissions", {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: { "Content-Type": "application/json" },
|
|
150
|
-
body: JSON.stringify(submissionPayload)
|
|
151
|
-
});
|
|
152
|
-
if (this.debug) console.log(`📡 API Response status: ${response.status}`);
|
|
153
|
-
const data = await response.json();
|
|
154
|
-
if (this.debug) if (response.status !== 202) {
|
|
155
|
-
console.error("❌ Submission failed with status:", response.status);
|
|
156
|
-
console.error("❌ Response data:", data);
|
|
157
|
-
} else {
|
|
158
|
-
console.log("✅ Submission successful!");
|
|
159
|
-
console.log(`📋 Submission UID: ${data.submissionUid}`);
|
|
160
|
-
console.log(`✅ Accepted documents: ${data.acceptedDocuments?.length || 0}`);
|
|
161
|
-
console.log(`❌ Rejected documents: ${data.rejectedDocuments?.length || 0}`);
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
data,
|
|
165
|
-
status: response.status
|
|
166
|
-
};
|
|
136
|
+
return require_documentSubmission.submitDocument({
|
|
137
|
+
fetch: this.fetch.bind(this),
|
|
138
|
+
debug: this.debug,
|
|
139
|
+
signingCredentials: this.signingCredentials
|
|
140
|
+
}, documents);
|
|
167
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Polls the MyInvois platform to get the current status of a document submission.
|
|
144
|
+
*
|
|
145
|
+
* This method continuously checks the submission status until it receives a final result
|
|
146
|
+
* (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the
|
|
147
|
+
* asynchronous nature of document processing on the MyInvois platform.
|
|
148
|
+
*
|
|
149
|
+
* @param submissionUid - The unique identifier of the submission to check
|
|
150
|
+
* @param pollInterval - Time in milliseconds between status checks (default: 1000ms)
|
|
151
|
+
* @param maxRetries - Maximum number of retry attempts (default: 10)
|
|
152
|
+
* @returns Promise resolving to submission status object with document summary and any errors
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* // Check submission status with default polling
|
|
157
|
+
* const result = await client.getSubmissionStatus('submission-uid-123');
|
|
158
|
+
* if (result.status === 'Valid') {
|
|
159
|
+
* console.log('All documents processed successfully');
|
|
160
|
+
* console.log('Document summaries:', result.documentSummary);
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
* // Custom polling interval and retry count
|
|
164
|
+
* const result = await client.getSubmissionStatus(
|
|
165
|
+
* 'submission-uid-123',
|
|
166
|
+
* 2000, // Poll every 2 seconds
|
|
167
|
+
* 20 // Try up to 20 times
|
|
168
|
+
* );
|
|
169
|
+
* ```
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* - Automatically retries on network errors until maxRetries is reached
|
|
173
|
+
* - Returns 'Invalid' status with timeout error if submission processing takes too long
|
|
174
|
+
* - Debug mode provides detailed logging of polling attempts and responses
|
|
175
|
+
* - Use reasonable poll intervals to avoid overwhelming the API
|
|
176
|
+
*/
|
|
168
177
|
async getSubmissionStatus(submissionUid, pollInterval = 1e3, maxRetries = 10) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
console.log("Submission:", data);
|
|
174
|
-
if (data.error) console.log("Submission error details:", data.error.details);
|
|
175
|
-
}
|
|
176
|
-
if (data.overallStatus === "Valid") return {
|
|
177
|
-
status: data.overallStatus,
|
|
178
|
-
documentSummary: data.documentSummary
|
|
179
|
-
};
|
|
180
|
-
if (data.overallStatus === "Invalid") return {
|
|
181
|
-
status: "Invalid",
|
|
182
|
-
documentSummary: data.documentSummary
|
|
183
|
-
};
|
|
184
|
-
if (maxRetries > 0) {
|
|
185
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
186
|
-
return await this.getSubmissionStatus(submissionUid, pollInterval, maxRetries - 1);
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
status: "Invalid",
|
|
190
|
-
error: {
|
|
191
|
-
code: "Timeout",
|
|
192
|
-
message: "Submission timed out",
|
|
193
|
-
target: "submission",
|
|
194
|
-
details: []
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (maxRetries > 0) {
|
|
199
|
-
if (this.debug) console.log("Request error, retrying...", error);
|
|
200
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
201
|
-
return await this.getSubmissionStatus(submissionUid, pollInterval, maxRetries - 1);
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
status: "Invalid",
|
|
205
|
-
error: {
|
|
206
|
-
code: "Timeout",
|
|
207
|
-
message: "Submission timed out after request errors",
|
|
208
|
-
target: "submission",
|
|
209
|
-
details: []
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
}
|
|
178
|
+
return require_documentSubmission.getSubmissionStatus({
|
|
179
|
+
fetch: this.fetch.bind(this),
|
|
180
|
+
debug: this.debug
|
|
181
|
+
}, submissionUid, pollInterval, maxRetries);
|
|
213
182
|
}
|
|
214
183
|
/**
|
|
215
184
|
* Retrieves a document by its unique identifier with the raw document content.
|
|
@@ -226,9 +195,7 @@ var MyInvoisClient = class {
|
|
|
226
195
|
* ```
|
|
227
196
|
*/
|
|
228
197
|
async getDocument(documentUid) {
|
|
229
|
-
|
|
230
|
-
const data = await response.json();
|
|
231
|
-
return data;
|
|
198
|
+
return require_documentManagement.getDocument({ fetch: this.fetch.bind(this) }, documentUid);
|
|
232
199
|
}
|
|
233
200
|
/**
|
|
234
201
|
* Retrieves detailed information about a document including validation results.
|
|
@@ -245,9 +212,7 @@ var MyInvoisClient = class {
|
|
|
245
212
|
* ```
|
|
246
213
|
*/
|
|
247
214
|
async getDocumentDetails(documentUid) {
|
|
248
|
-
|
|
249
|
-
const data = await response.json();
|
|
250
|
-
return data;
|
|
215
|
+
return require_documentManagement.getDocumentDetails({ fetch: this.fetch.bind(this) }, documentUid);
|
|
251
216
|
}
|
|
252
217
|
/**
|
|
253
218
|
* Searches for documents based on various filter criteria.
|
|
@@ -286,21 +251,159 @@ var MyInvoisClient = class {
|
|
|
286
251
|
* ```
|
|
287
252
|
*/
|
|
288
253
|
async searchDocuments({ uuid, submissionDateFrom, submissionDateTo, pageSize, pageNo, issueDateFrom, issueDateTo, invoiceDirection, status, documentType, searchQuery }) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
254
|
+
return require_documentManagement.searchDocuments({ fetch: this.fetch.bind(this) }, {
|
|
255
|
+
uuid,
|
|
256
|
+
submissionDateFrom,
|
|
257
|
+
submissionDateTo,
|
|
258
|
+
pageSize,
|
|
259
|
+
pageNo,
|
|
260
|
+
issueDateFrom,
|
|
261
|
+
issueDateTo,
|
|
262
|
+
invoiceDirection,
|
|
263
|
+
status,
|
|
264
|
+
documentType,
|
|
265
|
+
searchQuery
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves notifications from the MyInvois platform based on specified search criteria.
|
|
270
|
+
*
|
|
271
|
+
* This method allows you to search for system notifications, alerts, and messages
|
|
272
|
+
* sent by the MyInvois platform regarding document processing, system updates,
|
|
273
|
+
* or account-related information.
|
|
274
|
+
*
|
|
275
|
+
* @param params - Search parameters object for filtering notifications
|
|
276
|
+
* @param params.dateFrom - Optional start date for notification date range (ISO date string)
|
|
277
|
+
* @param params.dateTo - Optional end date for notification date range (ISO date string)
|
|
278
|
+
* @param params.type - Optional notification type filter
|
|
279
|
+
* @param params.language - Optional language preference for notifications
|
|
280
|
+
* @param params.status - Optional notification status filter
|
|
281
|
+
* @param params.pageNo - Optional page number for pagination (0-based)
|
|
282
|
+
* @param params.pageSize - Optional number of results per page
|
|
283
|
+
* @returns Promise resolving to notification response object or standard error
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* // Get all notifications from the last 7 days
|
|
288
|
+
* const notifications = await client.getNotifications({
|
|
289
|
+
* dateFrom: '2024-01-01',
|
|
290
|
+
* dateTo: '2024-01-07',
|
|
291
|
+
* pageSize: 20
|
|
292
|
+
* });
|
|
293
|
+
*
|
|
294
|
+
* // Get unread notifications only
|
|
295
|
+
* const unreadNotifications = await client.getNotifications({
|
|
296
|
+
* status: 0, // Assuming 0 = unread
|
|
297
|
+
* language: 'en'
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Paginated notification retrieval
|
|
301
|
+
* const firstPage = await client.getNotifications({
|
|
302
|
+
* dateFrom: '2024-01-01',
|
|
303
|
+
* pageNo: 0,
|
|
304
|
+
* pageSize: 10
|
|
305
|
+
* });
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @remarks
|
|
309
|
+
* - All parameters are optional, allowing flexible filtering
|
|
310
|
+
* - Returns paginated results when pageNo and pageSize are specified
|
|
311
|
+
* - Date parameters should be in ISO format (YYYY-MM-DD)
|
|
312
|
+
* - May return StandardError object if the request fails
|
|
313
|
+
*/
|
|
314
|
+
async getNotifications({ dateFrom, dateTo, type, language, status, pageNo, pageSize }) {
|
|
315
|
+
return require_notificationManagement.getNotifications({ fetch: this.fetch.bind(this) }, {
|
|
316
|
+
dateFrom,
|
|
317
|
+
dateTo,
|
|
318
|
+
type,
|
|
319
|
+
language,
|
|
320
|
+
status,
|
|
321
|
+
pageNo,
|
|
322
|
+
pageSize
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async getDocumentTypes() {
|
|
326
|
+
return require_documentTypeManagement.getDocumentTypes({ fetch: this.fetch.bind(this) });
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Retrieves detailed information about a specific document type from the MyInvois platform.
|
|
330
|
+
*
|
|
331
|
+
* This method fetches metadata and configuration details for a specific document type,
|
|
332
|
+
* including supported versions, validation rules, and structural requirements.
|
|
333
|
+
* Useful for understanding document format requirements before submission.
|
|
334
|
+
*
|
|
335
|
+
* @param id - The unique identifier of the document type to retrieve
|
|
336
|
+
* @returns Promise resolving to document type response object or standard error
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```typescript
|
|
340
|
+
* // Get details for e-invoice document type
|
|
341
|
+
* const invoiceType = await client.getDocumentType(1);
|
|
342
|
+
* if ('id' in invoiceType) {
|
|
343
|
+
* console.log('Document type name:', invoiceType.name);
|
|
344
|
+
* console.log('Available versions:', invoiceType.versionNumber);
|
|
345
|
+
* console.log('Description:', invoiceType.description);
|
|
346
|
+
* }
|
|
347
|
+
*
|
|
348
|
+
* // Handle potential errors
|
|
349
|
+
* const documentType = await client.getDocumentType(999);
|
|
350
|
+
* if ('error' in documentType) {
|
|
351
|
+
* console.error('Failed to retrieve document type:', documentType.error.message);
|
|
352
|
+
* }
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* @remarks
|
|
356
|
+
* - Returns StandardError object if the document type ID doesn't exist
|
|
357
|
+
* - Document type information includes validation schemas and business rules
|
|
358
|
+
* - Use this method to discover supported document formats and versions
|
|
359
|
+
* - Essential for understanding submission requirements for different document types
|
|
360
|
+
*/
|
|
361
|
+
async getDocumentType(id) {
|
|
362
|
+
return require_documentTypeManagement.getDocumentType({ fetch: this.fetch.bind(this) }, id);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves detailed information about a specific version of a document type.
|
|
366
|
+
*
|
|
367
|
+
* This method fetches version-specific metadata, schema definitions, and validation rules
|
|
368
|
+
* for a particular document type version. Essential for understanding the exact format
|
|
369
|
+
* and requirements for document submission in a specific version.
|
|
370
|
+
*
|
|
371
|
+
* @param id - The unique identifier of the document type
|
|
372
|
+
* @param versionId - The unique identifier of the specific version to retrieve
|
|
373
|
+
* @returns Promise resolving to document type version response object or standard error
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* // Get specific version details for e-invoice
|
|
378
|
+
* const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);
|
|
379
|
+
* if ('id' in invoiceV1_1) {
|
|
380
|
+
* console.log('Version number:', invoiceV1_1.versionNumber);
|
|
381
|
+
* console.log('Schema:', invoiceV1_1.jsonSchema);
|
|
382
|
+
* console.log('Status:', invoiceV1_1.status);
|
|
383
|
+
* }
|
|
384
|
+
*
|
|
385
|
+
* // Compare different versions
|
|
386
|
+
* const [v1_0, v1_1] = await Promise.all([
|
|
387
|
+
* client.getDocumentTypeVersion(1, 0),
|
|
388
|
+
* client.getDocumentTypeVersion(1, 1)
|
|
389
|
+
* ]);
|
|
390
|
+
*
|
|
391
|
+
* // Handle version not found
|
|
392
|
+
* const result = await client.getDocumentTypeVersion(1, 999);
|
|
393
|
+
* if ('error' in result) {
|
|
394
|
+
* console.error('Version not found:', result.error.message);
|
|
395
|
+
* }
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* @remarks
|
|
399
|
+
* - Returns StandardError object if document type ID or version ID doesn't exist
|
|
400
|
+
* - Version information includes JSON schema for validation
|
|
401
|
+
* - Different versions may have different validation rules and field requirements
|
|
402
|
+
* - Use this to ensure your documents conform to the specific version requirements
|
|
403
|
+
* - Version status indicates if the version is active, deprecated, or under development
|
|
404
|
+
*/
|
|
405
|
+
async getDocumentTypeVersion(id, versionId) {
|
|
406
|
+
return require_documentTypeManagement.getDocumentTypeVersion({ fetch: this.fetch.bind(this) }, id, versionId);
|
|
304
407
|
}
|
|
305
408
|
};
|
|
306
409
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: RegistrationType","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string"],"sources":["../src/index.ts"],"sourcesContent":["import { EInvoiceTypeCode } from './types'\nimport { platformLogin } from './api/platform/platformLogin'\nimport type {\n DocumentStatus,\n InvoiceV1_1,\n RegistrationType,\n SigningCredentials,\n} from './types/documents'\nimport { getBaseUrl } from './utils/getBaseUrl'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\n\nimport type {\n DocumentSummary,\n DocumentValidationResult,\n DocumentValidationStepResult,\n GetSubmissionResponse,\n SubmissionResponse,\n SubmissionStatus,\n} from './types/documents'\nimport { generateCompleteDocument } from './utils/document'\n\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against\n * @param idValue - The value of the ID to validate against\n * @returns true if the TIN is valid, false otherwise\n */\n async verifyTin(\n tin: string,\n idType: RegistrationType,\n idValue: string,\n ): Promise<boolean> {\n try {\n const response = await this.fetch(\n `/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`,\n {\n method: 'GET',\n },\n )\n\n if (response.status === 200) {\n return true\n }\n\n return false\n } catch (error) {\n if (this.debug) {\n console.error(error)\n }\n return false\n }\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n if (this.debug) {\n console.log(`📦 Preparing to submit ${documents.length} document(s)...`)\n }\n\n // Generate the complete signed document structure first\n const completeDocument = generateCompleteDocument(\n documents,\n this.signingCredentials,\n )\n\n if (this.debug) {\n console.log('✅ Documents signed successfully')\n console.log('📄 Document structure keys:', Object.keys(completeDocument))\n console.log('📊 Number of invoices:', completeDocument.Invoice.length)\n }\n\n // Convert the complete document to JSON string\n const documentJson = JSON.stringify(completeDocument)\n\n if (this.debug) {\n console.log(`📏 Document JSON size: ${documentJson.length} bytes`)\n }\n\n // Generate SHA256 hash of the JSON document\n const crypto = await import('crypto')\n const documentHash = crypto\n .createHash('sha256')\n .update(documentJson, 'utf8')\n .digest('hex')\n\n // Base64 encode the JSON document\n const documentBase64 = Buffer.from(documentJson, 'utf8').toString('base64')\n\n if (this.debug) {\n console.log(`🔒 Document hash: ${documentHash.substring(0, 16)}...`)\n console.log(`📦 Base64 size: ${documentBase64.length} bytes`)\n }\n\n // Build the submission payload according to MyInvois API format\n const submissionPayload = {\n documents: documents.map(doc => ({\n format: 'JSON', // We're submitting JSON format\n document: documentBase64, // Base64 encoded complete document\n documentHash: documentHash, // SHA256 hash of the JSON\n codeNumber: doc.eInvoiceCodeOrNumber, // Document reference number\n })),\n }\n\n if (this.debug) {\n console.log('🚀 Submission payload structure:')\n console.log('- Format: JSON')\n console.log('- Documents count:', submissionPayload.documents.length)\n console.log(\n '- Total payload size:',\n JSON.stringify(submissionPayload).length,\n 'bytes',\n )\n\n // Validate submission constraints\n const payloadSize = JSON.stringify(submissionPayload).length\n if (payloadSize > 5 * 1024 * 1024) {\n // 5MB\n console.warn('⚠️ WARNING: Payload size exceeds 5MB limit')\n }\n\n if (documents.length > 100) {\n console.warn('⚠️ WARNING: Document count exceeds 100 document limit')\n }\n\n if (documentJson.length > 300 * 1024) {\n // 300KB per document\n console.warn('⚠️ WARNING: Document size exceeds 300KB limit')\n }\n }\n\n // Submit to MyInvois API with proper headers\n const response = await this.fetch('/api/v1.0/documentsubmissions', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(submissionPayload),\n })\n\n if (this.debug) {\n console.log(`📡 API Response status: ${response.status}`)\n }\n\n const data = (await response.json()) as SubmissionResponse\n\n if (this.debug) {\n if (response.status !== 202) {\n console.error('❌ Submission failed with status:', response.status)\n console.error('❌ Response data:', data)\n } else {\n console.log('✅ Submission successful!')\n console.log(`📋 Submission UID: ${data.submissionUid}`)\n console.log(\n `✅ Accepted documents: ${data.acceptedDocuments?.length || 0}`,\n )\n console.log(\n `❌ Rejected documents: ${data.rejectedDocuments?.length || 0}`,\n )\n }\n }\n\n return {\n data,\n status: response.status,\n }\n }\n\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n try {\n const response = await this.fetch(\n `/api/v1.0/documentsubmissions/${submissionUid}`,\n )\n\n const data = (await response.json()) as GetSubmissionResponse\n\n if (this.debug) {\n console.log('Submission:', data)\n if (data.error) {\n console.log('Submission error details:', data.error.details)\n }\n }\n\n // If we have a successful response and status is completed, return success\n if (data.overallStatus === 'Valid') {\n return {\n status: data.overallStatus,\n documentSummary: data.documentSummary,\n }\n }\n if (data.overallStatus === 'Invalid') {\n return {\n status: 'Invalid',\n documentSummary: data.documentSummary,\n }\n }\n\n // If we have retries left, continue polling for any non-completed status or errors\n if (maxRetries > 0) {\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out',\n target: 'submission',\n details: [],\n },\n }\n } catch (error) {\n // Handle any request errors by retrying if we have retries left\n if (maxRetries > 0) {\n if (this.debug) {\n console.log('Request error, retrying...', error)\n }\n await new Promise(resolve => setTimeout(resolve, pollInterval))\n return await this.getSubmissionStatus(\n submissionUid,\n pollInterval,\n maxRetries - 1,\n )\n }\n\n // No retries left - return timeout\n return {\n status: 'Invalid',\n error: {\n code: 'Timeout',\n message: 'Submission timed out after request errors',\n target: 'submission',\n details: [],\n },\n }\n }\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n const response = await this.fetch(`/api/v1.0/documents/${documentUid}/raw`)\n\n const data = await response.json()\n\n return data as DocumentSummary & { document: string }\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n const response = await this.fetch(\n `/api/v1.0/documents/${documentUid}/details`,\n )\n\n const data = (await response.json()) as DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n\n return data\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n const queryParams = new URLSearchParams()\n\n if (uuid) queryParams.set('uuid', uuid)\n if (submissionDateFrom)\n queryParams.set('submissionDateFrom', submissionDateFrom)\n if (submissionDateTo) queryParams.set('submissionDateTo', submissionDateTo)\n if (pageSize) queryParams.set('pageSize', pageSize.toString())\n if (pageNo) queryParams.set('pageNo', pageNo.toString())\n if (issueDateFrom) queryParams.set('issueDateFrom', issueDateFrom)\n if (issueDateTo) queryParams.set('issueDateTo', issueDateTo)\n if (invoiceDirection) queryParams.set('invoiceDirection', invoiceDirection)\n if (status) queryParams.set('status', status)\n if (documentType) queryParams.set('documentType', documentType)\n if (searchQuery) queryParams.set('searchQuery', searchQuery)\n\n const response = await this.fetch(\n `/api/v1.0/documents/search?${queryParams.toString()}`,\n )\n\n const data = (await response.json()) as DocumentSummary[]\n\n return data\n }\n}\n\nexport type * from './types/index.d.ts'\n"],"mappings":";;;;;;AAqBA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,8BAAW,YAAY;AACtC,OAAK,aAAa;AAClB,OAAK,QAAS,SAAS,QAAQ,IAAI,mBAAmB,SAAU,OAAO;EAGvE,MAAM,EAAE,YAAY,cAAc,GAAG,2CAAuB,eAAe;AAE3E,OAAK,qBAAqB;GACxB;GACA;GACA;GACA;EACD;CACF;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,oCAAc;GACxC,UAAU,KAAK;GACf,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,OAAO,KAAK;EACb,EAAC;AAEF,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,cAAc;CACtC;CAED,MAAc,WAAW;AACvB,OACG,KAAK,mBACN,KAAK,kCAAkB,IAAI,UAC3B,MAAM,KAAK,gBAAgB,SAAS,CAAC,EACrC;AACA,OAAI,KAAK,OAAO;AACd,YAAQ,IAAI,gBAAgB;AAC5B,YAAQ,IAAI,mBAAm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,UACpC;EAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAOnC,SAAO;CACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCD,MAAM,gBAAgB,EACpB,MACA,oBACA,kBACA,UACA,QACA,eACA,aACA,kBACA,QACA,cACA,aAaD,EAA8B;EAC7B,MAAM,cAAc,IAAI;AAExB,MAAI,KAAM,aAAY,IAAI,QAAQ,KAAK;AACvC,MAAI,mBACF,aAAY,IAAI,sBAAsB,mBAAmB;AAC3D,MAAI,iBAAkB,aAAY,IAAI,oBAAoB,iBAAiB;AAC3E,MAAI,SAAU,aAAY,IAAI,YAAY,SAAS,UAAU,CAAC;AAC9D,MAAI,OAAQ,aAAY,IAAI,UAAU,OAAO,UAAU,CAAC;AACxD,MAAI,cAAe,aAAY,IAAI,iBAAiB,cAAc;AAClE,MAAI,YAAa,aAAY,IAAI,eAAe,YAAY;AAC5D,MAAI,iBAAkB,aAAY,IAAI,oBAAoB,iBAAiB;AAC3E,MAAI,OAAQ,aAAY,IAAI,UAAU,OAAO;AAC7C,MAAI,aAAc,aAAY,IAAI,gBAAgB,aAAa;AAC/D,MAAI,YAAa,aAAY,IAAI,eAAe,YAAY;EAE5D,MAAM,WAAW,MAAM,KAAK,OACzB,6BAA6B,YAAY,UAAU,CAAC,EACtD;EAED,MAAM,OAAQ,MAAM,SAAS,MAAM;AAEnC,SAAO;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","certificatePem: string","privateKeyPem: string","onBehalfOf?: string","debug?: boolean","path: string","options: Parameters<typeof fetch>[1]","tin: string","idType: RegistrationType","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string","id: number","versionId: number"],"sources":["../src/index.ts"],"sourcesContent":["import {\n DocumentStatus,\n DocumentSummary,\n DocumentTypeResponse,\n DocumentTypesResponse,\n DocumentTypeVersionResponse,\n DocumentValidationResult,\n DocumentValidationStepResult,\n EInvoiceTypeCode,\n InvoiceV1_1,\n NotificationResponse,\n NotificationSearchParams,\n RegistrationType,\n SigningCredentials,\n StandardError,\n SubmissionResponse,\n SubmissionStatus,\n} from './types'\n\nimport * as DocumentManagementAPI from './api/documentManagement'\nimport * as DocumentSubmissionAPI from './api/documentSubmission'\nimport * as DocumentTypeManagementAPI from './api/documentTypeManagement'\nimport * as NotificationManagementAPI from './api/notificationManagement'\nimport { platformLogin } from './api/platformLogin'\nimport * as TaxpayerValidationAPI from './api/taxpayerValidation'\nimport { extractCertificateInfo, validateKeyPair } from './utils/certificate'\nimport { getBaseUrl } from './utils/getBaseUrl'\n\nexport type * from './types/index.d.ts'\nexport class MyInvoisClient {\n private readonly baseUrl: string\n private readonly clientId: string\n private readonly clientSecret: string\n private readonly onBehalfOf?: string\n private readonly signingCredentials: SigningCredentials\n private readonly debug: boolean\n private token = ''\n private tokenExpiration: Date | undefined = undefined\n\n constructor(\n clientId: string,\n clientSecret: string,\n environment: 'sandbox' | 'production',\n certificatePem: string,\n privateKeyPem: string,\n onBehalfOf?: string,\n debug?: boolean,\n ) {\n // Check if basic signing credentials are available\n if (!privateKeyPem || !certificatePem) {\n throw new Error(\n 'Missing required environment variables: PRIVATE_KEY and CERTIFICATE',\n )\n }\n\n // Validate that the key pair matches\n if (!validateKeyPair(certificatePem, privateKeyPem)) {\n throw new Error('Certificate and private key do not match')\n }\n\n this.clientId = clientId\n this.clientSecret = clientSecret\n this.baseUrl = getBaseUrl(environment)\n this.onBehalfOf = onBehalfOf\n this.debug = (debug ?? process.env.MYINVOIS_DEBUG === 'true') ? true : false\n\n // Extract certificate information\n const { issuerName, serialNumber } = extractCertificateInfo(certificatePem)\n\n this.signingCredentials = {\n privateKeyPem,\n certificatePem,\n issuerName,\n serialNumber,\n }\n }\n\n private async refreshToken() {\n const tokenResponse = await platformLogin({\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n baseUrl: this.baseUrl,\n onBehalfOf: this.onBehalfOf,\n debug: this.debug,\n })\n\n this.token = tokenResponse.token\n this.tokenExpiration = tokenResponse.tokenExpiration\n }\n\n private async getToken() {\n if (\n !this.tokenExpiration ||\n this.tokenExpiration < new Date() ||\n isNaN(this.tokenExpiration.getTime())\n ) {\n if (this.debug) {\n console.log('Token expired')\n console.log('Refreshing token')\n }\n await this.refreshToken()\n }\n\n return this.token\n }\n\n private async fetch(path: string, options: Parameters<typeof fetch>[1] = {}) {\n const token = await this.getToken()\n\n return fetch(`${this.baseUrl}${path}`, {\n ...options,\n headers: { ...options.headers, Authorization: `Bearer ${token}` },\n })\n }\n\n /**\n * Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)\n *\n * This method verifies if a given Tax Identification Number (TIN) is valid by checking it against\n * the provided identification type and value through the MyInvois platform's validation service.\n *\n * @param tin - The TIN to validate\n * @param idType - The type of ID to validate against ('NRIC', 'ARMY', 'PASSPORT', or 'BRN')\n * @param idValue - The value of the ID to validate against\n * @returns Promise resolving to true if the TIN is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Validate TIN against NRIC\n * const isValid = await client.verifyTin('C12345678901234', 'NRIC', '123456789012');\n * if (isValid) {\n * console.log('TIN is valid');\n * }\n *\n * // Validate TIN against Business Registration Number\n * const isValidBusiness = await client.verifyTin('C98765432109876', 'BRN', '123456-K');\n * ```\n *\n * @remarks\n * - Returns false if validation fails due to network errors or invalid credentials\n * - Debug mode provides error logging for troubleshooting validation failures\n * - This is a non-blocking validation that won't throw exceptions on failure\n */\n async verifyTin(\n tin: string,\n idType: RegistrationType,\n idValue: string,\n ): Promise<boolean> {\n return TaxpayerValidationAPI.verifyTin(\n { fetch: this.fetch.bind(this), debug: this.debug },\n tin,\n idType,\n idValue,\n )\n }\n\n /**\n * Submits one or more e-invoice documents to the MyInvois platform for processing.\n *\n * This method digitally signs each document using the provided certificate and private key,\n * generates document hashes, encodes them for submission, and sends them to the platform.\n * The method includes comprehensive validation warnings for document size and count limits.\n *\n * @param documents - Array of InvoiceV1_1 documents to be submitted\n * @returns Promise resolving to submission response containing the submission data and HTTP status\n * @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing\n * @throws {Error} If document signing, encoding, or API submission fails\n *\n * @example\n * ```typescript\n * // Submit a single invoice\n * const result = await client.submitDocument([invoiceData]);\n * console.log(result.data.submissionUid); // Track submission with this UID\n *\n * // Submit multiple invoices\n * const result = await client.submitDocument([invoice1, invoice2, invoice3]);\n * if (result.status === 202) {\n * console.log('Documents submitted successfully');\n * }\n * ```\n *\n * @remarks\n * - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing\n * - Each document is digitally signed with XML-DSIG before submission\n * - Documents are base64-encoded for transmission\n * - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document\n * - Debug mode provides detailed logging of payload sizes and validation warnings\n * - Returns HTTP 202 for successful submissions that require processing\n */\n async submitDocument(documents: InvoiceV1_1[]): Promise<{\n data: SubmissionResponse\n status: number\n }> {\n return DocumentSubmissionAPI.submitDocument(\n {\n fetch: this.fetch.bind(this),\n debug: this.debug,\n signingCredentials: this.signingCredentials,\n },\n documents,\n )\n }\n\n /**\n * Polls the MyInvois platform to get the current status of a document submission.\n *\n * This method continuously checks the submission status until it receives a final result\n * (Valid or Invalid) or reaches the maximum retry limit. It's designed to handle the\n * asynchronous nature of document processing on the MyInvois platform.\n *\n * @param submissionUid - The unique identifier of the submission to check\n * @param pollInterval - Time in milliseconds between status checks (default: 1000ms)\n * @param maxRetries - Maximum number of retry attempts (default: 10)\n * @returns Promise resolving to submission status object with document summary and any errors\n *\n * @example\n * ```typescript\n * // Check submission status with default polling\n * const result = await client.getSubmissionStatus('submission-uid-123');\n * if (result.status === 'Valid') {\n * console.log('All documents processed successfully');\n * console.log('Document summaries:', result.documentSummary);\n * }\n *\n * // Custom polling interval and retry count\n * const result = await client.getSubmissionStatus(\n * 'submission-uid-123',\n * 2000, // Poll every 2 seconds\n * 20 // Try up to 20 times\n * );\n * ```\n *\n * @remarks\n * - Automatically retries on network errors until maxRetries is reached\n * - Returns 'Invalid' status with timeout error if submission processing takes too long\n * - Debug mode provides detailed logging of polling attempts and responses\n * - Use reasonable poll intervals to avoid overwhelming the API\n */\n async getSubmissionStatus(\n submissionUid: string,\n pollInterval: number = 1000,\n maxRetries: number = 10,\n ): Promise<{\n status: SubmissionStatus\n documentSummary?: DocumentSummary[]\n error?: {\n code: string\n message: string | null\n target: string\n details: {\n code: string\n message: string\n target: string\n }[]\n }\n }> {\n return DocumentSubmissionAPI.getSubmissionStatus(\n { fetch: this.fetch.bind(this), debug: this.debug },\n submissionUid,\n pollInterval,\n maxRetries,\n )\n }\n\n /**\n * Retrieves a document by its unique identifier with the raw document content.\n *\n * @param documentUid - The unique identifier of the document to retrieve\n * @returns Promise resolving to document summary with raw document content as a string\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const document = await client.getDocument('doc-uuid-123');\n * console.log(document.document); // Raw XML/JSON content\n * console.log(document.uuid); // Document UUID\n * ```\n */\n async getDocument(\n documentUid: string,\n ): Promise<DocumentSummary & { document: string }> {\n return DocumentManagementAPI.getDocument(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Retrieves detailed information about a document including validation results.\n *\n * @param documentUid - The unique identifier of the document to get details for\n * @returns Promise resolving to document summary with detailed validation results\n * @throws {Error} If the document is not found or request fails\n *\n * @example\n * ```typescript\n * const details = await client.getDocumentDetails('doc-uuid-123');\n * console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'\n * console.log(details.validationResults.validationSteps); // Array of validation step results\n * ```\n */\n async getDocumentDetails(documentUid: string): Promise<\n DocumentSummary & {\n validationResults: {\n status: DocumentValidationResult\n validationSteps: DocumentValidationStepResult[]\n }\n }\n > {\n return DocumentManagementAPI.getDocumentDetails(\n { fetch: this.fetch.bind(this) },\n documentUid,\n )\n }\n\n /**\n * Searches for documents based on various filter criteria.\n *\n * @param params - Search parameters object\n * @param params.uuid - Optional specific document UUID to search for\n * @param params.submissionDateFrom - Required start date for submission date range (ISO date string)\n * @param params.submissionDateTo - Optional end date for submission date range (ISO date string)\n * @param params.pageSize - Optional number of results per page (default handled by API)\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.issueDateFrom - Optional start date for issue date range (ISO date string)\n * @param params.issueDateTo - Optional end date for issue date range (ISO date string)\n * @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')\n * @param params.status - Optional filter by document status\n * @param params.documentType - Optional filter by e-invoice type code\n * @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n * @returns Promise resolving to array of document summaries matching the search criteria\n * @throws {Error} If the search request fails\n *\n * @example\n * ```typescript\n * // Search for documents submitted in the last 30 days\n * const documents = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * submissionDateTo: '2024-01-31',\n * status: 'Valid',\n * pageSize: 10\n * });\n *\n * // Search by supplier name\n * const supplierDocs = await client.searchDocuments({\n * submissionDateFrom: '2024-01-01',\n * searchQuery: 'ACME Corp',\n * invoiceDirection: 'Received'\n * });\n * ```\n */\n async searchDocuments({\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n }: {\n uuid?: string\n submissionDateFrom: string\n submissionDateTo?: string\n pageSize?: number\n pageNo?: number\n issueDateFrom?: string\n issueDateTo?: string\n invoiceDirection?: 'Sent' | 'Received'\n status?: DocumentStatus\n documentType?: EInvoiceTypeCode\n searchQuery?: string // Search by uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total\n }): Promise<DocumentSummary[]> {\n return DocumentManagementAPI.searchDocuments(\n { fetch: this.fetch.bind(this) },\n {\n uuid,\n submissionDateFrom,\n submissionDateTo,\n pageSize,\n pageNo,\n issueDateFrom,\n issueDateTo,\n invoiceDirection,\n status,\n documentType,\n searchQuery,\n },\n )\n }\n\n /**\n * Retrieves notifications from the MyInvois platform based on specified search criteria.\n *\n * This method allows you to search for system notifications, alerts, and messages\n * sent by the MyInvois platform regarding document processing, system updates,\n * or account-related information.\n *\n * @param params - Search parameters object for filtering notifications\n * @param params.dateFrom - Optional start date for notification date range (ISO date string)\n * @param params.dateTo - Optional end date for notification date range (ISO date string)\n * @param params.type - Optional notification type filter\n * @param params.language - Optional language preference for notifications\n * @param params.status - Optional notification status filter\n * @param params.pageNo - Optional page number for pagination (0-based)\n * @param params.pageSize - Optional number of results per page\n * @returns Promise resolving to notification response object or standard error\n *\n * @example\n * ```typescript\n * // Get all notifications from the last 7 days\n * const notifications = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * dateTo: '2024-01-07',\n * pageSize: 20\n * });\n *\n * // Get unread notifications only\n * const unreadNotifications = await client.getNotifications({\n * status: 0, // Assuming 0 = unread\n * language: 'en'\n * });\n *\n * // Paginated notification retrieval\n * const firstPage = await client.getNotifications({\n * dateFrom: '2024-01-01',\n * pageNo: 0,\n * pageSize: 10\n * });\n * ```\n *\n * @remarks\n * - All parameters are optional, allowing flexible filtering\n * - Returns paginated results when pageNo and pageSize are specified\n * - Date parameters should be in ISO format (YYYY-MM-DD)\n * - May return StandardError object if the request fails\n */\n async getNotifications({\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n }: NotificationSearchParams): Promise<NotificationResponse | StandardError> {\n return NotificationManagementAPI.getNotifications(\n { fetch: this.fetch.bind(this) },\n {\n dateFrom,\n dateTo,\n type,\n language,\n status,\n pageNo,\n pageSize,\n },\n )\n }\n\n async getDocumentTypes(): Promise<DocumentTypesResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentTypes({\n fetch: this.fetch.bind(this),\n })\n }\n\n /**\n * Retrieves detailed information about a specific document type from the MyInvois platform.\n *\n * This method fetches metadata and configuration details for a specific document type,\n * including supported versions, validation rules, and structural requirements.\n * Useful for understanding document format requirements before submission.\n *\n * @param id - The unique identifier of the document type to retrieve\n * @returns Promise resolving to document type response object or standard error\n *\n * @example\n * ```typescript\n * // Get details for e-invoice document type\n * const invoiceType = await client.getDocumentType(1);\n * if ('id' in invoiceType) {\n * console.log('Document type name:', invoiceType.name);\n * console.log('Available versions:', invoiceType.versionNumber);\n * console.log('Description:', invoiceType.description);\n * }\n *\n * // Handle potential errors\n * const documentType = await client.getDocumentType(999);\n * if ('error' in documentType) {\n * console.error('Failed to retrieve document type:', documentType.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if the document type ID doesn't exist\n * - Document type information includes validation schemas and business rules\n * - Use this method to discover supported document formats and versions\n * - Essential for understanding submission requirements for different document types\n */\n async getDocumentType(\n id: number,\n ): Promise<DocumentTypeResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentType(\n { fetch: this.fetch.bind(this) },\n id,\n )\n }\n\n /**\n * Retrieves detailed information about a specific version of a document type.\n *\n * This method fetches version-specific metadata, schema definitions, and validation rules\n * for a particular document type version. Essential for understanding the exact format\n * and requirements for document submission in a specific version.\n *\n * @param id - The unique identifier of the document type\n * @param versionId - The unique identifier of the specific version to retrieve\n * @returns Promise resolving to document type version response object or standard error\n *\n * @example\n * ```typescript\n * // Get specific version details for e-invoice\n * const invoiceV1_1 = await client.getDocumentTypeVersion(1, 1);\n * if ('id' in invoiceV1_1) {\n * console.log('Version number:', invoiceV1_1.versionNumber);\n * console.log('Schema:', invoiceV1_1.jsonSchema);\n * console.log('Status:', invoiceV1_1.status);\n * }\n *\n * // Compare different versions\n * const [v1_0, v1_1] = await Promise.all([\n * client.getDocumentTypeVersion(1, 0),\n * client.getDocumentTypeVersion(1, 1)\n * ]);\n *\n * // Handle version not found\n * const result = await client.getDocumentTypeVersion(1, 999);\n * if ('error' in result) {\n * console.error('Version not found:', result.error.message);\n * }\n * ```\n *\n * @remarks\n * - Returns StandardError object if document type ID or version ID doesn't exist\n * - Version information includes JSON schema for validation\n * - Different versions may have different validation rules and field requirements\n * - Use this to ensure your documents conform to the specific version requirements\n * - Version status indicates if the version is active, deprecated, or under development\n */\n async getDocumentTypeVersion(\n id: number,\n versionId: number,\n ): Promise<DocumentTypeVersionResponse | StandardError> {\n return DocumentTypeManagementAPI.getDocumentTypeVersion(\n { fetch: this.fetch.bind(this) },\n id,\n versionId,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AA6BA,IAAa,iBAAb,MAA4B;CAC1B,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAiB;CACjB,AAAQ,QAAQ;CAChB,AAAQ;CAER,YACEA,UACAC,cACAC,aACAC,gBACAC,eACAC,YACAC,OACA;AAEA,OAAK,kBAAkB,eACrB,OAAM,IAAI,MACR;AAKJ,OAAK,oCAAgB,gBAAgB,cAAc,CACjD,OAAM,IAAI,MAAM;AAGlB,OAAK,WAAW;AAChB,OAAK,eAAe;AACpB,OAAK,UAAU,8BAAW,YAAY;AACtC,OAAK,aAAa;AAClB,OAAK,QAAS,SAAS,QAAQ,IAAI,mBAAmB,SAAU,OAAO;EAGvE,MAAM,EAAE,YAAY,cAAc,GAAG,2CAAuB,eAAe;AAE3E,OAAK,qBAAqB;GACxB;GACA;GACA;GACA;EACD;CACF;CAED,MAAc,eAAe;EAC3B,MAAM,gBAAgB,MAAM,oCAAc;GACxC,UAAU,KAAK;GACf,cAAc,KAAK;GACnB,SAAS,KAAK;GACd,YAAY,KAAK;GACjB,OAAO,KAAK;EACb,EAAC;AAEF,OAAK,QAAQ,cAAc;AAC3B,OAAK,kBAAkB,cAAc;CACtC;CAED,MAAc,WAAW;AACvB,OACG,KAAK,mBACN,KAAK,kCAAkB,IAAI,UAC3B,MAAM,KAAK,gBAAgB,SAAS,CAAC,EACrC;AACA,OAAI,KAAK,OAAO;AACd,YAAQ,IAAI,gBAAgB;AAC5B,YAAQ,IAAI,mBAAmB;GAChC;AACD,SAAM,KAAK,cAAc;EAC1B;AAED,SAAO,KAAK;CACb;CAED,MAAc,MAAMC,MAAcC,UAAuC,CAAE,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