vome-core 0.0.6 → 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.
Files changed (41) hide show
  1. package/dist/index.js +236 -1
  2. package/dist/server/index.js +3261 -1
  3. package/package.json +10 -2
  4. package/src/admin/components/vm-auto-perm-dialog.vue +3 -0
  5. package/src/admin/components/vm-check-tree.vue +1 -0
  6. package/src/admin/components/vm-dept-tree.vue +3 -0
  7. package/src/admin/components/vm-empty.vue +1 -0
  8. package/src/admin/components/vm-eps-perm-picker.vue +2 -0
  9. package/src/admin/components/vm-group-cascader.vue +1 -0
  10. package/src/admin/components/vm-icon-picker.vue +1 -0
  11. package/src/admin/components/vm-markdown.vue +1 -0
  12. package/src/admin/components/vm-ri-icon.vue +2 -0
  13. package/src/admin/components/vm-role-picker.vue +2 -0
  14. package/src/admin/components/vm-view-path-picker.vue +1 -0
  15. package/src/admin/crud/components/vm-column-custom.vue +1 -0
  16. package/src/admin/crud/components/vm-context-menu.vue +1 -0
  17. package/src/admin/crud/components/vm-date-picker.vue +1 -0
  18. package/src/admin/crud/components/vm-date-range.vue +1 -0
  19. package/src/admin/crud/components/vm-date-text.vue +1 -0
  20. package/src/admin/crud/components/vm-dict-tag.vue +1 -0
  21. package/src/admin/crud/components/vm-file-icon.vue +1 -0
  22. package/src/admin/crud/components/vm-multi-select.vue +1 -0
  23. package/src/admin/crud/components/vm-select.vue +2 -0
  24. package/src/admin/crud/components/vm-switch.vue +1 -0
  25. package/src/admin/crud/components/vm-tree-select.vue +1 -0
  26. package/src/admin/crud/components/vm-upload-item.vue +1 -0
  27. package/src/admin/crud/components/vm-upload.vue +2 -0
  28. package/src/admin/crud/components/vm-user-select.vue +1 -0
  29. package/src/admin/crud/vm-add-btn.vue +1 -0
  30. package/src/admin/crud/vm-adv-search.vue +1 -0
  31. package/src/admin/crud/vm-crud.vue +2 -0
  32. package/src/admin/crud/vm-dialog.vue +1 -0
  33. package/src/admin/crud/vm-form.vue +1 -0
  34. package/src/admin/crud/vm-pagination.vue +1 -0
  35. package/src/admin/crud/vm-search-key.vue +1 -0
  36. package/src/admin/crud/vm-search.vue +1 -0
  37. package/src/admin/crud/vm-table.vue +1 -0
  38. package/src/admin/crud/vm-toolbar.vue +1 -0
  39. package/src/admin/crud/vm-upsert.vue +2 -0
  40. package/src/admin/lib/eps.ts +3 -2
  41. package/src/admin/service/index.ts +143 -46
