@opengis/fcore 0.0.1-beta.25 → 0.0.1-beta.27

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 (142) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.js +1 -1
  5. package/dist/fcore.js +1 -1
  6. package/dist/migrations/cli.js +1 -1
  7. package/dist/migrations/runner.js +1 -1
  8. package/dist/modules/auth/adduser-cli.js +1 -1
  9. package/dist/modules/auth/passwd-cli.js +1 -1
  10. package/dist/modules/auth/permission-cli.js +1 -1
  11. package/dist/modules/auth/route.d.ts.map +1 -1
  12. package/dist/modules/auth/route.js +1 -1
  13. package/dist/modules/auth/schema.js +1 -1
  14. package/dist/modules/auth/services/change-password.js +1 -1
  15. package/dist/modules/auth/services/get-current-user.d.ts +2 -0
  16. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  17. package/dist/modules/auth/services/get-current-user.js +1 -1
  18. package/dist/modules/auth/services/registration.js +1 -1
  19. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  20. package/dist/modules/file/mime.js +1 -1
  21. package/dist/modules/file/route.js +1 -1
  22. package/dist/modules/file/schema.js +1 -1
  23. package/dist/modules/file/services/get-file.js +1 -1
  24. package/dist/modules/file/services/resize-file.js +1 -1
  25. package/dist/modules/file/services/upload-file.js +1 -1
  26. package/dist/modules/resource/route.d.ts.map +1 -1
  27. package/dist/modules/resource/route.js +1 -1
  28. package/dist/modules/resource/schema.d.ts +13 -0
  29. package/dist/modules/resource/schema.d.ts.map +1 -1
  30. package/dist/modules/resource/schema.js +1 -1
  31. package/dist/modules/resource/services/add-note.js +1 -1
  32. package/dist/modules/resource/services/add-resource-file.js +1 -1
  33. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  34. package/dist/modules/resource/services/create-resource.js +1 -1
  35. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  36. package/dist/modules/resource/services/delete-resource.js +1 -1
  37. package/dist/modules/resource/services/export-resource.js +1 -1
  38. package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
  39. package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
  40. package/dist/modules/resource/services/generate-resource-code.js +1 -0
  41. package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
  42. package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
  43. package/dist/modules/resource/services/get-resource-schema.js +1 -0
  44. package/dist/modules/resource/services/get-resource.js +1 -1
  45. package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
  46. package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
  47. package/dist/modules/resource/services/list-resource-as-user.js +1 -0
  48. package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
  49. package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
  50. package/dist/modules/resource/services/list-resource-list.js +1 -0
  51. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  52. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  53. package/dist/modules/resource/services/list-resources.js +1 -1
  54. package/dist/modules/resource/services/search-resource.js +1 -1
  55. package/dist/modules/resource/services/suggest-resource.js +1 -1
  56. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  57. package/dist/modules/resource/services/update-resource.js +1 -1
  58. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  59. package/dist/modules/system/route.d.ts.map +1 -1
  60. package/dist/modules/system/route.js +1 -1
  61. package/dist/modules/system/schema.d.ts +22 -0
  62. package/dist/modules/system/schema.d.ts.map +1 -1
  63. package/dist/modules/system/schema.js +1 -1
  64. package/dist/modules/system/services/check-system.js +1 -1
  65. package/dist/modules/system/services/get-access.js +1 -1
  66. package/dist/modules/system/services/get-api-list.js +1 -1
  67. package/dist/modules/system/services/get-audit-log.js +1 -1
  68. package/dist/modules/system/services/get-dictionary.js +1 -1
  69. package/dist/modules/system/services/get-resource-access.d.ts +23 -0
  70. package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
  71. package/dist/modules/system/services/get-resource-access.js +1 -0
  72. package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
  73. package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
  74. package/dist/modules/system/services/get-resource-scopes.js +1 -0
  75. package/dist/modules/system/services/get-system-log.js +1 -1
  76. package/dist/modules/system/services/get-system-settings.js +1 -1
  77. package/dist/modules/system/services/list-dictionaries.js +1 -1
  78. package/dist/modules/system/services/set-access.d.ts +1 -0
  79. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  80. package/dist/modules/system/services/set-access.js +1 -1
  81. package/dist/modules/system/services/set-resource-access.d.ts +18 -0
  82. package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
  83. package/dist/modules/system/services/set-resource-access.js +1 -0
  84. package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
  85. package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
  86. package/dist/modules/system/services/set-resource-scopes.js +1 -0
  87. package/dist/modules/system/services/update-dictionary.js +1 -1
  88. package/dist/modules/system/services/update-system-settings.js +1 -1
  89. package/dist/modules/utils/require-admin.js +1 -1
  90. package/dist/modules/utils/safe-user.js +1 -1
  91. package/dist/modules/utils/unsupported.js +1 -1
  92. package/dist/plugins/audit/audit.js +1 -1
  93. package/dist/plugins/audit/services/write-audit.js +1 -1
  94. package/dist/plugins/auth/get-user-permissions.js +1 -1
  95. package/dist/plugins/auth/index.js +1 -1
  96. package/dist/plugins/auth/verifyUser.js +1 -1
  97. package/dist/plugins/dictionary.js +1 -1
  98. package/dist/plugins/file.js +1 -1
  99. package/dist/plugins/jwt.js +1 -1
  100. package/dist/plugins/logger/index.js +1 -1
  101. package/dist/plugins/logger/transport.js +1 -1
  102. package/dist/plugins/pg.js +1 -1
  103. package/dist/plugins/redis.js +1 -1
  104. package/dist/plugins/resource/resource.d.ts +1 -1
  105. package/dist/plugins/resource/resource.d.ts.map +1 -1
  106. package/dist/plugins/resource/resource.js +1 -1
  107. package/dist/plugins/resource/resource.registry.d.ts +3 -2
  108. package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
  109. package/dist/plugins/resource/resource.registry.js +1 -1
  110. package/dist/plugins/resource/resource.types.d.ts +23 -4
  111. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  112. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  113. package/dist/plugins/resource/services/add-file-token.js +1 -1
  114. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  115. package/dist/plugins/resource/services/create-relation.js +1 -1
  116. package/dist/plugins/resource/services/create.js +1 -1
  117. package/dist/plugins/resource/services/delete-relation.js +1 -1
  118. package/dist/plugins/resource/services/delete.js +1 -1
  119. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  120. package/dist/plugins/resource/services/find-one.js +1 -1
  121. package/dist/plugins/resource/services/find-relation.js +1 -1
  122. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  123. package/dist/plugins/resource/services/find.js +1 -1
  124. package/dist/plugins/resource/services/get-table-columns.js +1 -1
  125. package/dist/plugins/resource/services/update-relation.js +1 -1
  126. package/dist/plugins/resource/services/update.js +1 -1
  127. package/dist/plugins/resource/utils/auto-index.js +1 -1
  128. package/dist/plugins/resource/utils/fields.js +1 -1
  129. package/dist/plugins/resource/utils/filters.js +1 -1
  130. package/dist/plugins/resource/utils/permissions.js +1 -1
  131. package/dist/plugins/resource/utils/scope.d.ts +10 -0
  132. package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
  133. package/dist/plugins/resource/utils/scope.js +1 -0
  134. package/dist/plugins/resource/utils/sort.js +1 -1
  135. package/dist/plugins/resource/utils/sql.js +1 -1
  136. package/dist/plugins/resource/utils/summary.d.ts +5 -1
  137. package/dist/plugins/resource/utils/summary.d.ts.map +1 -1
  138. package/dist/plugins/resource/utils/summary.js +1 -1
  139. package/dist/shared/getIP.js +1 -1
  140. package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
  141. package/migrations/20260929_role_scope.sql +32 -0
  142. package/package.json +2 -2
