@opengis/fcore 0.0.27 → 0.0.28

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 (107) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.js +1 -1
  4. package/dist/context.js +1 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/fastify.js +1 -1
  7. package/dist/fcore.js +1 -1
  8. package/dist/migrations/cli.js +1 -1
  9. package/dist/migrations/runner.js +1 -1
  10. package/dist/modules/auth/adduser-cli.js +1 -1
  11. package/dist/modules/auth/passwd-cli.js +1 -1
  12. package/dist/modules/auth/permission-cli.js +1 -1
  13. package/dist/modules/auth/route.js +1 -1
  14. package/dist/modules/auth/schema.js +1 -1
  15. package/dist/modules/auth/services/change-password.js +1 -1
  16. package/dist/modules/auth/services/get-current-user.js +1 -1
  17. package/dist/modules/auth/services/registration.js +1 -1
  18. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  19. package/dist/modules/file/mime.js +1 -1
  20. package/dist/modules/file/route.js +1 -1
  21. package/dist/modules/file/schema.js +1 -1
  22. package/dist/modules/file/services/get-file.js +1 -1
  23. package/dist/modules/file/services/resize-file.js +1 -1
  24. package/dist/modules/file/services/upload-file.js +1 -1
  25. package/dist/modules/resource/route.js +1 -1
  26. package/dist/modules/resource/schema.js +1 -1
  27. package/dist/modules/resource/services/add-note.js +1 -1
  28. package/dist/modules/resource/services/add-resource-file.js +1 -1
  29. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/create-resource.js +1 -1
  31. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  32. package/dist/modules/resource/services/delete-resource.js +1 -1
  33. package/dist/modules/resource/services/export-resource.js +1 -1
  34. package/dist/modules/resource/services/generate-resource-code.js +1 -1
  35. package/dist/modules/resource/services/get-resource-schema.js +1 -1
  36. package/dist/modules/resource/services/get-resource.js +1 -1
  37. package/dist/modules/resource/services/list-resource-as-user.js +1 -1
  38. package/dist/modules/resource/services/list-resource-list.js +1 -1
  39. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/list-resources.js +1 -1
  41. package/dist/modules/resource/services/search-resource.js +1 -1
  42. package/dist/modules/resource/services/suggest-resource.js +1 -1
  43. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  44. package/dist/modules/resource/services/update-resource.js +1 -1
  45. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  46. package/dist/modules/system/route.js +1 -1
  47. package/dist/modules/system/schema.js +1 -1
  48. package/dist/modules/system/services/check-system.js +1 -1
  49. package/dist/modules/system/services/get-access.js +1 -1
  50. package/dist/modules/system/services/get-api-list.js +1 -1
  51. package/dist/modules/system/services/get-audit-log.js +1 -1
  52. package/dist/modules/system/services/get-dictionary.js +1 -1
  53. package/dist/modules/system/services/get-resource-access.js +1 -1
  54. package/dist/modules/system/services/get-resource-scopes.js +1 -1
  55. package/dist/modules/system/services/get-system-log.js +1 -1
  56. package/dist/modules/system/services/get-system-settings.js +1 -1
  57. package/dist/modules/system/services/list-dictionaries.js +1 -1
  58. package/dist/modules/system/services/set-access.js +1 -1
  59. package/dist/modules/system/services/set-resource-access.js +1 -1
  60. package/dist/modules/system/services/set-resource-scopes.js +1 -1
  61. package/dist/modules/system/services/update-dictionary.js +1 -1
  62. package/dist/modules/system/services/update-system-settings.js +1 -1
  63. package/dist/modules/utils/require-admin.js +1 -1
  64. package/dist/modules/utils/safe-user.js +1 -1
  65. package/dist/modules/utils/unsupported.js +1 -1
  66. package/dist/plugins/audit/audit.js +1 -1
  67. package/dist/plugins/audit/services/write-audit.js +1 -1
  68. package/dist/plugins/auth/get-user-permissions.js +1 -1
  69. package/dist/plugins/auth/index.js +1 -1
  70. package/dist/plugins/auth/verifyUser.js +1 -1
  71. package/dist/plugins/dictionary.js +1 -1
  72. package/dist/plugins/file.js +1 -1
  73. package/dist/plugins/jwt.js +1 -1
  74. package/dist/plugins/logger/index.js +1 -1
  75. package/dist/plugins/logger/transport.js +1 -1
  76. package/dist/plugins/pg.js +1 -1
  77. package/dist/plugins/redis.js +1 -1
  78. package/dist/plugins/resource/resource.js +1 -1
  79. package/dist/plugins/resource/resource.registry.js +1 -1
  80. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  81. package/dist/plugins/resource/services/add-file-token.js +1 -1
  82. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  83. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  84. package/dist/plugins/resource/services/create-relation.js +1 -1
  85. package/dist/plugins/resource/services/create.js +1 -1
  86. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  87. package/dist/plugins/resource/services/delete-relation.js +1 -1
  88. package/dist/plugins/resource/services/delete.js +1 -1
  89. package/dist/plugins/resource/services/find-one.js +1 -1
  90. package/dist/plugins/resource/services/find-relation.js +1 -1
  91. package/dist/plugins/resource/services/find.js +1 -1
  92. package/dist/plugins/resource/services/get-table-columns.js +1 -1
  93. package/dist/plugins/resource/services/update-relation.js +1 -1
  94. package/dist/plugins/resource/services/update.js +1 -1
  95. package/dist/plugins/resource/utils/auto-index.js +1 -1
  96. package/dist/plugins/resource/utils/fields.js +1 -1
  97. package/dist/plugins/resource/utils/filters.js +1 -1
  98. package/dist/plugins/resource/utils/permissions.js +1 -1
  99. package/dist/plugins/resource/utils/scope.js +1 -1
  100. package/dist/plugins/resource/utils/sort.js +1 -1
  101. package/dist/plugins/resource/utils/sql.js +1 -1
  102. package/dist/plugins/resource/utils/summary.js +1 -1
  103. package/dist/shared/getIP.js +1 -1
  104. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  105. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  106. package/migrations/20260929120000_allow_user_only_role_scopes.sql +1 -1
  107. package/package.json +92 -92
