vome-core 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +236 -1
- package/dist/server/index.js +3261 -1
- package/package.json +10 -2
- package/src/admin/components/vm-auto-perm-dialog.vue +3 -0
- package/src/admin/components/vm-check-tree.vue +1 -0
- package/src/admin/components/vm-dept-tree.vue +3 -0
- package/src/admin/components/vm-empty.vue +1 -0
- package/src/admin/components/vm-eps-perm-picker.vue +2 -0
- package/src/admin/components/vm-group-cascader.vue +1 -0
- package/src/admin/components/vm-icon-picker.vue +1 -0
- package/src/admin/components/vm-markdown.vue +1 -0
- package/src/admin/components/vm-ri-icon.vue +2 -0
- package/src/admin/components/vm-role-picker.vue +2 -0
- package/src/admin/components/vm-view-path-picker.vue +1 -0
- package/src/admin/crud/components/vm-column-custom.vue +1 -0
- package/src/admin/crud/components/vm-context-menu.vue +1 -0
- package/src/admin/crud/components/vm-date-picker.vue +1 -0
- package/src/admin/crud/components/vm-date-range.vue +1 -0
- package/src/admin/crud/components/vm-date-text.vue +1 -0
- package/src/admin/crud/components/vm-dict-tag.vue +1 -0
- package/src/admin/crud/components/vm-file-icon.vue +1 -0
- package/src/admin/crud/components/vm-multi-select.vue +1 -0
- package/src/admin/crud/components/vm-select.vue +2 -0
- package/src/admin/crud/components/vm-switch.vue +1 -0
- package/src/admin/crud/components/vm-tree-select.vue +1 -0
- package/src/admin/crud/components/vm-upload-item.vue +1 -0
- package/src/admin/crud/components/vm-upload.vue +2 -0
- package/src/admin/crud/components/vm-user-select.vue +1 -0
- package/src/admin/crud/vm-add-btn.vue +1 -0
- package/src/admin/crud/vm-adv-search.vue +1 -0
- package/src/admin/crud/vm-crud.vue +2 -0
- package/src/admin/crud/vm-dialog.vue +1 -0
- package/src/admin/crud/vm-form.vue +1 -0
- package/src/admin/crud/vm-pagination.vue +1 -0
- package/src/admin/crud/vm-search-key.vue +1 -0
- package/src/admin/crud/vm-search.vue +1 -0
- package/src/admin/crud/vm-table.vue +1 -0
- package/src/admin/crud/vm-toolbar.vue +1 -0
- package/src/admin/crud/vm-upsert.vue +2 -0
- package/src/admin/lib/eps.ts +3 -2
- package/src/admin/lib/menu.ts +3 -2
- package/src/admin/router/index.ts +1 -7
- package/src/admin/service/index.ts +143 -46
- package/src/admin/stores/user.ts +4 -4
package/dist/server/index.js
CHANGED
|
@@ -1 +1,3261 @@
|
|
|
1
|
-
const _0x3ec76d=_0x4875;(function(_0x459fd4,_0x489e41){const _0x2f2df7=_0x4875,_0x2fc76=_0x459fd4();while(!![]){try{const _0x14cf90=parseInt(_0x2f2df7(0x259))/0x1+parseInt(_0x2f2df7(0x311))/0x2+parseInt(_0x2f2df7(0x276))/0x3+-parseInt(_0x2f2df7(0x2cf))/0x4+-parseInt(_0x2f2df7(0x19e))/0x5*(parseInt(_0x2f2df7(0x256))/0x6)+parseInt(_0x2f2df7(0x1fb))/0x7*(-parseInt(_0x2f2df7(0x325))/0x8)+-parseInt(_0x2f2df7(0x224))/0x9*(-parseInt(_0x2f2df7(0x214))/0xa);if(_0x14cf90===_0x489e41)break;else _0x2fc76['push'](_0x2fc76['shift']());}catch(_0x32a640){_0x2fc76['push'](_0x2fc76['shift']());}}}(_0x384a,0xa4119));import{join as _0x6bb688}from'path';import{pathToFileURL as _0x30b6da}from'url';function P(){const _0x11b0e7=_0x4875;return Bun[_0x11b0e7(0x18a)][_0x11b0e7(0x326)]==='dev'?_0x11b0e7(0x237):_0x11b0e7(0x31b);}function a0(_0x255910,_0x2bd3b4){const _0xcde57f=_0x4875;let _0x512d9a={..._0x255910};for(let _0x122ed2 of Object[_0xcde57f(0x1fd)](_0x2bd3b4)){let _0x4f6daa=_0x512d9a[_0x122ed2],_0x37d133=_0x2bd3b4[_0x122ed2];if(_0x4f6daa&&_0x37d133&&typeof _0x4f6daa===_0xcde57f(0x287)&&typeof _0x37d133===_0xcde57f(0x287)&&!Array[_0xcde57f(0x201)](_0x4f6daa)&&!Array[_0xcde57f(0x201)](_0x37d133)){_0x512d9a[_0x122ed2]=a0(_0x4f6daa,_0x37d133);continue;}_0x512d9a[_0x122ed2]=_0x37d133;}return _0x512d9a;}async function V1(_0x3452d1=_0x6bb688(process[_0x3ec76d(0x317)](),_0x3ec76d(0x22a))){const _0x350df6=_0x3ec76d;let _0x16ff40=P()===_0x350df6(0x237)?_0x350df6(0x239):_0x350df6(0x286),_0x4a5234=await import(_0x30b6da(_0x6bb688(_0x3452d1,'default.ts'))['href']),_0x245eba=await import(_0x30b6da(_0x6bb688(_0x3452d1,_0x16ff40))[_0x350df6(0x29e)]);return a0(_0x4a5234[_0x350df6(0x1d0)],_0x245eba[_0x350df6(0x1d0)]);}var D=await V1();import{Elysia as _0x3335e2}from'elysia';import{Elysia as _0xaae206}from'elysia';import{AsyncLocalStorage as _0x3fbd09}from'async_hooks';var C0=new _0x3fbd09(),W1=!0x1;function w3(_0x5dd0e3){const _0x488e68=_0x3ec76d;let _0x3c57da=_0x5dd0e3['headers'][_0x488e68(0x307)](_0x488e68(0x17f));if(_0x3c57da){let _0x40f919=_0x3c57da['split'](',')[0x0]?.['trim']();if(_0x40f919)return _0x40f919;}return _0x5dd0e3[_0x488e68(0x205)][_0x488e68(0x307)](_0x488e68(0x2bf))?.[_0x488e68(0x2ae)]()||_0x5dd0e3[_0x488e68(0x205)][_0x488e68(0x307)](_0x488e68(0x207))?.['trim']()||'';}function z1(_0x325dee){const _0x51edc2=_0x3ec76d;let _0x350d35=new URL(_0x325dee[_0x51edc2(0x2c5)]),_0x55451a=_0x325dee[_0x51edc2(0x205)]['get']('x-forwarded-host')?.[_0x51edc2(0x2f6)](',')[0x0]?.[_0x51edc2(0x2ae)](),_0x4a1e22=_0x325dee[_0x51edc2(0x205)][_0x51edc2(0x307)]('host')?.[_0x51edc2(0x2ae)]();return{'requestId':crypto[_0x51edc2(0x342)](),'method':_0x325dee[_0x51edc2(0x192)],'path':_0x350d35[_0x51edc2(0x264)],'ip':w3(_0x325dee),'host':_0x55451a||_0x4a1e22||_0x350d35[_0x51edc2(0x1be)],'startTime':Date[_0x51edc2(0x292)]()};}function G1(_0x329bd5){const _0x504007=_0x3ec76d;C0[_0x504007(0x320)](_0x329bd5);}function b3(){const _0x4c598f=_0x3ec76d;return C0[_0x4c598f(0x252)]();}function y3(_0x496366){const _0x5364d9=_0x3ec76d;let _0x5866a1=C0['getStore']();if(!_0x5866a1){if(P()===_0x5364d9(0x237)&&!W1)W1=!0x0,console[_0x5364d9(0x291)](_0x5364d9(0x1e8));return;}Object[_0x5364d9(0x2f7)](_0x5866a1,_0x496366);}function g3(_0x1bd19d,_0x363cd2){const _0x52ecc8=_0x3ec76d;return C0[_0x52ecc8(0x329)](_0x1bd19d,_0x363cd2);}var _=Object[_0x3ec76d(0x2f7)](y3,{'get':b3,'run':g3});import'reflect-metadata';var I0=new Map();function f(_0x595301){const _0x1687b3=_0x3ec76d;I0[_0x1687b3(0x1d8)](_0x595301[_0x1687b3(0x1c9)],_0x595301);}function e0(_0x3cf23e){const _0x56df29=_0x3ec76d;return I0[_0x56df29(0x307)](_0x3cf23e);}function Z0(){const _0x2dd75b=_0x3ec76d;let _0x42571c=new Set(),_0x55257c=[];for(let _0x4a7d61 of I0[_0x2dd75b(0x18b)]()){if(_0x42571c[_0x2dd75b(0x34b)](_0x4a7d61[_0x2dd75b(0x1cb)]))continue;_0x42571c[_0x2dd75b(0x2f2)](_0x4a7d61['useClass']),_0x55257c[_0x2dd75b(0x279)](_0x4a7d61);}return _0x55257c;}function QQ(_0x5364e6){const _0x5b78c0=_0x3ec76d;if(typeof _0x5364e6==='string'||typeof _0x5364e6==='symbol')return String(_0x5364e6);return _0x5364e6[_0x5b78c0(0x254)]||'(anonymous)';}function c(_0x1ca04d,_0x1ac062){const _0x178eab=_0x3ec76d;let _0x1e38fe=Reflect[_0x178eab(0x304)](_0x178eab(0x1b0),_0x1ca04d)??[];_0x1e38fe[_0x178eab(0x279)](_0x1ac062),Reflect[_0x178eab(0x1c8)](_0x178eab(0x1b0),_0x1e38fe,_0x1ca04d);}function F1(_0x6c8315){const _0x18755c=_0x3ec76d;return Reflect[_0x18755c(0x304)](_0x18755c(0x1b0),_0x6c8315)??[];}function j1(){const _0x146ef4=_0x3ec76d;I0[_0x146ef4(0x1c6)]();}var p;(_0x4cfa99=>{const _0xe5a932=_0x3ec76d;_0x4cfa99[_0xe5a932(0x301)]='singleton',_0x4cfa99[_0xe5a932(0x33c)]='request',_0x4cfa99['Prototype']=_0xe5a932(0x1a9);})(p||={});var o=new Map(),R0=new Set(),H1=new WeakMap();function h3(_0x4bf66e,_0x3ea1f1){const _0x24fd5b=_0x3ec76d;for(let _0x22f8c5 of F1(_0x3ea1f1)){let {propertyKey:_0x562173,token:_0x55d69d,resolve:_0x15b6eb}=_0x22f8c5;if(!_0x15b6eb&&_0x55d69d==null)throw Error(_0x24fd5b(0x1fa)+String(_0x562173)+_0x24fd5b(0x1db));let _0x2de1f2=_0x15b6eb?_0x15b6eb():K['get'](_0x55d69d);_0x4bf66e[_0x562173]=_0x2de1f2;let _0x140459=_0x4bf66e[_0x24fd5b(0x26d)];if(_0x15b6eb&&typeof _0x140459===_0x24fd5b(0x22e))_0x140459[_0x24fd5b(0x170)](_0x4bf66e,_0x2de1f2);}}function $Q(_0x982851){const _0x4ca1b0=_0x3ec76d;if(R0['has'](_0x982851))throw Error(_0x4ca1b0(0x2d3)+_0x982851[_0x4ca1b0(0x254)]);R0[_0x4ca1b0(0x2f2)](_0x982851);try{let _0x33296d=new _0x982851();return h3(_0x33296d,_0x982851),_0x33296d;}finally{R0['delete'](_0x982851);}}function B1(_0x4333d5){const _0x3d52d5=_0x3ec76d;let _0x6b94f7=o['get'](_0x4333d5);if(_0x6b94f7)return _0x6b94f7;let _0x48f86e=$Q(_0x4333d5);return o[_0x3d52d5(0x1d8)](_0x4333d5,_0x48f86e),_0x48f86e;}function u3(){const _0x10209b=_0x3ec76d;let _0x2a5b90=_[_0x10209b(0x307)]();if(!_0x2a5b90)throw Error(_0x10209b(0x2b8));let _0x158dbe=H1[_0x10209b(0x307)](_0x2a5b90);if(!_0x158dbe)_0x158dbe=new Map(),H1[_0x10209b(0x1d8)](_0x2a5b90,_0x158dbe);return _0x158dbe;}function m3(_0x12e3ef){let _0x5b377b=u3(),_0x44e115=_0x5b377b['get'](_0x12e3ef);if(_0x44e115)return _0x44e115;let _0x2b73a2=$Q(_0x12e3ef);return _0x5b377b['set'](_0x12e3ef,_0x2b73a2),_0x2b73a2;}function c3(_0x22bb31,_0x290ad1){const _0x2291e4=_0x3ec76d;switch(_0x290ad1){case _0x2291e4(0x2fb):return B1(_0x22bb31);case _0x2291e4(0x1a9):return $Q(_0x22bb31);case _0x2291e4(0x243):return m3(_0x22bb31);default:throw Error(_0x2291e4(0x1a7)+_0x290ad1);}}function p3(_0x3e5096){const _0x12dcbd=_0x3ec76d;let _0x5c7be9=e0(_0x3e5096);if(!_0x5c7be9)throw Error(_0x12dcbd(0x333)+QQ(_0x3e5096));return _0x5c7be9;}function ZQ(){const _0x5c5776=_0x3ec76d;for(let {useClass:_0x18739a,scope:_0x12f85b}of Z0())if(_0x12f85b===_0x5c5776(0x2fb))B1(_0x18739a);console[_0x5c5776(0x1c3)](_0x5c5776(0x19d)+o[_0x5c5776(0x2f3)]+_0x5c5776(0x2ff));}function d3(_0x1d7461){const _0xf6c652=_0x3ec76d;let _0x19beb1=p3(_0x1d7461);return c3(_0x19beb1[_0xf6c652(0x1cb)],_0x19beb1[_0xf6c652(0x2fd)]);}function n3(_0x74913c,_0x4948ee){const _0x62f79=_0x3ec76d;if(typeof _0x74913c===_0x62f79(0x22e)){f({'token':_0x74913c,'useClass':_0x74913c,'scope':_0x62f79(0x2fb)}),o[_0x62f79(0x1d8)](_0x74913c,_0x4948ee);return;}let _0x46e7d0=_0x4948ee?.[_0x62f79(0x1df)];if(!_0x46e7d0||_0x46e7d0===Object)throw Error('[Ioc]\x20Ioc.set('+QQ(_0x74913c)+_0x62f79(0x24e));f({'token':_0x74913c,'useClass':_0x46e7d0,'scope':'singleton'}),f({'token':_0x46e7d0,'useClass':_0x46e7d0,'scope':_0x62f79(0x2fb)}),o[_0x62f79(0x1d8)](_0x46e7d0,_0x4948ee);}function JQ(){const _0x3cab4d=_0x3ec76d;o[_0x3cab4d(0x1c6)](),R0['clear'](),j1();}var K={'get':d3,'set':n3};import'reflect-metadata';var M1=new Map();function L1(_0x254156){const _0x2b8d22=_0x3ec76d;M1[_0x2b8d22(0x1d8)](_0x254156[_0x2b8d22(0x1c9)],_0x254156);}function O(_0x26969e){const _0xd65493=_0x3ec76d;let _0x1343b0=[...M1['values']()];return _0x26969e?_0x1343b0['filter'](_0x4a269d=>_0x4a269d[_0xd65493(0x2a2)]===_0x26969e):_0x1343b0;}var q0=_0x3ec76d(0x2e5),S0='vome:controller:route-public',E0='vome:controller:route-middleware',P0=_0x3ec76d(0x2ab),O0=_0x3ec76d(0x24b);function Y1(_0x304a79,_0x30344d,_0x596cb0){const _0x56745b=_0x3ec76d;let _0x50ea02=Reflect[_0x56745b(0x304)](q0,_0x304a79)??{},_0x101a41=_0x50ea02[_0x30344d]??[];_0x101a41['push'](_0x596cb0),_0x50ea02[_0x30344d]=_0x101a41,Reflect[_0x56745b(0x1c8)](q0,_0x50ea02,_0x304a79);}function U1(_0xec8f2f,_0x5065ce){const _0x31d59d=_0x3ec76d;return Reflect[_0x31d59d(0x304)](q0,_0xec8f2f)?.[_0x5065ce]??[];}function D1(_0x242ec3){const _0x987ffc=_0x3ec76d;Reflect[_0x987ffc(0x1cc)](q0,_0x242ec3);}function T1(_0x502618,_0x598765){const _0xa293d3=_0x3ec76d;let _0x5eb11f=Reflect[_0xa293d3(0x304)](S0,_0x502618)??{};_0x5eb11f[_0x598765]=!0x0,Reflect['defineMetadata'](S0,_0x5eb11f,_0x502618);}function N1(_0x42fe02,_0x328ae9){const _0x2fa772=_0x3ec76d;return!!Reflect[_0x2fa772(0x304)](S0,_0x42fe02)?.[_0x328ae9];}function A1(_0x2bac08){const _0x28e3ea=_0x3ec76d;Reflect[_0x28e3ea(0x1cc)](S0,_0x2bac08);}function K1(_0x29ea68,_0x532368,_0x5a7f76){const _0x34ac91=_0x3ec76d;let _0x232950=Reflect['getMetadata'](E0,_0x29ea68)??{};_0x232950[_0x532368]=[..._0x232950[_0x532368]??[],..._0x5a7f76],Reflect[_0x34ac91(0x1c8)](E0,_0x232950,_0x29ea68);}function _1(_0x4dc3c5,_0x32acb4){const _0x41f60d=_0x3ec76d;return Reflect[_0x41f60d(0x304)](E0,_0x4dc3c5)?.[_0x32acb4]??[];}function C1(_0x304acb){const _0x1d5c16=_0x3ec76d;Reflect[_0x1d5c16(0x1cc)](E0,_0x304acb);}function I1(_0x450d97,_0x34dc24,_0x2188b8){const _0xc7593d=_0x3ec76d;let _0x37082a=Reflect[_0xc7593d(0x304)](P0,_0x450d97)??{};_0x37082a[_0x34dc24]=_0x2188b8,Reflect['defineMetadata'](P0,_0x37082a,_0x450d97);}function R1(_0x3e121d,_0x24ccc1){const _0x223f2a=_0x3ec76d;return Reflect[_0x223f2a(0x304)](P0,_0x3e121d)?.[_0x24ccc1];}function q1(_0xdac270){const _0x1435ff=_0x3ec76d;Reflect[_0x1435ff(0x1cc)](P0,_0xdac270);}function S1(_0x32e88d,_0xf80f15){const _0x5473d3=_0x3ec76d;let _0x1cffb7=Reflect[_0x5473d3(0x304)](O0,_0x32e88d)??{};_0x1cffb7[_0xf80f15]=!0x0,Reflect['defineMetadata'](O0,_0x1cffb7,_0x32e88d);}function E1(_0x33a807,_0x330736){const _0x2c3e79=_0x3ec76d;return!!Reflect[_0x2c3e79(0x304)](O0,_0x33a807)?.[_0x330736];}function P1(_0xf246bf){Reflect['deleteMetadata'](O0,_0xf246bf);}function x0(_0x585e3e){const _0x45f58a=_0x3ec76d;let _0x4ca0aa={};for(let _0x147974 of _0x585e3e){if(_0x147974[_0x45f58a(0x2bb)]===_0x45f58a(0x2af)&&_0x147974[_0x45f58a(0x2f4)]!==void 0x0)_0x4ca0aa['body']=_0x147974[_0x45f58a(0x2f4)];if(_0x147974[_0x45f58a(0x2bb)]==='query'&&_0x147974[_0x45f58a(0x2f4)]!==void 0x0)_0x4ca0aa[_0x45f58a(0x20d)]=_0x147974[_0x45f58a(0x2f4)];if(_0x147974['source']==='params'&&_0x147974[_0x45f58a(0x2f4)]!==void 0x0)_0x4ca0aa[_0x45f58a(0x174)]=_0x147974['schema'];}return Object['keys'](_0x4ca0aa)[_0x45f58a(0x209)]>0x0?_0x4ca0aa:void 0x0;}function J0(_0x2f813a,_0x4e53b8){return _0x2f813a+'.'+_0x4e53b8;}function v0(_0x54194b){const _0x40d587=_0x3ec76d;if(_0x54194b===_0x40d587(0x275))return 0x0;if(_0x54194b===_0x40d587(0x1e9))return 0x1;return 0x2;}function k0(_0xf2a405){const _0x1a57d2=_0x3ec76d;let _0x59cf7d=_0xf2a405['lastIndexOf']('.');if(_0x59cf7d<0x0)return{'module':_0xf2a405,'side':''};return{'module':_0xf2a405[_0x1a57d2(0x231)](0x0,_0x59cf7d),'side':_0xf2a405['slice'](_0x59cf7d+0x1)};}function O1(){const _0x401bc7=_0x3ec76d;let _0x3848b4=O(),_0x348aaf=new Map(),_0x502c77=new Map();for(let _0x3f68fe of _0x3848b4){let _0x53d3fe=J0(_0x3f68fe[_0x401bc7(0x31c)],_0x3f68fe[_0x401bc7(0x2a2)]);if(!_0x348aaf[_0x401bc7(0x34b)](_0x53d3fe))_0x348aaf[_0x401bc7(0x1d8)](_0x53d3fe,{'name':_0x53d3fe,'description':_0x3f68fe[_0x401bc7(0x31c)]+'\x20'+_0x3f68fe['side'],'x-displayName':_0x3f68fe[_0x401bc7(0x2a2)]});let _0x39167c=_0x502c77[_0x401bc7(0x307)](_0x3f68fe[_0x401bc7(0x31c)]);if(!_0x39167c)_0x39167c=new Set(),_0x502c77['set'](_0x3f68fe[_0x401bc7(0x31c)],_0x39167c);_0x39167c[_0x401bc7(0x2f2)](_0x53d3fe);}let _0x24768a=[..._0x348aaf[_0x401bc7(0x18b)]()][_0x401bc7(0x2c1)]((_0x4b736f,_0x52b17e)=>{const _0x492a44=_0x401bc7;let _0x48a690=k0(_0x4b736f[_0x492a44(0x254)]),_0x4de82b=k0(_0x52b17e[_0x492a44(0x254)]);return _0x48a690[_0x492a44(0x31c)]['localeCompare'](_0x4de82b[_0x492a44(0x31c)])||v0(_0x48a690[_0x492a44(0x2a2)])-v0(_0x4de82b[_0x492a44(0x2a2)]);}),_0x3f83b7=[..._0x502c77[_0x401bc7(0x1f2)]()]['sort'](([_0x1f4950],[_0x300f85])=>_0x1f4950[_0x401bc7(0x341)](_0x300f85))[_0x401bc7(0x196)](([_0x1d626b,_0x17da3d])=>({'name':_0x1d626b,'tags':[..._0x17da3d]['sort']((_0x2e61a1,_0x1ba5e0)=>{const _0x2e42e5=_0x401bc7;let _0xca341b=k0(_0x2e61a1)[_0x2e42e5(0x2a2)],_0x270325=k0(_0x1ba5e0)[_0x2e42e5(0x2a2)];return v0(_0xca341b)-v0(_0x270325);})}));return{'tags':_0x24768a,'tagGroups':_0x3f83b7};}function w(_0x273e8e){const _0xddadf=_0x3ec76d;if(!_0x273e8e)return'';return _0x273e8e[_0xddadf(0x2c0)]('/')?_0x273e8e:'/'+_0x273e8e;}function b(..._0x4371f5){const _0x57e5bc=_0x3ec76d;let _0xce5e54=_0x4371f5[_0x57e5bc(0x196)](_0x10f9f9=>w(_0x10f9f9)[_0x57e5bc(0x1ce)](/^\/+|\/+$/g,''))[_0x57e5bc(0x22f)](Boolean);return _0xce5e54[_0x57e5bc(0x209)]?'/'+_0xce5e54[_0x57e5bc(0x216)]('/'):'/';}function d(_0x566a8f,_0x40902a){const _0x53fe59=_0x3ec76d;let _0x7080fe=w(_0x40902a)[_0x53fe59(0x1ce)](/\/$/,''),_0x3b8d65=w(_0x566a8f);if(!_0x7080fe)return _0x3b8d65||'/';if(_0x3b8d65===_0x7080fe)return'/';if(_0x3b8d65['startsWith'](_0x7080fe+'/'))return _0x3b8d65[_0x53fe59(0x231)](_0x7080fe[_0x53fe59(0x209)])||'/';return(_0x566a8f[_0x53fe59(0x2c0)]('/')?_0x566a8f:'/'+_0x566a8f)||'/';}function XQ(_0x5a95d6,_0x8e504a,_0x3e4cb8){const _0x3082ab=_0x3ec76d;let _0x31c089=_0x8e504a['replace'](/^\//,'')[_0x3082ab(0x1ce)](/\/+/g,':');if(_0x31c089===_0x5a95d6)_0x31c089=_0x5a95d6;else{if(_0x31c089[_0x3082ab(0x2c0)](_0x5a95d6+':'))_0x31c089=_0x31c089[_0x3082ab(0x231)](_0x5a95d6['length']+0x1);}let _0x384b8c=_0x5a95d6+'-';if(_0x31c089[_0x3082ab(0x2c0)](_0x384b8c))_0x31c089=_0x31c089[_0x3082ab(0x231)](_0x384b8c[_0x3082ab(0x209)]);if(_0x31c089=_0x31c089[_0x3082ab(0x1ce)](/-/g,':'),!_0x31c089)_0x31c089=_0x5a95d6;return _0x5a95d6+':'+_0x31c089+':'+_0x3e4cb8;}function VQ(_0x4150dd){const _0xe36deb=_0x3ec76d;let _0x2f0f22=_0x4150dd['replace'](/^\/+|\/+$/g,'');if(!_0x2f0f22)return _0xe36deb(0x1c1);let _0x92cfc=_0x2f0f22[_0xe36deb(0x2f6)]('/');return _0x92cfc[_0x92cfc[_0xe36deb(0x209)]-0x1]||'index';}function r(_0x44ea2d,_0x5a8245,_0x40a42d){const _0x16fa47=_0x3ec76d;if(_0x5a8245[_0x16fa47(0x2a2)]!==_0x16fa47(0x275)||_0x44ea2d['public']||_0x44ea2d[_0x16fa47(0x22b)])return;if(_0x44ea2d[_0x16fa47(0x343)]?.[_0x16fa47(0x209)])return _0x44ea2d[_0x16fa47(0x343)];let _0x13bb73=_0x40a42d??VQ(d(_0x44ea2d['path']??'/',_0x5a8245[_0x16fa47(0x260)]));return[XQ(_0x5a8245[_0x16fa47(0x31c)],_0x5a8245[_0x16fa47(0x260)],_0x13bb73)];}var WQ;function f0(_0x307848){WQ=_0x307848;}var i3={'admin':_0x3ec76d(0x1e3),'app':_0x3ec76d(0x18d)},x1=_0x3ec76d(0x309),s3=_0x3ec76d(0x33e),o3={'GET':_0x3ec76d(0x307),'POST':_0x3ec76d(0x1f3),'PUT':_0x3ec76d(0x200),'DELETE':'delete','PATCH':'patch'};function r3(_0x149632){return w(i3[_0x149632]);}function a3(_0x53ccaf){const _0x44b66a=_0x3ec76d;if(_0x53ccaf[_0x44b66a(0x174)]?.[_0x44b66a(0x209)])return x0(_0x53ccaf[_0x44b66a(0x174)]);let _0x48b95d={};if(_0x53ccaf[_0x44b66a(0x2af)]!==void 0x0)_0x48b95d[_0x44b66a(0x2af)]=_0x53ccaf[_0x44b66a(0x2af)];if(_0x53ccaf['query']!==void 0x0)_0x48b95d[_0x44b66a(0x20d)]=_0x53ccaf['query'];if(_0x53ccaf[_0x44b66a(0x2a3)]!==void 0x0)_0x48b95d[_0x44b66a(0x174)]=_0x53ccaf[_0x44b66a(0x2a3)];return Object[_0x44b66a(0x1fd)](_0x48b95d)[_0x44b66a(0x209)]>0x0?_0x48b95d:void 0x0;}function t3(_0x4e1ec6,_0x32a8f6,_0x3ec9ba){const _0x359281=_0x3ec76d;let _0x2267e2=new Set();for(let _0x2f6d05 of _0x4e1ec6){if(_0x2267e2[_0x359281(0x34b)](_0x2f6d05[_0x359281(0x2bb)])){let _0x2b5424=_0x2f6d05[_0x359281(0x2bb)]===_0x359281(0x2af)?_0x359281(0x1d2):_0x2f6d05['source']===_0x359281(0x20d)?_0x359281(0x269):_0x359281(0x2b7);throw Error(_0x359281(0x2ad)+_0x3ec9ba+'.'+_0x32a8f6+_0x359281(0x17b)+_0x2b5424);}_0x2267e2[_0x359281(0x2f2)](_0x2f6d05[_0x359281(0x2bb)]);}}function e3(_0x11b2bb,_0x3128ba,_0xaa6254){const _0x192012=_0x3ec76d;let _0x1c2265=_0x11b2bb[_0x3128ba][_0x192012(0x340)](_0x11b2bb);if(!_0xaa6254?.['length'])return _0x1c2265;let _0xe3d5b4=[..._0xaa6254]['sort']((_0xba6b21,_0xaa2e9d)=>_0xba6b21[_0x192012(0x1c1)]-_0xaa2e9d[_0x192012(0x1c1)]);return _0x389d43=>{const _0x18d27d=_0x192012;let _0x33e965=_0xe3d5b4[_0x18d27d(0x196)](_0x38ac46=>{const _0x3d7200=_0x18d27d;if(_0x38ac46[_0x3d7200(0x2bb)]===_0x3d7200(0x2af))return _0x389d43[_0x3d7200(0x2af)];if(_0x38ac46[_0x3d7200(0x2bb)]===_0x3d7200(0x20d))return _0x389d43[_0x3d7200(0x20d)];if(_0x38ac46['source']==='params')return _0x389d43[_0x3d7200(0x174)];throw Error(_0x3d7200(0x334)+_0x38ac46['source']);});return _0x1c2265(..._0x33e965,_0x389d43);};}function v1(_0x702cad){return _0x24c03a=>{const _0x16fc91=_0x4875;let _0x531060=_0x24c03a[_0x16fc91(0x1e4)],_0xb76ad4=_[_0x16fc91(0x307)]();if(_0xb76ad4?.['isSuper'])return;let _0x56b920=_0xb76ad4?.[_0x16fc91(0x343)]??[];if(_0x702cad[_0x16fc91(0x2b1)](_0x4b4846=>_0x56b920['includes'](_0x4b4846)))return;return _0x531060(0x193);};}function k1(_0x372b23,_0x1f0218){const _0x404dc2=_0x3ec76d;let _0xebb8f5=_0x372b23['replace'](/^\/+|\/+$/g,'')[_0x404dc2(0x2f6)]('/')['pop']()||_0x372b23;return _0x1f0218?_0xebb8f5+'\x20'+_0x1f0218:_0xebb8f5;}function Q5(_0x2613f8,_0x40a6bf){const _0x4f6a16=_0x3ec76d;let _0x1177e7={...a3(_0x2613f8)??{},'detail':{'tags':[J0(_0x40a6bf[_0x4f6a16(0x31c)],_0x40a6bf[_0x4f6a16(0x2a2)])],'summary':k1(_0x2613f8[_0x4f6a16(0x18f)],_0x2613f8[_0x4f6a16(0x30f)])}};if(_0x40a6bf[_0x4f6a16(0x2a2)]===_0x4f6a16(0x275)&&!_0x2613f8[_0x4f6a16(0x1af)])_0x1177e7[x1]=!0x0;if(_0x40a6bf['side']===_0x4f6a16(0x1e9)&&!_0x2613f8[_0x4f6a16(0x1af)])_0x1177e7[s3]=!0x0;let _0x54b407=[],_0x3397a2=r(_0x2613f8,_0x40a6bf);if(_0x3397a2?.[_0x4f6a16(0x209)])_0x54b407[_0x4f6a16(0x279)](v1(_0x3397a2));if(_0x2613f8['middleware']?.[_0x4f6a16(0x209)])_0x54b407[_0x4f6a16(0x279)](..._0x2613f8[_0x4f6a16(0x1d3)]);if(_0x54b407['length'])_0x1177e7['beforeHandle']=_0x54b407;return _0x1177e7;}function $5(_0x4867b1){const _0x398017=_0x3ec76d;if(_0x4867b1==null)return{};if(typeof _0x4867b1===_0x398017(0x332))return{'public':_0x4867b1};return _0x4867b1;}function Z5(_0x4ad8b2,_0x1d28ba){const _0x54d9a4=_0x3ec76d;let _0x27928b=r3(_0x4ad8b2[_0x54d9a4(0x2a2)]),_0xc1197f=b(_0x27928b,_0x4ad8b2[_0x54d9a4(0x260)]),_0x1bfd7a=K[_0x54d9a4(0x307)](_0x4ad8b2[_0x54d9a4(0x1c9)]),_0x4c7141=new _0xaae206({'prefix':_0xc1197f,'name':_0x4ad8b2['token']['name'],'tags':[J0(_0x4ad8b2[_0x54d9a4(0x31c)],_0x4ad8b2[_0x54d9a4(0x2a2)])]});for(let _0x434c24 of _0x4ad8b2[_0x54d9a4(0x1d3)]??[])_0x4c7141=_0x4c7141[_0x54d9a4(0x1b3)](_0x434c24);let _0x1ad3ef=[];for(let _0xbaa41b of _0x4ad8b2[_0x54d9a4(0x2eb)]){if(typeof _0x1bfd7a[_0xbaa41b['handler']]!=='function')throw Error(_0x54d9a4(0x2ad)+_0x4ad8b2[_0x54d9a4(0x1c9)][_0x54d9a4(0x254)]+'.'+_0xbaa41b[_0x54d9a4(0x18f)]+_0x54d9a4(0x2cd));t3(_0xbaa41b[_0x54d9a4(0x174)]??[],_0xbaa41b[_0x54d9a4(0x18f)],_0x4ad8b2['token'][_0x54d9a4(0x254)]);let _0x41e816=e3(_0x1bfd7a,_0xbaa41b[_0x54d9a4(0x18f)],_0xbaa41b['params']),_0x43d017=d(_0xbaa41b[_0x54d9a4(0x28a)],_0x4ad8b2[_0x54d9a4(0x260)]),_0x4916de=Q5(_0xbaa41b,_0x4ad8b2),_0x385aa9=o3[_0xbaa41b[_0x54d9a4(0x192)]];_0x4c7141=_0x4c7141[_0x385aa9](_0x43d017,_0x41e816,_0x4916de);}if(_0x4ad8b2[_0x54d9a4(0x2b2)]?.[_0x54d9a4(0x328)]?.[_0x54d9a4(0x209)]||_0x4ad8b2[_0x54d9a4(0x2b2)]?.[_0x54d9a4(0x16f)]?.[_0x54d9a4(0x209)]){if(!WQ)throw Error(_0x54d9a4(0x2ad)+_0x4ad8b2[_0x54d9a4(0x1c9)][_0x54d9a4(0x254)]+_0x54d9a4(0x238));_0x4c7141=WQ(_0x4c7141,_0x4ad8b2,{'controller':_0x1bfd7a,'routeOptions':_0x4e92fb=>{const _0x24f1d7=_0x54d9a4;let {public:_0x3a04e8,action:_0x8a9373,summary:_0x52db77}=$5(_0x4e92fb),_0x591fc0={'detail':{'tags':[J0(_0x4ad8b2[_0x24f1d7(0x31c)],_0x4ad8b2[_0x24f1d7(0x2a2)])],'summary':k1(_0x8a9373??_0x24f1d7(0x244),_0x52db77)}};if(_0x4ad8b2[_0x24f1d7(0x2a2)]===_0x24f1d7(0x275)&&!_0x3a04e8){if(_0x591fc0[x1]=!0x0,_0x8a9373){let _0xd88e75=XQ(_0x4ad8b2['module'],_0x4ad8b2['prefix'],_0x8a9373);_0x591fc0[_0x24f1d7(0x1ef)]=[v1([_0xd88e75])];}}return _0x591fc0;}});for(let _0x475dbb of _0x4ad8b2[_0x54d9a4(0x2b2)]?.['api']??[]){let _0x5dc7c9=_0x475dbb===_0x54d9a4(0x330)?_0x54d9a4(0x1bd):_0x54d9a4(0x197);_0x1ad3ef[_0x54d9a4(0x279)]({'method':_0x5dc7c9,'path':b(_0x4ad8b2['prefix'],_0x475dbb),'handler':_0x475dbb,'autoCrud':!0x0});}for(let _0x5f4f1c of _0x4ad8b2[_0x54d9a4(0x2b2)]?.[_0x54d9a4(0x16f)]??[])_0x1ad3ef[_0x54d9a4(0x279)]({'method':_0x54d9a4(0x197),'path':b(_0x4ad8b2[_0x54d9a4(0x260)],_0x5f4f1c),'handler':_0x5f4f1c,'autoCrud':!0x0});}return{'plugin':_0x4c7141,'pluginPrefix':_0xc1197f,'autoRoutes':_0x1ad3ef};}function f1(_0x8e709a,_0x4ef2de){const _0xb3ae32=_0x3ec76d;let _0x700a53=_0x8e709a,_0x44718d=0x0,_0x4f0533=[];for(let _0x47e7f3 of O()){let {plugin:_0x6aec1b,pluginPrefix:_0x8425f,autoRoutes:_0x1a56f7}=Z5(_0x47e7f3,_0x4ef2de);_0x700a53=_0x700a53['use'](_0x6aec1b);for(let _0x57b1da of[..._0x47e7f3[_0xb3ae32(0x2eb)],..._0x1a56f7]){_0x44718d+=0x1;let _0x50c7a2=d(_0x57b1da[_0xb3ae32(0x28a)],_0x47e7f3[_0xb3ae32(0x260)]),_0x30e071=_0x50c7a2==='/'?_0x8425f:b(_0x8425f,_0x50c7a2['replace'](/^\//,'')),_0x3de6d1=_0x57b1da[_0xb3ae32(0x1af)]?_0xb3ae32(0x285):_0x57b1da[_0xb3ae32(0x1cd)]?'\x20(crud)':'';_0x4f0533[_0xb3ae32(0x279)](_0x57b1da['method']+'\x20'+_0x30e071+_0x3de6d1);}}if(_0x44718d>0x0){console[_0xb3ae32(0x1c3)](_0xb3ae32(0x20b)+_0x44718d+'\x20route(s)');for(let _0x39217f of _0x4f0533)console['log']('\x20\x20'+_0x39217f);}return _0x700a53;}var {Glob:J5}=globalThis[_0x3ec76d(0x2d0)],X5=/\.tsx?$/;async function X0(_0xa41e8e,_0xc03a96={}){const _0x14a517=_0x3ec76d;let {cwd:_0x4dcf9b=process[_0x14a517(0x317)](),ext:_0x110c6a=X5}=_0xc03a96,_0x20b49f=Array[_0x14a517(0x201)](_0xa41e8e)?_0xa41e8e:[_0xa41e8e],_0x543f0c=[];for(let _0x2038de of _0x20b49f){let _0x233f66=new J5(_0x2038de);for await(let _0x3a9ec8 of _0x233f66[_0x14a517(0x28b)]({'cwd':_0x4dcf9b,'onlyFiles':!0x0}))if(_0x110c6a[_0x14a517(0x327)](_0x3a9ec8))_0x543f0c[_0x14a517(0x279)](_0x3a9ec8);}return[...new Set(_0x543f0c)][_0x14a517(0x2c1)]();}var w1=null;function zQ(_0x52ac49){w1=_0x52ac49;}function b1(){return w1;}function y1(_0x2351ea){const _0x34f310=_0x3ec76d;let _0x24844d=_0x2351ea[_0x34f310(0x172)](/modules\/([^/]+)\/controller\//);if(!_0x24844d)return'unknown';return _0x24844d[0x1];}function g1(_0x4d576d){const _0x4cb622=_0x3ec76d;let _0x296fa8=_0x4d576d['replace'](/\\/g,'/')[_0x4cb622(0x172)](/modules\/([^/]+)\/controller\/(?:admin|app)\/(.+)\.tsx?$/);if(!_0x296fa8)return'';let _0xcc6c7d=_0x296fa8[0x1],_0x3b2b85=_0x296fa8[0x2][_0x4cb622(0x1ce)](/\/+/g,'/')[_0x4cb622(0x1ce)](/^\/|\/$/g,'');if(!_0x3b2b85)return'/'+_0xcc6c7d;return'/'+_0xcc6c7d+'/'+_0x3b2b85;}var V5=/(?:Time|Date|At)$/,W5=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;function h1(_0x5d83b9){const _0xcac2db=_0x3ec76d;let _0x35939c=_0x5d83b9 instanceof Date?_0x5d83b9:new Date(_0x5d83b9);if(Number[_0xcac2db(0x31a)](_0x35939c[_0xcac2db(0x27e)]()))return String(_0x5d83b9);return new Intl[(_0xcac2db(0x19b))](_0xcac2db(0x270),{'timeZone':'Asia/Shanghai','year':_0xcac2db(0x180),'month':_0xcac2db(0x257),'day':_0xcac2db(0x257),'hour':'2-digit','minute':'2-digit','second':'2-digit','hour12':!0x1})[_0xcac2db(0x2b6)](_0x35939c)[_0xcac2db(0x1ce)]('T','\x20');}function z5(_0x2e942a){const _0x58c475=_0x3ec76d;return V5[_0x58c475(0x327)](_0x2e942a);}function u1(_0x43515c){return GQ(_0x43515c);}function GQ(_0x36006d,_0x2ce677){const _0x395fbd=_0x3ec76d;if(_0x36006d==null)return _0x36006d;if(_0x36006d instanceof Date)return h1(_0x36006d);if(typeof _0x36006d===_0x395fbd(0x1b4)&&_0x2ce677&&z5(_0x2ce677)&&W5[_0x395fbd(0x327)](_0x36006d))return h1(_0x36006d);if(Array[_0x395fbd(0x201)](_0x36006d))return _0x36006d[_0x395fbd(0x196)](_0xd6e343=>GQ(_0xd6e343));if(typeof _0x36006d==='object'){if(Object[_0x395fbd(0x1a9)][_0x395fbd(0x1b9)][_0x395fbd(0x170)](_0x36006d)!==_0x395fbd(0x27d))return _0x36006d;let _0x1868f7={};for(let [_0x1ab9d5,_0x5e6fbc]of Object[_0x395fbd(0x1f2)](_0x36006d))_0x1868f7[_0x1ab9d5]=GQ(_0x5e6fbc,_0x1ab9d5);return _0x1868f7;}return _0x36006d;}var C={'SUCCESS':0x3e8,'ERROR':0x3e9};class n{['ok'](_0x4a4817){const _0xfb401d=_0x3ec76d;let _0x125210=_0x4a4817===void 0x0?null:_0x4a4817;return{'code':C[_0xfb401d(0x1fe)],'message':_0xfb401d(0x248),'data':_0x125210==null?_0x125210:u1(_0x125210)};}[_0x3ec76d(0x1f0)](_0x22d060='error',_0x19d27c=C['ERROR']){return{'code':_0x19d27c,'message':_0x22d060};}}import'reflect-metadata';function G5(_0x514c4d){const _0x50ffc3=_0x3ec76d;if(_0x514c4d==null)return{};if(typeof _0x514c4d===_0x50ffc3(0x1b4)||typeof _0x514c4d===_0x50ffc3(0x2d2))return{'id':_0x514c4d};return _0x514c4d;}function FQ(_0x57d11b){return _0x54972b=>{const _0x4381f2=_0x4875;let _0x185fa5=G5(_0x57d11b),_0x2f1471=_0x185fa5[_0x4381f2(0x2fd)]??_0x4381f2(0x2fb);if(f({'token':_0x54972b,'useClass':_0x54972b,'scope':_0x2f1471}),_0x185fa5['id']!=null)f({'token':_0x185fa5['id'],'useClass':_0x54972b,'scope':_0x2f1471});};}function jQ(_0x742464){return(_0x4e1034,_0x2acf04)=>{const _0x1caf88=_0x4875;let _0x8a9ef6=Reflect[_0x1caf88(0x304)](_0x1caf88(0x203),_0x4e1034,_0x2acf04),_0x10998d=_0x742464??_0x8a9ef6;if(_0x10998d==null)throw Error(_0x1caf88(0x2ce)+String(_0x2acf04)+_0x1caf88(0x223));c(_0x4e1034[_0x1caf88(0x1df)],{'propertyKey':_0x2acf04,'token':_0x10998d});};}import{and as _0x17cffb,arrayContains as _0x13bef5,arrayOverlaps as _0x53dd58,asc as _0x36eeed,desc as _0x511368,eq as _0x529ce3,gte as _0x3ffee6,inArray as _0x1804f3,like as _0x1e3910,lte as _0x3c971d,or as _0x5958da,sql as _0x1dded4}from'drizzle-orm';function BQ(_0x1598de){const _0x22d6bb=_0x3ec76d;if(typeof _0x1598de==='string'){let _0x11b327=_0x1598de[_0x22d6bb(0x206)]('.')?_0x1598de[_0x22d6bb(0x2f6)]('.')[_0x22d6bb(0x2ec)]():_0x1598de;return{'column':_0x11b327,'param':_0x11b327,'none':!0x1};}let _0x161d8c=_0x1598de[_0x22d6bb(0x2f0)]['includes']('.')?_0x1598de['column']['split']('.')['pop']():_0x1598de[_0x22d6bb(0x2f0)];return{'column':_0x161d8c,'param':_0x1598de['requestParam']??_0x161d8c,'none':Boolean(_0x1598de[_0x22d6bb(0x184)])};}function U5(_0xab209a){const _0x1902b5=_0x3ec76d;return _0xab209a[_0x1902b5(0x2f0)]['includes']('.')?_0xab209a[_0x1902b5(0x2f0)][_0x1902b5(0x2f6)]('.')[_0x1902b5(0x2ec)]():_0xab209a[_0x1902b5(0x2f0)];}function h(_0x498a67,_0xa332a6){const _0x3047cc=_0x3ec76d;let _0x47f3ac=_0x498a67[_0xa332a6];if(_0x47f3ac==null)throw Error(_0x3047cc(0x335)+_0xa332a6);return _0x47f3ac;}function y(_0xba7945){return _0xba7945===void 0x0||_0xba7945===null||_0xba7945==='';}function MQ(_0x114782){const _0x3ad5ff=_0x3ec76d;if(_0x114782==null||_0x114782===!0x1)return[];return(Array[_0x3ad5ff(0x201)](_0x114782)?_0x114782:[_0x114782])[_0x3ad5ff(0x22f)](_0x20060f=>_0x20060f!=null&&_0x20060f!==!0x1);}var V0={'between'(_0x358078,_0x4a1ef0,_0x2a4aca){if(y(_0x4a1ef0)||y(_0x2a4aca))return;return _0x1dded4`${_0x358078} between ${_0x4a1ef0} and ${_0x2a4aca}`;},'range'(_0x2c1893,_0x17a8b8,_0x5446cf){const _0x342ee3=_0x3ec76d;let _0x39bc41=[];if(!y(_0x17a8b8))_0x39bc41[_0x342ee3(0x279)](_0x3ffee6(_0x2c1893,_0x17a8b8));if(!y(_0x5446cf))_0x39bc41[_0x342ee3(0x279)](_0x3c971d(_0x2c1893,_0x5446cf));if(!_0x39bc41['length'])return;return _0x39bc41['length']===0x1?_0x39bc41[0x0]:_0x17cffb(..._0x39bc41);},'eqRest'(_0xe821ca,_0x4f0756,_0x267b3f){const _0x493935=_0x3ec76d;let _0x342cdd=[];for(let [_0x1ff363,_0x21260c]of Object[_0x493935(0x1f2)](_0xe821ca)){if(y(_0x21260c))continue;let _0x335467=_0x267b3f?.[_0x1ff363]??_0x4f0756[_0x1ff363];if(_0x335467==null)continue;_0x342cdd[_0x493935(0x279)](_0x529ce3(_0x335467,_0x21260c));}return _0x342cdd;},'contains'(_0x1346d8,_0x1f2695){const _0x114f28=_0x3ec76d;if(y(_0x1f2695))return;let _0x37fb0c=Array[_0x114f28(0x201)](_0x1f2695)?_0x1f2695:[_0x1f2695];if(!_0x37fb0c[_0x114f28(0x209)])return;return _0x37fb0c[_0x114f28(0x209)]===0x1?_0x13bef5(_0x1346d8,_0x37fb0c):_0x53dd58(_0x1346d8,_0x37fb0c);}};function D5(_0x300812,_0x27cfff,_0xc1c323){const _0x47db7a=_0x3ec76d;let _0x261af4=[];if(_0xc1c323[_0x47db7a(0x2f8)]?.[_0x47db7a(0x209)]&&!y(_0x27cfff[_0x47db7a(0x27b)])){let _0x1927bc='%'+String(_0x27cfff[_0x47db7a(0x27b)])+'%',_0x46100a=_0xc1c323[_0x47db7a(0x2f8)][_0x47db7a(0x196)](_0x27d868=>{const _0x3904ee=_0x47db7a;let _0x2379a5=_0x27d868[_0x3904ee(0x206)]('.')?_0x27d868[_0x3904ee(0x2f6)]('.')[_0x3904ee(0x2ec)]():_0x27d868;return _0x1e3910(h(_0x300812,_0x2379a5),_0x1927bc);});if(_0x46100a[_0x47db7a(0x209)]===0x1)_0x261af4['push'](_0x46100a[0x0]);else{if(_0x46100a[_0x47db7a(0x209)]>0x1)_0x261af4['push'](_0x5958da(..._0x46100a));}}for(let _0x4bbc41 of _0xc1c323[_0x47db7a(0x267)]??[]){let {column:_0x35e3d8,param:_0x1bbc0f}=BQ(_0x4bbc41),_0x5ae5cf=_0x27cfff[_0x1bbc0f];if(y(_0x5ae5cf))continue;if(Array[_0x47db7a(0x201)](_0x5ae5cf)){if(!_0x5ae5cf[_0x47db7a(0x209)])continue;_0x261af4[_0x47db7a(0x279)](_0x1804f3(h(_0x300812,_0x35e3d8),_0x5ae5cf));}else _0x261af4[_0x47db7a(0x279)](_0x529ce3(h(_0x300812,_0x35e3d8),_0x5ae5cf));}for(let _0x3e4512 of _0xc1c323[_0x47db7a(0x189)]??[]){let {column:_0x3ec3ee,param:_0xaaa731}=BQ(_0x3e4512),_0xa33773=_0x27cfff[_0xaaa731];if(y(_0xa33773))continue;_0x261af4['push'](_0x1e3910(h(_0x300812,_0x3ec3ee),'%'+String(_0xa33773)+'%'));}for(let _0x5ab929 of _0xc1c323['fieldArray']??[]){let {column:_0x4c898a,param:_0x2373a0}=BQ(_0x5ab929),_0x448272=V0[_0x47db7a(0x265)](h(_0x300812,_0x4c898a),_0x27cfff[_0x2373a0]);if(_0x448272)_0x261af4[_0x47db7a(0x279)](_0x448272);}for(let _0x4122f2 of _0xc1c323[_0x47db7a(0x1ec)]??[]){let _0x334dbc=h(_0x300812,U5(_0x4122f2)),_0x561f4f=V0[_0x47db7a(0x2fc)](_0x334dbc,_0x27cfff[_0x4122f2['min']],_0x27cfff[_0x4122f2[_0x47db7a(0x232)]]);if(_0x561f4f)_0x261af4[_0x47db7a(0x279)](_0x561f4f);}return _0x261af4;}function T5(_0x3e5ad3,_0x255839,_0x1cf3c7){const _0x25cde9=_0x3ec76d;let _0x5adac4=[],_0x3f9ef5=_0x255839[_0x25cde9(0x1f8)]!=null?String(_0x255839[_0x25cde9(0x1f8)]):void 0x0,_0x26d1ca=_0x255839[_0x25cde9(0x2c1)]===_0x25cde9(0x25b)||_0x255839[_0x25cde9(0x2c1)]==='desc'?_0x255839['sort']:void 0x0;if(_0x3f9ef5){let _0x584630=h(_0x3e5ad3,_0x3f9ef5);_0x5adac4[_0x25cde9(0x279)](_0x26d1ca===_0x25cde9(0x25b)?_0x36eeed(_0x584630):_0x511368(_0x584630));}else{if(_0x1cf3c7[_0x25cde9(0x32f)])for(let [_0x189ca1,_0x2afe94]of Object[_0x25cde9(0x1f2)](_0x1cf3c7[_0x25cde9(0x32f)])){let _0x47a8ab=_0x189ca1[_0x25cde9(0x206)]('.')?_0x189ca1['split']('.')[_0x25cde9(0x2ec)]():_0x189ca1,_0x2c9a54=h(_0x3e5ad3,_0x47a8ab);_0x5adac4[_0x25cde9(0x279)](_0x2afe94===_0x25cde9(0x25b)?_0x36eeed(_0x2c9a54):_0x511368(_0x2c9a54));}}return _0x5adac4;}function W0(_0x5550de){const _0x5c6826=_0x3ec76d;return!!(_0x5550de?.[_0x5c6826(0x216)]?.['length']||_0x5550de?.[_0x5c6826(0x226)]);}async function l(_0x1dd06d,_0x27721c,_0x2ac998={},_0x24392b){const _0x275057=_0x3ec76d;let _0x5dd960=D5(_0x1dd06d,_0x27721c,_0x2ac998),_0x5cedd7=T5(_0x1dd06d,_0x27721c,_0x2ac998),_0x58a9a1={'body':_0x27721c,'request':_0x24392b??new Request(_0x275057(0x26e))};if(_0x2ac998[_0x275057(0x242)])_0x5dd960[_0x275057(0x279)](...MQ(await _0x2ac998[_0x275057(0x242)](_0x58a9a1)));if(_0x2ac998[_0x275057(0x179)]){let _0x2048cb={'andWhere'(_0x38ffdb){const _0x50a508=_0x275057;if(_0x38ffdb!=null&&_0x38ffdb!==!0x1)_0x5dd960[_0x50a508(0x279)](_0x38ffdb);},'orderBy'(..._0x124107){for(let _0x22c911 of _0x124107)if(_0x22c911!=null)_0x5cedd7['push'](_0x22c911);}};await _0x2ac998[_0x275057(0x179)](_0x2048cb,_0x58a9a1);}return{'where':_0x5dd960['length']===0x0?void 0x0:_0x5dd960[_0x275057(0x209)]===0x1?_0x5dd960[0x0]:_0x17cffb(..._0x5dd960),'orderBySql':_0x5cedd7};}import{and as _0x1f6be5,count as _0x1131e7,countDistinct as _0x5d8966,getTableColumns as _0x3a315e,isNotNull as _0x30503a,isNull as _0x46ac8b,sql as _0x2ce570}from'drizzle-orm';function w0(){const _0x56218=_0x3ec76d;return D['vome']?.[_0x56218(0x2b2)]??{};}function b0(_0x51d35c){const _0x3d4915=_0x3ec76d;return _0x51d35c??w0()[_0x3d4915(0x219)]??_0x3d4915(0x194);}function u(_0x2d8fa8){if(_0x2d8fa8!=null)return _0x2d8fa8;return w0()['softDelete']===!0x0;}class m{['drizzle'];[_0x3ec76d(0x29b)];[_0x3ec76d(0x2f4)];[_0x3ec76d(0x2b9)];constructor(_0x167bb6,_0x1dc928,_0x4a93b2,_0x5403cf){const _0x67a153=_0x3ec76d;this[_0x67a153(0x247)]=_0x167bb6,this[_0x67a153(0x29b)]=_0x1dc928,this[_0x67a153(0x2f4)]=_0x4a93b2,this[_0x67a153(0x2b9)]=_0x5403cf;}}import{and as _0x3ac208,inArray as _0xc5937d,sql as _0x255c7c}from'drizzle-orm';import{and as _0x6a6018,eq as _0x8c3016,sql as _0x25a2d6}from'drizzle-orm';var z0=_0x3ec76d(0x211);function y0(){const _0x2c3866=_0x3ec76d;return D[_0x2c3866(0x18e)]?.[_0x2c3866(0x23b)]===!0x0;}function LQ(_0x2bbdfd){const _0x3f853b=_0x3ec76d;return _0x2bbdfd[_0x3f853b(0x32c)]!=null;}function G0(){const _0x56fc7e=_0x3ec76d;if(!y0())return'off';let _0x5af69e=_[_0x56fc7e(0x307)]();if(_0x5af69e?.[z0])return _0x56fc7e(0x308);if(_0x5af69e?.[_0x56fc7e(0x30c)])return _0x56fc7e(0x27c);let _0x5daaee=_0x5af69e?.[_0x56fc7e(0x32c)],_0x499e89=typeof _0x5daaee===_0x56fc7e(0x268)?_0x5daaee:Number(_0x5daaee);if(!Number[_0x56fc7e(0x2fa)](_0x499e89)||_0x499e89<=0x0)return _0x56fc7e(0x184);return _0x499e89;}function YQ(_0x29e013,_0x33bcc6){const _0x4aa74c=_0x3ec76d;if(!LQ(_0x29e013))return _0x33bcc6;let _0x139cb0=G0();if(_0x139cb0===_0x4aa74c(0x308)||_0x139cb0==='all')return _0x33bcc6;let _0x50c4d2=_0x29e013[_0x4aa74c(0x32c)],_0x4f3913=_0x139cb0==='none'?_0x25a2d6`false`:_0x8c3016(_0x50c4d2,_0x139cb0);if(_0x33bcc6&&_0x4f3913)return _0x6a6018(_0x33bcc6,_0x4f3913);return _0x33bcc6??_0x4f3913;}function UQ(_0x44c582,_0x1e899c){const _0x1dd1d2=_0x3ec76d;if(!LQ(_0x44c582))return _0x1e899c;let _0x3eb045=G0();if(typeof _0x3eb045!==_0x1dd1d2(0x268))return _0x1e899c;if(_0x1e899c[_0x1dd1d2(0x32c)]!=null)return _0x1e899c;return{..._0x1e899c,'tenantId':_0x3eb045};}async function DQ(_0x5d3ffe){let _0x948299=_['get']();if(!_0x948299)return _0x5d3ffe();let _0x506b82=_0x948299[z0];_0x948299[z0]=!0x0;try{return await _0x5d3ffe();}finally{if(_0x506b82===void 0x0)delete _0x948299[z0];else _0x948299[z0]=_0x506b82;}}function TQ(_0x41eec4){const _0x560700=_0x3ec76d;if(!_0x41eec4)return'';return _0x41eec4[_0x560700(0x2ae)]()['toLowerCase']()['replace'](/:\d+$/,'');}var F0=_0x3ec76d(0x2ed);function g0(_0x11c73f){const _0x3cfb3e=_0x3ec76d;return _0x11c73f[_0x3cfb3e(0x2c6)]!=null;}function h0(){const _0xe87ad4=_0x3ec76d;let _0x565c35=_[_0xe87ad4(0x307)]();if(!_0x565c35)return _0xe87ad4(0x308);if(_0x565c35[F0])return'off';if(_0x565c35[_0xe87ad4(0x30c)])return'all';let _0x3e11ff=_0x565c35['dataScope'];if(_0x3e11ff==null||_0x3e11ff==='')return _0xe87ad4(0x308);if(_0x3e11ff===_0xe87ad4(0x27c))return _0xe87ad4(0x27c);if(_0x3e11ff===_0xe87ad4(0x184))return _0xe87ad4(0x184);let _0x206c0e=_0x565c35[_0xe87ad4(0x1ac)],_0x11fb54=Array[_0xe87ad4(0x201)](_0x206c0e)?_0x206c0e[_0xe87ad4(0x196)](_0x3df1df=>Number(_0x3df1df))[_0xe87ad4(0x22f)](_0x280d61=>Number[_0xe87ad4(0x2fa)](_0x280d61)&&_0x280d61>0x0):[];if(!_0x11fb54[_0xe87ad4(0x209)])return'none';return[...new Set(_0x11fb54)];}function u0(_0x1a921a,_0x246db2){const _0x4a1d6c=_0x3ec76d;if(!g0(_0x1a921a))return _0x246db2;let _0x33628d=h0();if(_0x33628d===_0x4a1d6c(0x308)||_0x33628d===_0x4a1d6c(0x27c))return _0x246db2;let _0x5a1dae=_0x1a921a[_0x4a1d6c(0x2c6)],_0xaf4ca5=_0x33628d==='none'?_0x255c7c`false`:_0xc5937d(_0x5a1dae,_0x33628d);if(_0x246db2)return _0x3ac208(_0x246db2,_0xaf4ca5);return _0xaf4ca5;}function q(_0x1fd187,_0x4ec213){return u0(_0x1fd187,YQ(_0x1fd187,_0x4ec213));}async function NQ(_0x1f1ce3){const _0x122442=_0x3ec76d;let _0x25019f=_[_0x122442(0x307)]();if(!_0x25019f)return _0x1f1ce3();let _0x1f2b81=_0x25019f[F0];_0x25019f[F0]=!0x0;try{return await _0x1f1ce3();}finally{if(_0x1f2b81===void 0x0)delete _0x25019f[F0];else _0x25019f[F0]=_0x1f2b81;}}function x5(_0x2b7c73){const _0x12e3f9=_0x3ec76d;return _0x2b7c73[_0x12e3f9(0x177)];}function v5(_0x4c82f2,_0x4d77ea){const _0x8141cf=_0x3ec76d;if(!u(_0x4d77ea?.[_0x8141cf(0x318)]))return;let _0x219685=x5(_0x4c82f2);if(_0x219685==null)return;if(_0x4d77ea?.['onlyTrashed'])return _0x30503a(_0x219685);if(_0x4d77ea?.['withTrashed'])return;return _0x46ac8b(_0x219685);}function k5(_0x52868a,_0x50be26){if(_0x52868a&&_0x50be26)return _0x1f6be5(_0x50be26,_0x52868a);return _0x52868a??_0x50be26;}function i1(_0x2ae798,_0x203b2c,_0x2a3e93){const _0x456c51=_0x3ec76d;let _0x3f9821=_0x2ae798;for(let _0x193cdf of _0x2a3e93[_0x456c51(0x216)]??[]){let _0x20ada7=_0x193cdf['table'],_0xdec685=_0x193cdf['on'](_0x203b2c),_0x223111=_0x193cdf['type']??_0x456c51(0x255);if(_0x223111===_0x456c51(0x18c)||_0x223111===_0x456c51(0x216))_0x3f9821=_0x3f9821['innerJoin'](_0x20ada7,_0xdec685);else _0x3f9821=_0x3f9821['leftJoin'](_0x20ada7,_0xdec685);}return _0x3f9821;}function f5(_0x8cb8c0,_0x58989c){const _0x531ef8=_0x3ec76d;if(_0x58989c[_0x531ef8(0x226)])return _0x58989c['select'];return _0x3a315e(_0x8cb8c0);}function w5(_0x419876,_0x59a23a){let _0x2fb5d6=_0x419876['id'];if(_0x2fb5d6!=null&&_0x59a23a)return _0x5d8966(_0x2fb5d6);if(_0x2fb5d6!=null)return _0x1131e7(_0x2fb5d6);return _0x1131e7(_0x2ce570`*`);}async function j0(_0x9b3219,_0x489a66,_0xeb4d65,_0x28ecb9){const _0x237eec=_0x3ec76d;let _0x547699=await l(_0x9b3219,_0x489a66,_0xeb4d65,_0x28ecb9[_0x237eec(0x243)]),_0x3a6ccd=v5(_0x9b3219,_0x28ecb9[_0x237eec(0x30d)]),_0x11d967=q(_0x9b3219,k5(_0x547699[_0x237eec(0x242)],_0x3a6ccd)),_0x2868e5=f5(_0x9b3219,_0xeb4d65),_0x36a2cc=!!_0xeb4d65[_0x237eec(0x216)]?.[_0x237eec(0x209)],_0x25773c=K[_0x237eec(0x307)](m)[_0x237eec(0x247)],_0x4cf92f=i1(_0x25773c['select'](_0x2868e5)['from'](_0x9b3219),_0x9b3219,_0xeb4d65);if(_0x11d967)_0x4cf92f=_0x4cf92f['where'](_0x11d967);if(_0x547699['orderBySql'][_0x237eec(0x209)])_0x4cf92f=_0x4cf92f['orderBy'](..._0x547699[_0x237eec(0x2d1)]);if(_0x28ecb9[_0x237eec(0x2be)]===_0x237eec(0x240))return await _0x4cf92f;let _0xfda6c0=Math[_0x237eec(0x232)](0x1,Number(_0x489a66['page']??0x1)),_0x5b9e98=Math[_0x237eec(0x220)](0x64,Math['max'](0x1,Number(_0x489a66[_0x237eec(0x2f3)]??0x14))),_0x1877db=(_0xfda6c0-0x1)*_0x5b9e98,_0x569549=await _0x4cf92f[_0x237eec(0x28c)](_0x5b9e98)[_0x237eec(0x345)](_0x1877db),_0x2fa629=i1(_0x25773c[_0x237eec(0x226)]({'value':w5(_0x9b3219,_0x36a2cc)})[_0x237eec(0x1ad)](_0x9b3219),_0x9b3219,_0xeb4d65);if(_0x11d967)_0x2fa629=_0x2fa629[_0x237eec(0x242)](_0x11d967);let _0x11ce75=await _0x2fa629,_0x434e35=Number(_0x11ce75[0x0]?.[_0x237eec(0x20e)]??0x0);return{'list':_0x569549,'pagination':{'page':_0xfda6c0,'size':_0x5b9e98,'total':_0x434e35}};}import{and as _0x55a76c,count as _0x4c58bc,eq as _0x17a63e,inArray as _0x4390cf,isNotNull as _0x2bb8e6,isNull as _0x436fc0}from'drizzle-orm';import{createInsertSchema as _0x109fe6,createSelectSchema as _0x3eb702,createUpdateSchema as _0x3ae575}from'drizzle-zod';function H0(_0x968a82){return{'select':_0x3eb702(_0x968a82),'insert':_0x109fe6(_0x968a82),'update':_0x3ae575(_0x968a82)};}var p5=[_0x3ec76d(0x337),_0x3ec76d(0x261),_0x3ec76d(0x177)];function KQ(_0x25e0c5){const _0x40d6fe=_0x3ec76d;let _0xa17dca=_0x25e0c5&&typeof _0x25e0c5===_0x40d6fe(0x287)&&!Array[_0x40d6fe(0x201)](_0x25e0c5)?{..._0x25e0c5}:{};for(let _0x28b518 of p5)delete _0xa17dca[_0x28b518];for(let [_0x5bf18c,_0x9b2af1]of Object[_0x40d6fe(0x1f2)](_0xa17dca)){if(typeof _0x9b2af1!=='string')continue;if(!/^\d{4}-\d{2}-\d{2}/[_0x40d6fe(0x327)](_0x9b2af1))continue;let _0x36ccf2=new Date(_0x9b2af1);if(!Number[_0x40d6fe(0x31a)](_0x36ccf2[_0x40d6fe(0x27e)]()))_0xa17dca[_0x5bf18c]=_0x36ccf2;}return _0xa17dca;}function _0x4875(_0x47b057,_0x7908e2){_0x47b057=_0x47b057-0x16f;const _0x384a2d=_0x384a();let _0x487580=_0x384a2d[_0x47b057];if(_0x4875['JFpPxu']===undefined){var _0x5c32ca=function(_0x54fbb8){const _0x67080='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x6bb688='',_0x30b6da='';for(let _0x3335e2=0x0,_0xaae206,_0x3fbd09,_0x17cffb=0x0;_0x3fbd09=_0x54fbb8['charAt'](_0x17cffb++);~_0x3fbd09&&(_0xaae206=_0x3335e2%0x4?_0xaae206*0x40+_0x3fbd09:_0x3fbd09,_0x3335e2++%0x4)?_0x6bb688+=String['fromCharCode'](0xff&_0xaae206>>(-0x2*_0x3335e2&0x6)):0x0){_0x3fbd09=_0x67080['indexOf'](_0x3fbd09);}for(let _0x13bef5=0x0,_0x53dd58=_0x6bb688['length'];_0x13bef5<_0x53dd58;_0x13bef5++){_0x30b6da+='%'+('00'+_0x6bb688['charCodeAt'](_0x13bef5)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x30b6da);};_0x4875['VzQYnp']=_0x5c32ca,_0x4875['lILLDu']={},_0x4875['JFpPxu']=!![];}const _0x39d465=_0x384a2d[0x0],_0x5042f2=_0x47b057+_0x39d465,_0x17fd95=_0x4875['lILLDu'][_0x5042f2];return!_0x17fd95?(_0x487580=_0x4875['VzQYnp'](_0x487580),_0x4875['lILLDu'][_0x5042f2]=_0x487580):_0x487580=_0x17fd95,_0x487580;}function d5(_0x4bb5c8){const _0x4be3c4=_0x3ec76d;return!!_0x4bb5c8&&typeof _0x4bb5c8==='object'&&_0x4bb5c8[_0x4be3c4(0x2e1)]!=null;}function x(){const _0x10b7ab=_0x3ec76d;return K[_0x10b7ab(0x307)](m)[_0x10b7ab(0x247)];}function B0(_0x124789){const _0x5310d1=_0x3ec76d;let _0x549275=_0x124789['id'];if(!_0x549275)throw Error(_0x5310d1(0x2a7));return _0x549275;}function r1(_0x2f7653){const _0x37bd46=_0x3ec76d;return _0x2f7653[_0x37bd46(0x177)];}function n5(_0x3a3045,_0x5ded8d){if(_0x3a3045&&_0x5ded8d)return _0x55a76c(_0x5ded8d,_0x3a3045);return _0x3a3045??_0x5ded8d;}function l5(_0xa8f6ca,_0x1a4df6){const _0x170973=_0x3ec76d;if(!u(_0x1a4df6?.[_0x170973(0x318)]))return;let _0x160238=r1(_0xa8f6ca);if(_0x160238==null)return;if(_0x1a4df6?.['onlyTrashed'])return _0x2bb8e6(_0x160238);if(_0x1a4df6?.[_0x170973(0x1eb)])return;return _0x436fc0(_0x160238);}class M0{['table'];[_0x3ec76d(0x2f4)];constructor(_0x23e990,_0xb2eab6){const _0x4a2fe2=_0x3ec76d;this[_0x4a2fe2(0x1f6)]=_0x23e990,this['schema']=_0xb2eab6??H0(_0x23e990);}[_0x3ec76d(0x1a3)](){const _0x11c985=_0x3ec76d;return r1(this[_0x11c985(0x1f6)])!=null;}[_0x3ec76d(0x28f)](_0x316e96,_0x4808ba){const _0x3cc92d=_0x3ec76d;return q(this['table'],n5(_0x316e96,l5(this[_0x3cc92d(0x1f6)],_0x4808ba)));}async[_0x3ec76d(0x2ef)](_0x4a1715,_0x3d8fbd){const _0x4299c4=_0x3ec76d;let _0x28b882=this['scopedWhere'](_0x4a1715,_0x3d8fbd),_0x19c121=x()[_0x4299c4(0x226)]()[_0x4299c4(0x1ad)](this[_0x4299c4(0x1f6)]);if(_0x28b882)_0x19c121=_0x19c121['where'](_0x28b882);if(_0x3d8fbd?.[_0x4299c4(0x298)]?.[_0x4299c4(0x209)])_0x19c121=_0x19c121[_0x4299c4(0x298)](..._0x3d8fbd[_0x4299c4(0x298)]);return await _0x19c121;}async['findOne'](_0x54f5cd,_0x264757){const _0x3b99ff=_0x3ec76d;let [_0x9b90b4]=await this[_0x3b99ff(0x2ef)](_0x54f5cd,_0x264757);return _0x9b90b4;}async[_0x3ec76d(0x33b)](_0x15d295,_0x4081fe){const _0x1640d5=_0x3ec76d;return this[_0x1640d5(0x338)](_0x17a63e(B0(this['table']),_0x15d295),_0x4081fe);}async['count'](_0xaa0183,_0x961b1b){const _0x18e9a9=_0x3ec76d;let _0x323ca3=this[_0x18e9a9(0x28f)](_0xaa0183,_0x961b1b),_0x5dceb4=x()[_0x18e9a9(0x226)]({'value':_0x4c58bc()})[_0x18e9a9(0x1ad)](this[_0x18e9a9(0x1f6)]),_0xf7bb23=_0x323ca3?await _0x5dceb4['where'](_0x323ca3):await _0x5dceb4;return Number(_0xf7bb23[0x0]?.[_0x18e9a9(0x20e)]??0x0);}async[_0x3ec76d(0x305)](_0xbadc42){const _0x4e5f63=_0x3ec76d;let {page:_0x29013f,size:_0x1a48bb,where:_0x4ab789,orderBy:_0x3a0de2,withTrashed:_0x4c63bd,onlyTrashed:_0x5b7890,softDelete:_0x5058da}=_0xbadc42,_0xb0324f={'withTrashed':_0x4c63bd,'onlyTrashed':_0x5b7890,'softDelete':_0x5058da},_0x2e2d3c=this[_0x4e5f63(0x28f)](_0x4ab789,_0xb0324f),_0x2cf242=(_0x29013f-0x1)*_0x1a48bb,_0x3496b2=x()[_0x4e5f63(0x226)]()['from'](this[_0x4e5f63(0x1f6)]);if(_0x2e2d3c)_0x3496b2=_0x3496b2['where'](_0x2e2d3c);if(_0x3a0de2?.[_0x4e5f63(0x209)])_0x3496b2=_0x3496b2['orderBy'](..._0x3a0de2);let _0x49b0aa=await _0x3496b2[_0x4e5f63(0x28c)](_0x1a48bb)[_0x4e5f63(0x345)](_0x2cf242),_0x4f9cde=await this['count'](_0x4ab789,_0xb0324f);return{'list':_0x49b0aa,'pagination':{'page':_0x29013f,'size':_0x1a48bb,'total':_0x4f9cde}};}[_0x3ec76d(0x1aa)](_0x5b944b){const _0x4f6e77=_0x3ec76d;let _0x21441e=UQ(this[_0x4f6e77(0x1f6)],KQ(_0x5b944b));return this[_0x4f6e77(0x2f4)]['insert'][_0x4f6e77(0x2e0)](_0x21441e);}async[_0x3ec76d(0x2d4)](_0x1bd6e7){const _0x5cf7ba=_0x3ec76d;if(Array[_0x5cf7ba(0x201)](_0x1bd6e7)){if(!_0x1bd6e7[_0x5cf7ba(0x209)])return[];let _0xb8f44b=_0x1bd6e7[_0x5cf7ba(0x196)](_0x1b756f=>this[_0x5cf7ba(0x1aa)](_0x1b756f));return await x()[_0x5cf7ba(0x194)](this['table'])[_0x5cf7ba(0x18b)](_0xb8f44b)[_0x5cf7ba(0x1f7)]();}let [_0x21f06c]=await x()[_0x5cf7ba(0x194)](this['table'])[_0x5cf7ba(0x18b)](this[_0x5cf7ba(0x1aa)](_0x1bd6e7))[_0x5cf7ba(0x1f7)]();return _0x21f06c;}async[_0x3ec76d(0x21a)](_0x57d48f){const _0x2ab196=_0x3ec76d;if(Array[_0x2ab196(0x201)](_0x57d48f)){if(!_0x57d48f['length'])return[];let _0x6373a3=_0x57d48f,_0x450ba5=B0(this['table']),_0x3c5098=_0x6373a3[_0x2ab196(0x22f)](_0x751c5a=>_0x751c5a?.['id']!=null&&_0x751c5a['id']!==''),_0x36c429=_0x6373a3[_0x2ab196(0x22f)](_0x35ba93=>_0x35ba93?.['id']==null||_0x35ba93['id']===''),_0x1950fc=new Set();if(_0x3c5098['length']){let _0x22083d=await this[_0x2ab196(0x2ef)](_0x4390cf(_0x450ba5,_0x3c5098['map'](_0x4665dd=>_0x4665dd['id'])));_0x1950fc=new Set(_0x22083d[_0x2ab196(0x196)](_0x17f245=>_0x17f245['id']));}let _0x396d7e=[],_0x451d01=[..._0x36c429];for(let _0x43c7ab of _0x3c5098)if(_0x1950fc[_0x2ab196(0x34b)](_0x43c7ab['id']))_0x396d7e[_0x2ab196(0x279)](_0x43c7ab);else _0x451d01[_0x2ab196(0x279)](_0x43c7ab);let _0x48dfc2=_0x396d7e[_0x2ab196(0x209)]?await this['update'](_0x396d7e):[],_0x12b136=_0x451d01[_0x2ab196(0x209)]?await this[_0x2ab196(0x2d4)](_0x451d01):[];return[...Array[_0x2ab196(0x201)](_0x48dfc2)?_0x48dfc2:_0x48dfc2?[_0x48dfc2]:[],...Array['isArray'](_0x12b136)?_0x12b136:_0x12b136?[_0x12b136]:[]];}let _0x3ed786=_0x57d48f,_0x19415c=_0x3ed786?.['id'];if(_0x19415c!=null&&_0x19415c!==''){let _0x1cfad9=await this[_0x2ab196(0x33b)](_0x19415c);if(_0x1cfad9){let {id:_0x16cb7a,..._0x39b15d}=_0x3ed786;return await this[_0x2ab196(0x2db)](_0x17a63e(B0(this[_0x2ab196(0x1f6)]),_0x19415c),_0x39b15d)??_0x1cfad9;}}return await this[_0x2ab196(0x2d4)](_0x57d48f);}async['update'](_0x5b9a95,_0x2bcd62){const _0x58f07a=_0x3ec76d;if(Array['isArray'](_0x5b9a95))return this[_0x58f07a(0x262)](_0x5b9a95);let _0x34c99b=this['schema'][_0x58f07a(0x2db)][_0x58f07a(0x2e0)](KQ(_0x2bcd62)),_0xfdb08=q(this[_0x58f07a(0x1f6)],_0x5b9a95);if(!_0xfdb08)return;let [_0x2323ce]=await x()[_0x58f07a(0x2db)](this[_0x58f07a(0x1f6)])[_0x58f07a(0x1d8)](_0x34c99b)[_0x58f07a(0x242)](_0xfdb08)[_0x58f07a(0x1f7)]();return _0x2323ce;}async[_0x3ec76d(0x262)](_0x1651a1){const _0x1cc19d=_0x3ec76d;if(!_0x1651a1[_0x1cc19d(0x209)])return[];let _0x45d53f=B0(this[_0x1cc19d(0x1f6)]),_0x5826b4=new Map();for(let _0x67dc7a of _0x1651a1){let _0xbe47de=_0x67dc7a['id'];if(_0xbe47de==null||_0xbe47de==='')throw Error(_0x1cc19d(0x253));let {id:_0x363237,..._0x186c76}=_0x67dc7a,_0x5b74bf=this[_0x1cc19d(0x2f4)][_0x1cc19d(0x2db)][_0x1cc19d(0x2e0)](KQ(_0x186c76)),_0x2a1b24=JSON[_0x1cc19d(0x284)](_0x5b74bf),_0x297ae6=_0x5826b4[_0x1cc19d(0x307)](_0x2a1b24);if(_0x297ae6)_0x297ae6['ids']['push'](_0xbe47de);else _0x5826b4['set'](_0x2a1b24,{'ids':[_0xbe47de],'patch':_0x5b74bf});}let _0x13be30=[];for(let {ids:_0x5b9b75,patch:_0x494a85}of _0x5826b4[_0x1cc19d(0x18b)]()){let _0x297182=q(this[_0x1cc19d(0x1f6)],_0x4390cf(_0x45d53f,_0x5b9b75));if(!_0x297182)continue;let _0x339415=await x()[_0x1cc19d(0x2db)](this['table'])[_0x1cc19d(0x1d8)](_0x494a85)[_0x1cc19d(0x242)](_0x297182)[_0x1cc19d(0x1f7)]();_0x13be30[_0x1cc19d(0x279)](..._0x339415);}return _0x13be30;}[_0x3ec76d(0x204)](_0x5e6dbb){const _0x2eb898=_0x3ec76d;if(d5(_0x5e6dbb))return q(this[_0x2eb898(0x1f6)],_0x5e6dbb);let _0x27eee7=Array[_0x2eb898(0x201)](_0x5e6dbb)?_0x5e6dbb:[_0x5e6dbb];if(!_0x27eee7[_0x2eb898(0x209)])return;return q(this[_0x2eb898(0x1f6)],_0x4390cf(B0(this[_0x2eb898(0x1f6)]),_0x27eee7));}async[_0x3ec76d(0x318)](_0x73dc9c){const _0x16d2c8=_0x3ec76d;if(!this[_0x16d2c8(0x1a3)]())throw Error(_0x16d2c8(0x282));let _0x5508d3=this[_0x16d2c8(0x204)](_0x73dc9c);if(!_0x5508d3)return;await x()[_0x16d2c8(0x2db)](this[_0x16d2c8(0x1f6)])['set']({'deletedAt':new Date()})[_0x16d2c8(0x242)](_0x5508d3);}async[_0x3ec76d(0x19c)](_0x488183){const _0x4d5f58=_0x3ec76d;if(!this[_0x4d5f58(0x1a3)]())throw Error(_0x4d5f58(0x19a));let _0x31e16f=this[_0x4d5f58(0x204)](_0x488183);if(!_0x31e16f)return;await x()[_0x4d5f58(0x2db)](this[_0x4d5f58(0x1f6)])[_0x4d5f58(0x1d8)]({'deletedAt':null})['where'](_0x31e16f);}async[_0x3ec76d(0x183)](_0x1f22fc){const _0x2f185e=_0x3ec76d;let _0x12fcfc=this[_0x2f185e(0x204)](_0x1f22fc);if(!_0x12fcfc)return;await x()[_0x2f185e(0x21b)](this[_0x2f185e(0x1f6)])[_0x2f185e(0x242)](_0x12fcfc);}}var o1=new WeakMap();function i(_0x763497){const _0x354b90=_0x3ec76d;let _0x407294=o1[_0x354b90(0x307)](_0x763497);if(_0x407294)return _0x407294;let _0x107b0c=new M0(_0x763497);return o1['set'](_0x763497,_0x107b0c),_0x107b0c;}function _Q(_0x5b1e8d){return(_0x1dc326,_0x443405)=>{const _0x273d8f=_0x4875;c(_0x1dc326[_0x273d8f(0x1df)],{'propertyKey':_0x443405,'resolve':()=>i(_0x5b1e8d)});};}function i5(_0x186ed4){const _0x2ab16d=_0x3ec76d;return!!_0x186ed4&&typeof _0x186ed4===_0x2ab16d(0x287)&&_0x186ed4[_0x2ab16d(0x2e1)]!=null;}class a{[_0x3ec76d(0x348)];[_0x3ec76d(0x26d)](_0x483579){const _0x589161=_0x3ec76d;if(!this[_0x589161(0x348)])this[_0x589161(0x348)]=_0x483579;}[_0x3ec76d(0x316)](_0x2e5e6c){const _0x229402=_0x3ec76d;this[_0x229402(0x348)]=_0x2e5e6c;}['hasEntity'](){const _0x876ec4=_0x3ec76d;return!!this[_0x876ec4(0x348)];}[_0x3ec76d(0x2de)](){return this['requireEntity']();}['requireEntity'](){const _0x36fc2b=_0x3ec76d;if(!this[_0x36fc2b(0x348)])throw Error(_0x36fc2b(0x2e4));return this[_0x36fc2b(0x348)];}async[_0x3ec76d(0x272)](_0x294642,_0x1734ea){}async['modifyAfter'](_0xb12de1,_0x2ae4b4){}async['add'](_0x258b02,_0xe575c2){const _0x585a3d=_0x3ec76d;let _0x2473e8=b0(_0xe575c2?.['upsert']),_0x57e4af=Array[_0x585a3d(0x201)](_0x258b02)?_0x258b02[_0x585a3d(0x196)](_0x317eae=>_0x317eae!=null&&typeof _0x317eae===_0x585a3d(0x287)?{..._0x317eae}:_0x317eae):_0x258b02!=null&&typeof _0x258b02==='object'?{..._0x258b02}:_0x258b02;await this[_0x585a3d(0x272)](_0x57e4af,_0x585a3d(0x2f2));let _0x3c8b1b=_0x2473e8===_0x585a3d(0x21a)?await this['requireEntity']()[_0x585a3d(0x21a)](_0x57e4af):await this['requireEntity']()['create'](_0x57e4af);return await this[_0x585a3d(0x222)](_0x3c8b1b??_0x57e4af,_0x585a3d(0x2f2)),_0x3c8b1b;}async[_0x3ec76d(0x2db)](_0x1b0841,_0x141dd0){const _0x34e430=_0x3ec76d;if(Array['isArray'](_0x1b0841)){let _0x51b6bb=_0x1b0841[_0x34e430(0x196)](_0x59164f=>({..._0x59164f}));await this[_0x34e430(0x272)](_0x51b6bb,_0x34e430(0x2db));let _0x4faed5=await this[_0x34e430(0x2b5)]()[_0x34e430(0x2db)](_0x51b6bb);return await this[_0x34e430(0x222)](_0x4faed5??_0x51b6bb,_0x34e430(0x2db)),_0x4faed5;}if(i5(_0x1b0841)){let _0x31d366=_0x141dd0!=null&&typeof _0x141dd0===_0x34e430(0x287)?{..._0x141dd0}:_0x141dd0;await this[_0x34e430(0x272)](_0x31d366,_0x34e430(0x2db));let _0x30b74c=await this[_0x34e430(0x2b5)]()[_0x34e430(0x2db)](_0x1b0841,_0x31d366);return await this['modifyAfter'](_0x30b74c??_0x31d366,'update'),_0x30b74c;}let _0x328fba={..._0x1b0841};await this['modifyBefore'](_0x328fba,'update');let _0x445b12=await this['requireEntity']()[_0x34e430(0x2db)]([_0x328fba]);return await this[_0x34e430(0x222)](_0x445b12??_0x328fba,_0x34e430(0x2db)),Array[_0x34e430(0x201)](_0x445b12)?_0x445b12[0x0]:_0x445b12;}async[_0x3ec76d(0x21b)](_0x5e0044,_0x19ff07){const _0x390453=_0x3ec76d;let _0x3fffa2=this[_0x390453(0x2b5)]();await this[_0x390453(0x272)](_0x5e0044,_0x390453(0x21b));let _0x2aacf6=u(_0x19ff07?.[_0x390453(0x318)]);if(_0x19ff07?.[_0x390453(0x319)]||!_0x2aacf6||!_0x3fffa2[_0x390453(0x1a3)]())await _0x3fffa2['forceDelete'](_0x5e0044);else await _0x3fffa2['softDelete'](_0x5e0044);await this['modifyAfter'](_0x5e0044,_0x390453(0x21b));}[_0x3ec76d(0x19c)](_0x2e7123){return this['requireEntity']()['restore'](_0x2e7123);}[_0x3ec76d(0x240)](_0x2cfce9,_0x1b1f2b){const _0x6706be=_0x3ec76d;return this[_0x6706be(0x2b5)]()[_0x6706be(0x2ef)](_0x2cfce9,_0x1b1f2b);}[_0x3ec76d(0x330)](_0x21b354,_0x122f01){const _0x249dd2=_0x3ec76d;let _0x2554a8=this['requireEntity']();if(typeof _0x21b354==='object')return _0x2554a8[_0x249dd2(0x338)](_0x21b354,_0x122f01);return _0x2554a8['findById'](_0x21b354,_0x122f01);}[_0x3ec76d(0x29a)](_0x2a44fd={}){const _0x360d8a=_0x3ec76d;let _0x4e72ee=Math[_0x360d8a(0x232)](0x1,_0x2a44fd[_0x360d8a(0x29a)]??0x1),_0x216ddd=Math[_0x360d8a(0x220)](0x64,Math['max'](0x1,_0x2a44fd[_0x360d8a(0x2f3)]??0x14));return this[_0x360d8a(0x2b5)]()[_0x360d8a(0x305)]({'page':_0x4e72ee,'size':_0x216ddd,'where':_0x2a44fd[_0x360d8a(0x242)],'orderBy':_0x2a44fd['orderBy'],'withTrashed':_0x2a44fd[_0x360d8a(0x1eb)],'onlyTrashed':_0x2a44fd['onlyTrashed'],'softDelete':_0x2a44fd['softDelete']});}}var m0={'add':'\u65B0\u589E','delete':'\u5220\u9664','update':'\u4FEE\u6539','info':_0x3ec76d(0x2bc),'list':_0x3ec76d(0x2f1),'page':_0x3ec76d(0x229),'restore':'\u6062\u590D'},s5=[_0x3ec76d(0x2f2),_0x3ec76d(0x21b),_0x3ec76d(0x2db),_0x3ec76d(0x330),_0x3ec76d(0x240),'page','restore'],CQ=new Set([_0x3ec76d(0x2f2),_0x3ec76d(0x2db),_0x3ec76d(0x21b),_0x3ec76d(0x19c)]);function o5(_0x1e2ad6,_0x4ec1ad){const _0x5cbbe8=_0x3ec76d;if(!_0x1e2ad6||!_0x4ec1ad?.[_0x5cbbe8(0x209)])return _0x1e2ad6;let _0x3aaaf8={..._0x1e2ad6};for(let _0x250a52 of _0x4ec1ad)delete _0x3aaaf8[_0x250a52];return _0x3aaaf8;}function a1(_0xbe77c9){const _0x2bb8f4=_0x3ec76d;if(Array[_0x2bb8f4(0x201)](_0xbe77c9))return _0xbe77c9[_0x2bb8f4(0x196)](_0x38cd46=>{const _0x1fcaa7=_0x2bb8f4;if(_0x38cd46!=null&&typeof _0x38cd46===_0x1fcaa7(0x287)&&'id'in _0x38cd46)return _0x38cd46['id'];return _0x38cd46;});if(_0xbe77c9&&typeof _0xbe77c9===_0x2bb8f4(0x287)){let _0x527196=_0xbe77c9;if(Array['isArray'](_0x527196[_0x2bb8f4(0x245)]))return _0x527196['ids'];if(_0x527196['id']!=null)return[_0x527196['id']];}return[];}function r5(_0x4bea3a){const _0x67eff2=_0x3ec76d;let _0x4f5aa1=_0x4bea3a[_0x67eff2(0x2b2)],_0x59e4e2=_0x4f5aa1[_0x67eff2(0x348)];if(_0x4f5aa1[_0x67eff2(0x31f)]){let _0x449e7c=K['get'](_0x4f5aa1[_0x67eff2(0x31f)]);if(_0x59e4e2&&!_0x449e7c[_0x67eff2(0x310)]())_0x449e7c[_0x67eff2(0x316)](i(_0x59e4e2));return _0x449e7c;}if(!_0x59e4e2)throw Error('[CRUD]\x20'+_0x4bea3a[_0x67eff2(0x1c9)]['name']+_0x67eff2(0x246));let _0x14460c=new class extends a{}();return _0x14460c[_0x67eff2(0x316)](i(_0x59e4e2)),_0x14460c;}function a5(_0x2b10ed,_0x3f5eb8){const _0x2cbf54=_0x3ec76d;let _0xda0b0e=_0x3f5eb8[_0x2cbf54(0x2b2)]?.['entity'];if(_0xda0b0e)return _0xda0b0e;return _0x2b10ed['getRepo']()[_0x2cbf54(0x1f6)];}var L0=(_0x33fef3,_0xd81bda,_0x54743e)=>{const _0x1a0186=_0x3ec76d;let _0x3566f0=_0xd81bda[_0x1a0186(0x2b2)];if(!_0x3566f0)return _0x33fef3;let _0x42a707=(_0x3566f0[_0x1a0186(0x328)]??[])['filter'](_0x1cdf03=>s5[_0x1a0186(0x206)](_0x1cdf03)),_0x5ce613=_0x3566f0[_0x1a0186(0x16f)]??[];if(!_0x42a707[_0x1a0186(0x209)]&&!_0x5ce613[_0x1a0186(0x209)])return _0x33fef3;let _0x237e0f=_0x54743e[_0x1a0186(0x2a0)]instanceof n?_0x54743e[_0x1a0186(0x2a0)]:new n(),_0x57d36d=_0x42a707[_0x1a0186(0x209)]>0x0,_0x58bcdd=_0x57d36d||_0x3566f0['service']?r5(_0xd81bda):void 0x0,_0x56e4d8=_0x57d36d&&_0x58bcdd?a5(_0x58bcdd,_0xd81bda):void 0x0,_0x55e0d9=_0x56e4d8?_0x56e4d8['id']:void 0x0;if(_0x57d36d&&_0x55e0d9==null)throw Error('[CRUD]\x20'+_0xd81bda['token']['name']+'\x20表无\x20id\x20列');let _0x4af508=_0x33fef3,_0x4d951d=(_0x11a3aa,_0x27a12c,_0x5d51aa,_0x1aed26)=>{_0x4af508=_0x4af508[_0x11a3aa](_0x27a12c,_0x1aed26,_0x54743e['routeOptions']({'action':_0x5d51aa,'summary':m0[_0x5d51aa]}));},_0x1d7361=async(_0x50bf0a,_0x25836c,_0x464b12)=>{const _0x4cf0d1=_0x1a0186;if(!_0x3566f0[_0x4cf0d1(0x323)]||!CQ[_0x4cf0d1(0x34b)](_0x50bf0a))return _0x25836c;return await _0x3566f0[_0x4cf0d1(0x323)]({'body':_0x25836c,'request':_0x464b12,'api':_0x50bf0a}),_0x25836c;};if(_0x42a707[_0x1a0186(0x206)](_0x1a0186(0x2f2))&&_0x58bcdd)_0x4d951d(_0x1a0186(0x1f3),_0x1a0186(0x1c7),'add',async({body:_0x705793,request:_0x48eea2})=>{const _0x80565f=_0x1a0186;try{let _0xa0ba29=_0x705793;if(Array[_0x80565f(0x201)](_0xa0ba29)){let _0xde5058=_0xa0ba29;if(_0x3566f0[_0x80565f(0x323)]&&CQ['has']('add')){for(let _0x44e4b8=0x0;_0x44e4b8<_0xde5058['length'];_0x44e4b8++)_0xde5058[_0x44e4b8]=await _0x1d7361(_0x80565f(0x2f2),{..._0xde5058[_0x44e4b8]??{}},_0x48eea2);}if(_0x3566f0[_0x80565f(0x202)]){let _0x3b7bf4=await _0x3566f0[_0x80565f(0x202)]({'body':_0xde5058[0x0]??{},'request':_0x48eea2});_0xde5058=_0xde5058['map'](_0x1d5a5b=>({..._0x1d5a5b,..._0x3b7bf4}));}let _0x37fe07=await _0x58bcdd[_0x80565f(0x2f2)](_0xde5058);return _0x237e0f['ok'](_0x37fe07);}let _0xc938f0={..._0xa0ba29??{}};if(_0xc938f0=await _0x1d7361(_0x80565f(0x2f2),_0xc938f0,_0x48eea2),_0x3566f0[_0x80565f(0x202)])Object[_0x80565f(0x2f7)](_0xc938f0,await _0x3566f0[_0x80565f(0x202)]({'body':_0xc938f0,'request':_0x48eea2}));let _0x38d8f5=await _0x58bcdd[_0x80565f(0x2f2)](_0xc938f0);return _0x237e0f['ok'](_0x38d8f5);}catch(_0x2590f3){return _0x237e0f[_0x80565f(0x1f0)](_0x2590f3 instanceof Error?_0x2590f3[_0x80565f(0x1a5)]:_0x80565f(0x2e3));}});if(_0x42a707[_0x1a0186(0x206)](_0x1a0186(0x21b))&&_0x58bcdd&&_0x55e0d9)_0x4d951d('post','/delete',_0x1a0186(0x21b),async({body:_0x4bfd36,request:_0x409b2e})=>{const _0x2d9d28=_0x1a0186;try{let _0x357c55=_0x4bfd36,_0x3bb34c=Array[_0x2d9d28(0x201)](_0x357c55)?_0x357c55:await _0x1d7361(_0x2d9d28(0x21b),{..._0x357c55??{}},_0x409b2e),_0x3e01bc=a1(_0x3bb34c);if(!_0x3e01bc[_0x2d9d28(0x209)])return _0x237e0f[_0x2d9d28(0x1f0)](_0x2d9d28(0x199));let _0x398317=!Array[_0x2d9d28(0x201)](_0x3bb34c)&&!!_0x3bb34c[_0x2d9d28(0x319)];return await _0x58bcdd[_0x2d9d28(0x21b)](_0x3e01bc,{'force':_0x398317}),_0x237e0f['ok']();}catch(_0x3d1889){return _0x237e0f[_0x2d9d28(0x1f0)](_0x3d1889 instanceof Error?_0x3d1889[_0x2d9d28(0x1a5)]:_0x2d9d28(0x2c2));}});if(_0x42a707['includes'](_0x1a0186(0x2db))&&_0x58bcdd&&_0x55e0d9)_0x4d951d(_0x1a0186(0x1f3),_0x1a0186(0x2c4),_0x1a0186(0x2db),async({body:_0xb0ebba,request:_0x1b0cc2})=>{const _0x4ede9d=_0x1a0186;try{let _0x59502b=_0xb0ebba;if(Array[_0x4ede9d(0x201)](_0x59502b)){let _0x2e910d=_0x59502b;if(_0x3566f0[_0x4ede9d(0x323)]&&CQ[_0x4ede9d(0x34b)](_0x4ede9d(0x2db))){for(let _0x4294e0=0x0;_0x4294e0<_0x2e910d[_0x4ede9d(0x209)];_0x4294e0++)_0x2e910d[_0x4294e0]=await _0x1d7361(_0x4ede9d(0x2db),{..._0x2e910d[_0x4294e0]??{}},_0x1b0cc2);}let _0xf24a8f=await _0x58bcdd[_0x4ede9d(0x2db)](_0x2e910d);return _0x237e0f['ok'](_0xf24a8f);}let _0x96f204=await _0x1d7361(_0x4ede9d(0x2db),{..._0x59502b??{}},_0x1b0cc2);if(_0x96f204['id']==null)return _0x237e0f[_0x4ede9d(0x1f0)](_0x4ede9d(0x1a1));let _0x4e2780=await _0x58bcdd[_0x4ede9d(0x2db)](_0x96f204);return _0x237e0f['ok'](_0x4e2780);}catch(_0x3895bd){return _0x237e0f[_0x4ede9d(0x1f0)](_0x3895bd instanceof Error?_0x3895bd[_0x4ede9d(0x1a5)]:_0x4ede9d(0x17c));}});if(_0x42a707[_0x1a0186(0x206)]('info')&&_0x58bcdd)_0x4d951d('get','/info',_0x1a0186(0x330),async({query:_0x21c9b0})=>{const _0x52728b=_0x1a0186;try{let _0xc7ea9a=_0x21c9b0?.['id'];if(_0xc7ea9a==null||_0xc7ea9a==='')return _0x237e0f['fail'](_0x52728b(0x1a1));let _0x4b66ad=await _0x58bcdd[_0x52728b(0x330)](_0xc7ea9a);return _0x237e0f['ok'](o5(_0x4b66ad,_0x3566f0[_0x52728b(0x2e6)]));}catch(_0x1e9855){return _0x237e0f[_0x52728b(0x1f0)](_0x1e9855 instanceof Error?_0x1e9855[_0x52728b(0x1a5)]:_0x52728b(0x22d));}});if(_0x42a707[_0x1a0186(0x206)](_0x1a0186(0x240))&&_0x58bcdd&&_0x56e4d8)_0x4d951d('post',_0x1a0186(0x324),_0x1a0186(0x240),async({body:_0x53e7e7,request:_0x4254bc})=>{const _0x21b268=_0x1a0186;try{let _0x254949=_0x53e7e7??{},_0x58b8af=_0x3566f0[_0x21b268(0x297)]??{},_0x3d8f43={'onlyTrashed':_0x254949[_0x21b268(0x344)]===!0x0,'withTrashed':_0x254949[_0x21b268(0x1eb)]===!0x0};if(W0(_0x58b8af)){let _0x2d4558=await j0(_0x56e4d8,_0x254949,_0x58b8af,{'request':_0x4254bc,'mode':_0x21b268(0x240),'trash':_0x3d8f43});return _0x237e0f['ok'](_0x2d4558);}let {where:_0x13ec90,orderBySql:_0x41cf09}=await l(_0x56e4d8,_0x254949,_0x58b8af,_0x4254bc),_0x57a41b=await _0x58bcdd[_0x21b268(0x240)](_0x13ec90,{'orderBy':_0x41cf09,..._0x3d8f43});return _0x237e0f['ok'](_0x57a41b);}catch(_0x33742d){return _0x237e0f[_0x21b268(0x1f0)](_0x33742d instanceof Error?_0x33742d['message']:_0x21b268(0x212));}});if(_0x42a707['includes'](_0x1a0186(0x29a))&&_0x58bcdd&&_0x56e4d8)_0x4d951d(_0x1a0186(0x1f3),_0x1a0186(0x306),'page',async({body:_0x33531d,request:_0x22c121})=>{const _0x5adf89=_0x1a0186;try{let _0x1ccff1=_0x33531d??{},_0x3d48d2=_0x3566f0[_0x5adf89(0x1ae)]??{},_0x256632={'onlyTrashed':_0x1ccff1[_0x5adf89(0x344)]===!0x0,'withTrashed':_0x1ccff1[_0x5adf89(0x1eb)]===!0x0};if(W0(_0x3d48d2)){let _0x591e45=await j0(_0x56e4d8,_0x1ccff1,_0x3d48d2,{'request':_0x22c121,'mode':_0x5adf89(0x29a),'trash':_0x256632});return _0x237e0f['ok'](_0x591e45);}let {where:_0x370347,orderBySql:_0x4ebfb9}=await l(_0x56e4d8,_0x1ccff1,_0x3d48d2,_0x22c121),_0x587df0=await _0x58bcdd['page']({'page':Number(_0x1ccff1[_0x5adf89(0x29a)]??0x1),'size':Number(_0x1ccff1[_0x5adf89(0x2f3)]??0x14),'where':_0x370347,'orderBy':_0x4ebfb9,..._0x256632});return _0x237e0f['ok'](_0x587df0);}catch(_0x12f54c){return _0x237e0f[_0x5adf89(0x1f0)](_0x12f54c instanceof Error?_0x12f54c[_0x5adf89(0x1a5)]:_0x5adf89(0x2aa));}});if(_0x42a707['includes'](_0x1a0186(0x19c))&&_0x58bcdd&&_0x55e0d9)_0x4d951d(_0x1a0186(0x1f3),_0x1a0186(0x1c5),_0x1a0186(0x19c),async({body:_0x52beb8,request:_0x518a76})=>{const _0x25d628=_0x1a0186;try{let _0x41f1ce=_0x52beb8,_0x25e1fd=Array[_0x25d628(0x201)](_0x41f1ce)?_0x41f1ce:await _0x1d7361(_0x25d628(0x19c),{..._0x41f1ce??{}},_0x518a76),_0x1edbb2=a1(_0x25e1fd);if(!_0x1edbb2[_0x25d628(0x209)])return _0x237e0f['fail']('ids\x20required');return await _0x58bcdd['restore'](_0x1edbb2),_0x237e0f['ok']();}catch(_0x53f063){return _0x237e0f['fail'](_0x53f063 instanceof Error?_0x53f063[_0x25d628(0x1a5)]:'restore\x20failed');}});if(_0x5ce613[_0x1a0186(0x209)]){if(!_0x3566f0[_0x1a0186(0x31f)])throw Error(_0x1a0186(0x24f)+_0xd81bda['token']['name']+'\x20配置了\x20serviceApis,需同时配置\x20service');let _0x1c86f3=K['get'](_0x3566f0[_0x1a0186(0x31f)]);for(let _0x4610c8 of _0x5ce613){let _0x570949=_0x1c86f3[_0x4610c8];if(typeof _0x570949!=='function')throw Error(_0x1a0186(0x24f)+_0x3566f0[_0x1a0186(0x31f)][_0x1a0186(0x254)]+'.'+_0x4610c8+_0x1a0186(0x2e8));let _0x30f272=_0x570949[_0x1a0186(0x340)](_0x1c86f3);_0x4d951d('post','/'+_0x4610c8,_0x4610c8,async({body:_0x215934})=>{const _0x37d660=_0x1a0186;try{let _0x48abdb=await _0x30f272(_0x215934);return _0x237e0f['ok'](_0x48abdb);}catch(_0x2dcde5){return _0x237e0f[_0x37d660(0x1f0)](_0x2dcde5 instanceof Error?_0x2dcde5['message']:_0x4610c8+_0x37d660(0x2a9));}});}}return _0x4af508;};import{join as _0x28e0f3}from'path';import{pathToFileURL as _0xd2ce5e}from'url';var t5=_0x3ec76d(0x187),e5=[{'pattern':'**/modules/*/controller/admin/**/*.ts','side':_0x3ec76d(0x275)},{'pattern':'**/modules/*/controller/app/**/*.ts','side':'app'}];async function Q4(_0x5e198b,_0x33ff79,_0x3fc3b5){const _0x2904a5=_0x3ec76d;zQ({'module':y1(_0x33ff79),'side':_0x3fc3b5,'file':_0x33ff79});try{await import(_0xd2ce5e(_0x28e0f3(_0x5e198b,_0x33ff79))[_0x2904a5(0x29e)]);}finally{zQ(null);}}async function HQ(){const _0x418591=_0x3ec76d;let _0x51a8bb=process['cwd'](),_0x1d8a1d=await X0(t5,{'cwd':_0x51a8bb});for(let _0xa0e1b4 of _0x1d8a1d)await import(_0xd2ce5e(_0x28e0f3(_0x51a8bb,_0xa0e1b4))[_0x418591(0x29e)]);let _0x3956cd=0x0;for(let {pattern:_0x468434,side:_0x20ab9a}of e5){let _0x5eb30a=await X0(_0x468434,{'cwd':_0x51a8bb});_0x3956cd+=_0x5eb30a[_0x418591(0x209)];for(let _0x170860 of _0x5eb30a)await Q4(_0x51a8bb,_0x170860,_0x20ab9a);}f0(L0),console[_0x418591(0x1c3)](_0x418591(0x2c3)),console[_0x418591(0x1c3)](_0x418591(0x289)+_0x1d8a1d[_0x418591(0x209)]+'\x20service,\x20'+_0x3956cd+_0x418591(0x1f1));}import{join as _0xfc633d}from'path';import{createPinoLogger as _0x10a98d}from'@bogeychan/elysia-logger';import _0x2e192a from'pino-pretty';import{createWriteStream as _0x3a1443,mkdirSync as _0x9b4742,readdirSync as _0x4385a0,unlinkSync as _0x2d6148}from'fs';import{join as _0x1c0222}from'path';import{Writable as _0x496e71}from'stream';var W4=/^(\d{4}-\d{2}-\d{2})\.log$/;function IQ(_0x1ede39=new Date()){const _0x254bb1=_0x3ec76d;let _0x4dbb49=_0x1ede39[_0x254bb1(0x2e9)](),_0x2110f9=String(_0x1ede39['getMonth']()+0x1)['padStart'](0x2,'0'),_0x26d734=String(_0x1ede39[_0x254bb1(0x20a)]())[_0x254bb1(0x273)](0x2,'0');return _0x4dbb49+'-'+_0x2110f9+'-'+_0x26d734;}function Q3(_0x34e262,_0x2e54a5){const _0x570fe5=_0x3ec76d;let _0x2fdfe5=new Date();_0x2fdfe5[_0x570fe5(0x2d8)](_0x2fdfe5[_0x570fe5(0x20a)]()-_0x2e54a5);let _0x52e61a=IQ(_0x2fdfe5);for(let _0x2bae0b of _0x4385a0(_0x34e262)){let _0x3ec18d=_0x2bae0b[_0x570fe5(0x172)](W4);if(!_0x3ec18d||_0x3ec18d[0x1]>=_0x52e61a)continue;_0x2d6148(_0x1c0222(_0x34e262,_0x2bae0b));}}function $3(_0x35da5c,_0x2c4209){const _0x16a2c0=_0x3ec76d;return _0x3a1443(_0x1c0222(_0x35da5c,_0x2c4209+_0x16a2c0(0x1d5)),{'flags':'a'});}function J3(_0x5981c3,_0x201290=0x1e){_0x9b4742(_0x5981c3,{'recursive':!0x0}),Q3(_0x5981c3,_0x201290);let _0x3fa047=IQ(),_0x4ca6a2=$3(_0x5981c3,_0x3fa047);return new _0x496e71({'write'(_0x3ad630,_0x3a756a,_0x101b57){let _0x2f259d=IQ();if(_0x2f259d!==_0x3fa047)_0x4ca6a2['end'](),_0x3fa047=_0x2f259d,_0x4ca6a2=$3(_0x5981c3,_0x3fa047),Q3(_0x5981c3,_0x201290);_0x4ca6a2['write'](_0x3ad630,_0x101b57);},'final'(_0x25c4c2){const _0x1e32c3=_0x4875;_0x4ca6a2[_0x1e32c3(0x302)](_0x25c4c2);}});}var c0;function F4(){const _0x57e256=_0x3ec76d;let _0x219287=D[_0x57e256(0x22c)]??{},_0x321455=_0x219287['level']??_0x57e256(0x330);if(_0x219287[_0x57e256(0x1e5)]==='file'){let _0x517a03=_0xfc633d(process[_0x57e256(0x317)](),_0x219287[_0x57e256(0x32d)]??'logging'),_0x1c9d41=_0x219287['maxDays']??0x1e;return _0x10a98d({'level':_0x321455,'stream':J3(_0x517a03,_0x1c9d41)});}return _0x10a98d({'level':_0x321455,'stream':_0x2e192a({'colorize':!0x0,'translateTime':_0x57e256(0x1e0),'ignore':_0x57e256(0x1d7)})});}function R(){if(!c0)c0=F4();return c0;}function RQ(){c0=void 0x0;}class s{[_0x3ec76d(0x330)](_0x12a28a,..._0x2d1e7b){const _0x1da441=_0x3ec76d;let _0x11d853=R();if(_0x2d1e7b[_0x1da441(0x209)])_0x11d853['info']({'args':_0x2d1e7b},_0x12a28a);else _0x11d853['info'](_0x12a28a);}[_0x3ec76d(0x291)](_0x8b10c7,..._0x426f3b){const _0x19afc7=_0x3ec76d;let _0x4c010e=R();if(_0x426f3b['length'])_0x4c010e[_0x19afc7(0x291)]({'args':_0x426f3b},_0x8b10c7);else _0x4c010e[_0x19afc7(0x291)](_0x8b10c7);}['debug'](_0x29816c,..._0x4f98d9){const _0x290423=_0x3ec76d;let _0x3bd342=R();if(_0x4f98d9[_0x290423(0x209)])_0x3bd342[_0x290423(0x1c2)]({'args':_0x4f98d9},_0x29816c);else _0x3bd342[_0x290423(0x1c2)](_0x29816c);}[_0x3ec76d(0x1b8)](_0x576578,..._0x37100b){const _0xd04249=_0x3ec76d;let _0x3ccd6c=R();if(_0x576578 instanceof Error){_0x3ccd6c['error'](_0x576578);return;}if(_0x37100b[0x0]instanceof Error){_0x3ccd6c['error'](_0x37100b[0x0],_0x576578);return;}if(_0x37100b[_0xd04249(0x209)])_0x3ccd6c[_0xd04249(0x1b8)]({'args':_0x37100b},_0x576578);else _0x3ccd6c[_0xd04249(0x1b8)](_0x576578);}}class Y0 extends Error{[_0x3ec76d(0x2da)];[_0x3ec76d(0x2cc)];constructor(_0x4981c3,_0x36529c){const _0x5124b2=_0x3ec76d;super(_0x4981c3),(this[_0x5124b2(0x254)]=_0x5124b2(0x188),this[_0x5124b2(0x2da)]=_0x36529c?.[_0x5124b2(0x2da)]??0xc8,this[_0x5124b2(0x2cc)]=_0x36529c?.[_0x5124b2(0x2cc)]??C[_0x5124b2(0x19f)]);}}function U0(_0x454102){return _0x454102 instanceof Y0;}function qQ(){R(),K['set'](s,new s());}function _0x384a(){const _0x32f8b9=['D2L0AfrYyxnOzwq','zMLLBgrsyw5Nzq','tK9ux0zpvu5e','pJ0WlJmWlJa','yMvMB3jLsgfUzgXL','zMfPBa','ignVBNrYB2XSzxiGzMLSzsHZkq','zw50CMLLCW','Cg9ZDa','y29SDw1UvhLWzq','5QIH5z2xia','DgfIBgu','CMv0DxjUAw5N','B3jKzxi','CgX1z2LUsw5MBW','w0LVy10G','mJC3mZK2vKTjvLPN','8j+tMIbbueNMLOFMOAm6ia','A2v5CW','u1vdq0vtuW','zxHWB3j0CW','Chv0','AxnbCNjHEq','Aw5Zzxj0ugfYyw0','zgvZAwDUoNr5Cgu','CMvZB2X2zuLKv2HLCMu','AgvHzgvYCW','Aw5JBhvKzxm','y2yTy29UBMvJDgLUzY1PCa','y3r4','BgvUz3rO','z2v0rgf0zq','w1jVDxrLCL0GCMvNAxn0zxjLzcdIHPaG','Agv4','CxvLCNK','DMfSDwu','yxbWBgLJyxrPB24VANnVBJSGy2HHCNnLDd11DgyToa','zMLSzq','x19ZA2LWvgvUyw50','BgLZDcbMywLSzwq','lMPZ','mJi0mtCWvxbUsxPX','BwfJCM8','AM9PBG','B3bLCMf0Aw9UvgL0BgvtB3vYy2u','zgvMyxvSDe5VDW','DxbZzxj0','C2f2zq','zgvSzxrL','DxnL','zM9UDc93B2zM','C3jJl21PzgrSzxDHCMuVAw5KzxGUDhm','pJ0YlJaUma','BwLU','zgf0yq','Bw9KAwz5qwz0zxi','ioEAHoEXU+wEI++8JoIVT+AyVUw8J+s8OowfPsb0B2TLBG','mZzUywrKs3K','yxbWBgLJyxrPB24VB2n0zxqTC3rYzwfT','C2vSzwn0','DgfIBgvFBMfTzq','DgfNCW','5yIg6Ag15P+L6k+I','C3jJl2nVBMzPzW','AwDUB3jLugvYBxm','Bg9Nz2LUzW','Aw5MBYbMywLSzwq','zNvUy3rPB24','zMLSDgvY','w01VzhvSzv0GBg9HzgvKia','C2XPy2u','Bwf4','cMLMicH0ExbLB2yGAgfUzgXLCNmGpt09icD1BMrLzMLUzwqNksbYzxr1CM4GBNvSBdSkCMv0DxjUigHHBMrSzxjZoW','lNbUzW','A2v5','pJ0ZlJuUma','zgv2','ioMfJEE9RUs6HIbHCgKVC2vYDMLJzufWAxpVViZKVyBMNkRMIB7LIlaGq1jvrcdLRP7NJRdVViHaDM9Tzs1JB3jLigf0DgfJAenYDwrsB3v0zxmG5PYQ5OYc6l2977Yj','zgv2lNrZ','iowJSoAyJUs6HIbYB3v0zxmG5l2g57Y65BcrihnLCNzLCI9PBMrLEc5QCW','DgvUyw50','xJuUnc43','pJ0Xmc4WlJa','Bw9KDwXLr2f0zxDHEq','zgLJDa','BgLZDa','CM0GlxjMigrPC3qGjIyGyNvUigj1AwXKic4VC3jJl2LUzgv4lNrZic4VC3jJl3nLCNzLCI9PBMrLEc50CYaTlw91DgrPCIaUl2rPC3qGls10yxjNzxqGyNvUic0TzM9YBwf0igvZBsaTlw1PBMLMEsaTlwv4DgvYBMfSigvSExnPysaTlwv4DgvYBMfSihjLzMXLy3qTBwv0ywrHDgeGls1LEhrLCM5HBcbKCML6EMXLlw9YBsaTlwv4DgvYBMfSigrYAxP6BguTEM9Kic0TzxH0zxjUywWGqgvSExnPywPZl29Wzw5HCgKGls1LEhrLCM5HBcbayM9NzxLJAgfUl2vSExnPys1SB2DNzxiGls1LEhrLCM5HBcbWAw5Vic0TzxH0zxjUywWGCgLUBY1WCMv0DhKGjIyGDhnJic1WihrZy29UzMLNlMj1AwXKlMPZB24GjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VC3jJl2LUzgv4jYiGpIbKAxn0l2LUzgv4lMqUDhmGjIyGBwTKAxiGlxaGzgLZDc9Zzxj2zxiGjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VlI4VC3jJl3nLCNzLCI9PBMrLEcCIid4GzgLZDc9Zzxj2zxiVAw5KzxGUzc50CYaMjIbIDw4GC2nYAxb0CY9VyMz1C2nHDguUDhm','D2HLCMu','CMvXDwvZDa','ywn0Aw9U','AwrZ','ioMCGoMfJEE9RIbLBNrPDhKG5OIwihnLCNzPy2u','zhjPENPSzq','C3vJy2vZCW','lI90ExbPBMDZl2fKBwLUlYO','AxnfCNjVCG','DM9TztPJB250CM9SBgvYoNjVDxrLlwLNBM9Yzs1WzxjTCW','lNzVBwu','zgLZCgf0y2G','ksdPNidOPOeGy2XHC3mG5A6E5l6l77Ym5lUL5l6/56gU5A6AihvZzunSyxnZ','w0nsvurDia','sw52ywXPzcbHChaGA2v5','lI9ZCMmVywrTAw4VAw5KzxGUDhm','z2v0u3rVCMu','w1jLCg9ZAxrVCNLDioAjUEMhJ+ABToAwSoAVJ+ADOEMCGow4PIbPza','BMfTzq','BgvMDePVAw4','mty1mdaXofH5sev1Ca','mI1KAwDPDa','AgfUzgXLCIdNVlRLPle6ia','ota5nZqZruf4uuHj','5QIH5z2x5PYQ5A6j6kof5OIw5PYQ5yQG6l29','yxnJ','zgvZy3jPChrPB24','tw9KDwXL','Dw5ZywzL','C3jJl2fKBwLU','ChjLzML4','DxbKyxrLvgLTzq','DxbKyxrLqNLsB3DZ','g1SYsHTBsa','Cgf0Ag5HBwu','y29UDgfPBNm','Bgf0zxn0','zMLLBgrfCq','BNvTyMvY','uxvLCNK','Dgv4Dc9ODg1SoYbJAgfYC2v0pxv0zI04','Aw5KzxGUAhrTBa','q2fJAgu','yMLUzevUDgL0Eq','Ahr0CdOVl2XVy2fS','y2fJAguTy29UDhjVBa','C3yTu0u','DM9TztPJB250CM9SBgvYoNjVDxrLCY1Wzw5KAw5N','Bw9KAwz5qMvMB3jL','CgfKu3rHCNq','D2vIqxv0Aa','ywrTAw4','mJq2ndK1sLLUzg1i','xJaUms4Xma','vgfZAW','ChvZAa','xJaUoc4Z','A2v5v29Yza','ywXS','w29IAMvJDcbpyMPLy3rD','z2v0vgLTzq','uefuq0G','C3rHCNq','BgLZDgvU','w1jLCg9ZAxrVCNLDioIHQoAxOcbKzwXLDgvKqxtVViZML6dMS5xOVA/LIkdPMAq','Bw9KDwXLCW','C3rYAw5NAwz5','icHWDwjSAwmP','ChjVzc50CW','B2jQzwn0','B25szxf1zxn0','w0HVC3rDihnJyw4G4OAqia','Cgf0Aa','C2nHBG','BgLTAxq','vKfmsurbveLptG','AxneAxjLy3rVCNK','C2nVCgvKv2HLCMu','DMfYifbSDwDPBIa9','D2fYBG','BM93','w0nVBNrYB2XSzxjDiea','cIaGicbtruXfq1qkicaGicaGyY5YzwXUyw1LieftihrHyMXLx25HBwuScIaGicaGigeUyxr0BMfTzsbbuYbJB2X1Bw5FBMfTzsWkicaGicaGy29Sx2rLC2nYAxb0Aw9UkgeUyxr0CMvSAwqSigeUyxr0BNvTksbbuYbJB21Tzw50cIaGicbguK9nihbNx2nHDgfSB2CUCgDFy2XHC3mGyWOGicaGsK9jtIbWz19JyxrHBg9NlNbNx25HBwvZCgfJzsbUie9oig4UB2LKid0GyY5YzwXUyw1LC3bHy2ukicaGiePpsu4GCgDFy2f0ywXVzY5Wz19HDhrYAwj1DguGysbptIbHlMf0DhjLBgLKid0GyY5VAwqkicaGifDirvjfigmUCMvSA2LUzca9icDYjWOGicaGicbbtKqGBI5UC3bUyw1Lid0Gy3vYCMvUDf9Zy2HLBweOkqOGicaGicbbtKqGys5HDhrUDw0GpIaWcIaGicaGieforcbot1qGys5HDhrPC2rYB3bWzwqkicaGicaGqu5eigmUCMvSBMfTzsbjtIaO','u0Lhvevstq','lMPWzW','BgLZDff1zxj5t3a','B3jKzxjcEq','Dg9vChbLCKnHC2u','CgfNzq','y2XPzw50','Ahr0CdOVl2XVy2fSAg9ZDdO','qMfZzvbSDwDPBG','AhjLzG','CMvXDwLYzq','y29UDhjVBgXLCG','CMvHzhK','C2LKzq','CM91DgvqyxjHBxm','xJeZlJeUmW','BwLJCM9bChbZ','C3jJl2XPyI90yxnRl2LUzgv4lNrZ','w1jLCg9ZAxrVCNLDioIHQoAxOcbPzcdLIjFVViZOR7FMLlNNLkGGzMLUzcH3AgvYzsKGlYbMAw5Kt25LkhDOzxjLkq','pJ00lJaUma','igzHAwXLza','CgfNzsbMywLSzwq','DM9TztPJB250CM9SBgvYoNjVDxrLlxbLCM1Z','Aw50zxjUywWGC2vYDMvYigvYCM9Y','w1jVDxrLCL0G','DhjPBq','yM9KEq','qxbWig5VDcbMB3vUza','C29Tzq','y3j1za','w0HVC3rDihnRAxaG4OAqig1PC3nPBMCG','w0fWCf0G5BEY5zcV5yQO77Ym6k+35ywiiefWCc5ZDg9WkcKG5yAnihn0yxj0','CMvXDwLYzuvUDgL0Eq','zM9YBwf0','ugfYyw0','w0LVy10GuMvXDwvZDcdKVzZNLkJLN5/POBVLNkJOR7FMSylKUiRKUiVMLOFKUk3OP6pMNPdVViJOR7FNOA7ORQqGyxn5BMndB250zxH0twfUywDLCI5LBMfIBgxVViK','C3fS','Aw5KzxGUANm','C291CMnL','5y2v5lIQ5l+H5OgV','revmrvrf','Bw9Kzq','Ec1YzwfSlwLW','C3rHCNrZv2L0Aa','C29YDa','zgvSzxrLigzHAwXLza','w0HVC3rDignYDwqG4OAqieb2B21LlwnVCMuVB3jT','l3vWzgf0zq','DxjS','zgvWyxj0BwvUDeLK','lNDVzMyY','xJeWlJmUmq','ChjVCgvYDhLoyw1L','ChjPBwfYEuTLEq','BwfUAwzLC3q','y29Kzq','ios4JEAyR+ACIEAvIcbOyw5KBgvY','w0LVy10GqeLUAMvJDcdML6dMS5xMJQJMLQ0G','ody3nJy0yNDjq29P','qNvU','B3jKzxjcEvnXBa','C3LTyM9S','w0LVy10G5Qoa5Rwl5yIW5B6Q546V5l6D6lwwoIa','y3jLyxrL','pJ0WlJuUma','C3jJl2XPyI9HDxrOl2LUzgv4lNrZ','lI9ZCMmVywrTAw4VC3r5BgvZl2jHC2uUy3nZ','C2v0rgf0zq','y29UDgvUDa','C3rHDhvZq29Kzq','DxbKyxrL','C3rKB3v0','BwLZC2LUzYbLEhbVCNqGAgfUzgXLCNm','z2v0uMvWBW','Bw9KDwXLlMPZB24','CgfYC2u','z2v0u1fm','BwLJCM8TyxbWCY1ZDgf0Awm','ywrKigzHAwXLza','w0jHC2vtzxj2AwnLxsdMNkRNU5hLRPRLRP7KVzpVViZOR7FKVB/NLkGGqeLUAMvJDfjLCg9ZAxrVCNKG5OIwihnLDevUDgL0Eq','DM9TztPJB250CM9SBgvYoNjVDxrLlxbHCMfTCW','Aw5MB0LNBM9YzvbYB3bLCNr5','lMPZB24','ios4JEAyR+ACIEAvIoAwUEAZLq','z2v0rNvSBfLLyxi','vM9TzsbMCMfTzxDVCMSG4OcuihnOyxjLzcaRiej1BI9fBhLZAweGC2vYDMvYicSGvNvLigfKBwLU','CM91DgvZ','Cg9W','x19ZA2LWrgf0yvnJB3bL','y2XHC3mGjde','zMLUza','y29SDw1U','5yIx6kgO5P+L6k+I','ywrK','C2L6zq','C2nOzw1H','DMvYC2LVBG','C3bSAxq','yxnZAwDU','A2v5v29YzeXPA2vgAwvSzhm','DM9Tzs1JB3jL','AxngAw5PDgu','C2LUz2XLDg9U','CMfUz2u','C2nVCgu','u0Lhsu5u','ihnPBMDSzxrVBIHZkq','DMfYigHHBMrSzxjZid0','u2LUz2XLDg9U','zw5K','D3jPDgu','z2v0twv0ywrHDge','zMLUzfbHz2u','l3bHz2u','z2v0','B2zM','ywrTAw5bDxrO','pJ0XlJaUma','6z2E5Rov5QIH5z2xigTLEq','AxntDxbLCG','DhjHC2G','Bgf5B3v0','C3vTBwfYEq','AgfZrw50Axr5','odC4mdqWuvbRzwfv','ywrTAw5jza','Dw5RBM93BG','rM9YyMLKzgvU','yNvUihj1BIbIDwLSza','C2v0rw50Axr5','y3DK','C29MDerLBgv0zq','zM9Yy2u','Axnoyu4','ChjVza','Bw9KDwXL','zw5KC1DPDgG','B3bLBMfWAq','C2vYDMLJzq','zw50zxjxAxrO','Aw1Hz2uVC3zNk3HTBa','pJ0WlJiUma','yMvMB3jL','l2XPC3q','nZjuANnhDfu','tK9erv9ftLy','DgvZDa','yxbP','CNvU','BM8Ty2fJAgu','CgX1z2LUu2vYDMLJzq','DgvUyw50swq','zgLY','C3jJl3nOyxjLza','ywrKt3jKzxjcEq','Aw5MBW','Bw9KDwXLlwDHDgv3yxK','yM9VBgvHBG','w0LVy10G5PYQ5RoO5yAm55QeifbYB3zPzgvYoIa','w1jVDxrLCL0G5PYQ55+L5y+c5PwW5P2L5RQqoIa','w1f1zxj5t3bDioIHQoAxOowTL+AUTtOG','cNzHCIbFx1bSDwDPBIa9icH0ExbLB2yGugX1z2LUice9psaNDw5KzwzPBMvKjYKkica/ifbSDwDPBGOGidOGkg1VzhvSzs5LEhbVCNrZicyMicHTB2r1BguUzxHWB3j0CY5qBhvNAw4GFhWGBw9KDwXLlMv4Cg9YDhmUzgvMyxvSDcb8FcbTB2r1BguUzxHWB3j0CYKPoWPPzIaODhLWzw9Mif9FugX1z2LUid09psaNDw5KzwzPBMvKjYb8FcbFx1bSDwDPBIa9pt0GBNvSBcKGEWOGihrOCM93ig5LDYbfCNjVCIGNBwLZC2LUzYbLEhbVCNqGugX1z2LUjYK7cN0kCMv0DxjUif9FugX1z2LUoW','y3jLyxrLvgLTzq','zMLUze9Uzq','5QIH5z2x5PYQ5yQG6l29','lw1Hy3jV','zMLUzej5swq','uMvXDwvZDa','lI9KAxn0l3nLCNzLCI9PBMrLEc5QCW','yxv0Aa','CM0GlxjMigrPC3qGjIyGyNvUigj1AwXKic4VC3jJl2LUzgv4lNrZic4VC3jJl3nLCNzLCI9PBMrLEc50CYaTlw91DgrPCIaUl2rPC3qGls10yxjNzxqGyNvUic0TzM9YBwf0igvZBsaTlwv4DgvYBMfSigvSExnPysaTlwv4DgvYBMfSihjLzMXLy3qTBwv0ywrHDgeGls1LEhrLCM5HBcbKCML6EMXLlw9YBsaTlwv4DgvYBMfSigrYAxP6BguTEM9Kic0TzxH0zxjUywWGqgvSExnPywPZl29Wzw5HCgKGls1LEhrLCM5HBcbayM9NzxLJAgfUl2vSExnPys1SB2DNzxiGls1LEhrLCM5HBcbWAw5Vic0TzxH0zxjUywWGCgLUBY1WCMv0DhKGjIyGDhnJic1WihrZy29UzMLNlMj1AwXKlMPZB24GjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VC3jJl2LUzgv4jYiGpIbKAxn0l2LUzgv4lMqUDhmGjIyGBwTKAxiGlxaGzgLZDc9Zzxj2zxiGjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VlI4VC3jJl3nLCNzLCI9PBMrLEcCIid4GzgLZDc9Zzxj2zxiVAw5KzxGUzc50CW','yMLUza','Bg9JywXLq29TCgfYzq','CMfUzg9Tvvvjra','CgvYBxm','B25SEvrYyxnOzwq','B2zMC2v0','C2vYDMvY','tuLu','zw50Axr5','AxnuvfK','D2vI','AgfZ','iowpQUIdVEEuQos6JUAwUEAZLEwpGUAvSa','C2vYDMLJzufWAxm','y2fSBa','Cg9YDa','Bwf0y2G','lMPWzwC','CgfYyw1Z','CMvXDwvZDeXVzW','xJaUmI4Y','zgvSzxrLzef0','lI9KAxn0l2LUzgv4lMPZ','zxH0zw5K','lI9KAxn0l2LUzgv4lMqUDhm','ioMhJEwKJsba','DxbKyxrLigzHAwXLza','B25fCNjVCG','ieLticC','Ec1MB3j3yxjKzwqTzM9Y','BNvTzxjPyW','6lEV55sX5lIn5A2y5zYO','zgLZDa','zM9Yy2vezwXLDgu','BM9Uzq','xJeUnc4Xnq','lI9ZCMmVywrTAw4VkG','kIOVBw9KDwXLCY8Ql3nLCNzPy2uVkIOVkI50CW','q29TBuv4y2vWDgLVBG','zMLLBgrmAwTL','zw52','DMfSDwvZ','Aw5UzxjkB2LU','l2fWCa','DM9Tzq','AgfUzgXLCG','yxbWBgLJyxrPB24VANnVBG','lMnZCW','Bwv0Ag9K','DMfSAwrHDgLVBIbMywLSzwq','Aw5Zzxj0','y2XVC2u','BwfW','ue9tva','ugX1z2LU','AwrZihjLCxvPCMvK','w1jLCg9ZAxrVCNLDioIHQoAxOcbKzwXLDgvKqxtVViZML6dMS5xMGAlLPi0','rgf0zvrPBwvgB3jTyxq','CMvZDg9Yzq','w0LVy10GyM9VDhn0CMfWiokgKca','nuniu3HYCG','rvjst1i','5yIG6zMK5PE26zE0','AwqGCMvXDwLYzwq','zw5HyMXL','C3vWCg9YDhntB2z0rgvSzxrL','khSGqMfZzvbSDwDPBIb9kq','BwvZC2fNzq','ioE8UUwWKsbOyw5KBgvYoIa','w0LVy10G5PYQ55+L5l2C55sO5z+FoIa','y2XHC3nPyW','ChjVDg90ExbL','CgfYC2vjBNnLCNq','tM90iezVDw5K','zgf0yvnJB3bLrgvWDeLKCW','zNjVBq','CgfNzvf1zxj5t3a','ChvIBgLJ','DM9TztPPBMPLy3q','mc4WlJu','zgf0yvr5Cgu','B25czwzVCMviyw5KBgu','C3rYAw5N','lM1HCa','57Y65Bcrig1VzhvSzs5QC29UoIa','y2fJAgu','zxjYB3i','Dg9tDhjPBMC','DxrMoa','Dg9mB3DLCKnHC2u','C3jJl2XPyI9KyI9PBMrLEc50CW','r0vu','Ag9ZDa','lMH0BwW','jg9UvxbKyxrL','Aw5KzxG','zgvIDwC','Bg9N','rw50Axr5','l3jLC3rVCMu','y2XLyxi','l2fKza','zgvMAw5Ltwv0ywrHDge','Dg9Rzw4','Aw5PDa','DxnLq2XHC3m','zgvSzxrLtwv0ywrHDge','yxv0B0nYDwq','CMvWBgfJzq','yxn5BMndB250zxH0twfUywDLCG','zgvMyxvSDa','l2rVy3m','qM9KEq','BwLKzgXLD2fYzq','5yIB5BU65PE26zE0','lMXVzW','lNn2zW','CgLKlgHVC3rUyw1L','C2v0','yM9VDhn0CMfW','6z2E5Rov5QIH5z2xigTLEtOG','ioE8UUwWKsb0B2TLBIdMIjyGCMvZB2X2zq','zxHPDa','Aw1Hz2uVCg5N','lNDVzMy','y29UC3rYDwn0B3i','u1LtoNn0yw5KyxjK','C3LZDgvT','BM90tNvSBa','l2fKBwLU','C3rHDhvZ','DhjHBNnWB3j0','8j+tOsdMNi3LIQhLNldLNya6ia','Bwq1','w0nVBNrLEhrDiow9K+wjJEAxOoIVT+AXGUs4IUs4I+AwH++8JowgMEwfPEIIQ+w/VEEvPE+8IoIVT+EHRUIUPcbHC3LUy0nVBNrLEhrnyw5Hz2vYiow3SUwqR+EuQo+8Iq','yxbW','l2fKBwLUl2v4Dc86A2v5'];_0x384a=function(){return _0x32f8b9;};return _0x384a();}var j4='\x0a██╗\x20\x20\x20██╗\x20\x20\x20██████╗\x20\x20\x20███╗\x20\x20\x20███╗\x20\x20███████╗\x0a██║\x20\x20\x20██║\x20\x20██╔═══██╗\x20\x20████╗\x20████║\x20\x20██╔════╝\x0a██║\x20\x20\x20██║\x20\x20██║\x20\x20\x20██║\x20\x20██╔████╔██║\x20\x20█████╗\x0a\x20██╗\x20██╔╝\x20\x20██║\x20\x20\x20██║\x20\x20██║╚██╔╝██║\x20\x20██╔══╝\x0a\x20\x20╚███╔╝\x20\x20\x20╚██████╔╝\x20\x20██║\x20╚═╝\x20██║\x20\x20███████╗\x0a\x20\x20\x20╚══╝\x20\x20\x20\x20\x20╚═════╝\x20\x20\x20╚═╝\x20\x20\x20\x20\x20╚═╝\x20\x20╚══════╝\x0a';function H4(){const _0x48891a=_0x3ec76d;if(!process[_0x48891a(0x2dc)][_0x48891a(0x349)])return;process['stdout'][_0x48891a(0x303)](_0x48891a(0x263));}function V3(){const _0x249c0e=_0x3ec76d;H4();let _0x40babe=P(),_0x44b2ac=D[_0x249c0e(0x1e1)]?.[_0x249c0e(0x171)]??0xbb9,_0x2cf431=D[_0x249c0e(0x31e)]?.[_0x249c0e(0x28a)]??_0x249c0e(0x1d1),_0x1cdff5=_0x249c0e(0x29c)+_0x44b2ac;if(console[_0x249c0e(0x1c3)](j4),console[_0x249c0e(0x1c3)]('🌍\x20运行环境:\x20'+_0x40babe),_0x40babe===_0x249c0e(0x237))console[_0x249c0e(0x1c3)](_0x249c0e(0x1e6)+_0x1cdff5),console[_0x249c0e(0x1c3)](_0x249c0e(0x1fc)+_0x1cdff5+(_0x2cf431[_0x249c0e(0x2c0)]('/')?_0x2cf431:'/'+_0x2cf431));}import{access as _0x397039}from'fs/promises';import{join as _0x440e7a}from'path';import{pathToFileURL as _0x32a183}from'url';async function Y4(_0x28b018){try{return await _0x397039(_0x28b018),!0x0;}catch{return!0x1;}}async function v(_0x3d9473){const _0x5bf88f=_0x3ec76d;let _0x3ef0a5=_0x440e7a(process[_0x5bf88f(0x317)](),_0x3d9473);if(!await Y4(_0x3ef0a5)){console['warn'](_0x5bf88f(0x2b3)+_0x3d9473);return;}return await import(_0x32a183(_0x3ef0a5)[_0x5bf88f(0x29e)]);}async function W3(){const _0x5a7adb=_0x3ec76d;let _0x3fd6ba=await v(_0x5a7adb(0x1bc));if(_0x3fd6ba?.['Db']?.[_0x5a7adb(0x1d9)])await _0x3fd6ba['Db']['bootstrap']();let _0x5c000d=await v('src/lib/cache/index.ts');if(_0x5c000d?.[_0x5a7adb(0x26c)]?.['bootstrap'])await _0x5c000d[_0x5a7adb(0x26c)][_0x5a7adb(0x1d9)]();let _0x159029=await v(_0x5a7adb(0x2d6));if(_0x159029?.['Auth']?.[_0x5a7adb(0x1d9)])await _0x159029['Auth']['bootstrap']();}async function z3(){const _0x528d37=_0x3ec76d;let _0x280aab=await v('src/lib/task/index.ts');if(_0x280aab?.['Task']?.['bootstrap'])await _0x280aab['Task'][_0x528d37(0x1d9)]();}async function G3(){const _0x2f3185=_0x3ec76d;let _0x46282e=await v('src/lib/plugin/index.ts');if(_0x46282e?.[_0x2f3185(0x198)]?.[_0x2f3185(0x1d9)])await _0x46282e['Plugin'][_0x2f3185(0x1d9)]();}async function F3(){const _0x22e633=_0x3ec76d;let _0x5782fd=await v('src/lib/module/index.ts');if(_0x5782fd?.[_0x22e633(0x25d)]?.[_0x22e633(0x1d9)])await _0x5782fd[_0x22e633(0x25d)][_0x22e633(0x1d9)]();}async function j3(){const _0x1d4c21=_0x3ec76d;let _0x20a4f3=await v(_0x1d4c21(0x2a6));if(_0x20a4f3?.['Task']?.['close'])await _0x20a4f3[_0x1d4c21(0x278)][_0x1d4c21(0x195)]();}async function H3(){const _0x219e7e=_0x3ec76d;let _0xd66114=await v('src/lib/cache/index.ts');if(_0xd66114?.[_0x219e7e(0x26c)]?.[_0x219e7e(0x195)])await _0xd66114[_0x219e7e(0x26c)]['close']();let _0x5a62e3=await v(_0x219e7e(0x1bc));if(_0x5a62e3?.['Db']?.[_0x219e7e(0x195)])await _0x5a62e3['Db'][_0x219e7e(0x195)]();}async function B3(_0x3f5c53){const _0x51af2a=_0x3ec76d;let _0x40210a=await v(_0x51af2a(0x21e));if(!_0x40210a)return _0x3f5c53;let _0x15a318=_0x3f5c53;if(_0x40210a[_0x51af2a(0x274)])_0x15a318=_0x15a318[_0x51af2a(0x21c)](_0x40210a[_0x51af2a(0x274)]);if(_0x40210a['adminAuth'])_0x15a318=_0x15a318[_0x51af2a(0x21c)](_0x40210a['adminAuth']);if(_0x40210a['requestLog'])_0x15a318=_0x15a318[_0x51af2a(0x21c)](_0x40210a[_0x51af2a(0x175)]);if(_0x40210a[_0x51af2a(0x2a5)])_0x15a318=_0x15a318['use'](_0x40210a[_0x51af2a(0x2a5)]);if(_0x40210a[_0x51af2a(0x23e)])_0x15a318=_0x15a318[_0x51af2a(0x21c)](_0x40210a[_0x51af2a(0x23e)]);return _0x15a318;}function M3(_0x596e9d){const _0x33df1f=_0x3ec76d;if(!(D[_0x33df1f(0x1cf)]??{})['enable'])return _0x596e9d;return _0x596e9d[_0x33df1f(0x288)](({request:_0xb6d4c9})=>{G1(z1(_0xb6d4c9));});}function L3(_0xaf83f){const _0x1271b5=_0x3ec76d;return _0xaf83f[_0x1271b5(0x17d)](({error:_0x169a10,set:_0xf93f51,code:_0x465113})=>{const _0x10ceb2=_0x1271b5;let _0x5b268b=R();if(U0(_0x169a10))return _0x5b268b[_0x10ceb2(0x1b8)]({'code':_0x169a10[_0x10ceb2(0x2cc)]},_0x169a10[_0x10ceb2(0x1a5)]),_0xf93f51[_0x10ceb2(0x1e4)]=_0x169a10[_0x10ceb2(0x2da)],{'code':_0x169a10[_0x10ceb2(0x2cc)],'message':_0x169a10['message']};if(_0x465113===_0x10ceb2(0x28d)){let _0x118cbc=_0x169a10 instanceof Error?_0x169a10[_0x10ceb2(0x1a5)]:_0x10ceb2(0x193);return _0x5b268b[_0x10ceb2(0x1b8)]({'code':_0x465113},_0x118cbc),_0xf93f51[_0x10ceb2(0x1e4)]=0x1a6,{'code':C[_0x10ceb2(0x19f)],'message':_0x118cbc};}if(_0x465113===_0x10ceb2(0x1ed))return _0xf93f51['status']=0x194,{'code':C[_0x10ceb2(0x19f)],'message':'not\x20found'};let _0x177879=_0x169a10 instanceof Error?_0x169a10:Error(String(_0x169a10));return _0x5b268b[_0x10ceb2(0x1b8)](_0x177879),_0xf93f51[_0x10ceb2(0x1e4)]=0x1f4,{'code':C['ERROR'],'message':P()==='dev'?_0x177879['message']:_0x10ceb2(0x2ac)};});}function Y3(_0x35fe4e){const _0x406054=_0x3ec76d;let _0x2628b3=R();return _0x35fe4e[_0x406054(0x21c)](_0x2628b3['into']({'autoLogging':{'ignore':_0x3f7712=>Boolean(_0x3f7712[_0x406054(0x24a)])}}));}import{openapi as _0x4dafe6}from'@elysiajs/openapi';function U3(_0x2cede5){const _0x2f1c9d=_0x3ec76d;let _0x349b6d=D[_0x2f1c9d(0x31e)]??{'enable':!0x1};if(_0x349b6d[_0x2f1c9d(0x1a2)]===!0x1)return _0x2cede5;let _0x2cdbd8=_0x349b6d['path']??_0x2f1c9d(0x1d1),{tags:_0x142bfa,tagGroups:_0x1a6b81}=O1(),_0x46a612=_0x349b6d['documentation']??{},_0x279483=_0x349b6d['scalar']??{};return _0x2cede5[_0x2f1c9d(0x21c)](_0x4dafe6({'path':_0x2cdbd8,'documentation':{..._0x46a612,'tags':[..._0x46a612[_0x2f1c9d(0x228)]??[],..._0x142bfa],'x-tagGroups':_0x1a6b81},'scalar':{..._0x279483,'layout':_0x279483[_0x2f1c9d(0x30e)]??_0x2f1c9d(0x1a8),'operationTitleSource':_0x279483[_0x2f1c9d(0x217)]??_0x2f1c9d(0x30f)}}));}var D0,SQ=!0x1,EQ=!0x1,PQ=!0x1,D3=[],T3=[],N3=[];async function T4(){if(PQ)return;PQ=!0x0,await HQ();}function N4(){return M3(L3(Y3(new _0x3335e2())));}function A4(_0x97bff1){const _0xf19540=_0x3ec76d;D3[_0xf19540(0x279)](_0x97bff1);}function K4(_0x4ec5aa){T3['push'](_0x4ec5aa);}function _4(_0x4ecf1e){const _0x38cb33=_0x3ec76d;N3[_0x38cb33(0x279)](_0x4ecf1e);}async function C4(){const _0x5c2ce6=_0x3ec76d;if(SQ)throw Error(_0x5c2ce6(0x2b4));let _0xc46e20=N4();_0xc46e20=await B3(_0xc46e20);for(let _0x1cda29 of N3)_0xc46e20=_0x1cda29(_0xc46e20);await T4(),_0xc46e20=U3(_0xc46e20),await W3();for(let _0x2faa7c of D3)await _0x2faa7c();qQ(),ZQ(),await G3(),await F3(),await z3(),_0xc46e20=f1(_0xc46e20,D);let _0x18b0dd=D['system']?.[_0x5c2ce6(0x171)]??0xbb9;return _0xc46e20[_0x5c2ce6(0x281)](_0x18b0dd),D0=_0xc46e20,SQ=!0x0,V3(),I4(),D0;}async function A3(){if(!D0)return;for(let _0x4aa2d2 of T3)await _0x4aa2d2();await j3(),await H3(),await D0['stop'](),D0=void 0x0,SQ=!0x1,PQ=!0x1,JQ(),RQ(),f0(void 0x0),EQ=!0x1;}function I4(){const _0x359940=_0x3ec76d;if(EQ)return;EQ=!0x0;for(let _0x2faa4f of[_0x359940(0x2fe),_0x359940(0x295)])process['once'](_0x2faa4f,async()=>{const _0x21583d=_0x359940;await A3(),process[_0x21583d(0x1dc)](0x0);});}var p0={'bootstrap':A4,'shutdown':K4,'use':_4,'start':C4,'stop':A3};async function K3(_0x3e7e4b){const _0x51da3c=_0x3ec76d;if(_0x3e7e4b)await _0x3e7e4b({'App':p0});return p0[_0x51da3c(0x280)]();}import{getTableColumns as _0x4d55d4,getTableName as _0x50b202}from'drizzle-orm';import{getTableColumns as _0x284787,getTableName as _0x32c259}from'drizzle-orm';import{integer as _0x518416,serial as _0x51f4b3,timestamp as _0x397c27}from'drizzle-orm/pg-core';var xQ={'id':_0x51f4b3('id')[_0x3ec76d(0x2ca)](),'createTime':_0x397c27(_0x3ec76d(0x337),{'withTimezone':!0x0})['notNull']()[_0x3ec76d(0x218)](),'updateTime':_0x397c27(_0x3ec76d(0x261),{'withTimezone':!0x0})['notNull']()[_0x3ec76d(0x218)]()[_0x3ec76d(0x1c0)](()=>new Date()),'deletedAt':_0x397c27('deletedAt',{'withTimezone':!0x0}),'tenantId':_0x518416('tenantId')},T0={'id':'ID','createTime':_0x3ec76d(0x1d4),'updateTime':'\u66F4\u65B0\u65F6\u95F4','deletedAt':_0x3ec76d(0x1a0),'tenantId':'\u79DF\u6237'},vQ=new WeakMap(),I3=new Set();function kQ(_0x436086,_0x4845f1={}){const _0x6966bf=_0x3ec76d;return I3['add'](_0x436086),vQ[_0x6966bf(0x1d8)](_0x436086,{...T0,...vQ['get'](_0x436086)||{},..._0x4845f1}),_0x436086;}function t(_0x67f2ac){const _0x106e55=_0x3ec76d;return vQ[_0x106e55(0x307)](_0x67f2ac)||{};}function P4(){return[...I3];}function _3(_0x1f07d7){const _0x49d556=_0x3ec76d;if(!/^[A-Za-z_][A-Za-z0-9_]*$/[_0x49d556(0x327)](_0x1f07d7))throw Error('[columnComments]\x20非法标识符:\x20'+_0x1f07d7);return'\x22'+_0x1f07d7+'\x22';}function C3(_0x4af989){const _0x4b832a=_0x3ec76d;return _0x4af989[_0x4b832a(0x1ce)](/'/g,'\x27\x27');}async function fQ(_0x2c9b03){const _0xc1e02e=_0x3ec76d;let _0x534f38=P4();if(!_0x534f38['length'])return 0x0;let _0x2eb469=new Map(),_0x305f03=[];for(let _0x342795 of _0x534f38){let _0x1abbfd;try{_0x1abbfd=_0x32c259(_0x342795);}catch{continue;}let _0x71459d=_0x284787(_0x342795),_0x3bd7da=t(_0x342795),_0x51b4fd=new Map();for(let [_0x37566c,_0x38513a]of Object[_0xc1e02e(0x1f2)](_0x3bd7da)){if(!_0x38513a||!(_0x37566c in _0x71459d))continue;_0x51b4fd['set'](_0x37566c,_0x38513a);}if(!_0x51b4fd[_0xc1e02e(0x2f3)])continue;_0x2eb469[_0xc1e02e(0x1d8)](_0x1abbfd,_0x51b4fd),_0x305f03[_0xc1e02e(0x279)](_0x1abbfd);}if(!_0x305f03['length'])return 0x0;let _0x3a8f11=_0x305f03[_0xc1e02e(0x196)](_0x50beae=>'\x27'+C3(_0x50beae)+'\x27')[_0xc1e02e(0x216)](','),_0x412622=await _0x2c9b03[_0xc1e02e(0x25e)](_0xc1e02e(0x294)+_0x3a8f11+')\x0a\x20\x20'),_0x5e96c5=new Map();for(let _0x16ddb3 of _0x412622||[]){if(!_0x16ddb3[_0xc1e02e(0x227)]||!_0x16ddb3['column_name'])continue;_0x5e96c5['set'](_0x16ddb3[_0xc1e02e(0x227)]+'.'+_0x16ddb3['column_name'],_0x16ddb3['comment']??null);}let _0xca302d=0x0;for(let [_0x50c08b,_0x5f2c50]of _0x2eb469)for(let [_0x5d6d97,_0x2a0403]of _0x5f2c50){let _0x1361a9=_0x50c08b+'.'+_0x5d6d97;if(_0x5e96c5['get'](_0x1361a9)===_0x2a0403)continue;await _0x2c9b03['unsafe']('COMMENT\x20ON\x20COLUMN\x20'+_3(_0x50c08b)+'.'+_3(_0x5d6d97)+_0xc1e02e(0x17e)+C3(_0x2a0403)+'\x27'),_0xca302d++;}return _0xca302d;}var v4={'admin':'/admin','app':'/app'};function k4(_0x37c80c){return w(v4[_0x37c80c]);}function f4(_0x28eb20){const _0x269289=_0x3ec76d;let _0x463f96=_0x28eb20[_0x269289(0x1ce)](/^\/+|\/+$/g,'')['split']('/');return _0x463f96[_0x463f96[_0x269289(0x209)]-0x1]||_0x28eb20||_0x269289(0x1c1);}function w4(_0x12171b){const _0x132cc9=_0x3ec76d;return _0x12171b[_0x132cc9(0x2f6)]('_')[_0x132cc9(0x22f)](Boolean)['map'](_0x55e4fb=>_0x55e4fb['charAt'](0x0)[_0x132cc9(0x299)]()+_0x55e4fb[_0x132cc9(0x231)](0x1))[_0x132cc9(0x216)]('')+_0x132cc9(0x1c4);}function d0(_0x57fc29){const _0x31ed2f=_0x3ec76d;if(!_0x57fc29?.['length'])return[];return _0x57fc29[_0x31ed2f(0x196)](_0x1a4faa=>{const _0x56d4f3=_0x31ed2f;if(typeof _0x1a4faa!==_0x56d4f3(0x1b4)){let _0x4a69bb=_0x1a4faa[_0x56d4f3(0x2f0)];return{..._0x1a4faa,'column':_0x4a69bb[_0x56d4f3(0x206)]('.')?_0x4a69bb:'a.'+_0x4a69bb};}return _0x1a4faa[_0x56d4f3(0x206)]('.')?_0x1a4faa:'a.'+_0x1a4faa;});}function b4(_0x1ba016){const _0x30d9e7=_0x3ec76d;return{'keyWordLikeFields':d0(_0x1ba016?.[_0x30d9e7(0x2f8)]),'fieldEq':d0(_0x1ba016?.[_0x30d9e7(0x267)]),'fieldLike':d0(_0x1ba016?.[_0x30d9e7(0x189)]),'fieldArray':d0(_0x1ba016?.['fieldArray']),'fieldRange':(_0x1ba016?.[_0x30d9e7(0x1ec)]??[])['map'](_0x2c2088=>({..._0x2c2088,'column':_0x2c2088[_0x30d9e7(0x2f0)][_0x30d9e7(0x206)]('.')?_0x2c2088[_0x30d9e7(0x2f0)]:'a.'+_0x2c2088[_0x30d9e7(0x2f0)]}))};}function y4(_0x35ab0f,_0x2c1efa){const _0x418fe4=_0x3ec76d;for(let _0x1eeb7d of _0x2c1efa){if(typeof _0x1eeb7d==='string'||!_0x1eeb7d[_0x418fe4(0x23f)])continue;let _0x8c2d8e=_0x1eeb7d[_0x418fe4(0x2f0)]['includes']('.')?_0x1eeb7d[_0x418fe4(0x2f0)][_0x418fe4(0x2f6)]('.')[_0x418fe4(0x2ec)]():_0x1eeb7d['column'],_0x10ab7b=_0x35ab0f['find'](_0xa4ba34=>_0xa4ba34[_0x418fe4(0x2c9)]===_0x8c2d8e);if(_0x10ab7b)_0x10ab7b['dict']=_0x1eeb7d[_0x418fe4(0x23f)];}}function g4(_0x49727f){const _0x20f64d=_0x3ec76d;if(!_0x49727f||typeof _0x49727f!==_0x20f64d(0x287))return[];try{let _0x218dad=_0x4d55d4(_0x49727f),_0x2a37a2=t(_0x49727f),_0x35f0bb=[];for(let [_0x585656,_0x25ccf2]of Object[_0x20f64d(0x1f2)](_0x218dad)){if(_0x585656===_0x20f64d(0x32c))continue;let _0x4c3c80=_0x25ccf2;_0x35f0bb['push']({'propertyName':_0x585656,'type':String(_0x4c3c80[_0x20f64d(0x1b2)]??_0x4c3c80[_0x20f64d(0x1f4)]??'string'),'length':_0x4c3c80['length']!=null?String(_0x4c3c80['length']):void 0x0,'nullable':_0x4c3c80[_0x20f64d(0x1e2)]!==!0x0,'source':'a.'+_0x585656,'comment':_0x2a37a2[_0x585656]});}let _0x1ff34c=new Set([_0x20f64d(0x337),_0x20f64d(0x261),_0x20f64d(0x177)]),_0x5c1df7=_0x35f0bb[_0x20f64d(0x22f)](_0xc627f=>!_0x1ff34c[_0x20f64d(0x34b)](_0xc627f[_0x20f64d(0x2c9)])),_0x422e76=_0x35f0bb['filter'](_0x2e073a=>_0x1ff34c['has'](_0x2e073a[_0x20f64d(0x2c9)]));return[..._0x5c1df7,..._0x422e76];}catch{return[];}}function h4(_0x24d328){const _0x1d245b=_0x3ec76d;if(!_0x24d328||typeof _0x24d328!==_0x1d245b(0x287))return;try{return w4(_0x50b202(_0x24d328));}catch{return;}}function u4(_0x23bfee,_0x53ef14){const _0x1582e8=_0x3ec76d;let _0x522a5f=[],_0x2421f9=new Set(),_0x5c6c43=_0x5080f4=>{const _0x280ccb=_0x4875;let _0x2c9c82=_0x5080f4[_0x280ccb(0x192)]+':'+_0x5080f4[_0x280ccb(0x28a)];if(_0x2421f9['has'](_0x2c9c82))return;_0x2421f9[_0x280ccb(0x2f2)](_0x2c9c82),_0x522a5f[_0x280ccb(0x279)](_0x5080f4);};for(let _0x40e592 of _0x23bfee[_0x1582e8(0x2eb)]){let _0xcb3a9c=d(_0x40e592[_0x1582e8(0x28a)],_0x23bfee[_0x1582e8(0x260)]),_0x2c3b74=_0xcb3a9c[_0x1582e8(0x2c0)]('/')?_0xcb3a9c:'/'+_0xcb3a9c,_0x920285=VQ(_0x2c3b74);_0x5c6c43({'method':_0x40e592[_0x1582e8(0x192)][_0x1582e8(0x1bb)](),'path':_0x2c3b74,'summary':_0x40e592[_0x1582e8(0x30f)]??'','dts':{},'tag':'','prefix':_0x53ef14,'ignoreToken':Boolean(_0x40e592['public']),'ignorePerms':Boolean(_0x40e592['ignorePerms']),'perms':r(_0x40e592,_0x23bfee,_0x920285)??[]});}for(let _0x56b442 of _0x23bfee['crud']?.[_0x1582e8(0x328)]??[]){let _0x41c9af='/'+_0x56b442;_0x5c6c43({'method':_0x56b442===_0x1582e8(0x330)?_0x1582e8(0x307):'post','path':_0x41c9af,'summary':m0[_0x56b442]??_0x56b442,'dts':{},'tag':'','prefix':_0x53ef14,'ignoreToken':!0x1,'ignorePerms':!0x1,'perms':r({},_0x23bfee,_0x56b442)??[]});}for(let _0x5bfbd2 of _0x23bfee[_0x1582e8(0x2b2)]?.[_0x1582e8(0x16f)]??[]){let _0x5ab455='/'+_0x5bfbd2;_0x5c6c43({'method':'post','path':_0x5ab455,'summary':_0x5bfbd2,'dts':{},'tag':'','prefix':_0x53ef14,'ignoreToken':!0x1,'ignorePerms':!0x1,'perms':r({},_0x23bfee,_0x5bfbd2)??[]});}return _0x522a5f;}function m4(_0x20283f){const _0x3bb086=_0x3ec76d;let _0xb44e38=b(k4(_0x20283f[_0x3bb086(0x2a2)]),_0x20283f[_0x3bb086(0x260)]),_0x583b30=f4(_0x20283f['prefix']),_0x10eb92=_0x20283f['crud']?.['entity'],_0x513f7f=g4(_0x10eb92),_0x59384a=b4(_0x20283f[_0x3bb086(0x2b2)]?.[_0x3bb086(0x1ae)]);return y4(_0x513f7f,_0x59384a[_0x3bb086(0x267)]),{'module':_0x20283f[_0x3bb086(0x31c)],'side':_0x20283f[_0x3bb086(0x2a2)],'prefix':_0xb44e38,'name':h4(_0x10eb92),'info':{'type':{'name':_0x583b30,'description':_0x20283f[_0x3bb086(0x25c)]??_0x583b30}},'api':u4(_0x20283f,_0xb44e38),'columns':_0x513f7f,'pageQueryOp':_0x59384a,'pageColumns':_0x513f7f};}function c4(_0x330654){const _0x17152e=_0x3ec76d;let _0x363512={};for(let _0x4f3d08 of _0x330654){let _0x44e463=_0x363512[_0x4f3d08[_0x17152e(0x31c)]]??[];_0x44e463['push'](_0x4f3d08),_0x363512[_0x4f3d08[_0x17152e(0x31c)]]=_0x44e463;}return _0x363512;}function N0(){const _0x1f02bb=_0x3ec76d;return Boolean(D[_0x1f02bb(0x18e)]?.['eps']);}function R3(_0x526ba2){const _0x22cf8b=_0x3ec76d;if(!N0())return{};return c4(O(_0x526ba2)[_0x22cf8b(0x196)](m4));}var wQ={'controllers':O,'admin':()=>R3(_0x3ec76d(0x275)),'app':()=>R3('app'),'enabled':N0};import'reflect-metadata';var n0=_0x3ec76d(0x271);function p4(_0x36c3f6,_0x320967){return b(_0x36c3f6,_0x320967==='/'?'':_0x320967);}function d4(_0x29931c){const _0x5bf9f0=_0x3ec76d;if(_0x29931c==null)return;return Array[_0x5bf9f0(0x201)](_0x29931c)?_0x29931c:[_0x29931c];}function n4(_0xab9595,_0x421d2f){const _0x5d5f75=_0x3ec76d;let _0x55fa0f=Reflect[_0x5d5f75(0x304)](n0,_0xab9595)??[];_0x55fa0f[_0x5d5f75(0x279)](_0x421d2f),Reflect[_0x5d5f75(0x1c8)](n0,_0x55fa0f,_0xab9595);}function bQ(_0x2809d8){const _0x113b21=_0x3ec76d;let _0x1a8bb9=_0x2809d8===_0x113b21(0x174)?_0x113b21(0x2b7):_0x2809d8===_0x113b21(0x2af)?_0x113b21(0x1d2):_0x113b21(0x269);return _0x315ebb=>(_0x3738eb,_0x4070dc,_0x21d2a1)=>{const _0x1247a2=_0x113b21;if(_0x4070dc===void 0x0)throw Error(_0x1247a2(0x293)+_0x1a8bb9+_0x1247a2(0x34c));let _0x39b5f4=_0x3738eb[_0x1247a2(0x1df)];Y1(_0x39b5f4,String(_0x4070dc),{'index':_0x21d2a1,'source':_0x2809d8,'schema':_0x315ebb});};}function l4(_0x136fe6){let {api:_0x10d7bf,entity:_0x33aa76,service:_0x5dd9d4,serviceApis:_0x363f2b,before:_0x3ff3f9,pageQueryOp:_0x3259ae,listQueryOp:_0x4ad214,insertParam:_0x20483a,infoIgnoreProperty:_0x5c0555}=_0x136fe6;if(_0x10d7bf==null&&_0x33aa76==null&&_0x5dd9d4==null&&_0x363f2b==null&&_0x3ff3f9==null&&_0x3259ae==null&&_0x4ad214==null&&_0x20483a==null&&_0x5c0555==null)return;return{'api':_0x10d7bf,'entity':_0x33aa76,'service':_0x5dd9d4,'serviceApis':_0x363f2b,'before':_0x3ff3f9,'pageQueryOp':_0x3259ae,'listQueryOp':_0x4ad214,'insertParam':_0x20483a,'infoIgnoreProperty':_0x5c0555};}function yQ(_0xdc0d43=''){let _0x54cbad=typeof _0xdc0d43==='string',_0x52d596=_0x54cbad?{'prefix':_0xdc0d43}:_0xdc0d43;return _0x3381e0=>{const _0x2e48d9=_0x4875;f({'token':_0x3381e0,'useClass':_0x3381e0,'scope':_0x2e48d9(0x2fb)});let _0x9e56a9=b1(),_0x41bce0=_0x54cbad&&_0xdc0d43===''||!_0x54cbad&&(_0x52d596['prefix']==null||_0x52d596[_0x2e48d9(0x260)]===''),_0x27d1f3=w(_0x41bce0&&_0x9e56a9?.['file']?g1(_0x9e56a9[_0x2e48d9(0x210)]):_0x52d596[_0x2e48d9(0x260)]??''),_0x1e540e=Reflect[_0x2e48d9(0x304)](n0,_0x3381e0)??[],_0x2b1890=l4(_0x52d596);L1({'token':_0x3381e0,'prefix':_0x27d1f3,'module':_0x52d596[_0x2e48d9(0x31c)]??_0x9e56a9?.[_0x2e48d9(0x31c)]??_0x2e48d9(0x313),'side':_0x52d596[_0x2e48d9(0x2a2)]??_0x9e56a9?.[_0x2e48d9(0x2a2)]??_0x2e48d9(0x275),'description':_0x52d596[_0x2e48d9(0x25c)],'file':_0x9e56a9?.[_0x2e48d9(0x210)],'middleware':d4(_0x52d596[_0x2e48d9(0x1d3)]),'crud':_0x2b1890,'routes':_0x1e540e[_0x2e48d9(0x196)](_0x52310c=>{const _0x140533=_0x2e48d9;let _0x4d569c=U1(_0x3381e0,_0x52310c[_0x140533(0x18f)]),_0xc37b41=x0(_0x4d569c),_0x15f30a=[..._0x52310c[_0x140533(0x1d3)]??[],..._1(_0x3381e0,_0x52310c['handler'])];return{..._0x52310c,'path':p4(_0x27d1f3,_0x52310c[_0x140533(0x28a)]['startsWith']('/')?_0x52310c[_0x140533(0x28a)][_0x140533(0x231)](0x1):_0x52310c[_0x140533(0x28a)]),'params':_0x4d569c,'body':_0xc37b41?.[_0x140533(0x2af)],'query':_0xc37b41?.[_0x140533(0x20d)],'routeParams':_0xc37b41?.[_0x140533(0x174)],'public':N1(_0x3381e0,_0x52310c[_0x140533(0x18f)]),'ignorePerms':E1(_0x3381e0,_0x52310c[_0x140533(0x18f)]),'perms':R1(_0x3381e0,_0x52310c[_0x140533(0x18f)]),'middleware':_0x15f30a['length']?_0x15f30a:void 0x0};})}),Reflect[_0x2e48d9(0x1cc)](n0,_0x3381e0),D1(_0x3381e0),A1(_0x3381e0),C1(_0x3381e0),q1(_0x3381e0),P1(_0x3381e0);};}function gQ(..._0x1178ff){return(_0x1cdc5f,_0x55a7ef)=>{const _0x528960=_0x4875;let _0x8b693a=_0x1cdc5f[_0x528960(0x1df)];K1(_0x8b693a,String(_0x55a7ef),_0x1178ff);};}function A0(_0x37b3ab){return(_0x5266cb='',_0xc7de9a)=>(_0xde48d4,_0x1efbd1)=>{const _0x411361=_0x4875;let _0x55d17e=_0xde48d4['constructor'];n4(_0x55d17e,{'method':_0x37b3ab,'path':_0x5266cb,'handler':String(_0x1efbd1),'summary':_0xc7de9a?.[_0x411361(0x30f)]});};}function hQ(){return(_0x392df0,_0x138b02)=>{const _0x26ef0e=_0x4875;let _0x5aefdc=_0x392df0[_0x26ef0e(0x1df)];T1(_0x5aefdc,String(_0x138b02));};}function uQ(..._0x23fecd){return(_0x4e628d,_0xbfb760)=>{const _0x47b5c3=_0x4875;let _0x5caced=_0x4e628d[_0x47b5c3(0x1df)];I1(_0x5caced,String(_0xbfb760),_0x23fecd);};}function mQ(){return(_0x3089cf,_0x119c51)=>{const _0x1cf7d4=_0x4875;let _0x5c69b=_0x3089cf[_0x1cf7d4(0x1df)];S1(_0x5c69b,String(_0x119c51));};}var cQ=bQ(_0x3ec76d(0x2af)),pQ=bQ('query'),dQ=bQ(_0x3ec76d(0x174)),nQ=A0(_0x3ec76d(0x1bd)),lQ=A0(_0x3ec76d(0x197)),iQ=A0('PUT'),sQ=A0(_0x3ec76d(0x2bd)),oQ=A0(_0x3ec76d(0x27f));class k{[_0x3ec76d(0x1f9)];[_0x3ec76d(0x208)];[_0x3ec76d(0x1b7)];[_0x3ec76d(0x32b)];async[_0x3ec76d(0x1ca)](_0x40c23a,_0x39f885,_0x3d1230,_0x57ea32){const _0x3c6404=_0x3ec76d;this['pluginInfo']=_0x40c23a,this[_0x3c6404(0x208)]=_0x39f885,this[_0x3c6404(0x1b7)]=_0x57ea32?.[_0x3c6404(0x1b7)],this[_0x3c6404(0x32b)]=_0x57ea32?.['pluginService'],await this[_0x3c6404(0x2a1)]();}async[_0x3ec76d(0x2a1)](){}}import{existsSync as _0x1dafa4,readFileSync as _0x1f6318}from'fs';import{createRequire as _0x2f9a38}from'module';import{join as _0xc42d43}from'path';import{createHash as _0x5d5d4b}from'crypto';import{homedir as _0x2e2bc6}from'os';import{join as _0x5a4ea4}from'path';function K0(){const _0x166ac2=_0x3ec76d;let _0x4ceed9=_0x5d5d4b(_0x166ac2(0x1e7))[_0x166ac2(0x2db)](String(D[_0x166ac2(0x1fd)]??_0x166ac2(0x18e)))['digest'](_0x166ac2(0x20c));return _0x5a4ea4(_0x2e2bc6(),_0x166ac2(0x24c),_0x4ceed9);}function _0(){return _0x5a4ea4(K0(),'plugin');}function e(){const _0x1c5995=_0x3ec76d;return _0x5a4ea4(K0(),_0x1c5995(0x283));}function g(_0x297973){return _0x5a4ea4(e(),_0x297973);}var r4=_0x2f9a38(import.meta.url);function a4(_0x149625){if(_0x149625==='vome-plugin-runtime')return{'BasePlugin':k};return r4(_0x149625);}function rQ(_0x48d599){const _0x422732=_0x3ec76d;try{let _0x2efe62=_0x48d599[_0x422732(0x1ce)](/export\s+const\s+Plugin\s*=/g,_0x422732(0x290))[_0x422732(0x1ce)](/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g,'')['replace'](/export\s+const\s+handlers\s*=/g,_0x422732(0x300))[_0x422732(0x1ce)](/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g,'')[_0x422732(0x1ce)](/export\s+class\s+(\w+)/g,_0x422732(0x2ee))[_0x422732(0x1ce)](/export\s+default\s+/g,'')[_0x422732(0x1ce)](/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g,'')[_0x422732(0x1ce)](/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g,'')[_0x422732(0x1ce)](/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g,'({\x20BasePlugin\x20})'),_0x3fd1bf=Function('BasePlugin',_0x422732(0x29f),_0x422732(0x31c),'exports',_0x2efe62+_0x422732(0x336)),_0x3a7162={'exports':{}};return _0x3fd1bf(k,a4,_0x3a7162,_0x3a7162[_0x422732(0x1ff)]);}catch(_0xb7e39e){throw Error('[Plugin]\x20加载失败:\x20'+(_0xb7e39e instanceof Error?_0xb7e39e['message']:String(_0xb7e39e)));}}function aQ(_0x419443){const _0x2a8890=_0x3ec76d;let _0x5652bd=_0xc42d43(g(_0x419443),_0x2a8890(0x346),_0x2a8890(0x2ba));if(_0x1dafa4(_0x5652bd))return _0x1f6318(_0x5652bd,'utf8');let _0x357579=_0xc42d43(_0(),_0x419443);if(!_0x1dafa4(_0x357579))return;try{return JSON[_0x2a8890(0x2e0)](_0x1f6318(_0x357579,'utf8'))[_0x2a8890(0x2d9)]?.[_0x2a8890(0x221)];}catch{return;}}import{existsSync as _0x4e2599,readFileSync as _0x132f7e,readdirSync as _0x8c0af8,statSync as _0x3b6e45}from'fs';import{createRequire as _0x5e6fe5}from'module';import{join as _0x420e4c}from'path';var Q0=new Map(),$2=_0x5e6fe5(import.meta.url);function Z2(_0x582e79){if(_0x582e79==='vome-plugin-runtime')return{'BasePlugin':k};return $2(_0x582e79);}function O3(_0x47fff3){const _0x3ae6d1=_0x3ec76d;return(_0x47fff3['startsWith']('/')?_0x47fff3:'/'+_0x47fff3)[_0x3ae6d1(0x1ce)](/\/+$/,'')||'/';}function x3(_0xfb72a6){const _0x364832=_0x3ec76d;return _0xfb72a6[_0x364832(0x299)]();}function J2(_0x3ed303){const _0x11be57=_0x3ec76d;return _0x3ed303[_0x11be57(0x1ce)](/export\s+const\s+handlers\s*=/g,'var\x20handlers\x20=')[_0x11be57(0x1ce)](/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g,'')['replace'](/export\s+default\s+\{/g,'var\x20handlers\x20=\x20{')['replace'](/export\s+const\s+Plugin\s*=/g,'var\x20Plugin\x20=')[_0x11be57(0x1ce)](/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g,'')['replace'](/export\s+class\s+(\w+)/g,_0x11be57(0x2ee))[_0x11be57(0x1ce)](/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g,'')['replace'](/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g,'')[_0x11be57(0x1ce)](/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g,_0x11be57(0x1a4));}function o0(_0x2fb0a3,_0x70808d=!0x0){const _0x1ee455=_0x3ec76d;let _0x1bf5b6=J2(_0x2fb0a3),_0x41d54=Function(_0x1ee455(0x29d),_0x1ee455(0x29f),_0x1ee455(0x31c),_0x1ee455(0x1ff),_0x1bf5b6+_0x1ee455(0x233)),_0x4f5c79={'exports':{}},_0x530697=_0x41d54(k,Z2,_0x4f5c79,_0x4f5c79[_0x1ee455(0x1ff)]);if(!_0x530697||typeof _0x530697!==_0x1ee455(0x287)){if(_0x70808d)throw Error(_0x1ee455(0x2dd));return{};}return _0x530697;}var $0={'get'(_0xb165db){const _0x1e7bbc=_0x3ec76d;return Q0[_0x1e7bbc(0x307)](_0xb165db);},'list'(){const _0x2bfb6a=_0x3ec76d;return[...Q0[_0x2bfb6a(0x1f2)]()][_0x2bfb6a(0x196)](([_0xc0e8a2,_0x3eec0f])=>({'key':_0xc0e8a2,'manifest':_0x3eec0f[_0x2bfb6a(0x2cb)],'routes':_0x3eec0f[_0x2bfb6a(0x2eb)]}));},'load'(_0x94d54f){const _0x22cc1d=_0x3ec76d;if(!_0x94d54f||!/^[a-zA-Z0-9_-]+$/[_0x22cc1d(0x327)](_0x94d54f))throw Error(_0x22cc1d(0x1da)+_0x94d54f);let _0x5f1b8e=g(_0x94d54f),_0x3b17c9=_0x420e4c(_0x5f1b8e,_0x22cc1d(0x2df));if(!_0x4e2599(_0x3b17c9))throw Error(_0x22cc1d(0x1b6)+_0x94d54f);let _0x2ac2d6=JSON[_0x22cc1d(0x2e0)](_0x132f7e(_0x3b17c9,_0x22cc1d(0x1ba))),_0x32a74a=(_0x2ac2d6[_0x22cc1d(0x2eb)]??[])['map'](_0x2c8538=>({..._0x2c8538,'method':x3(_0x2c8538[_0x22cc1d(0x192)]),'path':O3(_0x2c8538[_0x22cc1d(0x28a)])})),_0x5de946={},_0x336ff2=_0x420e4c(_0x5f1b8e,_0x22cc1d(0x346),'index.js');if(_0x4e2599(_0x336ff2)){let _0x3f063f=_0x132f7e(_0x336ff2,_0x22cc1d(0x1ba));_0x5de946=o0(_0x3f063f,_0x32a74a['length']>0x0);for(let _0x12bcb0 of _0x32a74a)if(typeof _0x5de946[_0x12bcb0[_0x22cc1d(0x18f)]]!==_0x22cc1d(0x22e))throw Error(_0x22cc1d(0x1f5)+_0x94d54f+_0x22cc1d(0x1a6)+_0x12bcb0[_0x22cc1d(0x18f)]);}else{if(_0x32a74a[_0x22cc1d(0x209)])throw Error(_0x22cc1d(0x1f5)+_0x94d54f+_0x22cc1d(0x23a));}return Q0['set'](_0x94d54f,{'manifest':_0x2ac2d6,'handlers':_0x5de946,'routes':_0x32a74a}),Q0[_0x22cc1d(0x307)](_0x94d54f);},'unload'(_0x53edc){const _0x31fc13=_0x3ec76d;Q0[_0x31fc13(0x21b)](_0x53edc);},async 'dispatch'(_0x17edcf,_0x3f7ba9,_0x35be99,_0x3d15e9){const _0x10f4bb=_0x3ec76d;let _0x44af17=Q0[_0x10f4bb(0x307)](_0x17edcf);if(!_0x44af17)return{'ok':!0x1,'status':0x194,'message':_0x10f4bb(0x339)};let _0x20d7a9=x3(_0x3f7ba9),_0x2a57db=O3(_0x35be99),_0x42aed6=_0x44af17['routes']['find'](_0x5408a2=>_0x5408a2[_0x10f4bb(0x192)]===_0x20d7a9&&_0x5408a2[_0x10f4bb(0x28a)]===_0x2a57db);if(!_0x42aed6)return{'ok':!0x1,'status':0x194,'message':_0x10f4bb(0x181)};let _0x116554=_0x44af17['handlers'][_0x42aed6[_0x10f4bb(0x18f)]];if(typeof _0x116554!==_0x10f4bb(0x22e))return{'ok':!0x1,'status':0x1f4,'message':_0x10f4bb(0x258)+_0x42aed6['handler']};try{return{'ok':!0x0,'data':await _0x116554(_0x3d15e9),'route':_0x42aed6};}catch(_0x112678){return{'ok':!0x1,'status':0x1f4,'message':_0x112678 instanceof Error?_0x112678['message']:String(_0x112678),'route':_0x42aed6};}},'bootstrap'(){const _0x412d43=_0x3ec76d;let _0x45634=e();if(!_0x4e2599(_0x45634))return;for(let _0x36e66b of _0x8c0af8(_0x45634)){let _0x4e7ef5=_0x420e4c(_0x45634,_0x36e66b);if(!_0x3b6e45(_0x4e7ef5)['isDirectory']())continue;if(!_0x4e2599(_0x420e4c(_0x4e7ef5,_0x412d43(0x2df))))continue;try{this['load'](_0x36e66b),console[_0x412d43(0x1c3)](_0x412d43(0x230)+_0x36e66b);}catch(_0x477f90){console['warn']('[Module]\x20load\x20failed\x20'+_0x36e66b+':',_0x477f90 instanceof Error?_0x477f90[_0x412d43(0x1a5)]:_0x477f90);}}}};import{existsSync as _0x28a223,statSync as _0x298b74}from'fs';import{join as _0x2be83f,normalize as _0x4c62f0,sep as _0x5f3c5b}from'path';import{Elysia as _0x292f18}from'elysia';var z2='/vome/apps';function G2(_0x1b3070){const _0x4695e7=_0x3ec76d;let _0x4d54c1=_0x1b3070['toLowerCase']();if(_0x4d54c1['endsWith'](_0x4695e7(0x1bf)))return _0x4695e7(0x26a);if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x213))||_0x4d54c1[_0x4695e7(0x31d)]('.mjs'))return'application/javascript;\x20charset=utf-8';if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x191)))return'text/css;\x20charset=utf-8';if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x2e7)))return _0x4695e7(0x20f);if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x1d6)))return _0x4695e7(0x321);if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x234)))return _0x4695e7(0x1dd);if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x296))||_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x173)))return'image/jpeg';if(_0x4d54c1['endsWith'](_0x4695e7(0x2c7)))return'font/woff2';if(_0x4d54c1[_0x4695e7(0x31d)](_0x4695e7(0x1de)))return _0x4695e7(0x21d);if(_0x4d54c1['endsWith'](_0x4695e7(0x1b5)))return _0x4695e7(0x190);return _0x4695e7(0x225);}var $1=new _0x292f18({'name':_0x3ec76d(0x2e2)})[_0x3ec76d(0x307)](z2+'/*',({params:_0x191afa,set:_0xb2da6d})=>{const _0x27c4a5=_0x3ec76d;let _0x2882cd=String(_0x191afa['*']||'')['split']('/')[_0x27c4a5(0x22f)](Boolean);if(!_0x2882cd[_0x27c4a5(0x209)])return _0xb2da6d[_0x27c4a5(0x1e4)]=0x194,'Not\x20Found';let _0x4d579e=_0x2882cd[0x0];if(!/^[a-zA-Z0-9_-]+$/[_0x27c4a5(0x327)](_0x4d579e))return _0xb2da6d[_0x27c4a5(0x1e4)]=0x190,_0x27c4a5(0x250);let _0x2d8936=_0x2be83f(g(_0x4d579e),_0x27c4a5(0x34a));if(!_0x28a223(_0x2d8936)||!_0x298b74(_0x2d8936)[_0x27c4a5(0x28e)]())return _0xb2da6d[_0x27c4a5(0x1e4)]=0x194,_0x27c4a5(0x2b0);let _0x27d900=_0x2882cd[_0x27c4a5(0x231)](0x1)['join']('/')||_0x27c4a5(0x26b);if(_0x27d900[_0x27c4a5(0x31d)]('/'))_0x27d900+=_0x27c4a5(0x26b);let _0x3ffb55=_0x4c62f0(_0x2be83f(_0x2d8936,_0x27d900));if(!_0x3ffb55[_0x27c4a5(0x2c0)](_0x2d8936+_0x5f3c5b)&&_0x3ffb55!==_0x2d8936)return _0xb2da6d[_0x27c4a5(0x1e4)]=0x193,_0x27c4a5(0x314);let _0x31d757=_0x3ffb55;if(_0x28a223(_0x31d757)&&_0x298b74(_0x31d757)[_0x27c4a5(0x28e)]())_0x31d757=_0x2be83f(_0x31d757,_0x27c4a5(0x26b));if(!_0x28a223(_0x31d757)||!_0x298b74(_0x31d757)['isFile']())return _0xb2da6d[_0x27c4a5(0x1e4)]=0x194,_0x27c4a5(0x1ab);return _0xb2da6d[_0x27c4a5(0x205)]['content-type']=G2(_0x31d757),_0xb2da6d[_0x27c4a5(0x205)][_0x27c4a5(0x26f)]=_0x27c4a5(0x32a),_0xb2da6d[_0x27c4a5(0x205)]['access-control-allow-origin']='*',Bun[_0x27c4a5(0x210)](_0x31d757);});import{Elysia as _0x3a683c}from'elysia';function j2(_0x5cf97a){const _0xc5e0bc=_0x3ec76d;return{'code':C['SUCCESS'],'message':_0xc5e0bc(0x248),'data':_0x5cf97a??null};}function r0(_0x5b923a,_0x4be096=C[_0x3ec76d(0x19f)]){return{'code':_0x4be096,'message':_0x5b923a};}async function v3(_0x84257c){const _0x271c5a=_0x3ec76d;let _0x567c27=_0x84257c['params'][_0x271c5a(0x235)];if(!_0x567c27||!/^[a-zA-Z0-9_-]+$/[_0x271c5a(0x327)](_0x567c27))return _0x84257c[_0x271c5a(0x1d8)][_0x271c5a(0x1e4)]=0x190,r0(_0x271c5a(0x30b));let _0x2c91ab=('/'+String(_0x84257c['params']['*']||''))[_0x271c5a(0x1ce)](/\/+/g,'/'),_0x1f6d42=_[_0x271c5a(0x307)](),_0x3d3bf=$0['get'](_0x567c27);if(!_0x3d3bf)return _0x84257c[_0x271c5a(0x1d8)][_0x271c5a(0x1e4)]=0x194,r0(_0x271c5a(0x25a));let _0x549e17=_0x84257c['request']['method'][_0x271c5a(0x299)](),_0x40cdf5=_0x2c91ab[_0x271c5a(0x1ce)](/\/+$/,'')||'/',_0x12673d=_0x3d3bf[_0x271c5a(0x2eb)][_0x271c5a(0x2ef)](_0x3ab0b8=>_0x3ab0b8['method']===_0x549e17&&_0x3ab0b8[_0x271c5a(0x28a)]===_0x40cdf5);if(!_0x12673d)return _0x84257c['set'][_0x271c5a(0x1e4)]=0x194,r0(_0x271c5a(0x181));if(_0x12673d[_0x271c5a(0x343)]&&!_0x1f6d42?.[_0x271c5a(0x30c)]){if(!(_0x1f6d42?.[_0x271c5a(0x343)]??[])['includes'](_0x12673d['perms']))return _0x84257c[_0x271c5a(0x1e4)](0x193);}let _0x49d987=await $0[_0x271c5a(0x24d)](_0x567c27,_0x549e17,_0x2c91ab,{'body':_0x84257c[_0x271c5a(0x2af)],'query':_0x84257c['query']??{},'params':_0x84257c[_0x271c5a(0x174)],'headers':_0x84257c[_0x271c5a(0x243)][_0x271c5a(0x205)],'adminId':_0x1f6d42?.[_0x271c5a(0x312)]});if(!_0x49d987['ok'])return _0x84257c[_0x271c5a(0x1d8)][_0x271c5a(0x1e4)]=_0x49d987[_0x271c5a(0x1e4)],r0(_0x49d987[_0x271c5a(0x1a5)]);return j2(_0x49d987[_0x271c5a(0x221)]);}function Z1(_0x35433d){const _0x444383=_0x3ec76d;return new _0x3a683c({'name':_0x444383(0x331)})[_0x444383(0x21c)](_0x35433d[_0x444383(0x309)])['all']('/admin/ext/:key/*',v3,{'adminAuth':!0x0})[_0x444383(0x27c)](_0x444383(0x1ea),v3,{'adminAuth':!0x0});}import{Elysia as _0x5a9657}from'elysia';function J1(_0x5bed45,_0x285414){const _0x27209f=_0x3ec76d;return new _0x5a9657({'name':_0x5bed45+_0x27209f(0x33a)})[_0x27209f(0x215)]({[_0x5bed45]:{'resolve':_0x285414}})['as']('scoped');}var k3={'name':_0x3ec76d(0x2f9),'version':_0x3ec76d(0x1b1),'description':_0x3ec76d(0x2ea),'license':_0x3ec76d(0x347),'type':_0x3ec76d(0x31c),'files':[_0x3ec76d(0x182),_0x3ec76d(0x25f),_0x3ec76d(0x32e),'typings/admin'],'main':_0x3ec76d(0x178),'types':_0x3ec76d(0x17a),'exports':{'.':{'types':_0x3ec76d(0x17a),'import':'./dist/index.js','default':_0x3ec76d(0x178)},'./server':{'types':'./dist/server/index.d.ts','import':'./dist/server/index.js','default':_0x3ec76d(0x33d)},'./admin':{'types':_0x3ec76d(0x251),'import':'./src/admin/index.ts','default':_0x3ec76d(0x251)},'./admin/*':_0x3ec76d(0x186),'./admin/styles/base.css':_0x3ec76d(0x2d7),'./typings/*':_0x3ec76d(0x249)},'scripts':{'build':_0x3ec76d(0x33f),'build:obfuscate':_0x3ec76d(0x241),'prepare':_0x3ec76d(0x315)},'peerDependencies':{'elysia':_0x3ec76d(0x30a),'reflect-metadata':_0x3ec76d(0x322),'drizzle-orm':_0x3ec76d(0x1ee),'drizzle-zod':_0x3ec76d(0x2d5),'vue':_0x3ec76d(0x236),'vue-router':_0x3ec76d(0x2a8),'pinia':_0x3ec76d(0x21f),'vue-sonner':'>=2.0.0','@vueuse/core':_0x3ec76d(0x23d),'clsx':_0x3ec76d(0x21f),'tailwind-merge':_0x3ec76d(0x21f)},'peerDependenciesMeta':{'drizzle-orm':{'optional':!0x0},'drizzle-zod':{'optional':!0x0},'vue':{'optional':!0x0},'vue-router':{'optional':!0x0},'pinia':{'optional':!0x0},'vue-sonner':{'optional':!0x0},'@vueuse/core':{'optional':!0x0},'clsx':{'optional':!0x0},'tailwind-merge':{'optional':!0x0}},'devDependencies':{'bun-types':_0x3ec76d(0x266),'drizzle-orm':_0x3ec76d(0x266),'drizzle-zod':_0x3ec76d(0x27a),'elysia':_0x3ec76d(0x266),'javascript-obfuscator':_0x3ec76d(0x23c),'reflect-metadata':_0x3ec76d(0x176),'typescript':_0x3ec76d(0x266)},'dependencies':{'@bogeychan/elysia-logger':_0x3ec76d(0x277),'@elysiajs/openapi':_0x3ec76d(0x185),'pino':_0x3ec76d(0x2c8),'pino-pretty':_0x3ec76d(0x2a4)}},n$=k3[_0x3ec76d(0x2f5)];export{K3 as vome,n$ as version,g0 as tableHasDepartmentId,fQ as syncColumnCommentsToPg,X0 as scanFiles,G0 as resolveTenantScope,h0 as resolveDataScope,aQ as readPluginScript,V0 as q,_0 as pPluginPath,e as pModulesPath,g as pModulePath,K0 as pDataPath,TQ as normalizeHost,DQ as noTenant,NQ as noDataScope,$1 as microApps,rQ as loadPluginClass,o0 as loadModuleHandlers,Z0 as listProviders,O as listControllers,y0 as isTenantEnabled,N0 as isEpsEnabled,U0 as isCommException,i as getRepository,P as getEnv,t as getColumnComments,H0 as entitySchemas,J1 as defineAuthMacro,Z1 as createModuleGateway,kQ as columnComments,xQ as baseColumns,L0 as attachCrudRoutes,q as applyRowScopes,u0 as applyDataScopeWhere,c as appendInjectMeta,D as VomeConfig,gQ as Use,p as ScopeEnum,M0 as Repository,C as RES_CODE,pQ as Query,iQ as Put,hQ as Public,FQ as Provide,lQ as Post,uQ as Perms,oQ as Patch,dQ as Param,$0 as ModuleRegistry,s as Logger,K as Ioc,_Q as InjectRepository,jQ as Inject,mQ as IgnorePerms,nQ as Get,wQ as Eps,sQ as Delete,m as DbStore,yQ as Controller,_ as Context,Y0 as CommException,cQ as Body,a as BaseService,k as BasePlugin,n as BaseController,T0 as BASE_COLUMN_COMMENTS,p0 as App};
|
|
1
|
+
// @bun
|
|
2
|
+
// src/core/config.ts
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
|
|
6
|
+
// src/comm/env.ts
|
|
7
|
+
function getEnv() {
|
|
8
|
+
return Bun.env.NODE_ENV === "dev" ? "dev" : "prod";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// src/comm/merge.ts
|
|
12
|
+
function merge(base, override) {
|
|
13
|
+
const result = { ...base };
|
|
14
|
+
for (const key of Object.keys(override)) {
|
|
15
|
+
const baseVal = result[key];
|
|
16
|
+
const overrideVal = override[key];
|
|
17
|
+
if (baseVal && overrideVal && typeof baseVal === "object" && typeof overrideVal === "object" && !Array.isArray(baseVal) && !Array.isArray(overrideVal)) {
|
|
18
|
+
result[key] = merge(baseVal, overrideVal);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
result[key] = overrideVal;
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/core/config.ts
|
|
27
|
+
async function loadConfig(configDir = join(process.cwd(), "src/config")) {
|
|
28
|
+
const envFile = getEnv() === "dev" ? "dev.ts" : "prod.ts";
|
|
29
|
+
const defaultMod = await import(pathToFileURL(join(configDir, "default.ts")).href);
|
|
30
|
+
const envMod = await import(pathToFileURL(join(configDir, envFile)).href);
|
|
31
|
+
return merge(defaultMod.default, envMod.default);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/core/vome-config.ts
|
|
35
|
+
var VomeConfig = await loadConfig();
|
|
36
|
+
// src/core/app.ts
|
|
37
|
+
import { Elysia as Elysia2 } from "elysia";
|
|
38
|
+
|
|
39
|
+
// src/routing/register.ts
|
|
40
|
+
import { Elysia } from "elysia";
|
|
41
|
+
|
|
42
|
+
// src/core/context/index.ts
|
|
43
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
44
|
+
var storage = new AsyncLocalStorage;
|
|
45
|
+
var warnedOutsideRequest = false;
|
|
46
|
+
function resolveClientIp(request) {
|
|
47
|
+
const forwarded = request.headers.get("x-forwarded-for");
|
|
48
|
+
if (forwarded) {
|
|
49
|
+
const first = forwarded.split(",")[0]?.trim();
|
|
50
|
+
if (first)
|
|
51
|
+
return first;
|
|
52
|
+
}
|
|
53
|
+
return request.headers.get("x-real-ip")?.trim() || request.headers.get("cf-connecting-ip")?.trim() || "";
|
|
54
|
+
}
|
|
55
|
+
function initContextFromRequest(request) {
|
|
56
|
+
const url = new URL(request.url);
|
|
57
|
+
const forwardedHost = request.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
|
58
|
+
const hostHeader = request.headers.get("host")?.trim();
|
|
59
|
+
return {
|
|
60
|
+
requestId: crypto.randomUUID(),
|
|
61
|
+
method: request.method,
|
|
62
|
+
path: url.pathname,
|
|
63
|
+
ip: resolveClientIp(request),
|
|
64
|
+
host: forwardedHost || hostHeader || url.host,
|
|
65
|
+
startTime: Date.now()
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function enterContextWith(ctx) {
|
|
69
|
+
storage.enterWith(ctx);
|
|
70
|
+
}
|
|
71
|
+
function getContext() {
|
|
72
|
+
return storage.getStore();
|
|
73
|
+
}
|
|
74
|
+
function assignContext(patch) {
|
|
75
|
+
const store = storage.getStore();
|
|
76
|
+
if (!store) {
|
|
77
|
+
if (getEnv() === "dev" && !warnedOutsideRequest) {
|
|
78
|
+
warnedOutsideRequest = true;
|
|
79
|
+
console.warn("[Context] \u5F53\u524D\u65E0\u8BF7\u6C42\u4E0A\u4E0B\u6587\uFF0C\u5199\u5165\u88AB\u5FFD\u7565\uFF08\u8BF7\u786E\u8BA4 asyncContextManager \u5DF2\u542F\u7528\uFF09");
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
Object.assign(store, patch);
|
|
84
|
+
}
|
|
85
|
+
function runContext(ctx, fn) {
|
|
86
|
+
return storage.run(ctx, fn);
|
|
87
|
+
}
|
|
88
|
+
var Context = Object.assign(assignContext, {
|
|
89
|
+
get: getContext,
|
|
90
|
+
run: runContext
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/ioc/container.ts
|
|
94
|
+
import"reflect-metadata";
|
|
95
|
+
|
|
96
|
+
// src/ioc/metadata.ts
|
|
97
|
+
var INJECT_METADATA_KEY = "vome:inject";
|
|
98
|
+
var providers = new Map;
|
|
99
|
+
function registerProvider(meta) {
|
|
100
|
+
providers.set(meta.token, meta);
|
|
101
|
+
}
|
|
102
|
+
function getProvider(token) {
|
|
103
|
+
return providers.get(token);
|
|
104
|
+
}
|
|
105
|
+
function listProviders() {
|
|
106
|
+
const seen = new Set;
|
|
107
|
+
const list = [];
|
|
108
|
+
for (const meta of providers.values()) {
|
|
109
|
+
if (seen.has(meta.useClass))
|
|
110
|
+
continue;
|
|
111
|
+
seen.add(meta.useClass);
|
|
112
|
+
list.push(meta);
|
|
113
|
+
}
|
|
114
|
+
return list;
|
|
115
|
+
}
|
|
116
|
+
function tokenLabel(token) {
|
|
117
|
+
if (typeof token === "string" || typeof token === "symbol")
|
|
118
|
+
return String(token);
|
|
119
|
+
return token.name || "(anonymous)";
|
|
120
|
+
}
|
|
121
|
+
function appendInjectMeta(target, inject) {
|
|
122
|
+
const list = Reflect.getMetadata(INJECT_METADATA_KEY, target) ?? [];
|
|
123
|
+
list.push(inject);
|
|
124
|
+
Reflect.defineMetadata(INJECT_METADATA_KEY, list, target);
|
|
125
|
+
}
|
|
126
|
+
function getInjectMetas(target) {
|
|
127
|
+
return Reflect.getMetadata(INJECT_METADATA_KEY, target) ?? [];
|
|
128
|
+
}
|
|
129
|
+
function resetProviders() {
|
|
130
|
+
providers.clear();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/ioc/scope.ts
|
|
134
|
+
var ScopeEnum;
|
|
135
|
+
((ScopeEnum2) => {
|
|
136
|
+
ScopeEnum2["Singleton"] = "singleton";
|
|
137
|
+
ScopeEnum2["Request"] = "request";
|
|
138
|
+
ScopeEnum2["Prototype"] = "prototype";
|
|
139
|
+
})(ScopeEnum ||= {});
|
|
140
|
+
|
|
141
|
+
// src/ioc/container.ts
|
|
142
|
+
var singletons = new Map;
|
|
143
|
+
var creating = new Set;
|
|
144
|
+
var requestCaches = new WeakMap;
|
|
145
|
+
function injectProperties(instance, useClass) {
|
|
146
|
+
for (const meta of getInjectMetas(useClass)) {
|
|
147
|
+
const { propertyKey, token: dep, resolve } = meta;
|
|
148
|
+
if (!resolve && dep == null) {
|
|
149
|
+
throw new Error(`[Ioc] ${String(propertyKey)} \u7F3A\u5C11 token \u6216 resolve`);
|
|
150
|
+
}
|
|
151
|
+
const value = resolve ? resolve() : Ioc.get(dep);
|
|
152
|
+
instance[propertyKey] = value;
|
|
153
|
+
const bind = instance.bindEntity;
|
|
154
|
+
if (resolve && typeof bind === "function") {
|
|
155
|
+
bind.call(instance, value);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function createInstance(useClass) {
|
|
160
|
+
if (creating.has(useClass)) {
|
|
161
|
+
throw new Error(`[Ioc] \u68C0\u6D4B\u5230\u5FAA\u73AF\u4F9D\u8D56: ${useClass.name}`);
|
|
162
|
+
}
|
|
163
|
+
creating.add(useClass);
|
|
164
|
+
try {
|
|
165
|
+
const instance = new useClass;
|
|
166
|
+
injectProperties(instance, useClass);
|
|
167
|
+
return instance;
|
|
168
|
+
} finally {
|
|
169
|
+
creating.delete(useClass);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function getSingleton(useClass) {
|
|
173
|
+
const cached = singletons.get(useClass);
|
|
174
|
+
if (cached)
|
|
175
|
+
return cached;
|
|
176
|
+
const instance = createInstance(useClass);
|
|
177
|
+
singletons.set(useClass, instance);
|
|
178
|
+
return instance;
|
|
179
|
+
}
|
|
180
|
+
function getRequestCache() {
|
|
181
|
+
const ctx = Context.get();
|
|
182
|
+
if (!ctx) {
|
|
183
|
+
throw new Error("[Ioc] Request \u4F5C\u7528\u57DF\u987B\u5728\u8BF7\u6C42\u4E0A\u4E0B\u6587\u4E2D\u89E3\u6790\uFF08\u8BF7\u786E\u8BA4 asyncContextManager.enable\uFF09");
|
|
184
|
+
}
|
|
185
|
+
let cache = requestCaches.get(ctx);
|
|
186
|
+
if (!cache) {
|
|
187
|
+
cache = new Map;
|
|
188
|
+
requestCaches.set(ctx, cache);
|
|
189
|
+
}
|
|
190
|
+
return cache;
|
|
191
|
+
}
|
|
192
|
+
function getRequestScoped(useClass) {
|
|
193
|
+
const cache = getRequestCache();
|
|
194
|
+
const cached = cache.get(useClass);
|
|
195
|
+
if (cached)
|
|
196
|
+
return cached;
|
|
197
|
+
const instance = createInstance(useClass);
|
|
198
|
+
cache.set(useClass, instance);
|
|
199
|
+
return instance;
|
|
200
|
+
}
|
|
201
|
+
function resolveByScope(useClass, scope) {
|
|
202
|
+
switch (scope) {
|
|
203
|
+
case "singleton" /* Singleton */:
|
|
204
|
+
return getSingleton(useClass);
|
|
205
|
+
case "prototype" /* Prototype */:
|
|
206
|
+
return createInstance(useClass);
|
|
207
|
+
case "request" /* Request */:
|
|
208
|
+
return getRequestScoped(useClass);
|
|
209
|
+
default:
|
|
210
|
+
throw new Error(`[Ioc] \u672A\u77E5\u4F5C\u7528\u57DF: ${scope}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function resolveMeta(token) {
|
|
214
|
+
const meta = getProvider(token);
|
|
215
|
+
if (!meta) {
|
|
216
|
+
throw new Error(`[Ioc] \u672A\u6CE8\u518C\u7684 Provider: ${tokenLabel(token)}`);
|
|
217
|
+
}
|
|
218
|
+
return meta;
|
|
219
|
+
}
|
|
220
|
+
function bootstrapIoc() {
|
|
221
|
+
for (const { useClass, scope } of listProviders()) {
|
|
222
|
+
if (scope === "singleton" /* Singleton */) {
|
|
223
|
+
getSingleton(useClass);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
console.log(`[Ioc] bootstrap \u2190 ${singletons.size} singleton(s)`);
|
|
227
|
+
}
|
|
228
|
+
function get(token) {
|
|
229
|
+
const meta = resolveMeta(token);
|
|
230
|
+
return resolveByScope(meta.useClass, meta.scope);
|
|
231
|
+
}
|
|
232
|
+
function set(token, instance) {
|
|
233
|
+
if (typeof token === "function") {
|
|
234
|
+
registerProvider({
|
|
235
|
+
token,
|
|
236
|
+
useClass: token,
|
|
237
|
+
scope: "singleton" /* Singleton */
|
|
238
|
+
});
|
|
239
|
+
singletons.set(token, instance);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const ctor = instance?.constructor;
|
|
243
|
+
if (!ctor || ctor === Object) {
|
|
244
|
+
throw new Error(`[Ioc] Ioc.set(${tokenLabel(token)}) \u9700\u8981 class \u5B9E\u4F8B\uFF0C\u4EE5\u4FBF\u786E\u5B9A useClass`);
|
|
245
|
+
}
|
|
246
|
+
registerProvider({ token, useClass: ctor, scope: "singleton" /* Singleton */ });
|
|
247
|
+
registerProvider({ token: ctor, useClass: ctor, scope: "singleton" /* Singleton */ });
|
|
248
|
+
singletons.set(ctor, instance);
|
|
249
|
+
}
|
|
250
|
+
function resetIoc() {
|
|
251
|
+
singletons.clear();
|
|
252
|
+
creating.clear();
|
|
253
|
+
resetProviders();
|
|
254
|
+
}
|
|
255
|
+
var Ioc = {
|
|
256
|
+
get,
|
|
257
|
+
set
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// src/routing/metadata.ts
|
|
261
|
+
import"reflect-metadata";
|
|
262
|
+
var controllers = new Map;
|
|
263
|
+
function registerController(meta) {
|
|
264
|
+
controllers.set(meta.token, meta);
|
|
265
|
+
}
|
|
266
|
+
function listControllers(side) {
|
|
267
|
+
const all = [...controllers.values()];
|
|
268
|
+
return side ? all.filter((c) => c.side === side) : all;
|
|
269
|
+
}
|
|
270
|
+
var ROUTE_PARAMS_KEY = "vome:controller:route-params";
|
|
271
|
+
var ROUTE_PUBLIC_KEY = "vome:controller:route-public";
|
|
272
|
+
var ROUTE_MW_KEY = "vome:controller:route-middleware";
|
|
273
|
+
var ROUTE_PERMS_KEY = "vome:controller:route-perms";
|
|
274
|
+
var ROUTE_IGNORE_PERMS_KEY = "vome:controller:route-ignore-perms";
|
|
275
|
+
function appendRouteParam(token, handler, param) {
|
|
276
|
+
const map = Reflect.getMetadata(ROUTE_PARAMS_KEY, token) ?? {};
|
|
277
|
+
const list = map[handler] ?? [];
|
|
278
|
+
list.push(param);
|
|
279
|
+
map[handler] = list;
|
|
280
|
+
Reflect.defineMetadata(ROUTE_PARAMS_KEY, map, token);
|
|
281
|
+
}
|
|
282
|
+
function getRouteParams(token, handler) {
|
|
283
|
+
const map = Reflect.getMetadata(ROUTE_PARAMS_KEY, token);
|
|
284
|
+
return map?.[handler] ?? [];
|
|
285
|
+
}
|
|
286
|
+
function clearRouteParams(token) {
|
|
287
|
+
Reflect.deleteMetadata(ROUTE_PARAMS_KEY, token);
|
|
288
|
+
}
|
|
289
|
+
function markRoutePublic(token, handler) {
|
|
290
|
+
const map = Reflect.getMetadata(ROUTE_PUBLIC_KEY, token) ?? {};
|
|
291
|
+
map[handler] = true;
|
|
292
|
+
Reflect.defineMetadata(ROUTE_PUBLIC_KEY, map, token);
|
|
293
|
+
}
|
|
294
|
+
function isRoutePublic(token, handler) {
|
|
295
|
+
const map = Reflect.getMetadata(ROUTE_PUBLIC_KEY, token);
|
|
296
|
+
return !!map?.[handler];
|
|
297
|
+
}
|
|
298
|
+
function clearRoutePublic(token) {
|
|
299
|
+
Reflect.deleteMetadata(ROUTE_PUBLIC_KEY, token);
|
|
300
|
+
}
|
|
301
|
+
function appendRouteMiddleware(token, handler, middleware) {
|
|
302
|
+
const map = Reflect.getMetadata(ROUTE_MW_KEY, token) ?? {};
|
|
303
|
+
map[handler] = [...map[handler] ?? [], ...middleware];
|
|
304
|
+
Reflect.defineMetadata(ROUTE_MW_KEY, map, token);
|
|
305
|
+
}
|
|
306
|
+
function getRouteMiddleware(token, handler) {
|
|
307
|
+
const map = Reflect.getMetadata(ROUTE_MW_KEY, token);
|
|
308
|
+
return map?.[handler] ?? [];
|
|
309
|
+
}
|
|
310
|
+
function clearRouteMiddleware(token) {
|
|
311
|
+
Reflect.deleteMetadata(ROUTE_MW_KEY, token);
|
|
312
|
+
}
|
|
313
|
+
function setRoutePerms(token, handler, perms) {
|
|
314
|
+
const map = Reflect.getMetadata(ROUTE_PERMS_KEY, token) ?? {};
|
|
315
|
+
map[handler] = perms;
|
|
316
|
+
Reflect.defineMetadata(ROUTE_PERMS_KEY, map, token);
|
|
317
|
+
}
|
|
318
|
+
function getRoutePerms(token, handler) {
|
|
319
|
+
const map = Reflect.getMetadata(ROUTE_PERMS_KEY, token);
|
|
320
|
+
return map?.[handler];
|
|
321
|
+
}
|
|
322
|
+
function clearRoutePerms(token) {
|
|
323
|
+
Reflect.deleteMetadata(ROUTE_PERMS_KEY, token);
|
|
324
|
+
}
|
|
325
|
+
function markRouteIgnorePerms(token, handler) {
|
|
326
|
+
const map = Reflect.getMetadata(ROUTE_IGNORE_PERMS_KEY, token) ?? {};
|
|
327
|
+
map[handler] = true;
|
|
328
|
+
Reflect.defineMetadata(ROUTE_IGNORE_PERMS_KEY, map, token);
|
|
329
|
+
}
|
|
330
|
+
function isRouteIgnorePerms(token, handler) {
|
|
331
|
+
const map = Reflect.getMetadata(ROUTE_IGNORE_PERMS_KEY, token);
|
|
332
|
+
return !!map?.[handler];
|
|
333
|
+
}
|
|
334
|
+
function clearRouteIgnorePerms(token) {
|
|
335
|
+
Reflect.deleteMetadata(ROUTE_IGNORE_PERMS_KEY, token);
|
|
336
|
+
}
|
|
337
|
+
function schemaFromParams(params) {
|
|
338
|
+
const schema = {};
|
|
339
|
+
for (const param of params) {
|
|
340
|
+
if (param.source === "body" && param.schema !== undefined)
|
|
341
|
+
schema.body = param.schema;
|
|
342
|
+
if (param.source === "query" && param.schema !== undefined)
|
|
343
|
+
schema.query = param.schema;
|
|
344
|
+
if (param.source === "params" && param.schema !== undefined)
|
|
345
|
+
schema.params = param.schema;
|
|
346
|
+
}
|
|
347
|
+
return Object.keys(schema).length > 0 ? schema : undefined;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// src/routing/openapi-tags.ts
|
|
351
|
+
function openApiTag(module, side) {
|
|
352
|
+
return `${module}.${side}`;
|
|
353
|
+
}
|
|
354
|
+
function sideOrder(side) {
|
|
355
|
+
if (side === "admin")
|
|
356
|
+
return 0;
|
|
357
|
+
if (side === "app")
|
|
358
|
+
return 1;
|
|
359
|
+
return 2;
|
|
360
|
+
}
|
|
361
|
+
function parseTag(tag) {
|
|
362
|
+
const i = tag.lastIndexOf(".");
|
|
363
|
+
if (i < 0)
|
|
364
|
+
return { module: tag, side: "" };
|
|
365
|
+
return { module: tag.slice(0, i), side: tag.slice(i + 1) };
|
|
366
|
+
}
|
|
367
|
+
function buildOpenApiTagDocs() {
|
|
368
|
+
const controllers2 = listControllers();
|
|
369
|
+
const tagMap = new Map;
|
|
370
|
+
const groupMap = new Map;
|
|
371
|
+
for (const meta of controllers2) {
|
|
372
|
+
const tag = openApiTag(meta.module, meta.side);
|
|
373
|
+
if (!tagMap.has(tag)) {
|
|
374
|
+
tagMap.set(tag, {
|
|
375
|
+
name: tag,
|
|
376
|
+
description: `${meta.module} ${meta.side}`,
|
|
377
|
+
"x-displayName": meta.side
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
let set2 = groupMap.get(meta.module);
|
|
381
|
+
if (!set2) {
|
|
382
|
+
set2 = new Set;
|
|
383
|
+
groupMap.set(meta.module, set2);
|
|
384
|
+
}
|
|
385
|
+
set2.add(tag);
|
|
386
|
+
}
|
|
387
|
+
const tags = [...tagMap.values()].sort((a, b) => {
|
|
388
|
+
const pa = parseTag(a.name);
|
|
389
|
+
const pb = parseTag(b.name);
|
|
390
|
+
return pa.module.localeCompare(pb.module) || sideOrder(pa.side) - sideOrder(pb.side);
|
|
391
|
+
});
|
|
392
|
+
const tagGroups = [...groupMap.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([name, set2]) => ({
|
|
393
|
+
name,
|
|
394
|
+
tags: [...set2].sort((a, b) => {
|
|
395
|
+
const sa = parseTag(a).side;
|
|
396
|
+
const sb = parseTag(b).side;
|
|
397
|
+
return sideOrder(sa) - sideOrder(sb);
|
|
398
|
+
})
|
|
399
|
+
}));
|
|
400
|
+
return { tags, tagGroups };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/routing/path-utils.ts
|
|
404
|
+
function normalizePrefix(prefix) {
|
|
405
|
+
if (!prefix)
|
|
406
|
+
return "";
|
|
407
|
+
return prefix.startsWith("/") ? prefix : `/${prefix}`;
|
|
408
|
+
}
|
|
409
|
+
function joinPrefix(...parts) {
|
|
410
|
+
const segments = parts.map((part) => normalizePrefix(part).replace(/^\/+|\/+$/g, "")).filter(Boolean);
|
|
411
|
+
return segments.length ? `/${segments.join("/")}` : "/";
|
|
412
|
+
}
|
|
413
|
+
function getRouteSubPath(routePath, controllerPrefix) {
|
|
414
|
+
const ctrl = normalizePrefix(controllerPrefix).replace(/\/$/, "");
|
|
415
|
+
const full = normalizePrefix(routePath);
|
|
416
|
+
if (!ctrl)
|
|
417
|
+
return full || "/";
|
|
418
|
+
if (full === ctrl)
|
|
419
|
+
return "/";
|
|
420
|
+
if (full.startsWith(`${ctrl}/`))
|
|
421
|
+
return full.slice(ctrl.length) || "/";
|
|
422
|
+
const sub = routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
423
|
+
return sub || "/";
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/routing/perm.ts
|
|
427
|
+
function resolveRoutePerm(module, prefix, action) {
|
|
428
|
+
let resource = prefix.replace(/^\//, "").replace(/\/+/g, ":");
|
|
429
|
+
if (resource === module) {
|
|
430
|
+
resource = module;
|
|
431
|
+
} else if (resource.startsWith(`${module}:`)) {
|
|
432
|
+
resource = resource.slice(module.length + 1);
|
|
433
|
+
}
|
|
434
|
+
const head = `${module}-`;
|
|
435
|
+
if (resource.startsWith(head)) {
|
|
436
|
+
resource = resource.slice(head.length);
|
|
437
|
+
}
|
|
438
|
+
resource = resource.replace(/-/g, ":");
|
|
439
|
+
if (!resource)
|
|
440
|
+
resource = module;
|
|
441
|
+
return `${module}:${resource}:${action}`;
|
|
442
|
+
}
|
|
443
|
+
function actionFromSubPath(subPath) {
|
|
444
|
+
const cleaned = subPath.replace(/^\/+|\/+$/g, "");
|
|
445
|
+
if (!cleaned)
|
|
446
|
+
return "index";
|
|
447
|
+
const parts = cleaned.split("/");
|
|
448
|
+
return parts[parts.length - 1] || "index";
|
|
449
|
+
}
|
|
450
|
+
function effectivePerms(route, meta, action) {
|
|
451
|
+
if (meta.side !== "admin" || route.public || route.ignorePerms)
|
|
452
|
+
return;
|
|
453
|
+
if (route.perms?.length)
|
|
454
|
+
return route.perms;
|
|
455
|
+
const act = action ?? actionFromSubPath(getRouteSubPath(route.path ?? "/", meta.prefix));
|
|
456
|
+
return [resolveRoutePerm(meta.module, meta.prefix, act)];
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// src/routing/register.ts
|
|
460
|
+
var crudRegistrar;
|
|
461
|
+
function setCrudRegistrar(fn) {
|
|
462
|
+
crudRegistrar = fn;
|
|
463
|
+
}
|
|
464
|
+
var SIDE_PREFIX = {
|
|
465
|
+
admin: "/admin",
|
|
466
|
+
app: "/app"
|
|
467
|
+
};
|
|
468
|
+
var ADMIN_GUARD = "adminAuth";
|
|
469
|
+
var APP_GUARD = "auth";
|
|
470
|
+
var ELYSIA_METHODS = {
|
|
471
|
+
GET: "get",
|
|
472
|
+
POST: "post",
|
|
473
|
+
PUT: "put",
|
|
474
|
+
DELETE: "delete",
|
|
475
|
+
PATCH: "patch"
|
|
476
|
+
};
|
|
477
|
+
function getSidePrefix(side) {
|
|
478
|
+
return normalizePrefix(SIDE_PREFIX[side]);
|
|
479
|
+
}
|
|
480
|
+
function buildRouteSchema(route) {
|
|
481
|
+
if (route.params?.length)
|
|
482
|
+
return schemaFromParams(route.params);
|
|
483
|
+
const schema = {};
|
|
484
|
+
if (route.body !== undefined)
|
|
485
|
+
schema.body = route.body;
|
|
486
|
+
if (route.query !== undefined)
|
|
487
|
+
schema.query = route.query;
|
|
488
|
+
if (route.routeParams !== undefined)
|
|
489
|
+
schema.params = route.routeParams;
|
|
490
|
+
return Object.keys(schema).length > 0 ? schema : undefined;
|
|
491
|
+
}
|
|
492
|
+
function assertRouteParams(params, handler, controller) {
|
|
493
|
+
const seen = new Set;
|
|
494
|
+
for (const param of params) {
|
|
495
|
+
if (seen.has(param.source)) {
|
|
496
|
+
const label = param.source === "body" ? "Body" : param.source === "query" ? "Query" : "Param";
|
|
497
|
+
throw new Error(`[Router] ${controller}.${handler} \u91CD\u590D @${label}`);
|
|
498
|
+
}
|
|
499
|
+
seen.add(param.source);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function createParamHandler(instance, handlerName, params) {
|
|
503
|
+
const method = instance[handlerName];
|
|
504
|
+
const bound = method.bind(instance);
|
|
505
|
+
if (!params?.length)
|
|
506
|
+
return bound;
|
|
507
|
+
const sorted = [...params].sort((a, b) => a.index - b.index);
|
|
508
|
+
return (ctx) => {
|
|
509
|
+
const args = sorted.map((param) => {
|
|
510
|
+
if (param.source === "body")
|
|
511
|
+
return ctx.body;
|
|
512
|
+
if (param.source === "query")
|
|
513
|
+
return ctx.query;
|
|
514
|
+
if (param.source === "params")
|
|
515
|
+
return ctx.params;
|
|
516
|
+
throw new Error(`[Router] \u672A\u77E5\u53C2\u6570\u6765\u6E90: ${param.source}`);
|
|
517
|
+
});
|
|
518
|
+
return bound(...args, ctx);
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
function createPermsGuard(codes) {
|
|
522
|
+
return (ctx) => {
|
|
523
|
+
const status = ctx.status;
|
|
524
|
+
const store = Context.get();
|
|
525
|
+
if (store?.isSuper)
|
|
526
|
+
return;
|
|
527
|
+
const held = store?.perms ?? [];
|
|
528
|
+
if (codes.some((code) => held.includes(code)))
|
|
529
|
+
return;
|
|
530
|
+
return status(403);
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function openApiSummary(name, remark) {
|
|
534
|
+
const title = name.replace(/^\/+|\/+$/g, "").split("/").pop() || name;
|
|
535
|
+
return remark ? `${title} ${remark}` : title;
|
|
536
|
+
}
|
|
537
|
+
function buildRouteOptions(route, meta) {
|
|
538
|
+
const schema = buildRouteSchema(route) ?? {};
|
|
539
|
+
const options = {
|
|
540
|
+
...schema,
|
|
541
|
+
detail: {
|
|
542
|
+
tags: [openApiTag(meta.module, meta.side)],
|
|
543
|
+
summary: openApiSummary(route.handler, route.summary)
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
if (meta.side === "admin" && !route.public) {
|
|
547
|
+
options[ADMIN_GUARD] = true;
|
|
548
|
+
}
|
|
549
|
+
if (meta.side === "app" && !route.public) {
|
|
550
|
+
options[APP_GUARD] = true;
|
|
551
|
+
}
|
|
552
|
+
const before = [];
|
|
553
|
+
const perms = effectivePerms(route, meta);
|
|
554
|
+
if (perms?.length)
|
|
555
|
+
before.push(createPermsGuard(perms));
|
|
556
|
+
if (route.middleware?.length)
|
|
557
|
+
before.push(...route.middleware);
|
|
558
|
+
if (before.length)
|
|
559
|
+
options.beforeHandle = before;
|
|
560
|
+
return options;
|
|
561
|
+
}
|
|
562
|
+
function normalizeCrudRouteOpts(opts) {
|
|
563
|
+
if (opts == null)
|
|
564
|
+
return {};
|
|
565
|
+
if (typeof opts === "boolean")
|
|
566
|
+
return { public: opts };
|
|
567
|
+
return opts;
|
|
568
|
+
}
|
|
569
|
+
function registerControllerPlugin(meta, _vomeConfig) {
|
|
570
|
+
const sidePrefix = getSidePrefix(meta.side);
|
|
571
|
+
const pluginPrefix = joinPrefix(sidePrefix, meta.prefix);
|
|
572
|
+
const instance = Ioc.get(meta.token);
|
|
573
|
+
let plugin = new Elysia({
|
|
574
|
+
prefix: pluginPrefix,
|
|
575
|
+
name: meta.token.name,
|
|
576
|
+
tags: [openApiTag(meta.module, meta.side)]
|
|
577
|
+
});
|
|
578
|
+
for (const mw of meta.middleware ?? []) {
|
|
579
|
+
plugin = plugin.onBeforeHandle(mw);
|
|
580
|
+
}
|
|
581
|
+
const autoRoutes = [];
|
|
582
|
+
for (const route of meta.routes) {
|
|
583
|
+
const handler = instance[route.handler];
|
|
584
|
+
if (typeof handler !== "function") {
|
|
585
|
+
throw new Error(`[Router] ${meta.token.name}.${route.handler} \u4E0D\u662F\u6709\u6548 handler`);
|
|
586
|
+
}
|
|
587
|
+
assertRouteParams(route.params ?? [], route.handler, meta.token.name);
|
|
588
|
+
const wrapped = createParamHandler(instance, route.handler, route.params);
|
|
589
|
+
const subPath = getRouteSubPath(route.path, meta.prefix);
|
|
590
|
+
const options = buildRouteOptions(route, meta);
|
|
591
|
+
const method = ELYSIA_METHODS[route.method];
|
|
592
|
+
plugin = plugin[method](subPath, wrapped, options);
|
|
593
|
+
}
|
|
594
|
+
if (meta.crud?.api?.length || meta.crud?.serviceApis?.length) {
|
|
595
|
+
if (!crudRegistrar) {
|
|
596
|
+
throw new Error(`[Router] ${meta.token.name} \u914D\u7F6E\u4E86 api/serviceApis\uFF0C\u4F46\u672A\u627E\u5230 CRUD \u5B9E\u73B0\uFF08@vome-core attachCrudRoutes \u672A\u6302\u8F7D\uFF09`);
|
|
597
|
+
}
|
|
598
|
+
plugin = crudRegistrar(plugin, meta, {
|
|
599
|
+
controller: instance,
|
|
600
|
+
routeOptions: (opts) => {
|
|
601
|
+
const { public: isPublic, action, summary } = normalizeCrudRouteOpts(opts);
|
|
602
|
+
const options = {
|
|
603
|
+
detail: {
|
|
604
|
+
tags: [openApiTag(meta.module, meta.side)],
|
|
605
|
+
summary: openApiSummary(action ?? "action", summary)
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
if (meta.side === "admin" && !isPublic) {
|
|
609
|
+
options[ADMIN_GUARD] = true;
|
|
610
|
+
if (action) {
|
|
611
|
+
const code = resolveRoutePerm(meta.module, meta.prefix, action);
|
|
612
|
+
options.beforeHandle = [createPermsGuard([code])];
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return options;
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
for (const name of meta.crud?.api ?? []) {
|
|
619
|
+
const method = name === "info" ? "GET" : "POST";
|
|
620
|
+
autoRoutes.push({
|
|
621
|
+
method,
|
|
622
|
+
path: joinPrefix(meta.prefix, name),
|
|
623
|
+
handler: name,
|
|
624
|
+
autoCrud: true
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
for (const name of meta.crud?.serviceApis ?? []) {
|
|
628
|
+
autoRoutes.push({
|
|
629
|
+
method: "POST",
|
|
630
|
+
path: joinPrefix(meta.prefix, name),
|
|
631
|
+
handler: name,
|
|
632
|
+
autoCrud: true
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
return { plugin, pluginPrefix, autoRoutes };
|
|
637
|
+
}
|
|
638
|
+
function registerControllers(app, vomeConfig) {
|
|
639
|
+
let result = app;
|
|
640
|
+
let routeCount = 0;
|
|
641
|
+
const lines = [];
|
|
642
|
+
for (const meta of listControllers()) {
|
|
643
|
+
const { plugin, pluginPrefix, autoRoutes } = registerControllerPlugin(meta, vomeConfig);
|
|
644
|
+
result = result.use(plugin);
|
|
645
|
+
for (const route of [...meta.routes, ...autoRoutes]) {
|
|
646
|
+
routeCount += 1;
|
|
647
|
+
const subPath = getRouteSubPath(route.path, meta.prefix);
|
|
648
|
+
const fullPath = subPath === "/" ? pluginPrefix : joinPrefix(pluginPrefix, subPath.replace(/^\//, ""));
|
|
649
|
+
const flag = route.public ? " (public)" : route.autoCrud ? " (crud)" : "";
|
|
650
|
+
lines.push(`${route.method} ${fullPath}${flag}`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if (routeCount > 0) {
|
|
654
|
+
console.log(`[Router] registered \u2190 ${routeCount} route(s)`);
|
|
655
|
+
for (const line of lines)
|
|
656
|
+
console.log(` ${line}`);
|
|
657
|
+
}
|
|
658
|
+
return result;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// src/comm/scan.ts
|
|
662
|
+
var {Glob } = globalThis.Bun;
|
|
663
|
+
var DEFAULT_EXT = /\.tsx?$/;
|
|
664
|
+
async function scanFiles(patterns, options = {}) {
|
|
665
|
+
const { cwd = process.cwd(), ext = DEFAULT_EXT } = options;
|
|
666
|
+
const list = Array.isArray(patterns) ? patterns : [patterns];
|
|
667
|
+
const files = [];
|
|
668
|
+
for (const pattern of list) {
|
|
669
|
+
const glob = new Glob(pattern);
|
|
670
|
+
for await (const path of glob.scan({ cwd, onlyFiles: true })) {
|
|
671
|
+
if (ext.test(path))
|
|
672
|
+
files.push(path);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return [...new Set(files)].sort();
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// src/routing/context.ts
|
|
679
|
+
var context = null;
|
|
680
|
+
function setControllerScanContext(next) {
|
|
681
|
+
context = next;
|
|
682
|
+
}
|
|
683
|
+
function getControllerScanContext() {
|
|
684
|
+
return context;
|
|
685
|
+
}
|
|
686
|
+
function parseModuleFromPath(file) {
|
|
687
|
+
const matched = file.match(/modules\/([^/]+)\/controller\//);
|
|
688
|
+
if (!matched)
|
|
689
|
+
return "unknown";
|
|
690
|
+
return matched[1];
|
|
691
|
+
}
|
|
692
|
+
function parseControllerAutoPrefix(file) {
|
|
693
|
+
const matched = file.replace(/\\/g, "/").match(/modules\/([^/]+)\/controller\/(?:admin|app)\/(.+)\.tsx?$/);
|
|
694
|
+
if (!matched)
|
|
695
|
+
return "";
|
|
696
|
+
const module = matched[1];
|
|
697
|
+
const rest = matched[2].replace(/\/+/g, "/").replace(/^\/|\/$/g, "");
|
|
698
|
+
if (!rest)
|
|
699
|
+
return `/${module}`;
|
|
700
|
+
return `/${module}/${rest}`;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// src/comm/format-time.ts
|
|
704
|
+
var TIME_KEY_RE = /(?:Time|Date|At)$/;
|
|
705
|
+
var ISO_RE = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;
|
|
706
|
+
function formatDateTime(value) {
|
|
707
|
+
const d = value instanceof Date ? value : new Date(value);
|
|
708
|
+
if (Number.isNaN(d.getTime()))
|
|
709
|
+
return String(value);
|
|
710
|
+
return new Intl.DateTimeFormat("sv-SE", {
|
|
711
|
+
timeZone: "Asia/Shanghai",
|
|
712
|
+
year: "numeric",
|
|
713
|
+
month: "2-digit",
|
|
714
|
+
day: "2-digit",
|
|
715
|
+
hour: "2-digit",
|
|
716
|
+
minute: "2-digit",
|
|
717
|
+
second: "2-digit",
|
|
718
|
+
hour12: false
|
|
719
|
+
}).format(d).replace("T", " ");
|
|
720
|
+
}
|
|
721
|
+
function isTimeKey(key) {
|
|
722
|
+
return TIME_KEY_RE.test(key);
|
|
723
|
+
}
|
|
724
|
+
function formatApiDates(data) {
|
|
725
|
+
return walk(data);
|
|
726
|
+
}
|
|
727
|
+
function walk(value, key) {
|
|
728
|
+
if (value == null)
|
|
729
|
+
return value;
|
|
730
|
+
if (value instanceof Date)
|
|
731
|
+
return formatDateTime(value);
|
|
732
|
+
if (typeof value === "string" && key && isTimeKey(key) && ISO_RE.test(value)) {
|
|
733
|
+
return formatDateTime(value);
|
|
734
|
+
}
|
|
735
|
+
if (Array.isArray(value))
|
|
736
|
+
return value.map((item) => walk(item));
|
|
737
|
+
if (typeof value === "object") {
|
|
738
|
+
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
739
|
+
return value;
|
|
740
|
+
const out = {};
|
|
741
|
+
for (const [k, v] of Object.entries(value)) {
|
|
742
|
+
out[k] = walk(v, k);
|
|
743
|
+
}
|
|
744
|
+
return out;
|
|
745
|
+
}
|
|
746
|
+
return value;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// src/routing/base.ts
|
|
750
|
+
var RES_CODE = {
|
|
751
|
+
SUCCESS: 1000,
|
|
752
|
+
ERROR: 1001
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
class BaseController {
|
|
756
|
+
ok(data) {
|
|
757
|
+
const raw = data === undefined ? null : data;
|
|
758
|
+
return {
|
|
759
|
+
code: RES_CODE.SUCCESS,
|
|
760
|
+
message: "success",
|
|
761
|
+
data: raw == null ? raw : formatApiDates(raw)
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
fail(message = "error", code = RES_CODE.ERROR) {
|
|
765
|
+
return { code, message };
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
// src/ioc/decorators.ts
|
|
769
|
+
import"reflect-metadata";
|
|
770
|
+
function normalizeProvideArgs(idOrOptions) {
|
|
771
|
+
if (idOrOptions == null)
|
|
772
|
+
return {};
|
|
773
|
+
if (typeof idOrOptions === "string" || typeof idOrOptions === "symbol") {
|
|
774
|
+
return { id: idOrOptions };
|
|
775
|
+
}
|
|
776
|
+
return idOrOptions;
|
|
777
|
+
}
|
|
778
|
+
function Provide(idOrOptions) {
|
|
779
|
+
return (target) => {
|
|
780
|
+
const options = normalizeProvideArgs(idOrOptions);
|
|
781
|
+
const scope = options.scope ?? "singleton" /* Singleton */;
|
|
782
|
+
registerProvider({ token: target, useClass: target, scope });
|
|
783
|
+
if (options.id != null) {
|
|
784
|
+
registerProvider({ token: options.id, useClass: target, scope });
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function Inject(token) {
|
|
789
|
+
return (target, propertyKey) => {
|
|
790
|
+
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
791
|
+
const injectToken = token ?? designType;
|
|
792
|
+
if (injectToken == null) {
|
|
793
|
+
throw new Error(`[Ioc] @Inject \u65E0\u6CD5\u63A8\u65AD ${String(propertyKey)} \u7684\u7C7B\u578B\uFF0C\u8BF7\u663E\u5F0F\u4F20\u5165 token`);
|
|
794
|
+
}
|
|
795
|
+
appendInjectMeta(target.constructor, {
|
|
796
|
+
propertyKey,
|
|
797
|
+
token: injectToken
|
|
798
|
+
});
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
// src/orm/query-op.ts
|
|
802
|
+
import {
|
|
803
|
+
and,
|
|
804
|
+
arrayContains,
|
|
805
|
+
arrayOverlaps,
|
|
806
|
+
asc,
|
|
807
|
+
desc,
|
|
808
|
+
eq,
|
|
809
|
+
gte,
|
|
810
|
+
inArray,
|
|
811
|
+
like,
|
|
812
|
+
lte,
|
|
813
|
+
or,
|
|
814
|
+
sql
|
|
815
|
+
} from "drizzle-orm";
|
|
816
|
+
function colName(ref) {
|
|
817
|
+
if (typeof ref === "string") {
|
|
818
|
+
const name = ref.includes(".") ? ref.split(".").pop() : ref;
|
|
819
|
+
return { column: name, param: name, none: false };
|
|
820
|
+
}
|
|
821
|
+
const column = ref.column.includes(".") ? ref.column.split(".").pop() : ref.column;
|
|
822
|
+
return {
|
|
823
|
+
column,
|
|
824
|
+
param: ref.requestParam ?? column,
|
|
825
|
+
none: Boolean(ref.none)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function rangeColumn(r) {
|
|
829
|
+
return r.column.includes(".") ? r.column.split(".").pop() : r.column;
|
|
830
|
+
}
|
|
831
|
+
function tableCol(table, name) {
|
|
832
|
+
const col = table[name];
|
|
833
|
+
if (col == null)
|
|
834
|
+
throw new Error(`[QueryOp] \u8868\u65E0\u5B57\u6BB5: ${name}`);
|
|
835
|
+
return col;
|
|
836
|
+
}
|
|
837
|
+
function isBlank(value) {
|
|
838
|
+
return value === undefined || value === null || value === "";
|
|
839
|
+
}
|
|
840
|
+
function compactWhere(result) {
|
|
841
|
+
if (result == null || result === false)
|
|
842
|
+
return [];
|
|
843
|
+
const list = Array.isArray(result) ? result : [result];
|
|
844
|
+
return list.filter((x) => x != null && x !== false);
|
|
845
|
+
}
|
|
846
|
+
var q = {
|
|
847
|
+
between(col, min, max) {
|
|
848
|
+
if (isBlank(min) || isBlank(max))
|
|
849
|
+
return;
|
|
850
|
+
return sql`${col} between ${min} and ${max}`;
|
|
851
|
+
},
|
|
852
|
+
range(col, start, end) {
|
|
853
|
+
const parts = [];
|
|
854
|
+
if (!isBlank(start))
|
|
855
|
+
parts.push(gte(col, start));
|
|
856
|
+
if (!isBlank(end))
|
|
857
|
+
parts.push(lte(col, end));
|
|
858
|
+
if (!parts.length)
|
|
859
|
+
return;
|
|
860
|
+
return parts.length === 1 ? parts[0] : and(...parts);
|
|
861
|
+
},
|
|
862
|
+
eqRest(params, table, map) {
|
|
863
|
+
const out = [];
|
|
864
|
+
for (const [key, value] of Object.entries(params)) {
|
|
865
|
+
if (isBlank(value))
|
|
866
|
+
continue;
|
|
867
|
+
const col = map?.[key] ?? table[key];
|
|
868
|
+
if (col == null)
|
|
869
|
+
continue;
|
|
870
|
+
out.push(eq(col, value));
|
|
871
|
+
}
|
|
872
|
+
return out;
|
|
873
|
+
},
|
|
874
|
+
contains(col, value) {
|
|
875
|
+
if (isBlank(value))
|
|
876
|
+
return;
|
|
877
|
+
const values = Array.isArray(value) ? value : [value];
|
|
878
|
+
if (!values.length)
|
|
879
|
+
return;
|
|
880
|
+
return values.length === 1 ? arrayContains(col, values) : arrayOverlaps(col, values);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
function buildFieldClauses(table, body, op) {
|
|
884
|
+
const clauses = [];
|
|
885
|
+
if (op.keyWordLikeFields?.length && !isBlank(body.keyWord)) {
|
|
886
|
+
const kw = `%${String(body.keyWord)}%`;
|
|
887
|
+
const likes = op.keyWordLikeFields.map((f) => {
|
|
888
|
+
const name = f.includes(".") ? f.split(".").pop() : f;
|
|
889
|
+
return like(tableCol(table, name), kw);
|
|
890
|
+
});
|
|
891
|
+
if (likes.length === 1)
|
|
892
|
+
clauses.push(likes[0]);
|
|
893
|
+
else if (likes.length > 1)
|
|
894
|
+
clauses.push(or(...likes));
|
|
895
|
+
}
|
|
896
|
+
for (const ref of op.fieldEq ?? []) {
|
|
897
|
+
const { column, param } = colName(ref);
|
|
898
|
+
const value = body[param];
|
|
899
|
+
if (isBlank(value))
|
|
900
|
+
continue;
|
|
901
|
+
if (Array.isArray(value)) {
|
|
902
|
+
if (!value.length)
|
|
903
|
+
continue;
|
|
904
|
+
clauses.push(inArray(tableCol(table, column), value));
|
|
905
|
+
} else {
|
|
906
|
+
clauses.push(eq(tableCol(table, column), value));
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
for (const ref of op.fieldLike ?? []) {
|
|
910
|
+
const { column, param } = colName(ref);
|
|
911
|
+
const value = body[param];
|
|
912
|
+
if (isBlank(value))
|
|
913
|
+
continue;
|
|
914
|
+
clauses.push(like(tableCol(table, column), `%${String(value)}%`));
|
|
915
|
+
}
|
|
916
|
+
for (const ref of op.fieldArray ?? []) {
|
|
917
|
+
const { column, param } = colName(ref);
|
|
918
|
+
const clause = q.contains(tableCol(table, column), body[param]);
|
|
919
|
+
if (clause)
|
|
920
|
+
clauses.push(clause);
|
|
921
|
+
}
|
|
922
|
+
for (const r of op.fieldRange ?? []) {
|
|
923
|
+
const col = tableCol(table, rangeColumn(r));
|
|
924
|
+
const clause = q.range(col, body[r.min], body[r.max]);
|
|
925
|
+
if (clause)
|
|
926
|
+
clauses.push(clause);
|
|
927
|
+
}
|
|
928
|
+
return clauses;
|
|
929
|
+
}
|
|
930
|
+
function buildOrderBy(table, body, op) {
|
|
931
|
+
const orderBy = [];
|
|
932
|
+
const orderField = body.order != null ? String(body.order) : undefined;
|
|
933
|
+
const sortDir = body.sort === "asc" || body.sort === "desc" ? body.sort : undefined;
|
|
934
|
+
if (orderField) {
|
|
935
|
+
const col = tableCol(table, orderField);
|
|
936
|
+
orderBy.push(sortDir === "asc" ? asc(col) : desc(col));
|
|
937
|
+
} else if (op.addOrderBy) {
|
|
938
|
+
for (const [field, dir] of Object.entries(op.addOrderBy)) {
|
|
939
|
+
const name = field.includes(".") ? field.split(".").pop() : field;
|
|
940
|
+
const col = tableCol(table, name);
|
|
941
|
+
orderBy.push(dir === "asc" ? asc(col) : desc(col));
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
return orderBy;
|
|
945
|
+
}
|
|
946
|
+
function needsAdvancedQuery(op) {
|
|
947
|
+
return !!(op?.join?.length || op?.select);
|
|
948
|
+
}
|
|
949
|
+
async function buildQueryOp(table, body, op = {}, request) {
|
|
950
|
+
const clauses = buildFieldClauses(table, body, op);
|
|
951
|
+
const orderBySql = buildOrderBy(table, body, op);
|
|
952
|
+
const ctx = { body, request: request ?? new Request("http://local") };
|
|
953
|
+
if (op.where) {
|
|
954
|
+
clauses.push(...compactWhere(await op.where(ctx)));
|
|
955
|
+
}
|
|
956
|
+
if (op.extend) {
|
|
957
|
+
const qb = {
|
|
958
|
+
andWhere(condition) {
|
|
959
|
+
if (condition != null && condition !== false)
|
|
960
|
+
clauses.push(condition);
|
|
961
|
+
},
|
|
962
|
+
orderBy(...orders) {
|
|
963
|
+
for (const o of orders) {
|
|
964
|
+
if (o != null)
|
|
965
|
+
orderBySql.push(o);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
await op.extend(qb, ctx);
|
|
970
|
+
}
|
|
971
|
+
const where = clauses.length === 0 ? undefined : clauses.length === 1 ? clauses[0] : and(...clauses);
|
|
972
|
+
return { where, orderBySql };
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// src/orm/query-builder.ts
|
|
976
|
+
import {
|
|
977
|
+
and as and4,
|
|
978
|
+
count,
|
|
979
|
+
countDistinct,
|
|
980
|
+
getTableColumns,
|
|
981
|
+
isNotNull,
|
|
982
|
+
isNull,
|
|
983
|
+
sql as sql4
|
|
984
|
+
} from "drizzle-orm";
|
|
985
|
+
|
|
986
|
+
// src/orm/crud-config.ts
|
|
987
|
+
function readCrudConfig() {
|
|
988
|
+
return VomeConfig.vome?.crud ?? {};
|
|
989
|
+
}
|
|
990
|
+
function resolveUpsert(override) {
|
|
991
|
+
return override ?? readCrudConfig().upsert ?? "insert";
|
|
992
|
+
}
|
|
993
|
+
function resolveSoftDelete(override) {
|
|
994
|
+
if (override != null)
|
|
995
|
+
return override;
|
|
996
|
+
return readCrudConfig().softDelete === true;
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
// src/orm/db-store.ts
|
|
1000
|
+
class DbStore {
|
|
1001
|
+
drizzle;
|
|
1002
|
+
client;
|
|
1003
|
+
schema;
|
|
1004
|
+
sql;
|
|
1005
|
+
constructor(drizzle, client, schema, sql2) {
|
|
1006
|
+
this.drizzle = drizzle;
|
|
1007
|
+
this.client = client;
|
|
1008
|
+
this.schema = schema;
|
|
1009
|
+
this.sql = sql2;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// src/orm/data-scope.ts
|
|
1014
|
+
import { and as and3, inArray as inArray2, sql as sql3 } from "drizzle-orm";
|
|
1015
|
+
|
|
1016
|
+
// src/orm/tenant.ts
|
|
1017
|
+
import { and as and2, eq as eq2, sql as sql2 } from "drizzle-orm";
|
|
1018
|
+
var SKIP_KEY = "__skipTenant";
|
|
1019
|
+
function isTenantEnabled() {
|
|
1020
|
+
return VomeConfig.vome?.tenant === true;
|
|
1021
|
+
}
|
|
1022
|
+
function tableHasTenantId(table) {
|
|
1023
|
+
return table.tenantId != null;
|
|
1024
|
+
}
|
|
1025
|
+
function resolveTenantScope() {
|
|
1026
|
+
if (!isTenantEnabled())
|
|
1027
|
+
return "off";
|
|
1028
|
+
const ctx = Context.get();
|
|
1029
|
+
if (ctx?.[SKIP_KEY])
|
|
1030
|
+
return "off";
|
|
1031
|
+
if (ctx?.isSuper)
|
|
1032
|
+
return "all";
|
|
1033
|
+
const raw = ctx?.tenantId;
|
|
1034
|
+
const id = typeof raw === "number" ? raw : Number(raw);
|
|
1035
|
+
if (!Number.isFinite(id) || id <= 0)
|
|
1036
|
+
return "none";
|
|
1037
|
+
return id;
|
|
1038
|
+
}
|
|
1039
|
+
function applyTenantWhere(table, where) {
|
|
1040
|
+
if (!tableHasTenantId(table))
|
|
1041
|
+
return where;
|
|
1042
|
+
const scope = resolveTenantScope();
|
|
1043
|
+
if (scope === "off" || scope === "all")
|
|
1044
|
+
return where;
|
|
1045
|
+
const col = table.tenantId;
|
|
1046
|
+
const tenantClause = scope === "none" ? sql2`false` : eq2(col, scope);
|
|
1047
|
+
if (where && tenantClause)
|
|
1048
|
+
return and2(where, tenantClause);
|
|
1049
|
+
return where ?? tenantClause;
|
|
1050
|
+
}
|
|
1051
|
+
function stampTenantId(table, data) {
|
|
1052
|
+
if (!tableHasTenantId(table))
|
|
1053
|
+
return data;
|
|
1054
|
+
const scope = resolveTenantScope();
|
|
1055
|
+
if (typeof scope !== "number")
|
|
1056
|
+
return data;
|
|
1057
|
+
if (data.tenantId != null)
|
|
1058
|
+
return data;
|
|
1059
|
+
return { ...data, tenantId: scope };
|
|
1060
|
+
}
|
|
1061
|
+
async function noTenant(fn) {
|
|
1062
|
+
const ctx = Context.get();
|
|
1063
|
+
if (!ctx)
|
|
1064
|
+
return fn();
|
|
1065
|
+
const prev = ctx[SKIP_KEY];
|
|
1066
|
+
ctx[SKIP_KEY] = true;
|
|
1067
|
+
try {
|
|
1068
|
+
return await fn();
|
|
1069
|
+
} finally {
|
|
1070
|
+
if (prev === undefined)
|
|
1071
|
+
delete ctx[SKIP_KEY];
|
|
1072
|
+
else
|
|
1073
|
+
ctx[SKIP_KEY] = prev;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
function normalizeHost(host) {
|
|
1077
|
+
if (!host)
|
|
1078
|
+
return "";
|
|
1079
|
+
return host.trim().toLowerCase().replace(/:\d+$/, "");
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// src/orm/data-scope.ts
|
|
1083
|
+
var SKIP_KEY2 = "__skipDataScope";
|
|
1084
|
+
function tableHasDepartmentId(table) {
|
|
1085
|
+
return table.departmentId != null;
|
|
1086
|
+
}
|
|
1087
|
+
function resolveDataScope() {
|
|
1088
|
+
const ctx = Context.get();
|
|
1089
|
+
if (!ctx)
|
|
1090
|
+
return "off";
|
|
1091
|
+
if (ctx[SKIP_KEY2])
|
|
1092
|
+
return "off";
|
|
1093
|
+
if (ctx.isSuper)
|
|
1094
|
+
return "all";
|
|
1095
|
+
const mode = ctx.dataScope;
|
|
1096
|
+
if (mode == null || mode === "")
|
|
1097
|
+
return "off";
|
|
1098
|
+
if (mode === "all")
|
|
1099
|
+
return "all";
|
|
1100
|
+
if (mode === "none")
|
|
1101
|
+
return "none";
|
|
1102
|
+
const raw = ctx.dataScopeDeptIds;
|
|
1103
|
+
const ids = Array.isArray(raw) ? raw.map((id) => Number(id)).filter((id) => Number.isFinite(id) && id > 0) : [];
|
|
1104
|
+
if (!ids.length)
|
|
1105
|
+
return "none";
|
|
1106
|
+
return [...new Set(ids)];
|
|
1107
|
+
}
|
|
1108
|
+
function applyDataScopeWhere(table, where) {
|
|
1109
|
+
if (!tableHasDepartmentId(table))
|
|
1110
|
+
return where;
|
|
1111
|
+
const scope = resolveDataScope();
|
|
1112
|
+
if (scope === "off" || scope === "all")
|
|
1113
|
+
return where;
|
|
1114
|
+
const col = table.departmentId;
|
|
1115
|
+
const clause = scope === "none" ? sql3`false` : inArray2(col, scope);
|
|
1116
|
+
if (where)
|
|
1117
|
+
return and3(where, clause);
|
|
1118
|
+
return clause;
|
|
1119
|
+
}
|
|
1120
|
+
function applyRowScopes(table, where) {
|
|
1121
|
+
return applyDataScopeWhere(table, applyTenantWhere(table, where));
|
|
1122
|
+
}
|
|
1123
|
+
async function noDataScope(fn) {
|
|
1124
|
+
const ctx = Context.get();
|
|
1125
|
+
if (!ctx)
|
|
1126
|
+
return fn();
|
|
1127
|
+
const prev = ctx[SKIP_KEY2];
|
|
1128
|
+
ctx[SKIP_KEY2] = true;
|
|
1129
|
+
try {
|
|
1130
|
+
return await fn();
|
|
1131
|
+
} finally {
|
|
1132
|
+
if (prev === undefined)
|
|
1133
|
+
delete ctx[SKIP_KEY2];
|
|
1134
|
+
else
|
|
1135
|
+
ctx[SKIP_KEY2] = prev;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
// src/orm/query-builder.ts
|
|
1140
|
+
function deletedAtColumn(table) {
|
|
1141
|
+
return table.deletedAt;
|
|
1142
|
+
}
|
|
1143
|
+
function trashClause(table, options) {
|
|
1144
|
+
if (!resolveSoftDelete(options?.softDelete))
|
|
1145
|
+
return;
|
|
1146
|
+
const col = deletedAtColumn(table);
|
|
1147
|
+
if (col == null)
|
|
1148
|
+
return;
|
|
1149
|
+
if (options?.onlyTrashed)
|
|
1150
|
+
return isNotNull(col);
|
|
1151
|
+
if (options?.withTrashed)
|
|
1152
|
+
return;
|
|
1153
|
+
return isNull(col);
|
|
1154
|
+
}
|
|
1155
|
+
function mergeWhere(where, trash) {
|
|
1156
|
+
if (where && trash)
|
|
1157
|
+
return and4(trash, where);
|
|
1158
|
+
return where ?? trash;
|
|
1159
|
+
}
|
|
1160
|
+
function applyJoins(query, main, op) {
|
|
1161
|
+
let next = query;
|
|
1162
|
+
for (const join2 of op.join ?? []) {
|
|
1163
|
+
const table = join2.table;
|
|
1164
|
+
const on = join2.on(main);
|
|
1165
|
+
const type = join2.type ?? "leftJoin";
|
|
1166
|
+
if (type === "innerJoin" || type === "join") {
|
|
1167
|
+
next = next.innerJoin(table, on);
|
|
1168
|
+
} else {
|
|
1169
|
+
next = next.leftJoin(table, on);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return next;
|
|
1173
|
+
}
|
|
1174
|
+
function resolveSelect(main, op) {
|
|
1175
|
+
if (op.select)
|
|
1176
|
+
return op.select;
|
|
1177
|
+
return getTableColumns(main);
|
|
1178
|
+
}
|
|
1179
|
+
function countExpr(main, hasJoin) {
|
|
1180
|
+
const idCol = main.id;
|
|
1181
|
+
if (idCol != null && hasJoin)
|
|
1182
|
+
return countDistinct(idCol);
|
|
1183
|
+
if (idCol != null)
|
|
1184
|
+
return count(idCol);
|
|
1185
|
+
return count(sql4`*`);
|
|
1186
|
+
}
|
|
1187
|
+
async function queryWithOp(main, body, op, options) {
|
|
1188
|
+
const built = await buildQueryOp(main, body, op, options.request);
|
|
1189
|
+
const trash = trashClause(main, options.trash);
|
|
1190
|
+
const where = applyRowScopes(main, mergeWhere(built.where, trash));
|
|
1191
|
+
const select = resolveSelect(main, op);
|
|
1192
|
+
const hasJoin = !!op.join?.length;
|
|
1193
|
+
const db = Ioc.get(DbStore).drizzle;
|
|
1194
|
+
let listQuery = applyJoins(db.select(select).from(main), main, op);
|
|
1195
|
+
if (where)
|
|
1196
|
+
listQuery = listQuery.where(where);
|
|
1197
|
+
if (built.orderBySql.length)
|
|
1198
|
+
listQuery = listQuery.orderBy(...built.orderBySql);
|
|
1199
|
+
if (options.mode === "list") {
|
|
1200
|
+
return await listQuery;
|
|
1201
|
+
}
|
|
1202
|
+
const page = Math.max(1, Number(body.page ?? 1));
|
|
1203
|
+
const size = Math.min(100, Math.max(1, Number(body.size ?? 20)));
|
|
1204
|
+
const offset = (page - 1) * size;
|
|
1205
|
+
const list = await listQuery.limit(size).offset(offset);
|
|
1206
|
+
let countQuery = applyJoins(db.select({ value: countExpr(main, hasJoin) }).from(main), main, op);
|
|
1207
|
+
if (where)
|
|
1208
|
+
countQuery = countQuery.where(where);
|
|
1209
|
+
const rows = await countQuery;
|
|
1210
|
+
const total = Number(rows[0]?.value ?? 0);
|
|
1211
|
+
return { list, pagination: { page, size, total } };
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// src/orm/repository.ts
|
|
1215
|
+
import { and as and5, count as count2, eq as eq3, inArray as inArray3, isNotNull as isNotNull2, isNull as isNull2 } from "drizzle-orm";
|
|
1216
|
+
|
|
1217
|
+
// src/orm/entity-schema.ts
|
|
1218
|
+
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
|
|
1219
|
+
function entitySchemas(table) {
|
|
1220
|
+
return {
|
|
1221
|
+
select: createSelectSchema(table),
|
|
1222
|
+
insert: createInsertSchema(table),
|
|
1223
|
+
update: createUpdateSchema(table)
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// src/orm/repository.ts
|
|
1228
|
+
var WRITE_META_KEYS = ["createTime", "updateTime", "deletedAt"];
|
|
1229
|
+
function sanitizeWritePayload(data) {
|
|
1230
|
+
const raw = data && typeof data === "object" && !Array.isArray(data) ? { ...data } : {};
|
|
1231
|
+
for (const k of WRITE_META_KEYS)
|
|
1232
|
+
delete raw[k];
|
|
1233
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
1234
|
+
if (typeof v !== "string")
|
|
1235
|
+
continue;
|
|
1236
|
+
if (!/^\d{4}-\d{2}-\d{2}/.test(v))
|
|
1237
|
+
continue;
|
|
1238
|
+
const d = new Date(v);
|
|
1239
|
+
if (!Number.isNaN(d.getTime()))
|
|
1240
|
+
raw[k] = d;
|
|
1241
|
+
}
|
|
1242
|
+
return raw;
|
|
1243
|
+
}
|
|
1244
|
+
function isSqlLike(v) {
|
|
1245
|
+
return !!v && typeof v === "object" && v.getSQL != null;
|
|
1246
|
+
}
|
|
1247
|
+
function db() {
|
|
1248
|
+
return Ioc.get(DbStore).drizzle;
|
|
1249
|
+
}
|
|
1250
|
+
function tableId(table) {
|
|
1251
|
+
const id = table.id;
|
|
1252
|
+
if (!id) {
|
|
1253
|
+
throw new Error("[Repository] \u8868\u65E0 id \u5217\uFF0C\u8BF7\u6539\u7528 find(where) / findOne(where)");
|
|
1254
|
+
}
|
|
1255
|
+
return id;
|
|
1256
|
+
}
|
|
1257
|
+
function deletedAtColumn2(table) {
|
|
1258
|
+
return table.deletedAt;
|
|
1259
|
+
}
|
|
1260
|
+
function mergeWhere2(where, trash) {
|
|
1261
|
+
if (where && trash)
|
|
1262
|
+
return and5(trash, where);
|
|
1263
|
+
return where ?? trash;
|
|
1264
|
+
}
|
|
1265
|
+
function trashClause2(table, options) {
|
|
1266
|
+
if (!resolveSoftDelete(options?.softDelete))
|
|
1267
|
+
return;
|
|
1268
|
+
const col = deletedAtColumn2(table);
|
|
1269
|
+
if (col == null)
|
|
1270
|
+
return;
|
|
1271
|
+
if (options?.onlyTrashed)
|
|
1272
|
+
return isNotNull2(col);
|
|
1273
|
+
if (options?.withTrashed)
|
|
1274
|
+
return;
|
|
1275
|
+
return isNull2(col);
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
class Repository {
|
|
1279
|
+
table;
|
|
1280
|
+
schema;
|
|
1281
|
+
constructor(table, schema) {
|
|
1282
|
+
this.table = table;
|
|
1283
|
+
this.schema = schema ?? entitySchemas(table);
|
|
1284
|
+
}
|
|
1285
|
+
supportsSoftDelete() {
|
|
1286
|
+
return deletedAtColumn2(this.table) != null;
|
|
1287
|
+
}
|
|
1288
|
+
scopedWhere(where, options) {
|
|
1289
|
+
return applyRowScopes(this.table, mergeWhere2(where, trashClause2(this.table, options)));
|
|
1290
|
+
}
|
|
1291
|
+
async find(where, options) {
|
|
1292
|
+
const scoped = this.scopedWhere(where, options);
|
|
1293
|
+
let query = db().select().from(this.table);
|
|
1294
|
+
if (scoped)
|
|
1295
|
+
query = query.where(scoped);
|
|
1296
|
+
if (options?.orderBy?.length)
|
|
1297
|
+
query = query.orderBy(...options.orderBy);
|
|
1298
|
+
return await query;
|
|
1299
|
+
}
|
|
1300
|
+
async findOne(where, options) {
|
|
1301
|
+
const [row] = await this.find(where, options);
|
|
1302
|
+
return row;
|
|
1303
|
+
}
|
|
1304
|
+
async findById(id, options) {
|
|
1305
|
+
return this.findOne(eq3(tableId(this.table), id), options);
|
|
1306
|
+
}
|
|
1307
|
+
async count(where, options) {
|
|
1308
|
+
const scoped = this.scopedWhere(where, options);
|
|
1309
|
+
const query = db().select({ value: count2() }).from(this.table);
|
|
1310
|
+
const rows = scoped ? await query.where(scoped) : await query;
|
|
1311
|
+
return Number(rows[0]?.value ?? 0);
|
|
1312
|
+
}
|
|
1313
|
+
async findPage(options) {
|
|
1314
|
+
const { page, size, where, orderBy, withTrashed, onlyTrashed, softDelete } = options;
|
|
1315
|
+
const trashOpts = { withTrashed, onlyTrashed, softDelete };
|
|
1316
|
+
const scoped = this.scopedWhere(where, trashOpts);
|
|
1317
|
+
const offset = (page - 1) * size;
|
|
1318
|
+
let query = db().select().from(this.table);
|
|
1319
|
+
if (scoped)
|
|
1320
|
+
query = query.where(scoped);
|
|
1321
|
+
if (orderBy?.length)
|
|
1322
|
+
query = query.orderBy(...orderBy);
|
|
1323
|
+
const list = await query.limit(size).offset(offset);
|
|
1324
|
+
const total = await this.count(where, trashOpts);
|
|
1325
|
+
return { list, pagination: { page, size, total } };
|
|
1326
|
+
}
|
|
1327
|
+
parseInsert(item) {
|
|
1328
|
+
const stamped = stampTenantId(this.table, sanitizeWritePayload(item));
|
|
1329
|
+
return this.schema.insert.parse(stamped);
|
|
1330
|
+
}
|
|
1331
|
+
async create(data) {
|
|
1332
|
+
if (Array.isArray(data)) {
|
|
1333
|
+
if (!data.length)
|
|
1334
|
+
return [];
|
|
1335
|
+
const values = data.map((item) => this.parseInsert(item));
|
|
1336
|
+
return await db().insert(this.table).values(values).returning();
|
|
1337
|
+
}
|
|
1338
|
+
const [row] = await db().insert(this.table).values(this.parseInsert(data)).returning();
|
|
1339
|
+
return row;
|
|
1340
|
+
}
|
|
1341
|
+
async save(data) {
|
|
1342
|
+
if (Array.isArray(data)) {
|
|
1343
|
+
if (!data.length)
|
|
1344
|
+
return [];
|
|
1345
|
+
const rows = data;
|
|
1346
|
+
const idCol = tableId(this.table);
|
|
1347
|
+
const withId = rows.filter((r) => r?.id != null && r.id !== "");
|
|
1348
|
+
const withoutId = rows.filter((r) => r?.id == null || r.id === "");
|
|
1349
|
+
let existingIds = new Set;
|
|
1350
|
+
if (withId.length) {
|
|
1351
|
+
const found = await this.find(inArray3(idCol, withId.map((r) => r.id)));
|
|
1352
|
+
existingIds = new Set(found.map((r) => r.id));
|
|
1353
|
+
}
|
|
1354
|
+
const toUpdate = [];
|
|
1355
|
+
const toInsert = [...withoutId];
|
|
1356
|
+
for (const r of withId) {
|
|
1357
|
+
if (existingIds.has(r.id))
|
|
1358
|
+
toUpdate.push(r);
|
|
1359
|
+
else
|
|
1360
|
+
toInsert.push(r);
|
|
1361
|
+
}
|
|
1362
|
+
const updated = toUpdate.length ? await this.update(toUpdate) : [];
|
|
1363
|
+
const inserted = toInsert.length ? await this.create(toInsert) : [];
|
|
1364
|
+
return [
|
|
1365
|
+
...Array.isArray(updated) ? updated : updated ? [updated] : [],
|
|
1366
|
+
...Array.isArray(inserted) ? inserted : inserted ? [inserted] : []
|
|
1367
|
+
];
|
|
1368
|
+
}
|
|
1369
|
+
const record = data;
|
|
1370
|
+
const id = record?.id;
|
|
1371
|
+
if (id != null && id !== "") {
|
|
1372
|
+
const existing = await this.findById(id);
|
|
1373
|
+
if (existing) {
|
|
1374
|
+
const { id: _omit, ...patch } = record;
|
|
1375
|
+
const updated = await this.update(eq3(tableId(this.table), id), patch);
|
|
1376
|
+
return updated ?? existing;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
return await this.create(data);
|
|
1380
|
+
}
|
|
1381
|
+
async update(whereOrRows, data) {
|
|
1382
|
+
if (Array.isArray(whereOrRows)) {
|
|
1383
|
+
return this.updateByRows(whereOrRows);
|
|
1384
|
+
}
|
|
1385
|
+
const patch = this.schema.update.parse(sanitizeWritePayload(data));
|
|
1386
|
+
const scoped = applyRowScopes(this.table, whereOrRows);
|
|
1387
|
+
if (!scoped)
|
|
1388
|
+
return;
|
|
1389
|
+
const [row] = await db().update(this.table).set(patch).where(scoped).returning();
|
|
1390
|
+
return row;
|
|
1391
|
+
}
|
|
1392
|
+
async updateByRows(rows) {
|
|
1393
|
+
if (!rows.length)
|
|
1394
|
+
return [];
|
|
1395
|
+
const idCol = tableId(this.table);
|
|
1396
|
+
const groups = new Map;
|
|
1397
|
+
for (const row of rows) {
|
|
1398
|
+
const id = row.id;
|
|
1399
|
+
if (id == null || id === "") {
|
|
1400
|
+
throw new Error("[Repository] \u6279\u91CF\u66F4\u65B0\u6BCF\u6761\u9700\u5E26 id");
|
|
1401
|
+
}
|
|
1402
|
+
const { id: _omit, ...rest } = row;
|
|
1403
|
+
const patch = this.schema.update.parse(sanitizeWritePayload(rest));
|
|
1404
|
+
const key = JSON.stringify(patch);
|
|
1405
|
+
const g = groups.get(key);
|
|
1406
|
+
if (g)
|
|
1407
|
+
g.ids.push(id);
|
|
1408
|
+
else
|
|
1409
|
+
groups.set(key, { ids: [id], patch });
|
|
1410
|
+
}
|
|
1411
|
+
const out = [];
|
|
1412
|
+
for (const { ids, patch } of groups.values()) {
|
|
1413
|
+
const scoped = applyRowScopes(this.table, inArray3(idCol, ids));
|
|
1414
|
+
if (!scoped)
|
|
1415
|
+
continue;
|
|
1416
|
+
const updated = await db().update(this.table).set(patch).where(scoped).returning();
|
|
1417
|
+
out.push(...updated);
|
|
1418
|
+
}
|
|
1419
|
+
return out;
|
|
1420
|
+
}
|
|
1421
|
+
resolveIdWhere(whereOrIds) {
|
|
1422
|
+
if (isSqlLike(whereOrIds)) {
|
|
1423
|
+
return applyRowScopes(this.table, whereOrIds);
|
|
1424
|
+
}
|
|
1425
|
+
const ids = Array.isArray(whereOrIds) ? whereOrIds : [whereOrIds];
|
|
1426
|
+
if (!ids.length)
|
|
1427
|
+
return;
|
|
1428
|
+
return applyRowScopes(this.table, inArray3(tableId(this.table), ids));
|
|
1429
|
+
}
|
|
1430
|
+
async softDelete(whereOrIds) {
|
|
1431
|
+
if (!this.supportsSoftDelete()) {
|
|
1432
|
+
throw new Error("[Repository] \u8868\u65E0 deletedAt\uFF0C\u65E0\u6CD5\u8F6F\u5220\u9664");
|
|
1433
|
+
}
|
|
1434
|
+
const scoped = this.resolveIdWhere(whereOrIds);
|
|
1435
|
+
if (!scoped)
|
|
1436
|
+
return;
|
|
1437
|
+
await db().update(this.table).set({ deletedAt: new Date }).where(scoped);
|
|
1438
|
+
}
|
|
1439
|
+
async restore(whereOrIds) {
|
|
1440
|
+
if (!this.supportsSoftDelete()) {
|
|
1441
|
+
throw new Error("[Repository] \u8868\u65E0 deletedAt\uFF0C\u65E0\u6CD5\u6062\u590D");
|
|
1442
|
+
}
|
|
1443
|
+
const scoped = this.resolveIdWhere(whereOrIds);
|
|
1444
|
+
if (!scoped)
|
|
1445
|
+
return;
|
|
1446
|
+
await db().update(this.table).set({ deletedAt: null }).where(scoped);
|
|
1447
|
+
}
|
|
1448
|
+
async forceDelete(whereOrIds) {
|
|
1449
|
+
const scoped = this.resolveIdWhere(whereOrIds);
|
|
1450
|
+
if (!scoped)
|
|
1451
|
+
return;
|
|
1452
|
+
await db().delete(this.table).where(scoped);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
var repoCache = new WeakMap;
|
|
1456
|
+
function getRepository(table) {
|
|
1457
|
+
const cached = repoCache.get(table);
|
|
1458
|
+
if (cached)
|
|
1459
|
+
return cached;
|
|
1460
|
+
const repo = new Repository(table);
|
|
1461
|
+
repoCache.set(table, repo);
|
|
1462
|
+
return repo;
|
|
1463
|
+
}
|
|
1464
|
+
function InjectRepository(table) {
|
|
1465
|
+
return (target, propertyKey) => {
|
|
1466
|
+
appendInjectMeta(target.constructor, {
|
|
1467
|
+
propertyKey,
|
|
1468
|
+
resolve: () => getRepository(table)
|
|
1469
|
+
});
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
// src/orm/service.ts
|
|
1474
|
+
function isSql(v) {
|
|
1475
|
+
return !!v && typeof v === "object" && v.getSQL != null;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
class BaseService {
|
|
1479
|
+
entity;
|
|
1480
|
+
bindEntity(repo) {
|
|
1481
|
+
if (!this.entity)
|
|
1482
|
+
this.entity = repo;
|
|
1483
|
+
}
|
|
1484
|
+
setEntity(repo) {
|
|
1485
|
+
this.entity = repo;
|
|
1486
|
+
}
|
|
1487
|
+
hasEntity() {
|
|
1488
|
+
return !!this.entity;
|
|
1489
|
+
}
|
|
1490
|
+
getRepo() {
|
|
1491
|
+
return this.requireEntity();
|
|
1492
|
+
}
|
|
1493
|
+
requireEntity() {
|
|
1494
|
+
if (!this.entity) {
|
|
1495
|
+
throw new Error("[BaseService] \u672A\u7ED1\u5B9A\u5B9E\u4F53\uFF0C\u8BF7\u4F7F\u7528 @InjectRepository \u6216 setEntity");
|
|
1496
|
+
}
|
|
1497
|
+
return this.entity;
|
|
1498
|
+
}
|
|
1499
|
+
async modifyBefore(_data, _type) {}
|
|
1500
|
+
async modifyAfter(_data, _type) {}
|
|
1501
|
+
async add(data, options) {
|
|
1502
|
+
const mode = resolveUpsert(options?.upsert);
|
|
1503
|
+
const payload = Array.isArray(data) ? data.map((item) => item != null && typeof item === "object" ? { ...item } : item) : data != null && typeof data === "object" ? { ...data } : data;
|
|
1504
|
+
await this.modifyBefore(payload, "add");
|
|
1505
|
+
const result = mode === "save" ? await this.requireEntity().save(payload) : await this.requireEntity().create(payload);
|
|
1506
|
+
await this.modifyAfter(result ?? payload, "add");
|
|
1507
|
+
return result;
|
|
1508
|
+
}
|
|
1509
|
+
async update(whereOrData, data) {
|
|
1510
|
+
if (Array.isArray(whereOrData)) {
|
|
1511
|
+
const payloads = whereOrData.map((item) => ({ ...item }));
|
|
1512
|
+
await this.modifyBefore(payloads, "update");
|
|
1513
|
+
const result2 = await this.requireEntity().update(payloads);
|
|
1514
|
+
await this.modifyAfter(result2 ?? payloads, "update");
|
|
1515
|
+
return result2;
|
|
1516
|
+
}
|
|
1517
|
+
if (isSql(whereOrData)) {
|
|
1518
|
+
const payload = data != null && typeof data === "object" ? { ...data } : data;
|
|
1519
|
+
await this.modifyBefore(payload, "update");
|
|
1520
|
+
const result2 = await this.requireEntity().update(whereOrData, payload);
|
|
1521
|
+
await this.modifyAfter(result2 ?? payload, "update");
|
|
1522
|
+
return result2;
|
|
1523
|
+
}
|
|
1524
|
+
const row = { ...whereOrData };
|
|
1525
|
+
await this.modifyBefore(row, "update");
|
|
1526
|
+
const result = await this.requireEntity().update([row]);
|
|
1527
|
+
await this.modifyAfter(result ?? row, "update");
|
|
1528
|
+
return Array.isArray(result) ? result[0] : result;
|
|
1529
|
+
}
|
|
1530
|
+
async delete(whereOrIds, options) {
|
|
1531
|
+
const entity = this.requireEntity();
|
|
1532
|
+
await this.modifyBefore(whereOrIds, "delete");
|
|
1533
|
+
const soft = resolveSoftDelete(options?.softDelete);
|
|
1534
|
+
if (options?.force || !soft || !entity.supportsSoftDelete()) {
|
|
1535
|
+
await entity.forceDelete(whereOrIds);
|
|
1536
|
+
} else {
|
|
1537
|
+
await entity.softDelete(whereOrIds);
|
|
1538
|
+
}
|
|
1539
|
+
await this.modifyAfter(whereOrIds, "delete");
|
|
1540
|
+
}
|
|
1541
|
+
restore(whereOrIds) {
|
|
1542
|
+
return this.requireEntity().restore(whereOrIds);
|
|
1543
|
+
}
|
|
1544
|
+
list(where, options) {
|
|
1545
|
+
return this.requireEntity().find(where, options);
|
|
1546
|
+
}
|
|
1547
|
+
info(idOrWhere, options) {
|
|
1548
|
+
const entity = this.requireEntity();
|
|
1549
|
+
if (typeof idOrWhere === "object")
|
|
1550
|
+
return entity.findOne(idOrWhere, options);
|
|
1551
|
+
return entity.findById(idOrWhere, options);
|
|
1552
|
+
}
|
|
1553
|
+
page(query = {}) {
|
|
1554
|
+
const page = Math.max(1, query.page ?? 1);
|
|
1555
|
+
const size = Math.min(100, Math.max(1, query.size ?? 20));
|
|
1556
|
+
return this.requireEntity().findPage({
|
|
1557
|
+
page,
|
|
1558
|
+
size,
|
|
1559
|
+
where: query.where,
|
|
1560
|
+
orderBy: query.orderBy,
|
|
1561
|
+
withTrashed: query.withTrashed,
|
|
1562
|
+
onlyTrashed: query.onlyTrashed,
|
|
1563
|
+
softDelete: query.softDelete
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
// src/routing/crud-summary.ts
|
|
1569
|
+
var CRUD_SUMMARY = {
|
|
1570
|
+
add: "\u65B0\u589E",
|
|
1571
|
+
delete: "\u5220\u9664",
|
|
1572
|
+
update: "\u4FEE\u6539",
|
|
1573
|
+
info: "\u5355\u4E2A\u4FE1\u606F",
|
|
1574
|
+
list: "\u5217\u8868\u67E5\u8BE2",
|
|
1575
|
+
page: "\u5206\u9875\u67E5\u8BE2",
|
|
1576
|
+
restore: "\u6062\u590D"
|
|
1577
|
+
};
|
|
1578
|
+
|
|
1579
|
+
// src/orm/crud-register.ts
|
|
1580
|
+
var CRUD_APIS = [
|
|
1581
|
+
"add",
|
|
1582
|
+
"delete",
|
|
1583
|
+
"update",
|
|
1584
|
+
"info",
|
|
1585
|
+
"list",
|
|
1586
|
+
"page",
|
|
1587
|
+
"restore"
|
|
1588
|
+
];
|
|
1589
|
+
var BEFORE_APIS = new Set(["add", "update", "delete", "restore"]);
|
|
1590
|
+
function omitProps(row, keys) {
|
|
1591
|
+
if (!row || !keys?.length)
|
|
1592
|
+
return row;
|
|
1593
|
+
const next = { ...row };
|
|
1594
|
+
for (const key of keys)
|
|
1595
|
+
delete next[key];
|
|
1596
|
+
return next;
|
|
1597
|
+
}
|
|
1598
|
+
function resolveIds(body) {
|
|
1599
|
+
if (Array.isArray(body)) {
|
|
1600
|
+
return body.map((item) => {
|
|
1601
|
+
if (item != null && typeof item === "object" && "id" in item) {
|
|
1602
|
+
return item.id;
|
|
1603
|
+
}
|
|
1604
|
+
return item;
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
if (body && typeof body === "object") {
|
|
1608
|
+
const o = body;
|
|
1609
|
+
if (Array.isArray(o.ids))
|
|
1610
|
+
return o.ids;
|
|
1611
|
+
if (o.id != null)
|
|
1612
|
+
return [o.id];
|
|
1613
|
+
}
|
|
1614
|
+
return [];
|
|
1615
|
+
}
|
|
1616
|
+
function resolveService(meta) {
|
|
1617
|
+
const crud = meta.crud;
|
|
1618
|
+
const table = crud.entity;
|
|
1619
|
+
if (crud.service) {
|
|
1620
|
+
const svc2 = Ioc.get(crud.service);
|
|
1621
|
+
if (table && !svc2.hasEntity())
|
|
1622
|
+
svc2.setEntity(getRepository(table));
|
|
1623
|
+
return svc2;
|
|
1624
|
+
}
|
|
1625
|
+
if (!table) {
|
|
1626
|
+
throw new Error(`[CRUD] ${meta.token.name} \u9700\u914D\u7F6E entity \u6216 service`);
|
|
1627
|
+
}
|
|
1628
|
+
const svc = new class extends BaseService {
|
|
1629
|
+
};
|
|
1630
|
+
svc.setEntity(getRepository(table));
|
|
1631
|
+
return svc;
|
|
1632
|
+
}
|
|
1633
|
+
function tableOf(svc, meta) {
|
|
1634
|
+
const fromCrud = meta.crud?.entity;
|
|
1635
|
+
if (fromCrud)
|
|
1636
|
+
return fromCrud;
|
|
1637
|
+
return svc.getRepo().table;
|
|
1638
|
+
}
|
|
1639
|
+
var attachCrudRoutes = (plugin, meta, ctx) => {
|
|
1640
|
+
const crud = meta.crud;
|
|
1641
|
+
if (!crud)
|
|
1642
|
+
return plugin;
|
|
1643
|
+
const apis = (crud.api ?? []).filter((a) => CRUD_APIS.includes(a));
|
|
1644
|
+
const serviceApis = crud.serviceApis ?? [];
|
|
1645
|
+
if (!apis.length && !serviceApis.length)
|
|
1646
|
+
return plugin;
|
|
1647
|
+
const responder = ctx.controller instanceof BaseController ? ctx.controller : new BaseController;
|
|
1648
|
+
const needsEntity = apis.length > 0;
|
|
1649
|
+
const svc = needsEntity || crud.service ? resolveService(meta) : undefined;
|
|
1650
|
+
const table = needsEntity && svc ? tableOf(svc, meta) : undefined;
|
|
1651
|
+
const idCol = table ? table.id : undefined;
|
|
1652
|
+
if (needsEntity && idCol == null) {
|
|
1653
|
+
throw new Error(`[CRUD] ${meta.token.name} \u8868\u65E0 id \u5217`);
|
|
1654
|
+
}
|
|
1655
|
+
let next = plugin;
|
|
1656
|
+
const mount = (method, path, action, handler) => {
|
|
1657
|
+
next = next[method](path, handler, ctx.routeOptions({ action, summary: CRUD_SUMMARY[action] }));
|
|
1658
|
+
};
|
|
1659
|
+
const runBefore = async (api, body, request) => {
|
|
1660
|
+
if (!crud.before || !BEFORE_APIS.has(api))
|
|
1661
|
+
return body;
|
|
1662
|
+
await crud.before({ body, request, api });
|
|
1663
|
+
return body;
|
|
1664
|
+
};
|
|
1665
|
+
if (apis.includes("add") && svc) {
|
|
1666
|
+
mount("post", "/add", "add", async ({ body, request }) => {
|
|
1667
|
+
try {
|
|
1668
|
+
const raw = body;
|
|
1669
|
+
if (Array.isArray(raw)) {
|
|
1670
|
+
let list = raw;
|
|
1671
|
+
if (crud.before && BEFORE_APIS.has("add")) {
|
|
1672
|
+
for (let i = 0;i < list.length; i++) {
|
|
1673
|
+
list[i] = await runBefore("add", { ...list[i] ?? {} }, request);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
if (crud.insertParam) {
|
|
1677
|
+
const extra = await crud.insertParam({ body: list[0] ?? {}, request });
|
|
1678
|
+
list = list.map((row2) => ({ ...row2, ...extra }));
|
|
1679
|
+
}
|
|
1680
|
+
const rows = await svc.add(list);
|
|
1681
|
+
return responder.ok(rows);
|
|
1682
|
+
}
|
|
1683
|
+
let data = { ...raw ?? {} };
|
|
1684
|
+
data = await runBefore("add", data, request);
|
|
1685
|
+
if (crud.insertParam) {
|
|
1686
|
+
Object.assign(data, await crud.insertParam({ body: data, request }));
|
|
1687
|
+
}
|
|
1688
|
+
const row = await svc.add(data);
|
|
1689
|
+
return responder.ok(row);
|
|
1690
|
+
} catch (e) {
|
|
1691
|
+
return responder.fail(e instanceof Error ? e.message : "add failed");
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
if (apis.includes("delete") && svc && idCol) {
|
|
1696
|
+
mount("post", "/delete", "delete", async ({ body, request }) => {
|
|
1697
|
+
try {
|
|
1698
|
+
const raw = body;
|
|
1699
|
+
const data = Array.isArray(raw) ? raw : await runBefore("delete", { ...raw ?? {} }, request);
|
|
1700
|
+
const ids = resolveIds(data);
|
|
1701
|
+
if (!ids.length)
|
|
1702
|
+
return responder.fail("ids required");
|
|
1703
|
+
const force = !Array.isArray(data) && !!data.force;
|
|
1704
|
+
await svc.delete(ids, { force });
|
|
1705
|
+
return responder.ok();
|
|
1706
|
+
} catch (e) {
|
|
1707
|
+
return responder.fail(e instanceof Error ? e.message : "delete failed");
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
if (apis.includes("update") && svc && idCol) {
|
|
1712
|
+
mount("post", "/update", "update", async ({ body, request }) => {
|
|
1713
|
+
try {
|
|
1714
|
+
const raw = body;
|
|
1715
|
+
if (Array.isArray(raw)) {
|
|
1716
|
+
let list = raw;
|
|
1717
|
+
if (crud.before && BEFORE_APIS.has("update")) {
|
|
1718
|
+
for (let i = 0;i < list.length; i++) {
|
|
1719
|
+
list[i] = await runBefore("update", { ...list[i] ?? {} }, request);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
const rows = await svc.update(list);
|
|
1723
|
+
return responder.ok(rows);
|
|
1724
|
+
}
|
|
1725
|
+
const data = await runBefore("update", { ...raw ?? {} }, request);
|
|
1726
|
+
const id = data.id;
|
|
1727
|
+
if (id == null)
|
|
1728
|
+
return responder.fail("id required");
|
|
1729
|
+
const row = await svc.update(data);
|
|
1730
|
+
return responder.ok(row);
|
|
1731
|
+
} catch (e) {
|
|
1732
|
+
return responder.fail(e instanceof Error ? e.message : "update failed");
|
|
1733
|
+
}
|
|
1734
|
+
});
|
|
1735
|
+
}
|
|
1736
|
+
if (apis.includes("info") && svc) {
|
|
1737
|
+
mount("get", "/info", "info", async ({ query }) => {
|
|
1738
|
+
try {
|
|
1739
|
+
const id = query?.id;
|
|
1740
|
+
if (id == null || id === "")
|
|
1741
|
+
return responder.fail("id required");
|
|
1742
|
+
const row = await svc.info(id);
|
|
1743
|
+
return responder.ok(omitProps(row, crud.infoIgnoreProperty));
|
|
1744
|
+
} catch (e) {
|
|
1745
|
+
return responder.fail(e instanceof Error ? e.message : "info failed");
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
if (apis.includes("list") && svc && table) {
|
|
1750
|
+
mount("post", "/list", "list", async ({ body, request }) => {
|
|
1751
|
+
try {
|
|
1752
|
+
const payload = body ?? {};
|
|
1753
|
+
const op = crud.listQueryOp ?? {};
|
|
1754
|
+
const trash = {
|
|
1755
|
+
onlyTrashed: payload.onlyTrashed === true,
|
|
1756
|
+
withTrashed: payload.withTrashed === true
|
|
1757
|
+
};
|
|
1758
|
+
if (needsAdvancedQuery(op)) {
|
|
1759
|
+
const list2 = await queryWithOp(table, payload, op, {
|
|
1760
|
+
request,
|
|
1761
|
+
mode: "list",
|
|
1762
|
+
trash
|
|
1763
|
+
});
|
|
1764
|
+
return responder.ok(list2);
|
|
1765
|
+
}
|
|
1766
|
+
const { where, orderBySql } = await buildQueryOp(table, payload, op, request);
|
|
1767
|
+
const list = await svc.list(where, { orderBy: orderBySql, ...trash });
|
|
1768
|
+
return responder.ok(list);
|
|
1769
|
+
} catch (e) {
|
|
1770
|
+
return responder.fail(e instanceof Error ? e.message : "list failed");
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
if (apis.includes("page") && svc && table) {
|
|
1775
|
+
mount("post", "/page", "page", async ({ body, request }) => {
|
|
1776
|
+
try {
|
|
1777
|
+
const payload = body ?? {};
|
|
1778
|
+
const op = crud.pageQueryOp ?? {};
|
|
1779
|
+
const trash = {
|
|
1780
|
+
onlyTrashed: payload.onlyTrashed === true,
|
|
1781
|
+
withTrashed: payload.withTrashed === true
|
|
1782
|
+
};
|
|
1783
|
+
if (needsAdvancedQuery(op)) {
|
|
1784
|
+
const result2 = await queryWithOp(table, payload, op, {
|
|
1785
|
+
request,
|
|
1786
|
+
mode: "page",
|
|
1787
|
+
trash
|
|
1788
|
+
});
|
|
1789
|
+
return responder.ok(result2);
|
|
1790
|
+
}
|
|
1791
|
+
const { where, orderBySql } = await buildQueryOp(table, payload, op, request);
|
|
1792
|
+
const result = await svc.page({
|
|
1793
|
+
page: Number(payload.page ?? 1),
|
|
1794
|
+
size: Number(payload.size ?? 20),
|
|
1795
|
+
where,
|
|
1796
|
+
orderBy: orderBySql,
|
|
1797
|
+
...trash
|
|
1798
|
+
});
|
|
1799
|
+
return responder.ok(result);
|
|
1800
|
+
} catch (e) {
|
|
1801
|
+
return responder.fail(e instanceof Error ? e.message : "page failed");
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
if (apis.includes("restore") && svc && idCol) {
|
|
1806
|
+
mount("post", "/restore", "restore", async ({ body, request }) => {
|
|
1807
|
+
try {
|
|
1808
|
+
const raw = body;
|
|
1809
|
+
const data = Array.isArray(raw) ? raw : await runBefore("restore", { ...raw ?? {} }, request);
|
|
1810
|
+
const ids = resolveIds(data);
|
|
1811
|
+
if (!ids.length)
|
|
1812
|
+
return responder.fail("ids required");
|
|
1813
|
+
await svc.restore(ids);
|
|
1814
|
+
return responder.ok();
|
|
1815
|
+
} catch (e) {
|
|
1816
|
+
return responder.fail(e instanceof Error ? e.message : "restore failed");
|
|
1817
|
+
}
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
if (serviceApis.length) {
|
|
1821
|
+
if (!crud.service) {
|
|
1822
|
+
throw new Error(`[CRUD] ${meta.token.name} \u914D\u7F6E\u4E86 serviceApis\uFF0C\u9700\u540C\u65F6\u914D\u7F6E service`);
|
|
1823
|
+
}
|
|
1824
|
+
const biz = Ioc.get(crud.service);
|
|
1825
|
+
for (const name of serviceApis) {
|
|
1826
|
+
const method = biz[name];
|
|
1827
|
+
if (typeof method !== "function") {
|
|
1828
|
+
throw new Error(`[CRUD] ${crud.service.name}.${name} \u4E0D\u662F\u6709\u6548\u65B9\u6CD5`);
|
|
1829
|
+
}
|
|
1830
|
+
const bound = method.bind(biz);
|
|
1831
|
+
mount("post", `/${name}`, name, async ({ body }) => {
|
|
1832
|
+
try {
|
|
1833
|
+
const result = await bound(body);
|
|
1834
|
+
return responder.ok(result);
|
|
1835
|
+
} catch (e) {
|
|
1836
|
+
return responder.fail(e instanceof Error ? e.message : `${name} failed`);
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
return next;
|
|
1842
|
+
};
|
|
1843
|
+
|
|
1844
|
+
// src/ioc/host.ts
|
|
1845
|
+
import { join as join2 } from "path";
|
|
1846
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
1847
|
+
var SERVICE_PATTERN = "**/modules/*/service/**/*.ts";
|
|
1848
|
+
var CONTROLLER_SCANS = [
|
|
1849
|
+
{ pattern: "**/modules/*/controller/admin/**/*.ts", side: "admin" },
|
|
1850
|
+
{ pattern: "**/modules/*/controller/app/**/*.ts", side: "app" }
|
|
1851
|
+
];
|
|
1852
|
+
async function importWithContext(cwd, file, side) {
|
|
1853
|
+
setControllerScanContext({
|
|
1854
|
+
module: parseModuleFromPath(file),
|
|
1855
|
+
side,
|
|
1856
|
+
file
|
|
1857
|
+
});
|
|
1858
|
+
try {
|
|
1859
|
+
const href = pathToFileURL2(join2(cwd, file)).href;
|
|
1860
|
+
await import(href);
|
|
1861
|
+
} finally {
|
|
1862
|
+
setControllerScanContext(null);
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
async function scanHost() {
|
|
1866
|
+
const cwd = process.cwd();
|
|
1867
|
+
const serviceFiles = await scanFiles(SERVICE_PATTERN, { cwd });
|
|
1868
|
+
for (const file of serviceFiles) {
|
|
1869
|
+
const href = pathToFileURL2(join2(cwd, file)).href;
|
|
1870
|
+
await import(href);
|
|
1871
|
+
}
|
|
1872
|
+
let controllerCount = 0;
|
|
1873
|
+
for (const { pattern, side } of CONTROLLER_SCANS) {
|
|
1874
|
+
const files = await scanFiles(pattern, { cwd });
|
|
1875
|
+
controllerCount += files.length;
|
|
1876
|
+
for (const file of files) {
|
|
1877
|
+
await importWithContext(cwd, file, side);
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
setCrudRegistrar(attachCrudRoutes);
|
|
1881
|
+
console.log(`[Host] crud \u2190 @vome-core/orm`);
|
|
1882
|
+
console.log(`[Host] scan \u2190 ${serviceFiles.length} service, ${controllerCount} controller file(s)`);
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// src/logger/pino.ts
|
|
1886
|
+
import { join as join4 } from "path";
|
|
1887
|
+
import { createPinoLogger } from "@bogeychan/elysia-logger";
|
|
1888
|
+
import pinoPretty from "pino-pretty";
|
|
1889
|
+
|
|
1890
|
+
// src/comm/daily-log.ts
|
|
1891
|
+
import {
|
|
1892
|
+
createWriteStream,
|
|
1893
|
+
mkdirSync,
|
|
1894
|
+
readdirSync,
|
|
1895
|
+
unlinkSync
|
|
1896
|
+
} from "fs";
|
|
1897
|
+
import { join as join3 } from "path";
|
|
1898
|
+
import { Writable } from "stream";
|
|
1899
|
+
var FILE_PATTERN = /^(\d{4}-\d{2}-\d{2})\.log$/;
|
|
1900
|
+
function formatLocalDate(date = new Date) {
|
|
1901
|
+
const y = date.getFullYear();
|
|
1902
|
+
const m = String(date.getMonth() + 1).padStart(2, "0");
|
|
1903
|
+
const d = String(date.getDate()).padStart(2, "0");
|
|
1904
|
+
return `${y}-${m}-${d}`;
|
|
1905
|
+
}
|
|
1906
|
+
function purgeOldLogs(dir, maxDays) {
|
|
1907
|
+
const cutoff = new Date;
|
|
1908
|
+
cutoff.setDate(cutoff.getDate() - maxDays);
|
|
1909
|
+
const cutoffStr = formatLocalDate(cutoff);
|
|
1910
|
+
for (const name of readdirSync(dir)) {
|
|
1911
|
+
const matched = name.match(FILE_PATTERN);
|
|
1912
|
+
if (!matched || matched[1] >= cutoffStr)
|
|
1913
|
+
continue;
|
|
1914
|
+
unlinkSync(join3(dir, name));
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
function openDailyStream(dir, date) {
|
|
1918
|
+
return createWriteStream(join3(dir, `${date}.log`), { flags: "a" });
|
|
1919
|
+
}
|
|
1920
|
+
function createDailyLogStream(dir, maxDays = 30) {
|
|
1921
|
+
mkdirSync(dir, { recursive: true });
|
|
1922
|
+
purgeOldLogs(dir, maxDays);
|
|
1923
|
+
let currentDate = formatLocalDate();
|
|
1924
|
+
let fileStream = openDailyStream(dir, currentDate);
|
|
1925
|
+
return new Writable({
|
|
1926
|
+
write(chunk, _encoding, callback) {
|
|
1927
|
+
const today = formatLocalDate();
|
|
1928
|
+
if (today !== currentDate) {
|
|
1929
|
+
fileStream.end();
|
|
1930
|
+
currentDate = today;
|
|
1931
|
+
fileStream = openDailyStream(dir, currentDate);
|
|
1932
|
+
purgeOldLogs(dir, maxDays);
|
|
1933
|
+
}
|
|
1934
|
+
fileStream.write(chunk, callback);
|
|
1935
|
+
},
|
|
1936
|
+
final(callback) {
|
|
1937
|
+
fileStream.end(callback);
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
// src/logger/pino.ts
|
|
1943
|
+
var pinoInstance;
|
|
1944
|
+
function buildPino() {
|
|
1945
|
+
const logging = VomeConfig.logging ?? {};
|
|
1946
|
+
const level = logging.level ?? "info";
|
|
1947
|
+
if (logging.transport === "file") {
|
|
1948
|
+
const dir = join4(process.cwd(), logging.dir ?? "logging");
|
|
1949
|
+
const maxDays = logging.maxDays ?? 30;
|
|
1950
|
+
return createPinoLogger({
|
|
1951
|
+
level,
|
|
1952
|
+
stream: createDailyLogStream(dir, maxDays)
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
return createPinoLogger({
|
|
1956
|
+
level,
|
|
1957
|
+
stream: pinoPretty({
|
|
1958
|
+
colorize: true,
|
|
1959
|
+
translateTime: "SYS:standard",
|
|
1960
|
+
ignore: "pid,hostname"
|
|
1961
|
+
})
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
function getPinoLogger() {
|
|
1965
|
+
if (!pinoInstance)
|
|
1966
|
+
pinoInstance = buildPino();
|
|
1967
|
+
return pinoInstance;
|
|
1968
|
+
}
|
|
1969
|
+
function resetPinoLogger() {
|
|
1970
|
+
pinoInstance = undefined;
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
// src/logger/logger.ts
|
|
1974
|
+
class Logger {
|
|
1975
|
+
info(msg, ...args) {
|
|
1976
|
+
const log = getPinoLogger();
|
|
1977
|
+
if (args.length)
|
|
1978
|
+
log.info({ args }, msg);
|
|
1979
|
+
else
|
|
1980
|
+
log.info(msg);
|
|
1981
|
+
}
|
|
1982
|
+
warn(msg, ...args) {
|
|
1983
|
+
const log = getPinoLogger();
|
|
1984
|
+
if (args.length)
|
|
1985
|
+
log.warn({ args }, msg);
|
|
1986
|
+
else
|
|
1987
|
+
log.warn(msg);
|
|
1988
|
+
}
|
|
1989
|
+
debug(msg, ...args) {
|
|
1990
|
+
const log = getPinoLogger();
|
|
1991
|
+
if (args.length)
|
|
1992
|
+
log.debug({ args }, msg);
|
|
1993
|
+
else
|
|
1994
|
+
log.debug(msg);
|
|
1995
|
+
}
|
|
1996
|
+
error(msg, ...args) {
|
|
1997
|
+
const log = getPinoLogger();
|
|
1998
|
+
if (msg instanceof Error) {
|
|
1999
|
+
log.error(msg);
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
2002
|
+
if (args[0] instanceof Error) {
|
|
2003
|
+
log.error(args[0], msg);
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
if (args.length)
|
|
2007
|
+
log.error({ args }, msg);
|
|
2008
|
+
else
|
|
2009
|
+
log.error(msg);
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
// src/logger/exception.ts
|
|
2013
|
+
class CommException extends Error {
|
|
2014
|
+
statusCode;
|
|
2015
|
+
code;
|
|
2016
|
+
constructor(message, options) {
|
|
2017
|
+
super(message);
|
|
2018
|
+
this.name = "CommException";
|
|
2019
|
+
this.statusCode = options?.statusCode ?? 200;
|
|
2020
|
+
this.code = options?.code ?? RES_CODE.ERROR;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
function isCommException(error) {
|
|
2024
|
+
return error instanceof CommException;
|
|
2025
|
+
}
|
|
2026
|
+
// src/logger/bootstrap.ts
|
|
2027
|
+
function bootstrapLogger() {
|
|
2028
|
+
getPinoLogger();
|
|
2029
|
+
Ioc.set(Logger, new Logger);
|
|
2030
|
+
}
|
|
2031
|
+
// src/comm/startBanner.ts
|
|
2032
|
+
var VOME_BANNER = `
|
|
2033
|
+
\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
2034
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D
|
|
2035
|
+
\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2557
|
|
2036
|
+
\u2588\u2588\u2557 \u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u255D
|
|
2037
|
+
\u255A\u2588\u2588\u2588\u2554\u255D \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557
|
|
2038
|
+
\u255A\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
2039
|
+
`;
|
|
2040
|
+
function resetViewport() {
|
|
2041
|
+
if (!process.stdout.isTTY)
|
|
2042
|
+
return;
|
|
2043
|
+
process.stdout.write("\x1B[2J\x1B[H");
|
|
2044
|
+
}
|
|
2045
|
+
function printStartupBanner() {
|
|
2046
|
+
resetViewport();
|
|
2047
|
+
const env = getEnv();
|
|
2048
|
+
const port = VomeConfig.system?.port ?? 3001;
|
|
2049
|
+
const docsPath = VomeConfig.openapi?.path ?? "/docs";
|
|
2050
|
+
const baseUrl = `http://localhost:${port}`;
|
|
2051
|
+
console.log(VOME_BANNER);
|
|
2052
|
+
console.log(`\uD83C\uDF0D \u8FD0\u884C\u73AF\u5883: ${env}`);
|
|
2053
|
+
if (env === "dev") {
|
|
2054
|
+
console.log(`\uD83D\uDCE1 \u670D\u52A1\u5730\u5740: ${baseUrl}`);
|
|
2055
|
+
console.log(`\uD83D\uDCDA API\u6587\u6863: ${baseUrl}${docsPath.startsWith("/") ? docsPath : `/${docsPath}`}`);
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
// src/core/host-infra.ts
|
|
2060
|
+
import { access } from "fs/promises";
|
|
2061
|
+
import { join as join5 } from "path";
|
|
2062
|
+
import { pathToFileURL as pathToFileURL3 } from "url";
|
|
2063
|
+
async function exists(abs) {
|
|
2064
|
+
try {
|
|
2065
|
+
await access(abs);
|
|
2066
|
+
return true;
|
|
2067
|
+
} catch {
|
|
2068
|
+
return false;
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
async function importHostModule(relPath) {
|
|
2072
|
+
const abs = join5(process.cwd(), relPath);
|
|
2073
|
+
if (!await exists(abs)) {
|
|
2074
|
+
console.warn(`[Host] skip \u2190 missing ${relPath}`);
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
return await import(pathToFileURL3(abs).href);
|
|
2078
|
+
}
|
|
2079
|
+
async function bootstrapHostInfra() {
|
|
2080
|
+
const dbMod = await importHostModule("src/lib/db/index.ts");
|
|
2081
|
+
if (dbMod?.Db?.bootstrap)
|
|
2082
|
+
await dbMod.Db.bootstrap();
|
|
2083
|
+
const cacheMod = await importHostModule("src/lib/cache/index.ts");
|
|
2084
|
+
if (cacheMod?.Cache?.bootstrap)
|
|
2085
|
+
await cacheMod.Cache.bootstrap();
|
|
2086
|
+
const authMod = await importHostModule("src/lib/auth/index.ts");
|
|
2087
|
+
if (authMod?.Auth?.bootstrap)
|
|
2088
|
+
await authMod.Auth.bootstrap();
|
|
2089
|
+
}
|
|
2090
|
+
async function bootstrapHostTasks() {
|
|
2091
|
+
const mod = await importHostModule("src/lib/task/index.ts");
|
|
2092
|
+
if (mod?.Task?.bootstrap)
|
|
2093
|
+
await mod.Task.bootstrap();
|
|
2094
|
+
}
|
|
2095
|
+
async function bootstrapHostPlugins() {
|
|
2096
|
+
const mod = await importHostModule("src/lib/plugin/index.ts");
|
|
2097
|
+
if (mod?.Plugin?.bootstrap)
|
|
2098
|
+
await mod.Plugin.bootstrap();
|
|
2099
|
+
}
|
|
2100
|
+
async function bootstrapHostModules() {
|
|
2101
|
+
const mod = await importHostModule("src/lib/module/index.ts");
|
|
2102
|
+
if (mod?.Module?.bootstrap)
|
|
2103
|
+
await mod.Module.bootstrap();
|
|
2104
|
+
}
|
|
2105
|
+
async function shutdownHostTasks() {
|
|
2106
|
+
const mod = await importHostModule("src/lib/task/index.ts");
|
|
2107
|
+
if (mod?.Task?.close)
|
|
2108
|
+
await mod.Task.close();
|
|
2109
|
+
}
|
|
2110
|
+
async function shutdownHostInfra() {
|
|
2111
|
+
const cacheMod = await importHostModule("src/lib/cache/index.ts");
|
|
2112
|
+
if (cacheMod?.Cache?.close)
|
|
2113
|
+
await cacheMod.Cache.close();
|
|
2114
|
+
const dbMod = await importHostModule("src/lib/db/index.ts");
|
|
2115
|
+
if (dbMod?.Db?.close)
|
|
2116
|
+
await dbMod.Db.close();
|
|
2117
|
+
}
|
|
2118
|
+
async function applyHostAuthMiddleware(app) {
|
|
2119
|
+
const mod = await importHostModule("src/middleware/index.ts");
|
|
2120
|
+
if (!mod)
|
|
2121
|
+
return app;
|
|
2122
|
+
let next = app;
|
|
2123
|
+
if (mod.webAuth)
|
|
2124
|
+
next = next.use(mod.webAuth);
|
|
2125
|
+
if (mod.adminAuth)
|
|
2126
|
+
next = next.use(mod.adminAuth);
|
|
2127
|
+
if (mod.requestLog)
|
|
2128
|
+
next = next.use(mod.requestLog);
|
|
2129
|
+
if (mod.microApps)
|
|
2130
|
+
next = next.use(mod.microApps);
|
|
2131
|
+
if (mod.moduleGateway)
|
|
2132
|
+
next = next.use(mod.moduleGateway);
|
|
2133
|
+
return next;
|
|
2134
|
+
}
|
|
2135
|
+
|
|
2136
|
+
// src/core/plugins/async-context.ts
|
|
2137
|
+
function applyAsyncContext(app) {
|
|
2138
|
+
const cfg = VomeConfig.asyncContextManager ?? {};
|
|
2139
|
+
if (!cfg.enable)
|
|
2140
|
+
return app;
|
|
2141
|
+
return app.onRequest(({ request }) => {
|
|
2142
|
+
enterContextWith(initContextFromRequest(request));
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
|
|
2146
|
+
// src/core/plugins/error.ts
|
|
2147
|
+
function applyErrorHandler(app) {
|
|
2148
|
+
return app.onError(({ error, set: set2, code }) => {
|
|
2149
|
+
const log = getPinoLogger();
|
|
2150
|
+
if (isCommException(error)) {
|
|
2151
|
+
log.error({ code: error.code }, error.message);
|
|
2152
|
+
set2.status = error.statusCode;
|
|
2153
|
+
return { code: error.code, message: error.message };
|
|
2154
|
+
}
|
|
2155
|
+
if (code === "VALIDATION") {
|
|
2156
|
+
const message = error instanceof Error ? error.message : "validation failed";
|
|
2157
|
+
log.error({ code }, message);
|
|
2158
|
+
set2.status = 422;
|
|
2159
|
+
return { code: RES_CODE.ERROR, message };
|
|
2160
|
+
}
|
|
2161
|
+
if (code === "NOT_FOUND") {
|
|
2162
|
+
set2.status = 404;
|
|
2163
|
+
return { code: RES_CODE.ERROR, message: "not found" };
|
|
2164
|
+
}
|
|
2165
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
2166
|
+
log.error(err);
|
|
2167
|
+
set2.status = 500;
|
|
2168
|
+
return {
|
|
2169
|
+
code: RES_CODE.ERROR,
|
|
2170
|
+
message: getEnv() === "dev" ? err.message : "internal server error"
|
|
2171
|
+
};
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
// src/core/plugins/logging.ts
|
|
2176
|
+
function applyLogging(app) {
|
|
2177
|
+
const log = getPinoLogger();
|
|
2178
|
+
return app.use(log.into({
|
|
2179
|
+
autoLogging: {
|
|
2180
|
+
ignore: (ctx) => Boolean(ctx.isError)
|
|
2181
|
+
}
|
|
2182
|
+
}));
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
// src/core/plugins/openapi.ts
|
|
2186
|
+
import { openapi } from "@elysiajs/openapi";
|
|
2187
|
+
function applyOpenapi(app) {
|
|
2188
|
+
const config = VomeConfig.openapi ?? { enable: false };
|
|
2189
|
+
if (config.enable === false)
|
|
2190
|
+
return app;
|
|
2191
|
+
const path = config.path ?? "/docs";
|
|
2192
|
+
const { tags, tagGroups } = buildOpenApiTagDocs();
|
|
2193
|
+
const userDoc = config.documentation ?? {};
|
|
2194
|
+
const userScalar = config.scalar ?? {};
|
|
2195
|
+
return app.use(openapi({
|
|
2196
|
+
path,
|
|
2197
|
+
documentation: {
|
|
2198
|
+
...userDoc,
|
|
2199
|
+
tags: [...userDoc.tags ?? [], ...tags],
|
|
2200
|
+
"x-tagGroups": tagGroups
|
|
2201
|
+
},
|
|
2202
|
+
scalar: {
|
|
2203
|
+
...userScalar,
|
|
2204
|
+
layout: userScalar.layout ?? "classic",
|
|
2205
|
+
operationTitleSource: userScalar.operationTitleSource ?? "summary"
|
|
2206
|
+
}
|
|
2207
|
+
}));
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2210
|
+
// src/core/app.ts
|
|
2211
|
+
var app;
|
|
2212
|
+
var started = false;
|
|
2213
|
+
var signalsRegistered = false;
|
|
2214
|
+
var hostScanned = false;
|
|
2215
|
+
var bootstrapHooks = [];
|
|
2216
|
+
var shutdownHooks = [];
|
|
2217
|
+
var usePlugins = [];
|
|
2218
|
+
async function ensureHostScanned() {
|
|
2219
|
+
if (hostScanned)
|
|
2220
|
+
return;
|
|
2221
|
+
hostScanned = true;
|
|
2222
|
+
await scanHost();
|
|
2223
|
+
}
|
|
2224
|
+
function createApp() {
|
|
2225
|
+
return applyAsyncContext(applyErrorHandler(applyLogging(new Elysia2)));
|
|
2226
|
+
}
|
|
2227
|
+
function bootstrap(hook) {
|
|
2228
|
+
bootstrapHooks.push(hook);
|
|
2229
|
+
}
|
|
2230
|
+
function shutdown(hook) {
|
|
2231
|
+
shutdownHooks.push(hook);
|
|
2232
|
+
}
|
|
2233
|
+
function use(setup) {
|
|
2234
|
+
usePlugins.push(setup);
|
|
2235
|
+
}
|
|
2236
|
+
async function start() {
|
|
2237
|
+
if (started) {
|
|
2238
|
+
throw new Error("[App] \u5DF2\u542F\u52A8\uFF0C\u8BF7\u5148 App.stop() \u518D start");
|
|
2239
|
+
}
|
|
2240
|
+
let next = createApp();
|
|
2241
|
+
next = await applyHostAuthMiddleware(next);
|
|
2242
|
+
for (const setup of usePlugins) {
|
|
2243
|
+
next = setup(next);
|
|
2244
|
+
}
|
|
2245
|
+
await ensureHostScanned();
|
|
2246
|
+
next = applyOpenapi(next);
|
|
2247
|
+
await bootstrapHostInfra();
|
|
2248
|
+
for (const hook of bootstrapHooks)
|
|
2249
|
+
await hook();
|
|
2250
|
+
bootstrapLogger();
|
|
2251
|
+
bootstrapIoc();
|
|
2252
|
+
await bootstrapHostPlugins();
|
|
2253
|
+
await bootstrapHostModules();
|
|
2254
|
+
await bootstrapHostTasks();
|
|
2255
|
+
next = registerControllers(next, VomeConfig);
|
|
2256
|
+
const port = VomeConfig.system?.port ?? 3001;
|
|
2257
|
+
next.listen(port);
|
|
2258
|
+
app = next;
|
|
2259
|
+
started = true;
|
|
2260
|
+
printStartupBanner();
|
|
2261
|
+
registerShutdownSignals();
|
|
2262
|
+
return app;
|
|
2263
|
+
}
|
|
2264
|
+
async function stop() {
|
|
2265
|
+
if (!app)
|
|
2266
|
+
return;
|
|
2267
|
+
for (const hook of shutdownHooks)
|
|
2268
|
+
await hook();
|
|
2269
|
+
await shutdownHostTasks();
|
|
2270
|
+
await shutdownHostInfra();
|
|
2271
|
+
await app.stop();
|
|
2272
|
+
app = undefined;
|
|
2273
|
+
started = false;
|
|
2274
|
+
hostScanned = false;
|
|
2275
|
+
resetIoc();
|
|
2276
|
+
resetPinoLogger();
|
|
2277
|
+
setCrudRegistrar(undefined);
|
|
2278
|
+
signalsRegistered = false;
|
|
2279
|
+
}
|
|
2280
|
+
function registerShutdownSignals() {
|
|
2281
|
+
if (signalsRegistered)
|
|
2282
|
+
return;
|
|
2283
|
+
signalsRegistered = true;
|
|
2284
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
2285
|
+
process.once(signal, async () => {
|
|
2286
|
+
await stop();
|
|
2287
|
+
process.exit(0);
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
var App = {
|
|
2292
|
+
bootstrap,
|
|
2293
|
+
shutdown,
|
|
2294
|
+
use,
|
|
2295
|
+
start,
|
|
2296
|
+
stop
|
|
2297
|
+
};
|
|
2298
|
+
async function vome(setup) {
|
|
2299
|
+
if (setup)
|
|
2300
|
+
await setup({ App });
|
|
2301
|
+
return App.start();
|
|
2302
|
+
}
|
|
2303
|
+
// src/routing/eps.ts
|
|
2304
|
+
import { getTableColumns as getTableColumns3, getTableName as getTableName2 } from "drizzle-orm";
|
|
2305
|
+
|
|
2306
|
+
// src/orm/column-comments.ts
|
|
2307
|
+
import { getTableColumns as getTableColumns2, getTableName } from "drizzle-orm";
|
|
2308
|
+
|
|
2309
|
+
// src/orm/base-columns.ts
|
|
2310
|
+
import { integer, serial, timestamp } from "drizzle-orm/pg-core";
|
|
2311
|
+
var baseColumns = {
|
|
2312
|
+
id: serial("id").primaryKey(),
|
|
2313
|
+
createTime: timestamp("createTime", { withTimezone: true }).notNull().defaultNow(),
|
|
2314
|
+
updateTime: timestamp("updateTime", { withTimezone: true }).notNull().defaultNow().$onUpdate(() => new Date),
|
|
2315
|
+
deletedAt: timestamp("deletedAt", { withTimezone: true }),
|
|
2316
|
+
tenantId: integer("tenantId")
|
|
2317
|
+
};
|
|
2318
|
+
var BASE_COLUMN_COMMENTS = {
|
|
2319
|
+
id: "ID",
|
|
2320
|
+
createTime: "\u521B\u5EFA\u65F6\u95F4",
|
|
2321
|
+
updateTime: "\u66F4\u65B0\u65F6\u95F4",
|
|
2322
|
+
deletedAt: "\u5220\u9664\u65F6\u95F4",
|
|
2323
|
+
tenantId: "\u79DF\u6237"
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
// src/orm/column-comments.ts
|
|
2327
|
+
var registry = new WeakMap;
|
|
2328
|
+
var tables = new Set;
|
|
2329
|
+
function columnComments(table, comments = {}) {
|
|
2330
|
+
tables.add(table);
|
|
2331
|
+
registry.set(table, {
|
|
2332
|
+
...BASE_COLUMN_COMMENTS,
|
|
2333
|
+
...registry.get(table) || {},
|
|
2334
|
+
...comments
|
|
2335
|
+
});
|
|
2336
|
+
return table;
|
|
2337
|
+
}
|
|
2338
|
+
function getColumnComments(table) {
|
|
2339
|
+
return registry.get(table) || {};
|
|
2340
|
+
}
|
|
2341
|
+
function listColumnCommentTables() {
|
|
2342
|
+
return [...tables];
|
|
2343
|
+
}
|
|
2344
|
+
function quoteIdent(name) {
|
|
2345
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
|
|
2346
|
+
throw new Error(`[columnComments] \u975E\u6CD5\u6807\u8BC6\u7B26: ${name}`);
|
|
2347
|
+
}
|
|
2348
|
+
return `"${name}"`;
|
|
2349
|
+
}
|
|
2350
|
+
function escapeLiteral(value) {
|
|
2351
|
+
return value.replace(/'/g, "''");
|
|
2352
|
+
}
|
|
2353
|
+
async function syncColumnCommentsToPg(sql5) {
|
|
2354
|
+
const registered = listColumnCommentTables();
|
|
2355
|
+
if (!registered.length)
|
|
2356
|
+
return 0;
|
|
2357
|
+
const desired = new Map;
|
|
2358
|
+
const tableNames = [];
|
|
2359
|
+
for (const table of registered) {
|
|
2360
|
+
let name;
|
|
2361
|
+
try {
|
|
2362
|
+
name = getTableName(table);
|
|
2363
|
+
} catch {
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2366
|
+
const cols = getTableColumns2(table);
|
|
2367
|
+
const comments = getColumnComments(table);
|
|
2368
|
+
const colMap = new Map;
|
|
2369
|
+
for (const [prop, text] of Object.entries(comments)) {
|
|
2370
|
+
if (!text || !(prop in cols))
|
|
2371
|
+
continue;
|
|
2372
|
+
colMap.set(prop, text);
|
|
2373
|
+
}
|
|
2374
|
+
if (!colMap.size)
|
|
2375
|
+
continue;
|
|
2376
|
+
desired.set(name, colMap);
|
|
2377
|
+
tableNames.push(name);
|
|
2378
|
+
}
|
|
2379
|
+
if (!tableNames.length)
|
|
2380
|
+
return 0;
|
|
2381
|
+
const inList = tableNames.map((t) => `'${escapeLiteral(t)}'`).join(",");
|
|
2382
|
+
const rows = await sql5.unsafe(`
|
|
2383
|
+
SELECT
|
|
2384
|
+
c.relname AS table_name,
|
|
2385
|
+
a.attname AS column_name,
|
|
2386
|
+
col_description(a.attrelid, a.attnum) AS comment
|
|
2387
|
+
FROM pg_catalog.pg_class c
|
|
2388
|
+
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
|
|
2389
|
+
JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
|
2390
|
+
WHERE c.relkind = 'r'
|
|
2391
|
+
AND n.nspname = current_schema()
|
|
2392
|
+
AND a.attnum > 0
|
|
2393
|
+
AND NOT a.attisdropped
|
|
2394
|
+
AND c.relname IN (${inList})
|
|
2395
|
+
`);
|
|
2396
|
+
const existing = new Map;
|
|
2397
|
+
for (const row of rows || []) {
|
|
2398
|
+
if (!row.table_name || !row.column_name)
|
|
2399
|
+
continue;
|
|
2400
|
+
existing.set(`${row.table_name}.${row.column_name}`, row.comment ?? null);
|
|
2401
|
+
}
|
|
2402
|
+
let updated = 0;
|
|
2403
|
+
for (const [tableName, cols] of desired) {
|
|
2404
|
+
for (const [colName2, text] of cols) {
|
|
2405
|
+
const key = `${tableName}.${colName2}`;
|
|
2406
|
+
const cur = existing.get(key);
|
|
2407
|
+
if (cur === text)
|
|
2408
|
+
continue;
|
|
2409
|
+
await sql5.unsafe(`COMMENT ON COLUMN ${quoteIdent(tableName)}.${quoteIdent(colName2)} IS '${escapeLiteral(text)}'`);
|
|
2410
|
+
updated++;
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
return updated;
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
// src/routing/eps.ts
|
|
2417
|
+
var SIDE_PREFIX2 = {
|
|
2418
|
+
admin: "/admin",
|
|
2419
|
+
app: "/app"
|
|
2420
|
+
};
|
|
2421
|
+
function getSidePrefix2(side) {
|
|
2422
|
+
return normalizePrefix(SIDE_PREFIX2[side]);
|
|
2423
|
+
}
|
|
2424
|
+
function lastSegment(prefix) {
|
|
2425
|
+
const parts = prefix.replace(/^\/+|\/+$/g, "").split("/");
|
|
2426
|
+
return parts[parts.length - 1] || prefix || "index";
|
|
2427
|
+
}
|
|
2428
|
+
function toPascalEntityName(tableName) {
|
|
2429
|
+
return tableName.split("_").filter(Boolean).map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("") + "Entity";
|
|
2430
|
+
}
|
|
2431
|
+
function withAlias(fields) {
|
|
2432
|
+
if (!fields?.length)
|
|
2433
|
+
return [];
|
|
2434
|
+
return fields.map((f) => {
|
|
2435
|
+
if (typeof f !== "string") {
|
|
2436
|
+
const col = f.column;
|
|
2437
|
+
return {
|
|
2438
|
+
...f,
|
|
2439
|
+
column: col.includes(".") ? col : `a.${col}`
|
|
2440
|
+
};
|
|
2441
|
+
}
|
|
2442
|
+
return f.includes(".") ? f : `a.${f}`;
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
function normalizePageQueryOp(op) {
|
|
2446
|
+
return {
|
|
2447
|
+
keyWordLikeFields: withAlias(op?.keyWordLikeFields),
|
|
2448
|
+
fieldEq: withAlias(op?.fieldEq),
|
|
2449
|
+
fieldLike: withAlias(op?.fieldLike),
|
|
2450
|
+
fieldArray: withAlias(op?.fieldArray),
|
|
2451
|
+
fieldRange: (op?.fieldRange ?? []).map((r) => ({
|
|
2452
|
+
...r,
|
|
2453
|
+
column: r.column.includes(".") ? r.column : `a.${r.column}`
|
|
2454
|
+
}))
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function applyFieldDictToColumns(columns, fieldEq) {
|
|
2458
|
+
for (const ref of fieldEq) {
|
|
2459
|
+
if (typeof ref === "string" || !ref.dict)
|
|
2460
|
+
continue;
|
|
2461
|
+
const name = ref.column.includes(".") ? ref.column.split(".").pop() : ref.column;
|
|
2462
|
+
const col = columns.find((c) => c.propertyName === name);
|
|
2463
|
+
if (col)
|
|
2464
|
+
col.dict = ref.dict;
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
function columnsFromEntity(entity) {
|
|
2468
|
+
if (!entity || typeof entity !== "object")
|
|
2469
|
+
return [];
|
|
2470
|
+
try {
|
|
2471
|
+
const cols = getTableColumns3(entity);
|
|
2472
|
+
const comments = getColumnComments(entity);
|
|
2473
|
+
const list = [];
|
|
2474
|
+
for (const [propertyName, col] of Object.entries(cols)) {
|
|
2475
|
+
if (propertyName === "tenantId")
|
|
2476
|
+
continue;
|
|
2477
|
+
const c = col;
|
|
2478
|
+
list.push({
|
|
2479
|
+
propertyName,
|
|
2480
|
+
type: String(c.dataType ?? c.columnType ?? "string"),
|
|
2481
|
+
length: c.length != null ? String(c.length) : undefined,
|
|
2482
|
+
nullable: c.notNull !== true,
|
|
2483
|
+
source: `a.${propertyName}`,
|
|
2484
|
+
comment: comments[propertyName]
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
const tail = new Set(["createTime", "updateTime", "deletedAt"]);
|
|
2488
|
+
const head = list.filter((c) => !tail.has(c.propertyName));
|
|
2489
|
+
const end = list.filter((c) => tail.has(c.propertyName));
|
|
2490
|
+
return [...head, ...end];
|
|
2491
|
+
} catch {
|
|
2492
|
+
return [];
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
function entityNameOf(entity) {
|
|
2496
|
+
if (!entity || typeof entity !== "object")
|
|
2497
|
+
return;
|
|
2498
|
+
try {
|
|
2499
|
+
return toPascalEntityName(getTableName2(entity));
|
|
2500
|
+
} catch {
|
|
2501
|
+
return;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
function buildApis(meta, fullPrefix) {
|
|
2505
|
+
const apis = [];
|
|
2506
|
+
const seen = new Set;
|
|
2507
|
+
const push = (item) => {
|
|
2508
|
+
const key = `${item.method}:${item.path}`;
|
|
2509
|
+
if (seen.has(key))
|
|
2510
|
+
return;
|
|
2511
|
+
seen.add(key);
|
|
2512
|
+
apis.push(item);
|
|
2513
|
+
};
|
|
2514
|
+
for (const route of meta.routes) {
|
|
2515
|
+
const subPath = getRouteSubPath(route.path, meta.prefix);
|
|
2516
|
+
const path = subPath.startsWith("/") ? subPath : `/${subPath}`;
|
|
2517
|
+
const action = actionFromSubPath(path);
|
|
2518
|
+
push({
|
|
2519
|
+
method: route.method.toLowerCase(),
|
|
2520
|
+
path,
|
|
2521
|
+
summary: route.summary ?? "",
|
|
2522
|
+
dts: {},
|
|
2523
|
+
tag: "",
|
|
2524
|
+
prefix: fullPrefix,
|
|
2525
|
+
ignoreToken: Boolean(route.public),
|
|
2526
|
+
ignorePerms: Boolean(route.ignorePerms),
|
|
2527
|
+
perms: effectivePerms(route, meta, action) ?? []
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
for (const name of meta.crud?.api ?? []) {
|
|
2531
|
+
const path = `/${name}`;
|
|
2532
|
+
push({
|
|
2533
|
+
method: name === "info" ? "get" : "post",
|
|
2534
|
+
path,
|
|
2535
|
+
summary: CRUD_SUMMARY[name] ?? name,
|
|
2536
|
+
dts: {},
|
|
2537
|
+
tag: "",
|
|
2538
|
+
prefix: fullPrefix,
|
|
2539
|
+
ignoreToken: false,
|
|
2540
|
+
ignorePerms: false,
|
|
2541
|
+
perms: effectivePerms({}, meta, name) ?? []
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
for (const name of meta.crud?.serviceApis ?? []) {
|
|
2545
|
+
const path = `/${name}`;
|
|
2546
|
+
push({
|
|
2547
|
+
method: "post",
|
|
2548
|
+
path,
|
|
2549
|
+
summary: name,
|
|
2550
|
+
dts: {},
|
|
2551
|
+
tag: "",
|
|
2552
|
+
prefix: fullPrefix,
|
|
2553
|
+
ignoreToken: false,
|
|
2554
|
+
ignorePerms: false,
|
|
2555
|
+
perms: effectivePerms({}, meta, name) ?? []
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
return apis;
|
|
2559
|
+
}
|
|
2560
|
+
function buildEntity(meta) {
|
|
2561
|
+
const fullPrefix = joinPrefix(getSidePrefix2(meta.side), meta.prefix);
|
|
2562
|
+
const typeName = lastSegment(meta.prefix);
|
|
2563
|
+
const entity = meta.crud?.entity;
|
|
2564
|
+
const columns = columnsFromEntity(entity);
|
|
2565
|
+
const pageQueryOp = normalizePageQueryOp(meta.crud?.pageQueryOp);
|
|
2566
|
+
applyFieldDictToColumns(columns, pageQueryOp.fieldEq);
|
|
2567
|
+
return {
|
|
2568
|
+
module: meta.module,
|
|
2569
|
+
side: meta.side,
|
|
2570
|
+
prefix: fullPrefix,
|
|
2571
|
+
name: entityNameOf(entity),
|
|
2572
|
+
info: {
|
|
2573
|
+
type: {
|
|
2574
|
+
name: typeName,
|
|
2575
|
+
description: meta.description ?? typeName
|
|
2576
|
+
}
|
|
2577
|
+
},
|
|
2578
|
+
api: buildApis(meta, fullPrefix),
|
|
2579
|
+
columns,
|
|
2580
|
+
pageQueryOp,
|
|
2581
|
+
pageColumns: columns
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function groupByModule(list) {
|
|
2585
|
+
const map = {};
|
|
2586
|
+
for (const item of list) {
|
|
2587
|
+
const arr = map[item.module] ?? [];
|
|
2588
|
+
arr.push(item);
|
|
2589
|
+
map[item.module] = arr;
|
|
2590
|
+
}
|
|
2591
|
+
return map;
|
|
2592
|
+
}
|
|
2593
|
+
function isEpsEnabled() {
|
|
2594
|
+
return Boolean(VomeConfig.vome?.eps);
|
|
2595
|
+
}
|
|
2596
|
+
function buildEps(side) {
|
|
2597
|
+
if (!isEpsEnabled())
|
|
2598
|
+
return {};
|
|
2599
|
+
return groupByModule(listControllers(side).map(buildEntity));
|
|
2600
|
+
}
|
|
2601
|
+
var Eps = {
|
|
2602
|
+
controllers: listControllers,
|
|
2603
|
+
admin: () => buildEps("admin"),
|
|
2604
|
+
app: () => buildEps("app"),
|
|
2605
|
+
enabled: isEpsEnabled
|
|
2606
|
+
};
|
|
2607
|
+
// src/routing/decorators.ts
|
|
2608
|
+
import"reflect-metadata";
|
|
2609
|
+
var ROUTES_PENDING_KEY = "vome:controller:routes-pending";
|
|
2610
|
+
function joinRoute(prefix, path) {
|
|
2611
|
+
return joinPrefix(prefix, path === "/" ? "" : path);
|
|
2612
|
+
}
|
|
2613
|
+
function asMiddlewareList(mw) {
|
|
2614
|
+
if (mw == null)
|
|
2615
|
+
return;
|
|
2616
|
+
return Array.isArray(mw) ? mw : [mw];
|
|
2617
|
+
}
|
|
2618
|
+
function appendPendingRoute(ctor, route) {
|
|
2619
|
+
const list = Reflect.getMetadata(ROUTES_PENDING_KEY, ctor) ?? [];
|
|
2620
|
+
list.push(route);
|
|
2621
|
+
Reflect.defineMetadata(ROUTES_PENDING_KEY, list, ctor);
|
|
2622
|
+
}
|
|
2623
|
+
function createParamDecorator(source) {
|
|
2624
|
+
const label = source === "params" ? "Param" : source === "body" ? "Body" : "Query";
|
|
2625
|
+
return (schema) => (target, propertyKey, parameterIndex) => {
|
|
2626
|
+
if (propertyKey === undefined) {
|
|
2627
|
+
throw new Error(`[Controller] @${label} \u53EA\u80FD\u7528\u4E8E\u65B9\u6CD5\u53C2\u6570`);
|
|
2628
|
+
}
|
|
2629
|
+
const ctor = target.constructor;
|
|
2630
|
+
appendRouteParam(ctor, String(propertyKey), {
|
|
2631
|
+
index: parameterIndex,
|
|
2632
|
+
source,
|
|
2633
|
+
schema
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
function pickCrudOptions(options) {
|
|
2638
|
+
const {
|
|
2639
|
+
api,
|
|
2640
|
+
entity,
|
|
2641
|
+
service,
|
|
2642
|
+
serviceApis,
|
|
2643
|
+
before,
|
|
2644
|
+
pageQueryOp,
|
|
2645
|
+
listQueryOp,
|
|
2646
|
+
insertParam,
|
|
2647
|
+
infoIgnoreProperty
|
|
2648
|
+
} = options;
|
|
2649
|
+
if (api == null && entity == null && service == null && serviceApis == null && before == null && pageQueryOp == null && listQueryOp == null && insertParam == null && infoIgnoreProperty == null) {
|
|
2650
|
+
return;
|
|
2651
|
+
}
|
|
2652
|
+
return {
|
|
2653
|
+
api,
|
|
2654
|
+
entity,
|
|
2655
|
+
service,
|
|
2656
|
+
serviceApis,
|
|
2657
|
+
before,
|
|
2658
|
+
pageQueryOp,
|
|
2659
|
+
listQueryOp,
|
|
2660
|
+
insertParam,
|
|
2661
|
+
infoIgnoreProperty
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
function Controller(prefixOrOptions = "") {
|
|
2665
|
+
const fromString = typeof prefixOrOptions === "string";
|
|
2666
|
+
const options = fromString ? { prefix: prefixOrOptions } : prefixOrOptions;
|
|
2667
|
+
return (target) => {
|
|
2668
|
+
registerProvider({
|
|
2669
|
+
token: target,
|
|
2670
|
+
useClass: target,
|
|
2671
|
+
scope: "singleton" /* Singleton */
|
|
2672
|
+
});
|
|
2673
|
+
const ctx = getControllerScanContext();
|
|
2674
|
+
const useAuto = fromString && prefixOrOptions === "" || !fromString && (options.prefix == null || options.prefix === "");
|
|
2675
|
+
const prefix = normalizePrefix(useAuto && ctx?.file ? parseControllerAutoPrefix(ctx.file) : options.prefix ?? "");
|
|
2676
|
+
const pending = Reflect.getMetadata(ROUTES_PENDING_KEY, target) ?? [];
|
|
2677
|
+
const crud = pickCrudOptions(options);
|
|
2678
|
+
registerController({
|
|
2679
|
+
token: target,
|
|
2680
|
+
prefix,
|
|
2681
|
+
module: options.module ?? ctx?.module ?? "unknown",
|
|
2682
|
+
side: options.side ?? ctx?.side ?? "admin",
|
|
2683
|
+
description: options.description,
|
|
2684
|
+
file: ctx?.file,
|
|
2685
|
+
middleware: asMiddlewareList(options.middleware),
|
|
2686
|
+
crud,
|
|
2687
|
+
routes: pending.map((route) => {
|
|
2688
|
+
const params = getRouteParams(target, route.handler);
|
|
2689
|
+
const schema = schemaFromParams(params);
|
|
2690
|
+
const routeMw = [
|
|
2691
|
+
...route.middleware ?? [],
|
|
2692
|
+
...getRouteMiddleware(target, route.handler)
|
|
2693
|
+
];
|
|
2694
|
+
return {
|
|
2695
|
+
...route,
|
|
2696
|
+
path: joinRoute(prefix, route.path.startsWith("/") ? route.path.slice(1) : route.path),
|
|
2697
|
+
params,
|
|
2698
|
+
body: schema?.body,
|
|
2699
|
+
query: schema?.query,
|
|
2700
|
+
routeParams: schema?.params,
|
|
2701
|
+
public: isRoutePublic(target, route.handler),
|
|
2702
|
+
ignorePerms: isRouteIgnorePerms(target, route.handler),
|
|
2703
|
+
perms: getRoutePerms(target, route.handler),
|
|
2704
|
+
middleware: routeMw.length ? routeMw : undefined
|
|
2705
|
+
};
|
|
2706
|
+
})
|
|
2707
|
+
});
|
|
2708
|
+
Reflect.deleteMetadata(ROUTES_PENDING_KEY, target);
|
|
2709
|
+
clearRouteParams(target);
|
|
2710
|
+
clearRoutePublic(target);
|
|
2711
|
+
clearRouteMiddleware(target);
|
|
2712
|
+
clearRoutePerms(target);
|
|
2713
|
+
clearRouteIgnorePerms(target);
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
function Use(...middleware) {
|
|
2717
|
+
return (target, propertyKey) => {
|
|
2718
|
+
const ctor = target.constructor;
|
|
2719
|
+
appendRouteMiddleware(ctor, String(propertyKey), middleware);
|
|
2720
|
+
};
|
|
2721
|
+
}
|
|
2722
|
+
function createMethodDecorator(method) {
|
|
2723
|
+
return (path = "", options) => (target, propertyKey) => {
|
|
2724
|
+
const ctor = target.constructor;
|
|
2725
|
+
appendPendingRoute(ctor, {
|
|
2726
|
+
method,
|
|
2727
|
+
path,
|
|
2728
|
+
handler: String(propertyKey),
|
|
2729
|
+
summary: options?.summary
|
|
2730
|
+
});
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
function Public() {
|
|
2734
|
+
return (target, propertyKey) => {
|
|
2735
|
+
const ctor = target.constructor;
|
|
2736
|
+
markRoutePublic(ctor, String(propertyKey));
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
function Perms(...codes) {
|
|
2740
|
+
return (target, propertyKey) => {
|
|
2741
|
+
const ctor = target.constructor;
|
|
2742
|
+
setRoutePerms(ctor, String(propertyKey), codes);
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
function IgnorePerms() {
|
|
2746
|
+
return (target, propertyKey) => {
|
|
2747
|
+
const ctor = target.constructor;
|
|
2748
|
+
markRouteIgnorePerms(ctor, String(propertyKey));
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
var Body = createParamDecorator("body");
|
|
2752
|
+
var Query = createParamDecorator("query");
|
|
2753
|
+
var Param = createParamDecorator("params");
|
|
2754
|
+
var Get = createMethodDecorator("GET");
|
|
2755
|
+
var Post = createMethodDecorator("POST");
|
|
2756
|
+
var Put = createMethodDecorator("PUT");
|
|
2757
|
+
var Delete = createMethodDecorator("DELETE");
|
|
2758
|
+
var Patch = createMethodDecorator("PATCH");
|
|
2759
|
+
// src/ext/base-plugin.ts
|
|
2760
|
+
class BasePlugin {
|
|
2761
|
+
pluginInfo;
|
|
2762
|
+
ctx;
|
|
2763
|
+
cache;
|
|
2764
|
+
pluginService;
|
|
2765
|
+
async init(pluginInfo, ctx, _app, services) {
|
|
2766
|
+
this.pluginInfo = pluginInfo;
|
|
2767
|
+
this.ctx = ctx;
|
|
2768
|
+
this.cache = services?.cache;
|
|
2769
|
+
this.pluginService = services?.pluginService;
|
|
2770
|
+
await this.ready();
|
|
2771
|
+
}
|
|
2772
|
+
async ready() {}
|
|
2773
|
+
}
|
|
2774
|
+
// src/ext/load-plugin.ts
|
|
2775
|
+
import { existsSync, readFileSync } from "fs";
|
|
2776
|
+
import { createRequire } from "module";
|
|
2777
|
+
import { join as join7 } from "path";
|
|
2778
|
+
|
|
2779
|
+
// src/ext/path.ts
|
|
2780
|
+
import { createHash } from "crypto";
|
|
2781
|
+
import { homedir } from "os";
|
|
2782
|
+
import { join as join6 } from "path";
|
|
2783
|
+
function pDataPath() {
|
|
2784
|
+
const hash = createHash("md5").update(String(VomeConfig.keys ?? "vome")).digest("hex");
|
|
2785
|
+
return join6(homedir(), ".vome", hash);
|
|
2786
|
+
}
|
|
2787
|
+
function pPluginPath() {
|
|
2788
|
+
return join6(pDataPath(), "plugin");
|
|
2789
|
+
}
|
|
2790
|
+
function pModulesPath() {
|
|
2791
|
+
return join6(pDataPath(), "modules");
|
|
2792
|
+
}
|
|
2793
|
+
function pModulePath(key) {
|
|
2794
|
+
return join6(pModulesPath(), key);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
// src/ext/load-plugin.ts
|
|
2798
|
+
var hostRequire = createRequire(import.meta.url);
|
|
2799
|
+
function pluginRequire(id) {
|
|
2800
|
+
if (id === "vome-plugin-runtime")
|
|
2801
|
+
return { BasePlugin };
|
|
2802
|
+
return hostRequire(id);
|
|
2803
|
+
}
|
|
2804
|
+
function loadPluginClass(content) {
|
|
2805
|
+
try {
|
|
2806
|
+
const normalized = content.replace(/export\s+const\s+Plugin\s*=/g, "var Plugin =").replace(/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g, "").replace(/export\s+const\s+handlers\s*=/g, "var handlers =").replace(/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g, "").replace(/export\s+class\s+(\w+)/g, "class $1").replace(/export\s+default\s+/g, "").replace(/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g, "").replace(/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g, "").replace(/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g, "({ BasePlugin })");
|
|
2807
|
+
const fn = new Function("BasePlugin", "require", "module", "exports", `${normalized}
|
|
2808
|
+
var __Plugin = (typeof Plugin !== 'undefined')
|
|
2809
|
+
? Plugin
|
|
2810
|
+
: (module.exports && (module.exports.Plugin || module.exports.default || module.exports));
|
|
2811
|
+
if (typeof __Plugin === 'undefined' || __Plugin === null) {
|
|
2812
|
+
throw new Error('missing export Plugin');
|
|
2813
|
+
}
|
|
2814
|
+
return __Plugin;`);
|
|
2815
|
+
const mod = { exports: {} };
|
|
2816
|
+
return fn(BasePlugin, pluginRequire, mod, mod.exports);
|
|
2817
|
+
} catch (e) {
|
|
2818
|
+
throw new Error(`[Plugin] \u52A0\u8F7D\u5931\u8D25: ${e instanceof Error ? e.message : String(e)}`);
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
function readPluginScript(keyName) {
|
|
2822
|
+
const moduleServer = join7(pModulePath(keyName), "server", "index.js");
|
|
2823
|
+
if (existsSync(moduleServer)) {
|
|
2824
|
+
return readFileSync(moduleServer, "utf8");
|
|
2825
|
+
}
|
|
2826
|
+
const legacy = join7(pPluginPath(), keyName);
|
|
2827
|
+
if (!existsSync(legacy))
|
|
2828
|
+
return;
|
|
2829
|
+
try {
|
|
2830
|
+
const payload = JSON.parse(readFileSync(legacy, "utf8"));
|
|
2831
|
+
return payload.content?.data;
|
|
2832
|
+
} catch {
|
|
2833
|
+
return;
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
// src/ext/module-registry.ts
|
|
2837
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, statSync } from "fs";
|
|
2838
|
+
import { createRequire as createRequire2 } from "module";
|
|
2839
|
+
import { join as join8 } from "path";
|
|
2840
|
+
var registry2 = new Map;
|
|
2841
|
+
var hostRequire2 = createRequire2(import.meta.url);
|
|
2842
|
+
function pluginRequire2(id) {
|
|
2843
|
+
if (id === "vome-plugin-runtime")
|
|
2844
|
+
return { BasePlugin };
|
|
2845
|
+
return hostRequire2(id);
|
|
2846
|
+
}
|
|
2847
|
+
function normalizePath(path) {
|
|
2848
|
+
const p = path.startsWith("/") ? path : `/${path}`;
|
|
2849
|
+
return p.replace(/\/+$/, "") || "/";
|
|
2850
|
+
}
|
|
2851
|
+
function normalizeMethod(method) {
|
|
2852
|
+
return method.toUpperCase();
|
|
2853
|
+
}
|
|
2854
|
+
function normalizeModuleScript(content) {
|
|
2855
|
+
return content.replace(/export\s+const\s+handlers\s*=/g, "var handlers =").replace(/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g, "").replace(/export\s+default\s+\{/g, "var handlers = {").replace(/export\s+const\s+Plugin\s*=/g, "var Plugin =").replace(/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g, "").replace(/export\s+class\s+(\w+)/g, "class $1").replace(/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g, "").replace(/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g, "").replace(/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g, "({ BasePlugin })");
|
|
2856
|
+
}
|
|
2857
|
+
function loadModuleHandlers(content, required = true) {
|
|
2858
|
+
const normalized = normalizeModuleScript(content);
|
|
2859
|
+
const fn = new Function("BasePlugin", "require", "module", "exports", `${normalized}
|
|
2860
|
+
if (typeof handlers === 'undefined') return null;
|
|
2861
|
+
return handlers;`);
|
|
2862
|
+
const mod = { exports: {} };
|
|
2863
|
+
const handlers = fn(BasePlugin, pluginRequire2, mod, mod.exports);
|
|
2864
|
+
if (!handlers || typeof handlers !== "object") {
|
|
2865
|
+
if (required)
|
|
2866
|
+
throw new Error("missing export handlers");
|
|
2867
|
+
return {};
|
|
2868
|
+
}
|
|
2869
|
+
return handlers;
|
|
2870
|
+
}
|
|
2871
|
+
var ModuleRegistry = {
|
|
2872
|
+
get(key) {
|
|
2873
|
+
return registry2.get(key);
|
|
2874
|
+
},
|
|
2875
|
+
list() {
|
|
2876
|
+
return [...registry2.entries()].map(([key, mod]) => ({
|
|
2877
|
+
key,
|
|
2878
|
+
manifest: mod.manifest,
|
|
2879
|
+
routes: mod.routes
|
|
2880
|
+
}));
|
|
2881
|
+
},
|
|
2882
|
+
load(key) {
|
|
2883
|
+
if (!key || !/^[a-zA-Z0-9_-]+$/.test(key)) {
|
|
2884
|
+
throw new Error(`\u975E\u6CD5\u6A21\u5757 key: ${key}`);
|
|
2885
|
+
}
|
|
2886
|
+
const dir = pModulePath(key);
|
|
2887
|
+
const metaPath = join8(dir, "module.json");
|
|
2888
|
+
if (!existsSync2(metaPath)) {
|
|
2889
|
+
throw new Error(`\u7F3A\u5C11 module.json: ${key}`);
|
|
2890
|
+
}
|
|
2891
|
+
const manifest = JSON.parse(readFileSync2(metaPath, "utf8"));
|
|
2892
|
+
const routes = (manifest.routes ?? []).map((r) => ({
|
|
2893
|
+
...r,
|
|
2894
|
+
method: normalizeMethod(r.method),
|
|
2895
|
+
path: normalizePath(r.path)
|
|
2896
|
+
}));
|
|
2897
|
+
let handlers = {};
|
|
2898
|
+
const serverEntry = join8(dir, "server", "index.js");
|
|
2899
|
+
if (existsSync2(serverEntry)) {
|
|
2900
|
+
const content = readFileSync2(serverEntry, "utf8");
|
|
2901
|
+
handlers = loadModuleHandlers(content, routes.length > 0);
|
|
2902
|
+
for (const route of routes) {
|
|
2903
|
+
if (typeof handlers[route.handler] !== "function") {
|
|
2904
|
+
throw new Error(`\u6A21\u5757 ${key} \u7F3A\u5C11 handler: ${route.handler}`);
|
|
2905
|
+
}
|
|
2906
|
+
}
|
|
2907
|
+
} else if (routes.length) {
|
|
2908
|
+
throw new Error(`\u6A21\u5757 ${key} \u58F0\u660E\u4E86 routes \u4F46\u7F3A\u5C11 server/index.js`);
|
|
2909
|
+
}
|
|
2910
|
+
registry2.set(key, { manifest, handlers, routes });
|
|
2911
|
+
return registry2.get(key);
|
|
2912
|
+
},
|
|
2913
|
+
unload(key) {
|
|
2914
|
+
registry2.delete(key);
|
|
2915
|
+
},
|
|
2916
|
+
async dispatch(key, method, subPath, ctx) {
|
|
2917
|
+
const mod = registry2.get(key);
|
|
2918
|
+
if (!mod) {
|
|
2919
|
+
return { ok: false, status: 404, message: "\u6A21\u5757\u672A\u52A0\u8F7D" };
|
|
2920
|
+
}
|
|
2921
|
+
const m = normalizeMethod(method);
|
|
2922
|
+
const path = normalizePath(subPath);
|
|
2923
|
+
const route = mod.routes.find((r) => r.method === m && r.path === path);
|
|
2924
|
+
if (!route) {
|
|
2925
|
+
return { ok: false, status: 404, message: "\u8DEF\u7531\u4E0D\u5B58\u5728" };
|
|
2926
|
+
}
|
|
2927
|
+
const handler = mod.handlers[route.handler];
|
|
2928
|
+
if (typeof handler !== "function") {
|
|
2929
|
+
return { ok: false, status: 500, message: `handler \u7F3A\u5931: ${route.handler}` };
|
|
2930
|
+
}
|
|
2931
|
+
try {
|
|
2932
|
+
const data = await handler(ctx);
|
|
2933
|
+
return { ok: true, data, route };
|
|
2934
|
+
} catch (e) {
|
|
2935
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
2936
|
+
return { ok: false, status: 500, message, route };
|
|
2937
|
+
}
|
|
2938
|
+
},
|
|
2939
|
+
bootstrap() {
|
|
2940
|
+
const root = pModulesPath();
|
|
2941
|
+
if (!existsSync2(root))
|
|
2942
|
+
return;
|
|
2943
|
+
for (const name of readdirSync2(root)) {
|
|
2944
|
+
const dir = join8(root, name);
|
|
2945
|
+
if (!statSync(dir).isDirectory())
|
|
2946
|
+
continue;
|
|
2947
|
+
if (!existsSync2(join8(dir, "module.json")))
|
|
2948
|
+
continue;
|
|
2949
|
+
try {
|
|
2950
|
+
this.load(name);
|
|
2951
|
+
console.log(`[Module] loaded ${name}`);
|
|
2952
|
+
} catch (e) {
|
|
2953
|
+
console.warn(`[Module] load failed ${name}:`, e instanceof Error ? e.message : e);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
// src/ext/micro-apps.ts
|
|
2959
|
+
import { existsSync as existsSync3, statSync as statSync2 } from "fs";
|
|
2960
|
+
import { join as join9, normalize, sep } from "path";
|
|
2961
|
+
import { Elysia as Elysia3 } from "elysia";
|
|
2962
|
+
var PREFIX = "/vome/apps";
|
|
2963
|
+
function contentType(filePath) {
|
|
2964
|
+
const lower = filePath.toLowerCase();
|
|
2965
|
+
if (lower.endsWith(".html"))
|
|
2966
|
+
return "text/html; charset=utf-8";
|
|
2967
|
+
if (lower.endsWith(".js") || lower.endsWith(".mjs"))
|
|
2968
|
+
return "application/javascript; charset=utf-8";
|
|
2969
|
+
if (lower.endsWith(".css"))
|
|
2970
|
+
return "text/css; charset=utf-8";
|
|
2971
|
+
if (lower.endsWith(".json"))
|
|
2972
|
+
return "application/json; charset=utf-8";
|
|
2973
|
+
if (lower.endsWith(".svg"))
|
|
2974
|
+
return "image/svg+xml";
|
|
2975
|
+
if (lower.endsWith(".png"))
|
|
2976
|
+
return "image/png";
|
|
2977
|
+
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg"))
|
|
2978
|
+
return "image/jpeg";
|
|
2979
|
+
if (lower.endsWith(".woff2"))
|
|
2980
|
+
return "font/woff2";
|
|
2981
|
+
if (lower.endsWith(".woff"))
|
|
2982
|
+
return "font/woff";
|
|
2983
|
+
if (lower.endsWith(".map"))
|
|
2984
|
+
return "application/json";
|
|
2985
|
+
return "application/octet-stream";
|
|
2986
|
+
}
|
|
2987
|
+
var microApps = new Elysia3({ name: "micro-apps-static" }).get(`${PREFIX}/*`, ({ params, set: set2 }) => {
|
|
2988
|
+
const star = String(params["*"] || "");
|
|
2989
|
+
const parts = star.split("/").filter(Boolean);
|
|
2990
|
+
if (!parts.length) {
|
|
2991
|
+
set2.status = 404;
|
|
2992
|
+
return "Not Found";
|
|
2993
|
+
}
|
|
2994
|
+
const key = parts[0];
|
|
2995
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(key)) {
|
|
2996
|
+
set2.status = 400;
|
|
2997
|
+
return "Invalid app key";
|
|
2998
|
+
}
|
|
2999
|
+
const root = join9(pModulePath(key), "web");
|
|
3000
|
+
if (!existsSync3(root) || !statSync2(root).isDirectory()) {
|
|
3001
|
+
set2.status = 404;
|
|
3002
|
+
return "App not found";
|
|
3003
|
+
}
|
|
3004
|
+
let sub = parts.slice(1).join("/") || "index.html";
|
|
3005
|
+
if (sub.endsWith("/"))
|
|
3006
|
+
sub += "index.html";
|
|
3007
|
+
const resolved = normalize(join9(root, sub));
|
|
3008
|
+
if (!resolved.startsWith(root + sep) && resolved !== root) {
|
|
3009
|
+
set2.status = 403;
|
|
3010
|
+
return "Forbidden";
|
|
3011
|
+
}
|
|
3012
|
+
let filePath = resolved;
|
|
3013
|
+
if (existsSync3(filePath) && statSync2(filePath).isDirectory()) {
|
|
3014
|
+
filePath = join9(filePath, "index.html");
|
|
3015
|
+
}
|
|
3016
|
+
if (!existsSync3(filePath) || !statSync2(filePath).isFile()) {
|
|
3017
|
+
set2.status = 404;
|
|
3018
|
+
return "Not Found";
|
|
3019
|
+
}
|
|
3020
|
+
set2.headers["content-type"] = contentType(filePath);
|
|
3021
|
+
set2.headers["cache-control"] = "no-cache";
|
|
3022
|
+
set2.headers["access-control-allow-origin"] = "*";
|
|
3023
|
+
return Bun.file(filePath);
|
|
3024
|
+
});
|
|
3025
|
+
// src/ext/module-gateway.ts
|
|
3026
|
+
import { Elysia as Elysia4 } from "elysia";
|
|
3027
|
+
function ok(data) {
|
|
3028
|
+
return { code: RES_CODE.SUCCESS, message: "success", data: data ?? null };
|
|
3029
|
+
}
|
|
3030
|
+
function fail(message, code = RES_CODE.ERROR) {
|
|
3031
|
+
return { code, message };
|
|
3032
|
+
}
|
|
3033
|
+
async function handleExt(ctx) {
|
|
3034
|
+
const key = ctx.params.key;
|
|
3035
|
+
if (!key || !/^[a-zA-Z0-9_-]+$/.test(key)) {
|
|
3036
|
+
ctx.set.status = 400;
|
|
3037
|
+
return fail("\u975E\u6CD5\u6A21\u5757 key");
|
|
3038
|
+
}
|
|
3039
|
+
const star = String(ctx.params["*"] || "");
|
|
3040
|
+
const subPath = `/${star}`.replace(/\/+/g, "/");
|
|
3041
|
+
const store = Context.get();
|
|
3042
|
+
const mod = ModuleRegistry.get(key);
|
|
3043
|
+
if (!mod) {
|
|
3044
|
+
ctx.set.status = 404;
|
|
3045
|
+
return fail("\u6A21\u5757\u672A\u5B89\u88C5\u6216\u672A\u52A0\u8F7D");
|
|
3046
|
+
}
|
|
3047
|
+
const method = ctx.request.method.toUpperCase();
|
|
3048
|
+
const pathNorm = subPath.replace(/\/+$/, "") || "/";
|
|
3049
|
+
const route = mod.routes.find((r) => r.method === method && r.path === pathNorm);
|
|
3050
|
+
if (!route) {
|
|
3051
|
+
ctx.set.status = 404;
|
|
3052
|
+
return fail("\u8DEF\u7531\u4E0D\u5B58\u5728");
|
|
3053
|
+
}
|
|
3054
|
+
if (route.perms && !store?.isSuper) {
|
|
3055
|
+
const held = store?.perms ?? [];
|
|
3056
|
+
if (!held.includes(route.perms)) {
|
|
3057
|
+
return ctx.status(403);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
const result = await ModuleRegistry.dispatch(key, method, subPath, {
|
|
3061
|
+
body: ctx.body,
|
|
3062
|
+
query: ctx.query ?? {},
|
|
3063
|
+
params: ctx.params,
|
|
3064
|
+
headers: ctx.request.headers,
|
|
3065
|
+
adminId: store?.adminId
|
|
3066
|
+
});
|
|
3067
|
+
if (!result.ok) {
|
|
3068
|
+
ctx.set.status = result.status;
|
|
3069
|
+
return fail(result.message);
|
|
3070
|
+
}
|
|
3071
|
+
return ok(result.data);
|
|
3072
|
+
}
|
|
3073
|
+
function createModuleGateway(options) {
|
|
3074
|
+
return new Elysia4({ name: "module-gateway" }).use(options.adminAuth).all("/admin/ext/:key/*", handleExt, { adminAuth: true }).all("/admin/ext/:key", handleExt, { adminAuth: true });
|
|
3075
|
+
}
|
|
3076
|
+
// src/auth/define-macro.ts
|
|
3077
|
+
import { Elysia as Elysia5 } from "elysia";
|
|
3078
|
+
function defineAuthMacro(name, resolve) {
|
|
3079
|
+
return new Elysia5({ name: `${name}-macro` }).macro({
|
|
3080
|
+
[name]: { resolve }
|
|
3081
|
+
}).as("scoped");
|
|
3082
|
+
}
|
|
3083
|
+
// package.json
|
|
3084
|
+
var package_default = {
|
|
3085
|
+
name: "vome-core",
|
|
3086
|
+
version: "0.0.8",
|
|
3087
|
+
description: "Vome framework \u2014 shared + Bun/Elysia server + Vue admin",
|
|
3088
|
+
license: "MIT",
|
|
3089
|
+
type: "module",
|
|
3090
|
+
files: [
|
|
3091
|
+
"dist",
|
|
3092
|
+
"src/admin",
|
|
3093
|
+
"src/shared",
|
|
3094
|
+
"typings/admin"
|
|
3095
|
+
],
|
|
3096
|
+
main: "./dist/index.js",
|
|
3097
|
+
types: "./dist/index.d.ts",
|
|
3098
|
+
exports: {
|
|
3099
|
+
".": {
|
|
3100
|
+
types: "./dist/index.d.ts",
|
|
3101
|
+
import: "./dist/index.js",
|
|
3102
|
+
default: "./dist/index.js"
|
|
3103
|
+
},
|
|
3104
|
+
"./server": {
|
|
3105
|
+
types: "./dist/server/index.d.ts",
|
|
3106
|
+
import: "./dist/server/index.js",
|
|
3107
|
+
default: "./dist/server/index.js"
|
|
3108
|
+
},
|
|
3109
|
+
"./admin": {
|
|
3110
|
+
types: "./src/admin/index.ts",
|
|
3111
|
+
import: "./src/admin/index.ts",
|
|
3112
|
+
default: "./src/admin/index.ts"
|
|
3113
|
+
},
|
|
3114
|
+
"./admin/*": "./src/admin/*",
|
|
3115
|
+
"./admin/styles/base.css": "./src/admin/styles/base.css",
|
|
3116
|
+
"./typings/*": "./typings/admin/*"
|
|
3117
|
+
},
|
|
3118
|
+
scripts: {
|
|
3119
|
+
build: `rm -rf dist && bun build ./src/index.ts ./src/server/index.ts --outdir ./dist --target bun --format esm --external elysia --external reflect-metadata --external drizzle-orm --external drizzle-zod --external @elysiajs/openapi --external @bogeychan/elysia-logger --external pino --external pino-pretty && tsc -p tsconfig.build.json && printf "%s\\n" "export * from '../src/index'" > dist/index.d.ts && mkdir -p dist/server && printf "%s\\n" "export * from '../../src/server/index'" > dist/server/index.d.ts`,
|
|
3120
|
+
"build:obfuscate": `rm -rf dist && bun build ./src/index.ts ./src/server/index.ts --outdir ./dist --target bun --format esm --minify --external elysia --external reflect-metadata --external drizzle-orm --external drizzle-zod --external @elysiajs/openapi --external @bogeychan/elysia-logger --external pino --external pino-pretty && tsc -p tsconfig.build.json && printf "%s\\n" "export * from '../src/index'" > dist/index.d.ts && mkdir -p dist/server && printf "%s\\n" "export * from '../../src/server/index'" > dist/server/index.d.ts && bun scripts/obfuscate.ts`,
|
|
3121
|
+
prepare: "bun run build"
|
|
3122
|
+
},
|
|
3123
|
+
peerDependencies: {
|
|
3124
|
+
elysia: ">=1.0.0",
|
|
3125
|
+
"reflect-metadata": ">=0.2.0",
|
|
3126
|
+
"drizzle-orm": ">=0.30.0",
|
|
3127
|
+
"drizzle-zod": ">=0.5.0",
|
|
3128
|
+
vue: ">=3.5.0",
|
|
3129
|
+
"vue-router": ">=4.0.0",
|
|
3130
|
+
pinia: ">=2.0.0",
|
|
3131
|
+
"vue-sonner": ">=2.0.0",
|
|
3132
|
+
"@vueuse/core": ">=10.0.0",
|
|
3133
|
+
clsx: ">=2.0.0",
|
|
3134
|
+
"tailwind-merge": ">=2.0.0",
|
|
3135
|
+
dompurify: ">=3.0.0",
|
|
3136
|
+
marked: ">=9.0.0"
|
|
3137
|
+
},
|
|
3138
|
+
peerDependenciesMeta: {
|
|
3139
|
+
"drizzle-orm": {
|
|
3140
|
+
optional: true
|
|
3141
|
+
},
|
|
3142
|
+
"drizzle-zod": {
|
|
3143
|
+
optional: true
|
|
3144
|
+
},
|
|
3145
|
+
vue: {
|
|
3146
|
+
optional: true
|
|
3147
|
+
},
|
|
3148
|
+
"vue-router": {
|
|
3149
|
+
optional: true
|
|
3150
|
+
},
|
|
3151
|
+
pinia: {
|
|
3152
|
+
optional: true
|
|
3153
|
+
},
|
|
3154
|
+
"vue-sonner": {
|
|
3155
|
+
optional: true
|
|
3156
|
+
},
|
|
3157
|
+
"@vueuse/core": {
|
|
3158
|
+
optional: true
|
|
3159
|
+
},
|
|
3160
|
+
clsx: {
|
|
3161
|
+
optional: true
|
|
3162
|
+
},
|
|
3163
|
+
"tailwind-merge": {
|
|
3164
|
+
optional: true
|
|
3165
|
+
},
|
|
3166
|
+
dompurify: {
|
|
3167
|
+
optional: true
|
|
3168
|
+
},
|
|
3169
|
+
marked: {
|
|
3170
|
+
optional: true
|
|
3171
|
+
}
|
|
3172
|
+
},
|
|
3173
|
+
devDependencies: {
|
|
3174
|
+
"bun-types": "latest",
|
|
3175
|
+
"drizzle-orm": "latest",
|
|
3176
|
+
"drizzle-zod": "^0.8.3",
|
|
3177
|
+
elysia: "latest",
|
|
3178
|
+
"javascript-obfuscator": "^5.4.7",
|
|
3179
|
+
"reflect-metadata": "^0.2.2",
|
|
3180
|
+
typescript: "latest"
|
|
3181
|
+
},
|
|
3182
|
+
dependencies: {
|
|
3183
|
+
"@bogeychan/elysia-logger": "^0.1.10",
|
|
3184
|
+
"@elysiajs/openapi": "^1.4.15",
|
|
3185
|
+
pino: "^10.3.1",
|
|
3186
|
+
"pino-pretty": "^13.1.3"
|
|
3187
|
+
}
|
|
3188
|
+
};
|
|
3189
|
+
|
|
3190
|
+
// src/server/index.ts
|
|
3191
|
+
var version = package_default.version;
|
|
3192
|
+
export {
|
|
3193
|
+
vome,
|
|
3194
|
+
version,
|
|
3195
|
+
tableHasDepartmentId,
|
|
3196
|
+
syncColumnCommentsToPg,
|
|
3197
|
+
scanFiles,
|
|
3198
|
+
resolveTenantScope,
|
|
3199
|
+
resolveDataScope,
|
|
3200
|
+
readPluginScript,
|
|
3201
|
+
q,
|
|
3202
|
+
pPluginPath,
|
|
3203
|
+
pModulesPath,
|
|
3204
|
+
pModulePath,
|
|
3205
|
+
pDataPath,
|
|
3206
|
+
normalizeHost,
|
|
3207
|
+
noTenant,
|
|
3208
|
+
noDataScope,
|
|
3209
|
+
microApps,
|
|
3210
|
+
loadPluginClass,
|
|
3211
|
+
loadModuleHandlers,
|
|
3212
|
+
listProviders,
|
|
3213
|
+
listControllers,
|
|
3214
|
+
isTenantEnabled,
|
|
3215
|
+
isEpsEnabled,
|
|
3216
|
+
isCommException,
|
|
3217
|
+
getRepository,
|
|
3218
|
+
getEnv,
|
|
3219
|
+
getColumnComments,
|
|
3220
|
+
entitySchemas,
|
|
3221
|
+
defineAuthMacro,
|
|
3222
|
+
createModuleGateway,
|
|
3223
|
+
columnComments,
|
|
3224
|
+
baseColumns,
|
|
3225
|
+
attachCrudRoutes,
|
|
3226
|
+
applyRowScopes,
|
|
3227
|
+
applyDataScopeWhere,
|
|
3228
|
+
appendInjectMeta,
|
|
3229
|
+
VomeConfig,
|
|
3230
|
+
Use,
|
|
3231
|
+
ScopeEnum,
|
|
3232
|
+
Repository,
|
|
3233
|
+
RES_CODE,
|
|
3234
|
+
Query,
|
|
3235
|
+
Put,
|
|
3236
|
+
Public,
|
|
3237
|
+
Provide,
|
|
3238
|
+
Post,
|
|
3239
|
+
Perms,
|
|
3240
|
+
Patch,
|
|
3241
|
+
Param,
|
|
3242
|
+
ModuleRegistry,
|
|
3243
|
+
Logger,
|
|
3244
|
+
Ioc,
|
|
3245
|
+
InjectRepository,
|
|
3246
|
+
Inject,
|
|
3247
|
+
IgnorePerms,
|
|
3248
|
+
Get,
|
|
3249
|
+
Eps,
|
|
3250
|
+
Delete,
|
|
3251
|
+
DbStore,
|
|
3252
|
+
Controller,
|
|
3253
|
+
Context,
|
|
3254
|
+
CommException,
|
|
3255
|
+
Body,
|
|
3256
|
+
BaseService,
|
|
3257
|
+
BasePlugin,
|
|
3258
|
+
BaseController,
|
|
3259
|
+
BASE_COLUMN_COMMENTS,
|
|
3260
|
+
App
|
|
3261
|
+
};
|