@@ -1 +1 @@
1
- export async function deleteResource(w,y){return y['resource']['delete']({'name':w['resource'],'id':w['id'],'user':w['user']});}
1
+ function k(h,n){h=h-0x95;var B=Q();var G=B[h];return G;}export async function deleteResource(h,n){var B=k;return n['resource'][B(0x95)]({'name':h['resource'],'id':h['id'],'user':h['user']});}function Q(){var G=['delete'];Q=function(){return G;};return Q();}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x78;const d=f();let Z=d[w];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){const M=['offset','user'];f=function(){return M;};return f();}export async function exportResource(w,y){const Z=Y,d=await y['resource']['find']({'name':w['resource'],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'limit':w['limit'],'offset':w[Z(0x78)],'fields':w['fields']},'user':w[Z(0x79)]});return d['rows'];}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function k(h,n){h=h-0x189;const B=Q();let G=B[h];return G;}export async function exportResource(h,n){const G=k,B=await n[G(0x189)][G(0x18a)]({'name':h[G(0x189)],'query':{'filter':parseFilterQuery(h),'sort':h['sort'],'search':h['search'],'limit':h[G(0x18b)],'offset':h[G(0x18c)],'fields':h['fields']},'user':h['user']});return B[G(0x18d)];}function Q(){const f=['resource','find','limit','offset','rows'];Q=function(){return f;};return Q();}
@@ -0,0 +1,16 @@
1
+ import type { AppContext } from "../../../context.js";
2
+ type CodeParams = {
3
+ resource: string;
4
+ id?: string;
5
+ field?: string;
6
+ template?: string;
7
+ };
8
+ export declare function generateResourceCode(params: CodeParams, ctx: AppContext): Promise<{
9
+ resource: string;
10
+ id?: string;
11
+ field?: string;
12
+ template: string | null;
13
+ code: string | null;
14
+ }>;
15
+ export {};
16
+ //# sourceMappingURL=generate-resource-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-resource-code.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/generate-resource-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA2GF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC,CAyED"}
@@ -0,0 +1 @@
1
+ import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function k(h,n){h=h-0x16d;const B=Q();let G=B[h];return G;}function relationValue(h,n,B){const G=n['fields'][B]?.['column']??B;return h[G]??h[B];}async function resolvePath(h,n,B,G){const m=k,[f,...j]=h['split']('.');if(!f)return undefined;const Z=B['relations']?.[f];if(!Z||!j['length']||!Z['resource'])return relationValue(n,B,h);const e=G['resource']['get'](Z['resource']),b=e[m(0x16d)];let P,u;if(Z[m(0x16e)])P=relationValue(n,B,Z['localKey']),u=b;else{if(Z['foreignKey'])P=relationValue(n,B,B['key']),u=Z['foreignKey'];else return undefined;}if(P===null||P===undefined)return undefined;const X=e[m(0x16f)][u]?.['column']??u,H=await G['pg'][m(0x170)]('SELECT\x20*\x20FROM\x20'+qt(e[m(0x171)])+'\x20t\x20WHERE\x20t.'+qi(X)+'\x20=\x20$1'+(Z[m(0x172)]?m(0x173)+Z['where']+')':'')+m(0x174),[P]),i=H['rows'][0x0];if(!i)return undefined;const p=j[0x0];if(!p)return undefined;if(j[m(0x175)]===0x1)return relationValue(i,e,p);return resolvePath(j['join']('.'),i,e,G);}function Q(){const O=['key','localKey','fields','query','table','where','\x20AND\x20(','\x20LIMIT\x201','length','push','WHERE\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\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20','mnum','Unknown\x20resource\x20field:\x20','name','field','rows','has','ynum','getMonth','padStart','replace'];Q=function(){return O;};return Q();}async function countValues(h,n,B,G){const A=k,f=[],j=h['where']?['('+h['where']+')']:[];n!==undefined&&(f[A(0x176)](n),j['push']('t.'+qi(h['key'])+'\x20<>\x20$'+f['length']));const Z=j['length']?A(0x177)+j['join']('\x20AND\x20'):'',e=h[A(0x16f)]['created_at'],b=e?'t.'+qi(e['column']??A(0x178)):undefined,P=new Date(G['getFullYear'](),0x0,0x1),u=new Date(G['getFullYear'](),G['getMonth'](),0x1);if(b){f[A(0x176)](P,u);const i='$'+(f[A(0x175)]-0x1),p='$'+f['length'],z=await B['pg'][A(0x170)](A(0x179)+b+'\x20>=\x20'+i+')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+b+A(0x17a)+p+A(0x17b)+qt(h['table'])+'\x20t\x20'+Z,f),t=z['rows'][0x0];return{'num':Number(t?.['num']??0x1),'ynum':Number(t?.['ynum']??0x1),'mnum':Number(t?.[A(0x17c)]??0x1)};}const X=await B['pg']['query']('SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20'+qt(h[A(0x171)])+'\x20t\x20'+Z,f),H=Number(X['rows'][0x0]?.['num']??0x1);return{'num':H,'ynum':H,'mnum':H};}export async function generateResourceCode(h,n){const U=k,B=n['resource']['get'](h['resource']);if(h['field']&&!B[U(0x16f)][h['field']])throw new ValidationError(U(0x17d)+h['field']);const G=h['template']??(h['field']?B[U(0x16f)][h['field']]?.['code_template']:undefined);if(!G)return{'resource':B[U(0x17e)],...h['id']!==undefined?{'id':h['id']}:{},...h['field']?{'field':h[U(0x17f)]}:{},'template':null,'code':null};const f=new Date(),j=await countValues(B,h['id'],n,f);let Z={};if(h['id']!==undefined){const u=await n['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(B[U(0x171)])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(B[U(0x16d)])+'\x20=\x20$1'+(B['where']?'\x20AND\x20('+B[U(0x172)]+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[h['id']]);Z=u[U(0x180)][0x0]??{};}const e=[...G['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],b=new Map();for(const X of e){const H=X[0x1];if(!H||b[U(0x181)](X[0x0]))continue;const i=Number(X[0x2]??0x0);let p;switch(H){case'num':p=j['num'];break;case U(0x182):p=j[U(0x182)];break;case U(0x17c):p=j['mnum'];break;case'yyyy':p=String(f['getFullYear']());break;case'yy':p=String(f['getFullYear']())['slice'](-0x2);break;case'mm':p=String(f[U(0x183)]()+0x1)[U(0x184)](0x2,'0');break;case'dd':p=String(f['getDate']())['padStart'](0x2,'0');break;case'resource':p=B['name'];break;case'resource_id':p=h['id'];break;default:p=h['id']===undefined?undefined:await resolvePath(H,Z,B,n);}if(p===null||p===undefined||p==='')throw new ValidationError('Cannot\x20resolve\x20code\x20template\x20variable:\x20{'+H+'}');const z=String(p);b['set'](X[0x0],i&&/^\d+$/['test'](z)?z[U(0x184)](i,'0'):z);}const P=G[U(0x185)](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,t=>b['get'](t)??t);return{'resource':B['name'],...h['id']!==undefined?{'id':h['id']}:{},...h['field']?{'field':h['field']}:{},'template':G,'code':P};}
@@ -0,0 +1,6 @@
1
+ import type { AppContext } from "../../../context.js";
2
+ import type { ResourceSchemaDto } from "../../../plugins/resource/resource.types.js";
3
+ export declare function getResourceSchema(params: {
4
+ resource: string;
5
+ }, ctx: AppContext): ResourceSchemaDto;
6
+ //# sourceMappingURL=get-resource-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-resource-schema.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/get-resource-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,6CAA6C,CAAC;AAyDrD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,iBAAiB,CAOnB"}
@@ -0,0 +1 @@
1
+ function variableType(h){const p=k;switch(h){case p(0x157):case p(0x158):return'number';case'boolean':return p(0x159);case p(0x15a):case p(0x15b):case'geom':return p(0x15c);default:return p(0x15d);}}function buildVariables(h,n,B='',G=new Set()){const z=k,f=new Set(G)[z(0x15e)](h['name']),j=[];for(const [Z,e]of Object['entries'](h['fields'])){if(e[z(0x15f)]===![]||e['readable']===![])continue;j['push']({'key':Z,'path':B?B+'.'+Z:Z,'type':variableType(e['type'])});}for(const [b,P]of Object[z(0x160)](h['relations']??{})){if(!P['resource']||!n['resource'][z(0x161)](P['resource']))continue;const u=n['resource'][z(0x162)](P[z(0x163)]),X=B?B+'.'+b:b,H=P['type']==='many',i={'key':b,'path':X,'type':H?'array':z(0x15c),'resource':P['resource'],'variables':f['has'](u[z(0x164)])?[]:buildVariables(u,n,X,f)};j['push'](i);}return j;}function k(h,n){h=h-0x157;const B=Q();let G=B[h];return G;}export function getResourceSchema(h,n){const t=k,B=n[t(0x163)]['get'](h[t(0x163)]);return{'resource':B[t(0x164)],...B[t(0x165)]?{'title':B['title']}:{},'variables':buildVariables(B,n)};}function Q(){const m=['number','integer','boolean','json','geometry','object','string','add','read','entries','has','get','resource','name','title'];Q=function(){return m;};return Q();}
@@ -1 +1 @@
1
- export async function getResource(w,y){return y['resource']['findOne']({'name':w['resource'],'id':w['id'],'query':{'include':w['include']},'user':w['user']});}
1
+ function k(h,n){h=h-0x11a;var B=Q();var G=B[h];return G;}function Q(){var G=['resource','findOne','user'];Q=function(){return G;};return Q();}export async function getResource(h,n){var B=k;return n[B(0x11a)][B(0x11b)]({'name':h[B(0x11a)],'id':h['id'],'query':{'include':h['include']},'user':h[B(0x11c)]});}
@@ -0,0 +1,8 @@
1
+ import type { AppContext, User } from "../../../context.js";
2
+ export declare function listResourceAsUser(params: {
3
+ resource: string;
4
+ user: string;
5
+ requester?: User;
6
+ [key: string]: unknown;
7
+ }, ctx: AppContext): Promise<unknown>;
8
+ //# sourceMappingURL=list-resource-as-user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-resource-as-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resource-as-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAM5D,wBAAsB,kBAAkB,CACtC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,OAAO,CAAC,CAyClB"}
@@ -0,0 +1 @@
1
+ import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';function k(h,n){h=h-0x132;const B=Q();let G=B[h];return G;}function Q(){const b=['requester','query','rows','User\x20not\x20found:\x20','find','search','offset'];Q=function(){return b;};return Q();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';export async function listResourceAsUser(h,n){const e=k;if(h[e(0x132)]?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const B=await n['pg'][e(0x133)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[h['user']]),G=B[e(0x134)][0x0];if(!G)throw new NotFoundError(e(0x135)+h['user']);const f={'id':G['uid'],'type':G['type'],'permissions':await getUserPermissions(G['uid'],n)},[j,Z]=await Promise['all']([n['resource'][e(0x136)]({'name':h['resource'],'query':{'filter':parseFilterQuery(h),'sort':h['sort'],'search':h[e(0x137)],'include':h['include'],'scope':h['scope'],'limit':h['limit'],'offset':h[e(0x138)]??(h['page']?Math['max'](Number(h['page'])-0x1,0x0):0x0)*Number(h['limit']??0x14)},'user':f}),getUserResourceScopes(f['id'],h['resource'],n['pg'])]);return{...j,'scopes':Z};}
@@ -0,0 +1,20 @@
1
+ import type { AppContext } from "../../../context.js";
2
+ import type { ResourceUser } from "../../../plugins/resource/resource.types.js";
3
+ type ResourceListItem = {
4
+ id: unknown;
5
+ text: string;
6
+ };
7
+ export declare function listResourceList(params: {
8
+ resource: string;
9
+ search?: string;
10
+ limit?: number;
11
+ user?: ResourceUser;
12
+ }, ctx: AppContext): Promise<{
13
+ search: string;
14
+ limit: number;
15
+ count: number;
16
+ time: number;
17
+ data: ResourceListItem[];
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=list-resource-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-resource-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resource-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAElG,KAAK,gBAAgB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAkDtD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,EAAE,CAAC;CAC1B,CAAC,CA2CD"}
@@ -0,0 +1 @@
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';function k(h,n){h=h-0xd1;const B=Q();let G=B[h];return G;}function Q(){const A=['key','fields','join','display','name','COALESCE(','::text,\x20\x27\x27)','index','push','length','resource','get','read','max','searchable','\x20OR\x20','WHERE\x20','\x20AND\x20','joins','SELECT\x20','\x20AS\x20id,\x20','table','\x20t\x20','\x0a\x20\x20\x20\x20\x20'];Q=function(){return A;};return Q();}import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(h,n){const z=k;if(n!==h[z(0xd1)]&&!h['fields'][n])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+n);const B=h[z(0xd2)][n]?.['column']??n;return B['split']('.')['map'](G=>quoteIdentifier(G))[z(0xd3)]('.');}function displayExpression(h){const t=k,n=h[t(0xd4)];if(!n||Array['isArray'](n)&&n['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20display\x20fields:\x20'+h[t(0xd5)]);if(Array['isArray'](n))return'concat_ws(\x27\x20\x27,\x20'+n['map'](j=>t(0xd6)+columnExpression(h,j)+t(0xd7))[t(0xd3)](',\x20')+')';const B=[],G=/\{([^{}]+)\}/g;let f=0x0;for(const j of n['matchAll'](G)){const Z=j[t(0xd8)]??0x0,e=j[0x1];if(!e)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+h[t(0xd5)]);Z>f&&B[t(0xd9)]('\x27'+n['slice'](f,Z)['replace'](/'/g,'\x27\x27')+'\x27'),B['push']('COALESCE('+columnExpression(h,e)+'::text,\x20\x27\x27)'),f=Z+j[0x0]['length'];}f<n[t(0xda)]&&B['push']('\x27'+n['slice'](f)['replace'](/'/g,'\x27\x27')+'\x27');if(B['length']===0x0)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+h['name']);return'concat('+B['join'](',\x20')+')';}export async function listResourceList(h,n){const m=k,B=Date['now'](),G=n[m(0xdb)][m(0xdc)](h[m(0xdb)]);assertOperation(G,m(0xdd),h['user']);const f=h['search']??'',j=Math['min'](Math[m(0xde)](Number(h['limit']??0x14),0x1),0xc8),Z=G['searchable']??Object['entries'](G['fields'])['filter'](([,i])=>i[m(0xdf)])['map'](([i])=>i);if(f&&Z['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+G['name']);const e=displayExpression(G),b=[],P=[];if(G['where'])b[m(0xd9)]('('+G['where']+')');if(f){const i=Z['map'](p=>columnExpression(G,p)+'::text\x20ILIKE\x20$1');b[m(0xd9)]('('+i[m(0xd3)](m(0xe0))+')'),P[m(0xd9)]('%'+f+'%');}P['push'](j);const u=b['length']?m(0xe1)+b['join'](m(0xe2)):'',X=G[m(0xe3)]?.['map'](p=>p['sql'])['join']('\x20')??'',H=await n['pg']['query'](m(0xe4)+quoteIdentifier(G[m(0xd1)])+m(0xe5)+e+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(G[m(0xe6)])+m(0xe7)+X+m(0xe8)+u+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+P['length'],P);return{'search':f,'limit':j,'count':H['rows']['length'],'time':Date['now']()-B,'data':H['rows']};}
@@ -1 +1 @@
1
- export async function listResourceRelation(w,y){const s=Y,{resource:d,id:Z,relation:M,query:H,user:Q}=w;return y['resource'][s(0x18b)]({'name':d,'id':Z,'relation':M,'query':H,'user':Q});}function Y(w,y){w=w-0x18b;const d=f();let Z=d[w];return Z;}function f(){const j=['findRelation'];f=function(){return j;};return f();}
1
+ function Q(){const b=['findRelation'];Q=function(){return b;};return Q();}function k(h,n){h=h-0x75;const B=Q();let G=B[h];return G;}export async function listResourceRelation(h,n){const e=k,{resource:B,id:G,relation:f,query:j,user:Z}=h;return n['resource'][e(0x75)]({'name':B,'id':G,'relation':f,'query':j,'user':Z});}
@@ -1 +1 @@
1
- {"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAa9E"}
1
+ {"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAgB9E"}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x93;var d=f();var Z=d[w];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){var Z=['offset','max','page','limit'];f=function(){return Z;};return f();}export async function listResources(w,y){var d=Y;return y['resource']['find']({'name':w['resource'],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'scope':w['scope'],'limit':w['limit'],'offset':w[d(0x93)]??(w['page']?Math[d(0x94)](w[d(0x95)]-0x1,0x0):0x0)*(w[d(0x96)]??0x14)},'user':w['user']});}
1
+ function k(h,n){h=h-0x1df;const B=Q();let G=B[h];return G;}function Q(){const f=['resource','find','sort','limit'];Q=function(){return f;};return Q();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function listResources(h,n){const G=k,B=h['user'];return n[G(0x1df)][G(0x1e0)]({'name':h['resource'],'query':{'filter':parseFilterQuery(h),'sort':h[G(0x1e1)],'search':h['search'],'include':h['include'],'scope':h['scope'],'limit':h[G(0x1e2)],'offset':h['offset']??(h['page']?Math['max'](h['page']-0x1,0x0):0x0)*(h['limit']??0x14)},'user':B});}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){var Z=['resource','user'];f=function(){return Z;};return f();}function Y(w,y){w=w-0xe6;var d=f();var Z=d[w];return Z;}export async function searchResource(w,y){var d=Y;return y['resource']['find']({'name':w[d(0xe6)],'query':{...w,'filter':parseFilterQuery(w)},'user':w[d(0xe7)]});}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function k(h,n){h=h-0x13f;var B=Q();var G=B[h];return G;}function Q(){var G=['resource'];Q=function(){return G;};return Q();}export async function searchResource(h,n){var B=k;return n[B(0x13f)]['find']({'name':h[B(0x13f)],'query':{...h,'filter':parseFilterQuery(h)},'user':h['user']});}
@@ -1 +1 @@
1
- function f(){const U=['resource','get','now','lookup','query','\x20as\x20text\x20FROM\x20','toLowerCase','then','dictionary','filter','code','name'];f=function(){return U;};return f();}import{ValidationError}from'../../../errors.js';function Y(w,y){w=w-0x1eb;const d=f();let Z=d[w];return Z;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(w,y){const G=Y,d=y[G(0x1eb)][G(0x1ec)](w['resource']),Z=String(w['search']??w['q']??'')['toLowerCase'](),M=Math['min'](Math['max'](Number(w['limit']??0x14),0x1),0xc8),H=Date[G(0x1ed)](),Q=d['fields'][w['field']],s=Q?.['dictionary'],j=Q?.[G(0x1ee)]?.['table'];if(j){const K=Q['lookup']?.['text']??'name',T=Q[G(0x1ee)]?.['value']??'id';autoIndex(j,K,'text',y['pg']);const h=await y['pg'][G(0x1ef)]('SELECT\x20'+T+'\x20as\x20id,\x20'+K+G(0x1f0)+j+'\x20WHERE\x20lower('+K+')\x20~\x20$1\x20LIMIT\x20$2',[''+Z[G(0x1f1)](),M])[G(0x1f2)](i=>i['rows']);return{'limit':M,'count':h['length'],'search':Z,'time':Date[G(0x1ed)]()-H,'data':h};}if(!s)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+w['field']);const n=await y[G(0x1f3)]['get'](s),t=n[G(0x1f4)](i=>!Z||i['code']['startsWith'](Z)||i['name']['startsWith'](Z))['slice'](0x0,M)['map'](i=>({'id':i[G(0x1f5)]||i['id'],'text':i[G(0x1f6)]||i['text']}));return{'search':Z,'limit':M,'count':t['length'],'time':Date['now']()-H,'data':t};}
1
+ function Q(){const t=['resource','get','min','max','limit','field','value','query',')\x20~\x20$1\x20LIMIT\x20$2','toLowerCase','length','dictionary','startsWith','code','text','now'];Q=function(){return t;};return Q();}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function k(h,n){h=h-0x169;const B=Q();let G=B[h];return G;}export async function suggestResource(h,n){const z=k,B=n[z(0x169)][z(0x16a)](h['resource']),G=String(h['search']??h['q']??'')['toLowerCase'](),f=Math[z(0x16b)](Math[z(0x16c)](Number(h[z(0x16d)]??0x14),0x1),0xc8),j=Date['now'](),Z=B['fields'][h[z(0x16e)]],e=Z?.['dictionary'],b=Z?.['lookup']?.['table'];if(b){const X=Z['lookup']?.['text']??'name',H=Z['lookup']?.[z(0x16f)]??'id';autoIndex(b,X,'text',n['pg']);const i=await n['pg'][z(0x170)]('SELECT\x20'+H+'\x20as\x20id,\x20'+X+'\x20as\x20text\x20FROM\x20'+b+'\x20WHERE\x20lower('+X+z(0x171),[''+G[z(0x172)](),f])['then'](p=>p['rows']);return{'limit':f,'count':i[z(0x173)],'search':G,'time':Date['now']()-j,'data':i};}if(!e)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+h['field']);const P=await n[z(0x174)]['get'](e),u=P['filter'](p=>!G||p['code']['startsWith'](G)||p['name'][z(0x175)](G))['slice'](0x0,f)['map'](p=>({'id':p[z(0x176)]||p['id'],'text':p['name']||p[z(0x177)]}));return{'search':G,'limit':f,'count':u['length'],'time':Date[z(0x178)]()-j,'data':u};}
@@ -1 +1 @@
1
- function f(){const n=['resource'];f=function(){return n;};return f();}function Y(w,y){w=w-0xcf;const d=f();let Z=d[w];return Z;}export async function updateResourceRelation(w,y){const j=Y,{resource:d,id:Z,relation:M,relationId:H,data:Q,user:s}=w;return y[j(0xcf)]['updateRelation']({'name':d,'id':Z,'relation':M,'relationId':H,'data':Q,'user':s});}
1
+ function k(h,n){h=h-0x1c9;const B=Q();let G=B[h];return G;}export async function updateResourceRelation(h,n){const b=k,{resource:B,id:G,relation:f,relationId:j,data:Z,user:e}=h;return n[b(0x1c9)]['updateRelation']({'name':B,'id':G,'relation':f,'relationId':j,'data':Z,'user':e});}function Q(){const P=['resource'];Q=function(){return P;};return Q();}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x14c;var d=f();var Z=d[w];return Z;}function f(){var Z=['resource','user'];f=function(){return Z;};return f();}export async function updateResource(w,y){var d=Y;return y[d(0x14c)]['update']({'name':w[d(0x14c)],'id':w['id'],'data':w['patch'],'user':w[d(0x14d)]});}
1
+ export async function updateResource(h,n){return n['resource']['update']({'name':h['resource'],'id':h['id'],'data':h['patch'],'user':h['user']});}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(){const s=['resource','get','admin','user','name','permission',':update','isBuffer','file','length','File\x20name\x20is\x20required','Uploaded\x20file\x20not\x20found','rows'];f=function(){return s;};return f();}function Y(w,y){w=w-0x1ac;const d=f();let Z=d[w];return Z;}export async function uploadResourceFile(w,y){const Q=Y,d=y[Q(0x1ac)][Q(0x1ad)](w['resource']);if(d['access']==='admin'&&w['user']?.['type']!==Q(0x1ae))throw new ForbiddenError('Admin\x20access\x20required');if(w['user']?.['type']!==Q(0x1ae)&&!w[Q(0x1af)]?.['permissions']?.['includes']((d['permission']??d[Q(0x1b0)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(d[Q(0x1b1)]??d[Q(0x1b0)])+Q(0x1b2));if(!Buffer[Q(0x1b3)](w['file'])||w[Q(0x1b4)][Q(0x1b5)]===0x0)throw new ValidationError('File\x20is\x20required');const Z=w['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!Z)throw new ValidationError(Q(0x1b6));const M='files/'+w['resource']+'/'+String(w['id'])+'/'+Z;await y['file']['put'](M,w['file']);if(!await y['file']['exists'](M))throw new NotFoundError(Q(0x1b7));const H=await y['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',[w[Q(0x1ac)],String(w['id']),M,w[Q(0x1b4)]['length']]);return H[Q(0x1b8)][0x0];}
1
+ import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function Q(){const e=['resource','admin','user','fileName','exists','file'];Q=function(){return e;};return Q();}function k(h,n){h=h-0xac;const B=Q();let G=B[h];return G;}export async function uploadResourceFile(h,n){const Z=k,B=n[Z(0xac)]['get'](h['resource']);if(B['access']===Z(0xad)&&h['user']?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(h[Z(0xae)]?.['type']!==Z(0xad)&&!h['user']?.['permissions']?.['includes']((B['permission']??B['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(B['permission']??B['name'])+':update');if(!Buffer['isBuffer'](h['file'])||h['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const G=h[Z(0xaf)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!G)throw new ValidationError('File\x20name\x20is\x20required');const f='files/'+h['resource']+'/'+String(h['id'])+'/'+G;await n['file']['put'](f,h['file']);if(!await n['file'][Z(0xb0)](f))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const j=await n['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',[h[Z(0xac)],String(h['id']),f,h[Z(0xb1)]['length']]);return j['rows'][0x0];}
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/system/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAanD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,SAAS,GAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAa,GACnD,kBAAkB,CA8JpB"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/system/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiBnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,SAAS,GAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAa,GACnD,kBAAkB,CAsOpB"}
@@ -1 +1 @@
1
- const j=Y;import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';function f(){const t=['user','system','dictionaryName','/api/dictionary/:name','system:dictionaries','body','get','/api/access/:type/:id','fcore','admin','post','Set\x20access\x20rules','system:access','/api/system/settings','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','apiListQuery'];f=function(){return t;};return f();}import{getAccess}from'./services/get-access.js';import{setAccess}from'./services/set-access.js';function Y(w,y){w=w-0x186;const d=f();let Z=d[w];return Z;}import{systemSchemas}from'./schema.js';const u=w=>w[j(0x186)];export function systemRoutes(w,y=new Map()){return async d=>{const n=Y;d['get']('/api/dictionary/:name',{'schema':{'tags':['fcore',n(0x187)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[n(0x188)]}},async M=>({'items':await getDictionary({...M['params'],'user':u(M)},w)})),d['post'](n(0x189),{'schema':{'tags':['fcore',n(0x187)],'summary':'Update\x20platform\x20dictionary','description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':'user','permissions':[n(0x18a)],'params':systemSchemas[n(0x188)],'body':systemSchemas['dictionaryItems']}},async M=>updateDictionary({...M['params'],...M[n(0x18b)],'user':u(M)},w));const Z=async M=>getAccess({...M['params'],'user':u(M)},w);d[n(0x18c)](n(0x18d),{'schema':{'tags':[n(0x18e),n(0x187)],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':n(0x18f),'permissions':['system:access'],'params':systemSchemas['accessTarget']}},Z),d[n(0x190)](n(0x18d),{'schema':{'tags':[n(0x18e),'system'],'summary':n(0x191),'description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[n(0x192)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async M=>setAccess({...M['params'],...M['body'],'user':u(M)},w)),d['get']('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':n(0x18f),'permissions':['system:settings']}},async M=>getSystemSettings({...M['params'],'user':u(M)},w)),d['post'](n(0x193),{'schema':{'tags':['fcore','system'],'summary':n(0x194),'description':n(0x195),'access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async M=>updateSystemSettings({...M['params'],'patch':M['body'],'user':u(M)},w)),d['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(M,H)=>{const {contentType:Q,body:s}=await getSystemLog({...M['query'],'user':u(M)},w);return H['type'](Q)['send'](s);}),d[n(0x18c)]('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':n(0x186),'permissions':['system:audit']}},async M=>getAuditLog({...M['query'],'user':u(M)},w)),d['get']('/api/system/check',{'schema':{'tags':[n(0x18e),'system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async M=>checkSystem({'user':u(M)},w)),d['get']('/api/system/list',{'schema':{'tags':[n(0x18e),'system'],'summary':'List\x20APIs','description':n(0x196),'access':n(0x18f),'permissions':[],'querystring':systemSchemas[n(0x197)]}},async M=>getApiList({'user':u(M),'apiRoutes':y,...M['query']},w));};}
1
+ import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';function Q(){const P=['/api/dictionary/:name','params','system','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','dictionaryName','fcore','Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','system:access','Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','resourceScope','body','accessResourceParams','post','/api/access/resource/:resource','get','/api/access/:type/:id','Get\x20access\x20rules','admin','Set\x20access\x20rules','Get\x20audit\x20log','/api/system/check','Check\x20system\x20health','user','apiListQuery','query'];Q=function(){return P;};return Q();}import{checkSystem}from'./services/check-system.js';function k(h,n){h=h-0x160;const B=Q();let G=B[h];return G;}import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=h=>h['user'];export function systemRoutes(h,n=new Map()){return async B=>{const b=k;B['get'](b(0x160),{'schema':{'tags':['fcore','system'],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas['dictionaryName']}},async f=>({'items':await getDictionary({...f[b(0x161)],'user':u(f)},h)})),B['post']('/api/dictionary/:name',{'schema':{'tags':['fcore',b(0x162)],'summary':'Update\x20platform\x20dictionary','description':b(0x163),'access':'user','permissions':['system:dictionaries'],'params':systemSchemas[b(0x164)],'body':systemSchemas['dictionaryItems']}},async f=>updateDictionary({...f[b(0x161)],...f['body'],'user':u(f)},h));const G=async f=>getAccess({...f['params'],'user':u(f)},h);B['get']('/api/access/scope/:resource',{'schema':{'tags':[b(0x165),b(0x162)],'summary':'Get\x20resource\x20access\x20scopes','description':b(0x166),'access':'admin','permissions':[b(0x167)],'params':systemSchemas['resourceScope']}},async f=>getResourceScopes(f[b(0x161)],h)),B['post']('/api/access/scope/:resource',{'schema':{'tags':[b(0x165),b(0x162)],'summary':'Set\x20resource\x20access\x20scopes','description':b(0x168),'access':'admin','permissions':['system:access'],'params':systemSchemas[b(0x169)],'body':systemSchemas['resourceScopeBody']}},async f=>setResourceScopes({...f['params'],...f[b(0x16a)],'user':u(f)},h)),B['get']('/api/access/resource/:resource',{'schema':{'tags':[b(0x165),b(0x162)],'summary':'Get\x20user\x20access\x20for\x20a\x20resource','description':'Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas[b(0x16b)]}},async f=>getResourceAccess(f[b(0x161)],h)),B[b(0x16c)](b(0x16d),{'schema':{'tags':['fcore','system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':'Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas[b(0x16b)],'body':systemSchemas['resourceAccess']}},async f=>setResourceAccess({...f['params'],...f['body'],'user':u(f)},h)),B[b(0x16e)](b(0x16f),{'schema':{'tags':[b(0x165),b(0x162)],'summary':b(0x170),'description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':b(0x171),'permissions':['system:access'],'params':systemSchemas['accessTarget']}},G),B['post']('/api/access/:type/:id',{'schema':{'tags':[b(0x165),'system'],'summary':b(0x172),'description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async f=>setAccess({...f[b(0x161)],...f['body'],'user':u(f)},h)),B['get']('/api/system/settings',{'schema':{'tags':[b(0x165),'system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':b(0x171),'permissions':['system:settings']}},async f=>getSystemSettings({...f['params'],'user':u(f)},h)),B[b(0x16c)]('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async f=>updateSystemSettings({...f['params'],'patch':f['body'],'user':u(f)},h)),B['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(f,j)=>{const {contentType:Z,body:e}=await getSystemLog({...f['query'],'user':u(f)},h);return j['type'](Z)['send'](e);}),B['get']('/api/system/audit',{'schema':{'tags':[b(0x165),'system'],'summary':b(0x173),'description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':'user','permissions':['system:audit']}},async f=>getAuditLog({...f['query'],'user':u(f)},h)),B[b(0x16e)](b(0x174),{'schema':{'tags':['fcore','system'],'summary':b(0x175),'description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':b(0x176),'permissions':['system:check']}},async f=>checkSystem({'user':u(f)},h)),B[b(0x16e)]('/api/system/list',{'schema':{'tags':[b(0x165),b(0x162)],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas[b(0x177)]}},async f=>getApiList({'user':u(f),'apiRoutes':n,...f[b(0x178)]},h));};}
@@ -15,7 +15,29 @@ export declare const systemSchemas: {
15
15
  type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"user">, import("@sinclair/typebox").TLiteral<"role">]>;
16
16
  id: import("@sinclair/typebox").TString;
17
17
  }>;
18
+ accessResourceParams: import("@sinclair/typebox").TObject<{
19
+ resource: import("@sinclair/typebox").TString;
20
+ }>;
21
+ resourceScope: import("@sinclair/typebox").TObject<{
22
+ resource: import("@sinclair/typebox").TString;
23
+ }>;
24
+ resourceScopeBody: import("@sinclair/typebox").TObject<{
25
+ user_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
26
+ role_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
27
+ scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>>;
28
+ }>;
29
+ resourceAccess: import("@sinclair/typebox").TObject<{
30
+ users: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
31
+ uid: import("@sinclair/typebox").TString;
32
+ actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
33
+ }>>>;
34
+ roles: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
35
+ role_id: import("@sinclair/typebox").TString;
36
+ actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
37
+ }>>>;
38
+ }>;
18
39
  access: import("@sinclair/typebox").TObject<{
40
+ roles: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
19
41
  permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
20
42
  access: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
21
43
  resource: import("@sinclair/typebox").TString;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/system/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,eAAO,MAAM,aAAa;IACxB,cAAc;;;IAGd,eAAe;;;;;;;;IAef,YAAY;;;;IAIZ,MAAM;;;;;;;IAaN,YAAY;;;IAGZ,cAAc;;;IACd,QAAQ;IACR,MAAM;;;CAKP,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/system/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,eAAO,MAAM,aAAa;IACxB,cAAc;;;IAGd,eAAe;;;;;;;;IAef,YAAY;;;;IAIZ,oBAAoB;;;IAGpB,aAAa;;;IAGb,iBAAiB;;;;;IAcjB,cAAc;;;;;;;;;;IAcd,MAAM;;;;;;;;IAcN,YAAY;;;IAGZ,cAAc;;;IACd,QAAQ;IACR,MAAM;;;CAKP,CAAC"}
@@ -1 +1 @@
1
- function f(){const y=['Object','Optional','Number','user','Literal','String','Union','Unknown'];f=function(){return y;};return f();}const w=Y;import{Type}from'@sinclair/typebox';function Y(w,y){w=w-0x108;const d=f();let Z=d[w];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[w(0x108)]({'name':identifier}),'dictionaryItems':Type[w(0x108)]({'items':Type['Array'](Type['Object']({'id':Type[w(0x109)](Type['Union']([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type[w(0x10a)](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal'](w(0x10b)),Type[w(0x10c)]('role')]),'id':identifier}),'access':Type[w(0x108)]({'permissions':Type[w(0x109)](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[w(0x10d)]({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type[w(0x108)]({'format':Type[w(0x109)](Type[w(0x10e)]([Type['Literal']('short'),Type[w(0x10c)]('extended')]))}),'settingsEntity':Type[w(0x108)]({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type[w(0x10d)]({'minLength':0x1}),Type[w(0x10f)]()),'logger':Type['Object']({'path':Type['Optional'](Type[w(0x10d)]({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
1
+ function Q(){const n=['String','Union','Optional','Object','Array','extended'];Q=function(){return n;};return Q();}const h=k;function k(h,n){h=h-0x1f2;const B=Q();let G=B[h];return G;}import{Type}from'@sinclair/typebox';export const identifier=Type[h(0x1f2)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type['Object']({'id':Type['Optional'](Type[h(0x1f3)]([Type[h(0x1f2)](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type[h(0x1f4)](Type['Union']([Type[h(0x1f2)](),Type['Number'](),Type['Null']()]))},{'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['Object']({'user_id':Type['Optional'](identifier),'role_id':Type[h(0x1f4)](identifier),'scopes':Type['Record'](identifier,Type['Union']([Type['Array'](Type['Unknown']()),Type['String'](),Type['Number'](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type['Object']({'users':Type['Optional'](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type['Array'](Type[h(0x1f5)]({'role_id':identifier,'actions':Type['Array'](Type[h(0x1f2)]({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type[h(0x1f4)](Type['Array'](identifier)),'permissions':Type['Optional'](Type[h(0x1f6)](Type[h(0x1f2)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type[h(0x1f6)](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[h(0x1f3)]([Type['Literal']('short'),Type['Literal'](h(0x1f7))]))}),'settingsEntity':Type[h(0x1f5)]({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type['Unknown']()),'logger':Type[h(0x1f5)]({'path':Type[h(0x1f4)](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
@@ -1 +1 @@
1
- export async function checkSystem(w,y){const M=Y,[d,Z]=await Promise['allSettled']([y['pg'][M(0x15a)]('SELECT\x201'),y[M(0x15b)]['ping']()]);return{'status':d['status']==='fulfilled'&&Z[M(0x15c)]===M(0x15d)?'ok':'degraded','pg':d[M(0x15c)],'redis':Z['status']};}function Y(w,y){w=w-0x15a;const d=f();let Z=d[w];return Z;}function f(){const H=['query','redis','status','fulfilled'];f=function(){return H;};return f();}
1
+ export async function checkSystem(h,n){const f=k,[B,G]=await Promise['allSettled']([n['pg'][f(0x104)]('SELECT\x201'),n[f(0x105)][f(0x106)]()]);return{'status':B['status']==='fulfilled'&&G[f(0x107)]==='fulfilled'?'ok':f(0x108),'pg':B['status'],'redis':G['status']};}function k(h,n){h=h-0x104;const B=Q();let G=B[h];return G;}function Q(){const j=['query','redis','ping','status','degraded'];Q=function(){return j;};return Q();}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x119;const d=f();let Z=d[w];return Z;}export async function getAccess(w,y){const Q=Y,d=w['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':Q(0x119),Z=await y['pg']['query'](d,[w['id']]),M=[...new Set(Z['rows']['map'](H=>H[Q(0x11a)])['filter'](H=>H!==null))];return{'access':Z['rows'],'resources':M};}function f(){const s=['\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','resource'];f=function(){return s;};return f();}
1
+ function k(h,n){h=h-0x82;const B=Q();let G=B[h];return G;}export async function getAccess(h,n){const Z=k,B=h['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':Z(0x82),G=await n['pg']['query'](B,[h['id']]),f=[...new Set(G['rows']['map'](j=>j['resource'])['filter'](j=>j!==null))];return{'access':G[Z(0x83)],'resources':f};}function Q(){const e=['\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20','rows'];Q=function(){return e;};return Q();}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x187;const d=f();let Z=d[w];return Z;}function f(){const j=['values','sort','method','short'];f=function(){return j;};return f();}export async function getApiList(w,y){const s=Y,d=[...w['apiRoutes'][s(0x187)]()][s(0x188)]((Z,M)=>(Z['endpoint']+'\x20'+Z['method'])['localeCompare'](M['endpoint']+'\x20'+M[s(0x189)]));if(w['format']!==s(0x18a))return d;return d['map'](({method:Z,endpoint:M,access:H,permissions:Q})=>Z+'\x20'+M);}
1
+ function Q(){const b=['apiRoutes','sort','localeCompare','endpoint','method'];Q=function(){return b;};return Q();}function k(h,n){h=h-0x1e0;const B=Q();let G=B[h];return G;}export async function getApiList(h,n){const e=k,B=[...h[e(0x1e0)]['values']()][e(0x1e1)]((G,f)=>(G['endpoint']+'\x20'+G['method'])[e(0x1e2)](f[e(0x1e3)]+'\x20'+f[e(0x1e4)]));if(h['format']!=='short')return B;return B['map'](({method:G,endpoint:f,access:j,permissions:Z})=>G+'\x20'+f);}
@@ -1 +1 @@
1
- function Y(w,y){w=w-0x9d;const d=f();let Z=d[w];return Z;}function f(){const Q=['limit','page'];f=function(){return Q;};return f();}export async function getAuditLog(w,y){const H=Y,d=Math['min'](Math['max'](w[H(0x9d)]??0x32,0x1),0xc8),Z=Math['max']((w[H(0x9e)]??0x1)-0x1,0x0)*d,M=await y['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',[d,Z]);return{'rows':M['rows'],'page':w[H(0x9e)]??0x1,'limit':d};}
1
+ export async function getAuditLog(h,n){const B=Math['min'](Math['max'](h['limit']??0x32,0x1),0xc8),G=Math['max']((h['page']??0x1)-0x1,0x0)*B,f=await n['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',[B,G]);return{'rows':f['rows'],'page':h['page']??0x1,'limit':B};}
@@ -1 +1 @@
1
- export async function getDictionary(w,y){return y['dictionary']['get'](w['name']);}
1
+ function k(h,n){h=h-0x159;var B=Q();var G=B[h];return G;}export async function getDictionary(h,n){var B=k;return n['dictionary']['get'](h[B(0x159)]);}function Q(){var G=['name'];Q=function(){return G;};return Q();}
@@ -0,0 +1,23 @@
1
+ import type { AppContext } from "../../../context.js";
2
+ export interface ResourceUserAccess {
3
+ type: "user";
4
+ uid: string;
5
+ actions: string[];
6
+ scopes?: Record<string, unknown>;
7
+ }
8
+ export interface ResourceRoleAccess {
9
+ type: "role";
10
+ role_id: string;
11
+ name: string | null;
12
+ actions: string[];
13
+ users_count: number;
14
+ scopes?: Record<string, unknown>;
15
+ }
16
+ export declare function getResourceAccess(params: {
17
+ resource: string;
18
+ }, ctx: AppContext): Promise<{
19
+ resource: string;
20
+ users: ResourceUserAccess[];
21
+ roles: ResourceRoleAccess[];
22
+ }>;
23
+ //# sourceMappingURL=get-resource-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-resource-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-resource-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AASD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,KAAK,EAAE,kBAAkB,EAAE,CAAC;CAC7B,CAAC,CA0ED"}
@@ -0,0 +1 @@
1
+ function k(h,n){h=h-0x156;const B=Q();let G=B[h];return G;}export async function getResourceAccess(h,n){const m=k,[B,G,f]=await Promise['all']([n['pg']['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',[h['resource']]),n['pg']['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',[h['resource']]),n['pg'][m(0x156)]('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',[h[m(0x157)]])]),j=new Map(),Z=new Map();for(const P of f['rows']){if(P['user_id']!==null){const u=j['get'](P['user_id'])??{};u[P[m(0x158)]]=P['value'],j['set'](P[m(0x159)],u);}else{if(P['role_id']!==null){const X=Z['get'](P['role_id'])??{};X[P['scope']]=P['value'],Z[m(0x15a)](P[m(0x15b)],X);}}}const e=B['rows']['map'](H=>({...H,...j['has'](H['uid'])?{'scopes':j['get'](H['uid'])}:{}}));for(const [H,i]of j){!e['some'](p=>p[m(0x15c)]===H)&&e['push']({'type':m(0x15d),'uid':H,'actions':[],'scopes':i});}const b=G['rows']['map'](p=>({...p,...Z['has'](p[m(0x15b)])?{'scopes':Z[m(0x15e)](p['role_id'])}:{}}));for(const [p,z]of Z){!b['some'](t=>t['role_id']===p)&&b['push']({'type':'role','role_id':p,'name':null,'actions':[],'users_count':0x0,'scopes':z});}return{'resource':h['resource'],'users':e,'roles':b};}function Q(){const A=['query','resource','scope','user_id','set','role_id','uid','user','get'];Q=function(){return A;};return Q();}
@@ -0,0 +1,16 @@
1
+ import type { AppContext } from "../../../context.js";
2
+ export declare function getResourceScopes(params: {
3
+ resource: string;
4
+ }, ctx: AppContext): Promise<{
5
+ resource: string;
6
+ users: Array<{
7
+ user_id: string;
8
+ role_id: string | null;
9
+ scopes: Record<string, unknown>;
10
+ }>;
11
+ roles: Array<{
12
+ role_id: string;
13
+ scopes: Record<string, unknown>;
14
+ }>;
15
+ }>;
16
+ //# sourceMappingURL=get-resource-scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-resource-scopes.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-resource-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAStD,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC3F,KAAK,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;CACpE,CAAC,CAoCD"}
@@ -0,0 +1 @@
1
+ export async function getResourceScopes(h,n){const P=k,{rows:B}=await n['pg'][P(0x17d)](P(0x17e),[h['resource']]),G=new Map(),f=new Map();for(const j of B){if(j['user_id']!==null){const Z=j[P(0x17f)]+':'+(j['role_id']??''),e=G[P(0x180)](Z)??{'user_id':j['user_id'],'role_id':j['role_id'],'scopes':{}};e['scopes'][j['scope']]=j[P(0x181)],G['set'](Z,e);continue;}if(j['role_id']!==null){const b=f[P(0x180)](j['role_id'])??{'role_id':j['role_id'],'scopes':{}};b[P(0x182)][j['scope']]=j['value'],f['set'](j['role_id'],b);}}return{'resource':h['resource'],'users':[...G['values']()],'roles':[...f['values']()]};}function k(h,n){h=h-0x17d;const B=Q();let G=B[h];return G;}function Q(){const u=['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','get','value','scopes'];Q=function(){return u;};return Q();}
@@ -1 +1 @@
1
- import w from'node:fs/promises';import y from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=y['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(d,Z){const i=Y,M=normalizePath(d['path']),H=y['resolve'](LOGS_ROOT,M);if(H!==LOGS_ROOT&&!H['startsWith'](LOGS_ROOT+y['sep']))throw new ValidationError('Invalid\x20log\x20path');const Q=await w[i(0xbc)](H)[i(0xbd)](()=>null);if(!Q)throw new NotFoundError('Log\x20path\x20not\x20found');if(Q['isDirectory']()){const j=await w['readdir'](H,{'withFileTypes':!![]}),n=await Promise['all'](j[i(0xbe)](async t=>{const G=i,K=await w['stat'](y['join'](H,t['name']));return{'name':t[G(0xbf)],'path':M?M+'/'+t['name']:t['name'],'type':t[G(0xc0)]()?G(0xc1):'file','size':t[G(0xc0)]()?undefined:K['size'],'modified':K['mtime'][G(0xc2)]()};}));n['sort']((t,K)=>t['name'][i(0xc3)](K[i(0xbf)]));if(M){const t=M['split']('/')['slice'](0x0,-0x1)['join']('/');n['unshift']({'name':'..','path':t,'type':i(0xc1)});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(M,n)};}const s=await tailFile(H,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':s['join']('\x0a')};}function renderDirectory(d,Z){const U=Y,M=Z['map'](Q=>{const s='?path='+encodeURIComponent(Q['path']),j=Q['type']==='directory'?Q['name']+'/':Q['name'];return'<li><a\x20href=\x22'+s+'\x22>'+escapeHtml(j)+'</a></li>';})['join']('\x0a'),H=escapeHtml('logs/'+d);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+H+'</title></head>\x0a<body>\x0a<h1>'+H+U(0xc4)+M+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(d){const E=Y;return d['replace'](/&/g,'&amp;')['replace'](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,E(0xc5));}function Y(w,y){w=w-0xbc;const d=f();let Z=d[w];return Z;}function normalizePath(d){const e=Y,Z=(d??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(Z['split']('/')[e(0xc6)](M=>M==='..'))throw new ValidationError('Invalid\x20log\x20path');return Z;}function f(){const A=['stat','catch','map','name','isDirectory','directory','toISOString','localeCompare','</h1>\x0a<ul>\x0a','&quot;','some','open','alloc','read','utf8','split','close'];f=function(){return A;};return f();}async function tailFile(d,Z){const l=Y,M=await w[l(0xc7)](d,'r');try{const {size:H}=await M['stat'](),Q=0x40*0x400;let s=H,j=Buffer[l(0xc8)](0x0),n=0x0;while(s>0x0&&n<=Z){const K=Math['min'](Q,s);s-=K;const T=Buffer['alloc'](K);await M[l(0xc9)](T,0x0,K,s),j=Buffer['concat']([T,j]),n+=countNewlines(T);}const t=j['toString'](l(0xca))[l(0xcb)]('\x0a')['filter'](h=>h['length']>0x0);return t['slice'](-Z)['reverse']();}finally{await M[l(0xcc)]();}}function countNewlines(d){let Z=0x0;for(const M of d){if(M===0xa)Z++;}return Z;}
1
+ const p=k;import h from'node:fs/promises';import n from'node:path';function Q(){const O=['resolve','startsWith','stat','isDirectory','join','name','directory','file','size','toISOString','localeCompare','split','slice','unshift','text/plain;\x20charset=utf-8','type','</a></li>','replace','open','alloc','read','close'];Q=function(){return O;};return Q();}import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=n[p(0xc6)](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(B,G){const z=p,f=normalizePath(B['path']),j=n['resolve'](LOGS_ROOT,f);if(j!==LOGS_ROOT&&!j[z(0xc7)](LOGS_ROOT+n['sep']))throw new ValidationError('Invalid\x20log\x20path');const Z=await h[z(0xc8)](j)['catch'](()=>null);if(!Z)throw new NotFoundError('Log\x20path\x20not\x20found');if(Z[z(0xc9)]()){const b=await h['readdir'](j,{'withFileTypes':!![]}),P=await Promise['all'](b['map'](async u=>{const t=z,X=await h['stat'](n[t(0xca)](j,u['name']));return{'name':u['name'],'path':f?f+'/'+u['name']:u[t(0xcb)],'type':u[t(0xc9)]()?t(0xcc):t(0xcd),'size':u['isDirectory']()?undefined:X[t(0xce)],'modified':X['mtime'][t(0xcf)]()};}));P['sort']((u,X)=>u['name'][z(0xd0)](X['name']));if(f){const u=f[z(0xd1)]('/')[z(0xd2)](0x0,-0x1)['join']('/');P[z(0xd3)]({'name':'..','path':u,'type':z(0xcc)});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(f,P)};}const e=await tailFile(j,TAIL_LINES);return{'contentType':z(0xd4),'body':e['join']('\x0a')};}function renderDirectory(B,G){const f=G['map'](Z=>{const m=k,e='?path='+encodeURIComponent(Z['path']),b=Z[m(0xd5)]==='directory'?Z[m(0xcb)]+'/':Z[m(0xcb)];return'<li><a\x20href=\x22'+e+'\x22>'+escapeHtml(b)+m(0xd6);})['join']('\x0a'),j=escapeHtml('logs/'+B);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+j+'</title></head>\x0a<body>\x0a<h1>'+j+'</h1>\x0a<ul>\x0a'+f+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(B){const A=p;return B['replace'](/&/g,'&amp;')[A(0xd7)](/</g,'&lt;')['replace'](/>/g,'&gt;')[A(0xd7)](/"/g,'&quot;');}function normalizePath(B){const G=(B??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(G['split']('/')['some'](f=>f==='..'))throw new ValidationError('Invalid\x20log\x20path');return G;}function k(h,n){h=h-0xc6;const B=Q();let G=B[h];return G;}async function tailFile(B,G){const U=p,f=await h[U(0xd8)](B,'r');try{const {size:j}=await f[U(0xc8)](),Z=0x40*0x400;let e=j,b=Buffer['alloc'](0x0),P=0x0;while(e>0x0&&P<=G){const X=Math['min'](Z,e);e-=X;const H=Buffer[U(0xd9)](X);await f[U(0xda)](H,0x0,X,e),b=Buffer['concat']([H,b]),P+=countNewlines(H);}const u=b['toString']('utf8')['split']('\x0a')['filter'](i=>i['length']>0x0);return u[U(0xd2)](-G)['reverse']();}finally{await f[U(0xdb)]();}}function countNewlines(B){let G=0x0;for(const f of B){if(f===0xa)G++;}return G;}
@@ -1 +1 @@
1
- export async function getSystemSettings(w,y){const j=Y,d=await y['pg']['query'](j(0x1b1));return d['rows']['reduce']((Z,M)=>{const n=j,H=String(M['key'])[n(0x1b2)]('.');let Q=Z;for(const s of H[n(0x1b3)](0x0,-0x1)){Q[s]??={},Q=Q[s];}return Q[H['at'](-0x1)]=M[n(0x1b4)],Z;},{});}function Y(w,y){w=w-0x1b1;const d=f();let Z=d[w];return Z;}function f(){const t=['\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','split','slice','value'];f=function(){return t;};return f();}
1
+ function k(h,n){h=h-0xb9;const B=Q();let G=B[h];return G;}export async function getSystemSettings(h,n){const b=k,B=await n['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 B['rows'][b(0xb9)]((G,f)=>{const P=b,j=String(f['key'])[P(0xba)]('.');let Z=G;for(const e of j['slice'](0x0,-0x1)){Z[e]??={},Z=Z[e];}return Z[j['at'](-0x1)]=f[P(0xbb)],G;},{});}function Q(){const u=['reduce','split','value'];Q=function(){return u;};return Q();}
@@ -1 +1 @@
1
- function f(){var Z=['list'];f=function(){return Z;};return f();}function Y(w,y){w=w-0x1ce;var d=f();var Z=d[w];return Z;}export async function listDictionaries(w,y){var d=Y;return y['dictionary'][d(0x1ce)]();}
1
+ function Q(){var G=['dictionary'];Q=function(){return G;};return Q();}function k(h,n){h=h-0x86;var B=Q();var G=B[h];return G;}export async function listDictionaries(h,n){var B=k;return n[B(0x86)]['list']();}
@@ -9,6 +9,7 @@ export declare function setAccess(params: {
9
9
  id: string;
10
10
  access?: AccessInput[];
11
11
  permissions?: string[];
12
+ roles?: string[];
12
13
  user: User;
13
14
  }, ctx: AppContext): Promise<{
14
15
  access: AccessRecord[];
@@ -1 +1 @@
1
- {"version":3,"file":"set-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,KAAK,WAAW,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAoBF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAiDrC"}
1
+ {"version":3,"file":"set-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/D,KAAK,WAAW,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAoBF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAiErC"}
@@ -1 +1 @@
1
- const t=Y;function Y(w,y){w=w-0x7d;const d=f();let Z=d[w];return Z;}import{getAccess}from'./get-access.js';const CRUD_ACTIONS=[t(0x7d),'update','create','delete'];function permissionsToAccess(w){const K=t,y=new Map();for(const d of w){const [Z,M]=d['split'](':');if(!Z)continue;const H=M==='edit'?'update':M,Q=y['get'](Z)??new Set();for(const s of H?[H]:CRUD_ACTIONS)Q['add'](s);y[K(0x7e)](Z,Q);}return[...y][K(0x7f)](([j,n])=>({'resource':j,'actions':[...n]}));}export async function setAccess(w,y){const T=t,d=await y['pg'][T(0x80)]();try{await d['query'](T(0x81));w['type']==='user'?await d[T(0x82)](T(0x83),[w['id']]):await d[T(0x82)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[w['id']]);const Z=w['permissions']?permissionsToAccess(w['permissions']):w[T(0x84)]??[];for(const M of Z){w[T(0x85)]==='user'?await d['query'](T(0x86),[M['resource'],M[T(0x87)],w['id'],w['user']['id'],w['user']['id']]):await d[T(0x82)](T(0x88),[M[T(0x89)],M['actions'],w['id'],w['user']['id'],w[T(0x8a)]['id']]);}await d['query']('COMMIT');}catch(H){await d['query']('ROLLBACK');throw H;}finally{d[T(0x8b)]();}return getAccess(w,y);}function f(){const h=['read','set','map','connect','BEGIN','query','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','access','type','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)','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)','resource','user','release'];f=function(){return h;};return f();}
1
+ function Q(){const H=['update','add','map','BEGIN','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','query','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)','user','resource','actions','release'];Q=function(){return H;};return Q();}function k(h,n){h=h-0x11b;const B=Q();let G=B[h];return G;}import{getAccess}from'./get-access.js';const CRUD_ACTIONS=['read','update','create','delete'];function permissionsToAccess(h){const u=k,n=new Map();for(const B of h){const [G,f]=B['split'](':');if(!G)continue;const j=f==='edit'?u(0x11b):f,Z=n['get'](G)??new Set();for(const e of j?[j]:CRUD_ACTIONS)Z[u(0x11c)](e);n['set'](G,Z);}return[...n][u(0x11d)](([b,P])=>({'resource':b,'actions':[...P]}));}export async function setAccess(h,n){const X=k,B=await n['pg']['connect']();try{await B['query'](X(0x11e));if(h['type']==='user'){await B['query'](X(0x11f),[h['id']]);if(h['roles']!==undefined){await B['query']('DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1',[h['id']]);for(const f of h['roles']){await B[X(0x120)](X(0x121),[h['id'],f,h[X(0x122)]['id'],h['user']['id']]);}}}else await B[X(0x120)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[h['id']]);const G=h['permissions']?permissionsToAccess(h['permissions']):h['access']??[];for(const j of G){h['type']==='user'?await B[X(0x120)]('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)',[j[X(0x123)],j[X(0x124)],h['id'],h['user']['id'],h['user']['id']]):await B['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)',[j['resource'],j['actions'],h['id'],h[X(0x122)]['id'],h['user']['id']]);}await B['query']('COMMIT');}catch(Z){await B['query']('ROLLBACK');throw Z;}finally{B[X(0x125)]();}return getAccess(h,n);}
@@ -0,0 +1,18 @@
1
+ import type { AppContext, User } from "../../../context.js";
2
+ import { getResourceAccess } from "./get-resource-access.js";
3
+ interface UserAccessInput {
4
+ uid: string;
5
+ actions: string[];
6
+ }
7
+ interface RoleAccessInput {
8
+ role_id: string;
9
+ actions: string[];
10
+ }
11
+ export declare function setResourceAccess(params: {
12
+ resource: string;
13
+ users?: UserAccessInput[];
14
+ roles?: RoleAccessInput[];
15
+ user: User;
16
+ }, ctx: AppContext): ReturnType<typeof getResourceAccess>;
17
+ export {};
18
+ //# sourceMappingURL=set-resource-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-resource-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,UAAU,eAAe;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAsEtC"}
@@ -0,0 +1 @@
1
+ import{ValidationError}from'../../../errors.js';import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(h,n){const u=k;if(h[u(0x19e)]===undefined&&h['roles']===undefined)throw new ValidationError(u(0x19f));const B=new Set();for(const j of h['users']??[]){if(B[u(0x1a0)](j['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+j['uid']);B['add'](j['uid']);}const G=new Set();for(const Z of h[u(0x1a1)]??[]){if(G['has'](Z[u(0x1a2)]))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+Z['role_id']);G['add'](Z['role_id']);}const f=await n['pg'][u(0x1a3)]();try{await f['query'](u(0x1a4));if(h['users']!==undefined){await f['query'](u(0x1a5),[h[u(0x1a6)]]);for(const e of h['users']){if(e['actions'][u(0x1a7)]===0x0)continue;await f['query']('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)',[h['resource'],e['actions'],e['uid'],h[u(0x1a8)]['id']]);}}if(h['roles']!==undefined){await f['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[h['resource']]);for(const b of h['roles']){if(b[u(0x1a9)]['length']===0x0)continue;await f['query']('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)',[h['resource'],b['actions'],b['role_id'],h[u(0x1a8)]['id']]);}}await f[u(0x1aa)](u(0x1ab));}catch(P){await f[u(0x1aa)]('ROLLBACK');throw P;}finally{f['release']();}return getResourceAccess({'resource':h['resource']},n);}function k(h,n){h=h-0x19e;const B=Q();let G=B[h];return G;}function Q(){const X=['users','At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided','has','roles','role_id','connect','BEGIN','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL','resource','length','user','actions','query','COMMIT'];Q=function(){return X;};return Q();}
@@ -0,0 +1,10 @@
1
+ import type { AppContext, User } from "../../../context.js";
2
+ import { getResourceScopes } from "./get-resource-scopes.js";
3
+ export declare function setResourceScopes(params: {
4
+ resource: string;
5
+ user_id?: string;
6
+ role_id?: string;
7
+ scopes: Record<string, unknown>;
8
+ user: User;
9
+ }, ctx: AppContext): ReturnType<typeof getResourceScopes>;
10
+ //# sourceMappingURL=set-resource-scopes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-resource-scopes.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/set-resource-scopes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,wBAAsB,iBAAiB,CACrC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,EAAE,IAAI,CAAC;CACZ,EACD,GAAG,EAAE,UAAU,GACd,UAAU,CAAC,OAAO,iBAAiB,CAAC,CA6CtC"}
@@ -0,0 +1 @@
1
+ import{ValidationError}from'../../../errors.js';function k(h,n){h=h-0x108;const B=Q();let G=B[h];return G;}import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(h,n){const Z=k;if(Boolean(h[Z(0x108)])===Boolean(h[Z(0x109)]))throw new ValidationError('Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id');if(Object['keys'](h['scopes'])[Z(0x10a)]===0x0)throw new ValidationError(Z(0x10b));const B=await n['pg'][Z(0x10c)]();try{await B['query'](Z(0x10d)),await B['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',[h['resource'],h['role_id']??null,h[Z(0x108)]??null]);for(const [G,f]of Object['entries'](h['scopes'])){await B[Z(0x10e)]('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)',[h['resource'],h[Z(0x109)]??null,h[Z(0x108)]??null,G,JSON['stringify'](f),h['user']['id']]);}await B['query']('COMMIT');}catch(j){await B['query']('ROLLBACK');throw j;}finally{B['release']();}return clearResourceScopeCache(),getResourceScopes({'resource':h['resource']},n);}function Q(){const e=['user_id','role_id','length','At\x20least\x20one\x20scope\x20must\x20be\x20provided','connect','BEGIN','query'];Q=function(){return e;};return Q();}