solve-engine 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -17
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.cts → BytecodeBuilder-DGGeByAP.d.cts} +18 -0
- package/dist/{BytecodeBuilder-Bp9xeTmX.d.ts → BytecodeBuilder-DGGeByAP.d.ts} +18 -0
- package/dist/{Configuration-C9W8tJv_.d.cts → Configuration-B6W0-T67.d.cts} +17 -4
- package/dist/{Configuration-C9W8tJv_.d.ts → Configuration-B6W0-T67.d.ts} +17 -4
- package/dist/{EngineError-B61GS1jp.d.cts → EngineError-Ce1lPkjZ.d.cts} +8 -0
- package/dist/{EngineError-B61GS1jp.d.ts → EngineError-Ce1lPkjZ.d.ts} +8 -0
- package/dist/{Lexer-BOs7euZe.d.cts → Lexer-B4C1qHXu.d.cts} +1 -1
- package/dist/{Lexer-CSI_lwbW.d.ts → Lexer-DKMlj7Sy.d.ts} +1 -1
- package/dist/{PackageCompatibility-B-7rK1TD.d.cts → PackageCompatibility-Bn5jnBtA.d.cts} +2 -2
- package/dist/{PackageCompatibility-Dh59eF-X.d.ts → PackageCompatibility-CIvq2MP5.d.ts} +2 -2
- package/dist/{PackageRegistry-_8rDlvxI.d.ts → PackageRegistry-DzeiWcv4.d.ts} +143 -175
- package/dist/{PackageRegistry-BHWJP83F.d.cts → PackageRegistry-dpdurBVO.d.cts} +143 -175
- package/dist/{Parselet-BBT8riYh.d.ts → Parselet-B-zoPrTa.d.ts} +9 -6
- package/dist/{Parselet-BHcgK9S7.d.cts → Parselet-C4Wu055_.d.cts} +9 -6
- package/dist/{ScopeManager-CxA24W5n.d.ts → ScopeManager-C2LDOrDx.d.ts} +14 -16
- package/dist/{ScopeManager-8vf02dwj.d.cts → ScopeManager-D7uMXbhS.d.cts} +14 -16
- package/dist/{Token-B1hdkedD.d.cts → Token-CbP_OutD.d.cts} +9 -0
- package/dist/{Token-B1hdkedD.d.ts → Token-CbP_OutD.d.ts} +9 -0
- package/dist/{TokenNormalizer-C6VzZgHa.d.ts → TokenNormalizer-DCWdZjGz.d.ts} +1 -1
- package/dist/{TokenNormalizer-DRc1Js1V.d.cts → TokenNormalizer-DnlL7_8c.d.cts} +1 -1
- package/dist/{VMCheckpoints-MK--EBH2.d.ts → VMCheckpoints-CGyFhivM.d.ts} +3 -3
- package/dist/{VMCheckpoints-ELYqITdF.d.cts → VMCheckpoints-I9jg3jWR.d.cts} +3 -3
- package/dist/{Value-BUi1RA3S.d.cts → Value-CCi_Eecs.d.cts} +72 -5
- package/dist/{Value-BUi1RA3S.d.ts → Value-CCi_Eecs.d.ts} +72 -5
- package/dist/{WorkerError-gzmaopj2.d.cts → WorkerError-B4p6PNfx.d.cts} +1 -1
- package/dist/{WorkerError-_-RkoQ5P.d.ts → WorkerError-Dhj9BQ_A.d.ts} +1 -1
- package/dist/chunk-2JMFUQZH.js +2 -0
- package/dist/chunk-2JMFUQZH.js.map +1 -0
- package/dist/chunk-2RWAXT6O.js +0 -1
- package/dist/chunk-4BZIYU7S.cjs +3 -0
- package/dist/chunk-4BZIYU7S.cjs.map +1 -0
- package/dist/chunk-4J7XZSZJ.cjs +5 -0
- package/dist/chunk-4J7XZSZJ.cjs.map +1 -0
- package/dist/chunk-4QVBSG6B.cjs +2 -0
- package/dist/chunk-4QVBSG6B.cjs.map +1 -0
- package/dist/chunk-5IJD5L3O.cjs +2 -0
- package/dist/chunk-5IJD5L3O.cjs.map +1 -0
- package/dist/chunk-62LMTO4F.js +2 -0
- package/dist/chunk-62LMTO4F.js.map +1 -0
- package/dist/chunk-6CY44ZPG.js +2 -0
- package/dist/chunk-6CY44ZPG.js.map +1 -0
- package/dist/chunk-6G3PMEPA.js +2 -0
- package/dist/chunk-6G3PMEPA.js.map +1 -0
- package/dist/chunk-6INX773F.cjs +2 -0
- package/dist/chunk-6INX773F.cjs.map +1 -0
- package/dist/chunk-6KFVG6UY.cjs +2 -0
- package/dist/chunk-6KFVG6UY.cjs.map +1 -0
- package/dist/chunk-76F3LCIL.js +4 -0
- package/dist/chunk-76F3LCIL.js.map +1 -0
- package/dist/chunk-7GK3XEZF.js +2 -0
- package/dist/chunk-7GK3XEZF.js.map +1 -0
- package/dist/chunk-APN442VD.cjs +2 -0
- package/dist/chunk-APN442VD.cjs.map +1 -0
- package/dist/chunk-AXMQG5TS.cjs +2 -0
- package/dist/chunk-AXMQG5TS.cjs.map +1 -0
- package/dist/chunk-CIQOK7Q4.cjs +2 -0
- package/dist/chunk-CIQOK7Q4.cjs.map +1 -0
- package/dist/chunk-E6Z4NQAS.js +2 -0
- package/dist/chunk-E6Z4NQAS.js.map +1 -0
- package/dist/chunk-EFJCC6FJ.cjs +2 -0
- package/dist/chunk-EFJCC6FJ.cjs.map +1 -0
- package/dist/chunk-ESUN2THE.cjs +2 -0
- package/dist/chunk-ESUN2THE.cjs.map +1 -0
- package/dist/chunk-EVAOPEO4.js +2 -0
- package/dist/chunk-EVAOPEO4.js.map +1 -0
- package/dist/chunk-EYRBENHC.js +3 -0
- package/dist/chunk-EYRBENHC.js.map +1 -0
- package/dist/chunk-FDE5HWDI.cjs +2 -0
- package/dist/chunk-FDE5HWDI.cjs.map +1 -0
- package/dist/chunk-FWW3M36J.cjs +2 -0
- package/dist/chunk-FWW3M36J.cjs.map +1 -0
- package/dist/chunk-GOIQYUWV.js +2 -0
- package/dist/chunk-GOIQYUWV.js.map +1 -0
- package/dist/chunk-HFKDWQUL.js +2 -0
- package/dist/chunk-HFKDWQUL.js.map +1 -0
- package/dist/chunk-HLBYHXQD.cjs +3 -0
- package/dist/chunk-HLBYHXQD.cjs.map +1 -0
- package/dist/chunk-IANAMBJQ.cjs +2 -0
- package/dist/chunk-IANAMBJQ.cjs.map +1 -0
- package/dist/chunk-IJMNVBIS.js +2 -0
- package/dist/chunk-IJMNVBIS.js.map +1 -0
- package/dist/chunk-J4LZD4ZY.js +3 -0
- package/dist/chunk-J4LZD4ZY.js.map +1 -0
- package/dist/chunk-JAK3RAFA.cjs +2 -0
- package/dist/chunk-JAK3RAFA.cjs.map +1 -0
- package/dist/chunk-JFAJN3C2.cjs +2 -0
- package/dist/chunk-JFAJN3C2.cjs.map +1 -0
- package/dist/chunk-JPFCXLJV.js +2 -0
- package/dist/chunk-JPFCXLJV.js.map +1 -0
- package/dist/chunk-JSPKKNPQ.js +3 -0
- package/dist/chunk-JSPKKNPQ.js.map +1 -0
- package/dist/chunk-L3FPQSGN.js +2 -0
- package/dist/chunk-L3FPQSGN.js.map +1 -0
- package/dist/chunk-LR4E4A4W.cjs +2 -0
- package/dist/chunk-LR4E4A4W.cjs.map +1 -0
- package/dist/chunk-MIQBJGGR.js +2 -0
- package/dist/chunk-MIQBJGGR.js.map +1 -0
- package/dist/chunk-MPB7KUN5.js +3 -0
- package/dist/chunk-MPB7KUN5.js.map +1 -0
- package/dist/chunk-MSYX32PF.cjs +2 -0
- package/dist/chunk-MSYX32PF.cjs.map +1 -0
- package/dist/chunk-MVZUTETT.js +2 -0
- package/dist/chunk-MVZUTETT.js.map +1 -0
- package/dist/chunk-N7N7MPMK.cjs +2 -0
- package/dist/chunk-N7N7MPMK.cjs.map +1 -0
- package/dist/chunk-NGBBNL4K.cjs +1 -3
- package/dist/chunk-P6WPEUAJ.cjs +2 -0
- package/dist/chunk-P6WPEUAJ.cjs.map +1 -0
- package/dist/chunk-PS272DZJ.cjs +2 -0
- package/dist/chunk-PS272DZJ.cjs.map +1 -0
- package/dist/chunk-QXQE7X4S.js +2 -0
- package/dist/chunk-QXQE7X4S.js.map +1 -0
- package/dist/chunk-R2ENWQ76.js +2 -0
- package/dist/chunk-R2ENWQ76.js.map +1 -0
- package/dist/chunk-R2SZFJTT.cjs +2 -0
- package/dist/chunk-R2SZFJTT.cjs.map +1 -0
- package/dist/chunk-RAF57WYO.js +2 -0
- package/dist/chunk-RAF57WYO.js.map +1 -0
- package/dist/chunk-RSF25YSJ.js +2 -0
- package/dist/chunk-RSF25YSJ.js.map +1 -0
- package/dist/chunk-SOMGSIO4.cjs +3 -0
- package/dist/chunk-SOMGSIO4.cjs.map +1 -0
- package/dist/chunk-SUXRZWH2.cjs +3 -0
- package/dist/chunk-SUXRZWH2.cjs.map +1 -0
- package/dist/chunk-SYYE3QAX.cjs +2 -0
- package/dist/chunk-SYYE3QAX.cjs.map +1 -0
- package/dist/chunk-SZGK6RIP.cjs +2 -0
- package/dist/chunk-SZGK6RIP.cjs.map +1 -0
- package/dist/chunk-TCZSPH4A.js +2 -0
- package/dist/chunk-TCZSPH4A.js.map +1 -0
- package/dist/chunk-TLG7VZRX.cjs +2 -0
- package/dist/chunk-TLG7VZRX.cjs.map +1 -0
- package/dist/chunk-TRBXW6HW.js +2 -0
- package/dist/{chunk-AQNHHJMJ.cjs.map → chunk-TRBXW6HW.js.map} +1 -1
- package/dist/chunk-TTFO4YDP.cjs +2 -0
- package/dist/chunk-TTFO4YDP.cjs.map +1 -0
- package/dist/chunk-TWC7K3ZX.js +2 -0
- package/dist/chunk-TWC7K3ZX.js.map +1 -0
- package/dist/chunk-UDQ57ZRX.cjs +2 -0
- package/dist/chunk-UDQ57ZRX.cjs.map +1 -0
- package/dist/chunk-UI6IFGBT.js +2 -0
- package/dist/chunk-UI6IFGBT.js.map +1 -0
- package/dist/chunk-UURM7P3P.cjs +4 -0
- package/dist/chunk-UURM7P3P.cjs.map +1 -0
- package/dist/chunk-W2JAR233.js +2 -0
- package/dist/chunk-W2JAR233.js.map +1 -0
- package/dist/chunk-WGZ3FNHI.js +2 -0
- package/dist/chunk-WGZ3FNHI.js.map +1 -0
- package/dist/chunk-WN5CMP4T.cjs +3 -0
- package/dist/chunk-WN5CMP4T.cjs.map +1 -0
- package/dist/chunk-XEIDV5JP.js +2 -0
- package/dist/chunk-XEIDV5JP.js.map +1 -0
- package/dist/chunk-XNIWQHXY.js +2 -0
- package/dist/chunk-XNIWQHXY.js.map +1 -0
- package/dist/chunk-XR7HEC7B.js +5 -0
- package/dist/chunk-XR7HEC7B.js.map +1 -0
- package/dist/chunk-Y7O4D3BJ.cjs +2 -0
- package/dist/chunk-Y7O4D3BJ.cjs.map +1 -0
- package/dist/chunk-YAYBVVG2.js +3 -0
- package/dist/chunk-YAYBVVG2.js.map +1 -0
- package/dist/chunk-YJ2OPULK.js +2 -0
- package/dist/chunk-YJ2OPULK.js.map +1 -0
- package/dist/chunk-YVKHEAFT.js +2 -0
- package/dist/chunk-YVKHEAFT.js.map +1 -0
- package/dist/chunk-ZCNBT44X.cjs +2 -0
- package/dist/chunk-ZCNBT44X.cjs.map +1 -0
- package/dist/chunk-ZLRJ7TDP.cjs +2 -0
- package/dist/chunk-ZLRJ7TDP.cjs.map +1 -0
- package/dist/constants.cjs +1 -21
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -4
- package/dist/engine.cjs +1 -94
- package/dist/engine.d.cts +29 -14
- package/dist/engine.d.ts +29 -14
- package/dist/engine.js +1 -37
- package/dist/errors.cjs +1 -105
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -4
- package/dist/format.cjs +1 -26
- package/dist/format.d.cts +2 -2
- package/dist/format.d.ts +2 -2
- package/dist/format.js +1 -9
- package/dist/index.cjs +1 -314
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -23
- package/dist/index.d.ts +55 -23
- package/dist/index.js +1 -278
- package/dist/index.js.map +1 -1
- package/dist/language.cjs +1 -369
- package/dist/language.cjs.map +1 -1
- package/dist/language.d.cts +12 -13
- package/dist/language.d.ts +12 -13
- package/dist/language.js +1 -348
- package/dist/language.js.map +1 -1
- package/dist/lexer.cjs +1 -63
- package/dist/lexer.d.cts +3 -3
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.js +1 -10
- package/dist/normalizer.cjs +1 -39
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +1 -10
- package/dist/packages.cjs +1 -128
- package/dist/packages.d.cts +39 -14
- package/dist/packages.d.ts +39 -14
- package/dist/packages.js +1 -23
- package/dist/parser.cjs +1 -54
- package/dist/parser.d.cts +9 -9
- package/dist/parser.d.ts +9 -9
- package/dist/parser.js +1 -9
- package/dist/{pipeline-CtfJtPQc.d.cts → pipeline-72QmQlGx.d.ts} +3 -3
- package/dist/{pipeline-DCd5M6Gk.d.ts → pipeline-DCQicwWX.d.cts} +3 -3
- package/dist/resolvers.cjs +1 -12
- package/dist/resolvers.d.cts +3 -3
- package/dist/resolvers.d.ts +3 -3
- package/dist/resolvers.js +1 -3
- package/dist/services.cjs +1 -20
- package/dist/services.js +1 -3
- package/dist/testing.cjs +3 -477
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -13
- package/dist/testing.d.ts +12 -13
- package/dist/testing.js +3 -469
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -55
- package/dist/uom.d.cts +3 -3
- package/dist/uom.d.ts +3 -3
- package/dist/uom.js +1 -10
- package/dist/utilities.cjs +1 -36
- package/dist/utilities.js +1 -7
- package/dist/vm.cjs +1 -295
- package/dist/vm.cjs.map +1 -1
- package/dist/vm.d.cts +22 -10
- package/dist/vm.d.ts +22 -10
- package/dist/vm.js +1 -193
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -492
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +19 -20
- package/dist/worker.d.ts +19 -20
- package/dist/worker.js +2 -483
- package/dist/worker.js.map +1 -1
- package/package.json +1 -13
- package/dist/chunk-267JPOTF.js +0 -406
- package/dist/chunk-267JPOTF.js.map +0 -1
- package/dist/chunk-2TZKENDH.cjs +0 -448
- package/dist/chunk-2TZKENDH.cjs.map +0 -1
- package/dist/chunk-3BOK2LDK.js +0 -17
- package/dist/chunk-3BOK2LDK.js.map +0 -1
- package/dist/chunk-3OWCDIPN.js +0 -215
- package/dist/chunk-3OWCDIPN.js.map +0 -1
- package/dist/chunk-3VGDNEE3.js +0 -84
- package/dist/chunk-3VGDNEE3.js.map +0 -1
- package/dist/chunk-4D6NIHE2.js +0 -451
- package/dist/chunk-4D6NIHE2.js.map +0 -1
- package/dist/chunk-4HQKTMWG.js +0 -7985
- package/dist/chunk-4HQKTMWG.js.map +0 -1
- package/dist/chunk-536WPM2V.cjs +0 -283
- package/dist/chunk-536WPM2V.cjs.map +0 -1
- package/dist/chunk-5HRB36DK.js +0 -405
- package/dist/chunk-5HRB36DK.js.map +0 -1
- package/dist/chunk-5ON7PUAZ.js +0 -12
- package/dist/chunk-5ON7PUAZ.js.map +0 -1
- package/dist/chunk-7KYSUDQO.js +0 -109
- package/dist/chunk-7KYSUDQO.js.map +0 -1
- package/dist/chunk-7ZX6B7SY.cjs +0 -3222
- package/dist/chunk-7ZX6B7SY.cjs.map +0 -1
- package/dist/chunk-ADBA3XBE.cjs +0 -20
- package/dist/chunk-ADBA3XBE.cjs.map +0 -1
- package/dist/chunk-ALYRJ72W.cjs +0 -434
- package/dist/chunk-ALYRJ72W.cjs.map +0 -1
- package/dist/chunk-AMOJYLG2.cjs +0 -1692
- package/dist/chunk-AMOJYLG2.cjs.map +0 -1
- package/dist/chunk-AQNHHJMJ.cjs +0 -261
- package/dist/chunk-B4HBEFTB.cjs +0 -375
- package/dist/chunk-B4HBEFTB.cjs.map +0 -1
- package/dist/chunk-B7LXJ6LC.cjs +0 -36
- package/dist/chunk-B7LXJ6LC.cjs.map +0 -1
- package/dist/chunk-B7NLZMQ3.cjs +0 -74
- package/dist/chunk-B7NLZMQ3.cjs.map +0 -1
- package/dist/chunk-BLI4NIQY.js +0 -98
- package/dist/chunk-BLI4NIQY.js.map +0 -1
- package/dist/chunk-BYJBUL7U.js +0 -499
- package/dist/chunk-BYJBUL7U.js.map +0 -1
- package/dist/chunk-CCBZZQAE.js +0 -312
- package/dist/chunk-CCBZZQAE.js.map +0 -1
- package/dist/chunk-CKQMXMHR.cjs +0 -219
- package/dist/chunk-CKQMXMHR.cjs.map +0 -1
- package/dist/chunk-CUR2WLI4.cjs +0 -507
- package/dist/chunk-CUR2WLI4.cjs.map +0 -1
- package/dist/chunk-DLEBSLF4.js +0 -336
- package/dist/chunk-DLEBSLF4.js.map +0 -1
- package/dist/chunk-E23GZEWL.cjs +0 -209
- package/dist/chunk-E23GZEWL.cjs.map +0 -1
- package/dist/chunk-EJ3ILXX6.cjs +0 -223
- package/dist/chunk-EJ3ILXX6.cjs.map +0 -1
- package/dist/chunk-ENKKJYD3.js +0 -333
- package/dist/chunk-ENKKJYD3.js.map +0 -1
- package/dist/chunk-ENRIK36Q.cjs +0 -94
- package/dist/chunk-ENRIK36Q.cjs.map +0 -1
- package/dist/chunk-ERCOHGXD.js +0 -356
- package/dist/chunk-ERCOHGXD.js.map +0 -1
- package/dist/chunk-FD5ZZHEU.js +0 -92
- package/dist/chunk-FD5ZZHEU.js.map +0 -1
- package/dist/chunk-FEAIOR7N.cjs +0 -91
- package/dist/chunk-FEAIOR7N.cjs.map +0 -1
- package/dist/chunk-GCM5JHMX.js +0 -88
- package/dist/chunk-GCM5JHMX.js.map +0 -1
- package/dist/chunk-GLA4JXBO.js +0 -204
- package/dist/chunk-GLA4JXBO.js.map +0 -1
- package/dist/chunk-HIQ5HSZL.cjs +0 -1923
- package/dist/chunk-HIQ5HSZL.cjs.map +0 -1
- package/dist/chunk-HVRVSI2Z.cjs +0 -829
- package/dist/chunk-HVRVSI2Z.cjs.map +0 -1
- package/dist/chunk-I4GAWIPW.js +0 -825
- package/dist/chunk-I4GAWIPW.js.map +0 -1
- package/dist/chunk-J45BCEZ4.cjs +0 -339
- package/dist/chunk-J45BCEZ4.cjs.map +0 -1
- package/dist/chunk-JG6ZJ2WU.js +0 -1513
- package/dist/chunk-JG6ZJ2WU.js.map +0 -1
- package/dist/chunk-L2TE7PMO.cjs +0 -14
- package/dist/chunk-L2TE7PMO.cjs.map +0 -1
- package/dist/chunk-LHZ6VOA7.js +0 -1764
- package/dist/chunk-LHZ6VOA7.js.map +0 -1
- package/dist/chunk-MN3LHRGV.cjs +0 -8012
- package/dist/chunk-MN3LHRGV.cjs.map +0 -1
- package/dist/chunk-MVTOCRV2.js +0 -213
- package/dist/chunk-MVTOCRV2.js.map +0 -1
- package/dist/chunk-N5NNW4VG.cjs +0 -341
- package/dist/chunk-N5NNW4VG.cjs.map +0 -1
- package/dist/chunk-N7FNVFXW.cjs +0 -32
- package/dist/chunk-N7FNVFXW.cjs.map +0 -1
- package/dist/chunk-NKW7LKYU.js +0 -3185
- package/dist/chunk-NKW7LKYU.js.map +0 -1
- package/dist/chunk-NLNDMWZC.js +0 -31
- package/dist/chunk-NLNDMWZC.js.map +0 -1
- package/dist/chunk-NNQ2TYDF.js +0 -1848
- package/dist/chunk-NNQ2TYDF.js.map +0 -1
- package/dist/chunk-NNZAEUDW.js +0 -6792
- package/dist/chunk-NNZAEUDW.js.map +0 -1
- package/dist/chunk-OUHT5Z36.cjs +0 -393
- package/dist/chunk-OUHT5Z36.cjs.map +0 -1
- package/dist/chunk-QFTDTX6K.cjs +0 -457
- package/dist/chunk-QFTDTX6K.cjs.map +0 -1
- package/dist/chunk-SBUFNJVE.js +0 -258
- package/dist/chunk-SBUFNJVE.js.map +0 -1
- package/dist/chunk-SRGQ72IR.cjs +0 -2800
- package/dist/chunk-SRGQ72IR.cjs.map +0 -1
- package/dist/chunk-SSV46KFA.cjs +0 -112
- package/dist/chunk-SSV46KFA.cjs.map +0 -1
- package/dist/chunk-T6ZYQJ63.cjs +0 -6807
- package/dist/chunk-T6ZYQJ63.cjs.map +0 -1
- package/dist/chunk-UKQHXPGW.js +0 -30
- package/dist/chunk-UKQHXPGW.js.map +0 -1
- package/dist/chunk-UO6BUV6K.js +0 -278
- package/dist/chunk-UO6BUV6K.js.map +0 -1
- package/dist/chunk-V4XG5QF6.js +0 -1685
- package/dist/chunk-V4XG5QF6.js.map +0 -1
- package/dist/chunk-VEKIWQ3F.cjs +0 -39
- package/dist/chunk-VEKIWQ3F.cjs.map +0 -1
- package/dist/chunk-WWQEY7BV.js +0 -67
- package/dist/chunk-WWQEY7BV.js.map +0 -1
- package/dist/chunk-WXEHD6TT.js +0 -2795
- package/dist/chunk-WXEHD6TT.js.map +0 -1
- package/dist/chunk-X6K3HUOY.cjs +0 -86
- package/dist/chunk-X6K3HUOY.cjs.map +0 -1
- package/dist/chunk-XA4CKRML.cjs +0 -316
- package/dist/chunk-XA4CKRML.cjs.map +0 -1
- package/dist/chunk-XBTEO4OB.js +0 -391
- package/dist/chunk-XBTEO4OB.js.map +0 -1
- package/dist/chunk-XIYYHA65.cjs +0 -101
- package/dist/chunk-XIYYHA65.cjs.map +0 -1
- package/dist/chunk-YLJ4XMA6.js +0 -33
- package/dist/chunk-YLJ4XMA6.js.map +0 -1
- package/dist/chunk-YRIKITGF.cjs +0 -1768
- package/dist/chunk-YRIKITGF.cjs.map +0 -1
- package/dist/chunk-Z2XP767T.cjs +0 -35
- package/dist/chunk-Z2XP767T.cjs.map +0 -1
- package/dist/chunk-Z4X2RWOF.js +0 -37
- package/dist/chunk-Z4X2RWOF.js.map +0 -1
- package/dist/chunk-Z7XGGLI2.js +0 -455
- package/dist/chunk-Z7XGGLI2.js.map +0 -1
- package/dist/chunk-ZMW6NU2K.cjs +0 -1516
- package/dist/chunk-ZMW6NU2K.cjs.map +0 -1
- package/dist/chunk-ZVTWQLK4.cjs +0 -459
- package/dist/chunk-ZVTWQLK4.cjs.map +0 -1
- package/dist/variables.cjs +0 -17
- package/dist/variables.cjs.map +0 -1
- package/dist/variables.d.cts +0 -87
- package/dist/variables.d.ts +0 -87
- package/dist/variables.js +0 -4
- package/dist/variables.js.map +0 -1
package/dist/chunk-Z7XGGLI2.js
DELETED
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import { createTimeoutSignal } from './chunk-Z4X2RWOF.js';
|
|
2
|
-
import { ErrorFactory } from './chunk-ERCOHGXD.js';
|
|
3
|
-
|
|
4
|
-
// src/uom/Iso4217.ts
|
|
5
|
-
var ISO_4217_CODES = /* @__PURE__ */ new Set([
|
|
6
|
-
"AED",
|
|
7
|
-
"AFN",
|
|
8
|
-
"ALL",
|
|
9
|
-
"AMD",
|
|
10
|
-
"ANG",
|
|
11
|
-
"AOA",
|
|
12
|
-
"ARS",
|
|
13
|
-
"AUD",
|
|
14
|
-
"AWG",
|
|
15
|
-
"AZN",
|
|
16
|
-
"BAM",
|
|
17
|
-
"BBD",
|
|
18
|
-
"BDT",
|
|
19
|
-
"BGN",
|
|
20
|
-
"BHD",
|
|
21
|
-
"BIF",
|
|
22
|
-
"BMD",
|
|
23
|
-
"BND",
|
|
24
|
-
"BOB",
|
|
25
|
-
"BOV",
|
|
26
|
-
"BRL",
|
|
27
|
-
"BSD",
|
|
28
|
-
"BTN",
|
|
29
|
-
"BWP",
|
|
30
|
-
"BYN",
|
|
31
|
-
"BZD",
|
|
32
|
-
"CAD",
|
|
33
|
-
"CDF",
|
|
34
|
-
"CHE",
|
|
35
|
-
"CHF",
|
|
36
|
-
"CHW",
|
|
37
|
-
"CLF",
|
|
38
|
-
"CLP",
|
|
39
|
-
"CNY",
|
|
40
|
-
"COP",
|
|
41
|
-
"COU",
|
|
42
|
-
"CRC",
|
|
43
|
-
"CUP",
|
|
44
|
-
"CVE",
|
|
45
|
-
"CZK",
|
|
46
|
-
"DJF",
|
|
47
|
-
"DKK",
|
|
48
|
-
"DOP",
|
|
49
|
-
"DZD",
|
|
50
|
-
"EGP",
|
|
51
|
-
"ERN",
|
|
52
|
-
"ETB",
|
|
53
|
-
"EUR",
|
|
54
|
-
"FJD",
|
|
55
|
-
"FKP",
|
|
56
|
-
"GBP",
|
|
57
|
-
"GEL",
|
|
58
|
-
"GHS",
|
|
59
|
-
"GIP",
|
|
60
|
-
"GMD",
|
|
61
|
-
"GNF",
|
|
62
|
-
"GTQ",
|
|
63
|
-
"GYD",
|
|
64
|
-
"HKD",
|
|
65
|
-
"HNL",
|
|
66
|
-
"HTG",
|
|
67
|
-
"HUF",
|
|
68
|
-
"IDR",
|
|
69
|
-
"ILS",
|
|
70
|
-
"INR",
|
|
71
|
-
"IQD",
|
|
72
|
-
"IRR",
|
|
73
|
-
"ISK",
|
|
74
|
-
"JMD",
|
|
75
|
-
"JOD",
|
|
76
|
-
"JPY",
|
|
77
|
-
"KES",
|
|
78
|
-
"KGS",
|
|
79
|
-
"KHR",
|
|
80
|
-
"KMF",
|
|
81
|
-
"KPW",
|
|
82
|
-
"KRW",
|
|
83
|
-
"KWD",
|
|
84
|
-
"KYD",
|
|
85
|
-
"KZT",
|
|
86
|
-
"LAK",
|
|
87
|
-
"LBP",
|
|
88
|
-
"LKR",
|
|
89
|
-
"LRD",
|
|
90
|
-
"LSL",
|
|
91
|
-
"LYD",
|
|
92
|
-
"MAD",
|
|
93
|
-
"MDL",
|
|
94
|
-
"MGA",
|
|
95
|
-
"MKD",
|
|
96
|
-
"MMK",
|
|
97
|
-
"MNT",
|
|
98
|
-
"MOP",
|
|
99
|
-
"MRU",
|
|
100
|
-
"MUR",
|
|
101
|
-
"MVR",
|
|
102
|
-
"MWK",
|
|
103
|
-
"MXN",
|
|
104
|
-
"MXV",
|
|
105
|
-
"MYR",
|
|
106
|
-
"MZN",
|
|
107
|
-
"NAD",
|
|
108
|
-
"NGN",
|
|
109
|
-
"NIO",
|
|
110
|
-
"NOK",
|
|
111
|
-
"NPR",
|
|
112
|
-
"NZD",
|
|
113
|
-
"OMR",
|
|
114
|
-
"PAB",
|
|
115
|
-
"PEN",
|
|
116
|
-
"PGK",
|
|
117
|
-
"PHP",
|
|
118
|
-
"PKR",
|
|
119
|
-
"PLN",
|
|
120
|
-
"PYG",
|
|
121
|
-
"QAR",
|
|
122
|
-
"RON",
|
|
123
|
-
"RSD",
|
|
124
|
-
"RUB",
|
|
125
|
-
"RWF",
|
|
126
|
-
"SAR",
|
|
127
|
-
"SBD",
|
|
128
|
-
"SCR",
|
|
129
|
-
"SDG",
|
|
130
|
-
"SEK",
|
|
131
|
-
"SGD",
|
|
132
|
-
"SHP",
|
|
133
|
-
"SLE",
|
|
134
|
-
"SOS",
|
|
135
|
-
"SRD",
|
|
136
|
-
"SSP",
|
|
137
|
-
"STN",
|
|
138
|
-
"SVC",
|
|
139
|
-
"SYP",
|
|
140
|
-
"SZL",
|
|
141
|
-
"THB",
|
|
142
|
-
"TJS",
|
|
143
|
-
"TMT",
|
|
144
|
-
"TND",
|
|
145
|
-
"TOP",
|
|
146
|
-
"TRY",
|
|
147
|
-
"TTD",
|
|
148
|
-
"TWD",
|
|
149
|
-
"TZS",
|
|
150
|
-
"UAH",
|
|
151
|
-
"UGX",
|
|
152
|
-
"USD",
|
|
153
|
-
"USN",
|
|
154
|
-
"UYI",
|
|
155
|
-
"UYU",
|
|
156
|
-
"UYW",
|
|
157
|
-
"UZS",
|
|
158
|
-
"VED",
|
|
159
|
-
"VES",
|
|
160
|
-
"VND",
|
|
161
|
-
"VUV",
|
|
162
|
-
"WST",
|
|
163
|
-
"XAF",
|
|
164
|
-
"XCD",
|
|
165
|
-
"XCG",
|
|
166
|
-
"XOF",
|
|
167
|
-
"XPF",
|
|
168
|
-
"YER",
|
|
169
|
-
"ZAR",
|
|
170
|
-
"ZMW",
|
|
171
|
-
"ZWG"
|
|
172
|
-
]);
|
|
173
|
-
function isIso4217(code) {
|
|
174
|
-
return ISO_4217_CODES.has(code.toUpperCase());
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// src/uom/CurrencyExchange.ts
|
|
178
|
-
var CurrencyErrorCodes = {
|
|
179
|
-
/** Frankfurter's rates endpoint returned a non-OK HTTP status. */
|
|
180
|
-
API_ERROR: "CURRENCY_API_ERROR",
|
|
181
|
-
/** A requested currency/crypto code isn't in the fetched rate table, an unrecognized code, not an API failure. */
|
|
182
|
-
UNKNOWN_CODE: "UNKNOWN_CURRENCY_CODE",
|
|
183
|
-
/** CoinGecko's simple-price endpoint returned a non-OK HTTP status. */
|
|
184
|
-
CRYPTO_API_ERROR: "CRYPTO_PRICE_API_ERROR"
|
|
185
|
-
};
|
|
186
|
-
var _CurrencyExchangeService = class _CurrencyExchangeService {
|
|
187
|
-
constructor() {
|
|
188
|
-
/**
|
|
189
|
-
* Live rate tables cached from successful getRate() fetches, keyed by
|
|
190
|
-
* uppercase base currency. Each table holds every rate the API returned
|
|
191
|
-
* for that base (plus the base itself at 1), so any pair whose two codes
|
|
192
|
-
* appear in one fresh table can be served synchronously, including
|
|
193
|
-
* cross pairs via triangulation (EUR→GBP through a USD-base table).
|
|
194
|
-
* Stale tables are ignored, not evicted; the next successful fetch for
|
|
195
|
-
* the same base overwrites them.
|
|
196
|
-
*/
|
|
197
|
-
this.baseTables = /* @__PURE__ */ new Map();
|
|
198
|
-
}
|
|
199
|
-
isCryptoCode(code) {
|
|
200
|
-
return code.toUpperCase() in _CurrencyExchangeService.CRYPTO_IDS;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Fetch the live exchange rate for converting 1 unit of `from` into `to`.
|
|
204
|
-
*
|
|
205
|
-
* Routes cryptocurrency codes (see {@link CRYPTO_IDS}) to CoinGecko and
|
|
206
|
-
* everything else to Frankfurter (ECB reference rates, fiat-only). On
|
|
207
|
-
* success, caches the whole returned rate table for `from` so subsequent
|
|
208
|
-
* lookups, including cross-pairs via triangulation, can be served
|
|
209
|
-
* synchronously by {@link getRateSync} within the freshness window.
|
|
210
|
-
*
|
|
211
|
-
* @throws If the currency code is unrecognized or the fetch fails/times out.
|
|
212
|
-
*/
|
|
213
|
-
async getRate(from, to, signal) {
|
|
214
|
-
const fromUpper = from.toUpperCase();
|
|
215
|
-
const toUpper = to.toUpperCase();
|
|
216
|
-
if (this.isCryptoCode(fromUpper) || this.isCryptoCode(toUpper)) {
|
|
217
|
-
return this.getCryptoRate(fromUpper, toUpper, signal);
|
|
218
|
-
}
|
|
219
|
-
const { signal: fetchSignal, cleanup } = createTimeoutSignal(
|
|
220
|
-
signal,
|
|
221
|
-
_CurrencyExchangeService.FETCH_TIMEOUT_MS,
|
|
222
|
-
"Currency API fetch"
|
|
223
|
-
);
|
|
224
|
-
try {
|
|
225
|
-
const response = await fetch(`https://api.frankfurter.dev/v2/rates?base=${fromUpper}`, { signal: fetchSignal });
|
|
226
|
-
if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.API_ERROR, `Currency API returned ${response.status}`, { status: response.status });
|
|
227
|
-
const data = await response.json();
|
|
228
|
-
const rates = Array.isArray(data) ? Object.fromEntries(
|
|
229
|
-
data.filter((entry) => {
|
|
230
|
-
if (typeof entry !== "object" || entry === null) return false;
|
|
231
|
-
const candidate = entry;
|
|
232
|
-
return typeof candidate.quote === "string" && typeof candidate.rate === "number";
|
|
233
|
-
}).map((entry) => [entry.quote.toUpperCase(), entry.rate])
|
|
234
|
-
) : data.rates ?? {};
|
|
235
|
-
if (rates[toUpper] === void 0) throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });
|
|
236
|
-
this.baseTables.set(fromUpper, {
|
|
237
|
-
fetchedAt: Date.now(),
|
|
238
|
-
rates: { ...rates, [fromUpper]: 1 }
|
|
239
|
-
});
|
|
240
|
-
return rates[toUpper];
|
|
241
|
-
} finally {
|
|
242
|
-
cleanup();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Crypto rate fetch, routed through CoinGecko's no-auth simple-price
|
|
247
|
-
* endpoint instead of Frankfurter (fiat-only, has no BTC/ETH concept).
|
|
248
|
-
* Handles all three combinations, crypto→crypto, crypto→fiat
|
|
249
|
-
* fiat→crypto, via prices denominated in USD (or the target fiat
|
|
250
|
-
* directly, which CoinGecko's `vs_currencies` also accepts), then
|
|
251
|
-
* caches the result as a same-shaped base table so getRateSync /
|
|
252
|
-
* convertSync keep working unchanged for crypto pairs too.
|
|
253
|
-
*/
|
|
254
|
-
async getCryptoRate(fromUpper, toUpper, signal) {
|
|
255
|
-
const { signal: fetchSignal, cleanup } = createTimeoutSignal(
|
|
256
|
-
signal,
|
|
257
|
-
_CurrencyExchangeService.FETCH_TIMEOUT_MS,
|
|
258
|
-
"Crypto price API fetch"
|
|
259
|
-
);
|
|
260
|
-
try {
|
|
261
|
-
const fromIsCrypto = this.isCryptoCode(fromUpper);
|
|
262
|
-
const toIsCrypto = this.isCryptoCode(toUpper);
|
|
263
|
-
let rate;
|
|
264
|
-
if (fromIsCrypto && toIsCrypto) {
|
|
265
|
-
const fromId = _CurrencyExchangeService.CRYPTO_IDS[fromUpper];
|
|
266
|
-
const toId = _CurrencyExchangeService.CRYPTO_IDS[toUpper];
|
|
267
|
-
const data = await this.fetchCoinGeckoPrices([fromId, toId], "usd", fetchSignal);
|
|
268
|
-
const fromUsd = data[fromId]?.usd;
|
|
269
|
-
const toUsd = data[toId]?.usd;
|
|
270
|
-
if (typeof fromUsd !== "number") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });
|
|
271
|
-
if (typeof toUsd !== "number") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });
|
|
272
|
-
rate = fromUsd / toUsd;
|
|
273
|
-
} else if (fromIsCrypto) {
|
|
274
|
-
const fromId = _CurrencyExchangeService.CRYPTO_IDS[fromUpper];
|
|
275
|
-
const vs = toUpper.toLowerCase();
|
|
276
|
-
const data = await this.fetchCoinGeckoPrices([fromId], vs, fetchSignal);
|
|
277
|
-
const value = data[fromId]?.[vs];
|
|
278
|
-
if (typeof value !== "number") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });
|
|
279
|
-
rate = value;
|
|
280
|
-
} else {
|
|
281
|
-
const toId = _CurrencyExchangeService.CRYPTO_IDS[toUpper];
|
|
282
|
-
const vs = fromUpper.toLowerCase();
|
|
283
|
-
const data = await this.fetchCoinGeckoPrices([toId], vs, fetchSignal);
|
|
284
|
-
const priceOfToInFrom = data[toId]?.[vs];
|
|
285
|
-
if (typeof priceOfToInFrom !== "number") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });
|
|
286
|
-
rate = 1 / priceOfToInFrom;
|
|
287
|
-
}
|
|
288
|
-
this.baseTables.set(fromUpper, {
|
|
289
|
-
fetchedAt: Date.now(),
|
|
290
|
-
rates: { [fromUpper]: 1, [toUpper]: rate }
|
|
291
|
-
});
|
|
292
|
-
return rate;
|
|
293
|
-
} finally {
|
|
294
|
-
cleanup();
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
async fetchCoinGeckoPrices(ids, vsCurrency, signal) {
|
|
298
|
-
const url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids.join(",")}&vs_currencies=${vsCurrency}`;
|
|
299
|
-
const response = await fetch(url, { signal });
|
|
300
|
-
if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.CRYPTO_API_ERROR, `Crypto price API returned ${response.status}`, { status: response.status });
|
|
301
|
-
return response.json();
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* Seed a base rate table without a network fetch.
|
|
305
|
-
*
|
|
306
|
-
* Intended for tests and for future user-provided offline rates
|
|
307
|
-
* production live data always comes from {@link getRate}. Seeded rates
|
|
308
|
-
* obey the same freshness window as fetched ones.
|
|
309
|
-
*
|
|
310
|
-
* @param base - Base currency code (e.g. "USD").
|
|
311
|
-
* @param rates - Map of currency code → rate relative to the base.
|
|
312
|
-
*/
|
|
313
|
-
primeRates(base, rates) {
|
|
314
|
-
const baseUpper = base.toUpperCase();
|
|
315
|
-
this.baseTables.set(baseUpper, {
|
|
316
|
-
fetchedAt: Date.now(),
|
|
317
|
-
rates: { ...rates, [baseUpper]: 1 }
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Drop every cached/primed rate table.
|
|
322
|
-
*
|
|
323
|
-
* Mainly for test isolation: {@link sharedCurrencyExchange} is a
|
|
324
|
-
* module-level singleton, so a rate primed or fetched by one test can
|
|
325
|
-
* silently leak into a later test in the same file. Also usable in
|
|
326
|
-
* production if a caller ever wants to force a full re-fetch.
|
|
327
|
-
*/
|
|
328
|
-
clearRates() {
|
|
329
|
-
this.baseTables.clear();
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* Synchronous rate lookup: `1` for same-currency pairs, a cached LIVE
|
|
333
|
-
* rate if one was fetched within {@link RATE_FRESHNESS_MS}, otherwise
|
|
334
|
-
* `null`, callers fall through to the async fetch path and the
|
|
335
|
-
* expression shows Pending until real data arrives.
|
|
336
|
-
*
|
|
337
|
-
* There is deliberately no hardcoded fallback table: a stale made-up
|
|
338
|
-
* rate presented as a real conversion is worse than a Pending state.
|
|
339
|
-
*/
|
|
340
|
-
getRateSync(from, to) {
|
|
341
|
-
const fromUpper = from.toUpperCase();
|
|
342
|
-
const toUpper = to.toUpperCase();
|
|
343
|
-
if (fromUpper === toUpper) {
|
|
344
|
-
return 1;
|
|
345
|
-
}
|
|
346
|
-
const now = Date.now();
|
|
347
|
-
for (const table of this.baseTables.values()) {
|
|
348
|
-
if (now - table.fetchedAt > _CurrencyExchangeService.RATE_FRESHNESS_MS) continue;
|
|
349
|
-
const fromRate = table.rates[fromUpper];
|
|
350
|
-
const toRate = table.rates[toUpper];
|
|
351
|
-
if (fromRate && toRate) {
|
|
352
|
-
return toRate / fromRate;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
/** Convert `value` from `from` to `to` using a freshly-fetched live rate (see {@link getRate}). */
|
|
358
|
-
async convert(value, from, to) {
|
|
359
|
-
const rate = await this.getRate(from, to);
|
|
360
|
-
return value * rate;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Get all currently cached fresh rates, keyed "FROM:TO".
|
|
364
|
-
* @returns Snapshot of fresh live rates, or null when none are cached.
|
|
365
|
-
*/
|
|
366
|
-
getAllRates() {
|
|
367
|
-
const now = Date.now();
|
|
368
|
-
const snapshot = {};
|
|
369
|
-
let any = false;
|
|
370
|
-
for (const [base, table] of this.baseTables) {
|
|
371
|
-
if (now - table.fetchedAt > _CurrencyExchangeService.RATE_FRESHNESS_MS) continue;
|
|
372
|
-
for (const [code, rate] of Object.entries(table.rates)) {
|
|
373
|
-
snapshot[`${base}:${code}`] = rate;
|
|
374
|
-
any = true;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return any ? snapshot : null;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Check whether any fresh live rates are currently cached.
|
|
381
|
-
*/
|
|
382
|
-
hasRates() {
|
|
383
|
-
return this.getAllRates() !== null;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Synchronous conversion using cached rates only
|
|
387
|
-
* Returns null if rate not in cache
|
|
388
|
-
*/
|
|
389
|
-
convertSync(value, from, to) {
|
|
390
|
-
const rate = this.getRateSync(from, to);
|
|
391
|
-
if (rate === null) return null;
|
|
392
|
-
return value * rate;
|
|
393
|
-
}
|
|
394
|
-
// ------------------------------------------------------------------------
|
|
395
|
-
// CURRENCY VALIDATION
|
|
396
|
-
// ------------------------------------------------------------------------
|
|
397
|
-
/**
|
|
398
|
-
* Check whether `code` is a recognized currency code: any active ISO 4217
|
|
399
|
-
* code, or one of the cryptocurrencies in {@link CRYPTO_IDS}.
|
|
400
|
-
*
|
|
401
|
-
* This used to be a hand-written list of forty-six codes, which meant
|
|
402
|
-
* `$100 in UAH` returned an unconverted hundred dollars rather than saying
|
|
403
|
-
* it could not convert. Answering from the standard rather than from
|
|
404
|
-
* whichever codes happened to get added is what stops that class of bug.
|
|
405
|
-
*
|
|
406
|
-
* Recognising a code is not the same as having a rate for it. That is
|
|
407
|
-
* answered later, by the exchange provider; conflating the two is what
|
|
408
|
-
* produced the silent failure.
|
|
409
|
-
*/
|
|
410
|
-
isCurrency(code) {
|
|
411
|
-
return isIso4217(code) || this.isCryptoCode(code);
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
/**
|
|
415
|
-
* How long a fetched rate may be served synchronously by getRateSync().
|
|
416
|
-
* Beyond this window callers fall through to the async path (expression
|
|
417
|
-
* shows Pending until the fetch lands).
|
|
418
|
-
*/
|
|
419
|
-
_CurrencyExchangeService.RATE_FRESHNESS_MS = 15 * 60 * 1e3;
|
|
420
|
-
/**
|
|
421
|
-
* Ticker → CoinGecko coin id, for the cryptocurrencies `isCurrency()`
|
|
422
|
-
* recognizes. Frankfurter (the fiat rate source below) is ECB reference
|
|
423
|
-
* rates only and has no concept of BTC/ETH/etc, routing a crypto code
|
|
424
|
-
* through it as `base=BTC` fails outright, which is why crypto pairs
|
|
425
|
-
* previously never resolved (see CurrencyAsyncResolver/VM.ts's ADD
|
|
426
|
-
* handling for the two bugs that let that failure pass silently instead
|
|
427
|
-
* of surfacing as a real fetch).
|
|
428
|
-
*/
|
|
429
|
-
_CurrencyExchangeService.CRYPTO_IDS = {
|
|
430
|
-
BTC: "bitcoin",
|
|
431
|
-
ETH: "ethereum",
|
|
432
|
-
SOL: "solana",
|
|
433
|
-
XRP: "ripple",
|
|
434
|
-
ADA: "cardano",
|
|
435
|
-
DOGE: "dogecoin",
|
|
436
|
-
DOT: "polkadot"
|
|
437
|
-
};
|
|
438
|
-
// ------------------------------------------------------------------------
|
|
439
|
-
// RATE FETCHING
|
|
440
|
-
// ------------------------------------------------------------------------
|
|
441
|
-
/**
|
|
442
|
-
* Timeout (ms) for currency exchange rate fetches.
|
|
443
|
-
*
|
|
444
|
-
* If the frankfurter API doesn't respond within this window, the fetch
|
|
445
|
-
* is aborted, preventing indefinite "Pending" states in the playground
|
|
446
|
-
* and Obsidian plugin when the exchange rate API is unreachable.
|
|
447
|
-
*/
|
|
448
|
-
_CurrencyExchangeService.FETCH_TIMEOUT_MS = 1e4;
|
|
449
|
-
var CurrencyExchangeService = _CurrencyExchangeService;
|
|
450
|
-
var currencyExchangeService = new CurrencyExchangeService();
|
|
451
|
-
var sharedCurrencyExchange = currencyExchangeService;
|
|
452
|
-
|
|
453
|
-
export { CurrencyExchangeService, currencyExchangeService, sharedCurrencyExchange };
|
|
454
|
-
//# sourceMappingURL=chunk-Z7XGGLI2.js.map
|
|
455
|
-
//# sourceMappingURL=chunk-Z7XGGLI2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/uom/Iso4217.ts","../src/uom/CurrencyExchange.ts"],"names":[],"mappings":";;;;AAyBO,IAAM,cAAA,uBAA0C,GAAA,CAAI;AAAA,EAC1D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAC/D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAC/D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EACnC,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAC/D,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EACrB,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EACrB,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EAAO,KAAA;AAAA,EACrB,KAAA;AAAA,EAAO,KAAA;AAAA,E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Exchange.isCurrency()` used to hold a\n * hand-written list of forty-six codes, and a code missing from it did not\n * error: `$100 in UAH` returned the original hundred dollars, unconverted, as\n * though the rate were 1. A wrong answer, not a missing feature.\n *\n * The list is the ISO 4217 active set, so \"is this a currency\" is answered by\n * the standard rather than by whichever codes happened to get added. Whether a\n * *rate* is available for one is a separate question, answered at resolution\n * time by whatever the exchange provider supports; conflating the two is what\n * produced the silent failure.\n *\n * Deliberately excluded:\n * - The historical/withdrawn codes (DEM, FRF, and the rest). They are not\n * active, no provider quotes them, and recognising them would only move the\n * failure later.\n * - The X-series non-currencies: XAU/XAG/XPT/XPD (metals), XDR (IMF special\n * drawing rights), XTS (reserved for testing) and XXX (explicitly \"no\n * currency\"). XXX in particular must never resolve.\n *\n * Cryptocurrencies are not here either. They are not ISO 4217 and are tracked\n * separately in `CurrencyExchangeService.CRYPTO_IDS`.\n */\nexport const ISO_4217_CODES: ReadonlySet<string> = new Set([\n\t\"AED\", \"AFN\", \"ALL\", \"AMD\", \"ANG\", \"AOA\", \"ARS\", \"AUD\", \"AWG\", \"AZN\",\n\t\"BAM\", \"BBD\", \"BDT\", \"BGN\", \"BHD\", \"BIF\", \"BMD\", \"BND\", \"BOB\", \"BOV\",\n\t\"BRL\", \"BSD\", \"BTN\", \"BWP\", \"BYN\", \"BZD\",\n\t\"CAD\", \"CDF\", \"CHE\", \"CHF\", \"CHW\", \"CLF\", \"CLP\", \"CNY\", \"COP\", \"COU\",\n\t\"CRC\", \"CUP\", \"CVE\", \"CZK\",\n\t\"DJF\", \"DKK\", \"DOP\", \"DZD\",\n\t\"EGP\", \"ERN\", \"ETB\", \"EUR\",\n\t\"FJD\", \"FKP\",\n\t\"GBP\", \"GEL\", \"GHS\", \"GIP\", \"GMD\", \"GNF\", \"GTQ\", \"GYD\",\n\t\"HKD\", \"HNL\", \"HTG\", \"HUF\",\n\t\"IDR\", \"ILS\", \"INR\", \"IQD\", \"IRR\", \"ISK\",\n\t\"JMD\", \"JOD\", \"JPY\",\n\t\"KES\", \"KGS\", \"KHR\", \"KMF\", \"KPW\", \"KRW\", \"KWD\", \"KYD\", \"KZT\",\n\t\"LAK\", \"LBP\", \"LKR\", \"LRD\", \"LSL\", \"LYD\",\n\t\"MAD\", \"MDL\", \"MGA\", \"MKD\", \"MMK\", \"MNT\", \"MOP\", \"MRU\", \"MUR\", \"MVR\",\n\t\"MWK\", \"MXN\", \"MXV\", \"MYR\", \"MZN\",\n\t\"NAD\", \"NGN\", \"NIO\", \"NOK\", \"NPR\", \"NZD\",\n\t\"OMR\",\n\t\"PAB\", \"PEN\", \"PGK\", \"PHP\", \"PKR\", \"PLN\", \"PYG\",\n\t\"QAR\",\n\t\"RON\", \"RSD\", \"RUB\", \"RWF\",\n\t\"SAR\", \"SBD\", \"SCR\", \"SDG\", \"SEK\", \"SGD\", \"SHP\", \"SLE\", \"SOS\", \"SRD\",\n\t\"SSP\", \"STN\", \"SVC\", \"SYP\", \"SZL\",\n\t\"THB\", \"TJS\", \"TMT\", \"TND\", \"TOP\", \"TRY\", \"TTD\", \"TWD\", \"TZS\",\n\t\"UAH\", \"UGX\", \"USD\", \"USN\", \"UYI\", \"UYU\", \"UYW\", \"UZS\",\n\t\"VED\", \"VES\", \"VND\", \"VUV\",\n\t\"WST\",\n\t\"XAF\", \"XCD\", \"XCG\", \"XOF\", \"XPF\",\n\t\"YER\",\n\t\"ZAR\", \"ZMW\", \"ZWG\",\n]);\n\n/**\n * Whether `code` is an active ISO 4217 currency code.\n *\n * @param code - A three-letter code, in any case.\n */\nexport function isIso4217(code: string): boolean {\n\treturn ISO_4217_CODES.has(code.toUpperCase());\n}\n","/**\n * Production-grade currency exchange service with scalable architecture\n * Integrates with DataQueryService for worker-based execution\n */\n\nimport { isIso4217 } from \"@solve-js/uom/Iso4217\";\nimport { createTimeoutSignal } from \"@solve-js/utilities/TimeoutSignal\";\nimport { ErrorFactory } from \"@solve-js/errors/UnifiedErrorFramework\";\n\n/**\n * Error codes for this service. Co-located rather than unioned into\n * `errors/ErrorCode.ts`'s core catalog (that catalog is scoped to the\n * parser/VM/engine/errors/config/lexer layers, not yet the ~17 domain\n * packages. See that file's module doc for the intended per-package\n * pattern this follows).\n */\nexport const CurrencyErrorCodes = {\n /** Frankfurter's rates endpoint returned a non-OK HTTP status. */\n API_ERROR: \"CURRENCY_API_ERROR\",\n /** A requested currency/crypto code isn't in the fetched rate table, an unrecognized code, not an API failure. */\n UNKNOWN_CODE: \"UNKNOWN_CURRENCY_CODE\",\n /** CoinGecko's simple-price endpoint returned a non-OK HTTP status. */\n CRYPTO_API_ERROR: \"CRYPTO_PRICE_API_ERROR\",\n} as const;\n\n// ============================================================================\n// CURRENCY EXCHANGE SERVICE\n// ============================================================================\n\n/**\n * Caches exchange rates fetched from an external source.\n *\n * Rates are global market data rather than per-engine configuration, which is\n * why one instance is shared. Two engines with private copies would fetch the\n * same endpoint twice and could disagree about one pair at one moment. See\n * `engine/EngineContext.ts`.\n */\nexport class CurrencyExchangeService {\n /**\n * Live rate tables cached from successful getRate() fetches, keyed by\n * uppercase base currency. Each table holds every rate the API returned\n * for that base (plus the base itself at 1), so any pair whose two codes\n * appear in one fresh table can be served synchronously, including\n * cross pairs via triangulation (EUR→GBP through a USD-base table).\n * Stale tables are ignored, not evicted; the next successful fetch for\n * the same base overwrites them.\n */\n private baseTables: Map<string, { fetchedAt: number; rates: Record<string, number> }> = new Map();\n\n /**\n * How long a fetched rate may be served synchronously by getRateSync().\n * Beyond this window callers fall through to the async path (expression\n * shows Pending until the fetch lands).\n */\n private static readonly RATE_FRESHNESS_MS = 15 * 60 * 1000;\n\n /**\n * Ticker → CoinGecko coin id, for the cryptocurrencies `isCurrency()`\n * recognizes. Frankfurter (the fiat rate source below) is ECB reference\n * rates only and has no concept of BTC/ETH/etc, routing a crypto code\n * through it as `base=BTC` fails outright, which is why crypto pairs\n * previously never resolved (see CurrencyAsyncResolver/VM.ts's ADD\n * handling for the two bugs that let that failure pass silently instead\n * of surfacing as a real fetch).\n */\n private static readonly CRYPTO_IDS: Record<string, string> = {\n BTC: \"bitcoin\", ETH: \"ethereum\", SOL: \"solana\", XRP: \"ripple\",\n ADA: \"cardano\", DOGE: \"dogecoin\", DOT: \"polkadot\",\n };\n\n private isCryptoCode(code: string): boolean {\n return code.toUpperCase() in CurrencyExchangeService.CRYPTO_IDS;\n }\n\n constructor() {}\n\n // ------------------------------------------------------------------------\n // RATE FETCHING\n // ------------------------------------------------------------------------\n\n /**\n * Timeout (ms) for currency exchange rate fetches.\n *\n * If the frankfurter API doesn't respond within this window, the fetch\n * is aborted, preventing indefinite \"Pending\" states in the playground\n * and Obsidian plugin when the exchange rate API is unreachable.\n */\n private static readonly FETCH_TIMEOUT_MS = 10_000;\n\n /**\n * Fetch the live exchange rate for converting 1 unit of `from` into `to`.\n *\n * Routes cryptocurrency codes (see {@link CRYPTO_IDS}) to CoinGecko and\n * everything else to Frankfurter (ECB reference rates, fiat-only). On\n * success, caches the whole returned rate table for `from` so subsequent\n * lookups, including cross-pairs via triangulation, can be served\n * synchronously by {@link getRateSync} within the freshness window.\n *\n * @throws If the currency code is unrecognized or the fetch fails/times out.\n */\n async getRate(from: string, to: string, signal?: AbortSignal): Promise<number> {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n\n if (this.isCryptoCode(fromUpper) || this.isCryptoCode(toUpper)) {\n return this.getCryptoRate(fromUpper, toUpper, signal);\n }\n\n // Combine the caller's optional abort signal with a hard timeout so a\n // hanging currency API never blocks re-evaluation indefinitely.\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Currency API fetch\",\n );\n\n try {\n const response = await fetch(`https://api.frankfurter.dev/v2/rates?base=${fromUpper}`, { signal: fetchSignal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.API_ERROR, `Currency API returned ${response.status}`, { status: response.status });\n const data = await response.json();\n // The v2 endpoint returns a flat array of { date, base, quote, rate }\n // entries (one per target currency) rather than the classic v1 shape\n // { base, date, rates: { CODE: rate } }. Reading data.rates against\n // the real response is always undefined, so every conversion used to\n // throw \"Unknown currency\" no matter which currencies were requested.\n // Accept both shapes so a future API revision back to the object form\n // doesn't silently break this again.\n const rates: Record<string, number> = Array.isArray(data)\n ? Object.fromEntries(\n data\n .filter((entry: unknown): entry is { quote: string; rate: number } => {\n if (typeof entry !== \"object\" || entry === null) return false;\n const candidate = entry as { quote?: unknown; rate?: unknown };\n return typeof candidate.quote === \"string\" && typeof candidate.rate === \"number\";\n })\n .map((entry: { quote: string; rate: number }) => [entry.quote.toUpperCase(), entry.rate])\n )\n : (data.rates ?? {});\n if (rates[toUpper] === undefined) throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n\n // The API returns ALL rates for the base currency, cache the whole\n // table so subsequent conversions (including cross pairs via\n // triangulation) resolve synchronously within the freshness window\n // instead of going Pending again.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [fromUpper]: 1 },\n });\n\n return rates[toUpper];\n } finally {\n cleanup();\n }\n }\n\n /**\n * Crypto rate fetch, routed through CoinGecko's no-auth simple-price\n * endpoint instead of Frankfurter (fiat-only, has no BTC/ETH concept).\n * Handles all three combinations, crypto→crypto, crypto→fiat\n * fiat→crypto, via prices denominated in USD (or the target fiat\n * directly, which CoinGecko's `vs_currencies` also accepts), then\n * caches the result as a same-shaped base table so getRateSync /\n * convertSync keep working unchanged for crypto pairs too.\n */\n private async getCryptoRate(fromUpper: string, toUpper: string, signal?: AbortSignal): Promise<number> {\n const { signal: fetchSignal, cleanup } = createTimeoutSignal(\n signal,\n CurrencyExchangeService.FETCH_TIMEOUT_MS,\n \"Crypto price API fetch\",\n );\n\n try {\n const fromIsCrypto = this.isCryptoCode(fromUpper);\n const toIsCrypto = this.isCryptoCode(toUpper);\n let rate: number;\n\n if (fromIsCrypto && toIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const data = await this.fetchCoinGeckoPrices([fromId, toId], \"usd\", fetchSignal);\n const fromUsd = data[fromId]?.usd;\n const toUsd = data[toId]?.usd;\n if (typeof fromUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n if (typeof toUsd !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = fromUsd / toUsd;\n } else if (fromIsCrypto) {\n const fromId = CurrencyExchangeService.CRYPTO_IDS[fromUpper];\n const vs = toUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([fromId], vs, fetchSignal);\n const value = data[fromId]?.[vs];\n if (typeof value !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${toUpper}`, { code: toUpper });\n rate = value;\n } else {\n const toId = CurrencyExchangeService.CRYPTO_IDS[toUpper];\n const vs = fromUpper.toLowerCase();\n const data = await this.fetchCoinGeckoPrices([toId], vs, fetchSignal);\n const priceOfToInFrom = data[toId]?.[vs];\n if (typeof priceOfToInFrom !== \"number\") throw ErrorFactory.validation(CurrencyErrorCodes.UNKNOWN_CODE, `Unknown currency: ${fromUpper}`, { code: fromUpper });\n rate = 1 / priceOfToInFrom;\n }\n\n // Cache as a single-pair base table, same shape Frankfurter fetches\n // produce, so getRateSync/convertSync's triangulation logic doesn't\n // need to know or care which source a rate came from.\n this.baseTables.set(fromUpper, {\n fetchedAt: Date.now(),\n rates: { [fromUpper]: 1, [toUpper]: rate },\n });\n\n return rate;\n } finally {\n cleanup();\n }\n }\n\n private async fetchCoinGeckoPrices(ids: string[], vsCurrency: string, signal: AbortSignal): Promise<Record<string, Record<string, number>>> {\n const url = `https://api.coingecko.com/api/v3/simple/price?ids=${ids.join(\",\")}&vs_currencies=${vsCurrency}`;\n const response = await fetch(url, { signal });\n if (!response.ok) throw ErrorFactory.external(CurrencyErrorCodes.CRYPTO_API_ERROR, `Crypto price API returned ${response.status}`, { status: response.status });\n return response.json();\n }\n\n /**\n * Seed a base rate table without a network fetch.\n *\n * Intended for tests and for future user-provided offline rates\n * production live data always comes from {@link getRate}. Seeded rates\n * obey the same freshness window as fetched ones.\n *\n * @param base - Base currency code (e.g. \"USD\").\n * @param rates - Map of currency code → rate relative to the base.\n */\n primeRates(base: string, rates: Record<string, number>): void {\n const baseUpper = base.toUpperCase();\n this.baseTables.set(baseUpper, {\n fetchedAt: Date.now(),\n rates: { ...rates, [baseUpper]: 1 },\n });\n }\n\n /**\n * Drop every cached/primed rate table.\n *\n * Mainly for test isolation: {@link sharedCurrencyExchange} is a\n * module-level singleton, so a rate primed or fetched by one test can\n * silently leak into a later test in the same file. Also usable in\n * production if a caller ever wants to force a full re-fetch.\n */\n clearRates(): void {\n this.baseTables.clear();\n }\n\n /**\n * Synchronous rate lookup: `1` for same-currency pairs, a cached LIVE\n * rate if one was fetched within {@link RATE_FRESHNESS_MS}, otherwise\n * `null`, callers fall through to the async fetch path and the\n * expression shows Pending until real data arrives.\n *\n * There is deliberately no hardcoded fallback table: a stale made-up\n * rate presented as a real conversion is worse than a Pending state.\n */\n getRateSync(from: string, to: string): number | null {\n const fromUpper = from.toUpperCase();\n const toUpper = to.toUpperCase();\n if (fromUpper === toUpper) {\n return 1;\n }\n const now = Date.now();\n for (const table of this.baseTables.values()) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n const fromRate = table.rates[fromUpper];\n const toRate = table.rates[toUpper];\n if (fromRate && toRate) {\n return toRate / fromRate;\n }\n }\n return null;\n }\n\n /** Convert `value` from `from` to `to` using a freshly-fetched live rate (see {@link getRate}). */\n async convert(value: number, from: string, to: string): Promise<number> {\n const rate = await this.getRate(from, to);\n return value * rate;\n }\n\n /**\n * Get all currently cached fresh rates, keyed \"FROM:TO\".\n * @returns Snapshot of fresh live rates, or null when none are cached.\n */\n getAllRates(): Record<string, number> | null {\n const now = Date.now();\n const snapshot: Record<string, number> = {};\n let any = false;\n for (const [base, table] of this.baseTables) {\n if (now - table.fetchedAt > CurrencyExchangeService.RATE_FRESHNESS_MS) continue;\n for (const [code, rate] of Object.entries(table.rates)) {\n snapshot[`${base}:${code}`] = rate;\n any = true;\n }\n }\n return any ? snapshot : null;\n }\n\n /**\n * Check whether any fresh live rates are currently cached.\n */\n hasRates(): boolean {\n return this.getAllRates() !== null;\n }\n\n /**\n * Synchronous conversion using cached rates only\n * Returns null if rate not in cache\n */\n convertSync(value: number, from: string, to: string): number | null {\n const rate = this.getRateSync(from, to);\n if (rate === null) return null;\n return value * rate;\n }\n\n // ------------------------------------------------------------------------\n // CURRENCY VALIDATION\n // ------------------------------------------------------------------------\n\n /**\n * Check whether `code` is a recognized currency code: any active ISO 4217\n * code, or one of the cryptocurrencies in {@link CRYPTO_IDS}.\n *\n * This used to be a hand-written list of forty-six codes, which meant\n * `$100 in UAH` returned an unconverted hundred dollars rather than saying\n * it could not convert. Answering from the standard rather than from\n * whichever codes happened to get added is what stops that class of bug.\n *\n * Recognising a code is not the same as having a rate for it. That is\n * answered later, by the exchange provider; conflating the two is what\n * produced the silent failure.\n */\n isCurrency(code: string): boolean {\n return isIso4217(code) || this.isCryptoCode(code);\n }\n}\n\n// ============================================================================\n// SINGLETON INSTANCE\n// ============================================================================\n\n/** The shared rate cache. See {@link CurrencyExchangeService} for why it is shared. */\nexport const currencyExchangeService = new CurrencyExchangeService();\n\n// Export for backward compatibility\n/** Alias for {@link currencyExchangeService}, kept for older imports. */\nexport const sharedCurrencyExchange = currencyExchangeService;\n\n// Default export\nexport default currencyExchangeService;\n"]}
|