@opengis/fcore 0.0.1-beta.19 → 0.0.1-beta.20

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 (92) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.d.ts.map +1 -1
  5. package/dist/fastify.js +1 -1
  6. package/dist/fcore.js +1 -1
  7. package/dist/migrations/cli.js +1 -1
  8. package/dist/migrations/runner.js +1 -1
  9. package/dist/modules/auth/adduser-cli.js +1 -1
  10. package/dist/modules/auth/passwd-cli.js +1 -1
  11. package/dist/modules/auth/permission-cli.js +1 -1
  12. package/dist/modules/auth/route.js +1 -1
  13. package/dist/modules/auth/schema.js +1 -1
  14. package/dist/modules/auth/services/change-password.js +1 -1
  15. package/dist/modules/auth/services/get-current-user.js +1 -1
  16. package/dist/modules/auth/services/registration.js +1 -1
  17. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  18. package/dist/modules/file/mime.js +1 -1
  19. package/dist/modules/file/route.js +1 -1
  20. package/dist/modules/file/schema.js +1 -1
  21. package/dist/modules/file/services/get-file.js +1 -1
  22. package/dist/modules/file/services/resize-file.js +1 -1
  23. package/dist/modules/file/services/upload-file.js +1 -1
  24. package/dist/modules/resource/route.d.ts.map +1 -1
  25. package/dist/modules/resource/route.js +1 -1
  26. package/dist/modules/resource/schema.js +1 -1
  27. package/dist/modules/resource/services/add-note.js +1 -1
  28. package/dist/modules/resource/services/add-resource-file.js +1 -1
  29. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/create-resource.js +1 -1
  31. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  32. package/dist/modules/resource/services/delete-resource.js +1 -1
  33. package/dist/modules/resource/services/export-resource.js +1 -1
  34. package/dist/modules/resource/services/get-resource.js +1 -1
  35. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  36. package/dist/modules/resource/services/list-resources.js +1 -1
  37. package/dist/modules/resource/services/search-resource.js +1 -1
  38. package/dist/modules/resource/services/suggest-resource.js +1 -1
  39. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/update-resource.js +1 -1
  41. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  42. package/dist/modules/system/route.js +1 -1
  43. package/dist/modules/system/schema.js +1 -1
  44. package/dist/modules/system/services/check-system.js +1 -1
  45. package/dist/modules/system/services/get-access.js +1 -1
  46. package/dist/modules/system/services/get-api-list.js +1 -1
  47. package/dist/modules/system/services/get-audit-log.js +1 -1
  48. package/dist/modules/system/services/get-dictionary.js +1 -1
  49. package/dist/modules/system/services/get-system-log.js +1 -1
  50. package/dist/modules/system/services/get-system-settings.js +1 -1
  51. package/dist/modules/system/services/list-dictionaries.js +1 -1
  52. package/dist/modules/system/services/set-access.js +1 -1
  53. package/dist/modules/system/services/update-dictionary.js +1 -1
  54. package/dist/modules/system/services/update-system-settings.js +1 -1
  55. package/dist/modules/utils/require-admin.js +1 -1
  56. package/dist/modules/utils/safe-user.js +1 -1
  57. package/dist/modules/utils/unsupported.js +1 -1
  58. package/dist/plugins/audit/audit.js +1 -1
  59. package/dist/plugins/audit/services/write-audit.js +1 -1
  60. package/dist/plugins/auth/get-user-permissions.js +1 -1
  61. package/dist/plugins/auth/index.js +1 -1
  62. package/dist/plugins/auth/verifyUser.js +1 -1
  63. package/dist/plugins/dictionary.js +1 -1
  64. package/dist/plugins/file.js +1 -1
  65. package/dist/plugins/jwt.js +1 -1
  66. package/dist/plugins/logger/index.js +1 -1
  67. package/dist/plugins/logger/transport.js +1 -1
  68. package/dist/plugins/pg.js +1 -1
  69. package/dist/plugins/redis.js +1 -1
  70. package/dist/plugins/resource/resource.js +1 -1
  71. package/dist/plugins/resource/resource.registry.js +1 -1
  72. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  73. package/dist/plugins/resource/services/add-file-token.js +1 -1
  74. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  75. package/dist/plugins/resource/services/create-relation.js +1 -1
  76. package/dist/plugins/resource/services/create.js +1 -1
  77. package/dist/plugins/resource/services/delete-relation.js +1 -1
  78. package/dist/plugins/resource/services/delete.js +1 -1
  79. package/dist/plugins/resource/services/find-one.js +1 -1
  80. package/dist/plugins/resource/services/find-relation.js +1 -1
  81. package/dist/plugins/resource/services/find.js +1 -1
  82. package/dist/plugins/resource/services/update-relation.js +1 -1
  83. package/dist/plugins/resource/services/update.js +1 -1
  84. package/dist/plugins/resource/utils/auto-index.js +1 -1
  85. package/dist/plugins/resource/utils/fields.js +1 -1
  86. package/dist/plugins/resource/utils/filters.js +1 -1
  87. package/dist/plugins/resource/utils/permissions.js +1 -1
  88. package/dist/plugins/resource/utils/sort.js +1 -1
  89. package/dist/plugins/resource/utils/sql.js +1 -1
  90. package/dist/shared/getIP.js +1 -1
  91. package/migrations/20260905120000_add_user_foreign_keys.sql +42 -42
  92. package/package.json +93 -93