@@ -1 +1,3261 @@
1
- const _0xde6411=_0x5e13;(function(_0x159a8c,_0x5e78a6){const _0x28456f=_0x5e13,_0x5b11df=_0x159a8c();while(!![]){try{const _0x269a06=-parseInt(_0x28456f(0x264))/0x1*(parseInt(_0x28456f(0x1b0))/0x2)+parseInt(_0x28456f(0x27a))/0x3+parseInt(_0x28456f(0x244))/0x4+parseInt(_0x28456f(0x273))/0x5*(-parseInt(_0x28456f(0x27c))/0x6)+-parseInt(_0x28456f(0x1a3))/0x7*(-parseInt(_0x28456f(0x2d6))/0x8)+parseInt(_0x28456f(0x1c4))/0x9+parseInt(_0x28456f(0x168))/0xa*(-parseInt(_0x28456f(0x217))/0xb);if(_0x269a06===_0x5e78a6)break;else _0x5b11df['push'](_0x5b11df['shift']());}catch(_0x50e992){_0x5b11df['push'](_0x5b11df['shift']());}}}(_0x1903,0x3f142));import{join as _0x1af216}from'path';import{pathToFileURL as _0x5a5ceb}from'url';function P(){const _0x1efe15=_0x5e13;return Bun[_0x1efe15(0x1d2)][_0x1efe15(0x254)]===_0x1efe15(0x2d0)?'dev':_0x1efe15(0x1c0);}function a0(_0x4c596f,_0x31905f){const _0x40607f=_0x5e13;let _0x33218e={..._0x4c596f};for(let _0x58a59b of Object['keys'](_0x31905f)){let _0x44fe2e=_0x33218e[_0x58a59b],_0x211829=_0x31905f[_0x58a59b];if(_0x44fe2e&&_0x211829&&typeof _0x44fe2e==='object'&&typeof _0x211829===_0x40607f(0x221)&&!Array[_0x40607f(0x1f3)](_0x44fe2e)&&!Array[_0x40607f(0x1f3)](_0x211829)){_0x33218e[_0x58a59b]=a0(_0x44fe2e,_0x211829);continue;}_0x33218e[_0x58a59b]=_0x211829;}return _0x33218e;}async function V1(_0x301c84=_0x1af216(process[_0xde6411(0x2ea)](),'src/config')){const _0x443bea=_0xde6411;let _0x90c47a=P()===_0x443bea(0x2d0)?_0x443bea(0x1ce):_0x443bea(0x2a0),_0x185b09=await import(_0x5a5ceb(_0x1af216(_0x301c84,_0x443bea(0x1dc)))[_0x443bea(0x1e0)]),_0x3c8b95=await import(_0x5a5ceb(_0x1af216(_0x301c84,_0x90c47a))[_0x443bea(0x1e0)]);return a0(_0x185b09[_0x443bea(0x1f8)],_0x3c8b95[_0x443bea(0x1f8)]);}var D=await V1();import{Elysia as _0x5737b5}from'elysia';import{Elysia as _0x2260fa}from'elysia';import{AsyncLocalStorage as _0xcb406d}from'async_hooks';var C0=new _0xcb406d(),W1=!0x1;function w3(_0x473e50){const _0x1e6743=_0xde6411;let _0xd25506=_0x473e50['headers'][_0x1e6743(0x1f4)](_0x1e6743(0x1a7));if(_0xd25506){let _0x5024f2=_0xd25506[_0x1e6743(0x1ee)](',')[0x0]?.[_0x1e6743(0x153)]();if(_0x5024f2)return _0x5024f2;}return _0x473e50[_0x1e6743(0x1b6)][_0x1e6743(0x1f4)](_0x1e6743(0x2a5))?.[_0x1e6743(0x153)]()||_0x473e50[_0x1e6743(0x1b6)][_0x1e6743(0x1f4)](_0x1e6743(0x16a))?.['trim']()||'';}function z1(_0x565567){const _0x219038=_0xde6411;let _0x556d1c=new URL(_0x565567[_0x219038(0x26d)]),_0x331198=_0x565567[_0x219038(0x1b6)]['get'](_0x219038(0x1e4))?.[_0x219038(0x1ee)](',')[0x0]?.[_0x219038(0x153)](),_0x607fd1=_0x565567[_0x219038(0x1b6)][_0x219038(0x1f4)](_0x219038(0x1a0))?.[_0x219038(0x153)]();return{'requestId':crypto[_0x219038(0x28a)](),'method':_0x565567[_0x219038(0x2e2)],'path':_0x556d1c[_0x219038(0x169)],'ip':w3(_0x565567),'host':_0x331198||_0x607fd1||_0x556d1c['host'],'startTime':Date[_0x219038(0x26c)]()};}function G1(_0x47dc12){const _0x48a051=_0xde6411;C0[_0x48a051(0x1a1)](_0x47dc12);}function b3(){const _0x3d08b8=_0xde6411;return C0[_0x3d08b8(0x2bf)]();}function y3(_0x15c78e){const _0x444cec=_0xde6411;let _0x1b7973=C0[_0x444cec(0x2bf)]();if(!_0x1b7973){if(P()===_0x444cec(0x2d0)&&!W1)W1=!0x0,console[_0x444cec(0x2b1)](_0x444cec(0x1b9));return;}Object['assign'](_0x1b7973,_0x15c78e);}function g3(_0x2f44bb,_0x30233f){return C0['run'](_0x2f44bb,_0x30233f);}var _=Object[_0xde6411(0x2dd)](y3,{'get':b3,'run':g3});import'reflect-metadata';var I0=new Map();function f(_0x12987f){const _0xf164a7=_0xde6411;I0[_0xf164a7(0x155)](_0x12987f[_0xf164a7(0x2d5)],_0x12987f);}function e0(_0x4a2232){const _0x4fabdc=_0xde6411;return I0[_0x4fabdc(0x1f4)](_0x4a2232);}function Z0(){const _0x356753=_0xde6411;let _0x247400=new Set(),_0x284ffe=[];for(let _0x5278f8 of I0[_0x356753(0x1cd)]()){if(_0x247400[_0x356753(0x1c7)](_0x5278f8[_0x356753(0x188)]))continue;_0x247400['add'](_0x5278f8[_0x356753(0x188)]),_0x284ffe['push'](_0x5278f8);}return _0x284ffe;}function QQ(_0x3b67aa){const _0x31e7c0=_0xde6411;if(typeof _0x3b67aa===_0x31e7c0(0x299)||typeof _0x3b67aa==='symbol')return String(_0x3b67aa);return _0x3b67aa['name']||_0x31e7c0(0x243);}function c(_0xa17ee3,_0x435bd9){const _0x1d29d0=_0xde6411;let _0x15ddb4=Reflect[_0x1d29d0(0x1e7)]('vome:inject',_0xa17ee3)??[];_0x15ddb4['push'](_0x435bd9),Reflect[_0x1d29d0(0x25c)](_0x1d29d0(0x210),_0x15ddb4,_0xa17ee3);}function F1(_0x131b2a){const _0x534915=_0xde6411;return Reflect[_0x534915(0x1e7)](_0x534915(0x210),_0x131b2a)??[];}function j1(){I0['clear']();}var p;(_0x541323=>{const _0x24639c=_0xde6411;_0x541323['Singleton']=_0x24639c(0x308),_0x541323[_0x24639c(0x2e7)]='request',_0x541323['Prototype']=_0x24639c(0x183);})(p||={});var o=new Map(),R0=new Set(),H1=new WeakMap();function h3(_0x2ce356,_0xf85bec){const _0x4974b6=_0xde6411;for(let _0xd7fc8f of F1(_0xf85bec)){let {propertyKey:_0xe48db6,token:_0x3a9ffd,resolve:_0x2b2d66}=_0xd7fc8f;if(!_0x2b2d66&&_0x3a9ffd==null)throw Error('[Ioc]\x20'+String(_0xe48db6)+_0x4974b6(0x276));let _0x468162=_0x2b2d66?_0x2b2d66():K[_0x4974b6(0x1f4)](_0x3a9ffd);_0x2ce356[_0xe48db6]=_0x468162;let _0x4ef816=_0x2ce356[_0x4974b6(0x2f7)];if(_0x2b2d66&&typeof _0x4ef816===_0x4974b6(0x14d))_0x4ef816[_0x4974b6(0x162)](_0x2ce356,_0x468162);}}function $Q(_0x4d3987){const _0x45b402=_0xde6411;if(R0[_0x45b402(0x1c7)](_0x4d3987))throw Error(_0x45b402(0x240)+_0x4d3987[_0x45b402(0x194)]);R0[_0x45b402(0x216)](_0x4d3987);try{let _0x5a25c3=new _0x4d3987();return h3(_0x5a25c3,_0x4d3987),_0x5a25c3;}finally{R0['delete'](_0x4d3987);}}function B1(_0x2c2345){const _0x10a5d5=_0xde6411;let _0x1641cf=o[_0x10a5d5(0x1f4)](_0x2c2345);if(_0x1641cf)return _0x1641cf;let _0x985d9=$Q(_0x2c2345);return o[_0x10a5d5(0x155)](_0x2c2345,_0x985d9),_0x985d9;}function u3(){const _0x4d1bed=_0xde6411;let _0xa4f0c5=_[_0x4d1bed(0x1f4)]();if(!_0xa4f0c5)throw Error(_0x4d1bed(0x229));let _0x58ef8f=H1[_0x4d1bed(0x1f4)](_0xa4f0c5);if(!_0x58ef8f)_0x58ef8f=new Map(),H1[_0x4d1bed(0x155)](_0xa4f0c5,_0x58ef8f);return _0x58ef8f;}function m3(_0x144f04){const _0x4c067b=_0xde6411;let _0x958376=u3(),_0x5c582f=_0x958376['get'](_0x144f04);if(_0x5c582f)return _0x5c582f;let _0x547ffb=$Q(_0x144f04);return _0x958376[_0x4c067b(0x155)](_0x144f04,_0x547ffb),_0x547ffb;}function c3(_0x597ab6,_0x46ac52){const _0x23392e=_0xde6411;switch(_0x46ac52){case'singleton':return B1(_0x597ab6);case _0x23392e(0x183):return $Q(_0x597ab6);case _0x23392e(0x284):return m3(_0x597ab6);default:throw Error(_0x23392e(0x223)+_0x46ac52);}}function p3(_0x5ccf19){const _0x512659=_0xde6411;let _0x5c59f0=e0(_0x5ccf19);if(!_0x5c59f0)throw Error(_0x512659(0x253)+QQ(_0x5ccf19));return _0x5c59f0;}function ZQ(){const _0x24fd9f=_0xde6411;for(let {useClass:_0x447df2,scope:_0x42bac3}of Z0())if(_0x42bac3===_0x24fd9f(0x308))B1(_0x447df2);console[_0x24fd9f(0x211)](_0x24fd9f(0x16f)+o[_0x24fd9f(0x292)]+_0x24fd9f(0x142));}function d3(_0x1f954b){const _0x3ba97e=_0xde6411;let _0x244471=p3(_0x1f954b);return c3(_0x244471[_0x3ba97e(0x188)],_0x244471[_0x3ba97e(0x2c7)]);}function n3(_0x57291,_0x5920c0){const _0x29a3d0=_0xde6411;if(typeof _0x57291===_0x29a3d0(0x14d)){f({'token':_0x57291,'useClass':_0x57291,'scope':_0x29a3d0(0x308)}),o['set'](_0x57291,_0x5920c0);return;}let _0x1b7b09=_0x5920c0?.[_0x29a3d0(0x157)];if(!_0x1b7b09||_0x1b7b09===Object)throw Error(_0x29a3d0(0x1f6)+QQ(_0x57291)+')\x20需要\x20class\x20实例,以便确定\x20useClass');f({'token':_0x57291,'useClass':_0x1b7b09,'scope':'singleton'}),f({'token':_0x1b7b09,'useClass':_0x1b7b09,'scope':_0x29a3d0(0x308)}),o[_0x29a3d0(0x155)](_0x1b7b09,_0x5920c0);}function JQ(){o['clear'](),R0['clear'](),j1();}var K={'get':d3,'set':n3};import'reflect-metadata';var M1=new Map();function L1(_0x2f4883){const _0x1fbce6=_0xde6411;M1[_0x1fbce6(0x155)](_0x2f4883[_0x1fbce6(0x2d5)],_0x2f4883);}function O(_0x3aab08){const _0x134303=_0xde6411;let _0x499d3f=[...M1['values']()];return _0x3aab08?_0x499d3f[_0x134303(0x24f)](_0x1c7d0a=>_0x1c7d0a[_0x134303(0x1bb)]===_0x3aab08):_0x499d3f;}var q0=_0xde6411(0x1cf),S0=_0xde6411(0x1ae),E0=_0xde6411(0x1c9),P0='vome:controller:route-perms',O0=_0xde6411(0x19a);function Y1(_0x4e1868,_0x267744,_0x587005){const _0x9b27bd=_0xde6411;let _0x28fafa=Reflect['getMetadata'](q0,_0x4e1868)??{},_0x3aaa89=_0x28fafa[_0x267744]??[];_0x3aaa89[_0x9b27bd(0x281)](_0x587005),_0x28fafa[_0x267744]=_0x3aaa89,Reflect['defineMetadata'](q0,_0x28fafa,_0x4e1868);}function U1(_0x1a93eb,_0x418a6e){return Reflect['getMetadata'](q0,_0x1a93eb)?.[_0x418a6e]??[];}function D1(_0x32ac89){Reflect['deleteMetadata'](q0,_0x32ac89);}function T1(_0x32398c,_0x562cd9){const _0x29042e=_0xde6411;let _0x44a49a=Reflect[_0x29042e(0x1e7)](S0,_0x32398c)??{};_0x44a49a[_0x562cd9]=!0x0,Reflect[_0x29042e(0x25c)](S0,_0x44a49a,_0x32398c);}function N1(_0x3edc7e,_0x58056c){const _0x191939=_0xde6411;return!!Reflect[_0x191939(0x1e7)](S0,_0x3edc7e)?.[_0x58056c];}function A1(_0x5ca999){Reflect['deleteMetadata'](S0,_0x5ca999);}function K1(_0x28ec3a,_0x4256cd,_0x6c0aba){let _0x12a71e=Reflect['getMetadata'](E0,_0x28ec3a)??{};_0x12a71e[_0x4256cd]=[..._0x12a71e[_0x4256cd]??[],..._0x6c0aba],Reflect['defineMetadata'](E0,_0x12a71e,_0x28ec3a);}function _1(_0x6d3a91,_0xccbcff){return Reflect['getMetadata'](E0,_0x6d3a91)?.[_0xccbcff]??[];}function C1(_0x2d1126){const _0x574f1f=_0xde6411;Reflect[_0x574f1f(0x1b7)](E0,_0x2d1126);}function I1(_0x62051f,_0x41ea35,_0x46b68f){const _0x445fc4=_0xde6411;let _0x39538a=Reflect['getMetadata'](P0,_0x62051f)??{};_0x39538a[_0x41ea35]=_0x46b68f,Reflect[_0x445fc4(0x25c)](P0,_0x39538a,_0x62051f);}function R1(_0x46cf91,_0x36553f){const _0x4a4077=_0xde6411;return Reflect[_0x4a4077(0x1e7)](P0,_0x46cf91)?.[_0x36553f];}function q1(_0xa48cc8){const _0x3e441d=_0xde6411;Reflect[_0x3e441d(0x1b7)](P0,_0xa48cc8);}function S1(_0x4b0f4c,_0x597d96){const _0xd6b41c=_0xde6411;let _0xb6cc7d=Reflect[_0xd6b41c(0x1e7)](O0,_0x4b0f4c)??{};_0xb6cc7d[_0x597d96]=!0x0,Reflect[_0xd6b41c(0x25c)](O0,_0xb6cc7d,_0x4b0f4c);}function E1(_0x4a3c5b,_0x7b0b54){return!!Reflect['getMetadata'](O0,_0x4a3c5b)?.[_0x7b0b54];}function P1(_0x4e1992){const _0x3d883e=_0xde6411;Reflect[_0x3d883e(0x1b7)](O0,_0x4e1992);}function x0(_0x11908e){const _0x4d7f37=_0xde6411;let _0x337a7d={};for(let _0x193f9f of _0x11908e){if(_0x193f9f[_0x4d7f37(0x1dd)]==='body'&&_0x193f9f[_0x4d7f37(0x25f)]!==void 0x0)_0x337a7d[_0x4d7f37(0x2b7)]=_0x193f9f[_0x4d7f37(0x25f)];if(_0x193f9f[_0x4d7f37(0x1dd)]===_0x4d7f37(0x26a)&&_0x193f9f[_0x4d7f37(0x25f)]!==void 0x0)_0x337a7d[_0x4d7f37(0x26a)]=_0x193f9f['schema'];if(_0x193f9f[_0x4d7f37(0x1dd)]===_0x4d7f37(0x203)&&_0x193f9f[_0x4d7f37(0x25f)]!==void 0x0)_0x337a7d[_0x4d7f37(0x203)]=_0x193f9f[_0x4d7f37(0x25f)];}return Object[_0x4d7f37(0x233)](_0x337a7d)[_0x4d7f37(0x1e8)]>0x0?_0x337a7d:void 0x0;}function J0(_0x44e742,_0x5f353b){return _0x44e742+'.'+_0x5f353b;}function v0(_0x4729f7){const _0x2aeeea=_0xde6411;if(_0x4729f7===_0x2aeeea(0x21b))return 0x0;if(_0x4729f7==='app')return 0x1;return 0x2;}function k0(_0x37307c){const _0x163406=_0xde6411;let _0x395ab7=_0x37307c['lastIndexOf']('.');if(_0x395ab7<0x0)return{'module':_0x37307c,'side':''};return{'module':_0x37307c[_0x163406(0x16e)](0x0,_0x395ab7),'side':_0x37307c[_0x163406(0x16e)](_0x395ab7+0x1)};}function O1(){const _0x551b13=_0xde6411;let _0x4261bd=O(),_0xd0ae46=new Map(),_0x628230=new Map();for(let _0x635f97 of _0x4261bd){let _0x365034=J0(_0x635f97[_0x551b13(0x204)],_0x635f97[_0x551b13(0x1bb)]);if(!_0xd0ae46[_0x551b13(0x1c7)](_0x365034))_0xd0ae46[_0x551b13(0x155)](_0x365034,{'name':_0x365034,'description':_0x635f97[_0x551b13(0x204)]+'\x20'+_0x635f97[_0x551b13(0x1bb)],'x-displayName':_0x635f97[_0x551b13(0x1bb)]});let _0x18b799=_0x628230[_0x551b13(0x1f4)](_0x635f97[_0x551b13(0x204)]);if(!_0x18b799)_0x18b799=new Set(),_0x628230[_0x551b13(0x155)](_0x635f97[_0x551b13(0x204)],_0x18b799);_0x18b799[_0x551b13(0x216)](_0x365034);}let _0x4cd2bc=[..._0xd0ae46[_0x551b13(0x1cd)]()][_0x551b13(0x212)]((_0x3ee952,_0x3e9f7b)=>{const _0x4d3cba=_0x551b13;let _0x239d76=k0(_0x3ee952[_0x4d3cba(0x194)]),_0x1ca39f=k0(_0x3e9f7b[_0x4d3cba(0x194)]);return _0x239d76['module']['localeCompare'](_0x1ca39f[_0x4d3cba(0x204)])||v0(_0x239d76[_0x4d3cba(0x1bb)])-v0(_0x1ca39f[_0x4d3cba(0x1bb)]);}),_0x26fbf9=[..._0x628230['entries']()][_0x551b13(0x212)](([_0x1ef6f1],[_0x507eb5])=>_0x1ef6f1[_0x551b13(0x263)](_0x507eb5))[_0x551b13(0x186)](([_0x189cf2,_0x23b092])=>({'name':_0x189cf2,'tags':[..._0x23b092][_0x551b13(0x212)]((_0xa14260,_0x6032bd)=>{const _0x194e28=_0x551b13;let _0x5f3da2=k0(_0xa14260)['side'],_0x3c3f5e=k0(_0x6032bd)[_0x194e28(0x1bb)];return v0(_0x5f3da2)-v0(_0x3c3f5e);})}));return{'tags':_0x4cd2bc,'tagGroups':_0x26fbf9};}function w(_0x44a25a){const _0x21d3a2=_0xde6411;if(!_0x44a25a)return'';return _0x44a25a[_0x21d3a2(0x154)]('/')?_0x44a25a:'/'+_0x44a25a;}function b(..._0x5ec939){const _0x52638b=_0xde6411;let _0xd5f56c=_0x5ec939[_0x52638b(0x186)](_0x27b06c=>w(_0x27b06c)[_0x52638b(0x307)](/^\/+|\/+$/g,''))['filter'](Boolean);return _0xd5f56c[_0x52638b(0x1e8)]?'/'+_0xd5f56c['join']('/'):'/';}function d(_0xdba491,_0x334a65){const _0x47da80=_0xde6411;let _0x4276aa=w(_0x334a65)[_0x47da80(0x307)](/\/$/,''),_0x235617=w(_0xdba491);if(!_0x4276aa)return _0x235617||'/';if(_0x235617===_0x4276aa)return'/';if(_0x235617[_0x47da80(0x154)](_0x4276aa+'/'))return _0x235617[_0x47da80(0x16e)](_0x4276aa[_0x47da80(0x1e8)])||'/';return(_0xdba491[_0x47da80(0x154)]('/')?_0xdba491:'/'+_0xdba491)||'/';}function XQ(_0x36e1f6,_0x10fce9,_0x52f971){const _0xe7d784=_0xde6411;let _0x1250ae=_0x10fce9[_0xe7d784(0x307)](/^\//,'')[_0xe7d784(0x307)](/\/+/g,':');if(_0x1250ae===_0x36e1f6)_0x1250ae=_0x36e1f6;else{if(_0x1250ae[_0xe7d784(0x154)](_0x36e1f6+':'))_0x1250ae=_0x1250ae[_0xe7d784(0x16e)](_0x36e1f6[_0xe7d784(0x1e8)]+0x1);}let _0x82ac06=_0x36e1f6+'-';if(_0x1250ae[_0xe7d784(0x154)](_0x82ac06))_0x1250ae=_0x1250ae[_0xe7d784(0x16e)](_0x82ac06[_0xe7d784(0x1e8)]);if(_0x1250ae=_0x1250ae[_0xe7d784(0x307)](/-/g,':'),!_0x1250ae)_0x1250ae=_0x36e1f6;return _0x36e1f6+':'+_0x1250ae+':'+_0x52f971;}function VQ(_0x1079c1){const _0x9a97db=_0xde6411;let _0x10d90c=_0x1079c1['replace'](/^\/+|\/+$/g,'');if(!_0x10d90c)return _0x9a97db(0x1cc);let _0x563466=_0x10d90c[_0x9a97db(0x1ee)]('/');return _0x563466[_0x563466['length']-0x1]||'index';}function r(_0x3131b,_0x3f7189,_0x41c355){const _0x421b0c=_0xde6411;if(_0x3f7189['side']!==_0x421b0c(0x21b)||_0x3131b[_0x421b0c(0x1d9)]||_0x3131b[_0x421b0c(0x145)])return;if(_0x3131b[_0x421b0c(0x2dc)]?.['length'])return _0x3131b[_0x421b0c(0x2dc)];let _0x2bf1ec=_0x41c355??VQ(d(_0x3131b[_0x421b0c(0x305)]??'/',_0x3f7189[_0x421b0c(0x2f9)]));return[XQ(_0x3f7189[_0x421b0c(0x204)],_0x3f7189[_0x421b0c(0x2f9)],_0x2bf1ec)];}var WQ;function f0(_0x36a958){WQ=_0x36a958;}var i3={'admin':_0xde6411(0x29c),'app':_0xde6411(0x18d)},x1=_0xde6411(0x2f8),s3='auth',o3={'GET':_0xde6411(0x1f4),'POST':'post','PUT':_0xde6411(0x2fa),'DELETE':_0xde6411(0x28d),'PATCH':_0xde6411(0x247)};function r3(_0x30e874){return w(i3[_0x30e874]);}function a3(_0x18c7c9){const _0x3e4d7f=_0xde6411;if(_0x18c7c9[_0x3e4d7f(0x203)]?.['length'])return x0(_0x18c7c9[_0x3e4d7f(0x203)]);let _0x51dd99={};if(_0x18c7c9[_0x3e4d7f(0x2b7)]!==void 0x0)_0x51dd99[_0x3e4d7f(0x2b7)]=_0x18c7c9['body'];if(_0x18c7c9[_0x3e4d7f(0x26a)]!==void 0x0)_0x51dd99[_0x3e4d7f(0x26a)]=_0x18c7c9[_0x3e4d7f(0x26a)];if(_0x18c7c9[_0x3e4d7f(0x29a)]!==void 0x0)_0x51dd99[_0x3e4d7f(0x203)]=_0x18c7c9[_0x3e4d7f(0x29a)];return Object[_0x3e4d7f(0x233)](_0x51dd99)[_0x3e4d7f(0x1e8)]>0x0?_0x51dd99:void 0x0;}function t3(_0x1a63cf,_0x5b3336,_0x182ab4){const _0x231d94=_0xde6411;let _0x24d424=new Set();for(let _0x94d6d of _0x1a63cf){if(_0x24d424['has'](_0x94d6d['source'])){let _0x5e0d4e=_0x94d6d['source']==='body'?_0x231d94(0x236):_0x94d6d[_0x231d94(0x1dd)]===_0x231d94(0x26a)?_0x231d94(0x27f):_0x231d94(0x225);throw Error(_0x231d94(0x2e1)+_0x182ab4+'.'+_0x5b3336+'\x20重复\x20@'+_0x5e0d4e);}_0x24d424[_0x231d94(0x216)](_0x94d6d[_0x231d94(0x1dd)]);}}function e3(_0x341349,_0x308190,_0x27ab91){const _0x86cfb0=_0xde6411;let _0x402667=_0x341349[_0x308190][_0x86cfb0(0x1b2)](_0x341349);if(!_0x27ab91?.[_0x86cfb0(0x1e8)])return _0x402667;let _0x58010a=[..._0x27ab91][_0x86cfb0(0x212)]((_0x2236ee,_0x4e9df6)=>_0x2236ee['index']-_0x4e9df6[_0x86cfb0(0x1cc)]);return _0x1585aa=>{const _0x56af1d=_0x86cfb0;let _0x38d63f=_0x58010a[_0x56af1d(0x186)](_0x53651e=>{const _0x3e3720=_0x56af1d;if(_0x53651e[_0x3e3720(0x1dd)]===_0x3e3720(0x2b7))return _0x1585aa[_0x3e3720(0x2b7)];if(_0x53651e['source']===_0x3e3720(0x26a))return _0x1585aa[_0x3e3720(0x26a)];if(_0x53651e['source']===_0x3e3720(0x203))return _0x1585aa['params'];throw Error(_0x3e3720(0x306)+_0x53651e[_0x3e3720(0x1dd)]);});return _0x402667(..._0x38d63f,_0x1585aa);};}function v1(_0x3d1431){return _0x5329a1=>{const _0x59db23=_0x5e13;let _0x5f52e0=_0x5329a1[_0x59db23(0x2c3)],_0x20de85=_['get']();if(_0x20de85?.['isSuper'])return;let _0x3861f5=_0x20de85?.[_0x59db23(0x2dc)]??[];if(_0x3d1431[_0x59db23(0x2f4)](_0x6cd3f8=>_0x3861f5[_0x59db23(0x261)](_0x6cd3f8)))return;return _0x5f52e0(0x193);};}function k1(_0x15c24b,_0x9696f3){const _0x16d4dd=_0xde6411;let _0x2e0a0f=_0x15c24b[_0x16d4dd(0x307)](/^\/+|\/+$/g,'')[_0x16d4dd(0x1ee)]('/')['pop']()||_0x15c24b;return _0x9696f3?_0x2e0a0f+'\x20'+_0x9696f3:_0x2e0a0f;}function Q4(_0x34aecd,_0x488de3){const _0x1f496d=_0xde6411;let _0x45bf31={...a3(_0x34aecd)??{},'detail':{'tags':[J0(_0x488de3[_0x1f496d(0x204)],_0x488de3[_0x1f496d(0x1bb)])],'summary':k1(_0x34aecd[_0x1f496d(0x23b)],_0x34aecd['summary'])}};if(_0x488de3['side']===_0x1f496d(0x21b)&&!_0x34aecd[_0x1f496d(0x1d9)])_0x45bf31[x1]=!0x0;if(_0x488de3[_0x1f496d(0x1bb)]==='app'&&!_0x34aecd['public'])_0x45bf31[s3]=!0x0;let _0x3757b4=[],_0x220d63=r(_0x34aecd,_0x488de3);if(_0x220d63?.['length'])_0x3757b4[_0x1f496d(0x281)](v1(_0x220d63));if(_0x34aecd[_0x1f496d(0x1a4)]?.['length'])_0x3757b4[_0x1f496d(0x281)](..._0x34aecd[_0x1f496d(0x1a4)]);if(_0x3757b4[_0x1f496d(0x1e8)])_0x45bf31[_0x1f496d(0x16b)]=_0x3757b4;return _0x45bf31;}function $4(_0x15ad2f){const _0x2b7c64=_0xde6411;if(_0x15ad2f==null)return{};if(typeof _0x15ad2f===_0x2b7c64(0x17f))return{'public':_0x15ad2f};return _0x15ad2f;}function Z4(_0x88139c,_0x15f23a){const _0x89c7fd=_0xde6411;let _0x292e17=r3(_0x88139c['side']),_0x2baf09=b(_0x292e17,_0x88139c['prefix']),_0x286685=K[_0x89c7fd(0x1f4)](_0x88139c[_0x89c7fd(0x2d5)]),_0x126a33=new _0x2260fa({'prefix':_0x2baf09,'name':_0x88139c[_0x89c7fd(0x2d5)][_0x89c7fd(0x194)],'tags':[J0(_0x88139c[_0x89c7fd(0x204)],_0x88139c['side'])]});for(let _0x1fc0d7 of _0x88139c['middleware']??[])_0x126a33=_0x126a33[_0x89c7fd(0x22e)](_0x1fc0d7);let _0x5f1dec=[];for(let _0x294703 of _0x88139c[_0x89c7fd(0x278)]){if(typeof _0x286685[_0x294703[_0x89c7fd(0x23b)]]!==_0x89c7fd(0x14d))throw Error(_0x89c7fd(0x2e1)+_0x88139c[_0x89c7fd(0x2d5)][_0x89c7fd(0x194)]+'.'+_0x294703[_0x89c7fd(0x23b)]+'\x20不是有效\x20handler');t3(_0x294703[_0x89c7fd(0x203)]??[],_0x294703[_0x89c7fd(0x23b)],_0x88139c[_0x89c7fd(0x2d5)][_0x89c7fd(0x194)]);let _0xe78609=e3(_0x286685,_0x294703[_0x89c7fd(0x23b)],_0x294703[_0x89c7fd(0x203)]),_0x1cb953=d(_0x294703[_0x89c7fd(0x305)],_0x88139c[_0x89c7fd(0x2f9)]),_0x1add7a=Q4(_0x294703,_0x88139c),_0x3f6071=o3[_0x294703['method']];_0x126a33=_0x126a33[_0x3f6071](_0x1cb953,_0xe78609,_0x1add7a);}if(_0x88139c['crud']?.['api']?.[_0x89c7fd(0x1e8)]||_0x88139c[_0x89c7fd(0x1bc)]?.[_0x89c7fd(0x175)]?.[_0x89c7fd(0x1e8)]){if(!WQ)throw Error(_0x89c7fd(0x2e1)+_0x88139c[_0x89c7fd(0x2d5)][_0x89c7fd(0x194)]+'\x20配置了\x20api/serviceApis,但未找到\x20CRUD\x20实现(@vome-core\x20attachCrudRoutes\x20未挂载)');_0x126a33=WQ(_0x126a33,_0x88139c,{'controller':_0x286685,'routeOptions':_0x236c74=>{const _0x478cfb=_0x89c7fd;let {public:_0x319a63,action:_0x23407c,summary:_0x9a245a}=$4(_0x236c74),_0x4d78ec={'detail':{'tags':[J0(_0x88139c['module'],_0x88139c['side'])],'summary':k1(_0x23407c??_0x478cfb(0x208),_0x9a245a)}};if(_0x88139c['side']===_0x478cfb(0x21b)&&!_0x319a63){if(_0x4d78ec[x1]=!0x0,_0x23407c){let _0x497286=XQ(_0x88139c[_0x478cfb(0x204)],_0x88139c[_0x478cfb(0x2f9)],_0x23407c);_0x4d78ec[_0x478cfb(0x16b)]=[v1([_0x497286])];}}return _0x4d78ec;}});for(let _0x3280c4 of _0x88139c[_0x89c7fd(0x1bc)]?.[_0x89c7fd(0x283)]??[]){let _0x1bda9c=_0x3280c4===_0x89c7fd(0x295)?_0x89c7fd(0x287):_0x89c7fd(0x15a);_0x5f1dec['push']({'method':_0x1bda9c,'path':b(_0x88139c[_0x89c7fd(0x2f9)],_0x3280c4),'handler':_0x3280c4,'autoCrud':!0x0});}for(let _0x24db1f of _0x88139c['crud']?.['serviceApis']??[])_0x5f1dec[_0x89c7fd(0x281)]({'method':_0x89c7fd(0x15a),'path':b(_0x88139c['prefix'],_0x24db1f),'handler':_0x24db1f,'autoCrud':!0x0});}return{'plugin':_0x126a33,'pluginPrefix':_0x2baf09,'autoRoutes':_0x5f1dec};}function f1(_0x532812,_0x50e7e2){const _0x176a4a=_0xde6411;let _0x94ad0=_0x532812,_0x4dceaa=0x0,_0x5a6845=[];for(let _0x49fa1c of O()){let {plugin:_0x4460ff,pluginPrefix:_0x471364,autoRoutes:_0x356e7d}=Z4(_0x49fa1c,_0x50e7e2);_0x94ad0=_0x94ad0[_0x176a4a(0x265)](_0x4460ff);for(let _0x1a466c of[..._0x49fa1c[_0x176a4a(0x278)],..._0x356e7d]){_0x4dceaa+=0x1;let _0x346dc2=d(_0x1a466c['path'],_0x49fa1c[_0x176a4a(0x2f9)]),_0x20854f=_0x346dc2==='/'?_0x471364:b(_0x471364,_0x346dc2[_0x176a4a(0x307)](/^\//,'')),_0x56c14e=_0x1a466c[_0x176a4a(0x1d9)]?'\x20(public)':_0x1a466c[_0x176a4a(0x26e)]?'\x20(crud)':'';_0x5a6845[_0x176a4a(0x281)](_0x1a466c[_0x176a4a(0x2e2)]+'\x20'+_0x20854f+_0x56c14e);}}if(_0x4dceaa>0x0){console[_0x176a4a(0x211)]('[Router]\x20registered\x20←\x20'+_0x4dceaa+_0x176a4a(0x201));for(let _0x50d244 of _0x5a6845)console[_0x176a4a(0x211)]('\x20\x20'+_0x50d244);}return _0x94ad0;}var {Glob:J4}=globalThis[_0xde6411(0x2bc)],X4=/\.tsx?$/;async function X0(_0x47154d,_0x581932={}){const _0x3684e4=_0xde6411;let {cwd:_0x5d859d=process[_0x3684e4(0x2ea)](),ext:_0x1afa6d=X4}=_0x581932,_0x75fbcd=Array['isArray'](_0x47154d)?_0x47154d:[_0x47154d],_0x540d23=[];for(let _0xc91ae4 of _0x75fbcd){let _0xaa00df=new J4(_0xc91ae4);for await(let _0x15d92a of _0xaa00df[_0x3684e4(0x2b6)]({'cwd':_0x5d859d,'onlyFiles':!0x0}))if(_0x1afa6d[_0x3684e4(0x1df)](_0x15d92a))_0x540d23[_0x3684e4(0x281)](_0x15d92a);}return[...new Set(_0x540d23)][_0x3684e4(0x212)]();}var w1=null;function zQ(_0x41693d){w1=_0x41693d;}function b1(){return w1;}function y1(_0x2e399b){const _0x192e5e=_0xde6411;let _0x47d3a9=_0x2e399b[_0x192e5e(0x1fa)](/modules\/([^/]+)\/controller\//);if(!_0x47d3a9)return _0x192e5e(0x192);return _0x47d3a9[0x1];}function g1(_0x1aa0ce){const _0x5384b2=_0xde6411;let _0x5bf255=_0x1aa0ce['replace'](/\\/g,'/')[_0x5384b2(0x1fa)](/modules\/([^/]+)\/controller\/(?:admin|app)\/(.+)\.tsx?$/);if(!_0x5bf255)return'';let _0x34e2a2=_0x5bf255[0x1],_0x3b53f7=_0x5bf255[0x2][_0x5384b2(0x307)](/\/+/g,'/')[_0x5384b2(0x307)](/^\/|\/$/g,'');if(!_0x3b53f7)return'/'+_0x34e2a2;return'/'+_0x34e2a2+'/'+_0x3b53f7;}var V4=/(?:Time|Date|At)$/,W4=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;function h1(_0x2037a7){const _0x1652a3=_0xde6411;let _0x21e066=_0x2037a7 instanceof Date?_0x2037a7:new Date(_0x2037a7);if(Number['isNaN'](_0x21e066['getTime']()))return String(_0x2037a7);return new Intl[(_0x1652a3(0x19f))](_0x1652a3(0x1ca),{'timeZone':_0x1652a3(0x19b),'year':_0x1652a3(0x20e),'month':_0x1652a3(0x25b),'day':'2-digit','hour':_0x1652a3(0x25b),'minute':'2-digit','second':_0x1652a3(0x25b),'hour12':!0x1})[_0x1652a3(0x199)](_0x21e066)[_0x1652a3(0x307)]('T','\x20');}function z4(_0x5a5a81){const _0x410b63=_0xde6411;return V4[_0x410b63(0x1df)](_0x5a5a81);}function u1(_0xb09745){return GQ(_0xb09745);}function GQ(_0xe6db8e,_0x30cfa7){const _0x322f25=_0xde6411;if(_0xe6db8e==null)return _0xe6db8e;if(_0xe6db8e instanceof Date)return h1(_0xe6db8e);if(typeof _0xe6db8e==='string'&&_0x30cfa7&&z4(_0x30cfa7)&&W4['test'](_0xe6db8e))return h1(_0xe6db8e);if(Array[_0x322f25(0x1f3)](_0xe6db8e))return _0xe6db8e[_0x322f25(0x186)](_0x4c75dd=>GQ(_0x4c75dd));if(typeof _0xe6db8e===_0x322f25(0x221)){if(Object[_0x322f25(0x183)][_0x322f25(0x2ce)][_0x322f25(0x162)](_0xe6db8e)!=='[object\x20Object]')return _0xe6db8e;let _0x4002ae={};for(let [_0x4b925b,_0x13bf49]of Object[_0x322f25(0x28f)](_0xe6db8e))_0x4002ae[_0x4b925b]=GQ(_0x13bf49,_0x4b925b);return _0x4002ae;}return _0xe6db8e;}var C={'SUCCESS':0x3e8,'ERROR':0x3e9};class n{['ok'](_0x12964e){let _0x5f09de=_0x12964e===void 0x0?null:_0x12964e;return{'code':C['SUCCESS'],'message':'success','data':_0x5f09de==null?_0x5f09de:u1(_0x5f09de)};}[_0xde6411(0x297)](_0x2077e1='error',_0x3508ef=C[_0xde6411(0x294)]){return{'code':_0x3508ef,'message':_0x2077e1};}}import'reflect-metadata';function G4(_0x10ef76){const _0x3c89bb=_0xde6411;if(_0x10ef76==null)return{};if(typeof _0x10ef76===_0x3c89bb(0x299)||typeof _0x10ef76===_0x3c89bb(0x2ab))return{'id':_0x10ef76};return _0x10ef76;}function FQ(_0x54d9d2){return _0x78cd44=>{const _0x57feab=_0x5e13;let _0x3c9cd3=G4(_0x54d9d2),_0x591605=_0x3c9cd3[_0x57feab(0x2c7)]??'singleton';if(f({'token':_0x78cd44,'useClass':_0x78cd44,'scope':_0x591605}),_0x3c9cd3['id']!=null)f({'token':_0x3c9cd3['id'],'useClass':_0x78cd44,'scope':_0x591605});};}function jQ(_0x3d8a29){return(_0x1eee73,_0x31e18a)=>{const _0x5b5bae=_0x5e13;let _0x1e1b3e=Reflect[_0x5b5bae(0x1e7)](_0x5b5bae(0x190),_0x1eee73,_0x31e18a),_0x9ee906=_0x3d8a29??_0x1e1b3e;if(_0x9ee906==null)throw Error(_0x5b5bae(0x215)+String(_0x31e18a)+_0x5b5bae(0x1ab));c(_0x1eee73[_0x5b5bae(0x157)],{'propertyKey':_0x31e18a,'token':_0x9ee906});};}import{and as _0x4dd14d,arrayContains as _0x41efe7,arrayOverlaps as _0x413919,asc as _0x574a9f,desc as _0x734e27,eq as _0x38a505,gte as _0x5d74ad,inArray as _0x1a46dd,like as _0x26d1ce,lte as _0x33b079,or as _0x4be8ef,sql as _0xa87cb0}from'drizzle-orm';function BQ(_0x2994ae){const _0x2dca8c=_0xde6411;if(typeof _0x2994ae===_0x2dca8c(0x299)){let _0x21fcfc=_0x2994ae[_0x2dca8c(0x261)]('.')?_0x2994ae['split']('.')[_0x2dca8c(0x2e5)]():_0x2994ae;return{'column':_0x21fcfc,'param':_0x21fcfc,'none':!0x1};}let _0x2f7a05=_0x2994ae[_0x2dca8c(0x2ef)][_0x2dca8c(0x261)]('.')?_0x2994ae['column'][_0x2dca8c(0x1ee)]('.')[_0x2dca8c(0x2e5)]():_0x2994ae[_0x2dca8c(0x2ef)];return{'column':_0x2f7a05,'param':_0x2994ae[_0x2dca8c(0x1b1)]??_0x2f7a05,'none':Boolean(_0x2994ae['none'])};}function U4(_0x4c30a5){const _0x4bffd0=_0xde6411;return _0x4c30a5[_0x4bffd0(0x2ef)][_0x4bffd0(0x261)]('.')?_0x4c30a5[_0x4bffd0(0x2ef)][_0x4bffd0(0x1ee)]('.')[_0x4bffd0(0x2e5)]():_0x4c30a5[_0x4bffd0(0x2ef)];}function h(_0x2e903d,_0x209aa4){let _0x183b15=_0x2e903d[_0x209aa4];if(_0x183b15==null)throw Error('[QueryOp]\x20表无字段:\x20'+_0x209aa4);return _0x183b15;}function y(_0x27581d){return _0x27581d===void 0x0||_0x27581d===null||_0x27581d==='';}function MQ(_0x110d67){const _0x356a93=_0xde6411;if(_0x110d67==null||_0x110d67===!0x1)return[];return(Array[_0x356a93(0x1f3)](_0x110d67)?_0x110d67:[_0x110d67])['filter'](_0xed53db=>_0xed53db!=null&&_0xed53db!==!0x1);}var V0={'between'(_0x21e2d,_0x4135b1,_0x1d2610){if(y(_0x4135b1)||y(_0x1d2610))return;return _0xa87cb0`${_0x21e2d} between ${_0x4135b1} and ${_0x1d2610}`;},'range'(_0x360885,_0x4fe4d4,_0x411ab8){const _0x17e6a7=_0xde6411;let _0x3fe051=[];if(!y(_0x4fe4d4))_0x3fe051[_0x17e6a7(0x281)](_0x5d74ad(_0x360885,_0x4fe4d4));if(!y(_0x411ab8))_0x3fe051[_0x17e6a7(0x281)](_0x33b079(_0x360885,_0x411ab8));if(!_0x3fe051['length'])return;return _0x3fe051[_0x17e6a7(0x1e8)]===0x1?_0x3fe051[0x0]:_0x4dd14d(..._0x3fe051);},'eqRest'(_0x250f9f,_0x1ce2c4,_0x5e0c99){const _0x8e9477=_0xde6411;let _0x5b0cce=[];for(let [_0x487f15,_0x1c8a46]of Object[_0x8e9477(0x28f)](_0x250f9f)){if(y(_0x1c8a46))continue;let _0x2b422b=_0x5e0c99?.[_0x487f15]??_0x1ce2c4[_0x487f15];if(_0x2b422b==null)continue;_0x5b0cce[_0x8e9477(0x281)](_0x38a505(_0x2b422b,_0x1c8a46));}return _0x5b0cce;},'contains'(_0x434f78,_0x568ba1){const _0x3026a5=_0xde6411;if(y(_0x568ba1))return;let _0x2134f0=Array[_0x3026a5(0x1f3)](_0x568ba1)?_0x568ba1:[_0x568ba1];if(!_0x2134f0['length'])return;return _0x2134f0[_0x3026a5(0x1e8)]===0x1?_0x41efe7(_0x434f78,_0x2134f0):_0x413919(_0x434f78,_0x2134f0);}};function D4(_0x1e8f64,_0x1a0590,_0x47bc5e){const _0x2f6c8c=_0xde6411;let _0x47a192=[];if(_0x47bc5e[_0x2f6c8c(0x30f)]?.['length']&&!y(_0x1a0590[_0x2f6c8c(0x237)])){let _0xf01385='%'+String(_0x1a0590['keyWord'])+'%',_0xaa1a46=_0x47bc5e[_0x2f6c8c(0x30f)][_0x2f6c8c(0x186)](_0x463ef3=>{const _0x2b940b=_0x2f6c8c;let _0x188ace=_0x463ef3[_0x2b940b(0x261)]('.')?_0x463ef3[_0x2b940b(0x1ee)]('.')[_0x2b940b(0x2e5)]():_0x463ef3;return _0x26d1ce(h(_0x1e8f64,_0x188ace),_0xf01385);});if(_0xaa1a46[_0x2f6c8c(0x1e8)]===0x1)_0x47a192[_0x2f6c8c(0x281)](_0xaa1a46[0x0]);else{if(_0xaa1a46[_0x2f6c8c(0x1e8)]>0x1)_0x47a192[_0x2f6c8c(0x281)](_0x4be8ef(..._0xaa1a46));}}for(let _0x19f9a5 of _0x47bc5e[_0x2f6c8c(0x289)]??[]){let {column:_0x4454ae,param:_0x24b2b0}=BQ(_0x19f9a5),_0x38ce0b=_0x1a0590[_0x24b2b0];if(y(_0x38ce0b))continue;if(Array[_0x2f6c8c(0x1f3)](_0x38ce0b)){if(!_0x38ce0b[_0x2f6c8c(0x1e8)])continue;_0x47a192[_0x2f6c8c(0x281)](_0x1a46dd(h(_0x1e8f64,_0x4454ae),_0x38ce0b));}else _0x47a192[_0x2f6c8c(0x281)](_0x38a505(h(_0x1e8f64,_0x4454ae),_0x38ce0b));}for(let _0x104f85 of _0x47bc5e[_0x2f6c8c(0x298)]??[]){let {column:_0x3bc2ff,param:_0x3ddddd}=BQ(_0x104f85),_0x5beda8=_0x1a0590[_0x3ddddd];if(y(_0x5beda8))continue;_0x47a192[_0x2f6c8c(0x281)](_0x26d1ce(h(_0x1e8f64,_0x3bc2ff),'%'+String(_0x5beda8)+'%'));}for(let _0xd7948 of _0x47bc5e[_0x2f6c8c(0x170)]??[]){let {column:_0x412630,param:_0x4b2edb}=BQ(_0xd7948),_0x52e177=V0[_0x2f6c8c(0x271)](h(_0x1e8f64,_0x412630),_0x1a0590[_0x4b2edb]);if(_0x52e177)_0x47a192[_0x2f6c8c(0x281)](_0x52e177);}for(let _0x570748 of _0x47bc5e[_0x2f6c8c(0x2e0)]??[]){let _0x12be23=h(_0x1e8f64,U4(_0x570748)),_0x1014ac=V0[_0x2f6c8c(0x144)](_0x12be23,_0x1a0590[_0x570748[_0x2f6c8c(0x303)]],_0x1a0590[_0x570748['max']]);if(_0x1014ac)_0x47a192[_0x2f6c8c(0x281)](_0x1014ac);}return _0x47a192;}function T4(_0x4bde61,_0x459d28,_0x2edd0b){const _0x27da28=_0xde6411;let _0x5276cb=[],_0x5eff17=_0x459d28[_0x27da28(0x1ed)]!=null?String(_0x459d28[_0x27da28(0x1ed)]):void 0x0,_0x128709=_0x459d28['sort']===_0x27da28(0x1e5)||_0x459d28[_0x27da28(0x212)]===_0x27da28(0x140)?_0x459d28['sort']:void 0x0;if(_0x5eff17){let _0x47f581=h(_0x4bde61,_0x5eff17);_0x5276cb['push'](_0x128709===_0x27da28(0x1e5)?_0x574a9f(_0x47f581):_0x734e27(_0x47f581));}else{if(_0x2edd0b[_0x27da28(0x2c6)])for(let [_0x328857,_0x33f229]of Object[_0x27da28(0x28f)](_0x2edd0b[_0x27da28(0x2c6)])){let _0x32b6d0=_0x328857[_0x27da28(0x261)]('.')?_0x328857[_0x27da28(0x1ee)]('.')[_0x27da28(0x2e5)]():_0x328857,_0x538d1b=h(_0x4bde61,_0x32b6d0);_0x5276cb[_0x27da28(0x281)](_0x33f229===_0x27da28(0x1e5)?_0x574a9f(_0x538d1b):_0x734e27(_0x538d1b));}}return _0x5276cb;}function W0(_0x3a1112){const _0xe245bc=_0xde6411;return!!(_0x3a1112?.[_0xe245bc(0x2b8)]?.[_0xe245bc(0x1e8)]||_0x3a1112?.[_0xe245bc(0x226)]);}async function l(_0x3a85f8,_0x506ccc,_0x438372={},_0x54d10a){const _0x26db52=_0xde6411;let _0x1052e2=D4(_0x3a85f8,_0x506ccc,_0x438372),_0x3a4328=T4(_0x3a85f8,_0x506ccc,_0x438372),_0x3cb20c={'body':_0x506ccc,'request':_0x54d10a??new Request('http://local')};if(_0x438372[_0x26db52(0x19d)])_0x1052e2[_0x26db52(0x281)](...MQ(await _0x438372['where'](_0x3cb20c)));if(_0x438372[_0x26db52(0x239)]){let _0x3572ba={'andWhere'(_0x1f21ac){const _0x4a4949=_0x26db52;if(_0x1f21ac!=null&&_0x1f21ac!==!0x1)_0x1052e2[_0x4a4949(0x281)](_0x1f21ac);},'orderBy'(..._0xe65020){const _0x588bb9=_0x26db52;for(let _0x4179bc of _0xe65020)if(_0x4179bc!=null)_0x3a4328[_0x588bb9(0x281)](_0x4179bc);}};await _0x438372[_0x26db52(0x239)](_0x3572ba,_0x3cb20c);}return{'where':_0x1052e2['length']===0x0?void 0x0:_0x1052e2['length']===0x1?_0x1052e2[0x0]:_0x4dd14d(..._0x1052e2),'orderBySql':_0x3a4328};}import{and as _0x282693,count as _0x4a4579,countDistinct as _0x3838e3,getTableColumns as _0x339bd,isNotNull as _0x3e571b,isNull as _0x674b60,sql as _0x22c0c8}from'drizzle-orm';function w0(){return D['vome']?.['crud']??{};}function b0(_0x28e83a){const _0x1f2afb=_0xde6411;return _0x28e83a??w0()[_0x1f2afb(0x2cb)]??_0x1f2afb(0x1fb);}function u(_0x36edee){const _0x5bcf5b=_0xde6411;if(_0x36edee!=null)return _0x36edee;return w0()[_0x5bcf5b(0x260)]===!0x0;}class m{[_0xde6411(0x2d2)];[_0xde6411(0x2d7)];[_0xde6411(0x25f)];[_0xde6411(0x165)];constructor(_0x5e6879,_0x3857d7,_0xf8049,_0x49bd16){const _0x3c6959=_0xde6411;this['drizzle']=_0x5e6879,this['client']=_0x3857d7,this['schema']=_0xf8049,this[_0x3c6959(0x165)]=_0x49bd16;}}import{and as _0x461f5c,inArray as _0x398118,sql as _0x5c5a6f}from'drizzle-orm';import{and as _0x4c62ca,eq as _0x4088b5,sql as _0x2172a2}from'drizzle-orm';var z0=_0xde6411(0x13a);function y0(){const _0x38861d=_0xde6411;return D[_0x38861d(0x14e)]?.[_0x38861d(0x29e)]===!0x0;}function LQ(_0xae3428){const _0xf959a3=_0xde6411;return _0xae3428[_0xf959a3(0x1f0)]!=null;}function G0(){const _0x2ce728=_0xde6411;if(!y0())return'off';let _0x4bfcda=_['get']();if(_0x4bfcda?.[z0])return _0x2ce728(0x29f);if(_0x4bfcda?.[_0x2ce728(0x178)])return _0x2ce728(0x2ad);let _0x15347c=_0x4bfcda?.['tenantId'],_0x3bbf0b=typeof _0x15347c==='number'?_0x15347c:Number(_0x15347c);if(!Number[_0x2ce728(0x29d)](_0x3bbf0b)||_0x3bbf0b<=0x0)return _0x2ce728(0x309);return _0x3bbf0b;}function YQ(_0x2c387f,_0x1a1c50){const _0x2a3820=_0xde6411;if(!LQ(_0x2c387f))return _0x1a1c50;let _0x1a0e71=G0();if(_0x1a0e71==='off'||_0x1a0e71==='all')return _0x1a1c50;let _0xcbe797=_0x2c387f[_0x2a3820(0x1f0)],_0x2236bc=_0x1a0e71===_0x2a3820(0x309)?_0x2172a2`false`:_0x4088b5(_0xcbe797,_0x1a0e71);if(_0x1a1c50&&_0x2236bc)return _0x4c62ca(_0x1a1c50,_0x2236bc);return _0x1a1c50??_0x2236bc;}function UQ(_0x10cd29,_0x1d3493){const _0x2cdcae=_0xde6411;if(!LQ(_0x10cd29))return _0x1d3493;let _0x2f6f1c=G0();if(typeof _0x2f6f1c!==_0x2cdcae(0x176))return _0x1d3493;if(_0x1d3493['tenantId']!=null)return _0x1d3493;return{..._0x1d3493,'tenantId':_0x2f6f1c};}async function DQ(_0x562e63){const _0x564a78=_0xde6411;let _0x41f367=_[_0x564a78(0x1f4)]();if(!_0x41f367)return _0x562e63();let _0x4fde04=_0x41f367[z0];_0x41f367[z0]=!0x0;try{return await _0x562e63();}finally{if(_0x4fde04===void 0x0)delete _0x41f367[z0];else _0x41f367[z0]=_0x4fde04;}}function TQ(_0x49b06e){const _0x2b0b91=_0xde6411;if(!_0x49b06e)return'';return _0x49b06e[_0x2b0b91(0x153)]()[_0x2b0b91(0x14b)]()[_0x2b0b91(0x307)](/:\d+$/,'');}var F0=_0xde6411(0x2d8);function g0(_0x92f2a7){return _0x92f2a7['departmentId']!=null;}function h0(){const _0x205718=_0xde6411;let _0x24a5c5=_[_0x205718(0x1f4)]();if(!_0x24a5c5)return _0x205718(0x29f);if(_0x24a5c5[F0])return _0x205718(0x29f);if(_0x24a5c5[_0x205718(0x178)])return _0x205718(0x2ad);let _0x1fdcb0=_0x24a5c5[_0x205718(0x18f)];if(_0x1fdcb0==null||_0x1fdcb0==='')return'off';if(_0x1fdcb0===_0x205718(0x2ad))return _0x205718(0x2ad);if(_0x1fdcb0===_0x205718(0x309))return _0x205718(0x309);let _0x382f7a=_0x24a5c5['dataScopeDeptIds'],_0x373e67=Array[_0x205718(0x1f3)](_0x382f7a)?_0x382f7a[_0x205718(0x186)](_0x55f73f=>Number(_0x55f73f))[_0x205718(0x24f)](_0x467cf6=>Number[_0x205718(0x29d)](_0x467cf6)&&_0x467cf6>0x0):[];if(!_0x373e67[_0x205718(0x1e8)])return'none';return[...new Set(_0x373e67)];}function u0(_0x9e5ae3,_0x27368a){const _0x644bd0=_0xde6411;if(!g0(_0x9e5ae3))return _0x27368a;let _0x345c5d=h0();if(_0x345c5d===_0x644bd0(0x29f)||_0x345c5d===_0x644bd0(0x2ad))return _0x27368a;let _0x498221=_0x9e5ae3[_0x644bd0(0x206)],_0x1e9360=_0x345c5d===_0x644bd0(0x309)?_0x5c5a6f`false`:_0x398118(_0x498221,_0x345c5d);if(_0x27368a)return _0x461f5c(_0x27368a,_0x1e9360);return _0x1e9360;}function q(_0x3e9ef8,_0x13bf4a){return u0(_0x3e9ef8,YQ(_0x3e9ef8,_0x13bf4a));}async function NQ(_0x3e2826){const _0x232060=_0xde6411;let _0x486f61=_[_0x232060(0x1f4)]();if(!_0x486f61)return _0x3e2826();let _0x445330=_0x486f61[F0];_0x486f61[F0]=!0x0;try{return await _0x3e2826();}finally{if(_0x445330===void 0x0)delete _0x486f61[F0];else _0x486f61[F0]=_0x445330;}}function x4(_0x43a6b0){const _0x3c4243=_0xde6411;return _0x43a6b0[_0x3c4243(0x293)];}function v4(_0x543914,_0x4f8b6b){const _0x2a8be3=_0xde6411;if(!u(_0x4f8b6b?.[_0x2a8be3(0x260)]))return;let _0x413462=x4(_0x543914);if(_0x413462==null)return;if(_0x4f8b6b?.['onlyTrashed'])return _0x3e571b(_0x413462);if(_0x4f8b6b?.[_0x2a8be3(0x1bd)])return;return _0x674b60(_0x413462);}function k4(_0x1f5569,_0x572cc2){if(_0x1f5569&&_0x572cc2)return _0x282693(_0x572cc2,_0x1f5569);return _0x1f5569??_0x572cc2;}function i1(_0x32ff0a,_0x59acd0,_0xaebd3){const _0x241035=_0xde6411;let _0x5818cc=_0x32ff0a;for(let _0xfeb157 of _0xaebd3[_0x241035(0x2b8)]??[]){let _0x52e43e=_0xfeb157['table'],_0xc8e0e4=_0xfeb157['on'](_0x59acd0),_0x19b2df=_0xfeb157[_0x241035(0x17a)]??_0x241035(0x2ca);if(_0x19b2df===_0x241035(0x275)||_0x19b2df===_0x241035(0x2b8))_0x5818cc=_0x5818cc[_0x241035(0x275)](_0x52e43e,_0xc8e0e4);else _0x5818cc=_0x5818cc[_0x241035(0x2ca)](_0x52e43e,_0xc8e0e4);}return _0x5818cc;}function f4(_0x542d4f,_0x27bbca){const _0x4a1129=_0xde6411;if(_0x27bbca['select'])return _0x27bbca[_0x4a1129(0x226)];return _0x339bd(_0x542d4f);}function w4(_0x4c46cb,_0x583d26){let _0x249b94=_0x4c46cb['id'];if(_0x249b94!=null&&_0x583d26)return _0x3838e3(_0x249b94);if(_0x249b94!=null)return _0x4a4579(_0x249b94);return _0x4a4579(_0x22c0c8`*`);}async function j0(_0x1e3afe,_0x2bcfc6,_0x41adbe,_0x4379c1){const _0x2fc515=_0xde6411;let _0x41979f=await l(_0x1e3afe,_0x2bcfc6,_0x41adbe,_0x4379c1[_0x2fc515(0x284)]),_0x541178=v4(_0x1e3afe,_0x4379c1[_0x2fc515(0x2e9)]),_0x18676a=q(_0x1e3afe,k4(_0x41979f[_0x2fc515(0x19d)],_0x541178)),_0x5893d5=f4(_0x1e3afe,_0x41adbe),_0x370fb8=!!_0x41adbe[_0x2fc515(0x2b8)]?.['length'],_0xab6ead=K[_0x2fc515(0x1f4)](m)['drizzle'],_0x56f6b4=i1(_0xab6ead[_0x2fc515(0x226)](_0x5893d5)[_0x2fc515(0x2d1)](_0x1e3afe),_0x1e3afe,_0x41adbe);if(_0x18676a)_0x56f6b4=_0x56f6b4['where'](_0x18676a);if(_0x41979f[_0x2fc515(0x14a)][_0x2fc515(0x1e8)])_0x56f6b4=_0x56f6b4[_0x2fc515(0x1ba)](..._0x41979f['orderBySql']);if(_0x4379c1[_0x2fc515(0x1ea)]===_0x2fc515(0x25a))return await _0x56f6b4;let _0x477792=Math['max'](0x1,Number(_0x2bcfc6[_0x2fc515(0x23f)]??0x1)),_0xc282c1=Math[_0x2fc515(0x303)](0x64,Math[_0x2fc515(0x23d)](0x1,Number(_0x2bcfc6[_0x2fc515(0x292)]??0x14))),_0x5b8efa=(_0x477792-0x1)*_0xc282c1,_0xb5fdfb=await _0x56f6b4[_0x2fc515(0x270)](_0xc282c1)['offset'](_0x5b8efa),_0x4259e1=i1(_0xab6ead[_0x2fc515(0x226)]({'value':w4(_0x1e3afe,_0x370fb8)})['from'](_0x1e3afe),_0x1e3afe,_0x41adbe);if(_0x18676a)_0x4259e1=_0x4259e1[_0x2fc515(0x19d)](_0x18676a);let _0x5a6b68=await _0x4259e1,_0x44e8b5=Number(_0x5a6b68[0x0]?.['value']??0x0);return{'list':_0xb5fdfb,'pagination':{'page':_0x477792,'size':_0xc282c1,'total':_0x44e8b5}};}import{and as _0x1fc32b,count as _0x5217ed,eq as _0x60b458,inArray as _0x4da05e,isNotNull as _0x16dd50,isNull as _0x1b1afc}from'drizzle-orm';import{createInsertSchema as _0x1075d9,createSelectSchema as _0x39f66b,createUpdateSchema as _0x194bc9}from'drizzle-zod';function H0(_0x4ca680){return{'select':_0x39f66b(_0x4ca680),'insert':_0x1075d9(_0x4ca680),'update':_0x194bc9(_0x4ca680)};}var p4=['createTime','updateTime','deletedAt'];function KQ(_0x1e60ec){const _0x1b07a9=_0xde6411;let _0x2fe3df=_0x1e60ec&&typeof _0x1e60ec===_0x1b07a9(0x221)&&!Array[_0x1b07a9(0x1f3)](_0x1e60ec)?{..._0x1e60ec}:{};for(let _0x4efd01 of p4)delete _0x2fe3df[_0x4efd01];for(let [_0x32a7ae,_0x193457]of Object[_0x1b07a9(0x28f)](_0x2fe3df)){if(typeof _0x193457!==_0x1b07a9(0x299))continue;if(!/^\d{4}-\d{2}-\d{2}/[_0x1b07a9(0x1df)](_0x193457))continue;let _0x4156aa=new Date(_0x193457);if(!Number['isNaN'](_0x4156aa[_0x1b07a9(0x232)]()))_0x2fe3df[_0x32a7ae]=_0x4156aa;}return _0x2fe3df;}function d4(_0x4c47b8){const _0x5de679=_0xde6411;return!!_0x4c47b8&&typeof _0x4c47b8===_0x5de679(0x221)&&_0x4c47b8['getSQL']!=null;}function x(){const _0x3f4fd7=_0xde6411;return K[_0x3f4fd7(0x1f4)](m)[_0x3f4fd7(0x2d2)];}function B0(_0x49c308){const _0x12f163=_0xde6411;let _0xe5cba9=_0x49c308['id'];if(!_0xe5cba9)throw Error(_0x12f163(0x250));return _0xe5cba9;}function r1(_0x2350a5){const _0x3bbf53=_0xde6411;return _0x2350a5[_0x3bbf53(0x293)];}function n4(_0x30bf8b,_0x584ef2){if(_0x30bf8b&&_0x584ef2)return _0x1fc32b(_0x584ef2,_0x30bf8b);return _0x30bf8b??_0x584ef2;}function l4(_0x58b354,_0x84aa0f){const _0x2183fd=_0xde6411;if(!u(_0x84aa0f?.[_0x2183fd(0x260)]))return;let _0x8304e0=r1(_0x58b354);if(_0x8304e0==null)return;if(_0x84aa0f?.[_0x2183fd(0x196)])return _0x16dd50(_0x8304e0);if(_0x84aa0f?.['withTrashed'])return;return _0x1b1afc(_0x8304e0);}class M0{['table'];[_0xde6411(0x25f)];constructor(_0x4c8169,_0x1a974c){const _0xa66c5f=_0xde6411;this[_0xa66c5f(0x195)]=_0x4c8169,this[_0xa66c5f(0x25f)]=_0x1a974c??H0(_0x4c8169);}['supportsSoftDelete'](){const _0x37b012=_0xde6411;return r1(this[_0x37b012(0x195)])!=null;}[_0xde6411(0x207)](_0x25bf89,_0x12ec9d){const _0x3a2df5=_0xde6411;return q(this[_0x3a2df5(0x195)],n4(_0x25bf89,l4(this[_0x3a2df5(0x195)],_0x12ec9d)));}async['find'](_0x3bf46e,_0x567e94){const _0x1cea06=_0xde6411;let _0x55392e=this[_0x1cea06(0x207)](_0x3bf46e,_0x567e94),_0x1bb474=x()[_0x1cea06(0x226)]()[_0x1cea06(0x2d1)](this[_0x1cea06(0x195)]);if(_0x55392e)_0x1bb474=_0x1bb474[_0x1cea06(0x19d)](_0x55392e);if(_0x567e94?.[_0x1cea06(0x1ba)]?.[_0x1cea06(0x1e8)])_0x1bb474=_0x1bb474[_0x1cea06(0x1ba)](..._0x567e94[_0x1cea06(0x1ba)]);return await _0x1bb474;}async['findOne'](_0x4df713,_0x101d9d){const _0x2ed77b=_0xde6411;let [_0x3992c1]=await this[_0x2ed77b(0x174)](_0x4df713,_0x101d9d);return _0x3992c1;}async[_0xde6411(0x30e)](_0x322be0,_0x3bda92){const _0x41430d=_0xde6411;return this['findOne'](_0x60b458(B0(this[_0x41430d(0x195)]),_0x322be0),_0x3bda92);}async[_0xde6411(0x141)](_0x2ba2ab,_0x324f1a){const _0x4af030=_0xde6411;let _0x32fe80=this[_0x4af030(0x207)](_0x2ba2ab,_0x324f1a),_0x37a8a5=x()[_0x4af030(0x226)]({'value':_0x5217ed()})['from'](this[_0x4af030(0x195)]),_0x57116f=_0x32fe80?await _0x37a8a5[_0x4af030(0x19d)](_0x32fe80):await _0x37a8a5;return Number(_0x57116f[0x0]?.[_0x4af030(0x300)]??0x0);}async[_0xde6411(0x257)](_0x229a87){const _0x4bf389=_0xde6411;let {page:_0x170d7c,size:_0x3d38ae,where:_0x5b67cd,orderBy:_0x3e85d6,withTrashed:_0x37470e,onlyTrashed:_0x1b1048,softDelete:_0x1ceac3}=_0x229a87,_0x3d2037={'withTrashed':_0x37470e,'onlyTrashed':_0x1b1048,'softDelete':_0x1ceac3},_0x20fe02=this[_0x4bf389(0x207)](_0x5b67cd,_0x3d2037),_0x35a4b0=(_0x170d7c-0x1)*_0x3d38ae,_0x1fc5a9=x()[_0x4bf389(0x226)]()[_0x4bf389(0x2d1)](this[_0x4bf389(0x195)]);if(_0x20fe02)_0x1fc5a9=_0x1fc5a9['where'](_0x20fe02);if(_0x3e85d6?.[_0x4bf389(0x1e8)])_0x1fc5a9=_0x1fc5a9[_0x4bf389(0x1ba)](..._0x3e85d6);let _0x3c17c8=await _0x1fc5a9['limit'](_0x3d38ae)[_0x4bf389(0x22a)](_0x35a4b0),_0x14efd0=await this[_0x4bf389(0x141)](_0x5b67cd,_0x3d2037);return{'list':_0x3c17c8,'pagination':{'page':_0x170d7c,'size':_0x3d38ae,'total':_0x14efd0}};}[_0xde6411(0x24c)](_0x4a47cc){const _0x56b592=_0xde6411;let _0x2b0166=UQ(this[_0x56b592(0x195)],KQ(_0x4a47cc));return this[_0x56b592(0x25f)]['insert'][_0x56b592(0x189)](_0x2b0166);}async[_0xde6411(0x277)](_0x2670b9){const _0x3f6d43=_0xde6411;if(Array[_0x3f6d43(0x1f3)](_0x2670b9)){if(!_0x2670b9['length'])return[];let _0x18b8a6=_0x2670b9[_0x3f6d43(0x186)](_0x5b5d81=>this[_0x3f6d43(0x24c)](_0x5b5d81));return await x()[_0x3f6d43(0x1fb)](this[_0x3f6d43(0x195)])[_0x3f6d43(0x1cd)](_0x18b8a6)[_0x3f6d43(0x258)]();}let [_0x3f8cba]=await x()['insert'](this[_0x3f6d43(0x195)])[_0x3f6d43(0x1cd)](this[_0x3f6d43(0x24c)](_0x2670b9))[_0x3f6d43(0x258)]();return _0x3f8cba;}async[_0xde6411(0x2c0)](_0x26dde3){const _0x537fb6=_0xde6411;if(Array[_0x537fb6(0x1f3)](_0x26dde3)){if(!_0x26dde3['length'])return[];let _0x2c6f87=_0x26dde3,_0x22fc8d=B0(this['table']),_0x2ec883=_0x2c6f87[_0x537fb6(0x24f)](_0x34b11a=>_0x34b11a?.['id']!=null&&_0x34b11a['id']!==''),_0xc6de40=_0x2c6f87[_0x537fb6(0x24f)](_0xb41725=>_0xb41725?.['id']==null||_0xb41725['id']===''),_0x142d45=new Set();if(_0x2ec883['length']){let _0x2ac0e8=await this['find'](_0x4da05e(_0x22fc8d,_0x2ec883[_0x537fb6(0x186)](_0x5bab1d=>_0x5bab1d['id'])));_0x142d45=new Set(_0x2ac0e8[_0x537fb6(0x186)](_0x49534a=>_0x49534a['id']));}let _0x30bc70=[],_0x4681c4=[..._0xc6de40];for(let _0x3edd20 of _0x2ec883)if(_0x142d45['has'](_0x3edd20['id']))_0x30bc70[_0x537fb6(0x281)](_0x3edd20);else _0x4681c4[_0x537fb6(0x281)](_0x3edd20);let _0x2affc8=_0x30bc70[_0x537fb6(0x1e8)]?await this['update'](_0x30bc70):[],_0x270bff=_0x4681c4[_0x537fb6(0x1e8)]?await this['create'](_0x4681c4):[];return[...Array['isArray'](_0x2affc8)?_0x2affc8:_0x2affc8?[_0x2affc8]:[],...Array[_0x537fb6(0x1f3)](_0x270bff)?_0x270bff:_0x270bff?[_0x270bff]:[]];}let _0x168b5d=_0x26dde3,_0x5462ee=_0x168b5d?.['id'];if(_0x5462ee!=null&&_0x5462ee!==''){let _0x58abb=await this[_0x537fb6(0x30e)](_0x5462ee);if(_0x58abb){let {id:_0x37f227,..._0x43f03d}=_0x168b5d;return await this[_0x537fb6(0x21c)](_0x60b458(B0(this[_0x537fb6(0x195)]),_0x5462ee),_0x43f03d)??_0x58abb;}}return await this[_0x537fb6(0x277)](_0x26dde3);}async[_0xde6411(0x21c)](_0x225a8d,_0x3967cb){const _0x511f1c=_0xde6411;if(Array[_0x511f1c(0x1f3)](_0x225a8d))return this[_0x511f1c(0x17e)](_0x225a8d);let _0x2e1573=this[_0x511f1c(0x25f)][_0x511f1c(0x21c)][_0x511f1c(0x189)](KQ(_0x3967cb)),_0xc0bb05=q(this[_0x511f1c(0x195)],_0x225a8d);if(!_0xc0bb05)return;let [_0x38a3bb]=await x()[_0x511f1c(0x21c)](this['table'])[_0x511f1c(0x155)](_0x2e1573)['where'](_0xc0bb05)['returning']();return _0x38a3bb;}async[_0xde6411(0x17e)](_0x1e4aed){const _0x95119c=_0xde6411;if(!_0x1e4aed['length'])return[];let _0xb2bd15=B0(this[_0x95119c(0x195)]),_0x347338=new Map();for(let _0x18c5c3 of _0x1e4aed){let _0x5d0c09=_0x18c5c3['id'];if(_0x5d0c09==null||_0x5d0c09==='')throw Error('[Repository]\x20\u6279\u91CF\u66F4\u65B0\u6BCF\u6761\u9700\u5E26\x20id');let {id:_0x39689f,..._0x4f4f8b}=_0x18c5c3,_0x410782=this[_0x95119c(0x25f)][_0x95119c(0x21c)][_0x95119c(0x189)](KQ(_0x4f4f8b)),_0x547732=JSON[_0x95119c(0x304)](_0x410782),_0x47581b=_0x347338[_0x95119c(0x1f4)](_0x547732);if(_0x47581b)_0x47581b[_0x95119c(0x249)]['push'](_0x5d0c09);else _0x347338['set'](_0x547732,{'ids':[_0x5d0c09],'patch':_0x410782});}let _0x54356e=[];for(let {ids:_0x222885,patch:_0x3d1198}of _0x347338[_0x95119c(0x1cd)]()){let _0x8c4e72=q(this[_0x95119c(0x195)],_0x4da05e(_0xb2bd15,_0x222885));if(!_0x8c4e72)continue;let _0x18f06f=await x()[_0x95119c(0x21c)](this[_0x95119c(0x195)])[_0x95119c(0x155)](_0x3d1198)['where'](_0x8c4e72)[_0x95119c(0x258)]();_0x54356e[_0x95119c(0x281)](..._0x18f06f);}return _0x54356e;}[_0xde6411(0x19e)](_0x18240d){const _0x42a5fa=_0xde6411;if(d4(_0x18240d))return q(this[_0x42a5fa(0x195)],_0x18240d);let _0x2806c3=Array[_0x42a5fa(0x1f3)](_0x18240d)?_0x18240d:[_0x18240d];if(!_0x2806c3[_0x42a5fa(0x1e8)])return;return q(this[_0x42a5fa(0x195)],_0x4da05e(B0(this[_0x42a5fa(0x195)]),_0x2806c3));}async[_0xde6411(0x260)](_0xf16ac3){const _0x10d9f5=_0xde6411;if(!this['supportsSoftDelete']())throw Error(_0x10d9f5(0x24e));let _0x6d96bc=this[_0x10d9f5(0x19e)](_0xf16ac3);if(!_0x6d96bc)return;await x()[_0x10d9f5(0x21c)](this['table'])[_0x10d9f5(0x155)]({'deletedAt':new Date()})[_0x10d9f5(0x19d)](_0x6d96bc);}async['restore'](_0x2519da){const _0x5b2315=_0xde6411;if(!this[_0x5b2315(0x2b4)]())throw Error(_0x5b2315(0x29b));let _0x505d29=this[_0x5b2315(0x19e)](_0x2519da);if(!_0x505d29)return;await x()['update'](this[_0x5b2315(0x195)])[_0x5b2315(0x155)]({'deletedAt':null})[_0x5b2315(0x19d)](_0x505d29);}async[_0xde6411(0x146)](_0x1b4919){const _0x51accd=_0xde6411;let _0x192efc=this['resolveIdWhere'](_0x1b4919);if(!_0x192efc)return;await x()[_0x51accd(0x28d)](this[_0x51accd(0x195)])[_0x51accd(0x19d)](_0x192efc);}}function _0x1903(){const _0x57aa02=['CgfYC2u','Bw9KDwXLlwDHDgv3yxK','y29UDhjVBgXLCG','y29TBwvUDa','l2fWCa','l2LUzM8','zgf0yvnJB3bL','zgvZAwDUoNr5Cgu','DgfIBgvFBMfTzq','Dw5RBM93BG','pJ0WlJiUma','BMfTzq','DgfIBgu','B25SEvrYyxnOzwq','y29Kzq','DMfYifbSDwDPBIa9','zM9YBwf0','DM9TztPJB250CM9SBgvYoNjVDxrLlwLNBM9Yzs1WzxjTCW','qxnPys9tAgfUz2HHAq','zgLNzxn0','D2HLCMu','CMvZB2X2zuLKv2HLCMu','rgf0zvrPBwvgB3jTyxq','Ag9ZDa','zw50zxjxAxrO','Aw5KzxGUAhrTBa','mZeXmZq2n3Hmv0XmwG','BwLKzgXLD2fYzq','tM90iezVDw5K','yM9VDhn0CMfW','Ec1MB3j3yxjKzwqTzM9Y','5yIG6zMK5PE26zE0','zxHPDa','y2XHC3mGjde','ioEAHoEXU+wEI++8JoIVT+AyVUw8J+s8OowfPsb0B2TLBG','C3jJl2fKBwLU','vgfZAW','DM9TztPJB250CM9SBgvYoNjVDxrLlxb1yMXPyW','C3rVCa','odzyrgvWqwe','CMvXDwvZDfbHCMfT','yMLUza','zw5HyMXL','w0HVC3rDihnRAxaG4OAqig1PC3nPBMCG','C2nHBgfY','AgvHzgvYCW','zgvSzxrLtwv0ywrHDge','DM9TztPJB250CM9SBgvYoNjVDxrLCY1Wzw5KAw5N','w0nVBNrLEhrDiow9K+wjJEAxOoIVT+AXGUs4IUs4I+AwH++8JowgMEwfPEIIQ+w/VEEvPE+8IoIVT+EHRUIUPcbHC3LUy0nVBNrLEhrnyw5Hz2vYiow3SUwqR+EuQo+8Iq','B3jKzxjcEq','C2LKzq','y3j1za','D2L0AfrYyxnOzwq','BgLZDcbMywLSzwq','ywnJzxnZlwnVBNrYB2WTywXSB3CTB3jPz2LU','ChjVza','iowJSoAyJUs6HIbYB3v0zxmG5l2g57Y65BcrihnLCNzLCI9PBMrLEc5QCW','y2fJAguTy29UDhjVBa','BwfJCM8','mJyXmdaZnKDzEfPMuW','z2v0rNvSBfLLyxi','xJuUnc43','AgfZ','BwvZC2fNzq','DM9TztPJB250CM9SBgvYoNjVDxrLlw1PzgrSzxDHCMu','C3yTu0u','D2vIqxv0Aa','Aw5KzxG','DMfSDwvZ','zgv2lNrZ','DM9TztPJB250CM9SBgvYoNjVDxrLlxbHCMfTCW','5yIB5BU65PE26zE0','C3vJy2vZCW','zw52','zgLZCgf0y2G','CM0GlxjMigrPC3qGjIyGyNvUigj1AwXKic4VC3jJl2LUzgv4lNrZic4VC3jJl3nLCNzLCI9PBMrLEc50CYaTlw91DgrPCIaUl2rPC3qGls10yxjNzxqGyNvUic0TzM9YBwf0igvZBsaTlw1PBMLMEsaTlwv4DgvYBMfSigvSExnPysaTlwv4DgvYBMfSihjLzMXLy3qTBwv0ywrHDgeGls1LEhrLCM5HBcbKCML6EMXLlw9YBsaTlwv4DgvYBMfSigrYAxP6BguTEM9Kic0TzxH0zxjUywWGqgvSExnPywPZl29Wzw5HCgKGls1LEhrLCM5HBcbayM9NzxLJAgfUl2vSExnPys1SB2DNzxiGls1LEhrLCM5HBcbWAw5Vic0TzxH0zxjUywWGCgLUBY1WCMv0DhKGjIyGDhnJic1WihrZy29UzMLNlMj1AwXKlMPZB24GjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VC3jJl2LUzgv4jYiGpIbKAxn0l2LUzgv4lMqUDhmGjIyGBwTKAxiGlxaGzgLZDc9Zzxj2zxiGjIyGChjPBNrMiciLC1XUiIaIzxHWB3j0icOGzNjVBsaNlI4VlI4VC3jJl3nLCNzLCI9PBMrLEcCIid4GzgLZDc9Zzxj2zxiVAw5KzxGUzc50CYaMjIbIDw4GC2nYAxb0CY9VyMz1C2nHDguUDhm','z2v0rgf0zq','zw5K','BM90tNvSBa','D2vI','ChvIBgLJ','y2XHC3nPyW','cNzHCIbFx1bSDwDPBIa9icH0ExbLB2yGugX1z2LUice9psaNDw5KzwzPBMvKjYKkica/ifbSDwDPBGOGidOGkg1VzhvSzs5LEhbVCNrZicyMicHTB2r1BguUzxHWB3j0CY5qBhvNAw4GFhWGBw9KDwXLlMv4Cg9YDhmUzgvMyxvSDcb8FcbTB2r1BguUzxHWB3j0CYKPoWPPzIaODhLWzw9Mif9FugX1z2LUid09psaNDw5KzwzPBMvKjYb8FcbFx1bSDwDPBIa9pt0GBNvSBcKGEWOGihrOCM93ig5LDYbfCNjVCIGNBwLZC2LUzYbLEhbVCNqGugX1z2LUjYK7cN0kCMv0DxjUif9FugX1z2LUoW','zgvMyxvSDc50CW','C291CMnL','zMLSzq','DgvZDa','AhjLzG','kqOGia','l2XPC3q','6z2E5Rov5QIH5z2xigTLEq','Ec1MB3j3yxjKzwqTAg9ZDa','yxnJ','Cg9ZDa','z2v0twv0ywrHDge','BgvUz3rO','DMfYigHHBMrSzxjZid0','Bw9Kzq','BgLZDgvU','xJaUms4Xma','B3jKzxi','C3bSAxq','C2v0rw50Axr5','DgvUyw50swq','pJ0WlJuUma','AxnuvfK','AxnbCNjHEq','z2v0','ioMCGoMfJEE9RIbLBNrPDhKG5OIwihnLCNzPy2u','w0LVy10Gsw9JlNnLDcG','yxbWBgLJyxrPB24VANnVBG','zgvMyxvSDa','ieLticC','Bwf0y2G','Aw5Zzxj0','5PU05PAW5PE26zE0','CMvXDwLYzq','AxngAwXL','C3jJl2XPyI9WBhvNAw4VAw5KzxGUDhm','zg9JDw1LBNrHDgLVBG','ihjVDxrLkhmP','q2fJAgu','CgfYyw1Z','Bw9KDwXL','u1LtoNn0yw5KyxjK','zgvWyxj0BwvUDeLK','C2nVCgvKv2HLCMu','ywn0Aw9U','yxbW','w01VzhvSzv0GBg9HzcbMywLSzwqG','C3jJl2XPyI9TB2r1BguVAw5KzxGUDhm','BwLJCM9bChbZ','l2rLBgv0zq','BNvTzxjPyW','Aw50zxjUywWGC2vYDMvYigvYCM9Y','DM9TztPPBMPLy3q','Bg9N','C29YDa','l3vWzgf0zq','igzHAwXLza','w0LVy10GqeLUAMvJDcdML6dMS5xMJQJMLQ0G','ywrK','mJjwB2zeyLu','ufvu','zw5KC1DPDgG','Aw1Hz2uVCg5N','ywrTAw4','DxbKyxrL','AwrZihjLCxvPCMvK','y2XVC2u','lI9KAxn0l2LUzgv4lMqUDhm','pJ0YlJaUma','B2jQzwn0','AwqGCMvXDwLYzwq','w0LVy10G5PYQ55+L5l2C55sO5z+FoIa','tw9KDwXL','ugfYyw0','C2vSzwn0','Bgf5B3v0','y3r4','w0LVy10GuMvXDwvZDcdKVzZNLkJLN5/POBVLNkJOR7FMSylKUiRKUiVMLOFKUk3OP6pMNPdVViJOR7FNOA7ORQqGyxn5BMndB250zxH0twfUywDLCI5LBMfIBgxVViK','B2zMC2v0','zM9UDc93B2zMmG','Bwq1','w0jHC2vtzxj2AwnLxsdMNkRNU5hLRPRLRP7KVzpVViZOR7FKVB/NLkGGqeLUAMvJDfjLCg9ZAxrVCNKG5OIwihnLDevUDgL0Eq','B25czwzVCMviyw5KBgu','C3rKB3v0','lMPWzW','C3LZDgvT','z2v0vgLTzq','A2v5CW','CM91DgvpChrPB25Z','BM90igzVDw5K','qM9KEq','A2v5v29Yza','lI90ExbPBMDZl2fKBwLUlYO','zxH0zw5K','lI9ZCMmVywrTAw4VkG','AgfUzgXLCG','z2v0u1fm','Bwf4','y29UDgvUDa','CgfNzq','w0LVy10G5Qoa5Rwl5yIW5B6Q546V5l6D6lwwoIa','tuLu','Ahr0CdOVl2XVy2fSAg9ZDdO','kgfUB255Bw91CYK','mtqYodeZnNjLvvvIrG','lMPWzwC','AgfUzgXLCNm','Cgf0y2G','Bw9KAwz5qwz0zxi','AwrZ','BM8Ty2fJAgu','lI9ZCMmVywrTAw4VAw5KzxGUDhm','CgfYC2vjBNnLCNq','yMvMB3jL','w1jLCg9ZAxrVCNLDioIHQoAxOcbKzwXLDgvKqxtVViZML6dMS5xOVA/LIkdPMAq','zMLSDgvY','w1jLCg9ZAxrVCNLDioIHQoAxOcbPzcdLIjFVViZOR7FMLlNNLkGGzMLUzcH3AgvYzsKGlYbMAw5Kt25LkhDOzxjLkq','CMvZDg9Yzq','pJ0ZlJuUma','w0LVy10G5PYQ5RoO5yAm55QeifbYB3zPzgvYoIa','tK9erv9ftLy','5QIH5z2x5PYQ5yQG6l29','pJ0WlJmWlJa','zMLUzfbHz2u','CMv0DxjUAw5N','cIaGicbtruXfq1qkicaGicaGyY5YzwXUyw1LieftihrHyMXLx25HBwuScIaGicaGigeUyxr0BMfTzsbbuYbJB2X1Bw5FBMfTzsWkicaGicaGy29Sx2rLC2nYAxb0Aw9UkgeUyxr0CMvSAwqSigeUyxr0BNvTksbbuYbJB21Tzw50cIaGicbguK9nihbNx2nHDgfSB2CUCgDFy2XHC3mGyWOGicaGsK9jtIbWz19JyxrHBg9NlNbNx25HBwvZCgfJzsbUie9oig4UB2LKid0GyY5YzwXUyw1LC3bHy2ukicaGiePpsu4GCgDFy2f0ywXVzY5Wz19HDhrYAwj1DguGysbptIbHlMf0DhjLBgLKid0GyY5VAwqkicaGifDirvjfigmUCMvSA2LUzca9icDYjWOGicaGicbbtKqGBI5UC3bUyw1Lid0Gy3vYCMvUDf9Zy2HLBweOkqOGicaGicbbtKqGys5HDhrUDw0GpIaWcIaGicaGieforcbot1qGys5HDhrPC2rYB3bWzwqkicaGicaGqu5eigmUCMvSBMfTzsbjtIaO','BgLZDa','mI1KAwDPDa','zgvMAw5Ltwv0ywrHDge','zgvMyxvSDe5VDW','l3jLC3rVCMu','C2nOzw1H','C29MDerLBgv0zq','Aw5JBhvKzxm','Agv4','Bg9JywXLq29TCgfYzq','ndC1m21cuuz6Aa','DxnL','C3rHDhvZq29Kzq','lI9KAxn0l2LUzgv4lMPZ','zw50Axr5','Bw9KDwXLlMPZB24','CxvLCNK','l2fKBwLUl2v4Dc86A2v5lYO','BM93','DxjS','yxv0B0nYDwq','Aw1Hz2uVC3zNk3HTBa','BgLTAxq','y29UDgfPBNm','Dgv4Dc9ODg1SoYbJAgfYC2v0pxv0zI04','nZq5mJG1CLfUEvPw','DxbKyxrLvgLTzq','Aw5UzxjkB2LU','ioE8UUwWKsb0B2TLBIdMIjyGCMvZB2X2zq','y3jLyxrL','CM91DgvZ','C3jJl2XPyI9HDxrOl2LUzgv4lNrZ','odCYndC4EKzVq0Hl','ywrTAw5jza','mtjNANzXtwG','BwLZC2LUzYbLEhbVCNqGAgfUzgXLCNm','zM9Yy2u','uxvLCNK','pJ00lJaUma','ChvZAa','CgfKu3rHCNq','yxbP','CMvXDwvZDa','ioIHQoAxOcbPzcdLIjC','AxneAxjLy3rVCNK','r0vu','Dg9vChbLCKnHC2u','zMLLBgrfCq','CMfUzg9Tvvvjra','cMLMicH0ExbLB2yGAgfUzgXLCNmGpt09icD1BMrLzMLUzwqNksbYzxr1CM4GBNvSBdSkCMv0DxjUigHHBMrSzxjZoW','zgLZDa','zgvSzxrL','CgX1z2LU','zw50CMLLCW','Aw5MB0LNBM9YzvbYB3bLCNr5','BgLZDff1zxj5t3a','C2L6zq','zgvSzxrLzef0','rvjst1i','Aw5MBW','vKfmsurbveLptG','zMfPBa','zMLLBgrmAwTL','C3rYAw5N','CM91DgvqyxjHBxm','w1jLCg9ZAxrVCNLDioIHQoAxOcbKzwXLDgvKqxtVViZML6dMS5xMGAlLPi0','l2fKBwLU','AxngAw5PDgu','DgvUyw50','B2zM','ChjVzc50CW','Bw9KDwXLCW','zxjYB3i','6lEV55sX5lIn5A2y5zYO','lMPZ','Ec1YzwfSlwLW','ignVBNrYB2XSzxiGzMLSzsHZkq','DgfNCW','lMPZB24','zgLY','Bwf4rgf5CW','C3LTyM9S','zgvIDwC','ywXS','g1SYsHTBsa','qxbWig5VDcbMB3vUza','vM9TzsbMCMfTzxDVCMSG4OcuihnOyxjLzcaRiej1BI9fBhLZAweGC2vYDMvYicSGvNvLigfKBwLU','D2fYBG','CgfNzsbMywLSzwq','DM9Tzs1JB3jL','C3vWCg9YDhntB2z0rgvSzxrL','lM1QCW','C2nHBG','yM9KEq','AM9PBG','C2vYDMvY','w0nsvurDia','khSGqMfZzvbSDwDPBIb9kq','qNvU','lM1HCa','tK9ux0zpvu5e','z2v0u3rVCMu','C2f2zq','zxbZ','yxbWBgLJyxrPB24VAMf2yxnJCMLWDdSGy2HHCNnLDd11DgyToa','C3rHDhvZ','z2v0uMvWBW','Dw5ZywzL','ywrKt3jKzxjcEq','C2nVCgu','C3jJl3nOyxjLza','rM9YyMLKzgvU','BgvMDePVAw4','DxbZzxj0','CMvXDwvZDeXVzW','CgX1z2LUu2vYDMLJzq','Dg9tDhjPBMC','DMfSAwrHDgLVBIbMywLSzwq','zgv2','zNjVBq','zhjPENPSzq','Aw5Zzxj0ugfYyw0','u0Lhsu5u','Dg9Rzw4','oeD2vwDYrq','y2XPzw50','x19ZA2LWrgf0yvnJB3bL','AgfZrw50Axr5','y3jLyxrLvgLTzq','CMvHzhK','CgvYBxm','yxnZAwDU','5QIH5z2xia','l2rVy3m','zMLLBgrsyw5Nzq','w1jVDxrLCL0G','Bwv0Ag9K','lNzVBwu','CgLKlgHVC3rUyw1L','Cg9W','5QIH5z2x5PYQ5A6j6kof5OIw5PYQ5yQG6l29','uMvXDwvZDa','B25fCNjVCG','DhjHC2G','y3DK','57Y65Bcrig1VzhvSzs5QC29UoIa','Bgf0zxn0','w0fWCf0G5BEY5zcV5yQO77Ym6k+35ywiiefWCc5ZDg9WkcKG5yAnihn0yxj0','rw50Axr5','y29SDw1U','y29SDw1Ux25HBwu','BwfUAwzLC3q','ChjPBwfYEuTLEq','u0Lhvevstq','C29Tzq','C3rHCNq','qxv0Aa','yMLUzevUDgL0Eq','ywrTAw5bDxrO','ChjLzML4','Chv0','zgvZy3jPChrPB24','CgfNzvf1zxj5t3a','zgLJDa','zMLUze9Uzq','jg9UvxbKyxrL','DMfSDwu','xJaUmI4Y','lMH0BwW','BwLU','C3rYAw5NAwz5','Cgf0Aa','w1jVDxrLCL0G5PYQ55+L5y+c5PwW5P2L5RQqoIa','CMvWBgfJzq','C2LUz2XLDg9U','BM9Uzq','q09ntuvovcbptIbdt0Xvtu4G','Aw50BW','z2v0tw9UDgG','C2vYDMLJzq','zMLUzej5swq','A2v5v29YzeXPA2vgAwvSzhm','x19ZA2LWvgvUyw50','lI9KAxn0l3nLCNzLCI9PBMrLEc5QCW','xJeZlJeUmW','sw52ywXPzcbHChaGA2v5','AgfUzgXLCIdNVlRLPle6ia','yxbWBgLJyxrPB24VB2n0zxqTC3rYzwfT','zgvZyW','y291BNq','ihnPBMDSzxrVBIHZkq','DhLWAw5NCY9Hzg1PBG','CMfUz2u','AwDUB3jLugvYBxm','zM9Yy2vezwXLDgu','BwLJCM8TyxbWCY1ZDgf0Awm','CMvZDg9YzsbMywLSzwq','qMfZzvbSDwDPBG','B3jKzxjcEvnXBa','Dg9mB3DLCKnHC2u','w2nVBhvTBKnVBw1LBNrZxsdPNz7MS5xMOiFOR4BNRky6ia','zNvUy3rPB24','DM9Tzq','CMvXDwLYzuvUDgL0Eq','zgf0yq','8j+tMIbbueNMLOFMOAm6ia','zgvSzxrLigzHAwXLza','DhjPBq','C3rHCNrZv2L0Aa','C2v0','iowpQUIdVEEuQos6JUAwUEAZLEwpGUAvSa','y29UC3rYDwn0B3i','mc4WlJy','lI9ZCMmVywrTAw4VC3r5BgvZl2jHC2uUy3nZ','ue9tva','zxHWB3j0CW','lNbUzW','Bw9KDwXLr2f0zxDHEq','y29SDw1UvhLWzq','yNvUihj1BIbIDwLSza','y2fJAgu','zgf0yvr5Cgu','y2fSBa','w0nVBNrYB2XSzxjDiea','kIOVBw9KDwXLCY8Ql2nVBNrYB2XSzxiVyxbWlYOQlYOUDhm','C3fS','C3vTBwfYEq','C3jJl2XPyI9JywnOzs9PBMrLEc50CW','mZeWmdKXmgHrq0rKua','Cgf0Ag5HBwu','y2yTy29UBMvJDgLUzY1PCa','yMvMB3jLsgfUzgXL','yxbWBgLJyxrPB24VANnVBJSGy2HHCNnLDd11DgyToa','ChjVCgvYDhLoyw1L','C2XPy2u','w0LVy10GyM9VDhn0CMfWiokgKca','zMLLBgrbCNjHEq','C3jJl2XPyI90yxnRl2LUzgv4lNrZ','lMnZCW','Aw5MBYbMywLSzwq','zMLUza','C2vYDMLJzufWAxm','BNvTyMvY','DxrMoa','AxntDxbLCG','l2fKBwLUl2v4Dc86A2v5','DhLWzq','Bw9KAwz5qMvMB3jL','ioMfJEE9RUs6HIbZzxj2AwnLqxbPC++8JoMCGowqJoAxTUMfJEE9RIbZzxj2AwnL','Cg9YDa','DxbKyxrLqNLsB3DZ','yM9VBgvHBG','CgX1z2LUsw5MBW','kIOVBw9KDwXLCY8Ql3nLCNzPy2uVkIOVkI50CW','D3jPDgu','ChjVDg90ExbL','w01VzhvSzv0GBg9HzgvKia','DhjHBNnWB3j0','BwfW','w1bSDwDPBL0G5yQG6l295AsX6lsLoIa','DxnLq2XHC3m'];_0x1903=function(){return _0x57aa02;};return _0x1903();}var o1=new WeakMap();function i(_0x16ef47){const _0x441e64=_0xde6411;let _0x530f79=o1[_0x441e64(0x1f4)](_0x16ef47);if(_0x530f79)return _0x530f79;let _0x127154=new M0(_0x16ef47);return o1['set'](_0x16ef47,_0x127154),_0x127154;}function _Q(_0x534ea0){return(_0x590197,_0x44d989)=>{const _0x54a169=_0x5e13;c(_0x590197[_0x54a169(0x157)],{'propertyKey':_0x44d989,'resolve':()=>i(_0x534ea0)});};}function i4(_0x443d2f){const _0x38f1a4=_0xde6411;return!!_0x443d2f&&typeof _0x443d2f===_0x38f1a4(0x221)&&_0x443d2f[_0x38f1a4(0x23c)]!=null;}class a{[_0xde6411(0x268)];[_0xde6411(0x2f7)](_0x2a89f4){const _0xc0a708=_0xde6411;if(!this[_0xc0a708(0x268)])this[_0xc0a708(0x268)]=_0x2a89f4;}[_0xde6411(0x1ef)](_0x4ec423){const _0xe967d7=_0xde6411;this[_0xe967d7(0x268)]=_0x4ec423;}['hasEntity'](){return!!this['entity'];}[_0xde6411(0x2c4)](){const _0x11b070=_0xde6411;return this[_0x11b070(0x14f)]();}[_0xde6411(0x14f)](){const _0x3691d4=_0xde6411;if(!this[_0x3691d4(0x268)])throw Error(_0x3691d4(0x22d));return this[_0x3691d4(0x268)];}async[_0xde6411(0x17b)](_0x2715bb,_0x27fba9){}async['modifyAfter'](_0x59c8bb,_0x55ee2d){}async[_0xde6411(0x216)](_0x49a26e,_0x21fb0b){const _0x3ef288=_0xde6411;let _0x5eff1f=b0(_0x21fb0b?.['upsert']),_0x4c9dd8=Array[_0x3ef288(0x1f3)](_0x49a26e)?_0x49a26e[_0x3ef288(0x186)](_0x139c3a=>_0x139c3a!=null&&typeof _0x139c3a==='object'?{..._0x139c3a}:_0x139c3a):_0x49a26e!=null&&typeof _0x49a26e===_0x3ef288(0x221)?{..._0x49a26e}:_0x49a26e;await this['modifyBefore'](_0x4c9dd8,_0x3ef288(0x216));let _0x243622=_0x5eff1f==='save'?await this['requireEntity']()[_0x3ef288(0x2c0)](_0x4c9dd8):await this['requireEntity']()[_0x3ef288(0x277)](_0x4c9dd8);return await this[_0x3ef288(0x248)](_0x243622??_0x4c9dd8,'add'),_0x243622;}async[_0xde6411(0x21c)](_0x55c6b3,_0x3e8e91){const _0x1d1d1a=_0xde6411;if(Array[_0x1d1d1a(0x1f3)](_0x55c6b3)){let _0xae8526=_0x55c6b3[_0x1d1d1a(0x186)](_0xe6259f=>({..._0xe6259f}));await this[_0x1d1d1a(0x17b)](_0xae8526,_0x1d1d1a(0x21c));let _0x24296d=await this[_0x1d1d1a(0x14f)]()['update'](_0xae8526);return await this['modifyAfter'](_0x24296d??_0xae8526,_0x1d1d1a(0x21c)),_0x24296d;}if(i4(_0x55c6b3)){let _0x9382df=_0x3e8e91!=null&&typeof _0x3e8e91===_0x1d1d1a(0x221)?{..._0x3e8e91}:_0x3e8e91;await this['modifyBefore'](_0x9382df,_0x1d1d1a(0x21c));let _0xd6a03e=await this[_0x1d1d1a(0x14f)]()['update'](_0x55c6b3,_0x9382df);return await this['modifyAfter'](_0xd6a03e??_0x9382df,_0x1d1d1a(0x21c)),_0xd6a03e;}let _0x4865b9={..._0x55c6b3};await this['modifyBefore'](_0x4865b9,'update');let _0x44f80d=await this[_0x1d1d1a(0x14f)]()['update']([_0x4865b9]);return await this['modifyAfter'](_0x44f80d??_0x4865b9,_0x1d1d1a(0x21c)),Array['isArray'](_0x44f80d)?_0x44f80d[0x0]:_0x44f80d;}async[_0xde6411(0x28d)](_0x14ca56,_0x2732de){const _0x4f35ab=_0xde6411;let _0x5b65fd=this[_0x4f35ab(0x14f)]();await this[_0x4f35ab(0x17b)](_0x14ca56,_0x4f35ab(0x28d));let _0x47b2a2=u(_0x2732de?.[_0x4f35ab(0x260)]);if(_0x2732de?.[_0x4f35ab(0x27e)]||!_0x47b2a2||!_0x5b65fd[_0x4f35ab(0x2b4)]())await _0x5b65fd[_0x4f35ab(0x146)](_0x14ca56);else await _0x5b65fd[_0x4f35ab(0x260)](_0x14ca56);await this[_0x4f35ab(0x248)](_0x14ca56,_0x4f35ab(0x28d));}[_0xde6411(0x251)](_0x1ed582){const _0x3d6d32=_0xde6411;return this[_0x3d6d32(0x14f)]()[_0x3d6d32(0x251)](_0x1ed582);}[_0xde6411(0x25a)](_0x1923f9,_0x26caab){const _0x5e32fe=_0xde6411;return this[_0x5e32fe(0x14f)]()[_0x5e32fe(0x174)](_0x1923f9,_0x26caab);}[_0xde6411(0x295)](_0x302e65,_0x65bca3){const _0x3cd236=_0xde6411;let _0x4a1321=this[_0x3cd236(0x14f)]();if(typeof _0x302e65===_0x3cd236(0x221))return _0x4a1321[_0x3cd236(0x2fe)](_0x302e65,_0x65bca3);return _0x4a1321[_0x3cd236(0x30e)](_0x302e65,_0x65bca3);}['page'](_0x2edb2d={}){const _0x5010c0=_0xde6411;let _0x470547=Math[_0x5010c0(0x23d)](0x1,_0x2edb2d[_0x5010c0(0x23f)]??0x1),_0x3ff40d=Math['min'](0x64,Math['max'](0x1,_0x2edb2d[_0x5010c0(0x292)]??0x14));return this['requireEntity']()[_0x5010c0(0x257)]({'page':_0x470547,'size':_0x3ff40d,'where':_0x2edb2d[_0x5010c0(0x19d)],'orderBy':_0x2edb2d[_0x5010c0(0x1ba)],'withTrashed':_0x2edb2d[_0x5010c0(0x1bd)],'onlyTrashed':_0x2edb2d[_0x5010c0(0x196)],'softDelete':_0x2edb2d['softDelete']});}}var m0={'add':'\u65B0\u589E','delete':'\u5220\u9664','update':'\u4FEE\u6539','info':'\u5355\u4E2A\u4FE1\u606F','list':'\u5217\u8868\u67E5\u8BE2','page':'\u5206\u9875\u67E5\u8BE2','restore':'\u6062\u590D'},s4=['add',_0xde6411(0x28d),_0xde6411(0x21c),'info',_0xde6411(0x25a),_0xde6411(0x23f),_0xde6411(0x251)],CQ=new Set([_0xde6411(0x216),_0xde6411(0x21c),_0xde6411(0x28d),'restore']);function o4(_0x2b2617,_0x1938d6){const _0x544895=_0xde6411;if(!_0x2b2617||!_0x1938d6?.[_0x544895(0x1e8)])return _0x2b2617;let _0x11a74b={..._0x2b2617};for(let _0x475fad of _0x1938d6)delete _0x11a74b[_0x475fad];return _0x11a74b;}function a1(_0x379d05){const _0x473f86=_0xde6411;if(Array[_0x473f86(0x1f3)](_0x379d05))return _0x379d05[_0x473f86(0x186)](_0x2a9135=>{const _0x2c69c7=_0x473f86;if(_0x2a9135!=null&&typeof _0x2a9135===_0x2c69c7(0x221)&&'id'in _0x2a9135)return _0x2a9135['id'];return _0x2a9135;});if(_0x379d05&&typeof _0x379d05===_0x473f86(0x221)){let _0x5cc38f=_0x379d05;if(Array[_0x473f86(0x1f3)](_0x5cc38f[_0x473f86(0x249)]))return _0x5cc38f[_0x473f86(0x249)];if(_0x5cc38f['id']!=null)return[_0x5cc38f['id']];}return[];}function r4(_0x30a3aa){const _0x228d28=_0xde6411;let _0x410ccf=_0x30a3aa['crud'],_0x192b95=_0x410ccf['entity'];if(_0x410ccf[_0x228d28(0x30d)]){let _0x2b93fe=K[_0x228d28(0x1f4)](_0x410ccf[_0x228d28(0x30d)]);if(_0x192b95&&!_0x2b93fe[_0x228d28(0x2d9)]())_0x2b93fe[_0x228d28(0x1ef)](i(_0x192b95));return _0x2b93fe;}if(!_0x192b95)throw Error('[CRUD]\x20'+_0x30a3aa['token']['name']+_0x228d28(0x1f5));let _0x361f21=new class extends a{}();return _0x361f21[_0x228d28(0x1ef)](i(_0x192b95)),_0x361f21;}function a4(_0x15ea2f,_0x2cbba9){const _0x47df88=_0xde6411;let _0x2b56e3=_0x2cbba9[_0x47df88(0x1bc)]?.[_0x47df88(0x268)];if(_0x2b56e3)return _0x2b56e3;return _0x15ea2f[_0x47df88(0x2c4)]()[_0x47df88(0x195)];}var L0=(_0xd86450,_0xa51211,_0x58b20c)=>{const _0x210d92=_0xde6411;let _0xa2c66c=_0xa51211[_0x210d92(0x1bc)];if(!_0xa2c66c)return _0xd86450;let _0x245a0c=(_0xa2c66c[_0x210d92(0x283)]??[])[_0x210d92(0x24f)](_0x64e18e=>s4[_0x210d92(0x261)](_0x64e18e)),_0x4f571b=_0xa2c66c[_0x210d92(0x175)]??[];if(!_0x245a0c[_0x210d92(0x1e8)]&&!_0x4f571b[_0x210d92(0x1e8)])return _0xd86450;let _0x2157ae=_0x58b20c[_0x210d92(0x18b)]instanceof n?_0x58b20c[_0x210d92(0x18b)]:new n(),_0x5d6559=_0x245a0c[_0x210d92(0x1e8)]>0x0,_0x326b6b=_0x5d6559||_0xa2c66c['service']?r4(_0xa51211):void 0x0,_0x4eee2=_0x5d6559&&_0x326b6b?a4(_0x326b6b,_0xa51211):void 0x0,_0x218548=_0x4eee2?_0x4eee2['id']:void 0x0;if(_0x5d6559&&_0x218548==null)throw Error(_0x210d92(0x2ba)+_0xa51211[_0x210d92(0x2d5)][_0x210d92(0x194)]+_0x210d92(0x285));let _0x1bbd88=_0xd86450,_0x481422=(_0x431d97,_0x1c7ef3,_0x2a66d5,_0x42d4e7)=>{const _0x370261=_0x210d92;_0x1bbd88=_0x1bbd88[_0x431d97](_0x1c7ef3,_0x42d4e7,_0x58b20c[_0x370261(0x234)]({'action':_0x2a66d5,'summary':m0[_0x2a66d5]}));},_0x8f1f96=async(_0x5caf56,_0x6c3657,_0x4cd090)=>{const _0x33748e=_0x210d92;if(!_0xa2c66c[_0x33748e(0x24d)]||!CQ[_0x33748e(0x1c7)](_0x5caf56))return _0x6c3657;return await _0xa2c66c['before']({'body':_0x6c3657,'request':_0x4cd090,'api':_0x5caf56}),_0x6c3657;};if(_0x245a0c[_0x210d92(0x261)](_0x210d92(0x216))&&_0x326b6b)_0x481422('post','/add','add',async({body:_0x427464,request:_0x3bfadd})=>{const _0x20e844=_0x210d92;try{let _0x4a2142=_0x427464;if(Array[_0x20e844(0x1f3)](_0x4a2142)){let _0x2c0629=_0x4a2142;if(_0xa2c66c['before']&&CQ[_0x20e844(0x1c7)](_0x20e844(0x216))){for(let _0x160db3=0x0;_0x160db3<_0x2c0629[_0x20e844(0x1e8)];_0x160db3++)_0x2c0629[_0x160db3]=await _0x8f1f96(_0x20e844(0x216),{..._0x2c0629[_0x160db3]??{}},_0x3bfadd);}if(_0xa2c66c[_0x20e844(0x2d3)]){let _0x398c8b=await _0xa2c66c['insertParam']({'body':_0x2c0629[0x0]??{},'request':_0x3bfadd});_0x2c0629=_0x2c0629[_0x20e844(0x186)](_0x33ca3a=>({..._0x33ca3a,..._0x398c8b}));}let _0x54be87=await _0x326b6b[_0x20e844(0x216)](_0x2c0629);return _0x2157ae['ok'](_0x54be87);}let _0x46a044={..._0x4a2142??{}};if(_0x46a044=await _0x8f1f96('add',_0x46a044,_0x3bfadd),_0xa2c66c[_0x20e844(0x2d3)])Object[_0x20e844(0x2dd)](_0x46a044,await _0xa2c66c[_0x20e844(0x2d3)]({'body':_0x46a044,'request':_0x3bfadd}));let _0x54bf1d=await _0x326b6b[_0x20e844(0x216)](_0x46a044);return _0x2157ae['ok'](_0x54bf1d);}catch(_0x1481c9){return _0x2157ae[_0x20e844(0x297)](_0x1481c9 instanceof Error?_0x1481c9[_0x20e844(0x1c8)]:'add\x20failed');}});if(_0x245a0c['includes']('delete')&&_0x326b6b&&_0x218548)_0x481422('post',_0x210d92(0x20d),_0x210d92(0x28d),async({body:_0x3f5331,request:_0x383f47})=>{const _0x3a3165=_0x210d92;try{let _0x5bd1cf=_0x3f5331,_0x31ed53=Array[_0x3a3165(0x1f3)](_0x5bd1cf)?_0x5bd1cf:await _0x8f1f96(_0x3a3165(0x28d),{..._0x5bd1cf??{}},_0x383f47),_0x4b5b8e=a1(_0x31ed53);if(!_0x4b5b8e[_0x3a3165(0x1e8)])return _0x2157ae[_0x3a3165(0x297)](_0x3a3165(0x21d));let _0x137b3f=!Array[_0x3a3165(0x1f3)](_0x31ed53)&&!!_0x31ed53[_0x3a3165(0x27e)];return await _0x326b6b[_0x3a3165(0x28d)](_0x4b5b8e,{'force':_0x137b3f}),_0x2157ae['ok']();}catch(_0x341b33){return _0x2157ae[_0x3a3165(0x297)](_0x341b33 instanceof Error?_0x341b33[_0x3a3165(0x1c8)]:_0x3a3165(0x152));}});if(_0x245a0c[_0x210d92(0x261)](_0x210d92(0x21c))&&_0x326b6b&&_0x218548)_0x481422('post',_0x210d92(0x213),_0x210d92(0x21c),async({body:_0x46554f,request:_0x3602be})=>{const _0x367b3b=_0x210d92;try{let _0x475547=_0x46554f;if(Array[_0x367b3b(0x1f3)](_0x475547)){let _0xd03485=_0x475547;if(_0xa2c66c['before']&&CQ[_0x367b3b(0x1c7)](_0x367b3b(0x21c))){for(let _0x56b090=0x0;_0x56b090<_0xd03485[_0x367b3b(0x1e8)];_0x56b090++)_0xd03485[_0x56b090]=await _0x8f1f96(_0x367b3b(0x21c),{..._0xd03485[_0x56b090]??{}},_0x3602be);}let _0x27263c=await _0x326b6b[_0x367b3b(0x21c)](_0xd03485);return _0x2157ae['ok'](_0x27263c);}let _0x3ebcca=await _0x8f1f96(_0x367b3b(0x21c),{..._0x475547??{}},_0x3602be);if(_0x3ebcca['id']==null)return _0x2157ae[_0x367b3b(0x297)]('id\x20required');let _0x537247=await _0x326b6b[_0x367b3b(0x21c)](_0x3ebcca);return _0x2157ae['ok'](_0x537247);}catch(_0x1d52b0){return _0x2157ae[_0x367b3b(0x297)](_0x1d52b0 instanceof Error?_0x1d52b0[_0x367b3b(0x1c8)]:'update\x20failed');}});if(_0x245a0c[_0x210d92(0x261)](_0x210d92(0x295))&&_0x326b6b)_0x481422('get',_0x210d92(0x18e),_0x210d92(0x295),async({query:_0xf4e579})=>{const _0x3fe78a=_0x210d92;try{let _0x4e0463=_0xf4e579?.['id'];if(_0x4e0463==null||_0x4e0463==='')return _0x2157ae[_0x3fe78a(0x297)](_0x3fe78a(0x222));let _0x35f816=await _0x326b6b[_0x3fe78a(0x295)](_0x4e0463);return _0x2157ae['ok'](o4(_0x35f816,_0xa2c66c[_0x3fe78a(0x290)]));}catch(_0x3f4526){return _0x2157ae['fail'](_0x3f4526 instanceof Error?_0x3f4526[_0x3fe78a(0x1c8)]:_0x3fe78a(0x173));}});if(_0x245a0c[_0x210d92(0x261)]('list')&&_0x326b6b&&_0x4eee2)_0x481422('post',_0x210d92(0x1e2),'list',async({body:_0x37135f,request:_0x479f4c})=>{const _0x344443=_0x210d92;try{let _0x53bcaf=_0x37135f??{},_0x1326ec=_0xa2c66c[_0x344443(0x291)]??{},_0x213e34={'onlyTrashed':_0x53bcaf[_0x344443(0x196)]===!0x0,'withTrashed':_0x53bcaf[_0x344443(0x1bd)]===!0x0};if(W0(_0x1326ec)){let _0x5de44e=await j0(_0x4eee2,_0x53bcaf,_0x1326ec,{'request':_0x479f4c,'mode':_0x344443(0x25a),'trash':_0x213e34});return _0x2157ae['ok'](_0x5de44e);}let {where:_0x41b8bf,orderBySql:_0x347ce9}=await l(_0x4eee2,_0x53bcaf,_0x1326ec,_0x479f4c),_0x6dfaf5=await _0x326b6b[_0x344443(0x25a)](_0x41b8bf,{'orderBy':_0x347ce9,..._0x213e34});return _0x2157ae['ok'](_0x6dfaf5);}catch(_0x148f55){return _0x2157ae['fail'](_0x148f55 instanceof Error?_0x148f55[_0x344443(0x1c8)]:_0x344443(0x1be));}});if(_0x245a0c[_0x210d92(0x261)](_0x210d92(0x23f))&&_0x326b6b&&_0x4eee2)_0x481422(_0x210d92(0x1e6),'/page',_0x210d92(0x23f),async({body:_0x55f98a,request:_0x2237af})=>{const _0x59fcbd=_0x210d92;try{let _0x10caa3=_0x55f98a??{},_0x525e2d=_0xa2c66c[_0x59fcbd(0x2fc)]??{},_0x23bcb9={'onlyTrashed':_0x10caa3[_0x59fcbd(0x196)]===!0x0,'withTrashed':_0x10caa3[_0x59fcbd(0x1bd)]===!0x0};if(W0(_0x525e2d)){let _0x26b2bd=await j0(_0x4eee2,_0x10caa3,_0x525e2d,{'request':_0x2237af,'mode':_0x59fcbd(0x23f),'trash':_0x23bcb9});return _0x2157ae['ok'](_0x26b2bd);}let {where:_0x2006f1,orderBySql:_0x1f6ae1}=await l(_0x4eee2,_0x10caa3,_0x525e2d,_0x2237af),_0x3d07cb=await _0x326b6b[_0x59fcbd(0x23f)]({'page':Number(_0x10caa3[_0x59fcbd(0x23f)]??0x1),'size':Number(_0x10caa3[_0x59fcbd(0x292)]??0x14),'where':_0x2006f1,'orderBy':_0x1f6ae1,..._0x23bcb9});return _0x2157ae['ok'](_0x3d07cb);}catch(_0x16b10e){return _0x2157ae[_0x59fcbd(0x297)](_0x16b10e instanceof Error?_0x16b10e['message']:_0x59fcbd(0x2b2));}});if(_0x245a0c[_0x210d92(0x261)](_0x210d92(0x251))&&_0x326b6b&&_0x218548)_0x481422(_0x210d92(0x1e6),_0x210d92(0x25e),'restore',async({body:_0x592815,request:_0x7aaf85})=>{const _0xe62795=_0x210d92;try{let _0xdc26c1=_0x592815,_0x15ef2c=Array[_0xe62795(0x1f3)](_0xdc26c1)?_0xdc26c1:await _0x8f1f96(_0xe62795(0x251),{..._0xdc26c1??{}},_0x7aaf85),_0x22d223=a1(_0x15ef2c);if(!_0x22d223[_0xe62795(0x1e8)])return _0x2157ae[_0xe62795(0x297)](_0xe62795(0x21d));return await _0x326b6b[_0xe62795(0x251)](_0x22d223),_0x2157ae['ok']();}catch(_0xdf5abc){return _0x2157ae[_0xe62795(0x297)](_0xdf5abc instanceof Error?_0xdf5abc[_0xe62795(0x1c8)]:_0xe62795(0x148));}});if(_0x4f571b[_0x210d92(0x1e8)]){if(!_0xa2c66c[_0x210d92(0x30d)])throw Error(_0x210d92(0x2ba)+_0xa51211[_0x210d92(0x2d5)][_0x210d92(0x194)]+_0x210d92(0x17c));let _0x5875d6=K[_0x210d92(0x1f4)](_0xa2c66c[_0x210d92(0x30d)]);for(let _0x49073f of _0x4f571b){let _0x38fd95=_0x5875d6[_0x49073f];if(typeof _0x38fd95!==_0x210d92(0x14d))throw Error('[CRUD]\x20'+_0xa2c66c[_0x210d92(0x30d)]['name']+'.'+_0x49073f+'\x20不是有效方法');let _0x5b980e=_0x38fd95['bind'](_0x5875d6);_0x481422('post','/'+_0x49073f,_0x49073f,async({body:_0x6326f})=>{const _0x1ddcf1=_0x210d92;try{let _0x332fc9=await _0x5b980e(_0x6326f);return _0x2157ae['ok'](_0x332fc9);}catch(_0x7cdff9){return _0x2157ae[_0x1ddcf1(0x297)](_0x7cdff9 instanceof Error?_0x7cdff9[_0x1ddcf1(0x1c8)]:_0x49073f+_0x1ddcf1(0x214));}});}}return _0x1bbd88;};import{join as _0x2be761}from'path';import{pathToFileURL as _0x18d9ac}from'url';var t4=_0xde6411(0x181),e4=[{'pattern':'**/modules/*/controller/admin/**/*.ts','side':_0xde6411(0x21b)},{'pattern':_0xde6411(0x164),'side':'app'}];async function Q5(_0x1bc596,_0x4f303c,_0x6f8821){const _0x319bff=_0xde6411;zQ({'module':y1(_0x4f303c),'side':_0x6f8821,'file':_0x4f303c});try{await import(_0x18d9ac(_0x2be761(_0x1bc596,_0x4f303c))[_0x319bff(0x1e0)]);}finally{zQ(null);}}async function HQ(){const _0x26c29d=_0xde6411;let _0xfedff4=process['cwd'](),_0x897816=await X0(t4,{'cwd':_0xfedff4});for(let _0x2c0403 of _0x897816)await import(_0x18d9ac(_0x2be761(_0xfedff4,_0x2c0403))['href']);let _0x5521fb=0x0;for(let {pattern:_0x11b18d,side:_0x4f8888}of e4){let _0x22cab2=await X0(_0x11b18d,{'cwd':_0xfedff4});_0x5521fb+=_0x22cab2[_0x26c29d(0x1e8)];for(let _0x2150b0 of _0x22cab2)await Q5(_0xfedff4,_0x2150b0,_0x4f8888);}f0(L0),console[_0x26c29d(0x211)]('[Host]\x20crud\x20\u2190\x20@vome-core/orm'),console[_0x26c29d(0x211)]('[Host]\x20scan\x20←\x20'+_0x897816[_0x26c29d(0x1e8)]+'\x20service,\x20'+_0x5521fb+_0x26c29d(0x2a6));}import{join as _0x2bc83a}from'path';import{createPinoLogger as _0x2709da}from'@bogeychan/elysia-logger';import _0x400a53 from'pino-pretty';import{createWriteStream as _0x1d7181,mkdirSync as _0x1362da,readdirSync as _0x1c5276,unlinkSync as _0x5d20b8}from'fs';import{join as _0x2249ed}from'path';import{Writable as _0x4c0e82}from'stream';var W5=/^(\d{4}-\d{2}-\d{2})\.log$/;function IQ(_0x57b64f=new Date()){const _0x55d766=_0xde6411;let _0x468130=_0x57b64f[_0x55d766(0x1c5)](),_0x47d9ad=String(_0x57b64f[_0x55d766(0x30c)]()+0x1)['padStart'](0x2,'0'),_0x813f62=String(_0x57b64f[_0x55d766(0x1d5)]())[_0x55d766(0x282)](0x2,'0');return _0x468130+'-'+_0x47d9ad+'-'+_0x813f62;}function Q3(_0x3c6bc8,_0x37a9d7){const _0x4dc35f=_0xde6411;let _0x11a2bb=new Date();_0x11a2bb['setDate'](_0x11a2bb[_0x4dc35f(0x1d5)]()-_0x37a9d7);let _0x1b4b0f=IQ(_0x11a2bb);for(let _0x18a469 of _0x1c5276(_0x3c6bc8)){let _0x9582f1=_0x18a469['match'](W5);if(!_0x9582f1||_0x9582f1[0x1]>=_0x1b4b0f)continue;_0x5d20b8(_0x2249ed(_0x3c6bc8,_0x18a469));}}function $3(_0x5520c0,_0x27d37d){return _0x1d7181(_0x2249ed(_0x5520c0,_0x27d37d+'.log'),{'flags':'a'});}function J3(_0x5121fb,_0x2321ea=0x1e){_0x1362da(_0x5121fb,{'recursive':!0x0}),Q3(_0x5121fb,_0x2321ea);let _0x51b00f=IQ(),_0x57037f=$3(_0x5121fb,_0x51b00f);return new _0x4c0e82({'write'(_0x4f9c90,_0x5e7705,_0x16f327){const _0x5b8854=_0x5e13;let _0x27a05e=IQ();if(_0x27a05e!==_0x51b00f)_0x57037f['end'](),_0x51b00f=_0x27a05e,_0x57037f=$3(_0x5121fb,_0x51b00f),Q3(_0x5121fb,_0x2321ea);_0x57037f[_0x5b8854(0x182)](_0x4f9c90,_0x16f327);},'final'(_0x14f1da){const _0x15772f=_0x5e13;_0x57037f[_0x15772f(0x1d6)](_0x14f1da);}});}var c0;function F5(){const _0x2479c1=_0xde6411;let _0x368739=D['logging']??{},_0x4a6431=_0x368739['level']??_0x2479c1(0x295);if(_0x368739[_0x2479c1(0x185)]==='file'){let _0x5952fa=_0x2bc83a(process[_0x2479c1(0x2ea)](),_0x368739[_0x2479c1(0x2a9)]??'logging'),_0x32c599=_0x368739[_0x2479c1(0x2aa)]??0x1e;return _0x2709da({'level':_0x4a6431,'stream':J3(_0x5952fa,_0x32c599)});}return _0x2709da({'level':_0x4a6431,'stream':_0x400a53({'colorize':!0x0,'translateTime':_0x2479c1(0x205),'ignore':_0x2479c1(0x2e4)})});}function R(){if(!c0)c0=F5();return c0;}function RQ(){c0=void 0x0;}class s{[_0xde6411(0x295)](_0x28fe70,..._0x115d70){const _0x41cde2=_0xde6411;let _0x4096b7=R();if(_0x115d70[_0x41cde2(0x1e8)])_0x4096b7[_0x41cde2(0x295)]({'args':_0x115d70},_0x28fe70);else _0x4096b7['info'](_0x28fe70);}['warn'](_0x19c4bf,..._0x5f44ba){const _0x26bb3e=_0xde6411;let _0x47c2d1=R();if(_0x5f44ba[_0x26bb3e(0x1e8)])_0x47c2d1[_0x26bb3e(0x2b1)]({'args':_0x5f44ba},_0x19c4bf);else _0x47c2d1[_0x26bb3e(0x2b1)](_0x19c4bf);}['debug'](_0x7275a9,..._0x3c839f){const _0x317e41=_0xde6411;let _0x1d4f4e=R();if(_0x3c839f['length'])_0x1d4f4e[_0x317e41(0x2ac)]({'args':_0x3c839f},_0x7275a9);else _0x1d4f4e['debug'](_0x7275a9);}[_0xde6411(0x2a2)](_0x391b66,..._0x30c8de){const _0x55648a=_0xde6411;let _0x37d4ae=R();if(_0x391b66 instanceof Error){_0x37d4ae[_0x55648a(0x2a2)](_0x391b66);return;}if(_0x30c8de[0x0]instanceof Error){_0x37d4ae[_0x55648a(0x2a2)](_0x30c8de[0x0],_0x391b66);return;}if(_0x30c8de['length'])_0x37d4ae[_0x55648a(0x2a2)]({'args':_0x30c8de},_0x391b66);else _0x37d4ae[_0x55648a(0x2a2)](_0x391b66);}}class Y0 extends Error{['statusCode'];[_0xde6411(0x197)];constructor(_0x3e0053,_0x18128c){const _0x92f2d5=_0xde6411;super(_0x3e0053),(this['name']='CommException',this['statusCode']=_0x18128c?.[_0x92f2d5(0x266)]??0xc8,this[_0x92f2d5(0x197)]=_0x18128c?.[_0x92f2d5(0x197)]??C[_0x92f2d5(0x294)]);}}function U0(_0x5f58f0){return _0x5f58f0 instanceof Y0;}function qQ(){const _0x2fc802=_0xde6411;R(),K[_0x2fc802(0x155)](s,new s());}var j5='\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 H5(){const _0x140a03=_0xde6411;if(!process[_0x140a03(0x22f)][_0x140a03(0x1f2)])return;process[_0x140a03(0x22f)][_0x140a03(0x182)](_0x140a03(0x2ae));}function V3(){const _0x33a927=_0xde6411;H5();let _0xfc42f7=P(),_0x30f479=D[_0x33a927(0x231)]?.[_0x33a927(0x17d)]??0xbb9,_0xbd2160=D['openapi']?.[_0x33a927(0x305)]??_0x33a927(0x2df),_0x43c652=_0x33a927(0x242)+_0x30f479;if(console[_0x33a927(0x211)](j5),console[_0x33a927(0x211)]('🌍\x20运行环境:\x20'+_0xfc42f7),_0xfc42f7===_0x33a927(0x2d0))console['log']('📡\x20服务地址:\x20'+_0x43c652),console[_0x33a927(0x211)](_0x33a927(0x151)+_0x43c652+(_0xbd2160[_0x33a927(0x154)]('/')?_0xbd2160:'/'+_0xbd2160));}import{access as _0x50e6bf}from'fs/promises';import{join as _0x39d97f}from'path';import{pathToFileURL as _0x373de8}from'url';async function Y5(_0x3d203a){try{return await _0x50e6bf(_0x3d203a),!0x0;}catch{return!0x1;}}async function v(_0x465935){const _0x44660a=_0xde6411;let _0x54a85c=_0x39d97f(process[_0x44660a(0x2ea)](),_0x465935);if(!await Y5(_0x54a85c)){console[_0x44660a(0x2b1)](_0x44660a(0x1b4)+_0x465935);return;}return await import(_0x373de8(_0x54a85c)['href']);}async function W3(){const _0x2add28=_0xde6411;let _0x579647=await v('src/lib/db/index.ts');if(_0x579647?.['Db']?.[_0x2add28(0x1a6)])await _0x579647['Db']['bootstrap']();let _0x11eed1=await v(_0x2add28(0x167));if(_0x11eed1?.[_0x2add28(0x202)]?.['bootstrap'])await _0x11eed1[_0x2add28(0x202)][_0x2add28(0x1a6)]();let _0x1c84f7=await v(_0x2add28(0x279));if(_0x1c84f7?.[_0x2add28(0x2f6)]?.[_0x2add28(0x1a6)])await _0x1c84f7['Auth']['bootstrap']();}async function z3(){const _0x1f4806=_0xde6411;let _0x378e9c=await v(_0x1f4806(0x171));if(_0x378e9c?.[_0x1f4806(0x1ad)]?.[_0x1f4806(0x1a6)])await _0x378e9c[_0x1f4806(0x1ad)]['bootstrap']();}async function G3(){const _0x4ba538=_0xde6411;let _0x1a720f=await v(_0x4ba538(0x1ff));if(_0x1a720f?.['Plugin']?.[_0x4ba538(0x1a6)])await _0x1a720f['Plugin'][_0x4ba538(0x1a6)]();}async function F3(){const _0x43633f=_0xde6411;let _0x263af6=await v(_0x43633f(0x20b));if(_0x263af6?.[_0x43633f(0x224)]?.['bootstrap'])await _0x263af6[_0x43633f(0x224)]['bootstrap']();}async function j3(){const _0x5b7fea=_0xde6411;let _0x534112=await v(_0x5b7fea(0x171));if(_0x534112?.[_0x5b7fea(0x1ad)]?.[_0x5b7fea(0x21e)])await _0x534112[_0x5b7fea(0x1ad)][_0x5b7fea(0x21e)]();}async function H3(){const _0x3b1ae8=_0xde6411;let _0x3e89b1=await v(_0x3b1ae8(0x167));if(_0x3e89b1?.['Cache']?.[_0x3b1ae8(0x21e)])await _0x3e89b1[_0x3b1ae8(0x202)]['close']();let _0x164c9b=await v('src/lib/db/index.ts');if(_0x164c9b?.['Db']?.['close'])await _0x164c9b['Db']['close']();}async function B3(_0x2cb3e5){const _0x7f4053=_0xde6411;let _0x371795=await v('src/middleware/index.ts');if(!_0x371795)return _0x2cb3e5;let _0x54688a=_0x2cb3e5;if(_0x371795[_0x7f4053(0x1cb)])_0x54688a=_0x54688a[_0x7f4053(0x265)](_0x371795[_0x7f4053(0x1cb)]);if(_0x371795[_0x7f4053(0x2f8)])_0x54688a=_0x54688a[_0x7f4053(0x265)](_0x371795[_0x7f4053(0x2f8)]);if(_0x371795[_0x7f4053(0x2cc)])_0x54688a=_0x54688a[_0x7f4053(0x265)](_0x371795[_0x7f4053(0x2cc)]);if(_0x371795[_0x7f4053(0x20c)])_0x54688a=_0x54688a['use'](_0x371795[_0x7f4053(0x20c)]);if(_0x371795[_0x7f4053(0x15d)])_0x54688a=_0x54688a[_0x7f4053(0x265)](_0x371795[_0x7f4053(0x15d)]);return _0x54688a;}function M3(_0x17204a){const _0x59324d=_0xde6411;if(!(D['asyncContextManager']??{})[_0x59324d(0x1b3)])return _0x17204a;return _0x17204a['onRequest'](({request:_0x135dff})=>{G1(z1(_0x135dff));});}function L3(_0xa6a188){const _0x2d2223=_0xde6411;return _0xa6a188[_0x2d2223(0x2e8)](({error:_0x291dfe,set:_0x1a8f09,code:_0x38e99e})=>{const _0x3f4814=_0x2d2223;let _0x268992=R();if(U0(_0x291dfe))return _0x268992[_0x3f4814(0x2a2)]({'code':_0x291dfe['code']},_0x291dfe[_0x3f4814(0x1c8)]),_0x1a8f09[_0x3f4814(0x2c3)]=_0x291dfe['statusCode'],{'code':_0x291dfe[_0x3f4814(0x197)],'message':_0x291dfe[_0x3f4814(0x1c8)]};if(_0x38e99e===_0x3f4814(0x296)){let _0x559e91=_0x291dfe instanceof Error?_0x291dfe[_0x3f4814(0x1c8)]:_0x3f4814(0x2cf);return _0x268992[_0x3f4814(0x2a2)]({'code':_0x38e99e},_0x559e91),_0x1a8f09[_0x3f4814(0x2c3)]=0x1a6,{'code':C[_0x3f4814(0x294)],'message':_0x559e91};}if(_0x38e99e===_0x3f4814(0x2be))return _0x1a8f09[_0x3f4814(0x2c3)]=0x194,{'code':C[_0x3f4814(0x294)],'message':_0x3f4814(0x235)};let _0x5e58e7=_0x291dfe instanceof Error?_0x291dfe:Error(String(_0x291dfe));return _0x268992[_0x3f4814(0x2a2)](_0x5e58e7),_0x1a8f09['status']=0x1f4,{'code':C['ERROR'],'message':P()===_0x3f4814(0x2d0)?_0x5e58e7[_0x3f4814(0x1c8)]:_0x3f4814(0x20f)};});}function Y3(_0x5615d9){const _0x2c163a=_0xde6411;let _0x3e5e91=R();return _0x5615d9['use'](_0x3e5e91[_0x2c163a(0x30b)]({'autoLogging':{'ignore':_0xef4194=>Boolean(_0xef4194['isError'])}}));}import{openapi as _0x182e83}from'@elysiajs/openapi';function U3(_0x767246){const _0x20f136=_0xde6411;let _0x36a141=D['openapi']??{'enable':!0x1};if(_0x36a141[_0x20f136(0x1b3)]===!0x1)return _0x767246;let _0x4dace2=_0x36a141['path']??_0x20f136(0x2df),{tags:_0x1194bc,tagGroups:_0x40391e}=O1(),_0x52a306=_0x36a141[_0x20f136(0x200)]??{},_0x419703=_0x36a141[_0x20f136(0x1b5)]??{};return _0x767246[_0x20f136(0x265)](_0x182e83({'path':_0x4dace2,'documentation':{..._0x52a306,'tags':[..._0x52a306[_0x20f136(0x2a7)]??[],..._0x1194bc],'x-tagGroups':_0x40391e},'scalar':{..._0x419703,'layout':_0x419703[_0x20f136(0x227)]??_0x20f136(0x1da),'operationTitleSource':_0x419703['operationTitleSource']??_0x20f136(0x166)}}));}var D0,SQ=!0x1,EQ=!0x1,PQ=!0x1,D3=[],T3=[],N3=[];async function T5(){if(PQ)return;PQ=!0x0,await HQ();}function N5(){return M3(L3(Y3(new _0x5737b5())));}function A5(_0x3a91a1){const _0x1ced4d=_0xde6411;D3[_0x1ced4d(0x281)](_0x3a91a1);}function K5(_0x40bcc0){T3['push'](_0x40bcc0);}function _5(_0x267d0c){N3['push'](_0x267d0c);}async function C5(){const _0x201250=_0xde6411;if(SQ)throw Error(_0x201250(0x2ed));let _0x3658bf=N5();_0x3658bf=await B3(_0x3658bf);for(let _0x5b4ff5 of N3)_0x3658bf=_0x5b4ff5(_0x3658bf);await T5(),_0x3658bf=U3(_0x3658bf),await W3();for(let _0x1fed30 of D3)await _0x1fed30();qQ(),ZQ(),await G3(),await F3(),await z3(),_0x3658bf=f1(_0x3658bf,D);let _0x5e9159=D[_0x201250(0x231)]?.[_0x201250(0x17d)]??0xbb9;return _0x3658bf[_0x201250(0x1eb)](_0x5e9159),D0=_0x3658bf,SQ=!0x0,V3(),I5(),D0;}async function A3(){const _0x52e204=_0xde6411;if(!D0)return;for(let _0x34fcf1 of T3)await _0x34fcf1();await j3(),await H3(),await D0[_0x52e204(0x1af)](),D0=void 0x0,SQ=!0x1,PQ=!0x1,JQ(),RQ(),f0(void 0x0),EQ=!0x1;}function I5(){const _0x18812e=_0xde6411;if(EQ)return;EQ=!0x0;for(let _0x407494 of[_0x18812e(0x2d4),_0x18812e(0x2f3)])process['once'](_0x407494,async()=>{const _0x570601=_0x18812e;await A3(),process[_0x570601(0x1a9)](0x0);});}var p0={'bootstrap':A5,'shutdown':K5,'use':_5,'start':C5,'stop':A3};async function K3(_0x2f440b){const _0x35a7f9=_0xde6411;if(_0x2f440b)await _0x2f440b({'App':p0});return p0[_0x35a7f9(0x2f5)]();}import{getTableColumns as _0x86df80,getTableName as _0x2313cd}from'drizzle-orm';import{getTableColumns as _0x27bb55,getTableName as _0xccd7d7}from'drizzle-orm';import{integer as _0x297f39,serial as _0x4301a9,timestamp as _0xe72189}from'drizzle-orm/pg-core';var xQ={'id':_0x4301a9('id')[_0xde6411(0x2f2)](),'createTime':_0xe72189(_0xde6411(0x2da),{'withTimezone':!0x0})['notNull']()[_0xde6411(0x25d)](),'updateTime':_0xe72189(_0xde6411(0x274),{'withTimezone':!0x0})[_0xde6411(0x1d7)]()[_0xde6411(0x25d)]()[_0xde6411(0x2ff)](()=>new Date()),'deletedAt':_0xe72189(_0xde6411(0x293),{'withTimezone':!0x0}),'tenantId':_0x297f39(_0xde6411(0x1f0))},T0={'id':'ID','createTime':_0xde6411(0x1d0),'updateTime':_0xde6411(0x1fc),'deletedAt':_0xde6411(0x1a8),'tenantId':'\u79DF\u6237'},vQ=new WeakMap(),I3=new Set();function kQ(_0x5867c0,_0x41bffb={}){const _0x5ab3b1=_0xde6411;return I3[_0x5ab3b1(0x216)](_0x5867c0),vQ['set'](_0x5867c0,{...T0,...vQ['get'](_0x5867c0)||{},..._0x41bffb}),_0x5867c0;}function t(_0x519ca5){return vQ['get'](_0x519ca5)||{};}function P5(){return[...I3];}function _3(_0x3cd14a){const _0x3fe7b4=_0xde6411;if(!/^[A-Za-z_][A-Za-z0-9_]*$/[_0x3fe7b4(0x1df)](_0x3cd14a))throw Error(_0x3fe7b4(0x14c)+_0x3cd14a);return'\x22'+_0x3cd14a+'\x22';}function C3(_0x349f53){const _0x2bd21b=_0xde6411;return _0x349f53[_0x2bd21b(0x307)](/'/g,'\x27\x27');}async function fQ(_0x38e8cd){const _0x5bffb2=_0xde6411;let _0x3b367d=P5();if(!_0x3b367d['length'])return 0x0;let _0x22f3f8=new Map(),_0x46ae0d=[];for(let _0x1e947f of _0x3b367d){let _0x1d409c;try{_0x1d409c=_0xccd7d7(_0x1e947f);}catch{continue;}let _0x1458c6=_0x27bb55(_0x1e947f),_0x396827=t(_0x1e947f),_0x2d83d7=new Map();for(let [_0x5c6787,_0x2f3cf7]of Object[_0x5bffb2(0x28f)](_0x396827)){if(!_0x2f3cf7||!(_0x5c6787 in _0x1458c6))continue;_0x2d83d7[_0x5bffb2(0x155)](_0x5c6787,_0x2f3cf7);}if(!_0x2d83d7[_0x5bffb2(0x292)])continue;_0x22f3f8[_0x5bffb2(0x155)](_0x1d409c,_0x2d83d7),_0x46ae0d[_0x5bffb2(0x281)](_0x1d409c);}if(!_0x46ae0d[_0x5bffb2(0x1e8)])return 0x0;let _0x2064ec=_0x46ae0d[_0x5bffb2(0x186)](_0x1b397e=>'\x27'+C3(_0x1b397e)+'\x27')[_0x5bffb2(0x2b8)](','),_0x16859d=await _0x38e8cd[_0x5bffb2(0x2c5)](_0x5bffb2(0x259)+_0x2064ec+_0x5bffb2(0x1e1)),_0x3f9146=new Map();for(let _0x38c963 of _0x16859d||[]){if(!_0x38c963[_0x5bffb2(0x191)]||!_0x38c963[_0x5bffb2(0x2f0)])continue;_0x3f9146[_0x5bffb2(0x155)](_0x38c963[_0x5bffb2(0x191)]+'.'+_0x38c963[_0x5bffb2(0x2f0)],_0x38c963[_0x5bffb2(0x18c)]??null);}let _0x1773e6=0x0;for(let [_0x5a2662,_0x56b31f]of _0x22f3f8)for(let [_0x5a7309,_0x292708]of _0x56b31f){let _0x5348e5=_0x5a2662+'.'+_0x5a7309;if(_0x3f9146[_0x5bffb2(0x1f4)](_0x5348e5)===_0x292708)continue;await _0x38e8cd[_0x5bffb2(0x2c5)](_0x5bffb2(0x30a)+_3(_0x5a2662)+'.'+_3(_0x5a7309)+_0x5bffb2(0x1f9)+C3(_0x292708)+'\x27'),_0x1773e6++;}return _0x1773e6;}var v5={'admin':'/admin','app':'/app'};function k5(_0x2fc3fb){return w(v5[_0x2fc3fb]);}function f5(_0x144b7e){const _0x2642a3=_0xde6411;let _0x316c11=_0x144b7e[_0x2642a3(0x307)](/^\/+|\/+$/g,'')[_0x2642a3(0x1ee)]('/');return _0x316c11[_0x316c11[_0x2642a3(0x1e8)]-0x1]||_0x144b7e||_0x2642a3(0x1cc);}function w5(_0x1d640f){const _0x281c19=_0xde6411;return _0x1d640f[_0x281c19(0x1ee)]('_')['filter'](Boolean)[_0x281c19(0x186)](_0x1a5f3f=>_0x1a5f3f['charAt'](0x0)[_0x281c19(0x288)]()+_0x1a5f3f[_0x281c19(0x16e)](0x1))[_0x281c19(0x2b8)]('')+_0x281c19(0x2ee);}function d0(_0x205033){const _0x27a667=_0xde6411;if(!_0x205033?.['length'])return[];return _0x205033[_0x27a667(0x186)](_0xeca654=>{const _0x1d298c=_0x27a667;if(typeof _0xeca654!==_0x1d298c(0x299)){let _0x2108cf=_0xeca654[_0x1d298c(0x2ef)];return{..._0xeca654,'column':_0x2108cf['includes']('.')?_0x2108cf:'a.'+_0x2108cf};}return _0xeca654[_0x1d298c(0x261)]('.')?_0xeca654:'a.'+_0xeca654;});}function b5(_0x74280a){const _0xe307a5=_0xde6411;return{'keyWordLikeFields':d0(_0x74280a?.['keyWordLikeFields']),'fieldEq':d0(_0x74280a?.[_0xe307a5(0x289)]),'fieldLike':d0(_0x74280a?.['fieldLike']),'fieldArray':d0(_0x74280a?.[_0xe307a5(0x170)]),'fieldRange':(_0x74280a?.[_0xe307a5(0x2e0)]??[])['map'](_0x27a946=>({..._0x27a946,'column':_0x27a946[_0xe307a5(0x2ef)]['includes']('.')?_0x27a946['column']:'a.'+_0x27a946[_0xe307a5(0x2ef)]}))};}function y5(_0x16b2a6,_0x3af30a){const _0x194bc5=_0xde6411;for(let _0xfa97de of _0x3af30a){if(typeof _0xfa97de===_0x194bc5(0x299)||!_0xfa97de[_0x194bc5(0x2fd)])continue;let _0xee2a00=_0xfa97de[_0x194bc5(0x2ef)]['includes']('.')?_0xfa97de['column'][_0x194bc5(0x1ee)]('.')[_0x194bc5(0x2e5)]():_0xfa97de[_0x194bc5(0x2ef)],_0x2b9abd=_0x16b2a6[_0x194bc5(0x174)](_0x1f12e8=>_0x1f12e8['propertyName']===_0xee2a00);if(_0x2b9abd)_0x2b9abd['dict']=_0xfa97de[_0x194bc5(0x2fd)];}}function g5(_0x30bab1){const _0x5640d8=_0xde6411;if(!_0x30bab1||typeof _0x30bab1!==_0x5640d8(0x221))return[];try{let _0x2ccd0b=_0x86df80(_0x30bab1),_0x320c12=t(_0x30bab1),_0x30c540=[];for(let [_0x33f3ae,_0xd4eb3e]of Object['entries'](_0x2ccd0b)){if(_0x33f3ae==='tenantId')continue;let _0x8db0c6=_0xd4eb3e;_0x30c540[_0x5640d8(0x281)]({'propertyName':_0x33f3ae,'type':String(_0x8db0c6[_0x5640d8(0x161)]??_0x8db0c6[_0x5640d8(0x15e)]??_0x5640d8(0x299)),'length':_0x8db0c6[_0x5640d8(0x1e8)]!=null?String(_0x8db0c6[_0x5640d8(0x1e8)]):void 0x0,'nullable':_0x8db0c6['notNull']!==!0x0,'source':'a.'+_0x33f3ae,'comment':_0x320c12[_0x33f3ae]});}let _0x42b4a6=new Set(['createTime',_0x5640d8(0x274),_0x5640d8(0x293)]),_0x50180a=_0x30c540[_0x5640d8(0x24f)](_0x3538e4=>!_0x42b4a6[_0x5640d8(0x1c7)](_0x3538e4[_0x5640d8(0x16d)])),_0x103a1d=_0x30c540[_0x5640d8(0x24f)](_0x5ba639=>_0x42b4a6[_0x5640d8(0x1c7)](_0x5ba639[_0x5640d8(0x16d)]));return[..._0x50180a,..._0x103a1d];}catch{return[];}}function h5(_0x42b862){const _0x25359f=_0xde6411;if(!_0x42b862||typeof _0x42b862!==_0x25359f(0x221))return;try{return w5(_0x2313cd(_0x42b862));}catch{return;}}function u5(_0x16c301,_0x20ba94){const _0xf3aa81=_0xde6411;let _0x2d6b37=[],_0x19453c=new Set(),_0x3f6b2c=_0x4bb9ee=>{const _0x2db402=_0x5e13;let _0x404cf5=_0x4bb9ee[_0x2db402(0x2e2)]+':'+_0x4bb9ee[_0x2db402(0x305)];if(_0x19453c['has'](_0x404cf5))return;_0x19453c['add'](_0x404cf5),_0x2d6b37[_0x2db402(0x281)](_0x4bb9ee);};for(let _0x4a8113 of _0x16c301[_0xf3aa81(0x278)]){let _0x46e0ae=d(_0x4a8113[_0xf3aa81(0x305)],_0x16c301[_0xf3aa81(0x2f9)]),_0x5eec92=_0x46e0ae[_0xf3aa81(0x154)]('/')?_0x46e0ae:'/'+_0x46e0ae,_0x5579c1=VQ(_0x5eec92);_0x3f6b2c({'method':_0x4a8113[_0xf3aa81(0x2e2)][_0xf3aa81(0x14b)](),'path':_0x5eec92,'summary':_0x4a8113[_0xf3aa81(0x166)]??'','dts':{},'tag':'','prefix':_0x20ba94,'ignoreToken':Boolean(_0x4a8113[_0xf3aa81(0x1d9)]),'ignorePerms':Boolean(_0x4a8113[_0xf3aa81(0x145)]),'perms':r(_0x4a8113,_0x16c301,_0x5579c1)??[]});}for(let _0x11c2ee of _0x16c301['crud']?.[_0xf3aa81(0x283)]??[]){let _0x2d70af='/'+_0x11c2ee;_0x3f6b2c({'method':_0x11c2ee===_0xf3aa81(0x295)?_0xf3aa81(0x1f4):_0xf3aa81(0x1e6),'path':_0x2d70af,'summary':m0[_0x11c2ee]??_0x11c2ee,'dts':{},'tag':'','prefix':_0x20ba94,'ignoreToken':!0x1,'ignorePerms':!0x1,'perms':r({},_0x16c301,_0x11c2ee)??[]});}for(let _0x2796d1 of _0x16c301['crud']?.['serviceApis']??[]){let _0x521299='/'+_0x2796d1;_0x3f6b2c({'method':'post','path':_0x521299,'summary':_0x2796d1,'dts':{},'tag':'','prefix':_0x20ba94,'ignoreToken':!0x1,'ignorePerms':!0x1,'perms':r({},_0x16c301,_0x2796d1)??[]});}return _0x2d6b37;}function m5(_0x25de46){const _0x20bf6c=_0xde6411;let _0x2fc8dc=b(k5(_0x25de46[_0x20bf6c(0x1bb)]),_0x25de46['prefix']),_0x4ffec7=f5(_0x25de46[_0x20bf6c(0x2f9)]),_0x2e7d9a=_0x25de46[_0x20bf6c(0x1bc)]?.['entity'],_0x12ef24=g5(_0x2e7d9a),_0x2fffd8=b5(_0x25de46[_0x20bf6c(0x1bc)]?.['pageQueryOp']);return y5(_0x12ef24,_0x2fffd8[_0x20bf6c(0x289)]),{'module':_0x25de46[_0x20bf6c(0x204)],'side':_0x25de46[_0x20bf6c(0x1bb)],'prefix':_0x2fc8dc,'name':h5(_0x2e7d9a),'info':{'type':{'name':_0x4ffec7,'description':_0x25de46['description']??_0x4ffec7}},'api':u5(_0x25de46,_0x2fc8dc),'columns':_0x12ef24,'pageQueryOp':_0x2fffd8,'pageColumns':_0x12ef24};}function c5(_0x3b6f9d){const _0xe928b5=_0xde6411;let _0x1f074={};for(let _0xb81c9 of _0x3b6f9d){let _0x291e94=_0x1f074[_0xb81c9[_0xe928b5(0x204)]]??[];_0x291e94[_0xe928b5(0x281)](_0xb81c9),_0x1f074[_0xb81c9['module']]=_0x291e94;}return _0x1f074;}function N0(){const _0x20e856=_0xde6411;return Boolean(D[_0x20e856(0x14e)]?.[_0x20e856(0x2c1)]);}function R3(_0x1c72b9){const _0x26cf4b=_0xde6411;if(!N0())return{};return c5(O(_0x1c72b9)[_0x26cf4b(0x186)](m5));}var wQ={'controllers':O,'admin':()=>R3('admin'),'app':()=>R3(_0xde6411(0x209)),'enabled':N0};import'reflect-metadata';var n0=_0xde6411(0x1b8);function p5(_0x256bd8,_0x4cbaaa){return b(_0x256bd8,_0x4cbaaa==='/'?'':_0x4cbaaa);}function d5(_0x516be0){const _0x400731=_0xde6411;if(_0x516be0==null)return;return Array[_0x400731(0x1f3)](_0x516be0)?_0x516be0:[_0x516be0];}function n5(_0x565a3b,_0x2c3aaa){const _0x41174e=_0xde6411;let _0x3cf354=Reflect[_0x41174e(0x1e7)](n0,_0x565a3b)??[];_0x3cf354['push'](_0x2c3aaa),Reflect['defineMetadata'](n0,_0x3cf354,_0x565a3b);}function bQ(_0x1e1537){const _0x4cc393=_0xde6411;let _0x3f7a06=_0x1e1537==='params'?'Param':_0x1e1537===_0x4cc393(0x2b7)?_0x4cc393(0x236):_0x4cc393(0x27f);return _0x14d4b8=>(_0xfebd06,_0x2976c9,_0x21dc92)=>{const _0xe0b958=_0x4cc393;if(_0x2976c9===void 0x0)throw Error(_0xe0b958(0x163)+_0x3f7a06+_0xe0b958(0x156));let _0x4f71fd=_0xfebd06[_0xe0b958(0x157)];Y1(_0x4f71fd,String(_0x2976c9),{'index':_0x21dc92,'source':_0x1e1537,'schema':_0x14d4b8});};}function l5(_0x53f743){let {api:_0x2d61d8,entity:_0x47020a,service:_0x375f7a,serviceApis:_0x1fe42f,before:_0x459c05,pageQueryOp:_0x244ab5,listQueryOp:_0x4400a9,insertParam:_0x4f4555,infoIgnoreProperty:_0x10ed92}=_0x53f743;if(_0x2d61d8==null&&_0x47020a==null&&_0x375f7a==null&&_0x1fe42f==null&&_0x459c05==null&&_0x244ab5==null&&_0x4400a9==null&&_0x4f4555==null&&_0x10ed92==null)return;return{'api':_0x2d61d8,'entity':_0x47020a,'service':_0x375f7a,'serviceApis':_0x1fe42f,'before':_0x459c05,'pageQueryOp':_0x244ab5,'listQueryOp':_0x4400a9,'insertParam':_0x4f4555,'infoIgnoreProperty':_0x10ed92};}function yQ(_0x5c9ac2=''){const _0x1d8e65=_0xde6411;let _0x52a5f7=typeof _0x5c9ac2===_0x1d8e65(0x299),_0x4e108e=_0x52a5f7?{'prefix':_0x5c9ac2}:_0x5c9ac2;return _0x552597=>{const _0x25e82a=_0x1d8e65;f({'token':_0x552597,'useClass':_0x552597,'scope':'singleton'});let _0x4cbb33=b1(),_0x3ecc38=_0x52a5f7&&_0x5c9ac2===''||!_0x52a5f7&&(_0x4e108e[_0x25e82a(0x2f9)]==null||_0x4e108e[_0x25e82a(0x2f9)]===''),_0x28795e=w(_0x3ecc38&&_0x4cbb33?.[_0x25e82a(0x1de)]?g1(_0x4cbb33[_0x25e82a(0x1de)]):_0x4e108e[_0x25e82a(0x2f9)]??''),_0x3bae80=Reflect[_0x25e82a(0x1e7)](n0,_0x552597)??[],_0x42058a=l5(_0x4e108e);L1({'token':_0x552597,'prefix':_0x28795e,'module':_0x4e108e[_0x25e82a(0x204)]??_0x4cbb33?.[_0x25e82a(0x204)]??'unknown','side':_0x4e108e[_0x25e82a(0x1bb)]??_0x4cbb33?.[_0x25e82a(0x1bb)]??_0x25e82a(0x21b),'description':_0x4e108e[_0x25e82a(0x2fb)],'file':_0x4cbb33?.[_0x25e82a(0x1de)],'middleware':d5(_0x4e108e[_0x25e82a(0x1a4)]),'crud':_0x42058a,'routes':_0x3bae80[_0x25e82a(0x186)](_0x56c609=>{const _0x302edb=_0x25e82a;let _0x1faf16=U1(_0x552597,_0x56c609['handler']),_0x2dfc3c=x0(_0x1faf16),_0xef2ff9=[..._0x56c609[_0x302edb(0x1a4)]??[],..._1(_0x552597,_0x56c609[_0x302edb(0x23b)])];return{..._0x56c609,'path':p5(_0x28795e,_0x56c609[_0x302edb(0x305)]['startsWith']('/')?_0x56c609[_0x302edb(0x305)][_0x302edb(0x16e)](0x1):_0x56c609[_0x302edb(0x305)]),'params':_0x1faf16,'body':_0x2dfc3c?.[_0x302edb(0x2b7)],'query':_0x2dfc3c?.[_0x302edb(0x26a)],'routeParams':_0x2dfc3c?.[_0x302edb(0x203)],'public':N1(_0x552597,_0x56c609[_0x302edb(0x23b)]),'ignorePerms':E1(_0x552597,_0x56c609[_0x302edb(0x23b)]),'perms':R1(_0x552597,_0x56c609[_0x302edb(0x23b)]),'middleware':_0xef2ff9[_0x302edb(0x1e8)]?_0xef2ff9:void 0x0};})}),Reflect[_0x25e82a(0x1b7)](n0,_0x552597),D1(_0x552597),A1(_0x552597),C1(_0x552597),q1(_0x552597),P1(_0x552597);};}function gQ(..._0x4d5163){return(_0x592801,_0x1dd786)=>{const _0x47538d=_0x5e13;let _0x4a68a5=_0x592801[_0x47538d(0x157)];K1(_0x4a68a5,String(_0x1dd786),_0x4d5163);};}function A0(_0x36452c){return(_0x5ca39b='',_0x491a71)=>(_0x1d516a,_0x40c735)=>{const _0x2b1501=_0x5e13;let _0x1c2626=_0x1d516a['constructor'];n5(_0x1c2626,{'method':_0x36452c,'path':_0x5ca39b,'handler':String(_0x40c735),'summary':_0x491a71?.[_0x2b1501(0x166)]});};}function hQ(){return(_0xdd494b,_0x26ca18)=>{const _0x404be2=_0x5e13;let _0x305749=_0xdd494b[_0x404be2(0x157)];T1(_0x305749,String(_0x26ca18));};}function uQ(..._0x428521){return(_0xcd7cde,_0x1f68aa)=>{const _0x26da12=_0x5e13;let _0x74fd32=_0xcd7cde[_0x26da12(0x157)];I1(_0x74fd32,String(_0x1f68aa),_0x428521);};}function mQ(){return(_0xe80421,_0x21e8fb)=>{let _0xf3903=_0xe80421['constructor'];S1(_0xf3903,String(_0x21e8fb));};}var cQ=bQ(_0xde6411(0x2b7)),pQ=bQ(_0xde6411(0x26a)),dQ=bQ(_0xde6411(0x203)),nQ=A0(_0xde6411(0x287)),lQ=A0(_0xde6411(0x15a)),iQ=A0(_0xde6411(0x218)),sQ=A0('DELETE'),oQ=A0('PATCH');class k{[_0xde6411(0x180)];[_0xde6411(0x228)];['cache'];[_0xde6411(0x2cd)];async['init'](_0xb7bc50,_0x4e28e4,_0x646def,_0x4c0a02){const _0x7aca88=_0xde6411;this[_0x7aca88(0x180)]=_0xb7bc50,this['ctx']=_0x4e28e4,this[_0x7aca88(0x160)]=_0x4c0a02?.[_0x7aca88(0x160)],this['pluginService']=_0x4c0a02?.[_0x7aca88(0x2cd)],await this[_0x7aca88(0x2db)]();}async[_0xde6411(0x2db)](){}}import{existsSync as _0x6e7a8d,readFileSync as _0x2f3232}from'fs';import{createRequire as _0x2b53e2}from'module';import{join as _0x1285e9}from'path';import{createHash as _0xfdeda2}from'crypto';import{homedir as _0xb949f4}from'os';import{join as _0x3d9a60}from'path';function K0(){const _0x5556ee=_0xde6411;let _0x1561fa=_0xfdeda2(_0x5556ee(0x22c))[_0x5556ee(0x21c)](String(D['keys']??_0x5556ee(0x14e)))[_0x5556ee(0x19c)](_0x5556ee(0x262));return _0x3d9a60(_0xb949f4(),_0x5556ee(0x2e3),_0x1561fa);}function _0(){const _0x43a007=_0xde6411;return _0x3d9a60(K0(),_0x43a007(0x28e));}function e(){const _0x34592c=_0xde6411;return _0x3d9a60(K0(),_0x34592c(0x2a1));}function g(_0x3477ca){return _0x3d9a60(e(),_0x3477ca);}var r5=_0x2b53e2(import.meta.url);function a5(_0x197fe7){if(_0x197fe7==='vome-plugin-runtime')return{'BasePlugin':k};return r5(_0x197fe7);}function rQ(_0x24456c){const _0x37ed24=_0xde6411;try{let _0x261edb=_0x24456c[_0x37ed24(0x307)](/export\s+const\s+Plugin\s*=/g,_0x37ed24(0x198))[_0x37ed24(0x307)](/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g,'')[_0x37ed24(0x307)](/export\s+const\s+handlers\s*=/g,_0x37ed24(0x1e9))[_0x37ed24(0x307)](/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g,'')[_0x37ed24(0x307)](/export\s+class\s+(\w+)/g,_0x37ed24(0x1aa))[_0x37ed24(0x307)](/export\s+default\s+/g,'')['replace'](/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g,'')[_0x37ed24(0x307)](/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g,'')[_0x37ed24(0x307)](/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g,_0x37ed24(0x2bb)),_0x18af13=Function(_0x37ed24(0x149),_0x37ed24(0x1fd),_0x37ed24(0x204),_0x37ed24(0x15b),_0x261edb+_0x37ed24(0x1db)),_0x2c556e={'exports':{}};return _0x18af13(k,a5,_0x2c556e,_0x2c556e[_0x37ed24(0x15b)]);}catch(_0xf1be0){throw Error(_0x37ed24(0x187)+(_0xf1be0 instanceof Error?_0xf1be0['message']:String(_0xf1be0)));}}function aQ(_0x23c1df){const _0x19e159=_0xde6411;let _0x28aab4=_0x1285e9(g(_0x23c1df),_0x19e159(0x2b9),'index.js');if(_0x6e7a8d(_0x28aab4))return _0x2f3232(_0x28aab4,'utf8');let _0x389a8e=_0x1285e9(_0(),_0x23c1df);if(!_0x6e7a8d(_0x389a8e))return;try{return JSON[_0x19e159(0x189)](_0x2f3232(_0x389a8e,_0x19e159(0x177)))[_0x19e159(0x23e)]?.[_0x19e159(0x150)];}catch{return;}}import{existsSync as _0x127a5a,readFileSync as _0x3e77af,readdirSync as _0x4ef11c,statSync as _0x4486e0}from'fs';import{createRequire as _0x3cacdd}from'module';import{join as _0x310a73}from'path';var Q0=new Map(),$2=_0x3cacdd(import.meta.url);function Z2(_0x1dfbcf){if(_0x1dfbcf==='vome-plugin-runtime')return{'BasePlugin':k};return $2(_0x1dfbcf);}function O3(_0x16610a){return(_0x16610a['startsWith']('/')?_0x16610a:'/'+_0x16610a)['replace'](/\/+$/,'')||'/';}function x3(_0x25615d){return _0x25615d['toUpperCase']();}function J2(_0x151f19){const _0x2cdd3c=_0xde6411;return _0x151f19[_0x2cdd3c(0x307)](/export\s+const\s+handlers\s*=/g,_0x2cdd3c(0x1e9))[_0x2cdd3c(0x307)](/export\s+\{[^}]*\bhandlers\b[^}]*\};?/g,'')['replace'](/export\s+default\s+\{/g,'var\x20handlers\x20=\x20{')[_0x2cdd3c(0x307)](/export\s+const\s+Plugin\s*=/g,_0x2cdd3c(0x198))['replace'](/export\s+\{[^}]*\bPlugin\b[^}]*\};?/g,'')[_0x2cdd3c(0x307)](/export\s+class\s+(\w+)/g,'class\x20$1')['replace'](/import\s+\{?\s*BasePlugin\s*\}?\s*from\s*['"][^'"]+['"];?/g,'')[_0x2cdd3c(0x307)](/import\s+BasePlugin\s+from\s*['"][^'"]+['"];?/g,'')['replace'](/require\(\s*['"]vome-plugin-runtime['"]\s*\)/g,'({\x20BasePlugin\x20})');}function o0(_0x8787c8,_0x3a65c6=!0x0){const _0x29a7f1=_0xde6411;let _0x591f2a=J2(_0x8787c8),_0x58c559=Function(_0x29a7f1(0x149),_0x29a7f1(0x1fd),_0x29a7f1(0x204),_0x29a7f1(0x15b),_0x591f2a+_0x29a7f1(0x28b)),_0x3aceda={'exports':{}},_0xf3256c=_0x58c559(k,Z2,_0x3aceda,_0x3aceda[_0x29a7f1(0x15b)]);if(!_0xf3256c||typeof _0xf3256c!==_0x29a7f1(0x221)){if(_0x3a65c6)throw Error(_0x29a7f1(0x27d));return{};}return _0xf3256c;}var $0={'get'(_0x5c37a2){const _0x4cedcb=_0xde6411;return Q0[_0x4cedcb(0x1f4)](_0x5c37a2);},'list'(){const _0x2d23cc=_0xde6411;return[...Q0[_0x2d23cc(0x28f)]()][_0x2d23cc(0x186)](([_0x473b80,_0x52c706])=>({'key':_0x473b80,'manifest':_0x52c706[_0x2d23cc(0x2f1)],'routes':_0x52c706[_0x2d23cc(0x278)]}));},'load'(_0xa812ae){const _0x57905e=_0xde6411;if(!_0xa812ae||!/^[a-zA-Z0-9_-]+$/[_0x57905e(0x1df)](_0xa812ae))throw Error('非法模块\x20key:\x20'+_0xa812ae);let _0x5b937a=g(_0xa812ae),_0x354232=_0x310a73(_0x5b937a,_0x57905e(0x269));if(!_0x127a5a(_0x354232))throw Error(_0x57905e(0x2eb)+_0xa812ae);let _0x448de4=JSON[_0x57905e(0x189)](_0x3e77af(_0x354232,_0x57905e(0x177))),_0x1f77df=(_0x448de4[_0x57905e(0x278)]??[])['map'](_0x1ddaaf=>({..._0x1ddaaf,'method':x3(_0x1ddaaf['method']),'path':O3(_0x1ddaaf[_0x57905e(0x305)])})),_0x28bf51={},_0x5533d5=_0x310a73(_0x5b937a,_0x57905e(0x2b9),'index.js');if(_0x127a5a(_0x5533d5)){let _0x29aa8a=_0x3e77af(_0x5533d5,'utf8');_0x28bf51=o0(_0x29aa8a,_0x1f77df[_0x57905e(0x1e8)]>0x0);for(let _0x1f28c5 of _0x1f77df)if(typeof _0x28bf51[_0x1f28c5['handler']]!=='function')throw Error(_0x57905e(0x2de)+_0xa812ae+'\x20缺少\x20handler:\x20'+_0x1f28c5[_0x57905e(0x23b)]);}else{if(_0x1f77df[_0x57905e(0x1e8)])throw Error(_0x57905e(0x2de)+_0xa812ae+_0x57905e(0x1c1));}return Q0['set'](_0xa812ae,{'manifest':_0x448de4,'handlers':_0x28bf51,'routes':_0x1f77df}),Q0['get'](_0xa812ae);},'unload'(_0x153fcd){Q0['delete'](_0x153fcd);},async 'dispatch'(_0x4362d4,_0x478eaf,_0xdb24ef,_0x5f1af1){const _0x563104=_0xde6411;let _0x11abac=Q0[_0x563104(0x1f4)](_0x4362d4);if(!_0x11abac)return{'ok':!0x1,'status':0x194,'message':_0x563104(0x255)};let _0x309489=x3(_0x478eaf),_0x5745c9=O3(_0xdb24ef),_0x547880=_0x11abac[_0x563104(0x278)][_0x563104(0x174)](_0x1d3eb9=>_0x1d3eb9[_0x563104(0x2e2)]===_0x309489&&_0x1d3eb9[_0x563104(0x305)]===_0x5745c9);if(!_0x547880)return{'ok':!0x1,'status':0x194,'message':_0x563104(0x2a3)};let _0x36e636=_0x11abac[_0x563104(0x246)][_0x547880['handler']];if(typeof _0x36e636!==_0x563104(0x14d))return{'ok':!0x1,'status':0x1f4,'message':_0x563104(0x13e)+_0x547880['handler']};try{return{'ok':!0x0,'data':await _0x36e636(_0x5f1af1),'route':_0x547880};}catch(_0x1247db){return{'ok':!0x1,'status':0x1f4,'message':_0x1247db instanceof Error?_0x1247db[_0x563104(0x1c8)]:String(_0x1247db),'route':_0x547880};}},'bootstrap'(){const _0x3a93c3=_0xde6411;let _0x255d97=e();if(!_0x127a5a(_0x255d97))return;for(let _0x3e20ed of _0x4ef11c(_0x255d97)){let _0x4e50f9=_0x310a73(_0x255d97,_0x3e20ed);if(!_0x4486e0(_0x4e50f9)[_0x3a93c3(0x286)]())continue;if(!_0x127a5a(_0x310a73(_0x4e50f9,_0x3a93c3(0x269))))continue;try{this['load'](_0x3e20ed),console[_0x3a93c3(0x211)](_0x3a93c3(0x184)+_0x3e20ed);}catch(_0x34553e){console[_0x3a93c3(0x2b1)](_0x3a93c3(0x20a)+_0x3e20ed+':',_0x34553e instanceof Error?_0x34553e['message']:_0x34553e);}}}};import{existsSync as _0x9d6839,statSync as _0x21417c}from'fs';function _0x5e13(_0x4ed538,_0x3ec8bc){_0x4ed538=_0x4ed538-0x13a;const _0x190375=_0x1903();let _0x5e131a=_0x190375[_0x4ed538];if(_0x5e13['evIlMW']===undefined){var _0x41cb2e=function(_0x334a32){const _0x6f907d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1af216='',_0x5a5ceb='';for(let _0x5737b5=0x0,_0x2260fa,_0xcb406d,_0x4dd14d=0x0;_0xcb406d=_0x334a32['charAt'](_0x4dd14d++);~_0xcb406d&&(_0x2260fa=_0x5737b5%0x4?_0x2260fa*0x40+_0xcb406d:_0xcb406d,_0x5737b5++%0x4)?_0x1af216+=String['fromCharCode'](0xff&_0x2260fa>>(-0x2*_0x5737b5&0x6)):0x0){_0xcb406d=_0x6f907d['indexOf'](_0xcb406d);}for(let _0x41efe7=0x0,_0x413919=_0x1af216['length'];_0x41efe7<_0x413919;_0x41efe7++){_0x5a5ceb+='%'+('00'+_0x1af216['charCodeAt'](_0x41efe7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5a5ceb);};_0x5e13['elpZmY']=_0x41cb2e,_0x5e13['UYQslw']={},_0x5e13['evIlMW']=!![];}const _0xfdbaed=_0x190375[0x0],_0x472031=_0x4ed538+_0xfdbaed,_0x32b444=_0x5e13['UYQslw'][_0x472031];return!_0x32b444?(_0x5e131a=_0x5e13['elpZmY'](_0x5e131a),_0x5e13['UYQslw'][_0x472031]=_0x5e131a):_0x5e131a=_0x32b444,_0x5e131a;}import{join as _0x3be2ef,normalize as _0x52ca04,sep as _0x27effc}from'path';import{Elysia as _0x332f0f}from'elysia';var z2='/vome/apps';function G2(_0x545895){const _0x4d8510=_0xde6411;let _0xc0795d=_0x545895[_0x4d8510(0x14b)]();if(_0xc0795d['endsWith'](_0x4d8510(0x302)))return _0x4d8510(0x272);if(_0xc0795d[_0x4d8510(0x219)](_0x4d8510(0x2a4))||_0xc0795d[_0x4d8510(0x219)](_0x4d8510(0x2b5)))return _0x4d8510(0x2c2);if(_0xc0795d[_0x4d8510(0x219)](_0x4d8510(0x172)))return'text/css;\x20charset=utf-8';if(_0xc0795d['endsWith'](_0x4d8510(0x2a8)))return _0x4d8510(0x16c);if(_0xc0795d[_0x4d8510(0x219)]('.svg'))return _0x4d8510(0x26f);if(_0xc0795d['endsWith'](_0x4d8510(0x15c)))return _0x4d8510(0x21a);if(_0xc0795d[_0x4d8510(0x219)](_0x4d8510(0x230))||_0xc0795d[_0x4d8510(0x219)](_0x4d8510(0x245)))return'image/jpeg';if(_0xc0795d[_0x4d8510(0x219)]('.woff2'))return _0x4d8510(0x22b);if(_0xc0795d[_0x4d8510(0x219)]('.woff'))return'font/woff';if(_0xc0795d['endsWith'](_0x4d8510(0x2bd)))return _0x4d8510(0x1f7);return _0x4d8510(0x13f);}var $1=new _0x332f0f({'name':_0xde6411(0x147)})[_0xde6411(0x1f4)](z2+'/*',({params:_0x2609b9,set:_0x1b16bf})=>{const _0x37beec=_0xde6411;let _0x3e4cf0=String(_0x2609b9['*']||'')[_0x37beec(0x1ee)]('/')[_0x37beec(0x24f)](Boolean);if(!_0x3e4cf0[_0x37beec(0x1e8)])return _0x1b16bf[_0x37beec(0x2c3)]=0x194,_0x37beec(0x1a5);let _0x143545=_0x3e4cf0[0x0];if(!/^[a-zA-Z0-9_-]+$/[_0x37beec(0x1df)](_0x143545))return _0x1b16bf[_0x37beec(0x2c3)]=0x190,_0x37beec(0x13d);let _0x1ca7ed=_0x3be2ef(g(_0x143545),_0x37beec(0x1d8));if(!_0x9d6839(_0x1ca7ed)||!_0x21417c(_0x1ca7ed)[_0x37beec(0x286)]())return _0x1b16bf[_0x37beec(0x2c3)]=0x194,_0x37beec(0x2af);let _0x9c6a3e=_0x3e4cf0[_0x37beec(0x16e)](0x1)[_0x37beec(0x2b8)]('/')||'index.html';if(_0x9c6a3e[_0x37beec(0x219)]('/'))_0x9c6a3e+=_0x37beec(0x1a2);let _0x1128c7=_0x52ca04(_0x3be2ef(_0x1ca7ed,_0x9c6a3e));if(!_0x1128c7['startsWith'](_0x1ca7ed+_0x27effc)&&_0x1128c7!==_0x1ca7ed)return _0x1b16bf[_0x37beec(0x2c3)]=0x193,_0x37beec(0x2c9);let _0x117023=_0x1128c7;if(_0x9d6839(_0x117023)&&_0x21417c(_0x117023)['isDirectory']())_0x117023=_0x3be2ef(_0x117023,_0x37beec(0x1a2));if(!_0x9d6839(_0x117023)||!_0x21417c(_0x117023)[_0x37beec(0x1fe)]())return _0x1b16bf[_0x37beec(0x2c3)]=0x194,_0x37beec(0x1a5);return _0x1b16bf[_0x37beec(0x1b6)]['content-type']=G2(_0x117023),_0x1b16bf[_0x37beec(0x1b6)][_0x37beec(0x1c2)]=_0x37beec(0x24a),_0x1b16bf[_0x37beec(0x1b6)][_0x37beec(0x1bf)]='*',Bun[_0x37beec(0x1de)](_0x117023);});import{Elysia as _0x493693}from'elysia';function j2(_0x3a4021){const _0x226819=_0xde6411;return{'code':C['SUCCESS'],'message':_0x226819(0x1d1),'data':_0x3a4021??null};}function r0(_0xe83602,_0x1535a4=C['ERROR']){return{'code':_0x1535a4,'message':_0xe83602};}async function v3(_0x3509e7){const _0x4f4a2e=_0xde6411;let _0x2cfced=_0x3509e7[_0x4f4a2e(0x203)]['key'];if(!_0x2cfced||!/^[a-zA-Z0-9_-]+$/[_0x4f4a2e(0x1df)](_0x2cfced))return _0x3509e7[_0x4f4a2e(0x155)][_0x4f4a2e(0x2c3)]=0x190,r0(_0x4f4a2e(0x1e3));let _0xc6811b=('/'+String(_0x3509e7['params']['*']||''))[_0x4f4a2e(0x307)](/\/+/g,'/'),_0x25a86d=_[_0x4f4a2e(0x1f4)](),_0x1687c2=$0[_0x4f4a2e(0x1f4)](_0x2cfced);if(!_0x1687c2)return _0x3509e7[_0x4f4a2e(0x155)]['status']=0x194,r0(_0x4f4a2e(0x2e6));let _0x576712=_0x3509e7[_0x4f4a2e(0x284)][_0x4f4a2e(0x2e2)][_0x4f4a2e(0x288)](),_0x206d23=_0xc6811b[_0x4f4a2e(0x307)](/\/+$/,'')||'/',_0x17f40e=_0x1687c2['routes'][_0x4f4a2e(0x174)](_0x219081=>_0x219081[_0x4f4a2e(0x2e2)]===_0x576712&&_0x219081[_0x4f4a2e(0x305)]===_0x206d23);if(!_0x17f40e)return _0x3509e7[_0x4f4a2e(0x155)][_0x4f4a2e(0x2c3)]=0x194,r0(_0x4f4a2e(0x2a3));if(_0x17f40e[_0x4f4a2e(0x2dc)]&&!_0x25a86d?.[_0x4f4a2e(0x178)]){if(!(_0x25a86d?.[_0x4f4a2e(0x2dc)]??[])[_0x4f4a2e(0x261)](_0x17f40e[_0x4f4a2e(0x2dc)]))return _0x3509e7[_0x4f4a2e(0x2c3)](0x193);}let _0x46a660=await $0[_0x4f4a2e(0x1d3)](_0x2cfced,_0x576712,_0xc6811b,{'body':_0x3509e7[_0x4f4a2e(0x2b7)],'query':_0x3509e7[_0x4f4a2e(0x26a)]??{},'params':_0x3509e7['params'],'headers':_0x3509e7[_0x4f4a2e(0x284)][_0x4f4a2e(0x1b6)],'adminId':_0x25a86d?.[_0x4f4a2e(0x27b)]});if(!_0x46a660['ok'])return _0x3509e7['set'][_0x4f4a2e(0x2c3)]=_0x46a660[_0x4f4a2e(0x2c3)],r0(_0x46a660[_0x4f4a2e(0x1c8)]);return j2(_0x46a660[_0x4f4a2e(0x150)]);}function Z1(_0x25cd3a){const _0xb0bf77=_0xde6411;return new _0x493693({'name':_0xb0bf77(0x18a)})[_0xb0bf77(0x265)](_0x25cd3a[_0xb0bf77(0x2f8)])[_0xb0bf77(0x2ad)](_0xb0bf77(0x26b),v3,{'adminAuth':!0x0})[_0xb0bf77(0x2ad)](_0xb0bf77(0x179),v3,{'adminAuth':!0x0});}import{Elysia as _0x42db37}from'elysia';function J1(_0x3b96a1,_0x42c9fb){const _0x39e3d2=_0xde6411;return new _0x42db37({'name':_0x3b96a1+'-macro'})[_0x39e3d2(0x1c3)]({[_0x3b96a1]:{'resolve':_0x42c9fb}})['as']('scoped');}var k3={'name':_0xde6411(0x2b3),'version':_0xde6411(0x158),'description':_0xde6411(0x2b0),'license':_0xde6411(0x241),'type':_0xde6411(0x204),'files':[_0xde6411(0x28c),_0xde6411(0x1ac),_0xde6411(0x2c8),_0xde6411(0x143)],'main':_0xde6411(0x267),'types':_0xde6411(0x21f),'exports':{'.':{'types':_0xde6411(0x21f),'import':_0xde6411(0x267),'default':_0xde6411(0x267)},'./server':{'types':'./dist/server/index.d.ts','import':_0xde6411(0x13b),'default':'./dist/server/index.js'},'./admin':{'types':_0xde6411(0x24b),'import':_0xde6411(0x24b),'default':'./src/admin/index.ts'},'./admin/*':_0xde6411(0x23a),'./admin/styles/base.css':_0xde6411(0x159),'./typings/*':_0xde6411(0x238)},'scripts':{'build':'rm\x20-rf\x20dist\x20&&\x20bun\x20build\x20./src/index.ts\x20./src/server/index.ts\x20--outdir\x20./dist\x20--target\x20bun\x20--format\x20esm\x20--external\x20elysia\x20--external\x20reflect-metadata\x20--external\x20drizzle-orm\x20--external\x20drizzle-zod\x20--external\x20@elysiajs/openapi\x20--external\x20@bogeychan/elysia-logger\x20--external\x20pino\x20--external\x20pino-pretty\x20&&\x20tsc\x20-p\x20tsconfig.build.json\x20&&\x20printf\x20\x22%s\x5cn\x22\x20\x22export\x20*\x20from\x20\x27../src/index\x27\x22\x20>\x20dist/index.d.ts\x20&&\x20mkdir\x20-p\x20dist/server\x20&&\x20printf\x20\x22%s\x5cn\x22\x20\x22export\x20*\x20from\x20\x27../../src/server/index\x27\x22\x20>\x20dist/server/index.d.ts','build:obfuscate':_0xde6411(0x1d4),'prepare':_0xde6411(0x15f)},'peerDependencies':{'elysia':'>=1.0.0','reflect-metadata':_0xde6411(0x193),'drizzle-orm':_0xde6411(0x256),'drizzle-zod':_0xde6411(0x1f1),'vue':_0xde6411(0x252),'vue-router':_0xde6411(0x280),'pinia':_0xde6411(0x220),'vue-sonner':'>=2.0.0','@vueuse/core':'>=10.0.0','clsx':_0xde6411(0x220),'tailwind-merge':'>=2.0.0'},'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':_0xde6411(0x2ec),'drizzle-orm':_0xde6411(0x2ec),'drizzle-zod':'^0.8.3','elysia':_0xde6411(0x2ec),'javascript-obfuscator':_0xde6411(0x1c6),'reflect-metadata':_0xde6411(0x301),'typescript':'latest'},'dependencies':{'@bogeychan/elysia-logger':_0xde6411(0x1ec),'@elysiajs/openapi':'^1.4.15','pino':'^10.3.1','pino-pretty':_0xde6411(0x13c)}},n9=k3['version'];export{K3 as vome,n9 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
+ };