@opengis/fcore 0.0.28 → 0.0.30

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 (127) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.js +1 -1
  4. package/dist/context.d.ts +2 -0
  5. package/dist/context.d.ts.map +1 -1
  6. package/dist/context.js +1 -1
  7. package/dist/errors.js +1 -1
  8. package/dist/fastify.js +1 -1
  9. package/dist/fcore.d.ts +2 -0
  10. package/dist/fcore.d.ts.map +1 -1
  11. package/dist/fcore.js +1 -1
  12. package/dist/migrations/cli.js +1 -1
  13. package/dist/migrations/runner.js +1 -1
  14. package/dist/modules/auth/adduser-cli.js +1 -1
  15. package/dist/modules/auth/passwd-cli.js +1 -1
  16. package/dist/modules/auth/permission-cli.js +1 -1
  17. package/dist/modules/auth/route.d.ts.map +1 -1
  18. package/dist/modules/auth/route.js +1 -1
  19. package/dist/modules/auth/schema.js +1 -1
  20. package/dist/modules/auth/services/change-password.js +1 -1
  21. package/dist/modules/auth/services/get-current-user.d.ts +2 -2
  22. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  23. package/dist/modules/auth/services/get-current-user.js +1 -1
  24. package/dist/modules/auth/services/registration.js +1 -1
  25. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  26. package/dist/modules/file/mime.js +1 -1
  27. package/dist/modules/file/route.js +1 -1
  28. package/dist/modules/file/schema.js +1 -1
  29. package/dist/modules/file/services/get-file.js +1 -1
  30. package/dist/modules/file/services/resize-file.js +1 -1
  31. package/dist/modules/file/services/upload-file.js +1 -1
  32. package/dist/modules/resource/route.js +1 -1
  33. package/dist/modules/resource/schema.d.ts +3 -2
  34. package/dist/modules/resource/schema.d.ts.map +1 -1
  35. package/dist/modules/resource/schema.js +1 -1
  36. package/dist/modules/resource/services/add-note.js +1 -1
  37. package/dist/modules/resource/services/add-resource-file.js +1 -1
  38. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  39. package/dist/modules/resource/services/create-resource.js +1 -1
  40. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  41. package/dist/modules/resource/services/delete-resource.js +1 -1
  42. package/dist/modules/resource/services/export-resource.js +1 -1
  43. package/dist/modules/resource/services/generate-resource-code.js +1 -1
  44. package/dist/modules/resource/services/get-resource-schema.js +1 -1
  45. package/dist/modules/resource/services/get-resource.d.ts +1 -1
  46. package/dist/modules/resource/services/get-resource.js +1 -1
  47. package/dist/modules/resource/services/list-resource-as-user.js +1 -1
  48. package/dist/modules/resource/services/list-resource-list.js +1 -1
  49. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  50. package/dist/modules/resource/services/list-resources.js +1 -1
  51. package/dist/modules/resource/services/search-resource.js +1 -1
  52. package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
  53. package/dist/modules/resource/services/suggest-resource.js +1 -1
  54. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  55. package/dist/modules/resource/services/update-resource.js +1 -1
  56. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  57. package/dist/modules/system/route.js +1 -1
  58. package/dist/modules/system/schema.js +1 -1
  59. package/dist/modules/system/services/check-system.js +1 -1
  60. package/dist/modules/system/services/get-access.js +1 -1
  61. package/dist/modules/system/services/get-api-list.js +1 -1
  62. package/dist/modules/system/services/get-audit-log.js +1 -1
  63. package/dist/modules/system/services/get-dictionary.js +1 -1
  64. package/dist/modules/system/services/get-resource-access.js +1 -1
  65. package/dist/modules/system/services/get-resource-scopes.js +1 -1
  66. package/dist/modules/system/services/get-system-log.js +1 -1
  67. package/dist/modules/system/services/get-system-settings.js +1 -1
  68. package/dist/modules/system/services/list-dictionaries.js +1 -1
  69. package/dist/modules/system/services/set-access.js +1 -1
  70. package/dist/modules/system/services/set-resource-access.js +1 -1
  71. package/dist/modules/system/services/set-resource-scopes.js +1 -1
  72. package/dist/modules/system/services/update-dictionary.js +1 -1
  73. package/dist/modules/system/services/update-system-settings.js +1 -1
  74. package/dist/modules/utils/require-admin.js +1 -1
  75. package/dist/modules/utils/safe-user.js +1 -1
  76. package/dist/modules/utils/unsupported.js +1 -1
  77. package/dist/plugins/audit/audit.js +1 -1
  78. package/dist/plugins/audit/services/write-audit.js +1 -1
  79. package/dist/plugins/auth/get-user-permissions.js +1 -1
  80. package/dist/plugins/auth/index.d.ts.map +1 -1
  81. package/dist/plugins/auth/index.js +1 -1
  82. package/dist/plugins/auth/verifyUser.js +1 -1
  83. package/dist/plugins/dictionary.js +1 -1
  84. package/dist/plugins/file.js +1 -1
  85. package/dist/plugins/hooks.d.ts +14 -0
  86. package/dist/plugins/hooks.d.ts.map +1 -0
  87. package/dist/plugins/hooks.js +1 -0
  88. package/dist/plugins/index.d.ts +1 -0
  89. package/dist/plugins/index.d.ts.map +1 -1
  90. package/dist/plugins/index.js +1 -1
  91. package/dist/plugins/jwt.js +1 -1
  92. package/dist/plugins/logger/index.js +1 -1
  93. package/dist/plugins/logger/transport.js +1 -1
  94. package/dist/plugins/pg.js +1 -1
  95. package/dist/plugins/redis.js +1 -1
  96. package/dist/plugins/resource/resource.js +1 -1
  97. package/dist/plugins/resource/resource.registry.js +1 -1
  98. package/dist/plugins/resource/resource.types.d.ts +1 -0
  99. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  100. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  101. package/dist/plugins/resource/services/add-file-token.js +1 -1
  102. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  103. package/dist/plugins/resource/services/create-relation.js +1 -1
  104. package/dist/plugins/resource/services/create.js +1 -1
  105. package/dist/plugins/resource/services/delete-relation.js +1 -1
  106. package/dist/plugins/resource/services/delete.js +1 -1
  107. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  108. package/dist/plugins/resource/services/find-one.js +1 -1
  109. package/dist/plugins/resource/services/find-relation.js +1 -1
  110. package/dist/plugins/resource/services/find.js +1 -1
  111. package/dist/plugins/resource/services/get-table-columns.js +1 -1
  112. package/dist/plugins/resource/services/update-relation.js +1 -1
  113. package/dist/plugins/resource/services/update.js +1 -1
  114. package/dist/plugins/resource/utils/auto-index.js +1 -1
  115. package/dist/plugins/resource/utils/fields.js +1 -1
  116. package/dist/plugins/resource/utils/filters.js +1 -1
  117. package/dist/plugins/resource/utils/permissions.js +1 -1
  118. package/dist/plugins/resource/utils/scope.js +1 -1
  119. package/dist/plugins/resource/utils/sort.js +1 -1
  120. package/dist/plugins/resource/utils/sql.js +1 -1
  121. package/dist/plugins/resource/utils/summary.js +1 -1
  122. package/dist/shared/getIP.js +1 -1
  123. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  124. package/migrations/20260903140000_settings_nulls_not_distinct.sql +1 -1
  125. package/migrations/20260905120000_add_user_foreign_keys.sql +15 -0
  126. package/migrations/20260929120000_allow_user_only_role_scopes.sql +1 -1
  127. package/package.json +92 -92