@@ -1 +1 @@
1
- const P=C;import{Type}from'@sinclair/typebox';function C(P,G){P=P-0x174;const j=m();let Z=j[P];return Z;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type['Object']({'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[P(0x174)](Type[P(0x175)]()),'search':Type[P(0x174)](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceListQuery':Type['Object']({'search':Type[P(0x174)](Type[P(0x175)]()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type['Object']({'id':Type[P(0x174)](Type[P(0x175)]({'minLength':0x1,'maxLength':0x80})),'field':Type['Optional'](identifier),'template':Type['Optional'](Type['String']({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type['Object']({'include':Type['Optional'](Type[P(0x175)]({'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['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type[P(0x176)]({'file':Type[P(0x177)](),'fileName':Type[P(0x175)]({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type['Optional'](Type['Record'](Type[P(0x175)](),Type['Unknown']())),'sort':Type[P(0x174)](Type['Array'](Type[P(0x175)]({'minLength':0x1}))),'search':Type['Optional'](Type['String']()),'scope':Type[P(0x174)](Type['String']()),'limit':Type[P(0x174)](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type[P(0x174)](Type['Integer']({'minimum':0x0})),'fields':Type[P(0x174)](Type[P(0x178)](identifier))})};function m(){const G=['Optional','String','Object','Any','Array'];m=function(){return G;};return m();}
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 +1 @@
1
- function m(){const q=['body'];m=function(){return q;};return m();}function C(P,G){P=P-0x171;const j=m();let Z=j[P];return Z;}export async function addNote(P,G){const Z=C,j=await G['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[P['resource'],String(P['id']),P[Z(0x171)]]);return j['rows'][0x0];}
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 +1 @@
1
- function m(){const q=['query','rows'];m=function(){return q;};return m();}function C(P,G){P=P-0x183;const j=m();let Z=j[P];return Z;}export async function addResourceFile(P,G){const Z=C,j=await G['pg'][Z(0x183)]('\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['resource'],String(P['id']),P['filePath'],P['size']??null]);return j[Z(0x184)][0x0];}
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 +1 @@
1
- function m(){const A=['createRelation'];m=function(){return A;};return m();}function C(P,G){P=P-0x17d;const j=m();let Z=j[P];return Z;}export async function createResourceRelation(P,G){const F=C,{resource:j,id:Z,relation:q,data:p,user:X}=P;return G['resource'][F(0x17d)]({'name':j,'id':Z,'relation':q,'data':p,'user':X});}
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 +1 @@
1
- function C(P,G){P=P-0x12f;var j=m();var Z=j[P];return Z;}export async function createResource(P,G){var j=C;return G[j(0x12f)][j(0x130)]({'name':P['resource'],'data':P['data'],'user':P[j(0x131)]});}function m(){var Z=['resource','create','user'];m=function(){return Z;};return m();}
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 +1 @@
1
- export async function deleteResourceRelation(P,G){const X=C,{resource:j,id:Z,relation:q,relationId:p}=P;return G[X(0x193)]['deleteRelation']({'name':j,'id':Z,'relation':q,'relationId':p});}function C(P,G){P=P-0x193;const j=m();let Z=j[P];return Z;}function m(){const F=['resource'];m=function(){return F;};return m();}
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 +1 @@
1
- function m(){var Z=['resource','delete'];m=function(){return Z;};return m();}function C(P,G){P=P-0xff;var j=m();var Z=j[P];return Z;}export async function deleteResource(P,G){var j=C;return G[j(0xff)][j(0x100)]({'name':P[j(0xff)],'id':P['id'],'user':P['user']});}
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 +1 @@
1
- function m(){const q=['user'];m=function(){return q;};return m();}function C(P,G){P=P-0x11f;const j=m();let Z=j[P];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(P,G){const Z=C,j=await G['resource']['find']({'name':P['resource'],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'limit':P['limit'],'offset':P['offset'],'fields':P['fields']},'user':P[Z(0x11f)]});return j['rows'];}
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 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function m(){const O=['column','foreignKey','key','\x20LIMIT\x201','length','where','push','\x20<>\x20$','\x20AND\x20','getFullYear','\x20t\x20','rows','SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20','table','resource','field','name','num','mnum','getMonth','padStart','Cannot\x20resolve\x20code\x20template\x20variable:\x20{'];m=function(){return O;};return m();}function C(P,G){P=P-0xf8;const j=m();let Z=j[P];return Z;}function relationValue(P,G,j){const T=C,Z=G['fields'][j]?.[T(0xf8)]??j;return P[Z]??P[j];}async function resolvePath(P,G,j,Z){const D=C,[q,...p]=P['split']('.');if(!q)return undefined;const X=j['relations']?.[q];if(!X||!p['length']||!X['resource'])return relationValue(G,j,P);const F=Z['resource']['get'](X['resource']),A=F['key'];let H,b;if(X['localKey'])H=relationValue(G,j,X['localKey']),b=A;else{if(X[D(0xf9)])H=relationValue(G,j,j[D(0xfa)]),b=X[D(0xf9)];else return undefined;}if(H===null||H===undefined)return undefined;const E=F['fields'][b]?.['column']??b,z=await Z['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(F['table'])+'\x20t\x20WHERE\x20t.'+qi(E)+'\x20=\x20$1'+(X['where']?'\x20AND\x20('+X['where']+')':'')+D(0xfb),[H]),x=z['rows'][0x0];if(!x)return undefined;const o=p[0x0];if(!o)return undefined;if(p[D(0xfc)]===0x1)return relationValue(x,F,o);return resolvePath(p['join']('.'),x,F,Z);}async function countValues(P,G,j,Z){const h=C,q=[],p=P['where']?['('+P[h(0xfd)]+')']:[];G!==undefined&&(q[h(0xfe)](G),p['push']('t.'+qi(P['key'])+h(0xff)+q['length']));const X=p['length']?'WHERE\x20'+p['join'](h(0x100)):'',F=P['fields']['created_at'],A=F?'t.'+qi(F[h(0xf8)]??'created_at'):undefined,H=new Date(Z['getFullYear'](),0x0,0x1),b=new Date(Z[h(0x101)](),Z['getMonth'](),0x1);if(A){q[h(0xfe)](H,b);const x='$'+(q['length']-0x1),o='$'+q[h(0xfc)],i=await j['pg']['query']('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'+A+'\x20>=\x20'+x+')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+A+'\x20>=\x20'+o+')::int\x20+\x201\x20AS\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(P['table'])+h(0x102)+X,q),y=i[h(0x103)][0x0];return{'num':Number(y?.['num']??0x1),'ynum':Number(y?.['ynum']??0x1),'mnum':Number(y?.['mnum']??0x1)};}const E=await j['pg']['query'](h(0x104)+qt(P[h(0x105)])+'\x20t\x20'+X,q),z=Number(E[h(0x103)][0x0]?.['num']??0x1);return{'num':z,'ynum':z,'mnum':z};}export async function generateResourceCode(P,G){const L=C,j=G['resource']['get'](P[L(0x106)]);if(P['field']&&!j['fields'][P['field']])throw new ValidationError('Unknown\x20resource\x20field:\x20'+P[L(0x107)]);const Z=P['template']??(P['field']?j['fields'][P['field']]?.['code_template']:undefined);if(!Z)return{'resource':j[L(0x108)],...P['id']!==undefined?{'id':P['id']}:{},...P['field']?{'field':P['field']}:{},'template':null,'code':null};const q=new Date(),p=await countValues(j,P['id'],G,q);let X={};if(P['id']!==undefined){const b=await G['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(j['table'])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(j['key'])+'\x20=\x20$1'+(j['where']?'\x20AND\x20('+j[L(0xfd)]+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[P['id']]);X=b['rows'][0x0]??{};}const F=[...Z['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],A=new Map();for(const E of F){const z=E[0x1];if(!z||A['has'](E[0x0]))continue;const x=Number(E[0x2]??0x0);let o;switch(z){case'num':o=p[L(0x109)];break;case'ynum':o=p['ynum'];break;case'mnum':o=p[L(0x10a)];break;case'yyyy':o=String(q[L(0x101)]());break;case'yy':o=String(q['getFullYear']())['slice'](-0x2);break;case'mm':o=String(q[L(0x10b)]()+0x1)[L(0x10c)](0x2,'0');break;case'dd':o=String(q['getDate']())[L(0x10c)](0x2,'0');break;case'resource':o=j['name'];break;case'resource_id':o=P['id'];break;default:o=P['id']===undefined?undefined:await resolvePath(z,X,j,G);}if(o===null||o===undefined||o==='')throw new ValidationError(L(0x10d)+z+'}');const i=String(o);A['set'](E[0x0],x&&/^\d+$/['test'](i)?i['padStart'](x,'0'):i);}const H=Z['replace'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,y=>A['get'](y)??y);return{'resource':j[L(0x108)],...P['id']!==undefined?{'id':P['id']}:{},...P[L(0x107)]?{'field':P['field']}:{},'template':Z,'code':H};}
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 +1 @@
1
- function variableType(P){const o=C;switch(P){case o(0xc1):case o(0xc2):return'number';case o(0xc3):return'boolean';case o(0xc4):case'geometry':case'geom':return'object';default:return'string';}}function C(P,G){P=P-0xc1;const j=m();let Z=j[P];return Z;}function buildVariables(P,G,j='',Z=new Set()){const i=C,q=new Set(Z)['add'](P['name']),p=[];for(const [X,F]of Object[i(0xc5)](P['fields'])){if(F['read']===![]||F[i(0xc6)]===![])continue;p['push']({'key':X,'path':j?j+'.'+X:X,'type':variableType(F['type'])});}for(const [A,H]of Object[i(0xc5)](P[i(0xc7)]??{})){if(!H['resource']||!G['resource'][i(0xc8)](H['resource']))continue;const b=G['resource']['get'](H[i(0xc9)]),E=j?j+'.'+A:A,z=H['type']===i(0xca),x={'key':A,'path':E,'type':z?'array':'object','resource':H[i(0xc9)],'variables':q['has'](b['name'])?[]:buildVariables(b,G,E,q)};p[i(0xcb)](x);}return p;}export function getResourceSchema(P,G){const y=C,j=G['resource']['get'](P[y(0xc9)]);return{'resource':j['name'],...j['title']?{'title':j['title']}:{},'variables':buildVariables(j,G)};}function m(){const T=['number','integer','boolean','json','entries','readable','relations','has','resource','many','push'];m=function(){return T;};return m();}
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 +1 @@
1
- export async function getResource(P,G){return G['resource']['findOne']({'name':P['resource'],'id':P['id'],'query':{'include':P['include']},'user':P['user']});}
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 +1 @@
1
- function m(){const A=['query','user','uid','all','limit','offset'];m=function(){return A;};return m();}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';function C(P,G){P=P-0x1e2;const j=m();let Z=j[P];return Z;}export async function listResourceAsUser(P,G){const F=C;if(P['requester']?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const j=await G['pg'][F(0x1e2)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[P['user']]),Z=j['rows'][0x0];if(!Z)throw new NotFoundError('User\x20not\x20found:\x20'+P[F(0x1e3)]);const q={'id':Z['uid'],'type':Z['type'],'permissions':await getUserPermissions(Z[F(0x1e4)],G)},[p,X]=await Promise[F(0x1e5)]([G['resource']['find']({'name':P['resource'],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'include':P['include'],'scope':P['scope'],'limit':P[F(0x1e6)],'offset':P[F(0x1e7)]??(P['page']?Math['max'](Number(P['page'])-0x1,0x0):0x0)*Number(P[F(0x1e6)]??0x14)},'user':q}),getUserResourceScopes(q['id'],P['resource'],G['pg'])]);return{...p,'scopes':X};}
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 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';function C(P,G){P=P-0x104;const j=m();let Z=j[P];return Z;}import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function m(){const D=['fields','join','display','name','map','matchAll','Invalid\x20display\x20template\x20for\x20resource:\x20','push','::text,\x20\x27\x27)','length','concat(','resource','get','read','max','searchable','where','WHERE\x20','key','table'];m=function(){return D;};return m();}function columnExpression(P,G){const i=C;if(G!==P['key']&&!P['fields'][G])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+G);const j=P[i(0x104)][G]?.['column']??G;return j['split']('.')['map'](Z=>quoteIdentifier(Z))[i(0x105)]('.');}function displayExpression(P){const y=C,G=P[y(0x106)];if(!G||Array['isArray'](G)&&G['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20display\x20fields:\x20'+P[y(0x107)]);if(Array['isArray'](G))return'concat_ws(\x27\x20\x27,\x20'+G[y(0x108)](p=>'COALESCE('+columnExpression(P,p)+'::text,\x20\x27\x27)')['join'](',\x20')+')';const j=[],Z=/\{([^{}]+)\}/g;let q=0x0;for(const p of G[y(0x109)](Z)){const X=p['index']??0x0,F=p[0x1];if(!F)throw new ValidationError(y(0x10a)+P['name']);X>q&&j['push']('\x27'+G['slice'](q,X)['replace'](/'/g,'\x27\x27')+'\x27'),j[y(0x10b)]('COALESCE('+columnExpression(P,F)+y(0x10c)),q=X+p[0x0][y(0x10d)];}q<G['length']&&j['push']('\x27'+G['slice'](q)['replace'](/'/g,'\x27\x27')+'\x27');if(j[y(0x10d)]===0x0)throw new ValidationError(y(0x10a)+P[y(0x107)]);return y(0x10e)+j['join'](',\x20')+')';}export async function listResourceList(P,G){const T=C,j=Date['now'](),Z=G[T(0x10f)][T(0x110)](P[T(0x10f)]);assertOperation(Z,T(0x111),P['user']);const q=P['search']??'',p=Math['min'](Math[T(0x112)](Number(P['limit']??0x14),0x1),0xc8),X=Z[T(0x113)]??Object['entries'](Z[T(0x104)])['filter'](([,x])=>x[T(0x113)])['map'](([x])=>x);if(q&&X['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+Z['name']);const F=displayExpression(Z),A=[],H=[];if(Z[T(0x114)])A[T(0x10b)]('('+Z['where']+')');if(q){const x=X['map'](o=>columnExpression(Z,o)+'::text\x20ILIKE\x20$1');A[T(0x10b)]('('+x['join']('\x20OR\x20')+')'),H[T(0x10b)]('%'+q+'%');}H['push'](p);const b=A[T(0x10d)]?T(0x115)+A['join']('\x20AND\x20'):'',E=Z['joins']?.[T(0x108)](o=>o['sql'])['join']('\x20')??'',z=await G['pg']['query']('SELECT\x20'+quoteIdentifier(Z[T(0x116)])+'\x20AS\x20id,\x20'+F+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(Z[T(0x117)])+'\x20t\x20'+E+'\x0a\x20\x20\x20\x20\x20'+b+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+H[T(0x10d)],H);return{'search':q,'limit':p,'count':z['rows']['length'],'time':Date['now']()-j,'data':z['rows']};}
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 +1 @@
1
- export async function listResourceRelation(P,G){const F=C,{resource:j,id:Z,relation:q,query:p,user:X}=P;return G['resource'][F(0x11e)]({'name':j,'id':Z,'relation':q,'query':p,'user':X});}function C(P,G){P=P-0x11e;const j=m();let Z=j[P];return Z;}function m(){const A=['findRelation'];m=function(){return A;};return m();}
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 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function C(P,G){P=P-0x135;const j=m();let Z=j[P];return Z;}export async function listResources(P,G){const Z=C,j=P['user'];return G[Z(0x135)]['find']({'name':P[Z(0x135)],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'include':P['include'],'scope':P['scope'],'limit':P['limit'],'offset':P['offset']??(P['page']?Math[Z(0x136)](P[Z(0x137)]-0x1,0x0):0x0)*(P['limit']??0x14)},'user':j});}function m(){const q=['resource','max','page'];m=function(){return q;};return m();}
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 +1 @@
1
- function m(){var Z=['user'];m=function(){return Z;};return m();}function C(P,G){P=P-0xed;var j=m();var Z=j[P];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function searchResource(P,G){var j=C;return G['resource']['find']({'name':P['resource'],'query':{...P,'filter':parseFilterQuery(P)},'user':P[j(0xed)]});}
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 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function m(){const y=['resource','min','fields','lookup','name','value','text','query','SELECT\x20','\x20as\x20text\x20FROM\x20',')\x20~\x20$1\x20LIMIT\x20$2','length','now'];m=function(){return y;};return m();}function C(P,G){P=P-0x10c;const j=m();let Z=j[P];return Z;}export async function suggestResource(P,G){const i=C,j=G[i(0x10c)]['get'](P['resource']),Z=String(P['search']??P['q']??'')['toLowerCase'](),q=Math[i(0x10d)](Math['max'](Number(P['limit']??0x14),0x1),0xc8),p=Date['now'](),X=j[i(0x10e)][P['field']],F=X?.['dictionary'],A=X?.['lookup']?.['table'];if(A){const E=X[i(0x10f)]?.['text']??i(0x110),z=X['lookup']?.[i(0x111)]??'id';autoIndex(A,E,i(0x112),G['pg']);const x=await G['pg'][i(0x113)](i(0x114)+z+'\x20as\x20id,\x20'+E+i(0x115)+A+'\x20WHERE\x20lower('+E+i(0x116),[''+Z['toLowerCase'](),q])['then'](o=>o['rows']);return{'limit':q,'count':x[i(0x117)],'search':Z,'time':Date[i(0x118)]()-p,'data':x};}if(!F)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+P['field']);const H=await G['dictionary']['get'](F),b=H['filter'](o=>!Z||o['code']['startsWith'](Z)||o['name']['startsWith'](Z))['slice'](0x0,q)['map'](o=>({'id':o['code']||o['id'],'text':o[i(0x110)]||o['text']}));return{'search':Z,'limit':q,'count':b[i(0x117)],'time':Date['now']()-p,'data':b};}
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 +1 @@
1
- function C(P,G){P=P-0x184;const j=m();let Z=j[P];return Z;}function m(){const H=['resource','updateRelation'];m=function(){return H;};return m();}export async function updateResourceRelation(P,G){const A=C,{resource:j,id:Z,relation:q,relationId:p,data:X,user:F}=P;return G[A(0x184)][A(0x185)]({'name':j,'id':Z,'relation':q,'relationId':p,'data':X,'user':F});}
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 +1 @@
1
- function m(){var Z=['resource'];m=function(){return Z;};return m();}function C(P,G){P=P-0x8c;var j=m();var Z=j[P];return Z;}export async function updateResource(P,G){var j=C;return G['resource']['update']({'name':P[j(0x8c)],'id':P['id'],'data':P['patch'],'user':P['user']});}
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 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(P,G){const X=C,j=G['resource']['get'](P['resource']);if(j['access']==='admin'&&P['user']?.[X(0xe9)]!==X(0xea))throw new ForbiddenError(X(0xeb));if(P['user']?.['type']!==X(0xea)&&!P['user']?.[X(0xec)]?.['includes']((j['permission']??j['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(j[X(0xed)]??j['name'])+X(0xee));if(!Buffer['isBuffer'](P[X(0xef)])||P['file'][X(0xf0)]===0x0)throw new ValidationError('File\x20is\x20required');const Z=P[X(0xf1)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!Z)throw new ValidationError('File\x20name\x20is\x20required');const q='files/'+P['resource']+'/'+String(P['id'])+'/'+Z;await G['file']['put'](q,P[X(0xef)]);if(!await G['file'][X(0xf2)](q))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const p=await G['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[X(0xf3)],String(P['id']),q,P[X(0xef)][X(0xf0)]]);return p[X(0xf4)][0x0];}function C(P,G){P=P-0xe9;const j=m();let Z=j[P];return Z;}function m(){const F=['type','admin','Admin\x20access\x20required','permissions','permission',':update','file','length','fileName','exists','resource','rows'];m=function(){return F;};return m();}
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 +1 @@
1
- const A=C;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';function m(){const b=['user','get','/api/dictionary/:name','fcore','system','system:dictionaries','params','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','dictionaryItems','Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','system:access','resourceScope','Set\x20resource\x20access\x20scopes','admin','body','Get\x20user\x20access\x20for\x20a\x20resource','accessResourceParams','resourceAccess','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','post','Get\x20system\x20settings','Returns\x20system\x20settings\x20as\x20nested\x20JSON.','settings','Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','system:logs','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','query','Check\x20system\x20health'];m=function(){return b;};return m();}import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';function C(P,G){P=P-0x81;const j=m();let Z=j[P];return Z;}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=P=>P[A(0x81)];export function systemRoutes(P,G=new Map()){return async j=>{const H=C;j[H(0x82)](H(0x83),{'schema':{'tags':[H(0x84),H(0x85)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':[H(0x86)],'params':systemSchemas['dictionaryName']}},async q=>({'items':await getDictionary({...q[H(0x87)],'user':u(q)},P)})),j['post'](H(0x83),{'schema':{'tags':['fcore','system'],'summary':H(0x88),'description':H(0x89),'access':'user','permissions':[H(0x86)],'params':systemSchemas['dictionaryName'],'body':systemSchemas[H(0x8a)]}},async q=>updateDictionary({...q['params'],...q['body'],'user':u(q)},P));const Z=async q=>getAccess({...q[H(0x87)],'user':u(q)},P);j[H(0x82)]('/api/access/scope/:resource',{'schema':{'tags':['fcore','system'],'summary':'Get\x20resource\x20access\x20scopes','description':H(0x8b),'access':'admin','permissions':[H(0x8c)],'params':systemSchemas[H(0x8d)]}},async q=>getResourceScopes(q[H(0x87)],P)),j['post']('/api/access/scope/:resource',{'schema':{'tags':[H(0x84),H(0x85)],'summary':H(0x8e),'description':'Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','access':H(0x8f),'permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async q=>setResourceScopes({...q['params'],...q[H(0x90)],'user':u(q)},P)),j['get']('/api/access/resource/:resource',{'schema':{'tags':['fcore',H(0x85)],'summary':H(0x91),'description':'Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async q=>getResourceAccess(q['params'],P)),j['post']('/api/access/resource/:resource',{'schema':{'tags':[H(0x84),'system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':'Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':[H(0x8c)],'params':systemSchemas[H(0x92)],'body':systemSchemas[H(0x93)]}},async q=>setResourceAccess({...q['params'],...q[H(0x90)],'user':u(q)},P)),j['get']('/api/access/:type/:id',{'schema':{'tags':[H(0x84),'system'],'summary':'Get\x20access\x20rules','description':H(0x94),'access':H(0x8f),'permissions':[H(0x8c)],'params':systemSchemas['accessTarget']}},Z),j[H(0x95)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[H(0x8c)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async q=>setAccess({...q['params'],...q['body'],'user':u(q)},P)),j['get']('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':H(0x96),'description':H(0x97),'access':'admin','permissions':['system:settings']}},async q=>getSystemSettings({...q[H(0x87)],'user':u(q)},P)),j['post']('/api/system/settings',{'schema':{'tags':['fcore',H(0x85)],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':['system:settings'],'body':systemSchemas[H(0x98)]}},async q=>updateSystemSettings({...q['params'],'patch':q['body'],'user':u(q)},P)),j['get']('/api/system/logger',{'schema':{'tags':['fcore',H(0x85)],'summary':'Get\x20system\x20log','description':H(0x99),'access':'user','permissions':[H(0x9a)],'querystring':systemSchemas['logger']}},async(q,p)=>{const {contentType:X,body:F}=await getSystemLog({...q['query'],'user':u(q)},P);return p['type'](X)['send'](F);}),j['get']('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':H(0x9b),'access':'user','permissions':[H(0x9c)]}},async q=>getAuditLog({...q[H(0x9d)],'user':u(q)},P)),j['get']('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':H(0x9e),'description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async q=>checkSystem({'user':u(q)},P)),j['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':H(0x8f),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async q=>getApiList({'user':u(q),'apiRoutes':G,...q[H(0x9d)]},P));};}
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 +1 @@
1
- const P=C;import{Type}from'@sinclair/typebox';function C(P,G){P=P-0x149;const j=m();let Z=j[P];return Z;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type[P(0x149)]({'items':Type[P(0x14a)](Type[P(0x149)]({'id':Type['Optional'](Type['Union']([Type[P(0x14b)](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type[P(0x14c)](),Type[P(0x14d)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'accessResourceParams':Type['Object']({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type[P(0x149)]({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type['Union']([Type['Array'](Type[P(0x14e)]()),Type['String'](),Type['Number'](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type[P(0x149)]({'users':Type['Optional'](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type['Array'](Type[P(0x149)]({'role_id':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type[P(0x14f)](Type['Array'](identifier)),'permissions':Type['Optional'](Type[P(0x14a)](Type[P(0x14b)]({'minLength':0x1,'maxLength':0x80,'pattern':P(0x150)}))),'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(0x151)]([Type[P(0x152)]('short'),Type[P(0x152)]('extended')]))}),'settingsEntity':Type[P(0x149)]({'entity':Type[P(0x14f)](identifier)}),'settings':Type['Record'](Type[P(0x14b)]({'minLength':0x1}),Type[P(0x14e)]()),'logger':Type['Object']({'path':Type[P(0x14f)](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};function m(){const G=['Object','Array','String','Number','Null','Unknown','Optional','^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$','Union','Literal'];m=function(){return G;};return m();}
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 +1 @@
1
- export async function checkSystem(P,G){const q=C,[j,Z]=await Promise['allSettled']([G['pg']['query'](q(0x194)),G['redis']['ping']()]);return{'status':j['status']===q(0x195)&&Z['status']==='fulfilled'?'ok':q(0x196),'pg':j[q(0x197)],'redis':Z[q(0x197)]};}function C(P,G){P=P-0x194;const j=m();let Z=j[P];return Z;}function m(){const p=['SELECT\x201','fulfilled','degraded','status'];m=function(){return p;};return m();}
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 +1 @@
1
- export async function getAccess(P,G){const X=C,j=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',Z=await G['pg']['query'](j,[P['id']]),q=[...new Set(Z['rows']['map'](p=>p[X(0xd1)])['filter'](p=>p!==null))];return{'access':Z['rows'],'resources':q};}function C(P,G){P=P-0xd1;const j=m();let Z=j[P];return Z;}function m(){const F=['resource'];m=function(){return F;};return m();}
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 +1 @@
1
- function C(P,G){P=P-0x1c1;const j=m();let Z=j[P];return Z;}export async function getApiList(P,G){const F=C,j=[...P[F(0x1c1)]['values']()]['sort']((Z,q)=>(Z[F(0x1c2)]+'\x20'+Z[F(0x1c3)])['localeCompare'](q['endpoint']+'\x20'+q['method']));if(P[F(0x1c4)]!=='short')return j;return j['map'](({method:Z,endpoint:q,access:p,permissions:X})=>Z+'\x20'+q);}function m(){const A=['apiRoutes','endpoint','method','format'];m=function(){return A;};return m();}
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 +1 @@
1
- export async function getAuditLog(P,G){const p=C,j=Math[p(0x1df)](Math['max'](P['limit']??0x32,0x1),0xc8),Z=Math[p(0x1e0)]((P[p(0x1e1)]??0x1)-0x1,0x0)*j,q=await G['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',[j,Z]);return{'rows':q[p(0x1e2)],'page':P['page']??0x1,'limit':j};}function C(P,G){P=P-0x1df;const j=m();let Z=j[P];return Z;}function m(){const X=['min','max','page','rows'];m=function(){return X;};return m();}
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 +1 @@
1
- export async function getDictionary(P,G){return G['dictionary']['get'](P['name']);}
1
+ export async function getDictionary(p,Z){return Z['dictionary']['get'](p['name']);}
@@ -1 +1 @@
1
- function C(P,G){P=P-0xf8;const j=m();let Z=j[P];return Z;}export async function getResourceAccess(P,G){const T=C,[j,Z,q]=await Promise['all']([G['pg'][T(0xf8)](T(0xf9),[P['resource']]),G['pg'][T(0xf8)]('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',[P[T(0xfa)]]),G['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']])]),p=new Map(),X=new Map();for(const H of q['rows']){if(H['user_id']!==null){const b=p['get'](H[T(0xfb)])??{};b[H[T(0xfc)]]=H['value'],p['set'](H[T(0xfb)],b);}else{if(H[T(0xfd)]!==null){const E=X['get'](H['role_id'])??{};E[H['scope']]=H[T(0xfe)],X[T(0xff)](H[T(0xfd)],E);}}}const F=j['rows']['map'](z=>({...z,...p['has'](z['uid'])?{'scopes':p['get'](z['uid'])}:{}}));for(const [z,x]of p){!F['some'](o=>o['uid']===z)&&F[T(0x100)]({'type':'user','uid':z,'actions':[],'scopes':x});}const A=Z['rows'][T(0x101)](o=>({...o,...X['has'](o[T(0xfd)])?{'scopes':X['get'](o[T(0xfd)])}:{}}));for(const [o,i]of X){!A['some'](y=>y[T(0xfd)]===o)&&A['push']({'type':'role','role_id':o,'name':null,'actions':[],'users_count':0x0,'scopes':i});}return{'resource':P['resource'],'users':F,'roles':A};}function m(){const D=['query','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','user_id','scope','role_id','value','set','push','map'];m=function(){return D;};return m();}
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 +1 @@
1
- function m(){const b=['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','user_id','role_id','value','set'];m=function(){return b;};return m();}function C(P,G){P=P-0xed;const j=m();let Z=j[P];return Z;}export async function getResourceScopes(P,G){const H=C,{rows:j}=await G['pg'][H(0xed)](H(0xee),[P['resource']]),Z=new Map(),q=new Map();for(const p of j){if(p['user_id']!==null){const X=p[H(0xef)]+':'+(p[H(0xf0)]??''),F=Z['get'](X)??{'user_id':p['user_id'],'role_id':p[H(0xf0)],'scopes':{}};F['scopes'][p['scope']]=p[H(0xf1)],Z['set'](X,F);continue;}if(p['role_id']!==null){const A=q['get'](p['role_id'])??{'role_id':p['role_id'],'scopes':{}};A['scopes'][p['scope']]=p['value'],q[H(0xf2)](p['role_id'],A);}}return{'resource':P['resource'],'users':[...Z['values']()],'roles':[...q['values']()]};}
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 +1 @@
1
- function C(P,G){P=P-0x188;const j=m();let Z=j[P];return Z;}const o=C;import P from'node:fs/promises';import G from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=G[o(0x188)](process['cwd'](),o(0x189)),TAIL_LINES=0x64;export async function getSystemLog(j,Z){const i=o,q=normalizePath(j[i(0x18a)]),p=G['resolve'](LOGS_ROOT,q);if(p!==LOGS_ROOT&&!p['startsWith'](LOGS_ROOT+G['sep']))throw new ValidationError('Invalid\x20log\x20path');const X=await P[i(0x18b)](p)[i(0x18c)](()=>null);if(!X)throw new NotFoundError('Log\x20path\x20not\x20found');if(X[i(0x18d)]()){const A=await P['readdir'](p,{'withFileTypes':!![]}),H=await Promise[i(0x18e)](A['map'](async b=>{const y=i,E=await P['stat'](G['join'](p,b['name']));return{'name':b['name'],'path':q?q+'/'+b['name']:b['name'],'type':b[y(0x18d)]()?y(0x18f):'file','size':b['isDirectory']()?undefined:E['size'],'modified':E['mtime'][y(0x190)]()};}));H['sort']((E,z)=>E[i(0x191)][i(0x192)](z[i(0x191)]));if(q){const b=q[i(0x193)]('/')[i(0x194)](0x0,-0x1)['join']('/');H['unshift']({'name':'..','path':b,'type':'directory'});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(q,H)};}const F=await tailFile(p,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':F['join']('\x0a')};}function renderDirectory(j,Z){const T=o,q=Z[T(0x195)](X=>{const D=T,F='?path='+encodeURIComponent(X['path']),A=X['type']===D(0x18f)?X['name']+'/':X['name'];return D(0x196)+F+'\x22>'+escapeHtml(A)+D(0x197);})[T(0x198)]('\x0a'),p=escapeHtml('logs/'+j);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+p+'</title></head>\x0a<body>\x0a<h1>'+p+'</h1>\x0a<ul>\x0a'+q+T(0x199);}function escapeHtml(j){const h=o;return j['replace'](/&/g,'&amp;')[h(0x19a)](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,h(0x19b));}function normalizePath(j){const L=o,Z=(j??'')[L(0x19a)](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(Z['split']('/')['some'](q=>q==='..'))throw new ValidationError('Invalid\x20log\x20path');return Z;}function m(){const N=['resolve','logs','path','stat','catch','isDirectory','all','directory','toISOString','name','localeCompare','split','slice','map','<li><a\x20href=\x22','</a></li>','join','\x0a</ul>\x0a</body>\x0a</html>','replace','&quot;','open','read','filter','reverse'];m=function(){return N;};return m();}async function tailFile(j,Z){const O=o,q=await P[O(0x19c)](j,'r');try{const {size:p}=await q[O(0x18b)](),X=0x40*0x400;let F=p,A=Buffer['alloc'](0x0),H=0x0;while(F>0x0&&H<=Z){const E=Math['min'](X,F);F-=E;const z=Buffer['alloc'](E);await q[O(0x19d)](z,0x0,E,F),A=Buffer['concat']([z,A]),H+=countNewlines(z);}const b=A['toString']('utf8')['split']('\x0a')[O(0x19e)](x=>x['length']>0x0);return b['slice'](-Z)[O(0x19f)]();}finally{await q['close']();}}function countNewlines(j){let Z=0x0;for(const q of j){if(q===0xa)Z++;}return Z;}
1
+ function f(p,Z){p=p-0x1d1;const A=s();let I=A[p];return I;}import p from'node:fs/promises';import Z from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=Z['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(A,I){const E=f,j=normalizePath(A['path']),D=Z['resolve'](LOGS_ROOT,j);if(D!==LOGS_ROOT&&!D['startsWith'](LOGS_ROOT+Z[E(0x1d1)]))throw new ValidationError('Invalid\x20log\x20path');const o=await p['stat'](D)['catch'](()=>null);if(!o)throw new NotFoundError('Log\x20path\x20not\x20found');if(o[E(0x1d2)]()){const B=await p['readdir'](D,{'withFileTypes':!![]}),H=await Promise['all'](B['map'](async e=>{const a=E,g=await p['stat'](Z['join'](D,e['name']));return{'name':e['name'],'path':j?j+'/'+e['name']:e['name'],'type':e['isDirectory']()?'directory':'file','size':e['isDirectory']()?undefined:g['size'],'modified':g[a(0x1d3)]['toISOString']()};}));H['sort']((e,g)=>e['name'][E(0x1d4)](g['name']));if(j){const e=j['split']('/')['slice'](0x0,-0x1)[E(0x1d5)]('/');H['unshift']({'name':'..','path':e,'type':'directory'});}return{'contentType':E(0x1d6),'body':renderDirectory(j,H)};}const R=await tailFile(D,TAIL_LINES);return{'contentType':E(0x1d7),'body':R[E(0x1d5)]('\x0a')};}function renderDirectory(A,I){const K=f,j=I['map'](o=>{const X=f,R=X(0x1d8)+encodeURIComponent(o['path']),B=o['type']==='directory'?o[X(0x1d9)]+'/':o['name'];return'<li><a\x20href=\x22'+R+'\x22>'+escapeHtml(B)+'</a></li>';})[K(0x1d5)]('\x0a'),D=escapeHtml('logs/'+A);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+D+K(0x1da)+D+K(0x1db)+j+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(A){const Q=f;return A['replace'](/&/g,'&amp;')[Q(0x1dc)](/</g,Q(0x1dd))['replace'](/>/g,Q(0x1de))[Q(0x1dc)](/"/g,Q(0x1df));}function normalizePath(A){const G=f,I=(A??'')[G(0x1dc)](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(I['split']('/')['some'](j=>j==='..'))throw new ValidationError('Invalid\x20log\x20path');return I;}async function tailFile(A,I){const V=f,j=await p[V(0x1e0)](A,'r');try{const {size:D}=await j['stat'](),o=0x40*0x400;let R=D,B=Buffer['alloc'](0x0),H=0x0;while(R>0x0&&H<=I){const g=Math['min'](o,R);R-=g;const N=Buffer['alloc'](g);await j['read'](N,0x0,g,R),B=Buffer['concat']([N,B]),H+=countNewlines(N);}const e=B['toString']('utf8')['split']('\x0a')['filter'](h=>h['length']>0x0);return e[V(0x1e1)](-I)['reverse']();}finally{await j['close']();}}function countNewlines(A){let I=0x0;for(const j of A){if(j===0xa)I++;}return I;}function s(){const O=['sep','isDirectory','mtime','localeCompare','join','text/html;\x20charset=utf-8','text/plain;\x20charset=utf-8','?path=','name','</title></head>\x0a<body>\x0a<h1>','</h1>\x0a<ul>\x0a','replace','&lt;','&gt;','&quot;','open','slice'];s=function(){return O;};return s();}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x18d;const j=m();let Z=j[P];return Z;}export async function getSystemSettings(P,G){const A=C,j=await G['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return j[A(0x18d)]['reduce']((Z,q)=>{const H=A,p=String(q[H(0x18e)])['split']('.');let X=Z;for(const F of p['slice'](0x0,-0x1)){X[F]??={},X=X[F];}return X[p['at'](-0x1)]=q[H(0x18f)],Z;},{});}function m(){const b=['rows','key','value'];m=function(){return b;};return m();}
1
+ export async function getSystemSettings(p,Z){const B=f,A=await Z['pg'][B(0xfe)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return A['rows']['reduce']((I,j)=>{const D=String(j['key'])['split']('.');let o=I;for(const R of D['slice'](0x0,-0x1)){o[R]??={},o=o[R];}return o[D['at'](-0x1)]=j['value'],I;},{});}function f(p,Z){p=p-0xfe;const A=s();let I=A[p];return I;}function s(){const H=['query'];s=function(){return H;};return s();}
@@ -1 +1 @@
1
- export async function listDictionaries(P,G){return G['dictionary']['list']();}
1
+ export async function listDictionaries(p,Z){return Z['dictionary']['list']();}
@@ -1 +1 @@
1
- const b=C;import{getAccess}from'./get-access.js';function m(){const x=['update','create','delete','edit','BEGIN','DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1','query','permissions','user','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','COMMIT','release'];m=function(){return x;};return m();}const CRUD_ACTIONS=['read',b(0x192),b(0x193),b(0x194)];function C(P,G){P=P-0x192;const j=m();let Z=j[P];return Z;}function permissionsToAccess(P){const E=b,G=new Map();for(const j of P){const [Z,q]=j['split'](':');if(!Z)continue;const p=q===E(0x195)?E(0x192):q,X=G['get'](Z)??new Set();for(const F of p?[p]:CRUD_ACTIONS)X['add'](F);G['set'](Z,X);}return[...G]['map'](([A,H])=>({'resource':A,'actions':[...H]}));}export async function setAccess(P,G){const z=b,j=await G['pg']['connect']();try{await j['query'](z(0x196));if(P['type']==='user'){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[P['id']]);if(P['roles']!==undefined){await j['query'](z(0x197),[P['id']]);for(const q of P['roles']){await j[z(0x198)]('INSERT\x20INTO\x20admin.user_roles\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(user_uid,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)',[P['id'],q,P['user']['id'],P['user']['id']]);}}}else await j[z(0x198)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[P['id']]);const Z=P['permissions']?permissionsToAccess(P[z(0x199)]):P['access']??[];for(const p of Z){P['type']===z(0x19a)?await j['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[p['resource'],p[z(0x19b)],P['id'],P['user']['id'],P['user']['id']]):await j['query'](z(0x19c),[p['resource'],p['actions'],P['id'],P['user']['id'],P['user']['id']]);}await j['query'](z(0x19d));}catch(X){await j['query']('ROLLBACK');throw X;}finally{j[z(0x19e)]();}return getAccess(P,G);}
1
+ function f(p,Z){p=p-0xf9;const A=s();let I=A[p];return I;}const e=f;import{getAccess}from'./get-access.js';function s(){const h=['read','update','create','split','map','BEGIN','user','roles','query','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','resource','actions'];s=function(){return h;};return s();}const CRUD_ACTIONS=[e(0xf9),e(0xfa),e(0xfb),'delete'];function permissionsToAccess(p){const g=e,Z=new Map();for(const A of p){const [I,j]=A[g(0xfc)](':');if(!I)continue;const D=j==='edit'?'update':j,o=Z['get'](I)??new Set();for(const R of D?[D]:CRUD_ACTIONS)o['add'](R);Z['set'](I,o);}return[...Z][g(0xfd)](([B,H])=>({'resource':B,'actions':[...H]}));}export async function setAccess(p,Z){const N=e,A=await Z['pg']['connect']();try{await A['query'](N(0xfe));if(p['type']===N(0xff)){await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[p['id']]);if(p[N(0x100)]!==undefined){await A['query']('DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1',[p['id']]);for(const j of p[N(0x100)]){await A[N(0x101)]('INSERT\x20INTO\x20admin.user_roles\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(user_uid,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)',[p['id'],j,p[N(0xff)]['id'],p['user']['id']]);}}}else await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[p['id']]);const I=p['permissions']?permissionsToAccess(p['permissions']):p['access']??[];for(const D of I){p['type']==='user'?await A['query'](N(0x102),[D[N(0x103)],D['actions'],p['id'],p['user']['id'],p[N(0xff)]['id']]):await A['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[D[N(0x103)],D[N(0x104)],p['id'],p['user']['id'],p['user']['id']]);}await A[N(0x101)]('COMMIT');}catch(o){await A['query']('ROLLBACK');throw o;}finally{A['release']();}return getAccess(p,Z);}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x11c;const j=m();let Z=j[P];return Z;}function m(){const E=['add','has','role_id','connect','query','users','length','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','resource','roles','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','release'];m=function(){return E;};return m();}import{ValidationError}from'../../../errors.js';import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(P,G){const b=C;if(P['users']===undefined&&P['roles']===undefined)throw new ValidationError('At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided');const j=new Set();for(const p of P['users']??[]){if(j['has'](p['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+p['uid']);j[b(0x11c)](p['uid']);}const Z=new Set();for(const X of P['roles']??[]){if(Z[b(0x11d)](X[b(0x11e)]))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+X['role_id']);Z[b(0x11c)](X['role_id']);}const q=await G['pg'][b(0x11f)]();try{await q['query']('BEGIN');if(P['users']!==undefined){await q[b(0x120)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[P['resource']]);for(const F of P[b(0x121)]){if(F['actions'][b(0x122)]===0x0)continue;await q['query'](b(0x123),[P[b(0x124)],F['actions'],F['uid'],P['user']['id']]);}}if(P[b(0x125)]!==undefined){await q['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[P['resource']]);for(const A of P[b(0x125)]){if(A['actions'][b(0x122)]===0x0)continue;await q[b(0x120)](b(0x126),[P['resource'],A['actions'],A[b(0x11e)],P['user']['id']]);}}await q['query']('COMMIT');}catch(H){await q['query']('ROLLBACK');throw H;}finally{q[b(0x127)]();}return getResourceAccess({'resource':P['resource']},G);}
1
+ import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x6d;const A=s();let I=A[p];return I;}function s(){const g=['roles','uid','has','role_id','query','length','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','resource'];s=function(){return g;};return s();}import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(p,Z){const e=f;if(p['users']===undefined&&p[e(0x6d)]===undefined)throw new ValidationError('At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided');const A=new Set();for(const D of p['users']??[]){if(A['has'](D['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+D['uid']);A['add'](D[e(0x6e)]);}const I=new Set();for(const o of p[e(0x6d)]??[]){if(I[e(0x6f)](o['role_id']))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+o['role_id']);I['add'](o[e(0x70)]);}const j=await Z['pg']['connect']();try{await j[e(0x71)]('BEGIN');if(p['users']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[p['resource']]);for(const R of p['users']){if(R['actions'][e(0x72)]===0x0)continue;await j['query'](e(0x73),[p['resource'],R['actions'],R['uid'],p['user']['id']]);}}if(p['roles']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[p['resource']]);for(const B of p['roles']){if(B[e(0x74)]['length']===0x0)continue;await j[e(0x71)](e(0x75),[p[e(0x76)],B['actions'],B['role_id'],p['user']['id']]);}}await j[e(0x71)]('COMMIT');}catch(H){await j['query']('ROLLBACK');throw H;}finally{j['release']();}return getResourceAccess({'resource':p['resource']},Z);}
@@ -1 +1 @@
1
- function m(){const F=['At\x20least\x20one\x20scope\x20must\x20be\x20provided','query','resource','role_id','entries','scopes','user_id','release'];m=function(){return F;};return m();}function C(P,G){P=P-0xd1;const j=m();let Z=j[P];return Z;}import{ValidationError}from'../../../errors.js';import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(P,G){const X=C;if(Boolean(P['user_id'])===Boolean(P['role_id']))throw new ValidationError('Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id');if(Object['keys'](P['scopes'])['length']===0x0)throw new ValidationError(X(0xd1));const j=await G['pg']['connect']();try{await j[X(0xd2)]('BEGIN'),await j[X(0xd2)]('DELETE\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20role_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20user_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$3',[P[X(0xd3)],P[X(0xd4)]??null,P['user_id']??null]);for(const [Z,q]of Object[X(0xd5)](P[X(0xd6)])){await j[X(0xd2)]('INSERT\x20INTO\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20role_id,\x20user_id,\x20scope,\x20value,\x20enabled,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5::jsonb,\x20TRUE,\x20$6,\x20$6)',[P[X(0xd3)],P['role_id']??null,P[X(0xd7)]??null,Z,JSON['stringify'](q),P['user']['id']]);}await j['query']('COMMIT');}catch(p){await j['query']('ROLLBACK');throw p;}finally{j[X(0xd8)]();}return clearResourceScopeCache(),getResourceScopes({'resource':P['resource']},G);}
1
+ import{ValidationError}from'../../../errors.js';function s(){const R=['Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id','keys','BEGIN','query','COMMIT','ROLLBACK','release'];s=function(){return R;};return s();}import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';function f(p,Z){p=p-0x16d;const A=s();let I=A[p];return I;}import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(p,Z){const o=f;if(Boolean(p['user_id'])===Boolean(p['role_id']))throw new ValidationError(o(0x16d));if(Object[o(0x16e)](p['scopes'])['length']===0x0)throw new ValidationError('At\x20least\x20one\x20scope\x20must\x20be\x20provided');const A=await Z['pg']['connect']();try{await A['query'](o(0x16f)),await A['query']('DELETE\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20role_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20user_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$3',[p['resource'],p['role_id']??null,p['user_id']??null]);for(const [I,j]of Object['entries'](p['scopes'])){await A[o(0x170)]('INSERT\x20INTO\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20role_id,\x20user_id,\x20scope,\x20value,\x20enabled,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5::jsonb,\x20TRUE,\x20$6,\x20$6)',[p['resource'],p['role_id']??null,p['user_id']??null,I,JSON['stringify'](j),p['user']['id']]);}await A['query'](o(0x171));}catch(D){await A['query'](o(0x172));throw D;}finally{A[o(0x173)]();}return clearResourceScopeCache(),getResourceScopes({'resource':p['resource']},Z);}
@@ -1 +1 @@
1
- export async function updateDictionary(P,G){return await G['dictionary']['put'](P['name'],P['items']),{'success':!![]};}
1
+ function s(){var I=['dictionary','items'];s=function(){return I;};return s();}function f(p,Z){p=p-0xc7;var A=s();var I=A[p];return I;}export async function updateDictionary(p,Z){var A=f;return await Z[A(0xc7)]['put'](p['name'],p[A(0xc8)]),{'success':!![]};}
@@ -1 +1 @@
1
- function C(P,G){P=P-0x1d4;const j=m();let Z=j[P];return Z;}import{ValidationError}from'../../../errors.js';function m(){const p=['keys','entries','patch','Invalid\x20setting\x20key:\x20','stringify','user'];m=function(){return p;};return m();}export async function updateSystemSettings(P,G){const q=C;if(!Object[q(0x1d4)](P['patch'])['length'])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [j,Z]of Object[q(0x1d5)](P[q(0x1d6)])){if(!j['trim']()||j['includes']('..'))throw new ValidationError(q(0x1d7)+j);await G['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[j,JSON[q(0x1d8)](Z),P[q(0x1d9)]['id']]);}return{'success':!![]};}
1
+ import{ValidationError}from'../../../errors.js';function s(){const D=['patch','length','entries','user'];s=function(){return D;};return s();}function f(p,Z){p=p-0x135;const A=s();let I=A[p];return I;}export async function updateSystemSettings(p,Z){const j=f;if(!Object['keys'](p[j(0x135)])[j(0x136)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [A,I]of Object[j(0x137)](p['patch'])){if(!A['trim']()||A['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+A);await Z['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[A,JSON['stringify'](I),p[j(0x138)]['id']]);}return{'success':!![]};}
@@ -1 +1 @@
1
- function m(){var Z=['User\x20required','Admin\x20access\x20required','includes'];m=function(){return Z;};return m();}import{ForbiddenError}from'../../errors.js';function C(P,G){P=P-0x1a6;var j=m();var Z=j[P];return Z;}export function requireAdmin(P,G){var j=C;if(!P)throw new ForbiddenError(j(0x1a6));if(P['type']!=='admin')throw new ForbiddenError(j(0x1a7));if(P['type']!=='admin'&&G&&!P['permissions']?.[j(0x1a8)](G))throw new ForbiddenError('Missing\x20permission:\x20'+G);}
1
+ import{ForbiddenError}from'../../errors.js';function s(){var I=['permissions','Missing\x20permission:\x20'];s=function(){return I;};return s();}function f(p,Z){p=p-0x19c;var A=s();var I=A[p];return I;}export function requireAdmin(p,Z){var A=f;if(!p)throw new ForbiddenError('User\x20required');if(p['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p['type']!=='admin'&&Z&&!p[A(0x19c)]?.['includes'](Z))throw new ForbiddenError(A(0x19d)+Z);}
@@ -1 +1 @@
1
- function m(){const p=['entries','filter'];m=function(){return p;};return m();}function C(P,G){P=P-0x96;const j=m();let Z=j[P];return Z;}export const safeUser=P=>{const q=C,G=['password','salt','secret','credentials'];return Object['fromEntries'](Object[q(0x96)](P)[q(0x97)](([j])=>!G['some'](Z=>j['toLowerCase']()['includes'](Z))));};
1
+ function s(){const D=['salt','entries','some','toLowerCase'];s=function(){return D;};return s();}function f(p,Z){p=p-0x154;const A=s();let I=A[p];return I;}export const safeUser=p=>{const j=f,Z=['password',j(0x154),'secret','credentials'];return Object['fromEntries'](Object[j(0x155)](p)['filter'](([A])=>!Z[j(0x156)](I=>A[j(0x157)]()['includes'](I))));};
@@ -1 +1 @@
1
- import{UnsupportedError}from'../../errors.js';export function unsupported(P){throw new UnsupportedError(P+'\x20requires\x20a\x20project/provider\x20implementation');}
1
+ import{UnsupportedError}from'../../errors.js';export function unsupported(p){throw new UnsupportedError(p+'\x20requires\x20a\x20project/provider\x20implementation');}
@@ -1 +1 @@
1
- import{writeAudit}from'./services/write-audit.js';export function createAudit(P){const G=writeAudit(P);return{'write':G};}
1
+ import{writeAudit}from'./services/write-audit.js';export function createAudit(p){const Z=writeAudit(p);return{'write':Z};}