phecda-server 7.0.0-alpha.15 → 7.0.0-alpha.18
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 +10 -10
- package/assets/schema.json +1 -7
- package/bin/cli.mjs +16 -11
- package/dist/chunk-25LNE62T.mjs +325 -0
- package/dist/chunk-25LNE62T.mjs.map +1 -0
- package/dist/chunk-2AANNMKJ.js +339 -0
- package/dist/chunk-2AANNMKJ.js.map +1 -0
- package/dist/chunk-2AF4PNIP.mjs +548 -0
- package/dist/chunk-2AF4PNIP.mjs.map +1 -0
- package/dist/chunk-2ATTABKA.mjs +330 -0
- package/dist/chunk-2ATTABKA.mjs.map +1 -0
- package/dist/chunk-2TZOJIU5.mjs +548 -0
- package/dist/chunk-2TZOJIU5.mjs.map +1 -0
- package/dist/chunk-2WO3UGXN.js +551 -0
- package/dist/chunk-2WO3UGXN.js.map +1 -0
- package/dist/chunk-3GHLAAIB.js +330 -0
- package/dist/chunk-3GHLAAIB.js.map +1 -0
- package/dist/chunk-3OHQDPV2.js +548 -0
- package/dist/chunk-3OHQDPV2.js.map +1 -0
- package/dist/chunk-3P3Z5UC6.mjs +150 -0
- package/dist/chunk-3P3Z5UC6.mjs.map +1 -0
- package/dist/chunk-3XK2RTI2.mjs +563 -0
- package/dist/chunk-3XK2RTI2.mjs.map +1 -0
- package/dist/chunk-4G7TPEE2.mjs +330 -0
- package/dist/chunk-4G7TPEE2.mjs.map +1 -0
- package/dist/chunk-4GH4IFBL.mjs +339 -0
- package/dist/chunk-4GH4IFBL.mjs.map +1 -0
- package/dist/chunk-56Y5GBKV.mjs +336 -0
- package/dist/chunk-56Y5GBKV.mjs.map +1 -0
- package/dist/{chunk-MUI6MTUO.mjs → chunk-5DOJ5DLK.mjs} +2 -1
- package/dist/chunk-5DOJ5DLK.mjs.map +1 -0
- package/dist/chunk-5SMDKUTT.js +551 -0
- package/dist/chunk-5SMDKUTT.js.map +1 -0
- package/dist/chunk-672QEOST.js +549 -0
- package/dist/chunk-672QEOST.js.map +1 -0
- package/dist/{chunk-YCES6ABN.mjs → chunk-6JAHCTOT.mjs} +2 -1
- package/dist/chunk-6JAHCTOT.mjs.map +1 -0
- package/dist/chunk-6TVDK7LS.mjs +334 -0
- package/dist/chunk-6TVDK7LS.mjs.map +1 -0
- package/dist/chunk-6UFCTN4R.mjs +153 -0
- package/dist/chunk-6UFCTN4R.mjs.map +1 -0
- package/dist/chunk-6WL4Q3PG.js +546 -0
- package/dist/chunk-6WL4Q3PG.js.map +1 -0
- package/dist/chunk-77T6PXFR.js +330 -0
- package/dist/chunk-77T6PXFR.js.map +1 -0
- package/dist/chunk-7BE5DAYB.mjs +548 -0
- package/dist/chunk-7BE5DAYB.mjs.map +1 -0
- package/dist/{chunk-KCPBITYZ.js → chunk-7RF74WML.js} +25 -24
- package/dist/chunk-7RF74WML.js.map +1 -0
- package/dist/chunk-7SKWIPNP.js +230 -0
- package/dist/chunk-7SKWIPNP.js.map +1 -0
- package/dist/chunk-7VCG4CO6.js +551 -0
- package/dist/chunk-7VCG4CO6.js.map +1 -0
- package/dist/chunk-7X5SWO7F.js +230 -0
- package/dist/chunk-7X5SWO7F.js.map +1 -0
- package/dist/chunk-A2ZAEKXE.js +230 -0
- package/dist/chunk-A2ZAEKXE.js.map +1 -0
- package/dist/chunk-A7IQ3C2W.mjs +551 -0
- package/dist/chunk-A7IQ3C2W.mjs.map +1 -0
- package/dist/chunk-A7Z6WC2U.mjs +549 -0
- package/dist/chunk-A7Z6WC2U.mjs.map +1 -0
- package/dist/{chunk-VX4BZEL7.mjs → chunk-AH2GHJYG.mjs} +12 -8
- package/dist/chunk-AH2GHJYG.mjs.map +1 -0
- package/dist/chunk-AKRBZ4QH.js +327 -0
- package/dist/chunk-AKRBZ4QH.js.map +1 -0
- package/dist/chunk-AUF4H6MB.mjs +330 -0
- package/dist/chunk-AUF4H6MB.mjs.map +1 -0
- package/dist/chunk-B4LHVDDL.js +329 -0
- package/dist/chunk-B4LHVDDL.js.map +1 -0
- package/dist/chunk-BVI6MJ57.js +150 -0
- package/dist/chunk-BVI6MJ57.js.map +1 -0
- package/dist/chunk-BZMKWF3E.mjs +546 -0
- package/dist/chunk-BZMKWF3E.mjs.map +1 -0
- package/dist/chunk-BZMKZ733.mjs +154 -0
- package/dist/chunk-BZMKZ733.mjs.map +1 -0
- package/dist/chunk-C2MTV2HS.js +148 -0
- package/dist/chunk-C2MTV2HS.js.map +1 -0
- package/dist/chunk-CGHKI3FB.js +548 -0
- package/dist/chunk-CGHKI3FB.js.map +1 -0
- package/dist/chunk-CLQEY47X.js +154 -0
- package/dist/chunk-CLQEY47X.js.map +1 -0
- package/dist/chunk-DIDCPEI7.js +546 -0
- package/dist/chunk-DIDCPEI7.js.map +1 -0
- package/dist/chunk-DJCMOLNU.mjs +547 -0
- package/dist/chunk-DJCMOLNU.mjs.map +1 -0
- package/dist/chunk-DJKIF6CO.mjs +230 -0
- package/dist/chunk-DJKIF6CO.mjs.map +1 -0
- package/dist/chunk-DZXOLJ2U.mjs +546 -0
- package/dist/chunk-DZXOLJ2U.mjs.map +1 -0
- package/dist/chunk-EEZLSH37.js +230 -0
- package/dist/chunk-EEZLSH37.js.map +1 -0
- package/dist/chunk-EYNIZVQM.js +334 -0
- package/dist/chunk-EYNIZVQM.js.map +1 -0
- package/dist/chunk-FA4XQ5HS.mjs +547 -0
- package/dist/chunk-FA4XQ5HS.mjs.map +1 -0
- package/dist/chunk-FBN6O256.js +153 -0
- package/dist/chunk-FBN6O256.js.map +1 -0
- package/dist/chunk-FJYLWOEI.js +325 -0
- package/dist/chunk-FJYLWOEI.js.map +1 -0
- package/dist/chunk-FV5CWX5Y.js +563 -0
- package/dist/chunk-FV5CWX5Y.js.map +1 -0
- package/dist/chunk-FZIJNZOP.js +546 -0
- package/dist/chunk-FZIJNZOP.js.map +1 -0
- package/dist/chunk-G377USSH.js +230 -0
- package/dist/chunk-G377USSH.js.map +1 -0
- package/dist/chunk-G3K6FCN4.js +549 -0
- package/dist/chunk-G3K6FCN4.js.map +1 -0
- package/dist/chunk-GA3YDUKH.js +150 -0
- package/dist/chunk-GA3YDUKH.js.map +1 -0
- package/dist/chunk-GMYV3IKV.mjs +548 -0
- package/dist/chunk-GMYV3IKV.mjs.map +1 -0
- package/dist/{chunk-IJFIY6QN.js → chunk-H7OCHDZT.js} +55 -63
- package/dist/chunk-H7OCHDZT.js.map +1 -0
- package/dist/chunk-HBITJSAJ.js +334 -0
- package/dist/chunk-HBITJSAJ.js.map +1 -0
- package/dist/chunk-HGCBKGAE.js +563 -0
- package/dist/chunk-HGCBKGAE.js.map +1 -0
- package/dist/chunk-HGQUWR5Y.js +548 -0
- package/dist/chunk-HGQUWR5Y.js.map +1 -0
- package/dist/chunk-HNHYJHTR.mjs +150 -0
- package/dist/chunk-HNHYJHTR.mjs.map +1 -0
- package/dist/chunk-HOMMTTY3.js +549 -0
- package/dist/chunk-HOMMTTY3.js.map +1 -0
- package/dist/chunk-HPCKU764.js +230 -0
- package/dist/chunk-HPCKU764.js.map +1 -0
- package/dist/chunk-HWZUI3S7.mjs +154 -0
- package/dist/chunk-HWZUI3S7.mjs.map +1 -0
- package/dist/chunk-HXAYHDBD.mjs +324 -0
- package/dist/chunk-HXAYHDBD.mjs.map +1 -0
- package/dist/chunk-I7Q27MJV.mjs +230 -0
- package/dist/chunk-I7Q27MJV.mjs.map +1 -0
- package/dist/{chunk-6OQ2SB5W.js → chunk-IIAJBTJE.js} +19 -22
- package/dist/chunk-IIAJBTJE.js.map +1 -0
- package/dist/chunk-IPEKAVER.js +336 -0
- package/dist/chunk-IPEKAVER.js.map +1 -0
- package/dist/chunk-IUBKOGEX.js +337 -0
- package/dist/chunk-IUBKOGEX.js.map +1 -0
- package/dist/chunk-JF5Q4N2N.mjs +330 -0
- package/dist/chunk-JF5Q4N2N.mjs.map +1 -0
- package/dist/chunk-JL3U632E.mjs +329 -0
- package/dist/chunk-JL3U632E.mjs.map +1 -0
- package/dist/chunk-JZW6S7UZ.mjs +334 -0
- package/dist/chunk-JZW6S7UZ.mjs.map +1 -0
- package/dist/chunk-K7BBDAQV.js +330 -0
- package/dist/chunk-K7BBDAQV.js.map +1 -0
- package/dist/chunk-KATTCXH7.mjs +153 -0
- package/dist/chunk-KATTCXH7.mjs.map +1 -0
- package/dist/chunk-KHHTD6W2.js +325 -0
- package/dist/chunk-KHHTD6W2.js.map +1 -0
- package/dist/chunk-KJTJTAM5.js +547 -0
- package/dist/chunk-KJTJTAM5.js.map +1 -0
- package/dist/chunk-KUGU3UGO.js +334 -0
- package/dist/chunk-KUGU3UGO.js.map +1 -0
- package/dist/chunk-LBH4RXQQ.mjs +534 -0
- package/dist/chunk-LBH4RXQQ.mjs.map +1 -0
- package/dist/chunk-LMCXPBEL.js +230 -0
- package/dist/chunk-LMCXPBEL.js.map +1 -0
- package/dist/chunk-LPCFXBIN.mjs +554 -0
- package/dist/chunk-LPCFXBIN.mjs.map +1 -0
- package/dist/chunk-LWKMKMGP.mjs +551 -0
- package/dist/chunk-LWKMKMGP.mjs.map +1 -0
- package/dist/chunk-M2NBQIY4.js +230 -0
- package/dist/chunk-M2NBQIY4.js.map +1 -0
- package/dist/chunk-MCVUJNTJ.mjs +546 -0
- package/dist/chunk-MCVUJNTJ.mjs.map +1 -0
- package/dist/{chunk-NQ55PA2X.mjs → chunk-MDPW6WGF.mjs} +1 -0
- package/dist/chunk-MDPW6WGF.mjs.map +1 -0
- package/dist/chunk-O23LYYQO.mjs +549 -0
- package/dist/chunk-O23LYYQO.mjs.map +1 -0
- package/dist/chunk-OGNSLEM7.js +562 -0
- package/dist/chunk-OGNSLEM7.js.map +1 -0
- package/dist/chunk-OSCTXAED.js +154 -0
- package/dist/chunk-OSCTXAED.js.map +1 -0
- package/dist/chunk-P5DXLNAV.mjs +334 -0
- package/dist/chunk-P5DXLNAV.mjs.map +1 -0
- package/dist/chunk-PDKES3CS.js +334 -0
- package/dist/chunk-PDKES3CS.js.map +1 -0
- package/dist/chunk-PLD4EI4W.mjs +334 -0
- package/dist/chunk-PLD4EI4W.mjs.map +1 -0
- package/dist/chunk-PQXBA7RP.mjs +325 -0
- package/dist/chunk-PQXBA7RP.mjs.map +1 -0
- package/dist/chunk-PUXTWHMP.mjs +337 -0
- package/dist/chunk-PUXTWHMP.mjs.map +1 -0
- package/dist/chunk-PWYWGN3L.mjs +562 -0
- package/dist/chunk-PWYWGN3L.mjs.map +1 -0
- package/dist/chunk-PXWSDTIP.mjs +551 -0
- package/dist/chunk-PXWSDTIP.mjs.map +1 -0
- package/dist/chunk-Q64YUA6Q.js +153 -0
- package/dist/chunk-Q64YUA6Q.js.map +1 -0
- package/dist/chunk-Q7FATBG4.mjs +327 -0
- package/dist/chunk-Q7FATBG4.mjs.map +1 -0
- package/dist/chunk-QLR7YJ7K.js +548 -0
- package/dist/chunk-QLR7YJ7K.js.map +1 -0
- package/dist/chunk-QNTSTOHM.mjs +230 -0
- package/dist/chunk-QNTSTOHM.mjs.map +1 -0
- package/dist/chunk-QP2HPQND.js +548 -0
- package/dist/chunk-QP2HPQND.js.map +1 -0
- package/dist/{chunk-4LLLQOMF.js → chunk-RLFCI3RG.js} +1 -0
- package/dist/chunk-RLFCI3RG.js.map +1 -0
- package/dist/chunk-RW5HHB6Z.mjs +230 -0
- package/dist/chunk-RW5HHB6Z.mjs.map +1 -0
- package/dist/chunk-RXBJH74V.js +334 -0
- package/dist/chunk-RXBJH74V.js.map +1 -0
- package/dist/chunk-S2B3Y2WJ.mjs +230 -0
- package/dist/chunk-S2B3Y2WJ.mjs.map +1 -0
- package/dist/chunk-SCA7SXI6.mjs +334 -0
- package/dist/chunk-SCA7SXI6.mjs.map +1 -0
- package/dist/chunk-SE2XQSPO.js +549 -0
- package/dist/chunk-SE2XQSPO.js.map +1 -0
- package/dist/chunk-SP4ASHBX.mjs +334 -0
- package/dist/chunk-SP4ASHBX.mjs.map +1 -0
- package/dist/chunk-TFK3ICC2.mjs +548 -0
- package/dist/chunk-TFK3ICC2.mjs.map +1 -0
- package/dist/chunk-TQR7KDFP.mjs +150 -0
- package/dist/chunk-TQR7KDFP.mjs.map +1 -0
- package/dist/chunk-TRJVULA2.js +330 -0
- package/dist/chunk-TRJVULA2.js.map +1 -0
- package/dist/chunk-TU4XB7CZ.mjs +230 -0
- package/dist/chunk-TU4XB7CZ.mjs.map +1 -0
- package/dist/chunk-U7EKEUCU.mjs +549 -0
- package/dist/chunk-U7EKEUCU.mjs.map +1 -0
- package/dist/chunk-UBQ4FXWS.js +554 -0
- package/dist/chunk-UBQ4FXWS.js.map +1 -0
- package/dist/chunk-UFQBSH4U.mjs +230 -0
- package/dist/chunk-UFQBSH4U.mjs.map +1 -0
- package/dist/chunk-UUHB6RHI.mjs +230 -0
- package/dist/chunk-UUHB6RHI.mjs.map +1 -0
- package/dist/chunk-UUKYR5HO.js +336 -0
- package/dist/chunk-UUKYR5HO.js.map +1 -0
- package/dist/chunk-UZTDXFFC.js +547 -0
- package/dist/chunk-UZTDXFFC.js.map +1 -0
- package/dist/chunk-V6AD4Y74.js +550 -0
- package/dist/chunk-V6AD4Y74.js.map +1 -0
- package/dist/chunk-VBBZA6PA.mjs +148 -0
- package/dist/chunk-VBBZA6PA.mjs.map +1 -0
- package/dist/chunk-VM4RFF4O.js +339 -0
- package/dist/chunk-VM4RFF4O.js.map +1 -0
- package/dist/chunk-W4AIKOBG.mjs +330 -0
- package/dist/chunk-W4AIKOBG.mjs.map +1 -0
- package/dist/chunk-WCLQYWET.mjs +328 -0
- package/dist/chunk-WCLQYWET.mjs.map +1 -0
- package/dist/chunk-WRN4ZVJQ.js +334 -0
- package/dist/chunk-WRN4ZVJQ.js.map +1 -0
- package/dist/chunk-X2H2PYE4.js +328 -0
- package/dist/chunk-X2H2PYE4.js.map +1 -0
- package/dist/chunk-X4YZRAFM.mjs +563 -0
- package/dist/chunk-X4YZRAFM.mjs.map +1 -0
- package/dist/chunk-X6M4LKQR.mjs +550 -0
- package/dist/chunk-X6M4LKQR.mjs.map +1 -0
- package/dist/chunk-X6WMGSPO.js +150 -0
- package/dist/chunk-X6WMGSPO.js.map +1 -0
- package/dist/chunk-XAI6JXXC.mjs +339 -0
- package/dist/chunk-XAI6JXXC.mjs.map +1 -0
- package/dist/chunk-XSABKCJD.js +546 -0
- package/dist/chunk-XSABKCJD.js.map +1 -0
- package/dist/chunk-XW3UEXLV.mjs +336 -0
- package/dist/chunk-XW3UEXLV.mjs.map +1 -0
- package/dist/chunk-YQYBLTSZ.js +330 -0
- package/dist/chunk-YQYBLTSZ.js.map +1 -0
- package/dist/chunk-YSRKB2RQ.js +334 -0
- package/dist/chunk-YSRKB2RQ.js.map +1 -0
- package/dist/chunk-YT4J7LJM.mjs +549 -0
- package/dist/chunk-YT4J7LJM.mjs.map +1 -0
- package/dist/chunk-YXXWVL32.mjs +330 -0
- package/dist/chunk-YXXWVL32.mjs.map +1 -0
- package/dist/chunk-Z4JSVZR3.js +324 -0
- package/dist/chunk-Z4JSVZR3.js.map +1 -0
- package/dist/{core-DiFYc0bC.d.mts → core--qu3pWkq.d.ts} +1 -1
- package/dist/core-BPUiAJHn.d.ts +49 -0
- package/dist/core-Bi3rTHpi.d.ts +49 -0
- package/dist/core-Bjw_HRhA.d.mts +49 -0
- package/dist/core-Brb7fvGi.d.ts +49 -0
- package/dist/core-C7FYVQ3G.d.ts +49 -0
- package/dist/core-C8nKzrYj.d.ts +49 -0
- package/dist/core-CTa38Qb8.d.mts +49 -0
- package/dist/core-C_vzHvIM.d.mts +49 -0
- package/dist/core-CjJyvCUL.d.mts +49 -0
- package/dist/core-CxB9E1Mb.d.mts +49 -0
- package/dist/core-D5cwjnXb.d.ts +49 -0
- package/dist/core-D9ivz8Je.d.mts +49 -0
- package/dist/{core-KvmgTDU0.d.ts → core-DEjpz7U-.d.ts} +1 -1
- package/dist/core-DFoppC8I.d.mts +49 -0
- package/dist/core-DU0-ELVr.d.ts +49 -0
- package/dist/core-Dk6Y21IK.d.mts +49 -0
- package/dist/core-ppueS5ax.d.mts +49 -0
- package/dist/core-scwP4qK3.d.ts +49 -0
- package/dist/core-vtBLhyjz.d.mts +49 -0
- package/dist/helper.d.mts +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js +4 -3
- package/dist/helper.js.map +1 -0
- package/dist/helper.mjs +3 -2
- package/dist/helper.mjs.map +1 -0
- package/dist/http/elysia/index.d.mts +3 -3
- package/dist/http/elysia/index.d.ts +3 -3
- package/dist/http/elysia/index.js +41 -40
- package/dist/http/elysia/index.js.map +1 -0
- package/dist/http/elysia/index.mjs +4 -3
- package/dist/http/elysia/index.mjs.map +1 -0
- package/dist/http/express/index.d.mts +3 -3
- package/dist/http/express/index.d.ts +3 -3
- package/dist/http/express/index.js +38 -37
- package/dist/http/express/index.js.map +1 -0
- package/dist/http/express/index.mjs +3 -2
- package/dist/http/express/index.mjs.map +1 -0
- package/dist/http/fastify/index.d.mts +3 -3
- package/dist/http/fastify/index.d.ts +3 -3
- package/dist/http/fastify/index.js +39 -38
- package/dist/http/fastify/index.js.map +1 -0
- package/dist/http/fastify/index.mjs +4 -3
- package/dist/http/fastify/index.mjs.map +1 -0
- package/dist/http/h3/index.d.mts +3 -3
- package/dist/http/h3/index.d.ts +3 -3
- package/dist/http/h3/index.js +39 -38
- package/dist/http/h3/index.js.map +1 -0
- package/dist/http/h3/index.mjs +3 -2
- package/dist/http/h3/index.mjs.map +1 -0
- package/dist/http/hono/index.d.mts +3 -3
- package/dist/http/hono/index.d.ts +3 -3
- package/dist/http/hono/index.js +35 -34
- package/dist/http/hono/index.js.map +1 -0
- package/dist/http/hono/index.mjs +3 -2
- package/dist/http/hono/index.mjs.map +1 -0
- package/dist/http/hyper-express/index.d.mts +3 -3
- package/dist/http/hyper-express/index.d.ts +3 -3
- package/dist/http/hyper-express/index.js +36 -35
- package/dist/http/hyper-express/index.js.map +1 -0
- package/dist/http/hyper-express/index.mjs +3 -2
- package/dist/http/hyper-express/index.mjs.map +1 -0
- package/dist/http/koa/index.d.mts +3 -3
- package/dist/http/koa/index.d.ts +3 -3
- package/dist/http/koa/index.js +38 -37
- package/dist/http/koa/index.js.map +1 -0
- package/dist/http/koa/index.mjs +3 -2
- package/dist/http/koa/index.mjs.map +1 -0
- package/dist/index.d.mts +8 -9
- package/dist/index.d.ts +8 -9
- package/dist/index.js +41 -40
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +13 -12
- package/dist/index.mjs.map +1 -0
- package/dist/meta-vC_LItVL.d.mts +90 -0
- package/dist/meta-vC_LItVL.d.ts +90 -0
- package/dist/rpc/bullmq/index.d.mts +3 -3
- package/dist/rpc/bullmq/index.d.ts +3 -3
- package/dist/rpc/bullmq/index.js +12 -11
- package/dist/rpc/bullmq/index.js.map +1 -0
- package/dist/rpc/bullmq/index.mjs +3 -2
- package/dist/rpc/bullmq/index.mjs.map +1 -0
- package/dist/rpc/electron/index.d.mts +3 -3
- package/dist/rpc/electron/index.d.ts +3 -3
- package/dist/rpc/electron/index.js +9 -8
- package/dist/rpc/electron/index.js.map +1 -0
- package/dist/rpc/electron/index.mjs +3 -2
- package/dist/rpc/electron/index.mjs.map +1 -0
- package/dist/rpc/kafka/index.d.mts +3 -3
- package/dist/rpc/kafka/index.d.ts +3 -3
- package/dist/rpc/kafka/index.js +11 -10
- package/dist/rpc/kafka/index.js.map +1 -0
- package/dist/rpc/kafka/index.mjs +3 -2
- package/dist/rpc/kafka/index.mjs.map +1 -0
- package/dist/rpc/nats/index.d.mts +3 -3
- package/dist/rpc/nats/index.d.ts +3 -3
- package/dist/rpc/nats/index.js +12 -11
- package/dist/rpc/nats/index.js.map +1 -0
- package/dist/rpc/nats/index.mjs +3 -2
- package/dist/rpc/nats/index.mjs.map +1 -0
- package/dist/rpc/rabbitmq/index.d.mts +3 -3
- package/dist/rpc/rabbitmq/index.d.ts +3 -3
- package/dist/rpc/rabbitmq/index.js +13 -12
- package/dist/rpc/rabbitmq/index.js.map +1 -0
- package/dist/rpc/rabbitmq/index.mjs +3 -2
- package/dist/rpc/rabbitmq/index.mjs.map +1 -0
- package/dist/rpc/redis/index.d.mts +3 -3
- package/dist/rpc/redis/index.d.ts +3 -3
- package/dist/rpc/redis/index.js +11 -10
- package/dist/rpc/redis/index.js.map +1 -0
- package/dist/rpc/redis/index.mjs +3 -2
- package/dist/rpc/redis/index.mjs.map +1 -0
- package/dist/rpc/web-ext/index.d.mts +2 -0
- package/dist/rpc/web-ext/index.d.ts +2 -0
- package/dist/rpc/web-ext/index.js +1 -0
- package/dist/rpc/web-ext/index.js.map +1 -0
- package/dist/rpc/web-ext/index.mjs +1 -0
- package/dist/rpc/web-ext/index.mjs.map +1 -0
- package/dist/rpc/ws/index.d.mts +3 -3
- package/dist/rpc/ws/index.d.ts +3 -3
- package/dist/rpc/ws/index.js +8 -7
- package/dist/rpc/ws/index.js.map +1 -0
- package/dist/rpc/ws/index.mjs +3 -2
- package/dist/rpc/ws/index.mjs.map +1 -0
- package/dist/test.d.mts +3 -3
- package/dist/test.d.ts +3 -3
- package/dist/test.js +7 -6
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +3 -2
- package/dist/test.mjs.map +1 -0
- package/dist/{types-8r301ZfZ.d.mts → types--FU0xyv7.d.mts} +1 -1
- package/dist/types-7nUdSf8z.d.mts +19 -0
- package/dist/{types-CVSbC6nz.d.mts → types-BE2z6gOo.d.ts} +1 -1
- package/dist/types-BJiHDyTL.d.mts +19 -0
- package/dist/types-BRCJyQsh.d.mts +90 -0
- package/dist/types-BRCJyQsh.d.ts +90 -0
- package/dist/types-BV7YmpJE.d.ts +14 -0
- package/dist/{types-Bz3JN2S1.d.ts → types-BVswigDc.d.ts} +1 -1
- package/dist/types-B_RVNTOF.d.mts +91 -0
- package/dist/types-B_RVNTOF.d.ts +91 -0
- package/dist/types-BtM-DxqM.d.mts +48 -0
- package/dist/types-C-nIlDCV.d.mts +48 -0
- package/dist/types-C-wRAcbr.d.ts +48 -0
- package/dist/types-C2KvkrD6.d.mts +48 -0
- package/dist/{meta-DlHaMicF.d.ts → types-C6hpZpnS.d.mts} +43 -43
- package/dist/{meta-DlHaMicF.d.mts → types-C6hpZpnS.d.ts} +43 -43
- package/dist/types-CFX2Ln0s.d.mts +48 -0
- package/dist/types-CR_EmIw8.d.mts +48 -0
- package/dist/types-CbRiXnzh.d.ts +19 -0
- package/dist/types-Ci9JeYtv.d.ts +48 -0
- package/dist/types-CiL0rHL3.d.ts +19 -0
- package/dist/types-CuBnfbgb.d.mts +14 -0
- package/dist/types-CvPG7k2Z.d.mts +14 -0
- package/dist/types-D9vxgkS4.d.mts +48 -0
- package/dist/types-DHYok84r.d.mts +14 -0
- package/dist/types-DI40e_s_.d.mts +19 -0
- package/dist/{types-DJuqpiI8.d.ts → types-DTOe0r2g.d.ts} +1 -1
- package/dist/types-DWVRUI6s.d.mts +91 -0
- package/dist/types-DWVRUI6s.d.ts +91 -0
- package/dist/types-DX98FM-A.d.ts +19 -0
- package/dist/types-DdJI1b5J.d.mts +19 -0
- package/dist/types-DfNl_AGj.d.ts +48 -0
- package/dist/types-DfNtpP-N.d.mts +111 -0
- package/dist/types-DfNtpP-N.d.ts +111 -0
- package/dist/types-DfVkUOZW.d.ts +48 -0
- package/dist/types-DfsKsjLM.d.mts +111 -0
- package/dist/types-DfsKsjLM.d.ts +111 -0
- package/dist/types-Didk5ZxZ.d.ts +48 -0
- package/dist/types-DsvVhEYR.d.ts +48 -0
- package/dist/types-Dt4WHNIG.d.mts +48 -0
- package/dist/types-DtG1fW8q.d.mts +48 -0
- package/dist/types-DwkH_ckj.d.mts +107 -0
- package/dist/types-DwkH_ckj.d.ts +107 -0
- package/dist/types-GLyEDoZh.d.ts +48 -0
- package/dist/types-HFldWW-W.d.mts +48 -0
- package/dist/types-LfX4z-X2.d.mts +48 -0
- package/dist/types-Ru_9udNp.d.ts +48 -0
- package/dist/types-gz344phy.d.mts +14 -0
- package/dist/types-hTbg1FQR.d.ts +19 -0
- package/dist/types-laEKHNwU.d.ts +14 -0
- package/dist/types-mcWWx2nR.d.mts +108 -0
- package/dist/types-mcWWx2nR.d.ts +108 -0
- package/dist/types-nA5JQl76.d.ts +14 -0
- package/dist/types-ojuQvq5-.d.ts +19 -0
- package/dist/types-pCI7fyyv.d.mts +108 -0
- package/dist/types-pCI7fyyv.d.ts +108 -0
- package/dist/types-vyUwFCHY.d.mts +19 -0
- package/dist/types-xovMFthM.d.ts +14 -0
- package/package.json +7 -2
- package/register/index.mjs +2 -2
- package/register/loader.mjs +33 -27
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ERROR_SYMBOL,
|
|
3
|
+
HMR,
|
|
4
|
+
IS_DEV,
|
|
5
|
+
IS_PURE,
|
|
6
|
+
IS_STRICT,
|
|
7
|
+
LOG_LEVEL,
|
|
8
|
+
__name,
|
|
9
|
+
log
|
|
10
|
+
} from "./chunk-6UFCTN4R.mjs";
|
|
11
|
+
|
|
12
|
+
// src/helper.ts
|
|
13
|
+
import pc2 from "picocolors";
|
|
14
|
+
|
|
15
|
+
// src/context.ts
|
|
16
|
+
import Debug from "debug";
|
|
17
|
+
import pc from "picocolors";
|
|
18
|
+
|
|
19
|
+
// src/pipe.ts
|
|
20
|
+
var defaultPipe = /* @__PURE__ */ __name(({ arg }) => {
|
|
21
|
+
return arg;
|
|
22
|
+
}, "defaultPipe");
|
|
23
|
+
|
|
24
|
+
// src/exception/base.ts
|
|
25
|
+
var Exception = class extends Error {
|
|
26
|
+
static {
|
|
27
|
+
__name(this, "Exception");
|
|
28
|
+
}
|
|
29
|
+
message;
|
|
30
|
+
status;
|
|
31
|
+
description;
|
|
32
|
+
constructor(message, status = 0, description = "Exception") {
|
|
33
|
+
super(message);
|
|
34
|
+
this.message = message;
|
|
35
|
+
this.status = status;
|
|
36
|
+
this.description = description;
|
|
37
|
+
}
|
|
38
|
+
get data() {
|
|
39
|
+
return {
|
|
40
|
+
message: this.message,
|
|
41
|
+
description: this.description,
|
|
42
|
+
status: this.status,
|
|
43
|
+
[ERROR_SYMBOL]: true
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/exception/undefine.ts
|
|
49
|
+
var UndefinedException = class extends Exception {
|
|
50
|
+
static {
|
|
51
|
+
__name(this, "UndefinedException");
|
|
52
|
+
}
|
|
53
|
+
constructor(message) {
|
|
54
|
+
super(message, 500, "Undefined error");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// src/exception/validate.ts
|
|
59
|
+
var ValidateException = class extends Exception {
|
|
60
|
+
static {
|
|
61
|
+
__name(this, "ValidateException");
|
|
62
|
+
}
|
|
63
|
+
constructor(message) {
|
|
64
|
+
super(message, 400, "Validate exception");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/exception/forbidden.ts
|
|
69
|
+
var ForbiddenException = class extends Exception {
|
|
70
|
+
static {
|
|
71
|
+
__name(this, "ForbiddenException");
|
|
72
|
+
}
|
|
73
|
+
constructor(message) {
|
|
74
|
+
super(message, 403, "Forbidden resource");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/exception/bad-request.ts
|
|
79
|
+
var BadRequestException = class extends Exception {
|
|
80
|
+
static {
|
|
81
|
+
__name(this, "BadRequestException");
|
|
82
|
+
}
|
|
83
|
+
constructor(message) {
|
|
84
|
+
super(message, 400, "Bad Request");
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// src/exception/not-found.ts
|
|
89
|
+
var NotFoundException = class extends Exception {
|
|
90
|
+
static {
|
|
91
|
+
__name(this, "NotFoundException");
|
|
92
|
+
}
|
|
93
|
+
constructor(message) {
|
|
94
|
+
super(message, 404, "Not Found");
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/exception/conflict.ts
|
|
99
|
+
var ConflictException = class extends Exception {
|
|
100
|
+
static {
|
|
101
|
+
__name(this, "ConflictException");
|
|
102
|
+
}
|
|
103
|
+
constructor(message) {
|
|
104
|
+
super(message, 409, "Conflict");
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// src/exception/bad-gateway.ts
|
|
109
|
+
var BadGatewayException = class extends Exception {
|
|
110
|
+
static {
|
|
111
|
+
__name(this, "BadGatewayException");
|
|
112
|
+
}
|
|
113
|
+
constructor(message) {
|
|
114
|
+
super(message, 502, "Bad Gatrway");
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/exception/invalid-input.ts
|
|
119
|
+
var InvalidInputException = class extends Exception {
|
|
120
|
+
static {
|
|
121
|
+
__name(this, "InvalidInputException");
|
|
122
|
+
}
|
|
123
|
+
constructor(message) {
|
|
124
|
+
super(message, 502, "Invalid Input");
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/exception/media-type.ts
|
|
129
|
+
var UnsupportedMediaTypeException = class extends Exception {
|
|
130
|
+
static {
|
|
131
|
+
__name(this, "UnsupportedMediaTypeException");
|
|
132
|
+
}
|
|
133
|
+
constructor(message) {
|
|
134
|
+
super(message, 415, "Unsupported Media Type");
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/exception/payload-large.ts
|
|
139
|
+
var PayloadLargeException = class extends Exception {
|
|
140
|
+
static {
|
|
141
|
+
__name(this, "PayloadLargeException");
|
|
142
|
+
}
|
|
143
|
+
constructor(message) {
|
|
144
|
+
super(message, 413, "Payload Too Large");
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/exception/timeout.ts
|
|
149
|
+
var TimeoutException = class extends Exception {
|
|
150
|
+
static {
|
|
151
|
+
__name(this, "TimeoutException");
|
|
152
|
+
}
|
|
153
|
+
constructor(message) {
|
|
154
|
+
super(message, 408, "Request Timeout");
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/exception/unauthorized.ts
|
|
159
|
+
var UnauthorizedException = class extends Exception {
|
|
160
|
+
static {
|
|
161
|
+
__name(this, "UnauthorizedException");
|
|
162
|
+
}
|
|
163
|
+
constructor(message) {
|
|
164
|
+
super(message, 401, "Unauthorized");
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/exception/unavailable-service.ts
|
|
169
|
+
var ServiceUnavailableException = class extends Exception {
|
|
170
|
+
static {
|
|
171
|
+
__name(this, "ServiceUnavailableException");
|
|
172
|
+
}
|
|
173
|
+
constructor(message) {
|
|
174
|
+
super(message, 503, "Service Unavailable");
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/exception/framework.ts
|
|
179
|
+
var FrameworkException = class extends Exception {
|
|
180
|
+
static {
|
|
181
|
+
__name(this, "FrameworkException");
|
|
182
|
+
}
|
|
183
|
+
constructor(message) {
|
|
184
|
+
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/exception/timer.ts
|
|
189
|
+
var TimerException = class extends Exception {
|
|
190
|
+
static {
|
|
191
|
+
__name(this, "TimerException");
|
|
192
|
+
}
|
|
193
|
+
constructor(message) {
|
|
194
|
+
super(message, 0, "Timer Error");
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// src/exception/worker.ts
|
|
199
|
+
var WorkerException = class extends Exception {
|
|
200
|
+
static {
|
|
201
|
+
__name(this, "WorkerException");
|
|
202
|
+
}
|
|
203
|
+
constructor(message) {
|
|
204
|
+
super(message, 0, "Worker Error");
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/filter.ts
|
|
209
|
+
var defaultFilter = /* @__PURE__ */ __name((e) => {
|
|
210
|
+
if (!(e instanceof Exception)) {
|
|
211
|
+
log(e.message, "error");
|
|
212
|
+
if (LOG_LEVEL <= 0) console.error(e.stack);
|
|
213
|
+
e = new UndefinedException(e.message || e);
|
|
214
|
+
} else {
|
|
215
|
+
log(`[${e.constructor.name}] ${e.message}`, "error");
|
|
216
|
+
if (LOG_LEVEL <= 0) console.error(e.stack);
|
|
217
|
+
}
|
|
218
|
+
return e.data;
|
|
219
|
+
}, "defaultFilter");
|
|
220
|
+
|
|
221
|
+
// src/context.ts
|
|
222
|
+
var debug = Debug("phecda-server(Context)");
|
|
223
|
+
var Context = class _Context {
|
|
224
|
+
static {
|
|
225
|
+
__name(this, "Context");
|
|
226
|
+
}
|
|
227
|
+
data;
|
|
228
|
+
method;
|
|
229
|
+
params;
|
|
230
|
+
static filterRecord = {
|
|
231
|
+
default: defaultFilter
|
|
232
|
+
};
|
|
233
|
+
static pipeRecord = {
|
|
234
|
+
default: defaultPipe
|
|
235
|
+
};
|
|
236
|
+
static guardRecord = {};
|
|
237
|
+
static addonRecord = {};
|
|
238
|
+
ctx;
|
|
239
|
+
canGetCtx;
|
|
240
|
+
constructor(data) {
|
|
241
|
+
this.data = data;
|
|
242
|
+
this.canGetCtx = true;
|
|
243
|
+
if (IS_DEV)
|
|
244
|
+
data._context = this;
|
|
245
|
+
const that = this;
|
|
246
|
+
this.ctx = new Proxy(data, {
|
|
247
|
+
get(target, p) {
|
|
248
|
+
if (IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
249
|
+
if (!(p in target)) log(`attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
250
|
+
return target[p];
|
|
251
|
+
},
|
|
252
|
+
set(target, p, newValue) {
|
|
253
|
+
target[p] = newValue;
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
static getAop(meta, opts) {
|
|
259
|
+
const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
|
|
260
|
+
const { data: { guards, filter, params, tag, func } } = meta;
|
|
261
|
+
const resolved = {
|
|
262
|
+
guards: [
|
|
263
|
+
...globalGuards,
|
|
264
|
+
...guards
|
|
265
|
+
],
|
|
266
|
+
pipe: params.map((item) => item.pipe || globalPipe),
|
|
267
|
+
filter: filter || globalFilter
|
|
268
|
+
};
|
|
269
|
+
if (process.env.DEBUG) {
|
|
270
|
+
const { guards: guards2, pipe, filter: filter2 } = resolved;
|
|
271
|
+
debug(`func "${tag}-${func}" aop:
|
|
272
|
+
${pc.magenta(`Guard ${guards2.join("->")}[${guards2.filter((g) => g in this.guardRecord).join("->")}]`)}
|
|
273
|
+
${pc.blue(`Pipe ${pipe.join("-")}[${pipe.map((p) => p in this.pipeRecord ? p : "default").join("-")}]`)}
|
|
274
|
+
${pc.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
guards: this.getGuards(resolved.guards),
|
|
278
|
+
pipe: this.getPipe(resolved.pipe),
|
|
279
|
+
filter: this.getFilter(resolved.filter)
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
async run({ guards, filter, pipe }, successCb, failCb) {
|
|
283
|
+
const { meta, moduleMap } = this.data;
|
|
284
|
+
const { paramsType, data: { ctxs, tag, params, func } } = meta;
|
|
285
|
+
try {
|
|
286
|
+
let res;
|
|
287
|
+
const nextHandler = /* @__PURE__ */ __name((index) => {
|
|
288
|
+
return async () => {
|
|
289
|
+
if (index === guards.length) {
|
|
290
|
+
const instance = moduleMap.get(tag);
|
|
291
|
+
if (ctxs) {
|
|
292
|
+
ctxs.forEach((ctx) => instance[ctx] = this.ctx);
|
|
293
|
+
}
|
|
294
|
+
const args = await Promise.all(params.map((item, i) => pipe[i]({
|
|
295
|
+
arg: resolveDep(this.data[item.type], item.key),
|
|
296
|
+
reflect: paramsType[item.index],
|
|
297
|
+
...item
|
|
298
|
+
}, this.ctx)));
|
|
299
|
+
if (IS_DEV) {
|
|
300
|
+
Promise.resolve().then(() => {
|
|
301
|
+
this.canGetCtx = false;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
res = await instance[func](...args);
|
|
305
|
+
this.canGetCtx = true;
|
|
306
|
+
} else {
|
|
307
|
+
let nextPromise;
|
|
308
|
+
async function next() {
|
|
309
|
+
return nextPromise = nextHandler(index + 1)().then((ret2) => {
|
|
310
|
+
if (ret2 !== void 0) {
|
|
311
|
+
debug(`The ${index + 1}th guard on "${tag}-${func}" rewrite the response value.`);
|
|
312
|
+
res = ret2;
|
|
313
|
+
}
|
|
314
|
+
return res;
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
__name(next, "next");
|
|
318
|
+
const ret = await guards[index](this.ctx, next);
|
|
319
|
+
if (ret !== void 0) {
|
|
320
|
+
res = ret;
|
|
321
|
+
} else {
|
|
322
|
+
if (!nextPromise) await next();
|
|
323
|
+
else await nextPromise;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
}, "nextHandler");
|
|
328
|
+
await nextHandler(0)();
|
|
329
|
+
return successCb(res);
|
|
330
|
+
} catch (e) {
|
|
331
|
+
const err = await filter(e, this.ctx);
|
|
332
|
+
return failCb(err);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
static getPipe(pipe) {
|
|
336
|
+
return pipe.map((pipe2) => {
|
|
337
|
+
return _Context.pipeRecord[pipe2] || _Context.pipeRecord.default;
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
static getFilter(filter = "default") {
|
|
341
|
+
return _Context.filterRecord[filter] || _Context.filterRecord.default;
|
|
342
|
+
}
|
|
343
|
+
static getGuards(guards) {
|
|
344
|
+
const ret = [];
|
|
345
|
+
for (const guard of new Set(guards)) {
|
|
346
|
+
if (guard in _Context.guardRecord) ret.push(_Context.guardRecord[guard]);
|
|
347
|
+
}
|
|
348
|
+
return ret.sort((a, b) => b.priority - a.priority).map((item) => item.value);
|
|
349
|
+
}
|
|
350
|
+
static applyAddons(addons, router, framework) {
|
|
351
|
+
const ret = [];
|
|
352
|
+
for (const a of new Set(addons)) {
|
|
353
|
+
if (a in _Context.addonRecord) ret.push(_Context.addonRecord[a]);
|
|
354
|
+
}
|
|
355
|
+
ret.sort((a, b) => b.priority - a.priority).forEach((item) => item.value(router, framework));
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
function addPipe(key, pipe) {
|
|
359
|
+
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
360
|
+
Context.pipeRecord[key] = pipe;
|
|
361
|
+
}
|
|
362
|
+
__name(addPipe, "addPipe");
|
|
363
|
+
function addFilter(key, filter) {
|
|
364
|
+
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
365
|
+
Context.filterRecord[key] = filter;
|
|
366
|
+
}
|
|
367
|
+
__name(addFilter, "addFilter");
|
|
368
|
+
function addGuard(key, guard, priority = 0) {
|
|
369
|
+
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
370
|
+
Context.guardRecord[key] = {
|
|
371
|
+
value: guard,
|
|
372
|
+
priority
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
__name(addGuard, "addGuard");
|
|
376
|
+
function addAddon(key, addon, priority = 0) {
|
|
377
|
+
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
378
|
+
Context.addonRecord[key] = {
|
|
379
|
+
value: addon,
|
|
380
|
+
priority
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
__name(addAddon, "addAddon");
|
|
384
|
+
|
|
385
|
+
// src/http/helper.ts
|
|
386
|
+
function resolveDep(ret, key) {
|
|
387
|
+
if (key) return ret?.[key];
|
|
388
|
+
return ret;
|
|
389
|
+
}
|
|
390
|
+
__name(resolveDep, "resolveDep");
|
|
391
|
+
|
|
392
|
+
// src/decorators/helper.ts
|
|
393
|
+
function shallowClone(obj) {
|
|
394
|
+
return {
|
|
395
|
+
...obj
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
__name(shallowClone, "shallowClone");
|
|
399
|
+
function mergeObject(...args) {
|
|
400
|
+
return Object.assign({}, ...args);
|
|
401
|
+
}
|
|
402
|
+
__name(mergeObject, "mergeObject");
|
|
403
|
+
|
|
404
|
+
// src/helper.ts
|
|
405
|
+
function createControllerMetaMap(meta, filter) {
|
|
406
|
+
const metaMap = /* @__PURE__ */ new Map();
|
|
407
|
+
function handleMeta() {
|
|
408
|
+
metaMap.clear();
|
|
409
|
+
for (const item of meta) {
|
|
410
|
+
const { tag, func } = item.data;
|
|
411
|
+
if (!filter(item)) continue;
|
|
412
|
+
if (metaMap.has(tag)) metaMap.get(tag)[func] = item;
|
|
413
|
+
else metaMap.set(tag, {
|
|
414
|
+
[func]: item
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
__name(handleMeta, "handleMeta");
|
|
419
|
+
handleMeta();
|
|
420
|
+
HMR(handleMeta);
|
|
421
|
+
return metaMap;
|
|
422
|
+
}
|
|
423
|
+
__name(createControllerMetaMap, "createControllerMetaMap");
|
|
424
|
+
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
425
|
+
if (IS_PURE) return;
|
|
426
|
+
const addonSet = /* @__PURE__ */ new Set();
|
|
427
|
+
const guardSet = /* @__PURE__ */ new Set();
|
|
428
|
+
const pipeSet = /* @__PURE__ */ new Set();
|
|
429
|
+
const filterSet = /* @__PURE__ */ new Set();
|
|
430
|
+
const warningSet = /* @__PURE__ */ new Set();
|
|
431
|
+
function handleMeta() {
|
|
432
|
+
addonSet.clear();
|
|
433
|
+
guardSet.clear();
|
|
434
|
+
pipeSet.clear();
|
|
435
|
+
filterSet.clear();
|
|
436
|
+
warningSet.clear();
|
|
437
|
+
addons?.forEach((item) => {
|
|
438
|
+
addonSet.add(item);
|
|
439
|
+
});
|
|
440
|
+
guards?.forEach((item) => {
|
|
441
|
+
guardSet.add(item);
|
|
442
|
+
});
|
|
443
|
+
meta.forEach(({ data }) => {
|
|
444
|
+
if (!data.controller) return;
|
|
445
|
+
if (typeof data.tag !== "string") warningSet.add(`Tag of controller "${data.name}" should be a string`);
|
|
446
|
+
if (data.controller !== controller) {
|
|
447
|
+
if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}"`);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (data.filter) filterSet.add(data.filter);
|
|
451
|
+
data.guards.forEach((i) => guardSet.add(i));
|
|
452
|
+
data.addons.forEach((i) => addonSet.add(i));
|
|
453
|
+
data.params.forEach((i) => {
|
|
454
|
+
if (i.pipe) pipeSet.add(i.pipe);
|
|
455
|
+
});
|
|
456
|
+
});
|
|
457
|
+
const missAddons = [
|
|
458
|
+
...addonSet
|
|
459
|
+
].filter((i) => !Context.addonRecord[i]);
|
|
460
|
+
const missGuards = [
|
|
461
|
+
...guardSet
|
|
462
|
+
].filter((i) => !Context.guardRecord[i]);
|
|
463
|
+
const missPipes = [
|
|
464
|
+
...pipeSet
|
|
465
|
+
].filter((i) => !Context.pipeRecord[i]);
|
|
466
|
+
const missFilters = [
|
|
467
|
+
...filterSet
|
|
468
|
+
].filter((i) => !Context.filterRecord[i]);
|
|
469
|
+
function exit() {
|
|
470
|
+
if (IS_STRICT) {
|
|
471
|
+
log("Does not meet strict mode requirements", "error");
|
|
472
|
+
process.exit(1);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
__name(exit, "exit");
|
|
476
|
+
if (missAddons.length) {
|
|
477
|
+
log(`${pc2.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
478
|
+
exit();
|
|
479
|
+
}
|
|
480
|
+
if (missGuards.length) {
|
|
481
|
+
log(`${pc2.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
482
|
+
exit();
|
|
483
|
+
}
|
|
484
|
+
if (missPipes.length) {
|
|
485
|
+
log(`${pc2.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
486
|
+
exit();
|
|
487
|
+
}
|
|
488
|
+
if (missFilters.length) {
|
|
489
|
+
log(`${pc2.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
490
|
+
exit();
|
|
491
|
+
}
|
|
492
|
+
warningSet.forEach((warn) => log(warn, "warn"));
|
|
493
|
+
if (warningSet.size) exit();
|
|
494
|
+
}
|
|
495
|
+
__name(handleMeta, "handleMeta");
|
|
496
|
+
handleMeta();
|
|
497
|
+
HMR(handleMeta);
|
|
498
|
+
return {
|
|
499
|
+
addonSet,
|
|
500
|
+
guardSet,
|
|
501
|
+
pipeSet,
|
|
502
|
+
filterSet
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
__name(detectAopDep, "detectAopDep");
|
|
506
|
+
function joinUrl(base, ...paths) {
|
|
507
|
+
const joinedPath = [
|
|
508
|
+
base,
|
|
509
|
+
...paths
|
|
510
|
+
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
511
|
+
return `/${joinedPath}`;
|
|
512
|
+
}
|
|
513
|
+
__name(joinUrl, "joinUrl");
|
|
514
|
+
|
|
515
|
+
export {
|
|
516
|
+
defaultPipe,
|
|
517
|
+
Exception,
|
|
518
|
+
UndefinedException,
|
|
519
|
+
ValidateException,
|
|
520
|
+
ForbiddenException,
|
|
521
|
+
BadRequestException,
|
|
522
|
+
NotFoundException,
|
|
523
|
+
ConflictException,
|
|
524
|
+
BadGatewayException,
|
|
525
|
+
InvalidInputException,
|
|
526
|
+
UnsupportedMediaTypeException,
|
|
527
|
+
PayloadLargeException,
|
|
528
|
+
TimeoutException,
|
|
529
|
+
UnauthorizedException,
|
|
530
|
+
ServiceUnavailableException,
|
|
531
|
+
FrameworkException,
|
|
532
|
+
TimerException,
|
|
533
|
+
WorkerException,
|
|
534
|
+
resolveDep,
|
|
535
|
+
shallowClone,
|
|
536
|
+
mergeObject,
|
|
537
|
+
createControllerMetaMap,
|
|
538
|
+
detectAopDep,
|
|
539
|
+
joinUrl,
|
|
540
|
+
Context,
|
|
541
|
+
addPipe,
|
|
542
|
+
addFilter,
|
|
543
|
+
addGuard,
|
|
544
|
+
addAddon
|
|
545
|
+
};
|
|
546
|
+
//# sourceMappingURL=chunk-MCVUJNTJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/helper.ts","../src/context.ts","../src/pipe.ts","../src/exception/base.ts","../src/exception/undefine.ts","../src/exception/validate.ts","../src/exception/forbidden.ts","../src/exception/bad-request.ts","../src/exception/not-found.ts","../src/exception/conflict.ts","../src/exception/bad-gateway.ts","../src/exception/invalid-input.ts","../src/exception/media-type.ts","../src/exception/payload-large.ts","../src/exception/timeout.ts","../src/exception/unauthorized.ts","../src/exception/unavailable-service.ts","../src/exception/framework.ts","../src/exception/timer.ts","../src/exception/worker.ts","../src/filter.ts","../src/http/helper.ts","../src/decorators/helper.ts"],"sourcesContent":["// help you build custom framework or decorator\r\n\r\nimport pc from 'picocolors'\r\nimport { log } from './utils'\r\nimport { Context } from './context'\r\nimport { HMR } from './hmr'\r\nimport { ControllerMeta, Meta } from './meta'\r\nimport { IS_PURE, IS_STRICT } from './common'\r\n\r\nexport * from './hmr'\r\nexport * from './http/helper'\r\nexport * from './decorators/helper'\r\n\r\nexport function createControllerMetaMap(meta: Meta[], filter: (meta: Meta) => boolean | void) {\r\n const metaMap = new Map<string, Record<string, ControllerMeta>>()\r\n\r\n function handleMeta() {\r\n metaMap.clear()\r\n for (const item of meta) {\r\n const { tag, func } = item.data\r\n if (!filter(item))\r\n continue\r\n\r\n if (metaMap.has(tag))\r\n metaMap.get(tag)![func] = item as ControllerMeta\r\n\r\n else\r\n metaMap.set(tag, { [func]: item as ControllerMeta })\r\n }\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n\r\n return metaMap\r\n}\r\n\r\n// detect whether addon/filter/pipe/guard/intercept is injected\r\nexport function detectAopDep(meta: Meta[], { guards, addons }: {\r\n guards?: string[]\r\n addons?: string[]\r\n\r\n} = {}, controller = 'http') {\r\n if (IS_PURE)\r\n return\r\n\r\n const addonSet = new Set<string>()\r\n const guardSet = new Set<string>()\r\n const pipeSet = new Set<string>()\r\n const filterSet = new Set<string>()\r\n const warningSet = new Set<string>()\r\n function handleMeta() {\r\n addonSet.clear()\r\n guardSet.clear()\r\n pipeSet.clear()\r\n filterSet.clear()\r\n warningSet.clear()\r\n\r\n addons?.forEach((item) => {\r\n addonSet.add(item)\r\n })\r\n guards?.forEach((item) => {\r\n guardSet.add(item)\r\n });\r\n\r\n (meta as ControllerMeta[]).forEach(({ data }) => {\r\n if (!data.controller)\r\n return\r\n\r\n if (typeof data.tag !== 'string')\r\n warningSet.add(`Tag of controller \"${data.name}\" should be a string`)\r\n\r\n // @todo func of meta on controller should be string\r\n\r\n if (data.controller !== controller) {\r\n if (data[controller])\r\n warningSet.add(`Should use ${controller} controller to decorate class \"${data.name}\"`)\r\n\r\n return\r\n }\r\n if (data.filter)\r\n filterSet.add(data.filter)\r\n\r\n data.guards.forEach(i => guardSet.add(i))\r\n data.addons.forEach(i => addonSet.add(i))\r\n data.params.forEach((i) => {\r\n if (i.pipe)\r\n pipeSet.add(i.pipe)\r\n })\r\n })\r\n const missAddons = [...addonSet].filter(i => !Context.addonRecord[i])\r\n const missGuards = [...guardSet].filter(i => !Context.guardRecord[i])\r\n const missPipes = [...pipeSet].filter(i => !Context.pipeRecord[i])\r\n const missFilters = [...filterSet].filter(i => !Context.filterRecord[i])\r\n\r\n function exit() {\r\n if (IS_STRICT) {\r\n log('Does not meet strict mode requirements', 'error')\r\n process.exit(1)\r\n }\r\n }\r\n\r\n if (missAddons.length) {\r\n log(`${pc.white(`Addon [${missAddons.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missGuards.length) {\r\n log(`${pc.magenta(`Guard [${missGuards.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missPipes.length) {\r\n log(`${pc.blue(`Pipe [${missPipes.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n if (missFilters.length) {\r\n log(`${pc.red(`Filter [${missFilters.join(',')}]`)} doesn't exist`, 'warn')\r\n exit()\r\n }\r\n\r\n warningSet.forEach(warn => log(warn, 'warn'))\r\n if (warningSet.size)\r\n exit()\r\n }\r\n\r\n handleMeta()\r\n HMR(handleMeta)\r\n return {\r\n addonSet,\r\n guardSet,\r\n pipeSet,\r\n filterSet,\r\n }\r\n}\r\n\r\nexport function joinUrl(base: string, ...paths: string[]) {\r\n const joinedPath = [base, ...paths].filter(p => p).map(path => path.replace(/(^\\/)/g, '')).join('/')\r\n return `/${joinedPath}`\r\n}\r\n","import Debug from 'debug'\r\nimport pc from 'picocolors'\r\nimport { defaultPipe } from './pipe'\r\nimport { defaultFilter } from './filter'\r\nimport type { BaseCtx, DefaultOptions } from './types'\r\nimport { IS_DEV } from './common'\r\nimport { type Exception, FrameworkException } from './exception'\r\nimport { resolveDep } from './helper'\r\nimport { ControllerMeta } from './meta'\r\nimport { log } from './utils'\r\n\r\nconst debug = Debug('phecda-server(Context)')\r\n\r\nexport interface AOP {\r\n guards: GuardType[]\r\n pipe: PipeType[]\r\n filter: FilterType\r\n}\r\n\r\nexport interface PipeArg { arg: any; pipe?: string; key: string; type: string; index: number; reflect: any; define: Record<string, any> }\r\nexport type GuardType<Ctx extends BaseCtx = any> = (ctx: Ctx, next: () => Promise<any>) => any\r\nexport type PipeType<Ctx extends BaseCtx = any> = (arg: PipeArg, ctx: Ctx) => Promise<any>\r\nexport type FilterType<Ctx extends BaseCtx = any, E extends Exception = any> = (err: E | Error, ctx?: Ctx) => Error | any\r\n\r\nexport class Context<Ctx extends BaseCtx> {\r\n method: string\r\n params: string[]\r\n\r\n static filterRecord: Record<PropertyKey, FilterType> = {\r\n default: defaultFilter,\r\n }\r\n\r\n static pipeRecord: Record<PropertyKey, PipeType> = {\r\n default: defaultPipe,\r\n }\r\n\r\n static guardRecord: Record<PropertyKey, {\r\n value: GuardType\r\n priority: number\r\n }> = {}\r\n\r\n static addonRecord: Record<PropertyKey, {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n\r\n }> = {}\r\n\r\n ctx: Ctx\r\n\r\n protected canGetCtx = true\r\n\r\n constructor(public data: Ctx) {\r\n if (IS_DEV)\r\n // @ts-expect-error work for debug\r\n data._context = this\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-this-alias\r\n const that = this\r\n\r\n this.ctx = new Proxy(data, {\r\n get(target, p) {\r\n if (IS_DEV && !that.canGetCtx)// only detect in dev\r\n throw new FrameworkException('ctx must be obtained within the same request cycle in controller')\r\n\r\n if (!(p in target))\r\n log(`attribute \"${p as string}\" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, 'warn', data.tag)\r\n\r\n return target[p as any]\r\n },\r\n set(target: any, p, newValue) {\r\n target[p] = newValue\r\n return true\r\n },\r\n })\r\n }\r\n\r\n static getAop(meta: ControllerMeta, opts: DefaultOptions) {\r\n const { globalGuards = [], globalFilter = 'default', globalPipe = 'default' } = opts\r\n const {\r\n data: {\r\n guards, filter,\r\n params, tag, func,\r\n },\r\n } = meta\r\n\r\n const resolved = {\r\n guards: [...globalGuards, ...guards],\r\n pipe: params.map(item => item.pipe || globalPipe),\r\n filter: filter || globalFilter,\r\n\r\n }\r\n\r\n if (process.env.DEBUG) {\r\n const { guards, pipe, filter } = resolved\r\n debug(`func \"${tag}-${func}\" aop: \\n${pc.magenta(`Guard ${guards.join('->')}[${guards.filter(g => g in this.guardRecord).join('->')}]`)}\\n${pc.blue(`Pipe ${pipe.join('-')}[${pipe.map(p => p in this.pipeRecord ? p : 'default').join('-')}]`)}\\n${pc.red(`Filter ${filter}[${filter || 'default'}]`)}`)\r\n }\r\n return {\r\n guards: this.getGuards(resolved.guards),\r\n pipe: this.getPipe(resolved.pipe),\r\n filter: this.getFilter(resolved.filter),\r\n }\r\n }\r\n\r\n public async run<ResponseData = any, ReturnErr = any>({\r\n guards, filter, pipe,\r\n }: {\r\n guards: GuardType[]\r\n filter: FilterType\r\n pipe: PipeType[]\r\n }, successCb: (data: any) => ResponseData, failCb: (err: any) => ReturnErr) {\r\n const { meta, moduleMap } = this.data\r\n const {\r\n paramsType,\r\n data: {\r\n ctxs,\r\n tag,\r\n params,\r\n func,\r\n },\r\n } = meta\r\n\r\n try {\r\n // let current = 0\r\n let res: any\r\n const nextHandler = (index: number) => {\r\n return async () => {\r\n if (index === guards.length) {\r\n const instance = moduleMap.get(tag)!\r\n if (ctxs) {\r\n ctxs.forEach(ctx => instance[ctx] = this.ctx,\r\n )\r\n }\r\n const args = await Promise.all(\r\n params.map((item, i) =>\r\n pipe[i]({ arg: resolveDep(this.data[item.type], item.key), reflect: paramsType[item.index], ...item }, this.ctx),\r\n ),\r\n )\r\n\r\n if (IS_DEV) {\r\n Promise.resolve().then(() => {\r\n this.canGetCtx = false\r\n })\r\n }\r\n res = await instance[func](...args)\r\n this.canGetCtx = true\r\n }\r\n else {\r\n let nextPromise: Promise<any> | undefined\r\n async function next() {\r\n return nextPromise = nextHandler(index + 1)().then((ret) => {\r\n if (ret !== undefined) {\r\n debug(`The ${index + 1}th guard on \"${tag}-${func}\" rewrite the response value.`)\r\n res = ret\r\n }\r\n\r\n return res\r\n })\r\n }\r\n\r\n const ret = await guards[index](this.ctx, next)\r\n\r\n if (ret !== undefined) {\r\n res = ret\r\n }\r\n else {\r\n if (!nextPromise)\r\n await next()\r\n\r\n else\r\n await nextPromise\r\n }\r\n }\r\n }\r\n }\r\n await nextHandler(0)()\r\n\r\n return successCb(res)\r\n }\r\n catch (e) {\r\n const err = await filter(e, this.ctx)\r\n return failCb(err)\r\n }\r\n }\r\n\r\n static getPipe(pipe: string[]) {\r\n return pipe.map((pipe) => {\r\n return Context.pipeRecord[pipe] || Context.pipeRecord.default\r\n })\r\n }\r\n\r\n static getFilter(filter = 'default') {\r\n return Context.filterRecord[filter] || Context.filterRecord.default\r\n }\r\n\r\n static getGuards(guards: string[]) {\r\n const ret: { value: GuardType; priority: number }[] = []\r\n for (const guard of new Set(guards)) {\r\n if (guard in Context.guardRecord)\r\n ret.push(Context.guardRecord[guard])\r\n }\r\n\r\n return ret.sort((a, b) => b.priority - a.priority).map(item => item.value)\r\n }\r\n\r\n static applyAddons(addons: string[], router: any, framework: string) {\r\n const ret: {\r\n value: (router: any, framework: string) => any\r\n priority: number\r\n }[] = []\r\n for (const a of new Set(addons)) {\r\n if (a in Context.addonRecord)\r\n ret.push(Context.addonRecord[a])\r\n }\r\n\r\n ret.sort((a, b) => b.priority - a.priority).forEach(item => item.value(router, framework))\r\n\r\n // await Context.addonRecord[a](router, framework)\r\n }\r\n}\r\n\r\nexport function addPipe<C extends BaseCtx>(key: PropertyKey, pipe: PipeType<C>) {\r\n if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe)\r\n debug(`overwrite Pipe \"${String(key)}\"`, 'warn')\r\n Context.pipeRecord[key] = pipe\r\n}\r\n\r\nexport function addFilter<C extends BaseCtx>(key: PropertyKey, filter: FilterType<C>) {\r\n if (Context.filterRecord[key] && Context.filterRecord[key] !== filter)\r\n debug(`overwrite Filter \"${String(key)}\"`, 'warn')\r\n Context.filterRecord[key] = filter\r\n}\r\n\r\nexport function addGuard<C extends BaseCtx>(key: PropertyKey, guard: GuardType<C>, priority = 0) {\r\n if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard)\r\n debug(`overwrite Guard \"${String(key)}\"`, 'warn')\r\n\r\n Context.guardRecord[key] = {\r\n value: guard,\r\n priority,\r\n }\r\n}\r\nexport function addAddon(key: PropertyKey, addon: (router: any, framework: string) => void, priority = 0) {\r\n if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon)\r\n debug(`overwrite Addon \"${String(key)}\"`, 'warn')\r\n Context.addonRecord[key] = {\r\n value: addon,\r\n priority,\r\n }\r\n}\r\n","// import { isPhecda, } from 'phecda-core'\r\n// import { ValidateException } from './exception/validate'\r\n\r\nimport type { PipeType } from './context'\r\n\r\nexport const defaultPipe: PipeType = ({ arg }) => {\r\n // if (['query', 'params'].includes(type) && reflect !== String) {\r\n // if ([Object, Array].includes(reflect)) {\r\n // return JSON.parse(arg)\r\n // }\r\n // if ([Number, Boolean].includes(reflect)) {\r\n // return reflect(arg)\r\n // }\r\n // }\r\n return arg\r\n}\r\n","import { ERROR_SYMBOL } from '../common'\r\n\r\nexport class Exception extends Error {\r\n constructor(public message: string, public status = 0, public description = 'Exception') {\r\n super(message)\r\n }\r\n\r\n get data() {\r\n return { message: this.message, description: this.description, status: this.status, [ERROR_SYMBOL]: true }\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UndefinedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 500, 'Undefined error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ValidateException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Validate exception')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ForbiddenException extends Exception {\r\n constructor(message: string) {\r\n super(message, 403, 'Forbidden resource')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadRequestException extends Exception {\r\n constructor(message: string) {\r\n super(message, 400, 'Bad Request')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class NotFoundException extends Exception {\r\n constructor(message: string) {\r\n super(message, 404, 'Not Found')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ConflictException extends Exception {\r\n constructor(message: string) {\r\n super(message, 409, 'Conflict')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class BadGatewayException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Bad Gatrway')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class InvalidInputException extends Exception {\r\n constructor(message: string) {\r\n super(message, 502, 'Invalid Input')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnsupportedMediaTypeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 415, 'Unsupported Media Type')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class PayloadLargeException extends Exception {\r\n constructor(message: string) {\r\n super(message, 413, 'Payload Too Large')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class TimeoutException extends Exception {\r\n constructor(message: string) {\r\n super(message, 408, 'Request Timeout',\r\n )\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class UnauthorizedException extends Exception {\r\n constructor(message: string) {\r\n super(message, 401, 'Unauthorized')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class ServiceUnavailableException extends Exception {\r\n constructor(message: string) {\r\n super(message, 503, 'Service Unavailable')\r\n }\r\n}\r\n","import { Exception } from './base'\r\n\r\nexport class FrameworkException extends Exception {\r\n constructor(message: string) {\r\n super(`[phecda-server] ${message}`, 500, 'Framework Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class TimerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Timer Error')\r\n }\r\n}\r\n","import { Exception } from './base'\r\nexport class WorkerException extends Exception {\r\n constructor(message: string) {\r\n super(message, 0, 'Worker Error')\r\n }\r\n}\r\n","import { LOG_LEVEL } from './common'\r\nimport { Exception, UndefinedException } from './exception'\r\nimport { log } from './utils'\r\nimport type { FilterType } from './context'\r\n\r\nexport const defaultFilter: FilterType = (e) => {\r\n if (!(e instanceof Exception)) {\r\n log(e.message, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n\r\n e = new UndefinedException(e.message || e)\r\n }\r\n else {\r\n log(`[${e.constructor.name}] ${e.message}`, 'error')\r\n if (LOG_LEVEL <= 0)\r\n console.error(e.stack)\r\n }\r\n\r\n return e.data\r\n}\r\n","export function resolveDep(ret: any, key: string) {\r\n if (key)\r\n return ret?.[key]\r\n return ret\r\n}\r\n\r\n// export function argToReq(params: ControllerMetaData['params'], args: any[], headers: Record<string, any>) {\r\n// const req = {\r\n// body: {},\r\n// query: {},\r\n// params: {},\r\n// headers,\r\n// } as any\r\n\r\n// params.forEach((param) => {\r\n// if (param.key)\r\n// req[param.type][param.key] = args[param.index]\r\n\r\n// else\r\n// req[param.type] = args[param.index]\r\n// })\r\n\r\n// return req\r\n// }\r\n","export function shallowClone(obj: any) {\r\n return { ...obj }\r\n}\r\nexport function mergeObject(...args: any[]) {\r\n return Object.assign({}, ...args)\r\n}\r\n"],"mappings":";;;;;;;;;;;;AAEA,OAAOA,SAAQ;;;ACFf,OAAOC,WAAW;AAClB,OAAOC,QAAQ;;;ACIR,IAAMC,cAAwB,wBAAC,EAAEC,IAAG,MAAE;AAS3C,SAAOA;AACT,GAVqC;;;ACH9B,IAAMC,YAAN,cAAwBC,MAAAA;EAF/B,OAE+BA;;;;;;EAC7BC,YAAmBC,SAAwBC,SAAS,GAAUC,cAAc,aAAa;AACvF,UAAMF,OAAAA;SADWA,UAAAA;SAAwBC,SAAAA;SAAmBC,cAAAA;EAE9D;EAEA,IAAIC,OAAO;AACT,WAAO;MAAEH,SAAS,KAAKA;MAASE,aAAa,KAAKA;MAAaD,QAAQ,KAAKA;MAAQ,CAACG,YAAAA,GAAe;IAAK;EAC3G;AACF;;;ACRO,IAAMC,qBAAN,cAAiCC,UAAAA;EAFxC,OAEwCA;;;EACtCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,iBAAA;EACtB;AACF;;;ACJO,IAAMC,oBAAN,cAAgCC,UAAAA;EAFvC,OAEuCA;;;EACrCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMC,qBAAN,cAAiCC,UAAAA;EAFxC,OAEwCA;;;EACtCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMC,sBAAN,cAAkCC,UAAAA;EAFzC,OAEyCA;;;EACvCC,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,aAAA;EACtB;AACF;;;ACJO,IAAMC,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kBAAmB,MAAA;AACjEP,WAAAA;IACF;AACA,QAAIF,YAAYM,QAAQ;AACtBF,UAAI,GAAGG,IAAGK,IAAI,WAAWZ,YAAYS,KAAK,GAAA,CAAA,GAAO,CAAA,kBAAmB,MAAA;AACpEP,WAAAA;IACF;AAEAhB,eAAWC,QAAQ0B,CAAAA,SAAQT,IAAIS,MAAM,MAAA,CAAA;AACrC,QAAI3B,WAAW4B,KACbZ,MAAAA;EACJ;AAvESpC;AAyETA,aAAAA;AACAS,MAAIT,UAAAA;AACJ,SAAO;IACLe;IACAE;IACAC;IACAC;EACF;AACF;AA9FgBT;AAgGT,SAASuC,QAAQC,SAAiBC,OAAe;AACtD,QAAMC,aAAa;IAACF;OAASC;IAAOtD,OAAOwD,CAAAA,MAAKA,CAAAA,EAAGC,IAAIC,CAAAA,SAAQA,KAAKC,QAAQ,UAAU,EAAA,CAAA,EAAKb,KAAK,GAAA;AAChG,SAAO,IAAIS,UAAAA;AACb;AAHgBH;","names":["pc","Debug","pc","defaultPipe","arg","Exception","Error","constructor","message","status","description","data","ERROR_SYMBOL","UndefinedException","Exception","constructor","message","ValidateException","Exception","constructor","message","ForbiddenException","Exception","constructor","message","BadRequestException","Exception","constructor","message","NotFoundException","Exception","constructor","message","ConflictException","Exception","constructor","message","BadGatewayException","Exception","constructor","message","InvalidInputException","Exception","constructor","message","UnsupportedMediaTypeException","Exception","constructor","message","PayloadLargeException","Exception","constructor","message","TimeoutException","Exception","constructor","message","UnauthorizedException","Exception","constructor","message","ServiceUnavailableException","Exception","constructor","message","FrameworkException","Exception","constructor","message","TimerException","Exception","constructor","message","WorkerException","Exception","constructor","message","defaultFilter","e","Exception","log","message","LOG_LEVEL","console","error","stack","UndefinedException","constructor","name","data","debug","Debug","Context","method","params","filterRecord","default","defaultFilter","pipeRecord","defaultPipe","guardRecord","addonRecord","ctx","canGetCtx","constructor","data","IS_DEV","_context","that","Proxy","get","target","p","FrameworkException","log","tag","set","newValue","getAop","meta","opts","globalGuards","globalFilter","globalPipe","guards","filter","func","resolved","pipe","map","item","process","env","DEBUG","pc","magenta","join","g","blue","red","getGuards","getPipe","getFilter","run","successCb","failCb","moduleMap","paramsType","ctxs","res","nextHandler","index","length","instance","forEach","args","Promise","all","i","arg","resolveDep","type","key","reflect","resolve","then","nextPromise","next","ret","undefined","e","err","guard","Set","push","sort","a","b","priority","value","applyAddons","addons","router","framework","addPipe","String","addFilter","addGuard","addAddon","addon","resolveDep","ret","key","shallowClone","obj","mergeObject","args","Object","assign","createControllerMetaMap","meta","filter","metaMap","Map","handleMeta","clear","item","tag","func","data","has","get","set","HMR","detectAopDep","guards","addons","controller","IS_PURE","addonSet","Set","guardSet","pipeSet","filterSet","warningSet","forEach","add","name","i","params","pipe","missAddons","Context","addonRecord","missGuards","guardRecord","missPipes","pipeRecord","missFilters","filterRecord","exit","IS_STRICT","log","process","length","pc","white","join","magenta","blue","red","warn","size","joinUrl","base","paths","joinedPath","p","map","path","replace"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common.ts","../src/utils.ts","../src/hmr.ts"],"sourcesContent":["export const ERROR_SYMBOL = '__PS_ERROR__'// only use in paralle request\r\n\r\nexport const IS_DEV = process.env.NODE_ENV === 'development'\r\nexport const IS_ONLY_GENERATE = !!process.env.PS_GENERATE// work for ci; only generate code\r\nexport const IS_STRICT = !!process.env.PS_STRICT// throw error if depends on an aop module which is not imported\r\nexport const IS_PURE = !!process.env.PS_PURE// pure mode, will skip detectAopDep\r\n\r\nexport const LOG_LEVEL = Number(process.env.PS_LOG_LEVEL || 0)// internal logger\r\n\r\nexport enum PS_EXIT_CODE {\r\n RELAUNCH = 4171,\r\n EXIT = 4172,\r\n}\r\n","import pc from 'picocolors'\r\nimport { LOG_LEVEL } from './common'\r\nimport { HttpCtx } from './http/types'\r\n\r\nexport type LogLevel = 'error' | 'info' | 'warn' | 'log' | 'debug'\r\n\r\nexport interface Logger {\r\n log(msg: unknown, level: LogLevel, ctx?: string): void\r\n}\r\n\r\nconst isObject = (fn: any): fn is object =>\r\n fn !== null && typeof fn === 'object'\r\n\r\nconst isPlainObject = (fn: any): fn is object => {\r\n if (!isObject(fn))\r\n return false\r\n\r\n const proto = Object.getPrototypeOf(fn)\r\n if (proto === null)\r\n return true\r\n\r\n const ctor\r\n = Object.prototype.hasOwnProperty.call(proto, 'constructor')\r\n && proto.constructor\r\n return (\r\n typeof ctor === 'function'\r\n && ctor instanceof ctor\r\n && Function.prototype.toString.call(ctor)\r\n === Function.prototype.toString.call(Object)\r\n )\r\n}\r\n\r\nclass InternalLogger {\r\n time: number\r\n color = { debug: 'bgMagenta', error: 'red', info: 'gray', warn: 'yellow', log: 'green' } as const\r\n dateFormatter = new Intl.DateTimeFormat(undefined, {\r\n year: 'numeric',\r\n hour: 'numeric',\r\n minute: 'numeric',\r\n second: 'numeric',\r\n day: '2-digit',\r\n month: '2-digit',\r\n })\r\n\r\n diffTimestamp() {\r\n const now = Date.now()\r\n\r\n if (!this.time)\r\n return ''\r\n const diff = now - this.time\r\n\r\n this.time = now\r\n\r\n return diff ? pc.yellow(` +${diff}`) : ''\r\n }\r\n\r\n colorize(message: string, logLevel: LogLevel) {\r\n return pc[this.color[logLevel]](message)\r\n }\r\n\r\n isAllowLog(level: LogLevel) {\r\n const logLevel = {\r\n debug: -1,\r\n info: 0,\r\n log: 1,\r\n warn: 2,\r\n error: 3,\r\n }[level]\r\n\r\n if (logLevel < LOG_LEVEL)\r\n return false\r\n\r\n return true\r\n }\r\n\r\n stringifyMessage(message: unknown, logLevel: LogLevel): string {\r\n if (typeof message === 'function') {\r\n const messageAsStr = Function.prototype.toString.call(message)\r\n const isClass = messageAsStr.startsWith('class ')\r\n if (isClass) {\r\n // If the message is a class, we will display the class name.\r\n return this.stringifyMessage(message.name, logLevel)\r\n }\r\n // If the message is a non-class function, call it and re-resolve its value.\r\n return this.stringifyMessage(message(), logLevel)\r\n }\r\n\r\n return (isPlainObject(message) || Array.isArray(message))\r\n ? `${this.colorize('Object:', logLevel)}\\n${JSON.stringify(\r\n message,\r\n (key, value) =>\r\n typeof value === 'bigint' ? value.toString() : value,\r\n 2,\r\n )}\\n`\r\n : this.colorize(message as string, logLevel)\r\n }\r\n\r\n log(msg: unknown, level: LogLevel, ctx?: string) {\r\n if (!this.isAllowLog(level))\r\n return\r\n msg = this.stringifyMessage(msg, level)\r\n const pidMsg = this.colorize(`[${process.env.PS_APP_NAME || 'phecda-server'}] ${process.pid}`, level)\r\n const ctxMsg = ctx ? this.colorize(pc.bold(`[${ctx}] `), level) : ''\r\n const timeDiff = this.diffTimestamp()\r\n const levelMsg = this.colorize(level.toUpperCase().padStart(7, ' '), level)\r\n process.stdout.write(`${pidMsg} ${this.dateFormatter.format(Date.now())} ${levelMsg} ${ctxMsg}${msg}${timeDiff}\\n`)\r\n }\r\n}\r\n\r\nlet _logger: Logger = new InternalLogger()\r\n\r\nexport function setLogger(logger: Logger) {\r\n _logger = logger\r\n}\r\nexport function getLogger() {\r\n return _logger\r\n}\r\n\r\nexport function log(msg: unknown, level: LogLevel = 'log', ctx?: any) {\r\n _logger.log(msg, level, ctx)\r\n}\r\n\r\nexport function runMiddleware(ctx: HttpCtx, middleware: (req: any, res: any, next?: any) => any) {\r\n return new Promise((resolve) => {\r\n middleware(ctx.getRequest(), ctx.getResponse(), resolve)\r\n })\r\n}\r\n\r\nexport { Mixin } from 'ts-mixer'\r\n","import { Construct } from 'phecda-core'\r\nimport { IS_DEV, PS_EXIT_CODE } from './common'\r\nimport { log } from './utils'\r\nexport function HMR(cb: (oldModels: Construct[], newModels: Construct[]) => any) {\r\n if (IS_DEV) {\r\n if (!globalThis.__PS_HMR__)\r\n globalThis.__PS_HMR__ = []\r\n globalThis.__PS_HMR__.push(cb)\r\n }\r\n}\r\n\r\nexport async function RELOAD(oldModels: Construct[], newModels: Construct[]) {\r\n log('reload module...')\r\n for (const cb of globalThis.__PS_HMR__) await cb(oldModels, newModels)\r\n\r\n log('reload done')\r\n}\r\n\r\nex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SYMBOL","IS_DEV","process","env","NODE_ENV","IS_ONLY_GENERATE","PS_GENERATE","IS_STRICT","PS_STRICT","IS_PURE","PS_PURE","LOG_LEVEL","Number","PS_LOG_LEVEL","PS_EXIT_CODE","pc","Mixin","isObject","fn","isPlainObject","proto","Object","getPrototypeOf","ctor","prototype","hasOwnProperty","call","constructor","Function","toString","InternalLogger","time","color","debug","error","info","warn","log","dateFormatter","Intl","DateTimeFormat","undefined","year","hour","minute","second","day","month","diffTimestamp","now","Date","diff","pc","yellow","colorize","message","logLevel","isAllowLog","level","LOG_LEVEL","stringifyMessage","messageAsStr","isClass","startsWith","name","Array","isArray","JSON","stringify","key","value","msg","ctx","pidMsg","process","env","PS_APP_NAME","pid","ctxMsg","bold","timeDiff","levelMsg","toUpperCase","padStart","stdout","write","format","_logger","setLogger","logger","getLogger","runMiddleware","middleware","Promise","resolve","getRequest","getResponse","HMR","cb","IS_DEV","globalThis","__PS_HMR__","push","RELOAD","oldModels","newModels","log","RELAUNCH","process","exit","PS_EXIT_CODE"]}
|