@@ -1 +1 @@
1
- import{fileTypeFromBuffer}from'file-type';import p from'../mime.js';import{randomUUID}from'node:crypto';import{ValidationError}from'../../../errors.js';export async function uploadFile(Z,A){const E=f,I=(Z[E(0x1db)]['name']??randomUUID())['replace'](/[^a-zA-Z0-9._-]/g,'_'),j=new Date(),D=String(j['getFullYear']())['slice'](-0x2),o=String(j['getMonth']()+0x1)['padStart'](0x2,'0'),R=String(j[E(0x1dc)]())['padStart'](0x2,'0'),B=Z[E(0x1db)][E(0x1dd)]??(Z['metadata'][E(0x1de)]?Z['metadata'][E(0x1de)]+'/'+(Z[E(0x1db)]['resourceId']??randomUUID())+'/'+I:null)??'uploads/'+D+'/'+o+'-'+R+'/'+I,H=await Z['file'][E(0x1df)](),e=await fileTypeFromBuffer(H);if(!p['has'](Z['file'][E(0x1e0)])&&(e?.['mime']?!p[E(0x1e1)](e['mime']):!![]))throw new Error('Unsupported\x20file\x20type:\x20'+Z['file']['mimetype']);const g=Boolean(Z['metadata']['resource']&&Z[E(0x1db)][E(0x1e2)]);if(g){const h=await A['pg']['query']('SELECT\x20file_id\x20FROM\x20admin.files\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20AND\x20file_name\x20=\x20$3\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[Z['metadata'][E(0x1de)],String(Z['metadata']['resourceId']),I]);if((h['rowCount']??0x0)>0x0)throw new ValidationError('File\x20with\x20name\x20\x22'+I+E(0x1e3)+Z[E(0x1db)]['resource']+E(0x1e4)+Z['metadata'][E(0x1e2)]+'\x22');}await A[E(0x1e5)][E(0x1e6)](B,H);const N=await A['pg'][E(0x1e7)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20file_type,\x20size,\x20uploaded_name,\x20file_name,\x20ext,\x20status,\x20created_by)\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,\x20$10)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[Z[E(0x1db)][E(0x1de)]??null,Z['metadata'][E(0x1e2)]??null,B,Z[E(0x1e5)]['mimetype'],Z['file']['file']['bytesRead'],Z['metadata'][E(0x1e8)],I,Z['file']['mimetype']['split']('/')['pop']()??null,g?'attached':'pending',Z['user']?.['id']??null]);return{...N['rows'][0x0],'token':A['file'][E(0x1e9)](B)};}function f(p,Z){p=p-0x1db;const A=s();let I=A[p];return I;}function s(){const a=['metadata','getDate','path','resource','toBuffer','mimetype','has','resourceId','\x22\x20already\x20exists\x20for\x20resource\x20\x22','\x22\x20and\x20id\x20\x22','file','put','query','name','create'];s=function(){return a;};return s();}
1
+ import{fileTypeFromBuffer}from'file-type';import i from'../mime.js';import{randomUUID}from'node:crypto';function g(i,E){i=i-0x1b5;const W=T();let M=W[i];return M;}import{ValidationError}from'../../../errors.js';export async function uploadFile(E,W){const y=g,M=(E[y(0x1b5)]['name']??randomUUID())[y(0x1b6)](/[^a-zA-Z0-9._-]/g,'_'),m=new Date(),P=String(m['getFullYear']())['slice'](-0x2),D=String(m['getMonth']()+0x1)[y(0x1b7)](0x2,'0'),x=String(m[y(0x1b8)]())['padStart'](0x2,'0'),Z=E['metadata']['path']??(E[y(0x1b5)]['resource']?E['metadata']['resource']+'/'+(E[y(0x1b5)][y(0x1b9)]??randomUUID())+'/'+M:null)??'uploads/'+P+'/'+D+'-'+x+'/'+M,f=await E['file']['toBuffer'](),b=await fileTypeFromBuffer(f);if(!i['has'](E['file']['mimetype'])&&(b?.['mime']?!i[y(0x1ba)](b['mime']):!![]))throw new Error(y(0x1bb)+E['file']['mimetype']);const K=Boolean(E[y(0x1b5)][y(0x1bc)]&&E['metadata']['resourceId']);if(K){const Q=await W['pg']['query'](y(0x1bd),[E['metadata']['resource'],String(E[y(0x1b5)]['resourceId']),M]);if((Q['rowCount']??0x0)>0x0)throw new ValidationError('File\x20with\x20name\x20\x22'+M+'\x22\x20already\x20exists\x20for\x20resource\x20\x22'+E['metadata']['resource']+'\x22\x20and\x20id\x20\x22'+E['metadata'][y(0x1b9)]+'\x22');}await W['file']['put'](Z,f);const J=await W['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20file_type,\x20size,\x20uploaded_name,\x20file_name,\x20ext,\x20status,\x20created_by)\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,\x20$10)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[E[y(0x1b5)]['resource']??null,E['metadata']['resourceId']??null,Z,E['file']['mimetype'],E[y(0x1be)]['file']['bytesRead'],E['metadata'][y(0x1bf)],M,E[y(0x1be)][y(0x1c0)]['split']('/')['pop']()??null,K?y(0x1c1):'pending',E['user']?.['id']??null]);return{...J['rows'][0x0],'token':W['file']['create'](Z)};}function T(){const s=['metadata','replace','padStart','getDate','resourceId','has','Unsupported\x20file\x20type:\x20','resource','SELECT\x20file_id\x20FROM\x20admin.files\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20AND\x20file_name\x20=\x20$3\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201','file','name','mimetype','attached'];T=function(){return s;};return T();}
@@ -1 +1 @@
1
- import{listResources}from'./services/list-resources.js';import{listResourceAsUser}from'./services/list-resource-as-user.js';import{getResource}from'./services/get-resource.js';import{createResource}from'./services/create-resource.js';function s(){const N=['Search\x20resource','user','query','/api/suggest/:resource/:field','fcore','Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','$resource:read','config','resource','Export\x20resource\x20records','exportResourceQuery','params','Returns\x20the\x20resource\x20variables\x20and\x20nested\x20relation\x20schema.','Generates\x20a\x20code\x20from\x20an\x20explicit\x20template\x20or\x20a\x20field\x20code_template.','/api/resource/:resource/scope/:user','List\x20resource\x20as\x20a\x20user\x20for\x20scope\x20testing','system:access','get','/api/resource/:resource','List\x20resource\x20records','auth','post','Create\x20resource\x20record','$resource:create','resourceIncludeQuery','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','resourceId','body','/api/resource/:resource/:id','Delete\x20resource\x20record','Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','$resource:update','uploadResourceFile','fields','value','Deletes\x20a\x20file\x20linked\x20to\x20a\x20resource\x20record\x20after\x20validating\x20it\x20belongs\x20to\x20this\x20resource\x20and\x20record.','rowCount','file','delete','resourceIdRelation','/api/resource/:resource/:id/:relation','Create\x20resource\x20relation','Updates\x20a\x20related\x20resource\x20record.','resourceIdRelationId'];s=function(){return N;};return s();}import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';import{createResourceRelation}from'./services/create-resource-relation.js';import{updateResourceRelation}from'./services/update-resource-relation.js';import{deleteResourceRelation}from'./services/delete-resource-relation.js';import{searchResource}from'./services/search-resource.js';import{exportResource}from'./services/export-resource.js';import{suggestResource}from'./services/suggest-resource.js';import{listResourceList}from'./services/list-resource-list.js';function f(p,Z){p=p-0x1a2;const A=s();let I=A[p];return I;}import{getResourceSchema}from'./services/get-resource-schema.js';import{generateResourceCode}from'./services/generate-resource-code.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=p=>p['user'];export function resourceRoutes(p){return async Z=>{const H=f;Z['get']('/api/resource/:resource/search',{'schema':{'tags':['fcore','resource'],'summary':H(0x1a2),'description':'Searches\x20records\x20in\x20a\x20registered\x20resource.','access':H(0x1a3),'permissions':['$resource:read'],'params':resourceSchemas['resource']}},async A=>searchResource({...A[H(0x1a4)],...A['params'],'user':user(A)||p['config']?.['auth']?.['user']},p)),Z['get'](H(0x1a5),{'schema':{'tags':[H(0x1a6),'resource'],'summary':'Suggest\x20resource\x20values','description':H(0x1a7),'access':'user','permissions':[H(0x1a8)],'params':resourceSchemas['resourceField'],'querystring':resourceSchemas['suggestQuery']}},async A=>suggestResource({...A['query'],...A['params'],'user':user(A)||p[H(0x1a9)]?.['auth']?.['user']},p)),Z['get']('/api/resource/:resource/export',{'schema':{'tags':[H(0x1a6),H(0x1aa)],'summary':H(0x1ab),'description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':H(0x1a3),'permissions':['$resource:read'],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas[H(0x1ac)]}},async A=>exportResource({...A[H(0x1a4)],...A[H(0x1ad)],'user':user(A)||p['config']?.['auth']?.[H(0x1a3)]},p)),Z['get']('/api/resource/:resource/schema',{'schema':{'tags':['fcore',H(0x1aa)],'summary':'Get\x20resource\x20schema','description':H(0x1ae),'access':'user','permissions':[H(0x1a8)],'params':resourceSchemas[H(0x1aa)]}},async A=>getResourceSchema(A[H(0x1ad)],p)),Z['get']('/api/resource/:resource/code',{'schema':{'tags':['fcore','resource'],'summary':'Generate\x20a\x20resource\x20code','description':H(0x1af),'access':'user','permissions':['$resource:read'],'params':resourceSchemas[H(0x1aa)],'querystring':resourceSchemas['resourceCodeQuery']}},async A=>generateResourceCode({...A['params'],...A[H(0x1a4)]},p)),Z['get'](H(0x1b0),{'schema':{'tags':['fcore','resource'],'summary':H(0x1b1),'description':'Returns\x20resource\x20records\x20using\x20the\x20specified\x20user\x27s\x20permissions\x20and\x20access\x20scopes.\x20Admin\x20only.','access':'admin','permissions':[H(0x1b2)],'params':resourceSchemas['resourceScopeTarget']}},async A=>listResourceAsUser({...A['params'],...A['query'],'requester':user(A)},p)),Z[H(0x1b3)](H(0x1b4),{'schema':{'tags':['fcore',H(0x1aa)],'summary':H(0x1b5),'description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas[H(0x1aa)]}},async A=>listResources({...A['query'],...A[H(0x1ad)],'user':user(A)||p['config']?.[H(0x1b6)]?.['user']},p)),Z[H(0x1b7)](H(0x1b4),{'schema':{'tags':[H(0x1a6),'resource'],'summary':H(0x1b8),'description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':H(0x1a3),'permissions':[H(0x1b9)],'params':resourceSchemas['resource']}},async A=>createResource({...A[H(0x1ad)],'data':A['body'],'user':user(A)||p['config']?.['auth']?.['user']},p)),Z['get']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[H(0x1a8)],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas[H(0x1ba)]}},async A=>getResource({...A['query'],...A[H(0x1ad)],'user':user(A)||p['config']?.['auth']?.[H(0x1a3)]},p)),Z['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20record','description':H(0x1bb),'access':H(0x1a3),'permissions':['$resource:update'],'params':resourceSchemas[H(0x1bc)]}},async A=>updateResource({...A['params'],'patch':A[H(0x1bd)],'user':user(A)||p[H(0x1a9)]?.['auth']?.['user']},p)),Z['delete'](H(0x1be),{'schema':{'tags':['fcore',H(0x1aa)],'summary':H(0x1bf),'description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':H(0x1a3),'permissions':['$resource:delete'],'params':resourceSchemas['resourceId']}},async A=>deleteResource({...A['params'],'user':user(A)||p[H(0x1a9)]?.[H(0x1b6)]?.['user']},p)),Z['post']('/api/resource/:resource/:id/upload',{'schema':{'tags':[H(0x1a6),H(0x1aa)],'summary':'Upload\x20resource\x20file','description':H(0x1c0),'access':'user','permissions':[H(0x1c1)],'params':resourceSchemas[H(0x1c2)]}},async A=>{const e=H,I=await A['file']();if(!I)throw new Error('File\x20is\x20required');const j=A['params']['resource'],D=A['params']['id'];return uploadFile({'file':I,'metadata':{'name':I['filename'],'path':I[e(0x1c3)]['path']?.[e(0x1c4)],'resource':j,'resourceId':D},'user':A['user']},p);}),Z['delete']('/api/resource/:resource/:id/file/:fid',{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20file','description':H(0x1c5),'access':H(0x1a3),'permissions':['$resource:update'],'params':resourceSchemas['resourceIdFileId']}},async A=>{const g=H,{resource:I,id:j,fid:D}=A['params'],o=await p['pg']['query']('SELECT\x20file_path\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3\x20LIMIT\x201',[D,I,String(j)]);if(!o[g(0x1c6)])throw new Error('File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record');const R=o['rows'][0x0]?.['file_path'],B=await p['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[D,I,String(j)]);return await p[g(0x1c7)][g(0x1c8)](R),{'success':(B['rowCount']??0x0)>0x0,'resource':I,'resourceId':j,'fileId':D};}),Z['get']('/api/resource/:resource/list',{'schema':{'tags':['fcore',H(0x1aa)],'summary':'List\x20resource\x20items','description':'Returns\x20resource\x20identifiers\x20and\x20display\x20text,\x20optionally\x20filtered\x20by\x20searchable\x20fields.','access':H(0x1a3),'permissions':['$resource:read'],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceListQuery']}},async A=>listResourceList({...A['params'],...A[H(0x1a4)],'user':user(A)||p['config']?.['auth']?.['user']},p)),Z[H(0x1b3)]('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20relations','description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':H(0x1a3),'params':resourceSchemas[H(0x1c9)],'permissions':['$resource:read']}},async A=>listResourceRelation({...A[H(0x1a4)],...A['params'],'user':user(A)||p['config']?.['auth']?.['user']},p)),Z['post'](H(0x1ca),{'schema':{'tags':[H(0x1a6),'resource'],'summary':H(0x1cb),'description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':H(0x1a3),'permissions':['$resource:create'],'params':resourceSchemas[H(0x1c9)]}},async A=>createResourceRelation({...A['params'],'data':A[H(0x1bd)],'user':user(A)||p[H(0x1a9)]?.['auth']?.[H(0x1a3)]},p)),Z[H(0x1c8)]('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':['$resource:delete'],'params':resourceSchemas['resourceIdRelationId']}},async A=>deleteResourceRelation({...A['params'],'user':user(A)||p[H(0x1a9)]?.['auth']?.['user']},p)),Z['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20relation','description':H(0x1cc),'access':'user','permissions':[H(0x1c1)],'params':resourceSchemas[H(0x1cd)]}},async A=>updateResourceRelation({...A['params'],'data':A[H(0x1bd)],'user':user(A)||p[H(0x1a9)]?.['auth']?.[H(0x1a3)]},p));};}
1
+ function T(){const Q=['user','get','resource','Search\x20resource','/api/suggest/:resource/:field','$resource:read','resourceField','params','auth','fcore','query','Get\x20resource\x20schema','/api/resource/:resource/code','resourceCodeQuery','/api/resource/:resource','List\x20resource\x20records','post','resourceIncludeQuery','put','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','body','config','/api/resource/:resource/:id','$resource:update','file','File\x20is\x20required','path','Deletes\x20a\x20file\x20linked\x20to\x20a\x20resource\x20record\x20after\x20validating\x20it\x20belongs\x20to\x20this\x20resource\x20and\x20record.','SELECT\x20file_path\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3\x20LIMIT\x201','rowCount','File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record','List\x20resource\x20items','Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','$resource:delete','/api/resource/:resource/:id/:relation/:relationId','Updates\x20a\x20related\x20resource\x20record.'];T=function(){return Q;};return T();}const f=g;import{listResources}from'./services/list-resources.js';import{listResourceAsUser}from'./services/list-resource-as-user.js';import{getResource}from'./services/get-resource.js';function g(i,E){i=i-0x178;const W=T();let M=W[i];return M;}import{createResource}from'./services/create-resource.js';import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';import{createResourceRelation}from'./services/create-resource-relation.js';import{updateResourceRelation}from'./services/update-resource-relation.js';import{deleteResourceRelation}from'./services/delete-resource-relation.js';import{searchResource}from'./services/search-resource.js';import{exportResource}from'./services/export-resource.js';import{suggestResource}from'./services/suggest-resource.js';import{listResourceList}from'./services/list-resource-list.js';import{getResourceSchema}from'./services/get-resource-schema.js';import{generateResourceCode}from'./services/generate-resource-code.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=i=>i[f(0x178)];export function resourceRoutes(i){return async E=>{const b=g;E[b(0x179)]('/api/resource/:resource/search',{'schema':{'tags':['fcore',b(0x17a)],'summary':b(0x17b),'description':'Searches\x20records\x20in\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resource']}},async W=>searchResource({...W['query'],...W['params'],'user':user(W)||i['config']?.['auth']?.[b(0x178)]},i)),E['get'](b(0x17c),{'schema':{'tags':['fcore','resource'],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':b(0x178),'permissions':[b(0x17d)],'params':resourceSchemas[b(0x17e)],'querystring':resourceSchemas['suggestQuery']}},async W=>suggestResource({...W['query'],...W[b(0x17f)],'user':user(W)||i['config']?.[b(0x180)]?.[b(0x178)]},i)),E[b(0x179)]('/api/resource/:resource/export',{'schema':{'tags':[b(0x181),'resource'],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[b(0x17d)],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async W=>exportResource({...W[b(0x182)],...W[b(0x17f)],'user':user(W)||i['config']?.[b(0x180)]?.['user']},i)),E[b(0x179)]('/api/resource/:resource/schema',{'schema':{'tags':['fcore','resource'],'summary':b(0x183),'description':'Returns\x20the\x20resource\x20variables\x20and\x20nested\x20relation\x20schema.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resource']}},async W=>getResourceSchema(W[b(0x17f)],i)),E[b(0x179)](b(0x184),{'schema':{'tags':['fcore',b(0x17a)],'summary':'Generate\x20a\x20resource\x20code','description':'Generates\x20a\x20code\x20from\x20an\x20explicit\x20template\x20or\x20a\x20field\x20code_template.','access':b(0x178),'permissions':[b(0x17d)],'params':resourceSchemas['resource'],'querystring':resourceSchemas[b(0x185)]}},async W=>generateResourceCode({...W[b(0x17f)],...W['query']},i)),E['get']('/api/resource/:resource/scope/:user',{'schema':{'tags':['fcore',b(0x17a)],'summary':'List\x20resource\x20as\x20a\x20user\x20for\x20scope\x20testing','description':'Returns\x20resource\x20records\x20using\x20the\x20specified\x20user\x27s\x20permissions\x20and\x20access\x20scopes.\x20Admin\x20only.','access':'admin','permissions':['system:access'],'params':resourceSchemas['resourceScopeTarget']}},async W=>listResourceAsUser({...W['params'],...W['query'],'requester':user(W)},i)),E[b(0x179)](b(0x186),{'schema':{'tags':['fcore',b(0x17a)],'summary':b(0x187),'description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[b(0x17d)],'params':resourceSchemas['resource']}},async W=>listResources({...W['query'],...W['params'],'user':user(W)||i['config']?.['auth']?.['user']},i)),E[b(0x188)]('/api/resource/:resource',{'schema':{'tags':[b(0x181),b(0x17a)],'summary':'Create\x20resource\x20record','description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:create'],'params':resourceSchemas[b(0x17a)]}},async W=>createResource({...W['params'],'data':W['body'],'user':user(W)||i['config']?.['auth']?.['user']},i)),E['get']('/api/resource/:resource/:id',{'schema':{'tags':[b(0x181),'resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas[b(0x189)]}},async W=>getResource({...W[b(0x182)],...W['params'],'user':user(W)||i['config']?.['auth']?.[b(0x178)]},i)),E[b(0x18a)]('/api/resource/:resource/:id',{'schema':{'tags':['fcore',b(0x17a)],'summary':'Update\x20resource\x20record','description':b(0x18b),'access':'user','permissions':['$resource:update'],'params':resourceSchemas['resourceId']}},async W=>updateResource({...W[b(0x17f)],'patch':W[b(0x18c)],'user':user(W)||i[b(0x18d)]?.['auth']?.['user']},i)),E['delete'](b(0x18e),{'schema':{'tags':[b(0x181),'resource'],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':b(0x178),'permissions':['$resource:delete'],'params':resourceSchemas['resourceId']}},async W=>deleteResource({...W['params'],'user':user(W)||i['config']?.['auth']?.[b(0x178)]},i)),E[b(0x188)]('/api/resource/:resource/:id/upload',{'schema':{'tags':['fcore',b(0x17a)],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':[b(0x18f)],'params':resourceSchemas['uploadResourceFile']}},async W=>{const K=b,M=await W[K(0x190)]();if(!M)throw new Error(K(0x191));const m=W[K(0x17f)][K(0x17a)],P=W[K(0x17f)]['id'];return uploadFile({'file':M,'metadata':{'name':M['filename'],'path':M['fields'][K(0x192)]?.['value'],'resource':m,'resourceId':P},'user':W['user']},i);}),E['delete']('/api/resource/:resource/:id/file/:fid',{'schema':{'tags':[b(0x181),'resource'],'summary':'Delete\x20resource\x20file','description':b(0x193),'access':'user','permissions':['$resource:update'],'params':resourceSchemas['resourceIdFileId']}},async W=>{const J=b,{resource:M,id:m,fid:P}=W[J(0x17f)],D=await i['pg']['query'](J(0x194),[P,M,String(m)]);if(!D[J(0x195)])throw new Error(J(0x196));const x=D['rows'][0x0]?.['file_path'],Z=await i['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[P,M,String(m)]);return await i['file']['delete'](x),{'success':(Z['rowCount']??0x0)>0x0,'resource':M,'resourceId':m,'fileId':P};}),E[b(0x179)]('/api/resource/:resource/list',{'schema':{'tags':[b(0x181),'resource'],'summary':b(0x197),'description':'Returns\x20resource\x20identifiers\x20and\x20display\x20text,\x20optionally\x20filtered\x20by\x20searchable\x20fields.','access':b(0x178),'permissions':[b(0x17d)],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceListQuery']}},async W=>listResourceList({...W[b(0x17f)],...W['query'],'user':user(W)||i[b(0x18d)]?.['auth']?.['user']},i)),E[b(0x179)]('/api/resource/:resource/:id/:relation',{'schema':{'tags':[b(0x181),'resource'],'summary':'List\x20resource\x20relations','description':b(0x198),'access':b(0x178),'params':resourceSchemas['resourceIdRelation'],'permissions':[b(0x17d)]}},async W=>listResourceRelation({...W['query'],...W['params'],'user':user(W)||i[b(0x18d)]?.['auth']?.['user']},i)),E['post']('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'Create\x20resource\x20relation','description':b(0x199),'access':b(0x178),'permissions':['$resource:create'],'params':resourceSchemas['resourceIdRelation']}},async W=>createResourceRelation({...W['params'],'data':W['body'],'user':user(W)||i['config']?.[b(0x180)]?.['user']},i)),E['delete']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore',b(0x17a)],'summary':'Delete\x20resource\x20relation','description':b(0x19a),'access':'user','permissions':[b(0x19b)],'params':resourceSchemas['resourceIdRelationId']}},async W=>deleteResourceRelation({...W[b(0x17f)],'user':user(W)||i[b(0x18d)]?.['auth']?.['user']},i)),E['put'](b(0x19c),{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20relation','description':b(0x19d),'access':'user','permissions':['$resource:update'],'params':resourceSchemas['resourceIdRelationId']}},async W=>updateResourceRelation({...W[b(0x17f)],'data':W[b(0x18c)],'user':user(W)||i['config']?.[b(0x180)]?.['user']},i));};}
@@ -31,11 +31,12 @@ export declare const resourceSchemas: {
31
31
  resource: import("@sinclair/typebox").TString;
32
32
  field: import("@sinclair/typebox").TString;
33
33
  }>;
