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,562 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkC2MTV2HSjs = require('./chunk-C2MTV2HS.js');
|
|
10
|
+
|
|
11
|
+
// src/helper.ts
|
|
12
|
+
var _picocolors = require('picocolors'); var _picocolors2 = _interopRequireDefault(_picocolors);
|
|
13
|
+
|
|
14
|
+
// src/context.ts
|
|
15
|
+
var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// src/pipe.ts
|
|
19
|
+
var defaultPipe = /* @__PURE__ */ _chunkC2MTV2HSjs.__name.call(void 0, ({ arg }) => {
|
|
20
|
+
return arg;
|
|
21
|
+
}, "defaultPipe");
|
|
22
|
+
|
|
23
|
+
// src/exception/base.ts
|
|
24
|
+
var Exception = class extends Error {
|
|
25
|
+
static {
|
|
26
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "Exception");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
constructor(message, status = 0, description = "Exception") {
|
|
32
|
+
super(message);
|
|
33
|
+
this.message = message;
|
|
34
|
+
this.status = status;
|
|
35
|
+
this.description = description;
|
|
36
|
+
}
|
|
37
|
+
get data() {
|
|
38
|
+
return {
|
|
39
|
+
message: this.message,
|
|
40
|
+
description: this.description,
|
|
41
|
+
status: this.status,
|
|
42
|
+
[_chunkC2MTV2HSjs.ERROR_SYMBOL]: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// src/exception/undefine.ts
|
|
48
|
+
var UndefinedException = class extends Exception {
|
|
49
|
+
static {
|
|
50
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "UndefinedException");
|
|
51
|
+
}
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message, 500, "Undefined error");
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/exception/validate.ts
|
|
58
|
+
var ValidateException = class extends Exception {
|
|
59
|
+
static {
|
|
60
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "ValidateException");
|
|
61
|
+
}
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message, 400, "Validate exception");
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/exception/forbidden.ts
|
|
68
|
+
var ForbiddenException = class extends Exception {
|
|
69
|
+
static {
|
|
70
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "ForbiddenException");
|
|
71
|
+
}
|
|
72
|
+
constructor(message) {
|
|
73
|
+
super(message, 403, "Forbidden resource");
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/exception/bad-request.ts
|
|
78
|
+
var BadRequestException = class extends Exception {
|
|
79
|
+
static {
|
|
80
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "BadRequestException");
|
|
81
|
+
}
|
|
82
|
+
constructor(message) {
|
|
83
|
+
super(message, 400, "Bad Request");
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/exception/not-found.ts
|
|
88
|
+
var NotFoundException = class extends Exception {
|
|
89
|
+
static {
|
|
90
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "NotFoundException");
|
|
91
|
+
}
|
|
92
|
+
constructor(message) {
|
|
93
|
+
super(message, 404, "Not Found");
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/exception/conflict.ts
|
|
98
|
+
var ConflictException = class extends Exception {
|
|
99
|
+
static {
|
|
100
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "ConflictException");
|
|
101
|
+
}
|
|
102
|
+
constructor(message) {
|
|
103
|
+
super(message, 409, "Conflict");
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// src/exception/bad-gateway.ts
|
|
108
|
+
var BadGatewayException = class extends Exception {
|
|
109
|
+
static {
|
|
110
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "BadGatewayException");
|
|
111
|
+
}
|
|
112
|
+
constructor(message) {
|
|
113
|
+
super(message, 502, "Bad Gatrway");
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/exception/invalid-input.ts
|
|
118
|
+
var InvalidInputException = class extends Exception {
|
|
119
|
+
static {
|
|
120
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "InvalidInputException");
|
|
121
|
+
}
|
|
122
|
+
constructor(message) {
|
|
123
|
+
super(message, 502, "Invalid Input");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/exception/media-type.ts
|
|
128
|
+
var UnsupportedMediaTypeException = class extends Exception {
|
|
129
|
+
static {
|
|
130
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "UnsupportedMediaTypeException");
|
|
131
|
+
}
|
|
132
|
+
constructor(message) {
|
|
133
|
+
super(message, 415, "Unsupported Media Type");
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// src/exception/payload-large.ts
|
|
138
|
+
var PayloadLargeException = class extends Exception {
|
|
139
|
+
static {
|
|
140
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "PayloadLargeException");
|
|
141
|
+
}
|
|
142
|
+
constructor(message) {
|
|
143
|
+
super(message, 413, "Payload Too Large");
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// src/exception/timeout.ts
|
|
148
|
+
var TimeoutException = class extends Exception {
|
|
149
|
+
static {
|
|
150
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "TimeoutException");
|
|
151
|
+
}
|
|
152
|
+
constructor(message) {
|
|
153
|
+
super(message, 408, "Request Timeout");
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/exception/unauthorized.ts
|
|
158
|
+
var UnauthorizedException = class extends Exception {
|
|
159
|
+
static {
|
|
160
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "UnauthorizedException");
|
|
161
|
+
}
|
|
162
|
+
constructor(message) {
|
|
163
|
+
super(message, 401, "Unauthorized");
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// src/exception/unavailable-service.ts
|
|
168
|
+
var ServiceUnavailableException = class extends Exception {
|
|
169
|
+
static {
|
|
170
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "ServiceUnavailableException");
|
|
171
|
+
}
|
|
172
|
+
constructor(message) {
|
|
173
|
+
super(message, 503, "Service Unavailable");
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/exception/framework.ts
|
|
178
|
+
var FrameworkException = class extends Exception {
|
|
179
|
+
static {
|
|
180
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "FrameworkException");
|
|
181
|
+
}
|
|
182
|
+
constructor(message) {
|
|
183
|
+
super(`[phecda-server] ${message}`, 500, "Framework Error");
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// src/exception/timer.ts
|
|
188
|
+
var TimerException = class extends Exception {
|
|
189
|
+
static {
|
|
190
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "TimerException");
|
|
191
|
+
}
|
|
192
|
+
constructor(message) {
|
|
193
|
+
super(message, 0, "Timer Error");
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/exception/worker.ts
|
|
198
|
+
var WorkerException = class extends Exception {
|
|
199
|
+
static {
|
|
200
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "WorkerException");
|
|
201
|
+
}
|
|
202
|
+
constructor(message) {
|
|
203
|
+
super(message, 0, "Worker Error");
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/filter.ts
|
|
208
|
+
var defaultFilter = /* @__PURE__ */ _chunkC2MTV2HSjs.__name.call(void 0, (e) => {
|
|
209
|
+
if (!(e instanceof Exception)) {
|
|
210
|
+
_chunkC2MTV2HSjs.log.call(void 0, e.message, "error");
|
|
211
|
+
if (_chunkC2MTV2HSjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
212
|
+
e = new UndefinedException(e.message || e);
|
|
213
|
+
} else {
|
|
214
|
+
_chunkC2MTV2HSjs.log.call(void 0, `[${e.constructor.name}] ${e.message}`, "error");
|
|
215
|
+
if (_chunkC2MTV2HSjs.LOG_LEVEL <= 0) console.error(e.stack);
|
|
216
|
+
}
|
|
217
|
+
return e.data;
|
|
218
|
+
}, "defaultFilter");
|
|
219
|
+
|
|
220
|
+
// src/context.ts
|
|
221
|
+
var debug = _debug2.default.call(void 0, "phecda-server(Context)");
|
|
222
|
+
var Context = (_class = class _Context {
|
|
223
|
+
static {
|
|
224
|
+
_chunkC2MTV2HSjs.__name.call(void 0, this, "Context");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
static __initStatic() {this.filterRecord = {
|
|
230
|
+
default: defaultFilter
|
|
231
|
+
}}
|
|
232
|
+
static __initStatic2() {this.pipeRecord = {
|
|
233
|
+
default: defaultPipe
|
|
234
|
+
}}
|
|
235
|
+
static __initStatic3() {this.guardRecord = {}}
|
|
236
|
+
static __initStatic4() {this.addonRecord = {}}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
constructor(data) {
|
|
240
|
+
this.data = data;
|
|
241
|
+
this.canGetCtx = true;
|
|
242
|
+
if (_chunkC2MTV2HSjs.IS_DEV)
|
|
243
|
+
data._context = this;
|
|
244
|
+
const that = this;
|
|
245
|
+
this.ctx = new Proxy(data, {
|
|
246
|
+
get(target, p) {
|
|
247
|
+
if (_chunkC2MTV2HSjs.IS_DEV && !that.canGetCtx) throw new FrameworkException("ctx must be obtained within the same request cycle in controller");
|
|
248
|
+
if (!(p in target)) _chunkC2MTV2HSjs.log.call(void 0, `attribute "${p}" does not exist on ctx, which might be due to a missing AOP role (such as a guard).`, "warn", data.tag);
|
|
249
|
+
return target[p];
|
|
250
|
+
},
|
|
251
|
+
set(target, p, newValue) {
|
|
252
|
+
target[p] = newValue;
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
static getAop(meta, opts) {
|
|
258
|
+
const { globalGuards = [], globalFilter = "default", globalPipe = "default" } = opts;
|
|
259
|
+
const { data: { guards, filter, params, tag, func } } = meta;
|
|
260
|
+
const resolved = {
|
|
261
|
+
guards: [
|
|
262
|
+
...globalGuards,
|
|
263
|
+
...guards
|
|
264
|
+
],
|
|
265
|
+
pipe: params.map((item) => item.pipe || globalPipe),
|
|
266
|
+
filter: filter || globalFilter
|
|
267
|
+
};
|
|
268
|
+
if (process.env.DEBUG) {
|
|
269
|
+
const { guards: guards2, pipe, filter: filter2 } = resolved;
|
|
270
|
+
debug(`func "${tag}-${func}" aop:
|
|
271
|
+
${_picocolors2.default.magenta(`Guard ${guards2.join("->")}[${guards2.filter((g) => g in this.guardRecord).join("->")}]`)}
|
|
272
|
+
${_picocolors2.default.blue(`Pipe ${pipe.join("-")}[${pipe.map((p) => p in this.pipeRecord ? p : "default").join("-")}]`)}
|
|
273
|
+
${_picocolors2.default.red(`Filter ${filter2}[${filter2 || "default"}]`)}`);
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
guards: this.getGuards(resolved.guards),
|
|
277
|
+
pipe: this.getPipe(resolved.pipe),
|
|
278
|
+
filter: this.getFilter(resolved.filter)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
async run({ guards, filter, pipe }, successCb, failCb) {
|
|
282
|
+
const { meta, moduleMap } = this.data;
|
|
283
|
+
const { paramsType, data: { ctxs, tag, params, func } } = meta;
|
|
284
|
+
try {
|
|
285
|
+
let res;
|
|
286
|
+
const nextHandler = /* @__PURE__ */ _chunkC2MTV2HSjs.__name.call(void 0, (index) => {
|
|
287
|
+
return async () => {
|
|
288
|
+
if (index === guards.length) {
|
|
289
|
+
const instance = moduleMap.get(tag);
|
|
290
|
+
if (ctxs) {
|
|
291
|
+
ctxs.forEach((ctx) => instance[ctx] = this.ctx);
|
|
292
|
+
}
|
|
293
|
+
const args = await Promise.all(params.map((item, i) => pipe[i]({
|
|
294
|
+
arg: resolveDep(this.data[item.type], item.key),
|
|
295
|
+
reflect: paramsType[item.index],
|
|
296
|
+
...item
|
|
297
|
+
}, this.ctx)));
|
|
298
|
+
if (_chunkC2MTV2HSjs.IS_DEV) {
|
|
299
|
+
Promise.resolve().then(() => {
|
|
300
|
+
this.canGetCtx = false;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
res = await instance[func](...args);
|
|
304
|
+
this.canGetCtx = true;
|
|
305
|
+
} else {
|
|
306
|
+
let nextPromise;
|
|
307
|
+
async function next() {
|
|
308
|
+
return nextPromise = nextHandler(index + 1)().then((ret2) => {
|
|
309
|
+
if (ret2 !== void 0) {
|
|
310
|
+
debug(`The ${index + 1}th guard on "${tag}-${func}" rewrite the response value.`);
|
|
311
|
+
res = ret2;
|
|
312
|
+
}
|
|
313
|
+
return res;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
_chunkC2MTV2HSjs.__name.call(void 0, next, "next");
|
|
317
|
+
const ret = await guards[index](this.ctx, next);
|
|
318
|
+
if (ret !== void 0) {
|
|
319
|
+
res = ret;
|
|
320
|
+
} else {
|
|
321
|
+
if (!nextPromise) await next();
|
|
322
|
+
else await nextPromise;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}, "nextHandler");
|
|
327
|
+
await nextHandler(0)();
|
|
328
|
+
return successCb(res);
|
|
329
|
+
} catch (e) {
|
|
330
|
+
const err = await filter(e, this.ctx);
|
|
331
|
+
return failCb(err);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
static getPipe(pipe) {
|
|
335
|
+
return pipe.map((pipe2) => {
|
|
336
|
+
return _Context.pipeRecord[pipe2] || _Context.pipeRecord.default;
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
static getFilter(filter = "default") {
|
|
340
|
+
return _Context.filterRecord[filter] || _Context.filterRecord.default;
|
|
341
|
+
}
|
|
342
|
+
static getGuards(guards) {
|
|
343
|
+
const ret = [];
|
|
344
|
+
for (const guard of new Set(guards)) {
|
|
345
|
+
if (guard in _Context.guardRecord) ret.push(_Context.guardRecord[guard]);
|
|
346
|
+
}
|
|
347
|
+
return ret.sort((a, b) => b.priority - a.priority).map((item) => item.value);
|
|
348
|
+
}
|
|
349
|
+
static applyAddons(addons, router, framework) {
|
|
350
|
+
const ret = [];
|
|
351
|
+
for (const a of new Set(addons)) {
|
|
352
|
+
if (a in _Context.addonRecord) ret.push(_Context.addonRecord[a]);
|
|
353
|
+
}
|
|
354
|
+
ret.sort((a, b) => b.priority - a.priority).forEach((item) => item.value(router, framework));
|
|
355
|
+
}
|
|
356
|
+
}, _class.__initStatic(), _class.__initStatic2(), _class.__initStatic3(), _class.__initStatic4(), _class);
|
|
357
|
+
function addPipe(key, pipe) {
|
|
358
|
+
if (Context.pipeRecord[key] && Context.pipeRecord[key] !== pipe) debug(`overwrite Pipe "${String(key)}"`, "warn");
|
|
359
|
+
Context.pipeRecord[key] = pipe;
|
|
360
|
+
}
|
|
361
|
+
_chunkC2MTV2HSjs.__name.call(void 0, addPipe, "addPipe");
|
|
362
|
+
function addFilter(key, filter) {
|
|
363
|
+
if (Context.filterRecord[key] && Context.filterRecord[key] !== filter) debug(`overwrite Filter "${String(key)}"`, "warn");
|
|
364
|
+
Context.filterRecord[key] = filter;
|
|
365
|
+
}
|
|
366
|
+
_chunkC2MTV2HSjs.__name.call(void 0, addFilter, "addFilter");
|
|
367
|
+
function addGuard(key, guard, priority = 0) {
|
|
368
|
+
if (Context.guardRecord[key] && Context.guardRecord[key].value !== guard) debug(`overwrite Guard "${String(key)}"`, "warn");
|
|
369
|
+
Context.guardRecord[key] = {
|
|
370
|
+
value: guard,
|
|
371
|
+
priority
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
_chunkC2MTV2HSjs.__name.call(void 0, addGuard, "addGuard");
|
|
375
|
+
function addAddon(key, addon, priority = 0) {
|
|
376
|
+
if (Context.addonRecord[key] && Context.addonRecord[key].value !== addon) debug(`overwrite Addon "${String(key)}"`, "warn");
|
|
377
|
+
Context.addonRecord[key] = {
|
|
378
|
+
value: addon,
|
|
379
|
+
priority
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
_chunkC2MTV2HSjs.__name.call(void 0, addAddon, "addAddon");
|
|
383
|
+
|
|
384
|
+
// src/http/helper.ts
|
|
385
|
+
function resolveDep(ret, key) {
|
|
386
|
+
if (key) return _optionalChain([ret, 'optionalAccess', _ => _[key]]);
|
|
387
|
+
return ret;
|
|
388
|
+
}
|
|
389
|
+
_chunkC2MTV2HSjs.__name.call(void 0, resolveDep, "resolveDep");
|
|
390
|
+
function argToReq(params, args, headers) {
|
|
391
|
+
const req = {
|
|
392
|
+
body: {},
|
|
393
|
+
query: {},
|
|
394
|
+
params: {},
|
|
395
|
+
headers
|
|
396
|
+
};
|
|
397
|
+
params.forEach((param) => {
|
|
398
|
+
if (param.key) req[param.type][param.key] = args[param.index];
|
|
399
|
+
else req[param.type] = args[param.index];
|
|
400
|
+
});
|
|
401
|
+
return req;
|
|
402
|
+
}
|
|
403
|
+
_chunkC2MTV2HSjs.__name.call(void 0, argToReq, "argToReq");
|
|
404
|
+
|
|
405
|
+
// src/rpc/helper.ts
|
|
406
|
+
var _os = require('os');
|
|
407
|
+
function genClientQueue(key) {
|
|
408
|
+
return `PS-${key ? `${key}-` : ""}${_os.hostname.call(void 0, )}-${process.pid}`;
|
|
409
|
+
}
|
|
410
|
+
_chunkC2MTV2HSjs.__name.call(void 0, genClientQueue, "genClientQueue");
|
|
411
|
+
|
|
412
|
+
// src/decorators/helper.ts
|
|
413
|
+
function shallowClone(obj) {
|
|
414
|
+
return {
|
|
415
|
+
...obj
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
_chunkC2MTV2HSjs.__name.call(void 0, shallowClone, "shallowClone");
|
|
419
|
+
function mergeObject(...args) {
|
|
420
|
+
return Object.assign({}, ...args);
|
|
421
|
+
}
|
|
422
|
+
_chunkC2MTV2HSjs.__name.call(void 0, mergeObject, "mergeObject");
|
|
423
|
+
|
|
424
|
+
// src/helper.ts
|
|
425
|
+
function createControllerMetaMap(meta, filter) {
|
|
426
|
+
const metaMap = /* @__PURE__ */ new Map();
|
|
427
|
+
function handleMeta() {
|
|
428
|
+
metaMap.clear();
|
|
429
|
+
for (const item of meta) {
|
|
430
|
+
const { tag, func } = item.data;
|
|
431
|
+
if (!filter(item)) continue;
|
|
432
|
+
if (metaMap.has(tag)) metaMap.get(tag)[func] = item;
|
|
433
|
+
else metaMap.set(tag, {
|
|
434
|
+
[func]: item
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
_chunkC2MTV2HSjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
439
|
+
handleMeta();
|
|
440
|
+
_chunkC2MTV2HSjs.HMR.call(void 0, handleMeta);
|
|
441
|
+
return metaMap;
|
|
442
|
+
}
|
|
443
|
+
_chunkC2MTV2HSjs.__name.call(void 0, createControllerMetaMap, "createControllerMetaMap");
|
|
444
|
+
function detectAopDep(meta, { guards, addons } = {}, controller = "http") {
|
|
445
|
+
const addonSet = /* @__PURE__ */ new Set();
|
|
446
|
+
const guardSet = /* @__PURE__ */ new Set();
|
|
447
|
+
const pipeSet = /* @__PURE__ */ new Set();
|
|
448
|
+
const filterSet = /* @__PURE__ */ new Set();
|
|
449
|
+
const warningSet = /* @__PURE__ */ new Set();
|
|
450
|
+
function handleMeta() {
|
|
451
|
+
addonSet.clear();
|
|
452
|
+
guardSet.clear();
|
|
453
|
+
pipeSet.clear();
|
|
454
|
+
filterSet.clear();
|
|
455
|
+
warningSet.clear();
|
|
456
|
+
_optionalChain([addons, 'optionalAccess', _2 => _2.forEach, 'call', _3 => _3((item) => {
|
|
457
|
+
addonSet.add(item);
|
|
458
|
+
})]);
|
|
459
|
+
_optionalChain([guards, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((item) => {
|
|
460
|
+
guardSet.add(item);
|
|
461
|
+
})]);
|
|
462
|
+
meta.forEach(({ data }) => {
|
|
463
|
+
if (data.controller !== controller) {
|
|
464
|
+
if (data[controller]) warningSet.add(`Should use ${controller} controller to decorate class "${data.name}"`);
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
if (data.filter) filterSet.add(data.filter);
|
|
468
|
+
data.guards.forEach((i) => guardSet.add(i));
|
|
469
|
+
data.addons.forEach((i) => addonSet.add(i));
|
|
470
|
+
data.params.forEach((i) => {
|
|
471
|
+
if (i.pipe) pipeSet.add(i.pipe);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
const missAddons = [
|
|
475
|
+
...addonSet
|
|
476
|
+
].filter((i) => !Context.addonRecord[i]);
|
|
477
|
+
const missGuards = [
|
|
478
|
+
...guardSet
|
|
479
|
+
].filter((i) => !Context.guardRecord[i]);
|
|
480
|
+
const missPipes = [
|
|
481
|
+
...pipeSet
|
|
482
|
+
].filter((i) => !Context.pipeRecord[i]);
|
|
483
|
+
const missFilters = [
|
|
484
|
+
...filterSet
|
|
485
|
+
].filter((i) => !Context.filterRecord[i]);
|
|
486
|
+
function exit() {
|
|
487
|
+
if (_chunkC2MTV2HSjs.IS_STRICT) process.exit(5);
|
|
488
|
+
}
|
|
489
|
+
_chunkC2MTV2HSjs.__name.call(void 0, exit, "exit");
|
|
490
|
+
if (missAddons.length) {
|
|
491
|
+
_chunkC2MTV2HSjs.log.call(void 0, `${_picocolors2.default.white(`Addon [${missAddons.join(",")}]`)} doesn't exist`, "warn");
|
|
492
|
+
exit();
|
|
493
|
+
}
|
|
494
|
+
if (missGuards.length) {
|
|
495
|
+
_chunkC2MTV2HSjs.log.call(void 0, `${_picocolors2.default.magenta(`Guard [${missGuards.join(",")}]`)} doesn't exist`, "warn");
|
|
496
|
+
exit();
|
|
497
|
+
}
|
|
498
|
+
if (missPipes.length) {
|
|
499
|
+
_chunkC2MTV2HSjs.log.call(void 0, `${_picocolors2.default.blue(`Pipe [${missPipes.join(",")}]`)} doesn't exist`, "warn");
|
|
500
|
+
exit();
|
|
501
|
+
}
|
|
502
|
+
if (missFilters.length) {
|
|
503
|
+
_chunkC2MTV2HSjs.log.call(void 0, `${_picocolors2.default.red(`Filter [${missFilters.join(",")}]`)} doesn't exist`, "warn");
|
|
504
|
+
exit();
|
|
505
|
+
}
|
|
506
|
+
warningSet.forEach((warn) => _chunkC2MTV2HSjs.log.call(void 0, warn, "warn"));
|
|
507
|
+
if (warningSet.size) exit();
|
|
508
|
+
}
|
|
509
|
+
_chunkC2MTV2HSjs.__name.call(void 0, handleMeta, "handleMeta");
|
|
510
|
+
handleMeta();
|
|
511
|
+
_chunkC2MTV2HSjs.HMR.call(void 0, handleMeta);
|
|
512
|
+
return {
|
|
513
|
+
addonSet,
|
|
514
|
+
guardSet,
|
|
515
|
+
pipeSet,
|
|
516
|
+
filterSet
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
_chunkC2MTV2HSjs.__name.call(void 0, detectAopDep, "detectAopDep");
|
|
520
|
+
function joinUrl(base, ...paths) {
|
|
521
|
+
const joinedPath = [
|
|
522
|
+
base,
|
|
523
|
+
...paths
|
|
524
|
+
].filter((p) => p).map((path) => path.replace(/(^\/)/g, "")).join("/");
|
|
525
|
+
return `/${joinedPath}`;
|
|
526
|
+
}
|
|
527
|
+
_chunkC2MTV2HSjs.__name.call(void 0, joinUrl, "joinUrl");
|
|
528
|
+
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
exports.defaultPipe = defaultPipe; exports.Exception = Exception; exports.UndefinedException = UndefinedException; exports.ValidateException = ValidateException; exports.ForbiddenException = ForbiddenException; exports.BadRequestException = BadRequestException; exports.NotFoundException = NotFoundException; exports.ConflictException = ConflictException; exports.BadGatewayException = BadGatewayException; exports.InvalidInputException = InvalidInputException; exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException; exports.PayloadLargeException = PayloadLargeException; exports.TimeoutException = TimeoutException; exports.UnauthorizedException = UnauthorizedException; exports.ServiceUnavailableException = ServiceUnavailableException; exports.FrameworkException = FrameworkException; exports.TimerException = TimerException; exports.WorkerException = WorkerException; exports.resolveDep = resolveDep; exports.argToReq = argToReq; exports.genClientQueue = genClientQueue; exports.shallowClone = shallowClone; exports.mergeObject = mergeObject; exports.createControllerMetaMap = createControllerMetaMap; exports.detectAopDep = detectAopDep; exports.joinUrl = joinUrl; exports.Context = Context; exports.addPipe = addPipe; exports.addFilter = addFilter; exports.addGuard = addGuard; exports.addAddon = addAddon;
|
|
562
|
+
//# sourceMappingURL=chunk-OGNSLEM7.js.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/rpc/helper.ts","../src/decorators/helper.ts"],"names":["pc","Debug","defaultPipe","arg","Exception","Error","constructor","message","status","description","data","ERROR_SYMBOL","UndefinedException","ValidateException","ForbiddenException","BadRequestException","NotFoundException","ConflictException","BadGatewayException","InvalidInputException","UnsupportedMediaTypeException","PayloadLargeException","TimeoutException","UnauthorizedException","ServiceUnavailableException","FrameworkException","TimerException","WorkerException","defaultFilter","e","log","LOG_LEVEL","console","error","stack","name","debug","Context","method","params","filterRecord","default","pipeRecord","guardRecord","addonRecord","ctx","canGetCtx","IS_DEV","_context","that","Proxy","get","target","p","tag","set","newValue","getAop","meta","opts","globalGuards","globalFilter","globalPipe","guards","filter","func","resolved","pipe","map","item","process","env","DEBUG","magenta","join","g","blue","red","getGuards","getPipe","getFilter","run","successCb","failCb","moduleMap","paramsType","ctxs","res","nextHandler","index","length","instance","forEach","args","Promise","all","i","resolveDep","type","key","reflect","resolve","then","nextPromise","next","ret","undefined","err","guard","Set","push","sort","a","b","priority","value","applyAddons","addons","router","framework","addPipe","String","addFilter","addGuard","addAddon","addon","argToReq","headers","req","body","query","param","hostname","genClientQueue","pid","shallowClone","obj","mergeObject","Object","assign","createControllerMetaMap","metaMap","Map","handleMeta","clear","has","HMR","detectAopDep","controller","addonSet","guardSet","pipeSet","filterSet","warningSet","add","missAddons","missGuards","missPipes","missFilters","exit","IS_STRICT","white","warn","size","joinUrl","base","paths","joinedPath","path","replace"],"mappings":";;;;;;;;;;;AAEA,OAAOA,SAAQ;;;ACFf,OAAOC,WAAW;AAClB,OAAOD,QAAQ;;;ACIR,IAAME,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,cAAiCR,UAAAA;EAFxC,OAEwCA;;;EACtCE,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,iBAAA;EACtB;AACF;;;ACJO,IAAMM,oBAAN,cAAgCT,UAAAA;EAFvC,OAEuCA;;;EACrCE,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMO,qBAAN,cAAiCV,UAAAA;EAFxC,OAEwCA;;;EACtCE,YAAYC,SAAiB;AAC3B,UAAMA,SAAS,KAAK,oBAAA;EACtB;AACF;;;ACJO,IAAMQ,sBAAN,cAAkCX,UAAAA;EAFzC,OAEy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// 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_STRICT } from './common'\r\n\r\nexport * from './hmr'\r\nexport * from './http/helper'\r\nexport * from './rpc/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 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\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 !== 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 process.exit(5)\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","import type { ControllerMetaData } from '../meta'\r\n\r\nexport function resolveDep(ret: any, key: string) {\r\n if (key)\r\n return ret?.[key]\r\n return ret\r\n}\r\n\r\nexport 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","import { hostname } from 'os'\r\n\r\nexport function genClientQueue(key?: string) {\r\n return `PS-${key ? `${key}-` : ''}${hostname()}-${process.pid}`\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"]}
|