@@ -1 +1 @@
1
- function O(L,E){L=L-0x103;const c=Z();let t=c[L];return t;}import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function Z(){const r=['resource','get','admin','user','type','Admin\x20access\x20required','put','Uploaded\x20file\x20not\x20found'];Z=function(){return r;};return Z();}export async function uploadResourceFile(L,E){const g=O,c=E[g(0x103)][g(0x104)](L['resource']);if(c['access']===g(0x105)&&L[g(0x106)]?.[g(0x107)]!=='admin')throw new ForbiddenError(g(0x108));if(L['user']?.[g(0x107)]!=='admin'&&!L[g(0x106)]?.['permissions']?.['includes']((c['permission']??c['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(c['permission']??c['name'])+':update');if(!Buffer['isBuffer'](L['file'])||L['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const t=L['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!t)throw new ValidationError('File\x20name\x20is\x20required');const e='files/'+L['resource']+'/'+String(L['id'])+'/'+t;await E['file'][g(0x109)](e,L['file']);if(!await E['file']['exists'](e))throw new NotFoundError(g(0x10a));const B=await E['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[L['resource'],String(L['id']),e,L['file']['length']]);return B['rows'][0x0];}
1
+ import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function u(I,X){I=I-0x1b5;const o=f();let b=o[I];return b;}export async function uploadResourceFile(I,X){const p=u,o=X['resource']['get'](I[p(0x1b5)]);if(o[p(0x1b6)]===p(0x1b7)&&I[p(0x1b8)]?.[p(0x1b9)]!==p(0x1b7))throw new ForbiddenError(p(0x1ba));if(I['user']?.[p(0x1b9)]!=='admin'&&!I['user']?.[p(0x1bb)]?.[p(0x1bc)]((o['permission']??o[p(0x1bd)])+':update'))throw new ForbiddenError(p(0x1be)+(o['permission']??o['name'])+':update');if(!Buffer[p(0x1bf)](I[p(0x1c0)])||I[p(0x1c0)][p(0x1c1)]===0x0)throw new ValidationError('File\x20is\x20required');const b=I['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!b)throw new ValidationError('File\x20name\x20is\x20required');const A='files/'+I['resource']+'/'+String(I['id'])+'/'+b;await X[p(0x1c0)]['put'](A,I['file']);if(!await X['file']['exists'](A))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const t=await X['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[I['resource'],String(I['id']),A,I['file']['length']]);return t['rows'][0x0];}function f(){const V=['resource','access','admin','user','type','Admin\x20access\x20required','permissions','includes','name','Missing\x20permission:\x20','isBuffer','file','length'];f=function(){return V;};return f();}
@@ -1 +1 @@
1
- import{getSystemSettings}from'./services/get-system-settings.js';function O(L,E){L=L-0x15a;const c=Z();let t=c[L];return t;}import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';function Z(){const F=['get','/api/dictionary/:name','fcore','system','system:dictionaries','dictionaryName','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','system:access','access','params','Update\x20system\x20settings','admin','settings','body','send','Returns\x20the\x20system\x20audit\x20log\x20entries.','user','apiListQuery'];Z=function(){return F;};return Z();}import{getAccess}from'./services/get-access.js';import{setAccess}from'./services/set-access.js';import{systemSchemas}from'./schema.js';const u=L=>L['user'];export function systemRoutes(L,E=new Map()){return async c=>{const X=O;c[X(0x15a)](X(0x15b),{'schema':{'tags':[X(0x15c),X(0x15d)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':[X(0x15e)],'params':systemSchemas[X(0x15f)]}},async e=>({'items':await getDictionary({...e['params'],'user':u(e)},L)})),c['post']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':'Update\x20platform\x20dictionary','description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[X(0x15f)],'body':systemSchemas['dictionaryItems']}},async e=>updateDictionary({...e['params'],...e['body'],'user':u(e)},L));const t=async e=>getAccess({...e['params'],'user':u(e)},L);c[X(0x15a)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Get\x20access\x20rules','description':X(0x160),'access':'admin','permissions':[X(0x161)],'params':systemSchemas['accessTarget']}},t),c['post']('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget'],'body':systemSchemas[X(0x162)]}},async e=>setAccess({...e['params'],...e['body'],'user':u(e)},L)),c[X(0x15a)]('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':['system:settings']}},async e=>getSystemSettings({...e[X(0x163)],'user':u(e)},L)),c['post']('/api/system/settings',{'schema':{'tags':[X(0x15c),'system'],'summary':X(0x164),'description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':X(0x165),'permissions':['system:settings'],'body':systemSchemas[X(0x166)]}},async e=>updateSystemSettings({...e['params'],'patch':e[X(0x167)],'user':u(e)},L)),c['get']('/api/system/logger',{'schema':{'tags':[X(0x15c),'system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(e,B)=>{const j=X,{contentType:g,body:r}=await getSystemLog({...e['query'],'user':u(e)},L);return B['type'](g)[j(0x168)](r);}),c['get']('/api/system/audit',{'schema':{'tags':[X(0x15c),'system'],'summary':'Get\x20audit\x20log','description':X(0x169),'access':X(0x16a),'permissions':['system:audit']}},async e=>getAuditLog({...e['query'],'user':u(e)},L)),c['get']('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async e=>checkSystem({'user':u(e)},L)),c[X(0x15a)]('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas[X(0x16b)]}},async e=>getApiList({'user':u(e),'apiRoutes':E,...e['query']},L));};}
1
+ import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';function f(){const r=['/api/dictionary/:name','Get\x20platform\x20dictionary','fcore','system:dictionaries','dictionaryName','dictionaryItems','/api/access/:type/:id','system','Get\x20access\x20rules','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','system:access','post','Set\x20access\x20rules','get','system:settings','/api/system/settings','settings','Get\x20system\x20log','user','query','send','/api/system/audit','system:check','List\x20APIs'];f=function(){return r;};return f();}import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';function I(u,X){u=u-0x185;const o=f();let b=o[u];return b;}import{setAccess}from'./services/set-access.js';import{systemSchemas}from'./schema.js';const u=X=>X['user'];export function systemRoutes(X,o=new Map()){return async b=>{const P=I;b['get'](P(0x185),{'schema':{'tags':['fcore','system'],'summary':P(0x186),'description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas['dictionaryName']}},async t=>({'items':await getDictionary({...t['params'],'user':u(t)},X)})),b['post'](P(0x185),{'schema':{'tags':[P(0x187),'system'],'summary':'Update\x20platform\x20dictionary','description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':'user','permissions':[P(0x188)],'params':systemSchemas[P(0x189)],'body':systemSchemas[P(0x18a)]}},async t=>updateDictionary({...t['params'],...t['body'],'user':u(t)},X));const A=async t=>getAccess({...t['params'],'user':u(t)},X);b['get'](P(0x18b),{'schema':{'tags':['fcore',P(0x18c)],'summary':P(0x18d),'description':P(0x18e),'access':'admin','permissions':[P(0x18f)],'params':systemSchemas['accessTarget']}},A),b[P(0x190)]('/api/access/:type/:id',{'schema':{'tags':['fcore',P(0x18c)],'summary':P(0x191),'description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async t=>setAccess({...t['params'],...t['body'],'user':u(t)},X)),b[P(0x192)]('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[P(0x193)]}},async t=>getSystemSettings({...t['params'],'user':u(t)},X)),b[P(0x190)](P(0x194),{'schema':{'tags':['fcore','system'],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':[P(0x193)],'body':systemSchemas[P(0x195)]}},async t=>updateSystemSettings({...t['params'],'patch':t['body'],'user':u(t)},X)),b['get']('/api/system/logger',{'schema':{'tags':[P(0x187),'system'],'summary':P(0x196),'description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':P(0x197),'permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(t,p)=>{const M=P,{contentType:V,body:O}=await getSystemLog({...t[M(0x198)],'user':u(t)},X);return p['type'](V)[M(0x199)](O);}),b['get'](P(0x19a),{'schema':{'tags':[P(0x187),'system'],'summary':'Get\x20audit\x20log','description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':'user','permissions':['system:audit']}},async t=>getAuditLog({...t[P(0x198)],'user':u(t)},X)),b['get']('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':[P(0x19b)]}},async t=>checkSystem({'user':u(t)},X)),b['get']('/api/system/list',{'schema':{'tags':[P(0x187),'system'],'summary':P(0x19c),'description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas['apiListQuery']}},async t=>getApiList({'user':u(t),'apiRoutes':o,...t['query']},X));};}
@@ -1 +1 @@
1
- function O(L,E){L=L-0xcf;const c=Z();let t=c[L];return t;}function Z(){const E=['Object','Union','Literal','Optional','Array','String','short'];Z=function(){return E;};return Z();}const L=O;import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type[L(0xcf)]({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type['Union']([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type[L(0xd0)]([Type[L(0xd1)]('user'),Type[L(0xd1)]('role')]),'id':identifier}),'access':Type[L(0xcf)]({'permissions':Type[L(0xd2)](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type[L(0xd3)](Type['Object']({'resource':Type[L(0xd4)]({'minLength':0x1,'maxLength':0x80}),'actions':Type[L(0xd3)](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type[L(0xd2)](Type[L(0xd0)]([Type['Literal'](L(0xd5)),Type[L(0xd1)]('extended')]))}),'settingsEntity':Type[L(0xcf)]({'entity':Type[L(0xd2)](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type['Unknown']()),'logger':Type['Object']({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
1
+ const I=u;function u(I,X){I=I-0xc2;const o=f();let b=o[I];return b;}import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':I(0xc2)});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type[I(0xc3)]([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type[I(0xc4)](Type['Union']([Type['String'](),Type[I(0xc5)](),Type[I(0xc6)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'access':Type['Object']({'permissions':Type['Optional'](Type[I(0xc7)](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type[I(0xc4)](Type[I(0xc7)](Type[I(0xc8)]({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type[I(0xc7)](Type[I(0xc9)]({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type[I(0xc4)](Type['Union']([Type['Literal']('short'),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type[I(0xc4)](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type['Unknown']()),'logger':Type['Object']({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};function f(){const X=['^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Union','Optional','Number','Null','Array','Object','String'];f=function(){return X;};return f();}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x1e5;const c=Z();let t=c[L];return t;}export async function checkSystem(L,E){const e=O,[c,t]=await Promise[e(0x1e5)]([E['pg'][e(0x1e6)](e(0x1e7)),E[e(0x1e8)]['ping']()]);return{'status':c[e(0x1e9)]===e(0x1ea)&&t['status']==='fulfilled'?'ok':'degraded','pg':c['status'],'redis':t['status']};}function Z(){const B=['allSettled','query','SELECT\x201','redis','status','fulfilled'];Z=function(){return B;};return Z();}
1
+ function f(){const t=['query','SELECT\x201','fulfilled'];f=function(){return t;};return f();}function u(I,X){I=I-0x144;const o=f();let b=o[I];return b;}export async function checkSystem(I,X){const A=u,[o,b]=await Promise['allSettled']([X['pg'][A(0x144)](A(0x145)),X['redis']['ping']()]);return{'status':o['status']==='fulfilled'&&b['status']===A(0x146)?'ok':'degraded','pg':o['status'],'redis':b['status']};}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x9c;const c=Z();let t=c[L];return t;}export async function getAccess(L,E){const g=O,c=L[g(0x9c)]==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20',t=await E['pg'][g(0x9d)](c,[L['id']]),e=[...new Set(t[g(0x9e)]['map'](B=>B['resource'])[g(0x9f)](B=>B!==null))];return{'access':t['rows'],'resources':e};}function Z(){const r=['type','query','rows','filter'];Z=function(){return r;};return Z();}
1
+ function u(I,X){I=I-0x1d7;const o=f();let b=o[I];return b;}function f(){const V=['type','user','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20','rows','filter'];f=function(){return V;};return f();}export async function getAccess(I,X){const p=u,o=I[p(0x1d7)]===p(0x1d8)?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':p(0x1d9),b=await X['pg']['query'](o,[I['id']]),A=[...new Set(b[p(0x1da)]['map'](t=>t['resource'])[p(0x1db)](t=>t!==null))];return{'access':b['rows'],'resources':A};}
@@ -1 +1 @@
1
- function O(L,E){L=L-0xed;const c=Z();let t=c[L];return t;}function Z(){const X=['sort','method','short'];Z=function(){return X;};return Z();}export async function getApiList(L,E){const r=O,c=[...L['apiRoutes']['values']()][r(0xed)]((t,e)=>(t['endpoint']+'\x20'+t[r(0xee)])['localeCompare'](e['endpoint']+'\x20'+e['method']));if(L['format']!==r(0xef))return c;return c['map'](({method:t,endpoint:e,access:B,permissions:g})=>t+'\x20'+e);}
1
+ export async function getApiList(I,X){const V=u,o=[...I['apiRoutes'][V(0x70)]()]['sort']((b,A)=>(b['endpoint']+'\x20'+b['method'])[V(0x71)](A[V(0x72)]+'\x20'+A['method']));if(I['format']!==V(0x73))return o;return o['map'](({method:b,endpoint:A,access:t,permissions:p})=>b+'\x20'+A);}function u(I,X){I=I-0x70;const o=f();let b=o[I];return b;}function f(){const O=['values','localeCompare','endpoint','short'];f=function(){return O;};return f();}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x175;const c=Z();let t=c[L];return t;}export async function getAuditLog(L,E){const B=O,c=Math['min'](Math[B(0x175)](L['limit']??0x32,0x1),0xc8),t=Math[B(0x175)]((L['page']??0x1)-0x1,0x0)*c,e=await E['pg']['query'](B(0x176),[c,t]);return{'rows':e['rows'],'page':L[B(0x177)]??0x1,'limit':c};}function Z(){const g=['max','SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2','page'];Z=function(){return g;};return Z();}
1
+ function u(I,X){I=I-0x7a;const o=f();let b=o[I];return b;}export async function getAuditLog(I,X){const t=u,o=Math['min'](Math['max'](I['limit']??0x32,0x1),0xc8),b=Math[t(0x7a)]((I[t(0x7b)]??0x1)-0x1,0x0)*o,A=await X['pg'][t(0x7c)](t(0x7d),[o,b]);return{'rows':A['rows'],'page':I[t(0x7b)]??0x1,'limit':o};}function f(){const p=['max','page','query','SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2'];f=function(){return p;};return f();}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x1d1;var c=Z();var t=c[L];return t;}export async function getDictionary(L,E){var c=O;return E['dictionary'][c(0x1d1)](L['name']);}function Z(){var t=['get'];Z=function(){return t;};return Z();}
1
+ export async function getDictionary(I,X){var o=u;return X['dictionary'][o(0xa5)](I['name']);}function u(I,X){I=I-0xa5;var o=f();var b=o[I];return b;}function f(){var b=['get'];f=function(){return b;};return f();}
@@ -1 +1 @@
1
- import L from'node:fs/promises';function O(L,E){L=L-0x73;const c=Z();let t=c[L];return t;}import E from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=E['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(c,t){const A=O,e=normalizePath(c[A(0x73)]),B=E['resolve'](LOGS_ROOT,e);if(B!==LOGS_ROOT&&!B[A(0x74)](LOGS_ROOT+E[A(0x75)]))throw new ValidationError('Invalid\x20log\x20path');const g=await L['stat'](B)['catch'](()=>null);if(!g)throw new NotFoundError('Log\x20path\x20not\x20found');if(g['isDirectory']()){const X=await L['readdir'](B,{'withFileTypes':!![]}),j=await Promise['all'](X[A(0x76)](async F=>{const G=A,I=await L['stat'](E[G(0x77)](B,F[G(0x78)]));return{'name':F[G(0x78)],'path':e?e+'/'+F['name']:F['name'],'type':F['isDirectory']()?'directory':'file','size':F['isDirectory']()?undefined:I[G(0x79)],'modified':I['mtime']['toISOString']()};}));j['sort']((F,I)=>F['name'][A(0x7a)](I['name']));if(e){const F=e[A(0x7b)]('/')['slice'](0x0,-0x1)[A(0x77)]('/');j['unshift']({'name':'..','path':F,'type':'directory'});}return{'contentType':A(0x7c),'body':renderDirectory(e,j)};}const r=await tailFile(B,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':r['join']('\x0a')};}function renderDirectory(c,t){const x=O,e=t[x(0x76)](g=>{const W=x,r='?path='+encodeURIComponent(g['path']),X=g['type']===W(0x7d)?g['name']+'/':g[W(0x78)];return'<li><a\x20href=\x22'+r+'\x22>'+escapeHtml(X)+'</a></li>';})['join']('\x0a'),B=escapeHtml('logs/'+c);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+B+'</title></head>\x0a<body>\x0a<h1>'+B+'</h1>\x0a<ul>\x0a'+e+'\x0a</ul>\x0a</body>\x0a</html>';}function Z(){const Y=['path','startsWith','sep','map','join','name','size','localeCompare','split','text/html;\x20charset=utf-8','directory','&lt;','replace','toString','utf8','slice','close'];Z=function(){return Y;};return Z();}function escapeHtml(c){const q=O;return c['replace'](/&/g,'&amp;')['replace'](/</g,q(0x7e))['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;');}function normalizePath(c){const y=O,t=(c??'')['replace'](/\\/g,'/')[y(0x7f)](/^\/+|\/+$/g,'');if(t['split']('/')['some'](e=>e==='..'))throw new ValidationError('Invalid\x20log\x20path');return t;}async function tailFile(c,t){const p=O,e=await L['open'](c,'r');try{const {size:B}=await e['stat'](),g=0x40*0x400;let r=B,X=Buffer['alloc'](0x0),j=0x0;while(r>0x0&&j<=t){const I=Math['min'](g,r);r-=I;const T=Buffer['alloc'](I);await e['read'](T,0x0,I,r),X=Buffer['concat']([T,X]),j+=countNewlines(T);}const F=X[p(0x80)](p(0x81))[p(0x7b)]('\x0a')['filter'](f=>f['length']>0x0);return F[p(0x82)](-t)['reverse']();}finally{await e[p(0x83)]();}}function countNewlines(c){let t=0x0;for(const e of c){if(e===0xa)t++;}return t;}
1
+ import I from'node:fs/promises';import X from'node:path';function f(){const q=['resolve','stat','join','isDirectory','toISOString','slice','text/plain;\x20charset=utf-8','?path=','name','</a></li>','<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>','replace','&quot;','split','alloc','min','concat','toString'];f=function(){return q;};return f();}import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=X['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(o,b){const F=u,A=normalizePath(o['path']),t=X[F(0x121)](LOGS_ROOT,A);if(t!==LOGS_ROOT&&!t['startsWith'](LOGS_ROOT+X['sep']))throw new ValidationError('Invalid\x20log\x20path');const p=await I['stat'](t)['catch'](()=>null);if(!p)throw new NotFoundError('Log\x20path\x20not\x20found');if(p['isDirectory']()){const O=await I['readdir'](t,{'withFileTypes':!![]}),P=await Promise['all'](O['map'](async M=>{const Z=F,r=await I[Z(0x122)](X[Z(0x123)](t,M['name']));return{'name':M['name'],'path':A?A+'/'+M['name']:M['name'],'type':M['isDirectory']()?'directory':'file','size':M[Z(0x124)]()?undefined:r['size'],'modified':r['mtime'][Z(0x125)]()};}));P['sort']((M,r)=>M['name']['localeCompare'](r['name']));if(A){const M=A['split']('/')[F(0x126)](0x0,-0x1)[F(0x123)]('/');P['unshift']({'name':'..','path':M,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(A,P)};}const V=await tailFile(t,TAIL_LINES);return{'contentType':F(0x127),'body':V[F(0x123)]('\x0a')};}function u(I,X){I=I-0x121;const o=f();let b=o[I];return b;}function renderDirectory(o,b){const K=u,A=b['map'](p=>{const W=u,V=W(0x128)+encodeURIComponent(p['path']),O=p['type']==='directory'?p[W(0x129)]+'/':p['name'];return'<li><a\x20href=\x22'+V+'\x22>'+escapeHtml(O)+W(0x12a);})['join']('\x0a'),t=escapeHtml('logs/'+o);return K(0x12b)+t+'</title></head>\x0a<body>\x0a<h1>'+t+'</h1>\x0a<ul>\x0a'+A+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(o){const y=u;return o['replace'](/&/g,'&amp;')[y(0x12c)](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,y(0x12d));}function normalizePath(o){const c=u,b=(o??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(b[c(0x12e)]('/')['some'](A=>A==='..'))throw new ValidationError('Invalid\x20log\x20path');return b;}async function tailFile(o,b){const Y=u,A=await I['open'](o,'r');try{const {size:t}=await A['stat'](),p=0x40*0x400;let V=t,O=Buffer[Y(0x12f)](0x0),P=0x0;while(V>0x0&&P<=b){const r=Math[Y(0x130)](p,V);V-=r;const B=Buffer['alloc'](r);await A['read'](B,0x0,r,V),O=Buffer[Y(0x131)]([B,O]),P+=countNewlines(B);}const M=O[Y(0x132)]('utf8')['split']('\x0a')['filter'](s=>s['length']>0x0);return M[Y(0x126)](-b)['reverse']();}finally{await A['close']();}}function countNewlines(o){let b=0x0;for(const A of o){if(A===0xa)b++;}return b;}
@@ -1 +1 @@
1
- export async function getSystemSettings(L,E){const X=O,c=await E['pg'][X(0x158)](X(0x159));return c['rows']['reduce']((t,e)=>{const B=String(e['key'])['split']('.');let g=t;for(const r of B['slice'](0x0,-0x1)){g[r]??={},g=g[r];}return g[B['at'](-0x1)]=e['value'],t;},{});}function O(L,E){L=L-0x158;const c=Z();let t=c[L];return t;}function Z(){const j=['query','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20'];Z=function(){return j;};return Z();}
1
+ function f(){const P=['query','reduce'];f=function(){return P;};return f();}function u(I,X){I=I-0x1d1;const o=f();let b=o[I];return b;}export async function getSystemSettings(I,X){const O=u,o=await X['pg'][O(0x1d1)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return o['rows'][O(0x1d2)]((b,A)=>{const t=String(A['key'])['split']('.');let p=b;for(const V of t['slice'](0x0,-0x1)){p[V]??={},p=p[V];}return p[t['at'](-0x1)]=A['value'],b;},{});}
@@ -1 +1 @@
1
- export async function listDictionaries(L,E){return E['dictionary']['list']();}
1
+ function u(I,X){I=I-0x102;var o=f();var b=o[I];return b;}export async function listDictionaries(I,X){var o=u;return X['dictionary'][o(0x102)]();}function f(){var b=['list'];f=function(){return b;};return f();}
@@ -1 +1 @@
1
- function Z(){const f=['delete','update','add','map','BEGIN','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','access','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','resource','query','user','ROLLBACK','release'];Z=function(){return f;};return Z();}const F=O;import{getAccess}from'./get-access.js';function O(L,E){L=L-0xaf;const c=Z();let t=c[L];return t;}const CRUD_ACTIONS=['read','update','create',F(0xaf)];function permissionsToAccess(L){const I=F,E=new Map();for(const c of L){const [t,e]=c['split'](':');if(!t)continue;const B=e==='edit'?I(0xb0):e,g=E['get'](t)??new Set();for(const r of B?[B]:CRUD_ACTIONS)g[I(0xb1)](r);E['set'](t,g);}return[...E][I(0xb2)](([X,j])=>({'resource':X,'actions':[...j]}));}export async function setAccess(L,E){const T=F,c=await E['pg']['connect']();try{await c['query'](T(0xb3));L['type']==='user'?await c['query'](T(0xb4),[L['id']]):await c['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[L['id']]);const t=L['permissions']?permissionsToAccess(L['permissions']):L[T(0xb5)]??[];for(const e of t){L['type']==='user'?await c['query'](T(0xb6),[e[T(0xb7)],e['actions'],L['id'],L['user']['id'],L['user']['id']]):await c[T(0xb8)]('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[e[T(0xb7)],e['actions'],L['id'],L[T(0xb9)]['id'],L['user']['id']]);}await c['query']('COMMIT');}catch(B){await c['query'](T(0xba));throw B;}finally{c[T(0xbb)]();}return getAccess(L,E);}
1
+ function u(I,X){I=I-0x1e8;const o=f();let b=o[I];return b;}function f(){const s=['read','update','edit','get','add','set','connect','user','permissions','access','type','query','actions'];f=function(){return s;};return f();}const M=u;import{getAccess}from'./get-access.js';const CRUD_ACTIONS=[M(0x1e8),M(0x1e9),'create','delete'];function permissionsToAccess(I){const r=M,X=new Map();for(const o of I){const [b,A]=o['split'](':');if(!b)continue;const t=A===r(0x1ea)?'update':A,p=X[r(0x1eb)](b)??new Set();for(const V of t?[t]:CRUD_ACTIONS)p[r(0x1ec)](V);X[r(0x1ed)](b,p);}return[...X]['map'](([O,P])=>({'resource':O,'actions':[...P]}));}export async function setAccess(I,X){const B=M,o=await X['pg'][B(0x1ee)]();try{await o['query']('BEGIN');I['type']===B(0x1ef)?await o['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[I['id']]):await o['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[I['id']]);const b=I[B(0x1f0)]?permissionsToAccess(I['permissions']):I[B(0x1f1)]??[];for(const A of b){I[B(0x1f2)]==='user'?await o[B(0x1f3)]('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[A['resource'],A['actions'],I['id'],I['user']['id'],I['user']['id']]):await o['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[A['resource'],A[B(0x1f4)],I['id'],I['user']['id'],I[B(0x1ef)]['id']]);}await o['query']('COMMIT');}catch(t){await o['query']('ROLLBACK');throw t;}finally{o['release']();}return getAccess(I,X);}
@@ -1 +1 @@
1
- function Z(){var t=['dictionary'];Z=function(){return t;};return Z();}function O(L,E){L=L-0x1c1;var c=Z();var t=c[L];return t;}export async function updateDictionary(L,E){var c=O;return await E[c(0x1c1)]['put'](L['name'],L['items']),{'success':!![]};}
1
+ function u(I,X){I=I-0xef;var o=f();var b=o[I];return b;}function f(){var b=['dictionary'];f=function(){return b;};return f();}export async function updateDictionary(I,X){var o=u;return await X[o(0xef)]['put'](I['name'],I['items']),{'success':!![]};}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(L,E){const e=O;if(!Object['keys'](L['patch'])['length'])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [c,t]of Object['entries'](L['patch'])){if(!c[e(0x15c)]()||c['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+c);await E['pg'][e(0x15d)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[c,JSON['stringify'](t),L['user']['id']]);}return{'success':!![]};}function O(L,E){L=L-0x15c;const c=Z();let t=c[L];return t;}function Z(){const B=['trim','query'];Z=function(){return B;};return Z();}
1
+ function u(I,X){I=I-0xdd;const o=f();let b=o[I];return b;}function f(){const t=['patch','length','entries','trim','query','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20','stringify','user'];f=function(){return t;};return f();}import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(I,X){const A=u;if(!Object['keys'](I[A(0xdd)])[A(0xde)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [o,b]of Object[A(0xdf)](I['patch'])){if(!o[A(0xe0)]()||o['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+o);await X['pg'][A(0xe1)](A(0xe2),[o,JSON[A(0xe3)](b),I[A(0xe4)]['id']]);}return{'success':!![]};}
@@ -1 +1 @@
1
- function Z(){var t=['admin'];Z=function(){return t;};return Z();}function O(L,E){L=L-0x1c8;var c=Z();var t=c[L];return t;}import{ForbiddenError}from'../../errors.js';export function requireAdmin(L,E){var c=O;if(!L)throw new ForbiddenError('User\x20required');if(L['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(L['type']!==c(0x1c8)&&E&&!L['permissions']?.['includes'](E))throw new ForbiddenError('Missing\x20permission:\x20'+E);}
1
+ function f(){var b=['User\x20required','admin','permissions','includes'];f=function(){return b;};return f();}function u(I,X){I=I-0x1e6;var o=f();var b=o[I];return b;}import{ForbiddenError}from'../../errors.js';export function requireAdmin(I,X){var o=u;if(!I)throw new ForbiddenError(o(0x1e6));if(I['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(I['type']!==o(0x1e7)&&X&&!I[o(0x1e8)]?.[o(0x1e9)](X))throw new ForbiddenError('Missing\x20permission:\x20'+X);}
@@ -1 +1 @@
1
- function Z(){const B=['some'];Z=function(){return B;};return Z();}function O(L,E){L=L-0x156;const c=Z();let t=c[L];return t;}export const safeUser=L=>{const e=O,E=['password','salt','secret','credentials'];return Object['fromEntries'](Object['entries'](L)['filter'](([c])=>!E[e(0x156)](t=>c['toLowerCase']()['includes'](t))));};
1
+ function f(){const t=['salt','credentials','fromEntries','toLowerCase','includes'];f=function(){return t;};return f();}function u(I,X){I=I-0x1c9;const o=f();let b=o[I];return b;}export const safeUser=I=>{const A=u,X=['password',A(0x1c9),'secret',A(0x1ca)];return Object[A(0x1cb)](Object['entries'](I)['filter'](([o])=>!X['some'](b=>o[A(0x1cc)]()[A(0x1cd)](b))));};
@@ -1 +1 @@
1
- function O(L,E){L=L-0xc8;var c=Z();var t=c[L];return t;}import{UnsupportedError}from'../../errors.js';function Z(){var c=['\x20requires\x20a\x20project/provider\x20implementation'];Z=function(){return c;};return Z();}export function unsupported(L){var E=O;throw new UnsupportedError(L+E(0xc8));}
1
+ import{UnsupportedError}from'../../errors.js';export function unsupported(I){throw new UnsupportedError(I+'\x20requires\x20a\x20project/provider\x20implementation');}
@@ -1 +1 @@
1
- import{writeAudit}from'./services/write-audit.js';export function createAudit(L){const E=writeAudit(L);return{'write':E};}
1
+ import{writeAudit}from'./services/write-audit.js';export function createAudit(I){const X=writeAudit(I);return{'write':X};}
@@ -1 +1 @@
1
- const secretPattern=/password|token|secret|credential|salt/i;function Z(){const f=['isArray','fromEntries','test','[REDACTED]','rows','map','table_name','has','audit_log','audit_log_data','catch','changes','oldValue','audit','userId','resourceId','fields','field','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20'];Z=function(){return f;};return Z();}function O(L,E){L=L-0x189;const c=Z();let t=c[L];return t;}function clean(L){const j=O;if(Array[j(0x189)](L))return L['map'](clean);if(L&&typeof L==='object')return Object[j(0x18a)](Object['entries'](L)['map'](([E,c])=>[E,secretPattern[j(0x18b)](E)?j(0x18c):clean(c)]));return L;}export function writeAudit(L){let E,c;async function t(){const I=O;if(!L['pg'])return![];if(E!==undefined)return E;return c??=L['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](e=>{const F=O,B=new Set(e[F(0x18d)][F(0x18e)](g=>g[F(0x18f)]));return E=B[F(0x190)](F(0x191))&&B['has'](F(0x192)),!E&&L['logger']['warn']({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...B]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),E;})[I(0x193)](e=>{return E=![],L['logger']['warn']({'err':e},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),c;}return async function e(B){const T=O;if(!await t())return L['logger']['info']({'auditFallback':!![],'event':clean({...B,'changes':B[T(0x194)]?.[T(0x18e)](X=>({...X,'oldValue':clean(X[T(0x195)]),'newValue':clean(X['newValue'])}))})},T(0x196)),0x0;if(!L['pg'])throw new Error('empty\x20pg');const g=await L['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20',[B[T(0x197)]??null,B['module'],B['resource'],B[T(0x198)]==null?null:String(B['resourceId']),B[T(0x199)]??null,B['action'],B['requestId']??null,B['ipAddress']??null,clean(B['metadata']??{})]),r=g['rows'][0x0]['id'];for(const X of B[T(0x194)]??[]){if(secretPattern['test'](X[T(0x19a)]))continue;await L['pg']['query'](T(0x19b),[r,X['field'],JSON['stringify'](clean(X['oldValue'])),JSON['stringify'](clean(X['newValue']))]);}return r;};}
1
+ const secretPattern=/password|token|secret|credential|salt/i;function clean(I){const P=u;if(Array['isArray'](I))return I['map'](clean);if(I&&typeof I===P(0xdd))return Object['fromEntries'](Object[P(0xde)](I)['map'](([X,o])=>[X,secretPattern['test'](X)?'[REDACTED]':clean(o)]));return I;}export function writeAudit(I){let X,o;async function b(){const M=u;if(!I['pg'])return![];if(X!==undefined)return X;return o??=I['pg']['query'](M(0xdf))['then'](A=>{const r=M,t=new Set(A['rows']['map'](p=>p['table_name']));return X=t[r(0xe0)]('audit_log')&&t['has']('audit_log_data'),!X&&I['logger']['warn']({'expectedTables':[r(0xe1),r(0xe2)],'foundTables':[...t]},r(0xe3)),X;})['catch'](A=>{return X=![],I['logger']['warn']({'err':A},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),o;}return async function A(t){const B=u;if(!await b())return I['logger']['info']({'auditFallback':!![],'event':clean({...t,'changes':t['changes']?.['map'](O=>({...O,'oldValue':clean(O['oldValue']),'newValue':clean(O['newValue'])}))})},B(0xe4)),0x0;if(!I['pg'])throw new Error('empty\x20pg');const p=await I['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20',[t[B(0xe5)]??null,t['module'],t[B(0xe6)],t[B(0xe7)]==null?null:String(t['resourceId']),t['fields']??null,t['action'],t['requestId']??null,t[B(0xe8)]??null,clean(t['metadata']??{})]),V=p[B(0xe9)][0x0]['id'];for(const O of t[B(0xea)]??[]){if(secretPattern['test'](O['field']))continue;await I['pg'][B(0xeb)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[V,O['field'],JSON['stringify'](clean(O[B(0xec)])),JSON[B(0xed)](clean(O['newValue']))]);}return V;};}function u(I,X){I=I-0xdd;const o=f();let b=o[I];return b;}function f(){const s=['object','entries','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20','has','admin.audit_log','admin.audit_log_data','Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled','audit','userId','resource','resourceId','ipAddress','rows','changes','query','oldValue','stringify'];f=function(){return s;};return f();}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x188;const c=Z();let t=c[L];return t;}export async function getUserPermissions(L,E){const e=O,c=await E['pg']['query'](e(0x188),[L]);return c[e(0x189)]['map'](t=>t[e(0x18a)]);}function Z(){const B=['\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20','rows','permission'];Z=function(){return B;};return Z();}
1
+ export async function getUserPermissions(I,X){const o=await X['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[I]);return o['rows']['map'](b=>b['permission']);}
@@ -1 +1 @@
1
- function O(L,E){L=L-0xa0;const c=Z();let t=c[L];return t;}export*from'./auth.types.js';import{randomBytes,scrypt as L,timingSafeEqual}from'node:crypto';import{promisify}from'node:util';const scrypt=promisify(L);import E from'@fastify/cookie';import c from'@fastify/session';import{Authenticator}from'@fastify/passport';import t from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();export*from'./verifyUser.js';export*from'./get-user-permissions.js';function Z(){const x=['scrypt$','toString','from','test','auth','cookieOptions','database','initialize','register','user'];Z=function(){return x;};return Z();}export async function hashPassword(e){const T=O,B=randomBytes(0x10),g=await scrypt(e,B,0x40);return T(0xa0)+B['toString']('hex')+'$'+g[T(0xa1)]('hex');}export async function verifyPassword(e,B){const f=O,[g,r,X]=B?.['split']('$')||[];if(g!=='scrypt'||!r||!X)return![];const j=Buffer[f(0xa2)](r,'hex'),F=Buffer['from'](X,'hex'),I=await scrypt(e,j,F['length']);return timingSafeEqual(I,F);}export async function createSessionStore(e,B){const A=O,{config:g,redis:r}=B;if(!g||!r){console['warn']('Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV===A(0xa3)||process.env.VITEST)return;await e['register'](E,{'parseOptions':g[A(0xa4)]['cookieOptions']}),await e['register'](c,{'secret':g['auth']['secret'],'cookieName':g['auth']['cookieName'],'cookie':g['auth'][A(0xa5)],'store':new t({'prefix':g[A(0xa4)]['cookieName']+':'+(g['pg']?.[A(0xa6)]||'db')+':','client':r})}),await e['register'](fastifyPassport[A(0xa7)]()),await e[A(0xa8)](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async X=>({'user':X})),fastifyPassport['registerUserDeserializer'](async X=>{const G=A,j=X?.[G(0xa9)]||X;return j?.['id']&&(j['permissions']=await getUserPermissions(j['id'],B)),j;});}
1
+ export*from'./auth.types.js';import{randomBytes,scrypt as I,timingSafeEqual}from'node:crypto';import{promisify}from'node:util';const scrypt=promisify(I);import X from'@fastify/cookie';import o from'@fastify/session';import{Authenticator}from'@fastify/passport';import b from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';function u(I,X){I=I-0xda;const o=f();let b=o[I];return b;}const fastifyPassport=new Authenticator();export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(A){const t=randomBytes(0x10),p=await scrypt(A,t,0x40);return'scrypt$'+t['toString']('hex')+'$'+p['toString']('hex');}export async function verifyPassword(A,t){const B=u,[p,V,O]=t?.['split']('$')||[];if(p!=='scrypt'||!V||!O)return![];const P=Buffer['from'](V,'hex'),M=Buffer['from'](O,B(0xda)),r=await scrypt(A,P,M[B(0xdb)]);return timingSafeEqual(r,M);}export async function createSessionStore(A,t){const s=u,{config:p,redis:V}=t;if(!p||!V){console[s(0xdc)](s(0xdd));return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await A['register'](X,{'parseOptions':p['auth']['cookieOptions']}),await A[s(0xde)](o,{'secret':p['auth'][s(0xdf)],'cookieName':p['auth']['cookieName'],'cookie':p['auth']['cookieOptions'],'store':new b({'prefix':p['auth']['cookieName']+':'+(p['pg']?.[s(0xe0)]||'db')+':','client':V})}),await A[s(0xde)](fastifyPassport[s(0xe1)]()),await A['register'](fastifyPassport[s(0xe2)]()),fastifyPassport['registerUserSerializer'](async O=>({'user':O})),fastifyPassport[s(0xe3)](async O=>{const F=s,P=O?.['user']||O;return P?.['id']&&(P[F(0xe4)]=await getUserPermissions(P['id'],t)),P;});}function f(){const Z=['hex','length','warn','Missing\x20config\x20or\x20redis\x20-\x20skipping\x20session\x20store\x20creation','register','secret','database','initialize','secureSession','registerUserDeserializer','permissions'];f=function(){return Z;};return f();}
@@ -1 +1 @@
1
- import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';function O(L,E){L=L-0x1c6;const c=Z();let t=c[L];return t;}function Z(){const I=['query','rows','info','auth/warn'];Z=function(){return I;};return Z();}export async function verifyUser({user:L,password:E,ip:c},{pg:t,logger:e}){const F=O;if(!L||L==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!E||E==='')throw new BadRequestError('not\x20enough\x20params:\x20password');e['metrics']('user.login');const B='select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201',g=await t[F(0x1c6)](B,[L])['then'](X=>X[F(0x1c7)]?.[0x0]);if(!g){const X='user\x20not\x20found';e[F(0x1c8)]({'file':F(0x1c9),'error':X,'user':L,'ip':c});throw new BadRequestError(X);}const r=await verifyPassword(E,g['password_hash']);if(!r){const j='Wrong\x20password';e[F(0x1c8)]({'file':'auth/warn','error':j,'user':L,'ip':c});throw new BadRequestError(j);}return delete g['password_hash'],g;}
1
+ function u(I,X){I=I-0x18a;const o=f();let b=o[I];return b;}import{BadRequestError}from'../../errors.js';function f(){const r=['not\x20enough\x20params:\x20user','user.login','select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201','query','info','auth/warn'];f=function(){return r;};return f();}import{verifyPassword}from'./index.js';export async function verifyUser({user:I,password:X,ip:o},{pg:b,logger:A}){const M=u;if(!I||I==='')throw new BadRequestError(M(0x18a));if(!X||X==='')throw new BadRequestError('not\x20enough\x20params:\x20password');A['metrics'](M(0x18b));const t=M(0x18c),p=await b[M(0x18d)](t,[I])['then'](O=>O['rows']?.[0x0]);if(!p){const O='user\x20not\x20found';A[M(0x18e)]({'file':'auth/warn','error':O,'user':I,'ip':o});throw new BadRequestError(O);}const V=await verifyPassword(X,p['password_hash']);if(!V){const P='Wrong\x20password';A['info']({'file':M(0x18f),'error':P,'user':I,'ip':o});throw new BadRequestError(P);}return delete p['password_hash'],p;}
@@ -1 +1 @@
1
- import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:L,dictionaries:dictionaries=[]}){const E=new Map(),c=new Map();let t,e;async function B(){const h=O;if(t!==undefined)return t;if(!L)throw new Error('empty\x20pg');return e??=L[h(0xae)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')[h(0xaf)](A=>{const w=h,G=A[w(0xb0)][0x0]?.[w(0xb1)];t=G==='dictionaries'?G:null;}),await e,t;}function g(A){if(!dictionaryName['test'](A))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+A);}function r(A){const S=O;for(const G of Array[S(0xb2)](A)?A:[A]){g(G['code']);if(!Array['isArray'](G['items']))throw new ValidationError(S(0xb3)+G['code']);if(E['has'](G['code']))throw new ConflictError('Dictionary\x20already\x20registered:\x20'+G[S(0xb4)]);E[S(0xb5)](G[S(0xb4)],{...G,'source':'static'});}}function X(A){return E['has'](A);}async function j(A){const D=O;g(A);const G=E['get'](A);if(G&&G[D(0xb6)])return G['items'];const x=await B();if(!x)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const W=await L?.[D(0xae)](D(0xb7),[A]);if(W?.['rows']?.['length']){const q=W?.[D(0xb0)];return E['set'](A,{'code':A,'name':A,'items':q,'source':'database','checked':!![]}),q;}if(!G?.['items'])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+A);return G['checked']=!![],G[D(0xb8)];}async function F(A,G){const u=O;g(A);if(!Array[u(0xb2)](G))throw new ValidationError('Dictionary\x20items\x20must\x20be\x20an\x20array');const x=await B();if(!x)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!L)throw new Error(u(0xb9));const W=await L['connect']();try{await W['query']('BEGIN');const q=await W[u(0xae)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[A,A,'fcore','custom',!![]]),y=q['rows'][0x0]['id'];await W['query']('DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1',[y]);for(const p of G){await W['query'](u(0xba),[y,p[u(0xb4)],p['name'],p[u(0xbb)]??null]);}await W['query']('COMMIT');}catch(Y){await W['query']('ROLLBACK');throw Y;}finally{W['release']();}E[u(0xb5)](A,{'items':G,'code':A,'source':'static','checked':!![]}),c['set'](A,(c['get'](A)??0x0)+0x1);}function I(A){return g(A),c['set'](A,(c['get'](A)??0x0)+0x1),E['delete'](A);}function T(A){return c['get'](A)??0x0;}async function f(){const A=[...E['values']()]['map'](({code:W,name:q,source:y})=>({'code':W,'name':q??W,'source':y})),G=await B();if(!G)return A;if(!L)throw new Error('empty\x20pg');const x=await L['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const W of x['rows']){!E['has'](W['code'])&&A['push'](W);}return A;}return r(dictionaries),{'register':r,'get':j,'put':F,'clear':I,'revision':T,'list':f,'has':X};}function O(L,E){L=L-0xae;const c=Z();let t=c[L];return t;}function Z(){const U=['query','then','rows','table_name','isArray','Invalid\x20dictionary\x20items:\x20','code','set','checked','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','items','empty\x20pg','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','parentId'];Z=function(){return U;};return Z();}
1
+ function u(I,X){I=I-0x15b;const o=f();let b=o[I];return b;}import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function f(){const H=['\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20','rows','table_name','code','items','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','set','checked','isArray','Dictionary\x20items\x20must\x20be\x20an\x20array','query','name','parentId','static','get','delete','values'];f=function(){return H;};return f();}const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:I,dictionaries:dictionaries=[]}){const X=new Map(),o=new Map();let b,A;async function t(){const D=u;if(b!==undefined)return b;if(!I)throw new Error('empty\x20pg');return A??=I['query'](D(0x15b))['then'](F=>{const d=D,Z=F[d(0x15c)][0x0]?.[d(0x15d)];b=Z==='dictionaries'?Z:null;}),await A,b;}function p(F){if(!dictionaryName['test'](F))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+F);}function V(F){const N=u;for(const Z of Array['isArray'](F)?F:[F]){p(Z[N(0x15e)]);if(!Array['isArray'](Z[N(0x15f)]))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+Z[N(0x15e)]);if(X['has'](Z['code']))throw new ConflictError('Dictionary\x20already\x20registered:\x20'+Z['code']);X['set'](Z['code'],{...Z,'source':'static'});}}function O(F){return X['has'](F);}async function P(F){const m=u;p(F);const Z=X['get'](F);if(Z&&Z['checked'])return Z['items'];const W=await t();if(!W)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const K=await I?.['query'](m(0x160),[F]);if(K?.[m(0x15c)]?.['length']){const y=K?.['rows'];return X[m(0x161)](F,{'code':F,'name':F,'items':y,'source':'database','checked':!![]}),y;}if(!Z?.['items'])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+F);return Z[m(0x162)]=!![],Z[m(0x15f)];}async function M(F,Z){const x=u;p(F);if(!Array[x(0x163)](Z))throw new ValidationError(x(0x164));const W=await t();if(!W)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!I)throw new Error('empty\x20pg');const K=await I['connect']();try{await K[x(0x165)]('BEGIN');const y=await K['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[F,F,'fcore','custom',!![]]),c=y[x(0x15c)][0x0]['id'];await K['query']('DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1',[c]);for(const Y of Z){await K['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[c,Y['code'],Y[x(0x166)],Y[x(0x167)]??null]);}await K[x(0x165)]('COMMIT');}catch(q){await K['query']('ROLLBACK');throw q;}finally{K['release']();}X[x(0x161)](F,{'items':Z,'code':F,'source':x(0x168),'checked':!![]}),o['set'](F,(o['get'](F)??0x0)+0x1);}function r(F){const l=u;return p(F),o['set'](F,(o[l(0x169)](F)??0x0)+0x1),X[l(0x16a)](F);}function B(F){const J=u;return o[J(0x169)](F)??0x0;}async function s(){const S=u,F=[...X[S(0x16b)]()]['map'](({code:K,name:y,source:c})=>({'code':K,'name':y??K,'source':c})),Z=await t();if(!Z)return F;if(!I)throw new Error('empty\x20pg');const W=await I['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const K of W['rows']){!X['has'](K[S(0x15e)])&&F['push'](K);}return F;}return V(dictionaries),{'register':V,'get':P,'put':M,'clear':r,'revision':B,'list':s,'has':O};}
@@ -1 +1 @@
1
- import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';function Z(){const q=['startsWith','includes','replace','transformToByteArray','push','from','concat','toString','us-east-1','forcePathStyle','bucket','Body','httpStatusCode','tokenTtl','base64url','createHmac','sha256','Invalid\x20file\x20token','digest','length'];Z=function(){return q;};return Z();}import L from'node:crypto';import{ValidationError}from'../errors.js';function O(L,E){L=L-0xec;const c=Z();let t=c[L];return t;}import{UnauthorizedError}from'../errors.js';function keyFor(E,c){const I=O;if(!c||c[I(0xec)]('/')||c[I(0xed)]('..'))throw new ValidationError('Invalid\x20file\x20path');const t=c['replace'](/\\/g,'/')[I(0xee)](/^\/+/,''),e=(E??'')['replace'](/^\/+|\/+$/g,'');return e?e+'/'+t:t;}async function bodyToBuffer(E){const T=O;if(!E)return Buffer['alloc'](0x0);const c=E;if(typeof c[T(0xef)]==='function')return Buffer['from'](await c['transformToByteArray']());const t=[];for await(const e of E){t[T(0xf0)](Buffer[T(0xf1)](e));}return Buffer[T(0xf2)](t);}export function createFileS3(E){const f=O,c=E['tokenSecret']??process.env.FILE_TOKEN_SECRET??L['randomBytes'](0x20)[f(0xf3)]('hex'),t=new S3Client({'endpoint':E['endpoint'],'region':E['region']??f(0xf4),'forcePathStyle':E[f(0xf5)]??!![],'credentials':E['accessKeyId']||E['accessKey']?{'accessKeyId':E['accessKeyId']??E['accessKey'],'secretAccessKey':E['secretAccessKey']??E['secretKey']}:undefined}),e=B=>keyFor(E['folder'],B);return{async 'put'(B,g){await t['send'](new PutObjectCommand({'Bucket':E['bucket'],'Key':e(B),'Body':g}));},async 'get'(B){const A=f,g=await t['send'](new GetObjectCommand({'Bucket':E[A(0xf6)],'Key':e(B)}));return bodyToBuffer(g[A(0xf7)]);},async 'exists'(B){const G=f;try{return await t['send'](new HeadObjectCommand({'Bucket':E['bucket'],'Key':e(B)})),!![];}catch(g){const r=g;if(r['$metadata']?.[G(0xf8)]===0x194||r['name']==='NotFound')return![];throw g;}},async 'delete'(B){await t['send'](new DeleteObjectCommand({'Bucket':E['bucket'],'Key':e(B)}));},'create'(B,g=E[f(0xf9)]??0xe10){const x=f,r=Buffer['from'](B)['toString'](x(0xfa)),X=L[x(0xfb)](x(0xfc),c)['update'](r)['digest']('base64url');return r+'.'+X;},'verify'(B){const W=f,[g,r]=B['split']('.');if(!g||!r)throw new UnauthorizedError(W(0xfd));const X=L['createHmac']('sha256',c)['update'](g)[W(0xfe)](),j=Buffer[W(0xf1)](r,'base64url');if(X[W(0xff)]!==j['length']||!L['timingSafeEqual'](X,j))throw new UnauthorizedError('Invalid\x20file\x20token');const F=Buffer['from'](g,'base64url')[W(0xf3)]('utf8');return F;}};}
1
+ function f(){const c=['includes','replace','function','concat','forcePathStyle','folder','send','bucket','NotFound','from','digest','Invalid\x20file\x20token','createHmac','sha256','update','base64url'];f=function(){return c;};return f();}function u(I,X){I=I-0xe2;const o=f();let b=o[I];return b;}import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import I from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function keyFor(X,o){const r=u;if(!o||o['startsWith']('/')||o[r(0xe2)]('..'))throw new ValidationError('Invalid\x20file\x20path');const b=o['replace'](/\\/g,'/')[r(0xe3)](/^\/+/,''),A=(X??'')['replace'](/^\/+|\/+$/g,'');return A?A+'/'+b:b;}async function bodyToBuffer(X){const B=u;if(!X)return Buffer['alloc'](0x0);const o=X;if(typeof o['transformToByteArray']===B(0xe4))return Buffer['from'](await o['transformToByteArray']());const b=[];for await(const A of X){b['push'](Buffer['from'](A));}return Buffer[B(0xe5)](b);}export function createFileS3(X){const s=u,o=X['tokenSecret']??process.env.FILE_TOKEN_SECRET??I['randomBytes'](0x20)['toString']('hex'),b=new S3Client({'endpoint':X['endpoint'],'region':X['region']??'us-east-1','forcePathStyle':X[s(0xe6)]??!![],'credentials':X['accessKeyId']||X['accessKey']?{'accessKeyId':X['accessKeyId']??X['accessKey'],'secretAccessKey':X['secretAccessKey']??X['secretKey']}:undefined}),A=t=>keyFor(X[s(0xe7)],t);return{async 'put'(t,p){await b['send'](new PutObjectCommand({'Bucket':X['bucket'],'Key':A(t),'Body':p}));},async 'get'(t){const F=s,p=await b[F(0xe8)](new GetObjectCommand({'Bucket':X['bucket'],'Key':A(t)}));return bodyToBuffer(p['Body']);},async 'exists'(t){const Z=s;try{return await b[Z(0xe8)](new HeadObjectCommand({'Bucket':X[Z(0xe9)],'Key':A(t)})),!![];}catch(p){const V=p;if(V['$metadata']?.['httpStatusCode']===0x194||V['name']===Z(0xea))return![];throw p;}},async 'delete'(t){const W=s;await b['send'](new DeleteObjectCommand({'Bucket':X[W(0xe9)],'Key':A(t)}));},'create'(t,p=X['tokenTtl']??0xe10){const K=s,V=Buffer[K(0xeb)](t)['toString']('base64url'),O=I['createHmac']('sha256',o)['update'](V)[K(0xec)]('base64url');return V+'.'+O;},'verify'(t){const y=s,[p,V]=t['split']('.');if(!p||!V)throw new UnauthorizedError(y(0xed));const O=I[y(0xee)](y(0xef),o)[y(0xf0)](p)['digest'](),P=Buffer[y(0xeb)](V,y(0xf1));if(O['length']!==P['length']||!I['timingSafeEqual'](O,P))throw new UnauthorizedError(y(0xed));const M=Buffer['from'](p,'base64url')['toString']('utf8');return M;}};}
@@ -1 +1 @@
1
- import{SignJWT,jwtVerify}from'jose';function O(L,E){L=L-0xf2;const c=Z();let t=c[L];return t;}const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);function Z(){const g=['setIssuedAt'];Z=function(){return g;};return Z();}export async function jwtSignToken(L){const B=O;if(!process.env.AUTH_JWT_SECRET)return;const {id:E,type:c,permissions:t}=L,e=await new SignJWT({'id':E,'type':c,'permissions':t})['setProtectedHeader']({'alg':'HS256'})[B(0xf2)]()['setExpirationTime']('1h')['sign'](secret);return e;}export async function jwtVerifyToken(L){const E=await jwtVerify(L,secret,{'algorithms':['HS256']})['catch'](c=>{console['log'](c['message']);});return E?.['payload'];}
1
+ import{SignJWT,jwtVerify}from'jose';const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);function u(I,X){I=I-0x1e5;const o=f();let b=o[I];return b;}export async function jwtSignToken(I){const t=u;if(!process.env.AUTH_JWT_SECRET)return;const {id:X,type:o,permissions:b}=I,A=await new SignJWT({'id':X,'type':o,'permissions':b})['setProtectedHeader']({'alg':t(0x1e5)})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return A;}export async function jwtVerifyToken(I){const X=await jwtVerify(I,secret,{'algorithms':['HS256']})['catch'](o=>{const p=u;console['log'](o[p(0x1e6)]);});return X?.['payload'];}function f(){const V=['HS256','message'];f=function(){return V;};return f();}
@@ -1 +1 @@
1
- import L from'pino';function Z(){const X=['transport','./transport.js','password','token','refreshToken','bind'];Z=function(){return X;};return Z();}function O(L,E){L=L-0xba;const c=Z();let t=c[L];return t;}export function createLogger(){const r=O,E=L[r(0xba)]({'target':r(0xbb)}),c=L({'level':'info','timestamp':L['stdTimeFunctions']['isoTime'],'base':{'service':'app'},'redact':{'paths':['req.headers.authorization',r(0xbc),r(0xbd),'accessToken',r(0xbe)],'censor':'[REDACTED]'}},E),t={};function e(B,g){if(B===undefined)return{...t};t[B]=(t[B]??0x0)+(g??0x1);}return Object['assign'](c,{'close':async()=>E['end'](),'metrics':e,'file':()=>c['info'][r(0xbf)](c)});}
1
+ function f(){const O=['app','req.headers.authorization','password','refreshToken'];f=function(){return O;};return f();}import I from'pino';function u(I,X){I=I-0x1cc;const o=f();let b=o[I];return b;}export function createLogger(){const V=u,X=I['transport']({'target':'./transport.js'}),o=I({'level':'info','timestamp':I['stdTimeFunctions']['isoTime'],'base':{'service':V(0x1cc)},'redact':{'paths':[V(0x1cd),V(0x1ce),'token','accessToken',V(0x1cf)],'censor':'[REDACTED]'}},X),b={};function A(t,p){if(t===undefined)return{...b};b[t]=(b[t]??0x0)+(p??0x1);}return Object['assign'](o,{'close':async()=>X['end'](),'metrics':A,'file':()=>o['info']['bind'](o)});}
@@ -1 +1 @@
1
- function Z(){const T=['slice','mkdirSync','createWriteStream','.log','stream','set','clear','file'];Z=function(){return T;};return Z();}import L from'node:fs';import E from'node:path';import c from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const r=O;return new Date()['toISOString']()[r(0x18e)](0x0,0xa);}function createStream(t,e){const X=O,B=E['resolve']('logs',t);return L[X(0x18f)](B,{'recursive':!![]}),L[X(0x190)](E['join'](B,e+X(0x191)),{'flags':'a'});}function getStream(t){const j=O,e=getDate(),B=streams['get'](t);if(B&&B['date']===e)return B['stream'];B?.[j(0x192)]['end']();const g=createStream(t,e);return streams[j(0x193)](t,{'date':e,'stream':g}),g;}function closeStreams(){const F=O;for(const {stream:t}of streams['values']()){t['end']();}streams[F(0x194)]();}function O(L,E){L=L-0x18e;const c=Z();let t=c[L];return t;}export default async function loggerTransport(){return c(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(t){const I=O;for await(const e of t){const B=LEVELS[e['level']];if(!B)continue;const g=getStream(e['file']||B);delete e[I(0x195)],g['write'](JSON['stringify'](e)+'\x0a');}}
1
+ const V=u;import I from'node:fs';import X from'node:path';import o from'pino-abstract-transport';function f(){const B=['warn','error','toISOString','slice','resolve','join','.log','set','level'];f=function(){return B;};return f();}const LEVELS={0x1e:'info',0x28:V(0x80),0x32:'error',0x3c:V(0x81)},streams=new Map();function getDate(){const O=V;return new Date()[O(0x82)]()[O(0x83)](0x0,0xa);}function createStream(b,A){const P=V,t=X[P(0x84)]('logs',b);return I['mkdirSync'](t,{'recursive':!![]}),I['createWriteStream'](X[P(0x85)](t,A+P(0x86)),{'flags':'a'});}function getStream(b){const M=V,A=getDate(),t=streams['get'](b);if(t&&t['date']===A)return t['stream'];t?.['stream']['end']();const p=createStream(b,A);return streams[M(0x87)](b,{'date':A,'stream':p}),p;}function closeStreams(){for(const {stream:b}of streams['values']()){b['end']();}streams['clear']();}export default async function loggerTransport(){return o(writeLogs,{'close':async()=>{closeStreams();}});}function u(I,X){I=I-0x80;const o=f();let b=o[I];return b;}async function writeLogs(b){const r=V;for await(const A of b){const t=LEVELS[A[r(0x88)]];if(!t)continue;const p=getStream(A['file']||t);delete A['file'],p['write'](JSON['stringify'](A)+'\x0a');}}
@@ -1 +1 @@
1
- import L from'pg';function Z(){const A=['query','bind','captureStackTrace','transaction','connect','BEGIN','ROLLBACK'];Z=function(){return A;};return Z();}const {Pool}=L;function O(L,E){L=L-0x6a;const c=Z();let t=c[L];return t;}export function createDatabase(E){const I=O,c=new Pool(E),t=c[I(0x6a)][I(0x6b)](c);function e(B,g){const T=I,r=new Error();return Error[T(0x6c)]?.(r,e),t(B,g)['catch'](X=>{const j=X;j['sql']=B,j['callerStack']=r['stack'];throw j;});}return c[I(0x6a)]=e,c['transaction']=async function(B){const f=I,g=new Error();Error[f(0x6c)]?.(g,c[f(0x6d)]);const r=await c[f(0x6e)]();try{await r['query'](f(0x6f));const X=await B(r);return await r['query']('COMMIT'),X;}catch(j){await r['query'](f(0x70));const F=j;F['callerStack']=g['stack'];throw F;}finally{r['release']();}},c;}
1
+ import I from'pg';const {Pool}=I;function f(){const F=['sql','callerStack','transaction','captureStackTrace','BEGIN','query','release'];f=function(){return F;};return f();}function u(I,X){I=I-0xf0;const o=f();let b=o[I];return b;}export function createDatabase(X){const B=u,o=new Pool(X),b=o['query']['bind'](o);function A(t,p){const V=new Error();return Error['captureStackTrace']?.(V,A),b(t,p)['catch'](O=>{const r=u,P=O;P[r(0xf0)]=t,P[r(0xf1)]=V['stack'];throw P;});}return o['query']=A,o[B(0xf2)]=async function(t){const s=B,p=new Error();Error[s(0xf3)]?.(p,o['transaction']);const V=await o['connect']();try{await V['query'](s(0xf4));const O=await t(V);return await V[s(0xf5)]('COMMIT'),O;}catch(P){await V['query']('ROLLBACK');const M=P;M['callerStack']=p['stack'];throw M;}finally{V[s(0xf6)]();}},o;}
@@ -1 +1 @@
1
- import{Redis}from'ioredis';function O(L,E){L=L-0xc6;const c=Z();let t=c[L];return t;}function Z(){const r=['del','ping'];Z=function(){return r;};return Z();}export function createRedis(L){const g=O,E=new Redis(L);return{'get':c=>E['get'](c),'set':(c,t,e,B)=>{if(B)return E['set'](c,t,'EX',B);if(typeof e==='number')return E['set'](c,t,'EX',e);return E['set'](c,t);},'del':c=>E['del'](c),'delete':c=>E[g(0xc6)](c),'close':()=>E['quit'](),'ping':()=>E[g(0xc7)](),'hincrby':(c,t,e)=>E['hincrby'](c,t,e),'incrby':(c,t)=>E['incrby'](c,t)};}
1
+ function f(){const O=['set','del','hincrby'];f=function(){return O;};return f();}function u(I,X){I=I-0xec;const o=f();let b=o[I];return b;}import{Redis}from'ioredis';export function createRedis(I){const V=u,X=new Redis(I);return{'get':o=>X['get'](o),'set':(o,b,A,t)=>{const p=u;if(t)return X[p(0xec)](o,b,'EX',t);if(typeof A==='number')return X['set'](o,b,'EX',A);return X[p(0xec)](o,b);},'del':o=>X['del'](o),'delete':o=>X[V(0xed)](o),'close':()=>X['quit'](),'ping':()=>X['ping'](),'hincrby':(o,b,A)=>X[V(0xee)](o,b,A),'incrby':(o,b)=>X['incrby'](o,b)};}
@@ -1 +1 @@
1
- import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(L){const E=new ResourceRegistry(),c=createFind(L,E),t=createFindOne(L,E),e=createCreate(L,E),B=createUpdate(L,E),g=createRemove(L,E),r=createFindRelation(L,E),X=createCreateRelation(L,E),j=createUpdateRelation(L,E),F=createDeleteRelation(L,E);return{'register':E['register']['bind'](E),'has':E['has']['bind'](E),'get':E['get']['bind'](E),'list':E['list']['bind'](E),'find':c,'findOne':t,'create':e,'update':B,'delete':g,'findRelation':r,'createRelation':X,'updateRelation':j,'deleteRelation':F};}
1
+ import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';function f(){const B=['has','bind'];f=function(){return B;};return f();}import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';function u(I,X){I=I-0x9b;const o=f();let b=o[I];return b;}import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(I){const r=u,X=new ResourceRegistry(),o=createFind(I,X),b=createFindOne(I,X),A=createCreate(I,X),t=createUpdate(I,X),p=createRemove(I,X),V=createFindRelation(I,X),O=createCreateRelation(I,X),P=createUpdateRelation(I,X),M=createDeleteRelation(I,X);return{'register':X['register']['bind'](X),'has':X[r(0x9b)]['bind'](X),'get':X['get'][r(0x9c)](X),'list':X['list'][r(0x9c)](X),'find':o,'findOne':b,'create':A,'update':t,'delete':p,'findRelation':V,'createRelation':O,'updateRelation':P,'deleteRelation':M};}
@@ -1 +1 @@
1
- function O(L,E){L=L-0xa9;const c=Z();let t=c[L];return t;}function Z(){const j=['isArray','name','has','resources','Resource\x20not\x20registered:\x20','values','test','table','key'];Z=function(){return j;};return Z();}const e=O;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(L){return L['split']('.')['length']<=0x2&&L['split']('.')['every'](E=>ident['test'](E));}export class ResourceRegistry{['resources']=new Map();['register'](L){const t=O;for(const E of Array[t(0xa9)](L)?L:[L]){this['validate'](E);if(this['resources']['has'](E['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+E['name']);this['resources']['set'](E[t(0xaa)],E);}}[e(0xab)](L){const B=e;return this[B(0xac)][B(0xab)](L);}['get'](L){const g=e,E=this['resources']['get'](L);if(!E)throw new NotFoundError(g(0xad)+L);return E;}['list'](){const r=e;return[...this['resources'][r(0xae)]()];}['validate'](L){const X=e;if(L['version']!==0x1||!ident[X(0xaf)](L['name'])||!validQualified(L[X(0xb0)])||!ident[X(0xaf)](L[X(0xb1)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+L[X(0xaa)]);for(const [E,c]of Object['entries'](L['fields'])){if(!ident['test'](E)||!ident['test'](c['column']??E))throw new ValidationError('Invalid\x20resource\x20field:\x20'+E);}}}
1
+ function f(){const P=['length','every','register','isArray','Resource\x20already\x20registered:\x20','resources','has','list','values','name','test'];f=function(){return P;};return f();}function u(I,X){I=I-0xb0;const o=f();let b=o[I];return b;}const A=u;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(I){const b=u;return I['split']('.')[b(0xb0)]<=0x2&&I['split']('.')[b(0xb1)](X=>ident['test'](X));}export class ResourceRegistry{['resources']=new Map();[A(0xb2)](I){const t=A;for(const X of Array[t(0xb3)](I)?I:[I]){this['validate'](X);if(this['resources']['has'](X['name']))throw new ConflictError(t(0xb4)+X['name']);this[t(0xb5)]['set'](X['name'],X);}}['has'](I){const p=A;return this['resources'][p(0xb6)](I);}['get'](I){const X=this['resources']['get'](I);if(!X)throw new NotFoundError('Resource\x20not\x20registered:\x20'+I);return X;}[A(0xb7)](){const V=A;return[...this['resources'][V(0xb8)]()];}['validate'](I){const O=A;if(I['version']!==0x1||!ident['test'](I['name'])||!validQualified(I['table'])||!ident['test'](I['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+I[O(0xb9)]);for(const [X,o]of Object['entries'](I['fields'])){if(!ident[O(0xba)](X)||!ident[O(0xba)](o['column']??X))throw new ValidationError('Invalid\x20resource\x20field:\x20'+X);}}}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x1e0;const c=Z();let t=c[L];return t;}function Z(){const A=['set','all','has','get','color','icon','length','flatMap'];Z=function(){return A;};return Z();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(L,E){const I=O,c=dictionaryIndexesCache['get'](E)??new Map(),t=dictionaryRevisionsCache['get'](E)??new Map();dictionaryIndexesCache['set'](E,c),dictionaryRevisionsCache[I(0x1e0)](E,t);const e=L['filter'](g=>t['get'](g)!==E['revision'](g));if(e['length']===0x0)return c;const B=await Promise[I(0x1e1)](e['map'](async g=>{const T=I;if(!E[T(0x1e2)](g))return[g,new Map()];const r=await E[T(0x1e3)](g),X=new Map();for(const j of r){const F=j['code']??j['id'];if(F==null)continue;X[T(0x1e0)](String(F),{'id':F,'text':j['name']??j['text'],...j['color']!==undefined?{'color':j[T(0x1e4)]}:{},...j['icon']!==undefined?{'icon':j[T(0x1e5)]}:{}});}return[g,X];}));for(const [g,r]of B){c['set'](g,r),t['set'](g,E['revision'](g));}return c;}export async function addDictionaryLookupData(L,E,c){const f=O;if(!c||L[f(0x1e6)]===0x0)return L;const t=Object['entries'](E)[f(0x1e7)](([B,g])=>{const r=g['dictionary'];return r?[{'field':B,'dictionaryName':r}]:[];});if(t['length']===0x0)return L;const e=await getDictionaryIndexes([...new Set(t['map'](({dictionaryName:B})=>B))],c);for(const B of L){for(const {field:g,dictionaryName:r}of t){const X=B[g];B[g+'_data']=X==null?null:e['get'](r)?.['get'](String(X))??null;}}return L;}
1
+ const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();function f(){const F=['set','filter','get','length','all','name','color','icon','flatMap','map'];f=function(){return F;};return f();}async function getDictionaryIndexes(I,X){const r=u,o=dictionaryIndexesCache['get'](X)??new Map(),b=dictionaryRevisionsCache['get'](X)??new Map();dictionaryIndexesCache[r(0xaf)](X,o),dictionaryRevisionsCache['set'](X,b);const A=I[r(0xb0)](p=>b[r(0xb1)](p)!==X['revision'](p));if(A[r(0xb2)]===0x0)return o;const t=await Promise[r(0xb3)](A['map'](async p=>{const B=r;if(!X['has'](p))return[p,new Map()];const V=await X['get'](p),O=new Map();for(const P of V){const M=P['code']??P['id'];if(M==null)continue;O[B(0xaf)](String(M),{'id':M,'text':P[B(0xb4)]??P['text'],...P['color']!==undefined?{'color':P[B(0xb5)]}:{},...P['icon']!==undefined?{'icon':P[B(0xb6)]}:{}});}return[p,O];}));for(const [p,V]of t){o['set'](p,V),b['set'](p,X['revision'](p));}return o;}function u(I,X){I=I-0xaf;const o=f();let b=o[I];return b;}export async function addDictionaryLookupData(I,X,o){const s=u;if(!o||I['length']===0x0)return I;const b=Object['entries'](X)[s(0xb7)](([t,p])=>{const V=p['dictionary'];return V?[{'field':t,'dictionaryName':V}]:[];});if(b['length']===0x0)return I;const A=await getDictionaryIndexes([...new Set(b[s(0xb8)](({dictionaryName:t})=>t))],o);for(const t of I){for(const {field:p,dictionaryName:V}of b){const O=t[p];t[p+'_data']=O==null?null:A['get'](V)?.['get'](String(O))??null;}}return I;}
@@ -1 +1 @@
1
- export function addFileToken(L,E,c){const r=O;if(!c||L['length']===0x0)return L;const t=Object['entries'](E)[r(0xe5)](([,e])=>e[r(0xe6)]===r(0xe7))['map'](([e])=>e);for(const e of L){for(const B of t){const g=e[B];typeof g==='string'&&g[r(0xe8)]>0x0&&(e[B]=c['create'](g));}}return L;}function O(L,E){L=L-0xe5;const c=Z();let t=c[L];return t;}function Z(){const X=['filter','type','file','length'];Z=function(){return X;};return Z();}
1
+ function u(I,X){I=I-0x162;const o=f();let b=o[I];return b;}export function addFileToken(I,X,o){const V=u;if(!o||I['length']===0x0)return I;const b=Object['entries'](X)['filter'](([,A])=>A[V(0x162)]==='file')[V(0x163)](([A])=>A);for(const A of I){for(const t of b){const p=A[t];typeof p==='string'&&p['length']>0x0&&(A[t]=o['create'](p));}}return I;}function f(){const O=['type','map'];f=function(){return O;};return f();}
@@ -1 +1 @@
1
- import{qi,qt}from'../utils/sql.js';function Z(){const q=['entries','string','number','has','query','SELECT\x20','\x20AS\x20id,\x20','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20','set','field','_data'];Z=function(){return q;};return Z();}const tableLookupCache=new WeakMap();export function clearTableLookupCache(L,E){const c=tableLookupCache['get'](E);if(!c)return;for(const t of c['keys']()){t['startsWith'](L+':')&&c['delete'](t);}}function O(L,E){L=L-0x68;const c=Z();let t=c[L];return t;}export async function addTableLookupData(L,E,c){const W=O;if(!c||L['length']===0x0)return L;const t=tableLookupCache['get'](c)??new Map();tableLookupCache['set'](c,t);const e=Object[W(0x68)](E)['flatMap'](([B,g])=>{const {table:r,value:value='id',text:text='name'}=g['lookup']??{};return r?[{'field':B,'table':r,'value':value,'text':text}]:[];});for(const B of e){const g=new Map();for(const F of L){const I=F[B['field']];(typeof I===W(0x69)||typeof I===W(0x6a))&&g['set'](String(I),I);}const r=B['table']+':'+B['value']+':'+B['text'],X=t['get'](r)??new Map();t['set'](r,X);const j=[...g['entries']()]['filter'](([T])=>!X[W(0x6b)](T))['map'](([,T])=>T);if(j['length']>0x0){const T=await c[W(0x6c)](W(0x6d)+qi(B['value'])+W(0x6e)+qi(B['text'])+W(0x6f)+qt(B['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(B['value'])+'\x20=\x20ANY($1)',[j]);for(const f of T['rows']){X[W(0x70)](String(f['id']),f);}for(const A of j){!X[W(0x6b)](String(A))&&X[W(0x70)](String(A),null);}}for(const G of L){const x=G[B['field']];G[B[W(0x71)]+W(0x72)]=x==null?null:X['get'](String(x))??null;}}return L;}
1
+ import{qi,qt}from'../utils/sql.js';function u(I,X){I=I-0x19a;const o=f();let b=o[I];return b;}const tableLookupCache=new WeakMap();function f(){const Y=['get','delete','set','lookup','table','map','query','SELECT\x20','text','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'];f=function(){return Y;};return f();}export function clearTableLookupCache(I,X){const K=u,o=tableLookupCache[K(0x19a)](X);if(!o)return;for(const b of o['keys']()){b['startsWith'](I+':')&&o[K(0x19b)](b);}}export async function addTableLookupData(I,X,o){const y=u;if(!o||I['length']===0x0)return I;const b=tableLookupCache['get'](o)??new Map();tableLookupCache[y(0x19c)](o,b);const A=Object['entries'](X)['flatMap'](([t,p])=>{const c=y,{table:V,value:value='id',text:text='name'}=p[c(0x19d)]??{};return V?[{'field':t,'table':V,'value':value,'text':text}]:[];});for(const t of A){const p=new Map();for(const M of I){const r=M[t['field']];(typeof r==='string'||typeof r==='number')&&p[y(0x19c)](String(r),r);}const V=t[y(0x19e)]+':'+t['value']+':'+t['text'],O=b['get'](V)??new Map();b[y(0x19c)](V,O);const P=[...p['entries']()]['filter'](([B])=>!O['has'](B))[y(0x19f)](([,B])=>B);if(P['length']>0x0){const B=await o[y(0x1a0)](y(0x1a1)+qi(t['value'])+'\x20AS\x20id,\x20'+qi(t[y(0x1a2)])+y(0x1a3)+qt(t['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(t['value'])+'\x20=\x20ANY($1)',[P]);for(const s of B['rows']){O['set'](String(s['id']),s);}for(const F of P){!O['has'](String(F))&&O[y(0x19c)](String(F),null);}}for(const Z of I){const W=Z[t['field']];Z[t['field']+'_data']=W==null?null:O['get'](String(W))??null;}}return I;}
@@ -1 +1 @@
1
- function Z(){const W=['files','includes','capabilities','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','filePath','size','rows','relations','resource','table','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation'];Z=function(){return W;};return Z();}import{UnsupportedError}from'../../../errors.js';function O(L,E){L=L-0x138;const c=Z();let t=c[L];return t;}import{createCreate}from'./create.js';export function createCreateRelation(L,E){const c=createCreate(L,E);return async function t({name:e,id:B,relation:g,data:r,user:X},j){const x=O,F=j?.['pg']??L['pg'],I=E['get'](e);if(['notes',x(0x138)][x(0x139)](g)&&!I[x(0x13a)]?.['includes'](g))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20capabilities\x20\x22'+g+'\x22');if(g==='notes'){const A=await F['query'](x(0x13b),[e,String(B),r?.['body']]);return A['rows'][0x0];}if(g==='files'){const G=await F['query'](x(0x13c),[e,String(B),r?.[x(0x13d)],r?.[x(0x13e)]??null]);return G[x(0x13f)][0x0];}const T=I[x(0x140)]?.[g];if(!T?.['foreignKey']||!T[x(0x141)]&&!T[x(0x142)])throw new UnsupportedError(x(0x143)+g+x(0x144));if(!r)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+r);if(!T['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+g);r[T['foreignKey']]=B;const f=await c({'name':T['resource'],'data':r??{},'user':X});return f;};}
1
+ import{UnsupportedError}from'../../../errors.js';import{createCreate}from'./create.js';export function createCreateRelation(I,X){const o=createCreate(I,X);return async function b({name:A,id:t,relation:p,data:V,user:O},P){const W=u,M=P?.['pg']??I['pg'],r=X['get'](A);if([W(0xa1),'files'][W(0xa2)](p)&&!r['capabilities']?.['includes'](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20capabilities\x20\x22'+p+'\x22');if(p==='notes'){const F=await M['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[A,String(t),V?.['body']]);return F[W(0xa3)][0x0];}if(p==='files'){const Z=await M['query'](W(0xa4),[A,String(t),V?.['filePath'],V?.['size']??null]);return Z['rows'][0x0];}const B=r[W(0xa5)]?.[p];if(!B?.['foreignKey']||!B['resource']&&!B['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!V)throw new UnsupportedError(W(0xa6)+V);if(!B['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+p);V[B[W(0xa7)]]=t;const s=await o({'name':B['resource'],'data':V??{},'user':O});return s;};}function u(I,X){I=I-0xa1;const o=f();let b=o[I];return b;}function f(){const K=['notes','includes','rows','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','relations','No\x20data\x20provided\x20for\x20relation:\x20','foreignKey'];f=function(){return K;};return f();}
@@ -1 +1 @@
1
- function O(L,E){L=L-0x10b;const c=Z();let t=c[L];return t;}function Z(){const q=['fields','No\x20writable\x20fields','map','join','audit','write','module'];Z=function(){return q;};return Z();}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(L,E){return async function c({name:t,data:e,user:B},g){const W=O,r=E['get'](t);assertOperation(r,'create',B),validateInputData({'resource':r,'data':e});const X=writableData(r,e);r['fields']['created_at']&&X['push'](['created_at',new Date()]);r[W(0x10b)]['created_by']&&X['push'](['created_by',B?.['id']]);if(!X['length'])throw new ValidationError(W(0x10c));const j=X['map'](([G])=>qi(G)),F=X[W(0x10d)]((G,x)=>'$'+(x+0x1)),I=X['map'](([,G])=>G),T=g?.['pg']??L['pg'],f=await T['query']('INSERT\x20INTO\x20'+qt(r['table'])+'\x20('+j[W(0x10e)](',\x20')+')\x20'+('VALUES\x20('+F['join'](',\x20')+')\x20')+'RETURNING\x20*',I),A=f['rows'][0x0];return clearTableLookupCache(r['table'],T),await(g?.[W(0x10f)]??L['audit'])?.[W(0x110)]({'userId':B?.['id'],'module':r[W(0x111)],'resource':r['name'],'resourceId':A[r['key']],'action':'create','fields':Object['keys'](e)}),A;};}
1
+ function u(I,X){I=I-0xb7;const o=f();let b=o[I];return b;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function f(){const y=['create','fields','created_at','created_by','length','RETURNING\x20*','audit','name'];f=function(){return y;};return f();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(I,X){return async function o({name:b,data:A,user:t},p){const K=u,V=X['get'](b);assertOperation(V,K(0xb7),t),validateInputData({'resource':V,'data':A});const O=writableData(V,A);V[K(0xb8)][K(0xb9)]&&O['push'](['created_at',new Date()]);V['fields'][K(0xba)]&&O['push'](['created_by',t?.['id']]);if(!O[K(0xbb)])throw new ValidationError('No\x20writable\x20fields');const P=O['map'](([Z])=>qi(Z)),M=O['map']((Z,W)=>'$'+(W+0x1)),r=O['map'](([,Z])=>Z),B=p?.['pg']??I['pg'],s=await B['query']('INSERT\x20INTO\x20'+qt(V['table'])+'\x20('+P['join'](',\x20')+')\x20'+('VALUES\x20('+M['join'](',\x20')+')\x20')+K(0xbc),r),F=s['rows'][0x0];return clearTableLookupCache(V['table'],B),await(p?.['audit']??I[K(0xbd)])?.['write']({'userId':t?.['id'],'module':V['module'],'resource':V[K(0xbe)],'resourceId':F[V['key']],'action':'create','fields':Object['keys'](A)}),F;};}
@@ -1 +1 @@
1
- import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function Z(){const G=['get','includes','notes','query','relations','resource','foreignKey'];Z=function(){return G;};return Z();}function O(L,E){L=L-0x81;const c=Z();let t=c[L];return t;}export function createDeleteRelation(L,E){const c=createRemove(L,E);return async function t({name:e,id:B,relation:g,relationId:r,user:X},j){const A=O,F=j?.['pg']??L['pg'],I=E[A(0x81)](e);if(['notes','files'][A(0x82)](g)&&!I['capabilities']?.[A(0x82)](g))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20capabilities\x20\x22'+g+'\x22');if(g===A(0x83))return await F['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[r,e,String(B)]),{'success':!![]};if(g==='files')return await F[A(0x84)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[r,e,String(B)]),{'success':!![]};const T=I[A(0x85)]?.[g];if(!T?.[A(0x86)]||!T[A(0x87)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+g+'\x22\x20requires\x20a\x20project/provider\x20implementation');const f=await c({'name':T[A(0x86)],'id':r,'user':X,'where':{'column':T[A(0x87)],'value':B}},j);return{'success':f};};}
1
+ import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function u(I,X){I=I-0xf3;const o=f();let b=o[I];return b;}export function createDeleteRelation(I,X){const o=createRemove(I,X);return async function b({name:A,id:t,relation:p,relationId:V,user:O},P){const F=u,M=P?.['pg']??I['pg'],r=X['get'](A);if(['notes','files']['includes'](p)&&!r['capabilities']?.[F(0xf3)](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20capabilities\x20\x22'+p+'\x22');if(p==='notes')return await M[F(0xf4)]('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[V,A,String(t)]),{'success':!![]};if(p===F(0xf5))return await M['query'](F(0xf6),[V,A,String(t)]),{'success':!![]};const B=r['relations']?.[p];if(!B?.[F(0xf7)]||!B['foreignKey'])throw new UnsupportedError(F(0xf8)+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');const s=await o({'name':B['resource'],'id':V,'user':O,'where':{'column':B['foreignKey'],'value':t}},P);return{'success':s};};}function f(){const Z=['includes','query','files','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','resource','Generic\x20Resource\x20relation\x20\x22'];f=function(){return Z;};return f();}