34
- suggestQuery: import("@sinclair/typebox").TObject<{
34
+ suggestQuery: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
35
35
  q: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
36
36
  search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
37
+ filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
37
38
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
38
- }>;
39
+ }>, import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>]>;
39
40
  resourceListQuery: import("@sinclair/typebox").TObject<{
40
41
  search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
41
42
  limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;QACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB;CACF;AAED,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,eAAe;IAC1B,cAAc;;;IACd,QAAQ;;;IACR,mBAAmB;;;;IACnB,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;IAKZ,iBAAiB;;;;IAIjB,iBAAiB;;;;;IAKjB,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,gBAAgB;;;;;IAKhB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;;CASpB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;QACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB;CACF;AAED,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAOnD,eAAO,MAAM,eAAe;IAC1B,cAAc;;;IACd,QAAQ;;;IACR,mBAAmB;;;;IACnB,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;;IASZ,iBAAiB;;;;IAIjB,iBAAiB;;;;;IAKjB,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,gBAAgB;;;;;IAKhB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;;CASpB,CAAC"}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x15b;const A=s();let I=A[p];return I;}function s(){const Z=['String','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Integer','Optional','Array'];s=function(){return Z;};return s();}const p=f;import{Type}from'@sinclair/typebox';export const identifier=Type[p(0x15b)]({'minLength':0x1,'maxLength':0x80,'pattern':p(0x15c)});export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type[p(0x15d)]({'resource':identifier}),'resourceScopeTarget':Type['Object']({'resource':identifier,'user':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type['Optional'](Type['String']()),'search':Type['Optional'](Type[p(0x15b)]()),'limit':Type['Optional'](Type[p(0x15e)]({'minimum':0x1,'maximum':0xc8}))}),'resourceListQuery':Type['Object']({'search':Type['Optional'](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type['Object']({'id':Type[p(0x15f)](Type[p(0x15b)]({'minLength':0x1,'maxLength':0x80})),'field':Type[p(0x15f)](identifier),'template':Type['Optional'](Type['String']({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type['Object']({'include':Type['Optional'](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'resourceIdFileId':Type['Object']({'resource':identifier,'id':identifier,'fid':identifier}),'uploadResourceFile':Type[p(0x15d)]({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type['Any'](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type[p(0x15d)]({'filter':Type['Optional'](Type['Record'](Type[p(0x15b)](),Type['Unknown']())),'sort':Type[p(0x15f)](Type['Array'](Type['String']({'minLength':0x1}))),'search':Type[p(0x15f)](Type['String']()),'scope':Type['Optional'](Type['String']()),'limit':Type[p(0x15f)](Type[p(0x15e)]({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type['Integer']({'minimum':0x0})),'fields':Type[p(0x15f)](Type[p(0x160)](identifier))})};
1
+ function T(){const E=['^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Record','Object','String','Optional','Integer'];T=function(){return E;};return T();}function g(i,E){i=i-0x1c5;const W=T();let M=W[i];return M;}const i=g;import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':i(0x1c5)});const flatFilterQuery=Type[i(0x1c6)](Type['String']({'pattern':'^filter\x5c[[^\x5c]]+\x5c](?:\x5c[[^\x5c]]+\x5c])?$'}),Type['Unknown']());export const resourceSchemas={'dictionaryName':Type[i(0x1c7)]({'name':identifier}),'resource':Type['Object']({'resource':identifier}),'resourceScopeTarget':Type[i(0x1c7)]({'resource':identifier,'user':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type[i(0x1c7)]({'resource':identifier,'field':identifier}),'suggestQuery':Type['Intersect']([Type['Object']({'q':Type['Optional'](Type[i(0x1c8)]()),'search':Type['Optional'](Type[i(0x1c8)]()),'filter':Type['Optional'](Type['Record'](Type[i(0x1c8)](),Type['Unknown']())),'limit':Type[i(0x1c9)](Type[i(0x1ca)]({'minimum':0x1,'maximum':0xc8}))}),flatFilterQuery]),'resourceListQuery':Type['Object']({'search':Type['Optional'](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type['Object']({'id':Type[i(0x1c9)](Type['String']({'minLength':0x1,'maxLength':0x80})),'field':Type['Optional'](identifier),'template':Type['Optional'](Type[i(0x1c8)]({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[i(0x1c7)]({'include':Type['Optional'](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'resourceIdFileId':Type['Object']({'resource':identifier,'id':identifier,'fid':identifier}),'uploadResourceFile':Type[i(0x1c7)]({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type[i(0x1c7)]({'file':Type['Any'](),'fileName':Type[i(0x1c8)]({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type[i(0x1c9)](Type['Record'](Type['String'](),Type['Unknown']())),'sort':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1}))),'search':Type['Optional'](Type[i(0x1c8)]()),'scope':Type[i(0x1c9)](Type['String']()),'limit':Type[i(0x1c9)](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type[i(0x1c9)](Type[i(0x1ca)]({'minimum':0x0})),'fields':Type['Optional'](Type['Array'](identifier))})};
@@ -1 +1 @@
1
- export async function addNote(p,Z){const A=await Z['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[p['resource'],String(p['id']),p['body']]);return A['rows'][0x0];}
1
+ function T(){const m=['INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','rows'];T=function(){return m;};return T();}function g(i,E){i=i-0x1c2;const W=T();let M=W[i];return M;}export async function addNote(i,E){const M=g,W=await E['pg']['query'](M(0x1c2),[i['resource'],String(i['id']),i['body']]);return W[M(0x1c3)][0x0];}
@@ -1 +1 @@
1
- export async function addResourceFile(p,Z){const I=f,A=await Z['pg'][I(0xe1)]('\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\x20\x20',[p[I(0xe2)],String(p['id']),p[I(0xe3)],p['size']??null]);return A['rows'][0x0];}function f(p,Z){p=p-0xe1;const A=s();let I=A[p];return I;}function s(){const j=['query','resource','filePath'];s=function(){return j;};return s();}
1
+ export async function addResourceFile(i,E){const M=g,W=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\x20\x20',[i['resource'],String(i['id']),i['filePath'],i['size']??null]);return W[M(0x1a8)][0x0];}function g(i,E){i=i-0x1a8;const W=T();let M=W[i];return M;}function T(){const m=['rows'];T=function(){return m;};return T();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x1c8;const A=s();let I=A[p];return I;}export async function createResourceRelation(p,Z){const R=f,{resource:A,id:I,relation:j,data:D,user:o}=p;return Z[R(0x1c8)][R(0x1c9)]({'name':A,'id':I,'relation':j,'data':D,'user':o});}function s(){const B=['resource','createRelation'];s=function(){return B;};return s();}
1
+ function g(i,E){i=i-0x116;const W=T();let M=W[i];return M;}function T(){const Z=['createRelation'];T=function(){return Z;};return T();}export async function createResourceRelation(i,E){const x=g,{resource:W,id:M,relation:m,data:P,user:D}=i;return E['resource'][x(0x116)]({'name':W,'id':M,'relation':m,'data':P,'user':D});}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0xae;var A=s();var I=A[p];return I;}export async function createResource(p,Z){var A=f;return Z[A(0xae)]['create']({'name':p[A(0xae)],'data':p['data'],'user':p['user']});}function s(){var I=['resource'];s=function(){return I;};return s();}
1
+ export async function createResource(i,E){var W=g;return E['resource']['create']({'name':i[W(0x1ac)],'data':i['data'],'user':i['user']});}function g(i,E){i=i-0x1ac;var W=T();var M=W[i];return M;}function T(){var M=['resource'];T=function(){return M;};return T();}
@@ -1 +1 @@
1
- export async function deleteResourceRelation(p,Z){const {resource:A,id:I,relation:j,relationId:D}=p;return Z['resource']['deleteRelation']({'name':A,'id':I,'relation':j,'relationId':D});}
1
+ function g(i,E){i=i-0x1a1;const W=T();let M=W[i];return M;}export async function deleteResourceRelation(i,E){const D=g,{resource:W,id:M,relation:m,relationId:P}=i;return E['resource'][D(0x1a1)]({'name':W,'id':M,'relation':m,'relationId':P});}function T(){const x=['deleteRelation'];T=function(){return x;};return T();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x13b;var A=s();var I=A[p];return I;}function s(){var I=['resource'];s=function(){return I;};return s();}export async function deleteResource(p,Z){var A=f;return Z['resource']['delete']({'name':p[A(0x13b)],'id':p['id'],'user':p['user']});}
1
+ export async function deleteResource(i,E){var W=g;return E[W(0x195)]['delete']({'name':i['resource'],'id':i['id'],'user':i['user']});}function g(i,E){i=i-0x195;var W=T();var M=W[i];return M;}function T(){var M=['resource'];T=function(){return M;};return T();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x8e;const A=s();let I=A[p];return I;}function s(){const j=['resource','limit','offset','rows'];s=function(){return j;};return s();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(p,Z){const I=f,A=await Z[I(0x8e)]['find']({'name':p[I(0x8e)],'query':{'filter':parseFilterQuery(p),'sort':p['sort'],'search':p['search'],'limit':p[I(0x8f)],'offset':p[I(0x90)],'fields':p['fields']},'user':p['user']});return A[I(0x91)];}
1
+ function g(i,E){i=i-0x1ed;const W=T();let M=W[i];return M;}function T(){const m=['resource','sort','search','limit','offset','user','rows'];T=function(){return m;};return T();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(i,E){const M=g,W=await E[M(0x1ed)]['find']({'name':i['resource'],'query':{'filter':parseFilterQuery(i),'sort':i[M(0x1ee)],'search':i[M(0x1ef)],'limit':i[M(0x1f0)],'offset':i[M(0x1f1)],'fields':i['fields']},'user':i[M(0x1f2)]});return W[M(0x1f3)];}
@@ -1 +1 @@
1
- function s(){const V=['key','column','query','SELECT\x20*\x20FROM\x20','table','where','\x20<>\x20$','length','\x20AND\x20','created_at','SELECT\x20count(*)::int\x20+\x201\x20AS\x20num,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20','\x20>=\x20',')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20','\x20t\x20','rows','mnum','num','field','code_template','has','resource','set'];s=function(){return V;};return s();}function f(p,Z){p=p-0xfb;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function relationValue(p,Z,A){const I=Z['fields'][A]?.['column']??A;return p[I]??p[A];}async function resolvePath(p,Z,A,I){const K=f,[j,...D]=p['split']('.');if(!j)return undefined;const o=A['relations']?.[j];if(!o||!D['length']||!o['resource'])return relationValue(Z,A,p);const R=I['resource']['get'](o['resource']),B=R[K(0xfb)];let H,e;if(o['localKey'])H=relationValue(Z,A,o['localKey']),e=B;else{if(o['foreignKey'])H=relationValue(Z,A,A['key']),e=o['foreignKey'];else return undefined;}if(H===null||H===undefined)return undefined;const g=R['fields'][e]?.[K(0xfc)]??e,N=await I['pg'][K(0xfd)](K(0xfe)+qt(R[K(0xff)])+'\x20t\x20WHERE\x20t.'+qi(g)+'\x20=\x20$1'+(o['where']?'\x20AND\x20('+o['where']+')':'')+'\x20LIMIT\x201',[H]),h=N['rows'][0x0];if(!h)return undefined;const E=D[0x0];if(!E)return undefined;if(D['length']===0x1)return relationValue(h,R,E);return resolvePath(D['join']('.'),h,R,I);}async function countValues(p,Z,A,I){const Q=f,j=[],D=p['where']?['('+p[Q(0x100)]+')']:[];Z!==undefined&&(j['push'](Z),D['push']('t.'+qi(p[Q(0xfb)])+Q(0x101)+j['length']));const o=D[Q(0x102)]?'WHERE\x20'+D['join'](Q(0x103)):'',R=p['fields'][Q(0x104)],B=R?'t.'+qi(R['column']??'created_at'):undefined,H=new Date(I['getFullYear'](),0x0,0x1),e=new Date(I['getFullYear'](),I['getMonth'](),0x1);if(B){j['push'](H,e);const h='$'+(j['length']-0x1),E='$'+j['length'],a=await A['pg']['query'](Q(0x105)+B+Q(0x106)+h+Q(0x107)+B+'\x20>=\x20'+E+')::int\x20+\x201\x20AS\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(p['table'])+Q(0x108)+o,j),X=a[Q(0x109)][0x0];return{'num':Number(X?.['num']??0x1),'ynum':Number(X?.['ynum']??0x1),'mnum':Number(X?.[Q(0x10a)]??0x1)};}const g=await A['pg']['query']('SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20'+qt(p['table'])+'\x20t\x20'+o,j),N=Number(g['rows'][0x0]?.[Q(0x10b)]??0x1);return{'num':N,'ynum':N,'mnum':N};}export async function generateResourceCode(p,Z){const G=f,A=Z['resource']['get'](p['resource']);if(p['field']&&!A['fields'][p['field']])throw new ValidationError('Unknown\x20resource\x20field:\x20'+p[G(0x10c)]);const I=p['template']??(p['field']?A['fields'][p['field']]?.[G(0x10d)]:undefined);if(!I)return{'resource':A['name'],...p['id']!==undefined?{'id':p['id']}:{},...p['field']?{'field':p[G(0x10c)]}:{},'template':null,'code':null};const j=new Date(),D=await countValues(A,p['id'],Z,j);let o={};if(p['id']!==undefined){const e=await Z['pg']['query'](G(0xfe)+qt(A[G(0xff)])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(A['key'])+'\x20=\x20$1'+(A['where']?'\x20AND\x20('+A[G(0x100)]+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[p['id']]);o=e[G(0x109)][0x0]??{};}const R=[...I['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],B=new Map();for(const g of R){const N=g[0x1];if(!N||B[G(0x10e)](g[0x0]))continue;const h=Number(g[0x2]??0x0);let E;switch(N){case G(0x10b):E=D['num'];break;case'ynum':E=D['ynum'];break;case G(0x10a):E=D['mnum'];break;case'yyyy':E=String(j['getFullYear']());break;case'yy':E=String(j['getFullYear']())['slice'](-0x2);break;case'mm':E=String(j['getMonth']()+0x1)['padStart'](0x2,'0');break;case'dd':E=String(j['getDate']())['padStart'](0x2,'0');break;case G(0x10f):E=A['name'];break;case'resource_id':E=p['id'];break;default:E=p['id']===undefined?undefined:await resolvePath(N,o,A,Z);}if(E===null||E===undefined||E==='')throw new ValidationError('Cannot\x20resolve\x20code\x20template\x20variable:\x20{'+N+'}');const a=String(E);B[G(0x110)](g[0x0],h&&/^\d+$/['test'](a)?a['padStart'](h,'0'):a);}const H=I['replace'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,X=>B['get'](X)??X);return{'resource':A['name'],...p['id']!==undefined?{'id':p['id']}:{},...p['field']?{'field':p['field']}:{},'template':I,'code':H};}
1
+ function T(){const p=['split','relations','get','key','fields','\x20=\x20$1','\x20AND\x20(','where','\x20<>\x20$','getFullYear','push','length','query','\x20>=\x20','\x20t\x20','ynum','mnum','SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20','resource','field','code_template','rows','slice','padStart'];T=function(){return p;};return T();}import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function relationValue(i,E,W){const M=E['fields'][W]?.['column']??W;return i[M]??i[W];}async function resolvePath(i,E,W,M){const r=g,[m,...P]=i[r(0x167)]('.');if(!m)return undefined;const D=W[r(0x168)]?.[m];if(!D||!P['length']||!D['resource'])return relationValue(E,W,i);const x=M['resource'][r(0x169)](D['resource']),Z=x[r(0x16a)];let f,b;if(D['localKey'])f=relationValue(E,W,D['localKey']),b=Z;else{if(D['foreignKey'])f=relationValue(E,W,W[r(0x16a)]),b=D['foreignKey'];else return undefined;}if(f===null||f===undefined)return undefined;const K=x[r(0x16b)][b]?.['column']??b,J=await M['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(x['table'])+'\x20t\x20WHERE\x20t.'+qi(K)+r(0x16c)+(D['where']?r(0x16d)+D['where']+')':'')+'\x20LIMIT\x201',[f]),Q=J['rows'][0x0];if(!Q)return undefined;const y=P[0x0];if(!y)return undefined;if(P['length']===0x1)return relationValue(Q,x,y);return resolvePath(P['join']('.'),Q,x,M);}async function countValues(i,E,W,M){const G=g,m=[],P=i['where']?['('+i[G(0x16e)]+')']:[];E!==undefined&&(m['push'](E),P['push']('t.'+qi(i['key'])+G(0x16f)+m['length']));const D=P['length']?'WHERE\x20'+P['join']('\x20AND\x20'):'',x=i[G(0x16b)]['created_at'],Z=x?'t.'+qi(x['column']??'created_at'):undefined,f=new Date(M['getFullYear'](),0x0,0x1),b=new Date(M[G(0x170)](),M['getMonth'](),0x1);if(Z){m[G(0x171)](f,b);const Q='$'+(m[G(0x172)]-0x1),y='$'+m[G(0x172)],s=await W['pg'][G(0x173)]('SELECT\x20count(*)::int\x20+\x201\x20AS\x20num,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+Z+'\x20>=\x20'+Q+')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+Z+G(0x174)+y+')::int\x20+\x201\x20AS\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(i['table'])+G(0x175)+D,m),o=s['rows'][0x0];return{'num':Number(o?.['num']??0x1),'ynum':Number(o?.[G(0x176)]??0x1),'mnum':Number(o?.[G(0x177)]??0x1)};}const K=await W['pg']['query'](G(0x178)+qt(i['table'])+'\x20t\x20'+D,m),J=Number(K['rows'][0x0]?.['num']??0x1);return{'num':J,'ynum':J,'mnum':J};}function g(i,E){i=i-0x167;const W=T();let M=W[i];return M;}export async function generateResourceCode(i,E){const S=g,W=E[S(0x179)]['get'](i['resource']);if(i['field']&&!W[S(0x16b)][i['field']])throw new ValidationError('Unknown\x20resource\x20field:\x20'+i[S(0x17a)]);const M=i['template']??(i[S(0x17a)]?W[S(0x16b)][i['field']]?.[S(0x17b)]:undefined);if(!M)return{'resource':W['name'],...i['id']!==undefined?{'id':i['id']}:{},...i[S(0x17a)]?{'field':i['field']}:{},'template':null,'code':null};const m=new Date(),P=await countValues(W,i['id'],E,m);let D={};if(i['id']!==undefined){const b=await E['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(W['table'])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(W[S(0x16a)])+'\x20=\x20$1'+(W['where']?'\x20AND\x20('+W['where']+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[i['id']]);D=b[S(0x17c)][0x0]??{};}const x=[...M['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],Z=new Map();for(const K of x){const J=K[0x1];if(!J||Z['has'](K[0x0]))continue;const Q=Number(K[0x2]??0x0);let y;switch(J){case'num':y=P['num'];break;case'ynum':y=P['ynum'];break;case'mnum':y=P['mnum'];break;case'yyyy':y=String(m['getFullYear']());break;case'yy':y=String(m[S(0x170)]())[S(0x17d)](-0x2);break;case'mm':y=String(m['getMonth']()+0x1)['padStart'](0x2,'0');break;case'dd':y=String(m['getDate']())[S(0x17e)](0x2,'0');break;case S(0x179):y=W['name'];break;case'resource_id':y=i['id'];break;default:y=i['id']===undefined?undefined:await resolvePath(J,D,W,E);}if(y===null||y===undefined||y==='')throw new ValidationError('Cannot\x20resolve\x20code\x20template\x20variable:\x20{'+J+'}');const s=String(y);Z['set'](K[0x0],Q&&/^\d+$/['test'](s)?s[S(0x17e)](Q,'0'):s);}const f=M['replace'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,o=>Z['get'](o)??o);return{'resource':W['name'],...i['id']!==undefined?{'id':i['id']}:{},...i['field']?{'field':i['field']}:{},'template':M,'code':f};}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0xf0;const A=s();let I=A[p];return I;}function s(){const K=['geometry','string','add','name','fields','read','resource','get','type','array','title'];s=function(){return K;};return s();}function variableType(p){const E=f;switch(p){case'number':case'integer':return'number';case'boolean':return'boolean';case'json':case E(0xf0):case'geom':return'object';default:return E(0xf1);}}function buildVariables(p,Z,A='',I=new Set()){const a=f,j=new Set(I)[a(0xf2)](p[a(0xf3)]),D=[];for(const [o,R]of Object['entries'](p[a(0xf4)])){if(R[a(0xf5)]===![]||R['readable']===![])continue;D['push']({'key':o,'path':A?A+'.'+o:o,'type':variableType(R['type'])});}for(const [B,H]of Object['entries'](p['relations']??{})){if(!H['resource']||!Z[a(0xf6)]['has'](H['resource']))continue;const e=Z['resource'][a(0xf7)](H['resource']),g=A?A+'.'+B:B,N=H[a(0xf8)]==='many',h={'key':B,'path':g,'type':N?a(0xf9):'object','resource':H['resource'],'variables':j['has'](e['name'])?[]:buildVariables(e,Z,g,j)};D['push'](h);}return D;}export function getResourceSchema(p,Z){const X=f,A=Z[X(0xf6)]['get'](p['resource']);return{'resource':A['name'],...A['title']?{'title':A[X(0xfa)]}:{},'variables':buildVariables(A,Z)};}
1
+ function T(){const r=['number','json','string','name','entries','read','resource','type','object','push','get'];T=function(){return r;};return T();}function g(i,E){i=i-0xfa;const W=T();let M=W[i];return M;}function variableType(i){const y=g;switch(i){case y(0xfa):case'integer':return y(0xfa);case'boolean':return'boolean';case y(0xfb):case'geometry':case'geom':return'object';default:return y(0xfc);}}function buildVariables(i,E,W='',M=new Set()){const s=g,m=new Set(M)['add'](i[s(0xfd)]),P=[];for(const [D,x]of Object[s(0xfe)](i['fields'])){if(x[s(0xff)]===![]||x['readable']===![])continue;P['push']({'key':D,'path':W?W+'.'+D:D,'type':variableType(x['type'])});}for(const [Z,f]of Object['entries'](i['relations']??{})){if(!f[s(0x100)]||!E['resource']['has'](f[s(0x100)]))continue;const b=E['resource']['get'](f[s(0x100)]),K=W?W+'.'+Z:Z,J=f[s(0x101)]==='many',Q={'key':Z,'path':K,'type':J?'array':s(0x102),'resource':f[s(0x100)],'variables':m['has'](b['name'])?[]:buildVariables(b,E,K,m)};P[s(0x103)](Q);}return P;}export function getResourceSchema(i,E){const o=g,W=E['resource'][o(0x104)](i['resource']);return{'resource':W['name'],...W['title']?{'title':W['title']}:{},'variables':buildVariables(W,E)};}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Implements the get resource application service for its module.
3
3
  */
4
- import type { AppContext } from '../../../context.js';
4
+ import type { AppContext } from "../../../context.js";
5
5
  export declare function getResource(params: any, ctx: AppContext): Promise<any>;
6
6
  //# sourceMappingURL=get-resource.d.ts.map
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x10f;var A=s();var I=A[p];return I;}function s(){var I=['findOne','resource'];s=function(){return I;};return s();}export async function getResource(p,Z){var A=f;return Z['resource'][A(0x10f)]({'name':p[A(0x110)],'id':p['id'],'query':{'include':p['include']},'user':p['user']});}
1
+ export async function getResource(i,E){var W=g;return E['resource'][W(0x113)]({'name':i[W(0x114)],'id':i['id'],'query':{'include':i[W(0x115)],'scope':i['scope']},'user':i[W(0x116)]});}function g(i,E){i=i-0x113;var W=T();var M=W[i];return M;}function T(){var M=['findOne','resource','include','user'];T=function(){return M;};return T();}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';function s(){const B=['query','user','User\x20not\x20found:\x20','scope','resource'];s=function(){return B;};return s();}function f(p,Z){p=p-0x15f;const A=s();let I=A[p];return I;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';export async function listResourceAsUser(p,Z){const R=f;if(p['requester']?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const A=await Z['pg'][R(0x15f)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[p[R(0x160)]]),I=A['rows'][0x0];if(!I)throw new NotFoundError(R(0x161)+p['user']);const j={'id':I['uid'],'type':I['type'],'permissions':await getUserPermissions(I['uid'],Z)},[D,o]=await Promise['all']([Z['resource']['find']({'name':p['resource'],'query':{'filter':parseFilterQuery(p),'sort':p['sort'],'search':p['search'],'include':p['include'],'scope':p[R(0x162)],'limit':p['limit'],'offset':p['offset']??(p['page']?Math['max'](Number(p['page'])-0x1,0x0):0x0)*Number(p['limit']??0x14)},'user':j}),getUserResourceScopes(j['id'],p[R(0x163)],Z['pg'])]);return{...D,'scopes':o};}
1
+ function g(i,E){i=i-0x180;const W=T();let M=W[i];return M;}function T(){const Z=['type','query','SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201','User\x20not\x20found:\x20','user','resource','include','offset','page'];T=function(){return Z;};return T();}import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';export async function listResourceAsUser(i,E){const x=g;if(i['requester']?.[x(0x180)]!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const W=await E['pg'][x(0x181)](x(0x182),[i['user']]),M=W['rows'][0x0];if(!M)throw new NotFoundError(x(0x183)+i[x(0x184)]);const m={'id':M['uid'],'type':M['type'],'permissions':await getUserPermissions(M['uid'],E)},[P,D]=await Promise['all']([E[x(0x185)]['find']({'name':i['resource'],'query':{'filter':parseFilterQuery(i),'sort':i['sort'],'search':i['search'],'include':i[x(0x186)],'scope':i['scope'],'limit':i['limit'],'offset':i[x(0x187)]??(i[x(0x188)]?Math['max'](Number(i[x(0x188)])-0x1,0x0):0x0)*Number(i['limit']??0x14)},'user':m}),getUserResourceScopes(m['id'],i['resource'],E['pg'])]);return{...P,'scopes':D};}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x79;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(p,Z){const a=f;if(Z!==p['key']&&!p['fields'][Z])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+Z);const A=p[a(0x79)][Z]?.[a(0x7a)]??Z;return A['split']('.')['map'](I=>quoteIdentifier(I))[a(0x7b)]('.');}function displayExpression(p){const X=f,Z=p[X(0x7c)];if(!Z||Array['isArray'](Z)&&Z[X(0x7d)]===0x0)throw new ValidationError(X(0x7e)+p['name']);if(Array['isArray'](Z))return X(0x7f)+Z[X(0x80)](D=>X(0x81)+columnExpression(p,D)+X(0x82))['join'](',\x20')+')';const A=[],I=/\{([^{}]+)\}/g;let j=0x0;for(const D of Z['matchAll'](I)){const o=D[X(0x83)]??0x0,R=D[0x1];if(!R)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);o>j&&A['push']('\x27'+Z[X(0x84)](j,o)['replace'](/'/g,'\x27\x27')+'\x27'),A['push']('COALESCE('+columnExpression(p,R)+'::text,\x20\x27\x27)'),j=o+D[0x0]['length'];}j<Z['length']&&A[X(0x85)]('\x27'+Z[X(0x84)](j)['replace'](/'/g,'\x27\x27')+'\x27');if(A[X(0x7d)]===0x0)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);return'concat('+A['join'](',\x20')+')';}export async function listResourceList(p,Z){const K=f,A=Date['now'](),I=Z['resource']['get'](p['resource']);assertOperation(I,K(0x86),p['user']);const j=p['search']??'',D=Math['min'](Math['max'](Number(p['limit']??0x14),0x1),0xc8),o=I['searchable']??Object['entries'](I[K(0x79)])['filter'](([,h])=>h['searchable'])[K(0x80)](([h])=>h);if(j&&o[K(0x7d)]===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+I['name']);const R=displayExpression(I),B=[],H=[];if(I['where'])B[K(0x85)]('('+I['where']+')');if(j){const h=o[K(0x80)](E=>columnExpression(I,E)+K(0x87));B['push']('('+h[K(0x7b)]('\x20OR\x20')+')'),H['push']('%'+j+'%');}H[K(0x85)](D);const e=B[K(0x7d)]?'WHERE\x20'+B['join'](K(0x88)):'',g=I['joins']?.['map'](E=>E[K(0x89)])[K(0x7b)]('\x20')??'',N=await Z['pg']['query']('SELECT\x20'+quoteIdentifier(I[K(0x8a)])+'\x20AS\x20id,\x20'+R+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(I[K(0x8b)])+'\x20t\x20'+g+K(0x8c)+e+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+H['length'],H);return{'search':j,'limit':D,'count':N[K(0x8d)][K(0x7d)],'time':Date['now']()-A,'data':N[K(0x8d)]};}function s(){const Q=['fields','column','join','display','length','Resource\x20has\x20no\x20display\x20fields:\x20','concat_ws(\x27\x20\x27,\x20','map','COALESCE(','::text,\x20\x27\x27)','index','slice','push','read','::text\x20ILIKE\x20$1','\x20AND\x20','sql','key','table','\x0a\x20\x20\x20\x20\x20','rows'];s=function(){return Q;};return s();}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';function T(){const G=['Unknown\x20display/search\x20field:\x20','column','Resource\x20has\x20no\x20display\x20fields:\x20','concat_ws(\x27\x20\x27,\x20','map','index','push','length','slice','Invalid\x20display\x20template\x20for\x20resource:\x20','name','concat(','resource','get','fields','searchable','::text\x20ILIKE\x20$1','join','joins','query','key','\x20AS\x20id,\x20','table','\x0a\x20\x20\x20\x20\x20','\x0a\x20\x20\x20\x20\x20LIMIT\x20$','rows','now'];T=function(){return G;};return T();}function g(i,E){i=i-0xa2;const W=T();let M=W[i];return M;}import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(i,E){const s=g;if(E!==i['key']&&!i['fields'][E])throw new ValidationError(s(0xa2)+E);const W=i['fields'][E]?.[s(0xa3)]??E;return W['split']('.')['map'](M=>quoteIdentifier(M))['join']('.');}function displayExpression(i){const o=g,E=i['display'];if(!E||Array['isArray'](E)&&E['length']===0x0)throw new ValidationError(o(0xa4)+i['name']);if(Array['isArray'](E))return o(0xa5)+E[o(0xa6)](P=>'COALESCE('+columnExpression(i,P)+'::text,\x20\x27\x27)')['join'](',\x20')+')';const W=[],M=/\{([^{}]+)\}/g;let m=0x0;for(const P of E['matchAll'](M)){const D=P[o(0xa7)]??0x0,x=P[0x1];if(!x)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+i['name']);D>m&&W['push']('\x27'+E['slice'](m,D)['replace'](/'/g,'\x27\x27')+'\x27'),W[o(0xa8)]('COALESCE('+columnExpression(i,x)+'::text,\x20\x27\x27)'),m=D+P[0x0][o(0xa9)];}m<E[o(0xa9)]&&W['push']('\x27'+E[o(0xaa)](m)['replace'](/'/g,'\x27\x27')+'\x27');if(W[o(0xa9)]===0x0)throw new ValidationError(o(0xab)+i[o(0xac)]);return o(0xad)+W['join'](',\x20')+')';}export async function listResourceList(i,E){const r=g,W=Date['now'](),M=E[r(0xae)][r(0xaf)](i[r(0xae)]);assertOperation(M,'read',i['user']);const m=i['search']??'',P=Math['min'](Math['max'](Number(i['limit']??0x14),0x1),0xc8),D=M['searchable']??Object['entries'](M[r(0xb0)])['filter'](([,Q])=>Q[r(0xb1)])['map'](([Q])=>Q);if(m&&D['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+M[r(0xac)]);const x=displayExpression(M),Z=[],f=[];if(M['where'])Z['push']('('+M['where']+')');if(m){const Q=D['map'](y=>columnExpression(M,y)+r(0xb2));Z['push']('('+Q[r(0xb3)]('\x20OR\x20')+')'),f[r(0xa8)]('%'+m+'%');}f[r(0xa8)](P);const b=Z[r(0xa9)]?'WHERE\x20'+Z[r(0xb3)]('\x20AND\x20'):'',K=M[r(0xb4)]?.[r(0xa6)](y=>y['sql'])['join']('\x20')??'',J=await E['pg'][r(0xb5)]('SELECT\x20'+quoteIdentifier(M[r(0xb6)])+r(0xb7)+x+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(M[r(0xb8)])+'\x20t\x20'+K+r(0xb9)+b+r(0xba)+f[r(0xa9)],f);return{'search':m,'limit':P,'count':J[r(0xbb)]['length'],'time':Date[r(0xbc)]()-W,'data':J['rows']};}
@@ -1 +1 @@
1
- export async function listResourceRelation(p,Z){const {resource:A,id:I,relation:j,query:D,user:o}=p;return Z['resource']['findRelation']({'name':A,'id':I,'relation':j,'query':D,'user':o});}
1
+ function g(i,E){i=i-0x6f;const W=T();let M=W[i];return M;}export async function listResourceRelation(i,E){const x=g,{resource:W,id:M,relation:m,query:P,user:D}=i;return E['resource'][x(0x6f)]({'name':W,'id':M,'relation':m,'query':P,'user':D});}function T(){const Z=['findRelation'];T=function(){return Z;};return T();}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(p,Z){p=p-0x13a;const A=s();let I=A[p];return I;}function s(){const j=['user','resource','sort','search','scope','offset','page','limit'];s=function(){return j;};return s();}export async function listResources(p,Z){const I=f,A=p[I(0x13a)];return Z['resource']['find']({'name':p[I(0x13b)],'query':{'filter':parseFilterQuery(p),'sort':p[I(0x13c)],'search':p[I(0x13d)],'include':p['include'],'scope':p[I(0x13e)],'limit':p['limit'],'offset':p[I(0x13f)]??(p[I(0x140)]?Math['max'](p['page']-0x1,0x0):0x0)*(p[I(0x141)]??0x14)},'user':A});}
1
+ function T(){const m=['user','resource','search'];T=function(){return m;};return T();}function g(i,E){i=i-0x1bf;const W=T();let M=W[i];return M;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function listResources(i,E){const M=g,W=i[M(0x1bf)];return E[M(0x1c0)]['find']({'name':i['resource'],'query':{'filter':parseFilterQuery(i),'sort':i['sort'],'search':i[M(0x1c1)],'include':i['include'],'scope':i['scope'],'limit':i['limit'],'offset':i['offset']??(i['page']?Math['max'](i['page']-0x1,0x0):0x0)*(i['limit']??0x14)},'user':W});}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function s(){var I=['user'];s=function(){return I;};return s();}function f(p,Z){p=p-0x1cc;var A=s();var I=A[p];return I;}export async function searchResource(p,Z){var A=f;return Z['resource']['find']({'name':p['resource'],'query':{...p,'filter':parseFilterQuery(p)},'user':p[A(0x1cc)]});}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function T(){var M=['find'];T=function(){return M;};return T();}function g(i,E){i=i-0xe8;var W=T();var M=W[i];return M;}export async function searchResource(i,E){var W=g;return E['resource'][W(0xe8)]({'name':i['resource'],'query':{...i,'filter':parseFilterQuery(i)},'user':i['user']});}
@@ -1 +1 @@
1
- {"version":3,"file":"suggest-resource.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/suggest-resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,KAAK,qBAAqB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAElB,CAAC;AAEF,wBAAsB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA4ClG"}
1
+ {"version":3,"file":"suggest-resource.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/suggest-resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAwEtD,KAAK,qBAAqB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAElB,CAAC;AAEF,wBAAsB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA0DlG"}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x15b;const A=s();let I=A[p];return I;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function s(){const X=['resource','search','min','dictionary','lookup','value','text','\x20as\x20id,\x20','\x20as\x20text\x20FROM\x20','\x20WHERE\x20lower(','then','startsWith','slice','name','length'];s=function(){return X;};return s();}export async function suggestResource(p,Z){const a=f,A=Z['resource']['get'](p[a(0x15b)]),I=String(p[a(0x15c)]??p['q']??'')['toLowerCase'](),j=Math[a(0x15d)](Math['max'](Number(p['limit']??0x14),0x1),0xc8),D=Date['now'](),o=A['fields'][p['field']],R=o?.[a(0x15e)],B=o?.[a(0x15f)]?.['table'];if(B){const g=o[a(0x15f)]?.['text']??'name',N=o['lookup']?.[a(0x160)]??'id';autoIndex(B,g,a(0x161),Z['pg']);const h=await Z['pg']['query']('SELECT\x20'+N+a(0x162)+g+a(0x163)+B+a(0x164)+g+')\x20~\x20$1\x20LIMIT\x20$2',[''+I['toLowerCase'](),j])[a(0x165)](E=>E['rows']);return{'limit':j,'count':h['length'],'search':I,'time':Date['now']()-D,'data':h};}if(!R)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+p['field']);const H=await Z['dictionary']['get'](R),e=H['filter'](E=>!I||E['code'][a(0x166)](I)||E['name']['startsWith'](I))[a(0x167)](0x0,j)['map'](E=>({'id':E['code']||E['id'],'text':E[a(0x168)]||E['text']}));return{'search':I,'limit':j,'count':e[a(0x169)],'time':Date['now']()-D,'data':e};}
1
+ function T(){const U=['entries','test','includes','has','push','length','like','LIKE','isArray','true','get','resource','search','limit','lookup','fields','filter','\x20as\x20id','\x20as\x20text','map','values','then','rows','field','code'];T=function(){return U;};return T();}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);function buildLookupFilters(i,E,W){const p=g,M=[],m=[];for(const [P,D]of Object[p(0x1ef)](i??{})){if(!/^[A-Za-z_][A-Za-z0-9_]*$/[p(0x1f0)](P))throw new ValidationError('Invalid\x20lookup\x20filter\x20field:\x20'+P);if(!E[p(0x1f1)](P))throw new ValidationError('Lookup\x20filter\x20field\x20is\x20not\x20allowed:\x20'+P);const x=qi(P),Z=isRecord(D)?D:{'eq':D};for(const [f,b]of Object['entries'](Z)){if(!filterOperators[p(0x1f2)](f))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+f);if(f==='null'){M['push'](x+'\x20IS\x20'+(isTruthy(b)?'':'NOT\x20')+'NULL');continue;}if(f==='in'||f==='nin'){const Q=Array['isArray'](b)?b:[b];if(Q['length']===0x0){M[p(0x1f3)](f==='in'?'FALSE':'TRUE');continue;}m['push'](Q),M['push'](x+'\x20'+(f==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(W+m[p(0x1f4)]-0x1)+')');continue;}const K={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<='},J='$'+(W+m[p(0x1f4)]);if(f===p(0x1f5)||f==='ilike'){m['push'](b),M['push'](x+'\x20'+(f===p(0x1f5)?p(0x1f6):'ILIKE')+'\x20'+J);continue;}m['push'](b),M[p(0x1f3)](x+'\x20'+K[f]+'\x20'+J);}}return{'sql':M['length']?'\x20AND\x20'+M['join']('\x20AND\x20'):'','values':m};}function g(i,E){i=i-0x1ef;const W=T();let M=W[i];return M;}function isRecord(i){const Y=g;return typeof i==='object'&&i!==null&&!Array[Y(0x1f7)](i);}function isTruthy(i){const d=g;return i===!![]||i===d(0x1f8)||i==='1'||i===0x1;}export async function suggestResource(i,E){const X=g,W=E['resource'][X(0x1f9)](i[X(0x1fa)]),M=String(i[X(0x1fb)]??i['q']??'')['toLowerCase'](),m=Math['min'](Math['max'](Number(i[X(0x1fc)]??0x14),0x1),0xc8),P=Date['now'](),D=W['fields'][i['field']],x=D?.['dictionary'],Z=D?.['lookup']?.['table'];if(Z){const K=D[X(0x1fd)]?.['text']??'name',J=D[X(0x1fd)]?.['value']??'id',Q=buildLookupFilters(parseFilterQuery(i),D[X(0x1fd)]?.['filterFields']??[],0x2),y=[...new Set(D['lookup']?.[X(0x1fe)]??[])][X(0x1ff)](S=>S!==J&&S!==K),s=[qi(J)+X(0x200),qi(K)+X(0x201),...y[X(0x202)](qi)]['join'](',\x20');autoIndex(Z,K,'text',E['pg']);const o=Q[X(0x203)]['length']+0x2,r='SELECT\x20'+s+'\x20FROM\x20'+qt(Z)+'\x20WHERE\x20lower('+qi(K)+')\x20~\x20$1\x20'+Q['sql']+'\x20LIMIT\x20$'+o,G=await E['pg']['query'](r,[''+M['toLowerCase'](),...Q['values'],m])[X(0x204)](S=>S[X(0x205)]);return{'limit':m,'count':G['length'],'search':M,'time':Date['now']()-P,'data':G};}if(!x)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+i[X(0x206)]);const f=await E['dictionary']['get'](x),b=f['filter'](S=>!M||S['code']['startsWith'](M)||S['name']['startsWith'](M))['slice'](0x0,m)['map'](S=>({'id':S[X(0x207)]||S['id'],'text':S['name']||S['text']}));return{'search':M,'limit':m,'count':b['length'],'time':Date['now']()-P,'data':b};}
@@ -1 +1 @@
1
- export async function updateResourceRelation(p,Z){const {resource:A,id:I,relation:j,relationId:D,data:o,user:R}=p;return Z['resource']['updateRelation']({'name':A,'id':I,'relation':j,'relationId':D,'data':o,'user':R});}
1
+ export async function updateResourceRelation(i,E){const {resource:W,id:M,relation:m,relationId:P,data:D,user:x}=i;return E['resource']['updateRelation']({'name':W,'id':M,'relation':m,'relationId':P,'data':D,'user':x});}
@@ -1 +1 @@
1
- export async function updateResource(p,Z){var A=f;return Z[A(0x8e)]['update']({'name':p[A(0x8e)],'id':p['id'],'data':p[A(0x8f)],'user':p['user']});}function f(p,Z){p=p-0x8e;var A=s();var I=A[p];return I;}function s(){var I=['resource','patch'];s=function(){return I;};return s();}
1
+ function g(i,E){i=i-0x160;var W=T();var M=W[i];return M;}function T(){var M=['resource','patch','user'];T=function(){return M;};return T();}export async function updateResource(i,E){var W=g;return E['resource']['update']({'name':i[W(0x160)],'id':i['id'],'data':i[W(0x161)],'user':i[W(0x162)]});}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x1d3;const A=s();let I=A[p];return I;}function s(){const R=['resource','type','user','permission','name','replace','File\x20name\x20is\x20required','files/'];s=function(){return R;};return s();}export async function uploadResourceFile(p,Z){const o=f,A=Z[o(0x1d3)]['get'](p[o(0x1d3)]);if(A['access']==='admin'&&p['user']?.[o(0x1d4)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p[o(0x1d5)]?.['type']!=='admin'&&!p['user']?.['permissions']?.['includes']((A[o(0x1d6)]??A[o(0x1d7)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(A['permission']??A['name'])+':update');if(!Buffer['isBuffer'](p['file'])||p['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const I=p['fileName'][o(0x1d8)](/[^A-Za-z0-9._-]/g,'_');if(!I)throw new ValidationError(o(0x1d9));const j=o(0x1da)+p['resource']+'/'+String(p['id'])+'/'+I;await Z['file']['put'](j,p['file']);if(!await Z['file']['exists'](j))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const D=await Z['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',[p['resource'],String(p['id']),j,p['file']['length']]);return D['rows'][0x0];}
1
+ import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function T(){const x=['get','admin','user','includes','File\x20is\x20required','File\x20name\x20is\x20required','resource','file','exists','Uploaded\x20file\x20not\x20found','query','rows'];T=function(){return x;};return T();}function g(i,E){i=i-0x17c;const W=T();let M=W[i];return M;}export async function uploadResourceFile(i,E){const D=g,W=E['resource'][D(0x17c)](i['resource']);if(W['access']===D(0x17d)&&i['user']?.['type']!==D(0x17d))throw new ForbiddenError('Admin\x20access\x20required');if(i['user']?.['type']!=='admin'&&!i[D(0x17e)]?.['permissions']?.[D(0x17f)]((W['permission']??W['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(W['permission']??W['name'])+':update');if(!Buffer['isBuffer'](i['file'])||i['file']['length']===0x0)throw new ValidationError(D(0x180));const M=i['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!M)throw new ValidationError(D(0x181));const m='files/'+i[D(0x182)]+'/'+String(i['id'])+'/'+M;await E['file']['put'](m,i[D(0x183)]);if(!await E['file'][D(0x184)](m))throw new NotFoundError(D(0x185));const P=await E['pg'][D(0x186)]('\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']),m,i['file']['length']]);return P[D(0x187)][0x0];}
@@ -1 +1 @@
1
- const B=f;import{getSystemSettings}from'./services/get-system-settings.js';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';function f(p,Z){p=p-0xde;const A=s();let I=A[p];return I;}import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';function s(){const g=['user','Get\x20platform\x20dictionary','dictionaryName','/api/dictionary/:name','system','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','system:dictionaries','params','/api/access/scope/:resource','fcore','Set\x20resource\x20access\x20scopes','Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','admin','get','Get\x20user\x20access\x20for\x20a\x20resource','Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','resourceAccess','Get\x20access\x20rules','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','post','Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','system:access','system:settings','/api/system/settings','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','system:logs','logger','query','send','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','List\x20APIs'];s=function(){return g;};return s();}import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=p=>p[B(0xde)];export function systemRoutes(p,Z=new Map()){return async A=>{const H=f;A['get']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':H(0xdf),'description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[H(0xe0)]}},async j=>({'items':await getDictionary({...j['params'],'user':u(j)},p)})),A['post'](H(0xe1),{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xe3),'description':H(0xe4),'access':'user','permissions':[H(0xe5)],'params':systemSchemas['dictionaryName'],'body':systemSchemas['dictionaryItems']}},async j=>updateDictionary({...j['params'],...j['body'],'user':u(j)},p));const I=async j=>getAccess({...j[H(0xe6)],'user':u(j)},p);A['get'](H(0xe7),{'schema':{'tags':['fcore',H(0xe2)],'summary':'Get\x20resource\x20access\x20scopes','description':'Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['resourceScope']}},async j=>getResourceScopes(j['params'],p)),A['post']('/api/access/scope/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':H(0xe9),'description':H(0xea),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async j=>setResourceScopes({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/resource/:resource',{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xed),'description':H(0xee),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async j=>getResourceAccess(j['params'],p)),A['post']('/api/access/resource/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':H(0xef),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams'],'body':systemSchemas[H(0xf0)]}},async j=>setResourceAccess({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':H(0xf1),'description':H(0xf2),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget']}},I),A[H(0xf3)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':H(0xf4),'access':'admin','permissions':[H(0xf5)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async j=>setAccess({...j['params'],...j['body'],'user':u(j)},p)),A['get']('/api/system/settings',{'schema':{'tags':[H(0xe8),H(0xe2)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[H(0xf6)]}},async j=>getSystemSettings({...j[H(0xe6)],'user':u(j)},p)),A['post'](H(0xf7),{'schema':{'tags':['fcore','system'],'summary':H(0xf8),'description':H(0xf9),'access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async j=>updateSystemSettings({...j['params'],'patch':j['body'],'user':u(j)},p)),A['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':[H(0xfa)],'querystring':systemSchemas[H(0xfb)]}},async(j,D)=>{const e=H,{contentType:o,body:R}=await getSystemLog({...j[e(0xfc)],'user':u(j)},p);return D['type'](o)[e(0xfd)](R);}),A[H(0xec)]('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':H(0xfe),'access':'user','permissions':[H(0xff)]}},async j=>getAuditLog({...j['query'],'user':u(j)},p)),A[H(0xec)]('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async j=>checkSystem({'user':u(j)},p)),A['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':H(0x100),'description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':H(0xeb),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async j=>getApiList({'user':u(j),'apiRoutes':Z,...j['query']},p));};}
1
+ function g(i,E){i=i-0x158;const W=T();let M=W[i];return M;}import{getSystemSettings}from'./services/get-system-settings.js';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';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=i=>i['user'];function T(){const b=['get','system','Get\x20platform\x20dictionary','dictionaryName','params','post','/api/dictionary/:name','fcore','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','system:access','Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','admin','resourceAccess','body','/api/access/:type/:id','/api/system/settings','Update\x20system\x20settings','system:settings','settings','Get\x20system\x20log','Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','query','Returns\x20the\x20system\x20audit\x20log\x20entries.','Check\x20system\x20health','Checks\x20the\x20availability\x20of\x20system\x20dependencies.','system:check'];T=function(){return b;};return T();}export function systemRoutes(i,E=new Map()){return async W=>{const Z=g;W[Z(0x158)]('/api/dictionary/:name',{'schema':{'tags':['fcore',Z(0x159)],'summary':Z(0x15a),'description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[Z(0x15b)]}},async m=>({'items':await getDictionary({...m[Z(0x15c)],'user':u(m)},i)})),W[Z(0x15d)](Z(0x15e),{'schema':{'tags':[Z(0x15f),'system'],'summary':Z(0x160),'description':Z(0x161),'access':'user','permissions':['system:dictionaries'],'params':systemSchemas['dictionaryName'],'body':systemSchemas['dictionaryItems']}},async m=>updateDictionary({...m['params'],...m['body'],'user':u(m)},i));const M=async m=>getAccess({...m[Z(0x15c)],'user':u(m)},i);W['get']('/api/access/scope/:resource',{'schema':{'tags':['fcore','system'],'summary':'Get\x20resource\x20access\x20scopes','description':'Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','access':'admin','permissions':[Z(0x162)],'params':systemSchemas['resourceScope']}},async m=>getResourceScopes(m['params'],i)),W[Z(0x15d)]('/api/access/scope/:resource',{'schema':{'tags':['fcore',Z(0x159)],'summary':'Set\x20resource\x20access\x20scopes','description':Z(0x163),'access':'admin','permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async m=>setResourceScopes({...m[Z(0x15c)],...m['body'],'user':u(m)},i)),W['get']('/api/access/resource/:resource',{'schema':{'tags':[Z(0x15f),'system'],'summary':'Get\x20user\x20access\x20for\x20a\x20resource','description':'Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':Z(0x164),'permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async m=>getResourceAccess(m['params'],i)),W['post']('/api/access/resource/:resource',{'schema':{'tags':[Z(0x15f),Z(0x159)],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':'Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':Z(0x164),'permissions':[Z(0x162)],'params':systemSchemas['accessResourceParams'],'body':systemSchemas[Z(0x165)]}},async m=>setResourceAccess({...m[Z(0x15c)],...m[Z(0x166)],'user':u(m)},i)),W[Z(0x158)](Z(0x167),{'schema':{'tags':['fcore','system'],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget']}},M),W['post']('/api/access/:type/:id',{'schema':{'tags':['fcore',Z(0x159)],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[Z(0x162)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async m=>setAccess({...m[Z(0x15c)],...m['body'],'user':u(m)},i)),W['get']('/api/system/settings',{'schema':{'tags':[Z(0x15f),Z(0x159)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':['system:settings']}},async m=>getSystemSettings({...m['params'],'user':u(m)},i)),W['post'](Z(0x168),{'schema':{'tags':['fcore','system'],'summary':Z(0x169),'description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':[Z(0x16a)],'body':systemSchemas[Z(0x16b)]}},async m=>updateSystemSettings({...m['params'],'patch':m[Z(0x166)],'user':u(m)},i)),W[Z(0x158)]('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':Z(0x16c),'description':Z(0x16d),'access':'user','permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(m,P)=>{const f=Z,{contentType:D,body:x}=await getSystemLog({...m[f(0x16e)],'user':u(m)},i);return P['type'](D)['send'](x);}),W['get']('/api/system/audit',{'schema':{'tags':['fcore',Z(0x159)],'summary':'Get\x20audit\x20log','description':Z(0x16f),'access':'user','permissions':['system:audit']}},async m=>getAuditLog({...m[Z(0x16e)],'user':u(m)},i)),W['get']('/api/system/check',{'schema':{'tags':[Z(0x15f),'system'],'summary':Z(0x170),'description':Z(0x171),'access':'user','permissions':[Z(0x172)]}},async m=>checkSystem({'user':u(m)},i)),W[Z(0x158)]('/api/system/list',{'schema':{'tags':['fcore',Z(0x159)],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':Z(0x164),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async m=>getApiList({'user':u(m),'apiRoutes':E,...m['query']},i));};}
@@ -1 +1 @@
1
- const p=f;import{Type}from'@sinclair/typebox';export const identifier=Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}function s(){const Z=['String','Object','Number','Union','Literal','user','role','Optional','Array','Unknown','^[A-Za-z0-9_.\x5c-/]*$'];s=function(){return Z;};return s();}export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type[p(0x1a1)]({'id':Type['Optional'](Type['Union']([Type[p(0x1a0)](),Type[p(0x1a2)]()])),'code':Type[p(0x1a0)]({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type[p(0x1a3)]([Type[p(0x1a4)](p(0x1a5)),Type['Literal'](p(0x1a6))]),'id':identifier}),'accessResourceParams':Type['Object']({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type['Object']({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type[p(0x1a3)]([Type['Array'](Type['Unknown']()),Type['String'](),Type[p(0x1a2)](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type['Object']({'users':Type[p(0x1a7)](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type[p(0x1a8)](Type['Object']({'role_id':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type['Optional'](Type[p(0x1a8)](identifier)),'permissions':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type[p(0x1a3)]([Type[p(0x1a4)]('short'),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type[p(0x1a0)]({'minLength':0x1}),Type[p(0x1a9)]()),'logger':Type[p(0x1a1)]({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':p(0x1aa)}))})};
1
+ const i=g;import{Type}from'@sinclair/typebox';function T(){const E=['String','Array','Optional','Literal','user','role','Object','Union','Boolean','Record','Unknown'];T=function(){return E;};return T();}function g(i,E){i=i-0xa0;const W=T();let M=W[i];return M;}export const identifier=Type[i(0xa0)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type[i(0xa1)](Type['Object']({'id':Type[i(0xa2)](Type['Union']([Type['String'](),Type['Number']()])),'code':Type[i(0xa0)]({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type[i(0xa0)](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type[i(0xa3)](i(0xa4)),Type['Literal'](i(0xa5))]),'id':identifier}),'accessResourceParams':Type[i(0xa6)]({'resource':identifier}),'resourceScope':Type[i(0xa6)]({'resource':identifier}),'resourceScopeBody':Type['Object']({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type[i(0xa7)]([Type['Array'](Type['Unknown']()),Type['String'](),Type['Number'](),Type[i(0xa8)](),Type['Null']()]))}),'resourceAccess':Type['Object']({'users':Type['Optional'](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type[i(0xa1)](Type[i(0xa6)]({'role_id':identifier,'actions':Type['Array'](Type[i(0xa0)]({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type['Optional'](Type['Array'](identifier)),'permissions':Type[i(0xa2)](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type[i(0xa0)]({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type[i(0xa2)](Type['Union']([Type['Literal']('short'),Type[i(0xa3)]('extended')]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type[i(0xa9)](Type[i(0xa0)]({'minLength':0x1}),Type[i(0xaa)]()),'logger':Type['Object']({'path':Type[i(0xa2)](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x1c6;const A=s();let I=A[p];return I;}export async function checkSystem(p,Z){const j=f,[A,I]=await Promise['allSettled']([Z['pg']['query']('SELECT\x201'),Z[j(0x1c6)][j(0x1c7)]()]);return{'status':A['status']==='fulfilled'&&I['status']==='fulfilled'?'ok':'degraded','pg':A['status'],'redis':I['status']};}function s(){const D=['redis','ping'];s=function(){return D;};return s();}
1
+ function g(i,E){i=i-0x165;const W=T();let M=W[i];return M;}function T(){const P=['ping','fulfilled'];T=function(){return P;};return T();}export async function checkSystem(i,E){const m=g,[W,M]=await Promise['allSettled']([E['pg']['query']('SELECT\x201'),E['redis'][m(0x165)]()]);return{'status':W['status']===m(0x166)&&M['status']==='fulfilled'?'ok':'degraded','pg':W['status'],'redis':M['status']};}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}export async function getAccess(p,Z){const o=f,A=p['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\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',I=await Z['pg']['query'](A,[p['id']]),j=[...new Set(I['rows'][o(0x1a0)](D=>D['resource'])[o(0x1a1)](D=>D!==null))];return{'access':I['rows'],'resources':j};}function s(){const R=['map','filter'];s=function(){return R;};return s();}
1
+ function g(i,E){i=i-0x198;const W=T();let M=W[i];return M;}export async function getAccess(i,E){const D=g,W=i[D(0x198)]==='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':D(0x199),M=await E['pg']['query'](W,[i['id']]),m=[...new Set(M[D(0x19a)][D(0x19b)](P=>P['resource'])['filter'](P=>P!==null))];return{'access':M[D(0x19a)],'resources':m};}function T(){const x=['type','\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','map'];T=function(){return x;};return T();}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0x66;const A=s();let I=A[p];return I;}export async function getApiList(p,Z){const R=f,A=[...p[R(0x66)][R(0x67)]()][R(0x68)]((I,j)=>(I['endpoint']+'\x20'+I[R(0x69)])['localeCompare'](j['endpoint']+'\x20'+j['method']));if(p['format']!=='short')return A;return A['map'](({method:I,endpoint:j,access:D,permissions:o})=>I+'\x20'+j);}function s(){const B=['apiRoutes','values','sort','method'];s=function(){return B;};return s();}
1
+ function g(i,E){i=i-0x103;const W=T();let M=W[i];return M;}export async function getApiList(i,E){const x=g,W=[...i[x(0x103)]['values']()]['sort']((M,m)=>(M['endpoint']+'\x20'+M['method'])['localeCompare'](m['endpoint']+'\x20'+m['method']));if(i['format']!==x(0x104))return W;return W['map'](({method:M,endpoint:m,access:P,permissions:D})=>M+'\x20'+m);}function T(){const Z=['apiRoutes','short'];T=function(){return Z;};return T();}
@@ -1 +1 @@
1
- export async function getAuditLog(p,Z){const D=f,A=Math[D(0xd7)](Math[D(0xd8)](p['limit']??0x32,0x1),0xc8),I=Math['max']((p['page']??0x1)-0x1,0x0)*A,j=await Z['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[A,I]);return{'rows':j['rows'],'page':p['page']??0x1,'limit':A};}function f(p,Z){p=p-0xd7;const A=s();let I=A[p];return I;}function s(){const o=['min','max'];s=function(){return o;};return s();}
1
+ function T(){const D=['limit','SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2'];T=function(){return D;};return T();}function g(i,E){i=i-0x139;const W=T();let M=W[i];return M;}export async function getAuditLog(i,E){const P=g,W=Math['min'](Math['max'](i[P(0x139)]??0x32,0x1),0xc8),M=Math['max']((i['page']??0x1)-0x1,0x0)*W,m=await E['pg']['query'](P(0x13a),[W,M]);return{'rows':m['rows'],'page':i['page']??0x1,'limit':W};}
@@ -1 +1 @@
1
- export async function getDictionary(p,Z){return Z['dictionary']['get'](p['name']);}
1
+ function g(i,E){i=i-0xda;var W=T();var M=W[i];return M;}function T(){var M=['get'];T=function(){return M;};return T();}export async function getDictionary(i,E){var W=g;return E['dictionary'][W(0xda)](i['name']);}
@@ -1 +1 @@
1
- function f(p,Z){p=p-0xaa;const A=s();let I=A[p];return I;}export async function getResourceAccess(p,Z){const K=f,[A,I,j]=await Promise['all']([Z['pg']['query'](K(0xaa),[p[K(0xab)]]),Z['pg'][K(0xac)](K(0xad),[p[K(0xab)]]),Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE',[p['resource']])]),D=new Map(),o=new Map();for(const H of j['rows']){if(H['user_id']!==null){const e=D[K(0xae)](H['user_id'])??{};e[H['scope']]=H[K(0xaf)],D[K(0xb0)](H['user_id'],e);}else{if(H['role_id']!==null){const g=o['get'](H['role_id'])??{};g[H['scope']]=H['value'],o[K(0xb0)](H['role_id'],g);}}}const R=A['rows'][K(0xb1)](N=>({...N,...D['has'](N[K(0xb2)])?{'scopes':D[K(0xae)](N['uid'])}:{}}));for(const [N,h]of D){!R['some'](E=>E[K(0xb2)]===N)&&R[K(0xb3)]({'type':'user','uid':N,'actions':[],'scopes':h});}const B=I['rows']['map'](E=>({...E,...o['has'](E['role_id'])?{'scopes':o['get'](E['role_id'])}:{}}));for(const [E,a]of o){!B['some'](X=>X['role_id']===E)&&B['push']({'type':'role','role_id':E,'name':null,'actions':[],'users_count':0x0,'scopes':a});}return{'resource':p[K(0xab)],'users':R,'roles':B};}function s(){const Q=['SELECT\x20\x27user\x27::text\x20AS\x20type,\x20user_uid\x20AS\x20uid,\x20actions\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20user_uid','resource','query','SELECT\x20\x27role\x27::text\x20AS\x20type,\x20ra.role_id,\x20r.name,\x20ra.actions,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(DISTINCT\x20ur.user_uid)::int\x20AS\x20users_count\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.roles\x20r\x20ON\x20r.role_id\x20=\x20ra.role_id\x0a\x20\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\x20\x20WHERE\x20ra.resource\x20=\x20$1\x20AND\x20ra.role_id\x20IS\x20NOT\x20NULL\x20AND\x20ra.user_uid\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20GROUP\x20BY\x20ra.role_id,\x20r.name,\x20ra.actions\x0a\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20r.name,\x20ra.role_id','get','value','set','map','uid','push'];s=function(){return Q;};return s();}
1
+ export async function getResourceAccess(i,E){const r=g,[W,M,m]=await Promise[r(0x96)]([E['pg']['query'](r(0x97),[i['resource']]),E['pg']['query'](r(0x98),[i['resource']]),E['pg'][r(0x99)](r(0x9a),[i[r(0x9b)]])]),P=new Map(),D=new Map();for(const f of m['rows']){if(f['user_id']!==null){const b=P['get'](f['user_id'])??{};b[f[r(0x9c)]]=f[r(0x9d)],P['set'](f[r(0x9e)],b);}else{if(f[r(0x9f)]!==null){const K=D['get'](f['role_id'])??{};K[f['scope']]=f['value'],D['set'](f['role_id'],K);}}}const x=W[r(0xa0)]['map'](J=>({...J,...P[r(0xa1)](J['uid'])?{'scopes':P['get'](J[r(0xa2)])}:{}}));for(const [J,Q]of P){!x['some'](y=>y['uid']===J)&&x['push']({'type':r(0xa3),'uid':J,'actions':[],'scopes':Q});}const Z=M[r(0xa0)]['map'](y=>({...y,...D['has'](y['role_id'])?{'scopes':D['get'](y[r(0x9f)])}:{}}));for(const [y,s]of D){!Z['some'](o=>o['role_id']===y)&&Z['push']({'type':'role','role_id':y,'name':null,'actions':[],'users_count':0x0,'scopes':s});}return{'resource':i[r(0x9b)],'users':x,'roles':Z};}function g(i,E){i=i-0x96;const W=T();let M=W[i];return M;}function T(){const G=['all','SELECT\x20\x27user\x27::text\x20AS\x20type,\x20user_uid\x20AS\x20uid,\x20actions\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20user_uid','SELECT\x20\x27role\x27::text\x20AS\x20type,\x20ra.role_id,\x20r.name,\x20ra.actions,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(DISTINCT\x20ur.user_uid)::int\x20AS\x20users_count\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.roles\x20r\x20ON\x20r.role_id\x20=\x20ra.role_id\x0a\x20\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\x20\x20WHERE\x20ra.resource\x20=\x20$1\x20AND\x20ra.role_id\x20IS\x20NOT\x20NULL\x20AND\x20ra.user_uid\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20GROUP\x20BY\x20ra.role_id,\x20r.name,\x20ra.actions\x0a\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20r.name,\x20ra.role_id','query','SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE','resource','scope','value','user_id','role_id','rows','has','uid','user'];T=function(){return G;};return T();}
@@ -1 +1 @@
1
- function s(){const e=['role_id','set','resource','values'];s=function(){return e;};return s();}function f(p,Z){p=p-0x1e7;const A=s();let I=A[p];return I;}export async function getResourceScopes(p,Z){const H=f,{rows:A}=await Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20role_id,\x20user_id\x20NULLS\x20FIRST,\x20scope',[p['resource']]),I=new Map(),j=new Map();for(const D of A){if(D['user_id']!==null){const o=D['user_id']+':'+(D['role_id']??''),R=I['get'](o)??{'user_id':D['user_id'],'role_id':D[H(0x1e7)],'scopes':{}};R['scopes'][D['scope']]=D['value'],I['set'](o,R);continue;}if(D['role_id']!==null){const B=j['get'](D['role_id'])??{'role_id':D['role_id'],'scopes':{}};B['scopes'][D['scope']]=D['value'],j[H(0x1e8)](D['role_id'],B);}}return{'resource':p[H(0x1e9)],'users':[...I['values']()],'roles':[...j[H(0x1ea)]()]};}
1
+ export async function getResourceScopes(i,E){const f=g,{rows:W}=await E['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20role_id,\x20user_id\x20NULLS\x20FIRST,\x20scope',[i[f(0x1a6)]]),M=new Map(),m=new Map();for(const P of W){if(P['user_id']!==null){const D=P[f(0x1a7)]+':'+(P['role_id']??''),x=M['get'](D)??{'user_id':P['user_id'],'role_id':P[f(0x1a8)],'scopes':{}};x['scopes'][P['scope']]=P['value'],M['set'](D,x);continue;}if(P['role_id']!==null){const Z=m['get'](P['role_id'])??{'role_id':P['role_id'],'scopes':{}};Z[f(0x1a9)][P['scope']]=P[f(0x1aa)],m['set'](P['role_id'],Z);}}return{'resource':i['resource'],'users':[...M[f(0x1ab)]()],'roles':[...m[f(0x1ab)]()]};}function g(i,E){i=i-0x1a6;const W=T();let M=W[i];return M;}function T(){const b=['resource','user_id','role_id','scopes','value','values'];T=function(){return b;};return T();}