@ripwords/myinvois-client 0.1.0 → 0.1.2
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/CHANGELOG.md +99 -0
- package/README.md +128 -4
- package/bun.lock +59 -0
- package/dist/{0X-Yw7mZEro.d.cts → 0X-CG1S1WKn.d.ts} +1 -2
- package/dist/{0X-C4IRh_fJ.d.ts → 0X-ChfmeAYF.d.cts} +1 -1
- package/dist/{1X-D_aUVsuM.d.cts → 1X-CmlbG02M.d.ts} +1 -2
- package/dist/{1X-BwpSoT3o.d.cts → 1X-DFikQbP0.d.cts} +1 -1
- package/dist/{1X-C-_KHV-Q.d.ts → 1X-DbFshzup.d.ts} +1 -2
- package/dist/{1X-Brnls9Jh.d.ts → 1X-jFrFCOs0.d.cts} +1 -1
- package/dist/{2X-UdQcQW24.d.ts → 2X-5cE4ojEX.d.cts} +1 -1
- package/dist/{2X-hClUyw26.d.cts → 2X-DA6J6Wd7.d.ts} +1 -2
- package/dist/{2X-Bb6elyzV.d.cts → 2X-FWZ1rYVt.d.cts} +1 -1
- package/dist/{2X-DkS1BoE5.d.ts → 2X-eC_p0QJf.d.ts} +1 -2
- package/dist/{3X-C7VFD-n-.d.cts → 3X-D9duw0Ro.d.cts} +1 -1
- package/dist/{3X-DFI-4RQQ.d.ts → 3X-DbfkwdkO.d.ts} +1 -2
- package/dist/{3X-DVDyspgb.d.ts → 3X-GxuN79Ax.d.ts} +1 -2
- package/dist/{3X-CLMESDvz.d.cts → 3X-r9xbWJ2l.d.cts} +1 -1
- package/dist/{4X-CIJ2JJ2w.d.ts → 4X-1ZkK-uH5.d.cts} +1 -1
- package/dist/{4X-CUR8jlaZ.d.ts → 4X-CLO9OuKa.d.cts} +1 -1
- package/dist/{4X-DIfvpU6V.d.cts → 4X-CnHtgO6u.d.ts} +1 -2
- package/dist/{4X-CvScPJTf.d.cts → 4X-DYz_nYSD.d.ts} +1 -2
- package/dist/{5X-COsZHUaQ.d.ts → 5X-BzPEdkbC.d.ts} +1 -2
- package/dist/{5X-C6db432h.d.ts → 5X-BziH0a09.d.cts} +1 -1
- package/dist/{5X-BOUxhadJ.d.cts → 5X-Cfe39fFc.d.cts} +1 -1
- package/dist/{5X-CkLu7Vyd.d.cts → 5X-kBF74qx1.d.ts} +1 -2
- package/dist/{6X-C_fFIcJC.d.ts → 6X-BceErbps.d.cts} +1 -1
- package/dist/{6X-DE7RJeV6.d.cts → 6X-C_xpeu6J.d.ts} +1 -2
- package/dist/{6X-ClZDKOTC.d.ts → 6X-DLWEe1bP.d.cts} +1 -1
- package/dist/{6X-Mf32k1d0.d.cts → 6X-sQZfT0ZK.d.ts} +1 -2
- package/dist/{7X-Chtd6B66.d.cts → 7X-Bet2agJ6.d.ts} +1 -2
- package/dist/{7X-kot_VccM.d.ts → 7X-BoKQxMoO.d.ts} +1 -2
- package/dist/{7X-BZyesooz.d.ts → 7X-CucHYQsA.d.cts} +1 -1
- package/dist/{7X-DoCUcp-J.d.cts → 7X-CwPAqozm.d.cts} +1 -1
- package/dist/{8X-Df4DOBOe.d.ts → 8X-BIjJ9kaV.d.cts} +1 -1
- package/dist/{8X-Dr9RunRw.d.cts → 8X-BOEWATU3.d.ts} +1 -2
- package/dist/{8X-DkuKAkHz.d.ts → 8X-CJpqd5xp.d.cts} +1 -1
- package/dist/{8X-DqZyMvyV.d.cts → 8X-s5AzkHR-.d.ts} +1 -2
- package/dist/{9X-BDgifncF.d.ts → 9X-BBDP1gZ6.d.ts} +1 -2
- package/dist/{9X-BaoZtjWF.d.cts → 9X-CP5Xp6bE.d.cts} +1 -1
- package/dist/{9X-BcAb6Uso.d.cts → 9X-D3aOVCnz.d.cts} +1 -1
- package/dist/{9X-BhBWlgxG.d.ts → 9X-DAAZV4sr.d.ts} +1 -2
- package/dist/{AX-D6XHWdrY.d.ts → AX-CmpMMhII.d.ts} +1 -2
- package/dist/{AX-BY72FohC.d.cts → AX-DFzpxGOT.d.cts} +1 -1
- package/dist/{BX-D_0C8Qbd.d.ts → BX-CyiqNE6b.d.cts} +1 -1
- package/dist/{BX-CA0OmrUZ.d.cts → BX-j78z_ju_.d.ts} +1 -2
- package/dist/{CX-glpQSL8x.d.cts → CX-B6rEhQx7.d.ts} +1 -2
- package/dist/{CX-HH4cSZRX.d.ts → CX-BTPvC3Dv.d.cts} +1 -1
- package/dist/{DX-DimL1MDM.d.cts → DX-BD4-hTCh.d.cts} +1 -1
- package/dist/{DX-Dx22ax_I.d.ts → DX-CAmMnx5a.d.ts} +1 -2
- package/dist/{EX-BRWh1wFc.d.ts → EX-CXhSC85J.d.ts} +1 -2
- package/dist/{EX-Cx87Ruxl.d.cts → EX-mTHCH0Yk.d.cts} +1 -1
- package/dist/{FX-D81UlxNN.d.cts → FX-DOOMoQl2.d.cts} +1 -1
- package/dist/{FX-RmjwAr40.d.ts → FX-DYVIJ3l0.d.ts} +1 -2
- package/dist/{GX-CJyo7oDp.d.ts → GX-8URJ7WHz.d.cts} +1 -1
- package/dist/{GX-9i7piP9G.d.cts → GX-eBOVHqi6.d.ts} +1 -2
- package/dist/{HX-20GVJAvl.d.cts → HX-49z8CzsE.d.cts} +1 -1
- package/dist/{HX-XALBTdLA.d.ts → HX-Dz5T0xXI.d.ts} +1 -2
- package/dist/{IX-6SZ55QKb.d.ts → IX-B6kblmBs.d.cts} +1 -1
- package/dist/{IX-D54NGPsc.d.cts → IX-PiKYro5a.d.ts} +1 -2
- package/dist/{JX-C1RYcwQX.d.cts → JX-DMwHLGEE.d.cts} +1 -1
- package/dist/{JX-hQ1XRmLp.d.ts → JX-Dvnt0mSK.d.ts} +1 -2
- package/dist/{KX-BNwunEfn.d.ts → KX-BUb8e0yg.d.ts} +1 -2
- package/dist/{KX-gQHCIgtQ.d.cts → KX-DaJPkefl.d.cts} +1 -1
- package/dist/{LX-CHYX3X3J.d.ts → LX-BnILxjdS.d.cts} +1 -1
- package/dist/{LX-CPurJGIh.d.cts → LX-l5ZBaGov.d.ts} +1 -2
- package/dist/{MX-BPGLWSUz.d.ts → MX-BbPO8mTj.d.cts} +1 -1
- package/dist/{MX-BnyW5eHf.d.cts → MX-C7C15AWi.d.ts} +1 -2
- package/dist/{NX-RulN5Ml3.d.ts → NX-C7nFVC-D.d.ts} +1 -2
- package/dist/{NX-B11fQuco.d.cts → NX-xy5uw7H3.d.cts} +1 -1
- package/dist/{OX-DgKVSp7I.d.ts → OX-CIzARbON.d.cts} +1 -1
- package/dist/{OX-T-ydRXQS.d.cts → OX-Dmkvcaij.d.ts} +1 -2
- package/dist/{PX-DA4A2kEv.d.ts → PX-BKZ14N7N.d.ts} +1 -2
- package/dist/{PX-p0n1SzvU.d.cts → PX-CL8waFgx.d.cts} +1 -1
- package/dist/{QX-DrFqsMEs.d.ts → QX-6xdSNtxZ.d.ts} +1 -2
- package/dist/{QX-CI1NccIB.d.cts → QX-BowAYqZb.d.cts} +1 -1
- package/dist/{RX-DnNKol22.d.cts → RX-DFoiOK5q.d.ts} +1 -2
- package/dist/{RX-Cm7vFcFN.d.ts → RX-fWoWcHTG.d.cts} +1 -1
- package/dist/{SX-BUjiWQYz.d.cts → SX-CZ3e31OT.d.cts} +1 -1
- package/dist/{SX-CsPPTu-W.d.ts → SX-D-Szi9wa.d.ts} +1 -2
- package/dist/{TX-DCY25MdR.d.ts → TX-CJhJ-HYX.d.cts} +1 -1
- package/dist/{TX-DOEpsf05.d.cts → TX-DTfkGsqn.d.ts} +1 -2
- package/dist/{UX-DgUOnTFK.d.cts → UX-Bw4HHAj4.d.ts} +1 -2
- package/dist/{UX-DauyagHy.d.ts → UX-P7-u2y70.d.cts} +1 -1
- package/dist/{VX-DD4scgCe.d.ts → VX-C8Eu5gQf.d.cts} +1 -1
- package/dist/{VX-kUX6LM-3.d.cts → VX-DCv5x_hi.d.ts} +1 -2
- package/dist/{WX-DPfyPFFh.d.cts → WX-BYtJ5_if.d.ts} +1 -2
- package/dist/{WX-CjkoppdY.d.ts → WX-DkiaqB2V.d.cts} +1 -1
- package/dist/{XX-sbsIUOnA.d.ts → XX-D4p4iK-a.d.cts} +1 -1
- package/dist/{XX-C4C1gQZH.d.cts → XX-Jo1yJO3A.d.ts} +1 -2
- package/dist/{YX-DUdO8mRC.d.ts → YX-BvGmEsVG.d.ts} +1 -2
- package/dist/{YX-BeT-LsiA.d.cts → YX-Du8zv9qz.d.cts} +1 -1
- package/dist/{ZX-BuVTTq-D.d.cts → ZX-B4jFD-21.d.cts} +1 -1
- package/dist/{ZX-DwfcSA-D.d.ts → ZX-B59AJcBY.d.ts} +1 -2
- package/dist/api/platform/platformLogin.d.ts +58 -60
- package/dist/api/platform/platformLogin.js +1 -1
- package/dist/certificate-DFK-788s.cjs +62 -0
- package/dist/certificate-DFK-788s.cjs.map +1 -0
- package/dist/certificate-aooIRf9A.js +49 -0
- package/dist/{classification-codes-C2X4xW5-.d.ts → classification-codes-BKxV-rO9.d.ts} +1 -2
- package/dist/{country-code-DsI8Mbzx.d.ts → country-code-CQuaiQm2.d.ts} +1 -2
- package/dist/{currencies-DKuDflOO.d.ts → currencies-BYJK-m6v.d.ts} +1 -2
- package/dist/document-DMIMRJV0.cjs +472 -0
- package/dist/document-DMIMRJV0.cjs.map +1 -0
- package/dist/document-NQos5fSr.js +405 -0
- package/dist/documents-BVG7KIKY.d.ts +847 -0
- package/dist/documents-C066EC9m.d.cts +848 -0
- package/dist/{e-invoice-C2TxhyrK.d.ts → e-invoice-CmbLQkHw.d.ts} +1 -2
- package/dist/{getBaseUrl-Dx6RDC8I.js → getBaseUrl-R3IdgCu3.js} +1 -2
- package/dist/{index-B1DSs-wd.d.cts → index-0-EvC6Nv.d.ts} +1 -2
- package/dist/{index-FTgB2nM6.d.ts → index-D2_HVwCz.d.cts} +1 -1
- package/dist/index.cjs +308 -12
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +233 -60
- package/dist/index.js +306 -11
- package/dist/index10.cjs +0 -34
- package/dist/index11.cjs +25 -15
- package/dist/index11.cjs.map +1 -1
- package/dist/index12.cjs +24 -0
- package/dist/index12.cjs.map +1 -0
- package/dist/index13.cjs +0 -13
- package/dist/index15.cjs +3 -2
- package/dist/index16.cjs +12 -16
- package/dist/index17.cjs +2 -2
- package/dist/index18.cjs +336 -204
- package/dist/index18.cjs.map +1 -1
- package/dist/index19.cjs +325 -105
- package/dist/index19.cjs.map +1 -1
- package/dist/index20.cjs +136 -133
- package/dist/index20.cjs.map +1 -1
- package/dist/index21.cjs +2 -63
- package/dist/index22.cjs +203 -262
- package/dist/index22.cjs.map +1 -1
- package/dist/index23.cjs +104 -74
- package/dist/index23.cjs.map +1 -1
- package/dist/index24.cjs +132 -102
- package/dist/index24.cjs.map +1 -1
- package/dist/index25.cjs +59 -68
- package/dist/index25.cjs.map +1 -1
- package/dist/index26.cjs +262 -107
- package/dist/index26.cjs.map +1 -1
- package/dist/index27.cjs +74 -95
- package/dist/index27.cjs.map +1 -1
- package/dist/index28.cjs +102 -13
- package/dist/index28.cjs.map +1 -1
- package/dist/index29.cjs +68 -33
- package/dist/index29.cjs.map +1 -1
- package/dist/index30.cjs +107 -14
- package/dist/index30.cjs.map +1 -1
- package/dist/index31.cjs +95 -24
- package/dist/index31.cjs.map +1 -1
- package/dist/index32.cjs +11 -13
- package/dist/index32.cjs.map +1 -1
- package/dist/index33.cjs +31 -7
- package/dist/index33.cjs.map +1 -1
- package/dist/index34.cjs +12 -7
- package/dist/index34.cjs.map +1 -1
- package/dist/index35.cjs +22 -10
- package/dist/index35.cjs.map +1 -1
- package/dist/index36.cjs +13 -6
- package/dist/index36.cjs.map +1 -1
- package/dist/index37.cjs +7 -101
- package/dist/index37.cjs.map +1 -1
- package/dist/index38.cjs +7 -106
- package/dist/index38.cjs.map +1 -1
- package/dist/index39.cjs +10 -119
- package/dist/index39.cjs.map +1 -1
- package/dist/index40.cjs +6 -106
- package/dist/index40.cjs.map +1 -1
- package/dist/index41.cjs +101 -98
- package/dist/index41.cjs.map +1 -1
- package/dist/index42.cjs +106 -118
- package/dist/index42.cjs.map +1 -1
- package/dist/index43.cjs +119 -127
- package/dist/index43.cjs.map +1 -1
- package/dist/index44.cjs +106 -117
- package/dist/index44.cjs.map +1 -1
- package/dist/index45.cjs +98 -14
- package/dist/index45.cjs.map +1 -1
- package/dist/index46.cjs +118 -95
- package/dist/index46.cjs.map +1 -1
- package/dist/index47.cjs +127 -142
- package/dist/index47.cjs.map +1 -1
- package/dist/index48.cjs +117 -114
- package/dist/index48.cjs.map +1 -1
- package/dist/index49.cjs +14 -144
- package/dist/index49.cjs.map +1 -1
- package/dist/index5.cjs +0 -25
- package/dist/index50.cjs +95 -113
- package/dist/index50.cjs.map +1 -1
- package/dist/index51.cjs +142 -17
- package/dist/index51.cjs.map +1 -1
- package/dist/index52.cjs +114 -112
- package/dist/index52.cjs.map +1 -1
- package/dist/index53.cjs +144 -47
- package/dist/index53.cjs.map +1 -1
- package/dist/index54.cjs +113 -14
- package/dist/index54.cjs.map +1 -1
- package/dist/index55.cjs +17 -28
- package/dist/index55.cjs.map +1 -1
- package/dist/index56.cjs +112 -22
- package/dist/index56.cjs.map +1 -1
- package/dist/index57.cjs +47 -9
- package/dist/index57.cjs.map +1 -1
- package/dist/index58.cjs +14 -8
- package/dist/index58.cjs.map +1 -1
- package/dist/index58.cts.map +1 -0
- package/dist/index59.cjs +28 -17
- package/dist/index59.cjs.map +1 -1
- package/dist/index59.cts.map +1 -1
- package/dist/index6.cjs +25 -0
- package/dist/{index5.cjs.map → index6.cjs.map} +1 -1
- package/dist/index60.cjs +22 -412
- package/dist/index60.cjs.map +1 -1
- package/dist/index60.cts.map +1 -0
- package/dist/index61.cjs +9 -8
- package/dist/index61.cjs.map +1 -1
- package/dist/index61.cts.map +1 -0
- package/dist/index62.cjs +8 -9
- package/dist/index62.cjs.map +1 -1
- package/dist/index62.cts.map +1 -1
- package/dist/index63.cjs +24 -0
- package/dist/index63.cjs.map +1 -0
- package/dist/index63.cts.map +1 -1
- package/dist/index64.cjs +419 -0
- package/dist/index64.cjs.map +1 -0
- package/dist/index64.cts.map +1 -1
- package/dist/index65.cjs +9 -116
- package/dist/index65.cjs.map +1 -1
- package/dist/index65.cts.map +1 -1
- package/dist/index66.cjs +10 -223
- package/dist/index66.cjs.map +1 -1
- package/dist/index66.cts.map +1 -1
- package/dist/index8.cjs +0 -25
- package/dist/index9.cjs +25 -0
- package/dist/{index8.cjs.map → index9.cjs.map} +1 -1
- package/dist/{msic-codes-B_1W6lZF.d.cts → msic-codes-CPWVNnpq.d.cts} +11 -11
- package/dist/msic-codes-DToUqTI6.d.ts +25 -0
- package/dist/{payment-modes-DHihrywe.d.cts → payment-modes-DA7uBIGb.d.ts} +1 -2
- package/dist/{payment-modes-B8dNy3SM.d.ts → payment-modes-FX88uyhP.d.cts} +1 -1
- package/dist/platformLogin-PGzMhw1X.cjs.map +1 -1
- package/dist/{platformLogin-DsxWWUXr.js → platformLogin-f0bNAoZI.js} +1 -2
- package/dist/{signatures-C9QPZTQd.d.ts → signatures-CG175mpg.d.ts} +1 -2
- package/dist/{state-codes-DXSWtE6a.d.cts → state-codes-CNp_6051.d.cts} +1 -1
- package/dist/{state-codes-CxG1S9YY.d.ts → state-codes-dvoTe5pC.d.ts} +1 -2
- package/dist/{tax-types-CEpfSh5P.d.ts → tax-types-tosH5I0q.d.ts} +1 -2
- 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 +7 -0
- package/dist/types/e-invoice.d.ts +1 -1
- package/dist/types/index.d.ts +58 -59
- 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/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/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/unit-types-BKZxwVYQ.d.ts +55 -0
- package/dist/unit-types-CaOA5ZDG.d.cts +56 -0
- package/dist/utils/base64.d.ts +1 -2
- package/dist/utils/base64.js +1 -2
- package/dist/utils/certificate.d.ts +22 -0
- package/dist/utils/certificate.js +3 -0
- package/dist/utils/document.d.ts +135 -0
- package/dist/utils/document.js +3 -0
- package/dist/utils/getBaseUrl.d.ts +1 -2
- package/dist/utils/getBaseUrl.js +1 -1
- package/dist/utils/helpers.d.ts +271 -0
- package/dist/utils/helpers.js +330 -0
- package/dist/utils/signature-diagnostics.d.ts +93 -0
- package/dist/utils/signature-diagnostics.js +326 -0
- package/dist/utils/validation.d.ts +46 -0
- package/dist/utils/validation.js +134 -0
- package/myinvois-cert.conf.template +23 -0
- package/package.json +9 -3
- package/scripts/gen-cert.sh +159 -0
- package/src/api/platform/platformLogin.ts +1 -1
- package/src/index.ts +528 -1
- package/src/types/documents.d.ts +862 -0
- package/src/types/index.d.ts +1 -1
- package/src/utils/certificate.ts +60 -0
- package/src/utils/document.ts +852 -0
- package/src/utils/helpers.ts +552 -0
- package/src/utils/signature-diagnostics.ts +583 -0
- package/src/utils/validation.ts +268 -0
- package/test/MyInvoiClientWithRealData.test.ts +9 -1
- package/test/MyInvoisClient.test.ts +7 -1
- package/test/dynamicInvoiceFeatures.test.ts +449 -0
- package/test/signAndSubmitInvoice.test.ts +269 -734
- package/test/signature-diagnostics.test.ts +128 -0
- package/tsconfig.json +0 -3
- package/dist/0X-C4IRh_fJ.d.ts.map +0 -1
- package/dist/0X-Yw7mZEro.d.cts.map +0 -1
- package/dist/1X-Brnls9Jh.d.ts.map +0 -1
- package/dist/1X-BwpSoT3o.d.cts.map +0 -1
- package/dist/1X-C-_KHV-Q.d.ts.map +0 -1
- package/dist/1X-D_aUVsuM.d.cts.map +0 -1
- package/dist/2X-Bb6elyzV.d.cts.map +0 -1
- package/dist/2X-DkS1BoE5.d.ts.map +0 -1
- package/dist/2X-UdQcQW24.d.ts.map +0 -1
- package/dist/2X-hClUyw26.d.cts.map +0 -1
- package/dist/3X-C7VFD-n-.d.cts.map +0 -1
- package/dist/3X-CLMESDvz.d.cts.map +0 -1
- package/dist/3X-DFI-4RQQ.d.ts.map +0 -1
- package/dist/3X-DVDyspgb.d.ts.map +0 -1
- package/dist/4X-CIJ2JJ2w.d.ts.map +0 -1
- package/dist/4X-CUR8jlaZ.d.ts.map +0 -1
- package/dist/4X-CvScPJTf.d.cts.map +0 -1
- package/dist/4X-DIfvpU6V.d.cts.map +0 -1
- package/dist/5X-BOUxhadJ.d.cts.map +0 -1
- package/dist/5X-C6db432h.d.ts.map +0 -1
- package/dist/5X-COsZHUaQ.d.ts.map +0 -1
- package/dist/5X-CkLu7Vyd.d.cts.map +0 -1
- package/dist/6X-C_fFIcJC.d.ts.map +0 -1
- package/dist/6X-ClZDKOTC.d.ts.map +0 -1
- package/dist/6X-DE7RJeV6.d.cts.map +0 -1
- package/dist/6X-Mf32k1d0.d.cts.map +0 -1
- package/dist/7X-BZyesooz.d.ts.map +0 -1
- package/dist/7X-Chtd6B66.d.cts.map +0 -1
- package/dist/7X-DoCUcp-J.d.cts.map +0 -1
- package/dist/7X-kot_VccM.d.ts.map +0 -1
- package/dist/8X-Df4DOBOe.d.ts.map +0 -1
- package/dist/8X-DkuKAkHz.d.ts.map +0 -1
- package/dist/8X-DqZyMvyV.d.cts.map +0 -1
- package/dist/8X-Dr9RunRw.d.cts.map +0 -1
- package/dist/9X-BDgifncF.d.ts.map +0 -1
- package/dist/9X-BaoZtjWF.d.cts.map +0 -1
- package/dist/9X-BcAb6Uso.d.cts.map +0 -1
- package/dist/9X-BhBWlgxG.d.ts.map +0 -1
- package/dist/AX-BY72FohC.d.cts.map +0 -1
- package/dist/AX-D6XHWdrY.d.ts.map +0 -1
- package/dist/BX-CA0OmrUZ.d.cts.map +0 -1
- package/dist/BX-D_0C8Qbd.d.ts.map +0 -1
- package/dist/CX-HH4cSZRX.d.ts.map +0 -1
- package/dist/CX-glpQSL8x.d.cts.map +0 -1
- package/dist/DX-DimL1MDM.d.cts.map +0 -1
- package/dist/DX-Dx22ax_I.d.ts.map +0 -1
- package/dist/EX-BRWh1wFc.d.ts.map +0 -1
- package/dist/EX-Cx87Ruxl.d.cts.map +0 -1
- package/dist/FX-D81UlxNN.d.cts.map +0 -1
- package/dist/FX-RmjwAr40.d.ts.map +0 -1
- package/dist/GX-9i7piP9G.d.cts.map +0 -1
- package/dist/GX-CJyo7oDp.d.ts.map +0 -1
- package/dist/HX-20GVJAvl.d.cts.map +0 -1
- package/dist/HX-XALBTdLA.d.ts.map +0 -1
- package/dist/IX-6SZ55QKb.d.ts.map +0 -1
- package/dist/IX-D54NGPsc.d.cts.map +0 -1
- package/dist/JX-C1RYcwQX.d.cts.map +0 -1
- package/dist/JX-hQ1XRmLp.d.ts.map +0 -1
- package/dist/KX-BNwunEfn.d.ts.map +0 -1
- package/dist/KX-gQHCIgtQ.d.cts.map +0 -1
- package/dist/LX-CHYX3X3J.d.ts.map +0 -1
- package/dist/LX-CPurJGIh.d.cts.map +0 -1
- package/dist/MX-BPGLWSUz.d.ts.map +0 -1
- package/dist/MX-BnyW5eHf.d.cts.map +0 -1
- package/dist/MyInvoisClient-BrNyMjS-.d.cts +0 -178
- package/dist/MyInvoisClient-BrNyMjS-.d.cts.map +0 -1
- package/dist/MyInvoisClient-CXu4pdl-.d.ts +0 -178
- package/dist/MyInvoisClient-CXu4pdl-.d.ts.map +0 -1
- package/dist/MyInvoisClient-Cnvb5iUC.js +0 -299
- package/dist/MyInvoisClient-Cnvb5iUC.js.map +0 -1
- package/dist/MyInvoisClient-DO1dJfQq.cjs +0 -304
- package/dist/MyInvoisClient-DO1dJfQq.cjs.map +0 -1
- package/dist/NX-B11fQuco.d.cts.map +0 -1
- package/dist/NX-RulN5Ml3.d.ts.map +0 -1
- package/dist/OX-DgKVSp7I.d.ts.map +0 -1
- package/dist/OX-T-ydRXQS.d.cts.map +0 -1
- package/dist/PX-DA4A2kEv.d.ts.map +0 -1
- package/dist/PX-p0n1SzvU.d.cts.map +0 -1
- package/dist/QX-CI1NccIB.d.cts.map +0 -1
- package/dist/QX-DrFqsMEs.d.ts.map +0 -1
- package/dist/RX-Cm7vFcFN.d.ts.map +0 -1
- package/dist/RX-DnNKol22.d.cts.map +0 -1
- package/dist/SX-BUjiWQYz.d.cts.map +0 -1
- package/dist/SX-CsPPTu-W.d.ts.map +0 -1
- package/dist/TX-DCY25MdR.d.ts.map +0 -1
- package/dist/TX-DOEpsf05.d.cts.map +0 -1
- package/dist/UX-DauyagHy.d.ts.map +0 -1
- package/dist/UX-DgUOnTFK.d.cts.map +0 -1
- package/dist/VX-DD4scgCe.d.ts.map +0 -1
- package/dist/VX-kUX6LM-3.d.cts.map +0 -1
- package/dist/WX-CjkoppdY.d.ts.map +0 -1
- package/dist/WX-DPfyPFFh.d.cts.map +0 -1
- package/dist/XX-C4C1gQZH.d.cts.map +0 -1
- package/dist/XX-sbsIUOnA.d.ts.map +0 -1
- package/dist/YX-BeT-LsiA.d.cts.map +0 -1
- package/dist/YX-DUdO8mRC.d.ts.map +0 -1
- package/dist/ZX-BuVTTq-D.d.cts.map +0 -1
- package/dist/ZX-DwfcSA-D.d.ts.map +0 -1
- package/dist/api/platform/platformLogin.d.ts.map +0 -1
- package/dist/canonicalize-C_fNNpYr.cjs +0 -80
- package/dist/canonicalize-C_fNNpYr.cjs.map +0 -1
- package/dist/canonicalize-DNUrCGad.js +0 -68
- package/dist/canonicalize-DNUrCGad.js.map +0 -1
- package/dist/classification-codes-B15PbWxz.d.cts.map +0 -1
- package/dist/classification-codes-C2X4xW5-.d.ts.map +0 -1
- package/dist/country-code-DPeNFMMi.d.cts.map +0 -1
- package/dist/country-code-DsI8Mbzx.d.ts.map +0 -1
- package/dist/currencies-DKuDflOO.d.ts.map +0 -1
- package/dist/currencies-S5g1gzBU.d.cts.map +0 -1
- package/dist/e-invoice-BuwtFnlI.d.cts.map +0 -1
- package/dist/e-invoice-C2TxhyrK.d.ts.map +0 -1
- package/dist/getBaseUrl-Dx6RDC8I.js.map +0 -1
- package/dist/hashCert-Bol7lIh2.js +0 -62
- package/dist/hashCert-Bol7lIh2.js.map +0 -1
- package/dist/hashCert-mlYEuYex.cjs +0 -68
- package/dist/hashCert-mlYEuYex.cjs.map +0 -1
- package/dist/hashSignedProperties-9vj5wlYR.js +0 -83
- package/dist/hashSignedProperties-9vj5wlYR.js.map +0 -1
- package/dist/hashSignedProperties-CU_ZqqmY.cjs +0 -95
- package/dist/hashSignedProperties-CU_ZqqmY.cjs.map +0 -1
- package/dist/index-B1DSs-wd.d.cts.map +0 -1
- package/dist/index-CJNLQVjx.d.ts +0 -1
- package/dist/index-FTgB2nM6.d.ts.map +0 -1
- package/dist/index-Wy1ONBjV.d.cts +0 -1
- package/dist/index10.cjs.map +0 -1
- package/dist/index21.cjs.map +0 -1
- package/dist/index67.cjs +0 -4
- package/dist/index67.cts.map +0 -1
- package/dist/index68.cjs +0 -3
- package/dist/index68.cts.map +0 -1
- package/dist/index69.cjs +0 -4
- package/dist/index69.cts.map +0 -1
- package/dist/index70.cjs +0 -3
- package/dist/index70.cts.map +0 -1
- package/dist/index71.cjs +0 -3
- package/dist/index71.cts.map +0 -1
- package/dist/index72.cjs +0 -3
- package/dist/index72.cts.map +0 -1
- package/dist/index73.cjs +0 -3
- package/dist/index73.cts.map +0 -1
- package/dist/invoice-1_1-BJVcw-oE.d.ts +0 -432
- package/dist/invoice-1_1-BJVcw-oE.d.ts.map +0 -1
- package/dist/invoice-1_1-DWdNPRzr.d.cts +0 -432
- package/dist/invoice-1_1-DWdNPRzr.d.cts.map +0 -1
- package/dist/invoice1-1-8S-QQn7P.cjs +0 -547
- package/dist/invoice1-1-8S-QQn7P.cjs.map +0 -1
- package/dist/invoice1-1-CHuLpkFz.js +0 -504
- package/dist/invoice1-1-CHuLpkFz.js.map +0 -1
- package/dist/msic-codes-B_1W6lZF.d.cts.map +0 -1
- package/dist/msic-codes-bs0lTfSZ.d.ts +0 -26
- package/dist/msic-codes-bs0lTfSZ.d.ts.map +0 -1
- package/dist/payment-modes-B8dNy3SM.d.ts.map +0 -1
- package/dist/payment-modes-DHihrywe.d.cts.map +0 -1
- package/dist/platformLogin-DsxWWUXr.js.map +0 -1
- package/dist/populateFinalDocument-BdyYzz5Y.cjs +0 -96
- package/dist/populateFinalDocument-BdyYzz5Y.cjs.map +0 -1
- package/dist/populateFinalDocument-BpLXmgLv.js +0 -90
- package/dist/populateFinalDocument-BpLXmgLv.js.map +0 -1
- package/dist/populateSignedProperties-BJMcBQ6S.cjs +0 -58
- package/dist/populateSignedProperties-BJMcBQ6S.cjs.map +0 -1
- package/dist/populateSignedProperties-BvGN-YZH.js +0 -52
- package/dist/populateSignedProperties-BvGN-YZH.js.map +0 -1
- package/dist/sign-B61Cy3gO.cjs +0 -40
- package/dist/sign-B61Cy3gO.cjs.map +0 -1
- package/dist/sign-DzHK7UhR.js +0 -34
- package/dist/sign-DzHK7UhR.js.map +0 -1
- package/dist/signatures-BKi9DP2K.d.cts.map +0 -1
- package/dist/signatures-C9QPZTQd.d.ts.map +0 -1
- package/dist/state-codes-CxG1S9YY.d.ts.map +0 -1
- package/dist/state-codes-DXSWtE6a.d.cts.map +0 -1
- package/dist/tax-types-CEpfSh5P.d.ts.map +0 -1
- package/dist/tax-types-CgwxONDS.d.cts.map +0 -1
- package/dist/transform-BLz0S687.cjs +0 -72
- package/dist/transform-BLz0S687.cjs.map +0 -1
- package/dist/transform-D1q-U6Zj.js +0 -66
- package/dist/transform-D1q-U6Zj.js.map +0 -1
- package/dist/types/documents/index.d.ts +0 -57
- package/dist/types/documents/invoice-1_1.d.ts +0 -56
- package/dist/unit-types-1bF0KhIp.d.ts +0 -56
- package/dist/unit-types-1bF0KhIp.d.ts.map +0 -1
- package/dist/unit-types-CsrkvgfG.d.cts +0 -56
- package/dist/unit-types-CsrkvgfG.d.cts.map +0 -1
- package/dist/utils/MyInvoisClient.d.ts +0 -60
- package/dist/utils/MyInvoisClient.js +0 -13
- package/dist/utils/base64.d.ts.map +0 -1
- package/dist/utils/base64.js.map +0 -1
- package/dist/utils/debug/debug-document-hash.d.ts +0 -100
- package/dist/utils/debug/debug-document-hash.d.ts.map +0 -1
- package/dist/utils/debug/debug-document-hash.js +0 -120
- package/dist/utils/debug/debug-document-hash.js.map +0 -1
- package/dist/utils/debug/debug-invoice-submission.d.ts +0 -152
- package/dist/utils/debug/debug-invoice-submission.d.ts.map +0 -1
- package/dist/utils/debug/debug-invoice-submission.js +0 -226
- package/dist/utils/debug/debug-invoice-submission.js.map +0 -1
- package/dist/utils/getBaseUrl.d.ts.map +0 -1
- package/dist/utils/invoice1-1.d.ts +0 -117
- package/dist/utils/invoice1-1.d.ts.map +0 -1
- package/dist/utils/invoice1-1.js +0 -10
- package/dist/utils/signature/canonicalize.d.ts +0 -26
- package/dist/utils/signature/canonicalize.d.ts.map +0 -1
- package/dist/utils/signature/canonicalize.js +0 -3
- package/dist/utils/signature/hashCert.d.ts +0 -15
- package/dist/utils/signature/hashCert.d.ts.map +0 -1
- package/dist/utils/signature/hashCert.js +0 -3
- package/dist/utils/signature/hashSignedProperties.d.ts +0 -25
- package/dist/utils/signature/hashSignedProperties.d.ts.map +0 -1
- package/dist/utils/signature/hashSignedProperties.js +0 -3
- package/dist/utils/signature/populateFinalDocument.d.ts +0 -23
- package/dist/utils/signature/populateFinalDocument.d.ts.map +0 -1
- package/dist/utils/signature/populateFinalDocument.js +0 -3
- package/dist/utils/signature/populateSignedProperties.d.ts +0 -23
- package/dist/utils/signature/populateSignedProperties.d.ts.map +0 -1
- package/dist/utils/signature/populateSignedProperties.js +0 -3
- package/dist/utils/signature/sign.d.ts +0 -16
- package/dist/utils/signature/sign.d.ts.map +0 -1
- package/dist/utils/signature/sign.js +0 -3
- package/dist/utils/signature/transform.d.ts +0 -16
- package/dist/utils/signature/transform.d.ts.map +0 -1
- package/dist/utils/signature/transform.js +0 -3
- package/src/types/documents/index.d.ts +0 -1
- package/src/types/documents/invoice-1_1.d.ts +0 -439
- package/src/utils/MyInvoisClient.ts +0 -501
- package/src/utils/debug/debug-document-hash.ts +0 -249
- package/src/utils/debug/debug-invoice-submission.ts +0 -355
- package/src/utils/invoice1-1.ts +0 -671
- package/src/utils/signature/canonicalize.ts +0 -104
- package/src/utils/signature/hashCert.ts +0 -115
- package/src/utils/signature/hashSignedProperties.ts +0 -155
- package/src/utils/signature/populateFinalDocument.ts +0 -187
- package/src/utils/signature/populateSignedProperties.ts +0 -87
- package/src/utils/signature/sign.ts +0 -51
- package/src/utils/signature/transform.ts +0 -99
- package/test/canonicalize.test.ts +0 -110
- package/test/hashCert.test.ts +0 -95
- package/test/hashSignedProperties.test.ts +0 -140
- package/test/populateFinalDocument.test.ts +0 -218
- package/test/populateSignedProperties.test.ts +0 -155
- package/test/sign.test.ts +0 -70
- package/test/transform.test.ts +0 -158
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { EInvoiceTypeCode } from "./e-invoice-BuwtFnlI.cjs";
|
|
2
|
-
import { DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, InvoiceV1_1, SubmissionResponse, SubmissionStatus } from "./invoice-1_1-DWdNPRzr.cjs";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/MyInvoisClient.d.ts
|
|
5
|
-
declare class MyInvoisClient {
|
|
6
|
-
private readonly baseUrl;
|
|
7
|
-
private readonly clientId;
|
|
8
|
-
private readonly clientSecret;
|
|
9
|
-
private readonly onBehalfOf?;
|
|
10
|
-
private readonly debug;
|
|
11
|
-
private token;
|
|
12
|
-
private tokenExpiration;
|
|
13
|
-
constructor(clientId: string, clientSecret: string, environment: "sandbox" | "production", onBehalfOf?: string, debug?: boolean);
|
|
14
|
-
private refreshToken;
|
|
15
|
-
private getToken;
|
|
16
|
-
private fetch;
|
|
17
|
-
/**
|
|
18
|
-
* Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)
|
|
19
|
-
*
|
|
20
|
-
* @param tin - The TIN to validate
|
|
21
|
-
* @param idType - The type of ID to validate against
|
|
22
|
-
* @param idValue - The value of the ID to validate against
|
|
23
|
-
* @returns true if the TIN is valid, false otherwise
|
|
24
|
-
*/
|
|
25
|
-
verifyTin(tin: string, idType: "NRIC" | "ARMY" | "PASSPORT" | "BRN", idValue: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Submits one or more e-invoice documents to the MyInvois platform for processing.
|
|
28
|
-
*
|
|
29
|
-
* This method digitally signs each document using the provided certificate and private key,
|
|
30
|
-
* generates document hashes, encodes them for submission, and sends them to the platform.
|
|
31
|
-
* The method includes comprehensive validation warnings for document size and count limits.
|
|
32
|
-
*
|
|
33
|
-
* @param documents - Array of InvoiceV1_1 documents to be submitted
|
|
34
|
-
* @returns Promise resolving to submission response containing the submission data and HTTP status
|
|
35
|
-
* @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing
|
|
36
|
-
* @throws {Error} If document signing, encoding, or API submission fails
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* // Submit a single invoice
|
|
41
|
-
* const result = await client.submitDocument([invoiceData]);
|
|
42
|
-
* console.log(result.data.submissionUid); // Track submission with this UID
|
|
43
|
-
*
|
|
44
|
-
* // Submit multiple invoices
|
|
45
|
-
* const result = await client.submitDocument([invoice1, invoice2, invoice3]);
|
|
46
|
-
* if (result.status === 202) {
|
|
47
|
-
* console.log('Documents submitted successfully');
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing
|
|
53
|
-
* - Each document is digitally signed with XML-DSIG before submission
|
|
54
|
-
* - Documents are base64-encoded for transmission
|
|
55
|
-
* - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document
|
|
56
|
-
* - Debug mode provides detailed logging of payload sizes and validation warnings
|
|
57
|
-
* - Returns HTTP 202 for successful submissions that require processing
|
|
58
|
-
*/
|
|
59
|
-
submitDocument(documents: InvoiceV1_1[]): Promise<{
|
|
60
|
-
data: SubmissionResponse;
|
|
61
|
-
status: number;
|
|
62
|
-
}>;
|
|
63
|
-
getSubmissionStatus(submissionUid: string, pollInterval?: number, maxRetries?: number): Promise<{
|
|
64
|
-
status: SubmissionStatus;
|
|
65
|
-
documentSummary?: DocumentSummary[];
|
|
66
|
-
error?: {
|
|
67
|
-
code: string;
|
|
68
|
-
message: string | null;
|
|
69
|
-
target: string;
|
|
70
|
-
details: {
|
|
71
|
-
code: string;
|
|
72
|
-
message: string;
|
|
73
|
-
target: string;
|
|
74
|
-
}[];
|
|
75
|
-
};
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieves a document by its unique identifier with the raw document content.
|
|
79
|
-
*
|
|
80
|
-
* @param documentUid - The unique identifier of the document to retrieve
|
|
81
|
-
* @returns Promise resolving to document summary with raw document content as a string
|
|
82
|
-
* @throws {Error} If the document is not found or request fails
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const document = await client.getDocument('doc-uuid-123');
|
|
87
|
-
* console.log(document.document); // Raw XML/JSON content
|
|
88
|
-
* console.log(document.uuid); // Document UUID
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
getDocument(documentUid: string): Promise<DocumentSummary & {
|
|
92
|
-
document: string;
|
|
93
|
-
}>;
|
|
94
|
-
/**
|
|
95
|
-
* Retrieves detailed information about a document including validation results.
|
|
96
|
-
*
|
|
97
|
-
* @param documentUid - The unique identifier of the document to get details for
|
|
98
|
-
* @returns Promise resolving to document summary with detailed validation results
|
|
99
|
-
* @throws {Error} If the document is not found or request fails
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* const details = await client.getDocumentDetails('doc-uuid-123');
|
|
104
|
-
* console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'
|
|
105
|
-
* console.log(details.validationResults.validationSteps); // Array of validation step results
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
getDocumentDetails(documentUid: string): Promise<DocumentSummary & {
|
|
109
|
-
validationResults: {
|
|
110
|
-
status: DocumentValidationResult;
|
|
111
|
-
validationSteps: DocumentValidationStepResult[];
|
|
112
|
-
};
|
|
113
|
-
}>;
|
|
114
|
-
/**
|
|
115
|
-
* Searches for documents based on various filter criteria.
|
|
116
|
-
*
|
|
117
|
-
* @param params - Search parameters object
|
|
118
|
-
* @param params.uuid - Optional specific document UUID to search for
|
|
119
|
-
* @param params.submissionDateFrom - Required start date for submission date range (ISO date string)
|
|
120
|
-
* @param params.submissionDateTo - Optional end date for submission date range (ISO date string)
|
|
121
|
-
* @param params.pageSize - Optional number of results per page (default handled by API)
|
|
122
|
-
* @param params.pageNo - Optional page number for pagination (0-based)
|
|
123
|
-
* @param params.issueDateFrom - Optional start date for issue date range (ISO date string)
|
|
124
|
-
* @param params.issueDateTo - Optional end date for issue date range (ISO date string)
|
|
125
|
-
* @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')
|
|
126
|
-
* @param params.status - Optional filter by document status
|
|
127
|
-
* @param params.documentType - Optional filter by e-invoice type code
|
|
128
|
-
* @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total
|
|
129
|
-
* @returns Promise resolving to array of document summaries matching the search criteria
|
|
130
|
-
* @throws {Error} If the search request fails
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* // Search for documents submitted in the last 30 days
|
|
135
|
-
* const documents = await client.searchDocuments({
|
|
136
|
-
* submissionDateFrom: '2024-01-01',
|
|
137
|
-
* submissionDateTo: '2024-01-31',
|
|
138
|
-
* status: 'Valid',
|
|
139
|
-
* pageSize: 10
|
|
140
|
-
* });
|
|
141
|
-
*
|
|
142
|
-
* // Search by supplier name
|
|
143
|
-
* const supplierDocs = await client.searchDocuments({
|
|
144
|
-
* submissionDateFrom: '2024-01-01',
|
|
145
|
-
* searchQuery: 'ACME Corp',
|
|
146
|
-
* invoiceDirection: 'Received'
|
|
147
|
-
* });
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
searchDocuments({
|
|
151
|
-
uuid,
|
|
152
|
-
submissionDateFrom,
|
|
153
|
-
submissionDateTo,
|
|
154
|
-
pageSize,
|
|
155
|
-
pageNo,
|
|
156
|
-
issueDateFrom,
|
|
157
|
-
issueDateTo,
|
|
158
|
-
invoiceDirection,
|
|
159
|
-
status,
|
|
160
|
-
documentType,
|
|
161
|
-
searchQuery
|
|
162
|
-
}: {
|
|
163
|
-
uuid?: string;
|
|
164
|
-
submissionDateFrom: string;
|
|
165
|
-
submissionDateTo?: string;
|
|
166
|
-
pageSize?: number;
|
|
167
|
-
pageNo?: number;
|
|
168
|
-
issueDateFrom?: string;
|
|
169
|
-
issueDateTo?: string;
|
|
170
|
-
invoiceDirection?: "Sent" | "Received";
|
|
171
|
-
status?: DocumentStatus;
|
|
172
|
-
documentType?: EInvoiceTypeCode;
|
|
173
|
-
searchQuery?: string;
|
|
174
|
-
}): Promise<DocumentSummary[]>;
|
|
175
|
-
}
|
|
176
|
-
//#endregion
|
|
177
|
-
export { MyInvoisClient };
|
|
178
|
-
//# sourceMappingURL=MyInvoisClient-BrNyMjS-.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MyInvoisClient-BrNyMjS-.d.cts","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","onBehalfOf?: string","debug?: boolean","tin: string","idType: 'NRIC' | 'ARMY' | 'PASSPORT' | 'BRN'","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string"],"sources":["../src/utils/MyInvoisClient.ts"],"sourcesContent":[],"mappings":";;;;cAuBa,cAAA;EAAb,iBAAa,OAAA;EAAA,iBAAA,QAAA;EAAA,iBA2ER,YAAA;EAAA,iBAuD6B,UAAA;EAAA,iBACxB,KAAA;EAAA,QADwC,KAAA;EAAA,QAmHtC,eAAA;EAAA,WACU,CAAA,QAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,WAAA,EAAA,SAAA,GAAA,YAAA,EAAA,UAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,EAAA,OAAA;EAAA,QAFjB,YAAA;EAAA,QAyGQ,QAAA;EAAA,QAAR,KAAA;EAAA;;;;;;;;EAoFD,SACA,CAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,GAAA,MAAA,GAAA,UAAA,GAAA,KAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EAvWC,OAuWD,CAAA,OAAA,CAAA;EAAA;;;;;;;;;;AAmBE;;;;;;;;;;;;;;;;;;;;;;;4BAnU4B,gBAAgB;UACxC;;;0FAiHL;YACO;sBACU;;;;;;;;;;;;;;;;;;;;;;;;;;oCAuGjB,QAAQ;;;;;;;;;;;;;;;;;2CAsBoC,QAC7C;;cAEY;uBACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2EZ;mBACM;;MAEb,QAAQ"}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { EInvoiceTypeCode } from "./e-invoice-C2TxhyrK.js";
|
|
2
|
-
import { DocumentStatus, DocumentSummary, DocumentValidationResult, DocumentValidationStepResult, InvoiceV1_1, SubmissionResponse, SubmissionStatus } from "./invoice-1_1-BJVcw-oE.js";
|
|
3
|
-
|
|
4
|
-
//#region src/utils/MyInvoisClient.d.ts
|
|
5
|
-
declare class MyInvoisClient {
|
|
6
|
-
private readonly baseUrl;
|
|
7
|
-
private readonly clientId;
|
|
8
|
-
private readonly clientSecret;
|
|
9
|
-
private readonly onBehalfOf?;
|
|
10
|
-
private readonly debug;
|
|
11
|
-
private token;
|
|
12
|
-
private tokenExpiration;
|
|
13
|
-
constructor(clientId: string, clientSecret: string, environment: "sandbox" | "production", onBehalfOf?: string, debug?: boolean);
|
|
14
|
-
private refreshToken;
|
|
15
|
-
private getToken;
|
|
16
|
-
private fetch;
|
|
17
|
-
/**
|
|
18
|
-
* Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)
|
|
19
|
-
*
|
|
20
|
-
* @param tin - The TIN to validate
|
|
21
|
-
* @param idType - The type of ID to validate against
|
|
22
|
-
* @param idValue - The value of the ID to validate against
|
|
23
|
-
* @returns true if the TIN is valid, false otherwise
|
|
24
|
-
*/
|
|
25
|
-
verifyTin(tin: string, idType: "NRIC" | "ARMY" | "PASSPORT" | "BRN", idValue: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Submits one or more e-invoice documents to the MyInvois platform for processing.
|
|
28
|
-
*
|
|
29
|
-
* This method digitally signs each document using the provided certificate and private key,
|
|
30
|
-
* generates document hashes, encodes them for submission, and sends them to the platform.
|
|
31
|
-
* The method includes comprehensive validation warnings for document size and count limits.
|
|
32
|
-
*
|
|
33
|
-
* @param documents - Array of InvoiceV1_1 documents to be submitted
|
|
34
|
-
* @returns Promise resolving to submission response containing the submission data and HTTP status
|
|
35
|
-
* @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing
|
|
36
|
-
* @throws {Error} If document signing, encoding, or API submission fails
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* // Submit a single invoice
|
|
41
|
-
* const result = await client.submitDocument([invoiceData]);
|
|
42
|
-
* console.log(result.data.submissionUid); // Track submission with this UID
|
|
43
|
-
*
|
|
44
|
-
* // Submit multiple invoices
|
|
45
|
-
* const result = await client.submitDocument([invoice1, invoice2, invoice3]);
|
|
46
|
-
* if (result.status === 202) {
|
|
47
|
-
* console.log('Documents submitted successfully');
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @remarks
|
|
52
|
-
* - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing
|
|
53
|
-
* - Each document is digitally signed with XML-DSIG before submission
|
|
54
|
-
* - Documents are base64-encoded for transmission
|
|
55
|
-
* - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document
|
|
56
|
-
* - Debug mode provides detailed logging of payload sizes and validation warnings
|
|
57
|
-
* - Returns HTTP 202 for successful submissions that require processing
|
|
58
|
-
*/
|
|
59
|
-
submitDocument(documents: InvoiceV1_1[]): Promise<{
|
|
60
|
-
data: SubmissionResponse;
|
|
61
|
-
status: number;
|
|
62
|
-
}>;
|
|
63
|
-
getSubmissionStatus(submissionUid: string, pollInterval?: number, maxRetries?: number): Promise<{
|
|
64
|
-
status: SubmissionStatus;
|
|
65
|
-
documentSummary?: DocumentSummary[];
|
|
66
|
-
error?: {
|
|
67
|
-
code: string;
|
|
68
|
-
message: string | null;
|
|
69
|
-
target: string;
|
|
70
|
-
details: {
|
|
71
|
-
code: string;
|
|
72
|
-
message: string;
|
|
73
|
-
target: string;
|
|
74
|
-
}[];
|
|
75
|
-
};
|
|
76
|
-
}>;
|
|
77
|
-
/**
|
|
78
|
-
* Retrieves a document by its unique identifier with the raw document content.
|
|
79
|
-
*
|
|
80
|
-
* @param documentUid - The unique identifier of the document to retrieve
|
|
81
|
-
* @returns Promise resolving to document summary with raw document content as a string
|
|
82
|
-
* @throws {Error} If the document is not found or request fails
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const document = await client.getDocument('doc-uuid-123');
|
|
87
|
-
* console.log(document.document); // Raw XML/JSON content
|
|
88
|
-
* console.log(document.uuid); // Document UUID
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
getDocument(documentUid: string): Promise<DocumentSummary & {
|
|
92
|
-
document: string;
|
|
93
|
-
}>;
|
|
94
|
-
/**
|
|
95
|
-
* Retrieves detailed information about a document including validation results.
|
|
96
|
-
*
|
|
97
|
-
* @param documentUid - The unique identifier of the document to get details for
|
|
98
|
-
* @returns Promise resolving to document summary with detailed validation results
|
|
99
|
-
* @throws {Error} If the document is not found or request fails
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```typescript
|
|
103
|
-
* const details = await client.getDocumentDetails('doc-uuid-123');
|
|
104
|
-
* console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'
|
|
105
|
-
* console.log(details.validationResults.validationSteps); // Array of validation step results
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
getDocumentDetails(documentUid: string): Promise<DocumentSummary & {
|
|
109
|
-
validationResults: {
|
|
110
|
-
status: DocumentValidationResult;
|
|
111
|
-
validationSteps: DocumentValidationStepResult[];
|
|
112
|
-
};
|
|
113
|
-
}>;
|
|
114
|
-
/**
|
|
115
|
-
* Searches for documents based on various filter criteria.
|
|
116
|
-
*
|
|
117
|
-
* @param params - Search parameters object
|
|
118
|
-
* @param params.uuid - Optional specific document UUID to search for
|
|
119
|
-
* @param params.submissionDateFrom - Required start date for submission date range (ISO date string)
|
|
120
|
-
* @param params.submissionDateTo - Optional end date for submission date range (ISO date string)
|
|
121
|
-
* @param params.pageSize - Optional number of results per page (default handled by API)
|
|
122
|
-
* @param params.pageNo - Optional page number for pagination (0-based)
|
|
123
|
-
* @param params.issueDateFrom - Optional start date for issue date range (ISO date string)
|
|
124
|
-
* @param params.issueDateTo - Optional end date for issue date range (ISO date string)
|
|
125
|
-
* @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')
|
|
126
|
-
* @param params.status - Optional filter by document status
|
|
127
|
-
* @param params.documentType - Optional filter by e-invoice type code
|
|
128
|
-
* @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total
|
|
129
|
-
* @returns Promise resolving to array of document summaries matching the search criteria
|
|
130
|
-
* @throws {Error} If the search request fails
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* // Search for documents submitted in the last 30 days
|
|
135
|
-
* const documents = await client.searchDocuments({
|
|
136
|
-
* submissionDateFrom: '2024-01-01',
|
|
137
|
-
* submissionDateTo: '2024-01-31',
|
|
138
|
-
* status: 'Valid',
|
|
139
|
-
* pageSize: 10
|
|
140
|
-
* });
|
|
141
|
-
*
|
|
142
|
-
* // Search by supplier name
|
|
143
|
-
* const supplierDocs = await client.searchDocuments({
|
|
144
|
-
* submissionDateFrom: '2024-01-01',
|
|
145
|
-
* searchQuery: 'ACME Corp',
|
|
146
|
-
* invoiceDirection: 'Received'
|
|
147
|
-
* });
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
searchDocuments({
|
|
151
|
-
uuid,
|
|
152
|
-
submissionDateFrom,
|
|
153
|
-
submissionDateTo,
|
|
154
|
-
pageSize,
|
|
155
|
-
pageNo,
|
|
156
|
-
issueDateFrom,
|
|
157
|
-
issueDateTo,
|
|
158
|
-
invoiceDirection,
|
|
159
|
-
status,
|
|
160
|
-
documentType,
|
|
161
|
-
searchQuery
|
|
162
|
-
}: {
|
|
163
|
-
uuid?: string;
|
|
164
|
-
submissionDateFrom: string;
|
|
165
|
-
submissionDateTo?: string;
|
|
166
|
-
pageSize?: number;
|
|
167
|
-
pageNo?: number;
|
|
168
|
-
issueDateFrom?: string;
|
|
169
|
-
issueDateTo?: string;
|
|
170
|
-
invoiceDirection?: "Sent" | "Received";
|
|
171
|
-
status?: DocumentStatus;
|
|
172
|
-
documentType?: EInvoiceTypeCode;
|
|
173
|
-
searchQuery?: string;
|
|
174
|
-
}): Promise<DocumentSummary[]>;
|
|
175
|
-
}
|
|
176
|
-
//#endregion
|
|
177
|
-
export { MyInvoisClient };
|
|
178
|
-
//# sourceMappingURL=MyInvoisClient-CXu4pdl-.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MyInvoisClient-CXu4pdl-.d.ts","names":["clientId: string","clientSecret: string","environment: 'sandbox' | 'production'","onBehalfOf?: string","debug?: boolean","tin: string","idType: 'NRIC' | 'ARMY' | 'PASSPORT' | 'BRN'","idValue: string","documents: InvoiceV1_1[]","submissionUid: string","pollInterval: number","maxRetries: number","documentUid: string"],"sources":["../src/utils/MyInvoisClient.ts"],"sourcesContent":[],"mappings":";;;;cAuBa,cAAA;EAAb,iBAAa,OAAA;EAAA,iBAAA,QAAA;EAAA,iBA2ER,YAAA;EAAA,iBAuD6B,UAAA;EAAA,iBACxB,KAAA;EAAA,QADwC,KAAA;EAAA,QAmHtC,eAAA;EAAA,WACU,CAAA,QAAA,EAAA,MAAA,EAAA,YAAA,EAAA,MAAA,EAAA,WAAA,EAAA,SAAA,GAAA,YAAA,EAAA,UAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,EAAA,OAAA;EAAA,QAFjB,YAAA;EAAA,QAyGQ,QAAA;EAAA,QAAR,KAAA;EAAA;;;;;;;;EAoFD,SACA,CAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,GAAA,MAAA,GAAA,UAAA,GAAA,KAAA,EAAA,OAAA,EAAA,MAAA,CAAA,EAvWC,OAuWD,CAAA,OAAA,CAAA;EAAA;;;;;;;;;;AAmBE;;;;;;;;;;;;;;;;;;;;;;;4BAnU4B,gBAAgB;UACxC;;;0FAiHL;YACO;sBACU;;;;;;;;;;;;;;;;;;;;;;;;;;oCAuGjB,QAAQ;;;;;;;;;;;;;;;;;2CAsBoC,QAC7C;;cAEY;uBACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA2EZ;mBACM;;MAEb,QAAQ"}
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { createSigningCredentials, encodeDocumentForSubmission, generateDocumentHash, generateSignedInvoiceXML } from "./invoice1-1-CHuLpkFz.js";
|
|
2
|
-
import { platformLogin } from "./platformLogin-DsxWWUXr.js";
|
|
3
|
-
import { getBaseUrl } from "./getBaseUrl-Dx6RDC8I.js";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/MyInvoisClient.ts
|
|
6
|
-
var MyInvoisClient = class {
|
|
7
|
-
baseUrl;
|
|
8
|
-
clientId;
|
|
9
|
-
clientSecret;
|
|
10
|
-
onBehalfOf;
|
|
11
|
-
debug;
|
|
12
|
-
token = "";
|
|
13
|
-
tokenExpiration = void 0;
|
|
14
|
-
constructor(clientId, clientSecret, environment, onBehalfOf, debug) {
|
|
15
|
-
this.clientId = clientId;
|
|
16
|
-
this.clientSecret = clientSecret;
|
|
17
|
-
this.baseUrl = getBaseUrl(environment);
|
|
18
|
-
this.debug = debug ?? process.env.MYINVOIS_DEBUG === "true" ? true : false;
|
|
19
|
-
this.onBehalfOf = onBehalfOf;
|
|
20
|
-
}
|
|
21
|
-
async refreshToken() {
|
|
22
|
-
const tokenResponse = await platformLogin({
|
|
23
|
-
clientId: this.clientId,
|
|
24
|
-
clientSecret: this.clientSecret,
|
|
25
|
-
baseUrl: this.baseUrl,
|
|
26
|
-
onBehalfOf: this.onBehalfOf,
|
|
27
|
-
debug: this.debug
|
|
28
|
-
});
|
|
29
|
-
this.token = tokenResponse.token;
|
|
30
|
-
this.tokenExpiration = tokenResponse.tokenExpiration;
|
|
31
|
-
}
|
|
32
|
-
async getToken() {
|
|
33
|
-
if (!this.tokenExpiration || this.tokenExpiration < /* @__PURE__ */ new Date() || isNaN(this.tokenExpiration.getTime())) {
|
|
34
|
-
if (this.debug) console.log("Token expired");
|
|
35
|
-
if (this.debug) console.log("Refreshing token");
|
|
36
|
-
await this.refreshToken();
|
|
37
|
-
}
|
|
38
|
-
return this.token;
|
|
39
|
-
}
|
|
40
|
-
async fetch(path, options = {}) {
|
|
41
|
-
const token = await this.getToken();
|
|
42
|
-
return fetch(`${this.baseUrl}${path}`, {
|
|
43
|
-
...options,
|
|
44
|
-
headers: {
|
|
45
|
-
...options.headers,
|
|
46
|
-
Authorization: `Bearer ${token}`
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Validates a TIN against a NRIC/ARMY/PASSPORT/BRN (Business Registration Number)
|
|
52
|
-
*
|
|
53
|
-
* @param tin - The TIN to validate
|
|
54
|
-
* @param idType - The type of ID to validate against
|
|
55
|
-
* @param idValue - The value of the ID to validate against
|
|
56
|
-
* @returns true if the TIN is valid, false otherwise
|
|
57
|
-
*/
|
|
58
|
-
async verifyTin(tin, idType, idValue) {
|
|
59
|
-
try {
|
|
60
|
-
const response = await this.fetch(`/api/v1.0/taxpayer/validate/${tin}?idType=${idType}&idValue=${idValue}`, { method: "GET" });
|
|
61
|
-
if (response.status === 200) return true;
|
|
62
|
-
return false;
|
|
63
|
-
} catch (error) {
|
|
64
|
-
if (this.debug) console.error(error);
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Submits one or more e-invoice documents to the MyInvois platform for processing.
|
|
70
|
-
*
|
|
71
|
-
* This method digitally signs each document using the provided certificate and private key,
|
|
72
|
-
* generates document hashes, encodes them for submission, and sends them to the platform.
|
|
73
|
-
* The method includes comprehensive validation warnings for document size and count limits.
|
|
74
|
-
*
|
|
75
|
-
* @param documents - Array of InvoiceV1_1 documents to be submitted
|
|
76
|
-
* @returns Promise resolving to submission response containing the submission data and HTTP status
|
|
77
|
-
* @throws {Error} If PRIVATE_KEY or CERTIFICATE environment variables are missing
|
|
78
|
-
* @throws {Error} If document signing, encoding, or API submission fails
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```typescript
|
|
82
|
-
* // Submit a single invoice
|
|
83
|
-
* const result = await client.submitDocument([invoiceData]);
|
|
84
|
-
* console.log(result.data.submissionUid); // Track submission with this UID
|
|
85
|
-
*
|
|
86
|
-
* // Submit multiple invoices
|
|
87
|
-
* const result = await client.submitDocument([invoice1, invoice2, invoice3]);
|
|
88
|
-
* if (result.status === 202) {
|
|
89
|
-
* console.log('Documents submitted successfully');
|
|
90
|
-
* }
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @remarks
|
|
94
|
-
* - Requires PRIVATE_KEY and CERTIFICATE environment variables for document signing
|
|
95
|
-
* - Each document is digitally signed with XML-DSIG before submission
|
|
96
|
-
* - Documents are base64-encoded for transmission
|
|
97
|
-
* - API limits: Max 100 documents per submission, 5MB total payload, 300KB per document
|
|
98
|
-
* - Debug mode provides detailed logging of payload sizes and validation warnings
|
|
99
|
-
* - Returns HTTP 202 for successful submissions that require processing
|
|
100
|
-
*/
|
|
101
|
-
async submitDocument(documents) {
|
|
102
|
-
if (!process.env.PRIVATE_KEY || !process.env.CERTIFICATE) throw new Error("Missing required environment variables: PRIVATE_KEY and CERTIFICATE");
|
|
103
|
-
const signingCredentials = createSigningCredentials(process.env.CERTIFICATE, process.env.PRIVATE_KEY);
|
|
104
|
-
const signedDocuments = await Promise.all(documents.map(async (d) => {
|
|
105
|
-
const signedXML = await generateSignedInvoiceXML(d, signingCredentials);
|
|
106
|
-
const documentHash = generateDocumentHash(signedXML);
|
|
107
|
-
const base64Document = encodeDocumentForSubmission(signedXML);
|
|
108
|
-
return {
|
|
109
|
-
format: "XML",
|
|
110
|
-
document: base64Document,
|
|
111
|
-
documentHash,
|
|
112
|
-
codeNumber: d.eInvoiceCodeOrNumber
|
|
113
|
-
};
|
|
114
|
-
}));
|
|
115
|
-
try {
|
|
116
|
-
const payload = { documents: signedDocuments };
|
|
117
|
-
if (this.debug) {
|
|
118
|
-
console.log("Submitting payload structure:");
|
|
119
|
-
console.log(JSON.stringify({ documents: signedDocuments.map((doc) => ({
|
|
120
|
-
format: doc.format,
|
|
121
|
-
codeNumber: doc.codeNumber,
|
|
122
|
-
documentHash: doc.documentHash,
|
|
123
|
-
documentSize: doc.document.length
|
|
124
|
-
})) }, null, 2));
|
|
125
|
-
const totalSize = JSON.stringify(payload).length;
|
|
126
|
-
console.log(`Total payload size: ${totalSize} bytes (${(totalSize / 1024 / 1024).toFixed(2)} MB)`);
|
|
127
|
-
console.log(`Number of documents: ${signedDocuments.length}`);
|
|
128
|
-
signedDocuments.forEach((doc, index) => {
|
|
129
|
-
const docSize = Buffer.from(doc.document, "base64").length;
|
|
130
|
-
console.log(`Document ${index + 1}: ${docSize} bytes (${(docSize / 1024).toFixed(2)} KB)`);
|
|
131
|
-
});
|
|
132
|
-
if (totalSize > 5 * 1024 * 1024) console.warn("⚠️ WARNING: Payload exceeds 5MB limit!");
|
|
133
|
-
if (signedDocuments.length > 100) console.warn("⚠️ WARNING: More than 100 documents in submission!");
|
|
134
|
-
signedDocuments.forEach((doc, index) => {
|
|
135
|
-
const docSize = Buffer.from(doc.document, "base64").length;
|
|
136
|
-
if (docSize > 300 * 1024) console.warn(`⚠️ WARNING: Document ${index + 1} exceeds 300KB limit!`);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
const response = await this.fetch(`/api/v1.0/documentsubmissions`, {
|
|
140
|
-
method: "POST",
|
|
141
|
-
headers: { "Content-Type": "application/json" },
|
|
142
|
-
body: JSON.stringify(payload)
|
|
143
|
-
});
|
|
144
|
-
const responseBody = await response.json();
|
|
145
|
-
if (this.debug) {
|
|
146
|
-
console.log("API Response Status:", response.status);
|
|
147
|
-
console.log("API Response Headers:", Object.fromEntries(response.headers.entries()));
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
data: responseBody,
|
|
151
|
-
status: response.status
|
|
152
|
-
};
|
|
153
|
-
} catch (error) {
|
|
154
|
-
console.error(error);
|
|
155
|
-
throw error;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
async getSubmissionStatus(submissionUid, pollInterval = 1e3, maxRetries = 10) {
|
|
159
|
-
try {
|
|
160
|
-
const response = await this.fetch(`/api/v1.0/documentsubmissions/${submissionUid}`);
|
|
161
|
-
const data = await response.json();
|
|
162
|
-
if (this.debug) {
|
|
163
|
-
console.log("Submission:", data);
|
|
164
|
-
if (data.error) console.log("Submission error details:", data.error.details);
|
|
165
|
-
}
|
|
166
|
-
if (data.overallStatus === "Valid") return {
|
|
167
|
-
status: data.overallStatus,
|
|
168
|
-
documentSummary: data.documentSummary
|
|
169
|
-
};
|
|
170
|
-
if (data.overallStatus === "Invalid") return {
|
|
171
|
-
status: "Invalid",
|
|
172
|
-
documentSummary: data.documentSummary
|
|
173
|
-
};
|
|
174
|
-
if (maxRetries > 0) {
|
|
175
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
176
|
-
return await this.getSubmissionStatus(submissionUid, pollInterval, maxRetries - 1);
|
|
177
|
-
}
|
|
178
|
-
return {
|
|
179
|
-
status: "Invalid",
|
|
180
|
-
error: {
|
|
181
|
-
code: "Timeout",
|
|
182
|
-
message: "Submission timed out",
|
|
183
|
-
target: "submission",
|
|
184
|
-
details: []
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
} catch (error) {
|
|
188
|
-
if (maxRetries > 0) {
|
|
189
|
-
if (this.debug) console.log("Request error, retrying...", error);
|
|
190
|
-
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
191
|
-
return await this.getSubmissionStatus(submissionUid, pollInterval, maxRetries - 1);
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
status: "Invalid",
|
|
195
|
-
error: {
|
|
196
|
-
code: "Timeout",
|
|
197
|
-
message: "Submission timed out after request errors",
|
|
198
|
-
target: "submission",
|
|
199
|
-
details: []
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Retrieves a document by its unique identifier with the raw document content.
|
|
206
|
-
*
|
|
207
|
-
* @param documentUid - The unique identifier of the document to retrieve
|
|
208
|
-
* @returns Promise resolving to document summary with raw document content as a string
|
|
209
|
-
* @throws {Error} If the document is not found or request fails
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* ```typescript
|
|
213
|
-
* const document = await client.getDocument('doc-uuid-123');
|
|
214
|
-
* console.log(document.document); // Raw XML/JSON content
|
|
215
|
-
* console.log(document.uuid); // Document UUID
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
async getDocument(documentUid) {
|
|
219
|
-
const response = await this.fetch(`/api/v1.0/documents/${documentUid}/raw`);
|
|
220
|
-
const data = await response.json();
|
|
221
|
-
return data;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Retrieves detailed information about a document including validation results.
|
|
225
|
-
*
|
|
226
|
-
* @param documentUid - The unique identifier of the document to get details for
|
|
227
|
-
* @returns Promise resolving to document summary with detailed validation results
|
|
228
|
-
* @throws {Error} If the document is not found or request fails
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* const details = await client.getDocumentDetails('doc-uuid-123');
|
|
233
|
-
* console.log(details.validationResults.status); // 'Valid' | 'Invalid' | 'Processing'
|
|
234
|
-
* console.log(details.validationResults.validationSteps); // Array of validation step results
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
async getDocumentDetails(documentUid) {
|
|
238
|
-
const response = await this.fetch(`/api/v1.0/documents/${documentUid}/details`);
|
|
239
|
-
const data = await response.json();
|
|
240
|
-
return data;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Searches for documents based on various filter criteria.
|
|
244
|
-
*
|
|
245
|
-
* @param params - Search parameters object
|
|
246
|
-
* @param params.uuid - Optional specific document UUID to search for
|
|
247
|
-
* @param params.submissionDateFrom - Required start date for submission date range (ISO date string)
|
|
248
|
-
* @param params.submissionDateTo - Optional end date for submission date range (ISO date string)
|
|
249
|
-
* @param params.pageSize - Optional number of results per page (default handled by API)
|
|
250
|
-
* @param params.pageNo - Optional page number for pagination (0-based)
|
|
251
|
-
* @param params.issueDateFrom - Optional start date for issue date range (ISO date string)
|
|
252
|
-
* @param params.issueDateTo - Optional end date for issue date range (ISO date string)
|
|
253
|
-
* @param params.invoiceDirection - Optional filter by invoice direction ('Sent' or 'Received')
|
|
254
|
-
* @param params.status - Optional filter by document status
|
|
255
|
-
* @param params.documentType - Optional filter by e-invoice type code
|
|
256
|
-
* @param params.searchQuery - Optional text search across uuid, buyerTIN, supplierTIN, buyerName, supplierName, internalID, total
|
|
257
|
-
* @returns Promise resolving to array of document summaries matching the search criteria
|
|
258
|
-
* @throws {Error} If the search request fails
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```typescript
|
|
262
|
-
* // Search for documents submitted in the last 30 days
|
|
263
|
-
* const documents = await client.searchDocuments({
|
|
264
|
-
* submissionDateFrom: '2024-01-01',
|
|
265
|
-
* submissionDateTo: '2024-01-31',
|
|
266
|
-
* status: 'Valid',
|
|
267
|
-
* pageSize: 10
|
|
268
|
-
* });
|
|
269
|
-
*
|
|
270
|
-
* // Search by supplier name
|
|
271
|
-
* const supplierDocs = await client.searchDocuments({
|
|
272
|
-
* submissionDateFrom: '2024-01-01',
|
|
273
|
-
* searchQuery: 'ACME Corp',
|
|
274
|
-
* invoiceDirection: 'Received'
|
|
275
|
-
* });
|
|
276
|
-
* ```
|
|
277
|
-
*/
|
|
278
|
-
async searchDocuments({ uuid, submissionDateFrom, submissionDateTo, pageSize, pageNo, issueDateFrom, issueDateTo, invoiceDirection, status, documentType, searchQuery }) {
|
|
279
|
-
const queryParams = new URLSearchParams();
|
|
280
|
-
if (uuid) queryParams.set("uuid", uuid);
|
|
281
|
-
if (submissionDateFrom) queryParams.set("submissionDateFrom", submissionDateFrom);
|
|
282
|
-
if (submissionDateTo) queryParams.set("submissionDateTo", submissionDateTo);
|
|
283
|
-
if (pageSize) queryParams.set("pageSize", pageSize.toString());
|
|
284
|
-
if (pageNo) queryParams.set("pageNo", pageNo.toString());
|
|
285
|
-
if (issueDateFrom) queryParams.set("issueDateFrom", issueDateFrom);
|
|
286
|
-
if (issueDateTo) queryParams.set("issueDateTo", issueDateTo);
|
|
287
|
-
if (invoiceDirection) queryParams.set("invoiceDirection", invoiceDirection);
|
|
288
|
-
if (status) queryParams.set("status", status);
|
|
289
|
-
if (documentType) queryParams.set("documentType", documentType);
|
|
290
|
-
if (searchQuery) queryParams.set("searchQuery", searchQuery);
|
|
291
|
-
const response = await this.fetch(`/api/v1.0/documents/search?${queryParams.toString()}`);
|
|
292
|
-
const data = await response.json();
|
|
293
|
-
return data;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
//#endregion
|
|
298
|
-
export { MyInvoisClient };
|
|
299
|
-
//# sourceMappingURL=MyInvoisClient-Cnvb5iUC.js.map
|