@opengis/fcore 0.0.1-beta.9 → 0.0.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 (183) hide show
  1. package/dist/config.d.ts +1 -0
  2. package/dist/config.d.ts.map +1 -1
  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.d.ts +0 -3
  7. package/dist/fastify.d.ts.map +1 -1
  8. package/dist/fastify.js +1 -1
  9. package/dist/fcore.d.ts.map +1 -1
  10. package/dist/fcore.js +1 -1
  11. package/dist/migrations/cli.js +1 -1
  12. package/dist/migrations/runner.js +1 -1
  13. package/dist/modules/auth/adduser-cli.js +1 -1
  14. package/dist/modules/auth/passwd-cli.js +1 -1
  15. package/dist/modules/auth/permission-cli.js +1 -1
  16. package/dist/modules/auth/route.d.ts.map +1 -1
  17. package/dist/modules/auth/route.js +1 -1
  18. package/dist/modules/auth/schema.js +1 -1
  19. package/dist/modules/auth/services/change-password.js +1 -1
  20. package/dist/modules/auth/services/get-current-user.d.ts +2 -0
  21. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  22. package/dist/modules/auth/services/get-current-user.js +1 -1
  23. package/dist/modules/auth/services/registration.js +1 -1
  24. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  25. package/dist/modules/file/mime.js +1 -1
  26. package/dist/modules/file/route.js +1 -1
  27. package/dist/modules/file/schema.js +1 -1
  28. package/dist/modules/file/services/get-file.js +1 -1
  29. package/dist/modules/file/services/resize-file.js +1 -1
  30. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  31. package/dist/modules/file/services/upload-file.js +1 -1
  32. package/dist/modules/resource/route.d.ts.map +1 -1
  33. package/dist/modules/resource/route.js +1 -1
  34. package/dist/modules/resource/schema.d.ts +19 -0
  35. package/dist/modules/resource/schema.d.ts.map +1 -1
  36. package/dist/modules/resource/schema.js +1 -1
  37. package/dist/modules/resource/services/add-note.js +1 -1
  38. package/dist/modules/resource/services/add-resource-file.js +1 -1
  39. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/create-resource.js +1 -1
  41. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  42. package/dist/modules/resource/services/delete-resource.js +1 -1
  43. package/dist/modules/resource/services/export-resource.js +1 -1
  44. package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
  45. package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
  46. package/dist/modules/resource/services/generate-resource-code.js +1 -0
  47. package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
  48. package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
  49. package/dist/modules/resource/services/get-resource-schema.js +1 -0
  50. package/dist/modules/resource/services/get-resource.js +1 -1
  51. package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
  52. package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
  53. package/dist/modules/resource/services/list-resource-as-user.js +1 -0
  54. package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
  55. package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
  56. package/dist/modules/resource/services/list-resource-list.js +1 -0
  57. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  58. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  59. package/dist/modules/resource/services/list-resources.js +1 -1
  60. package/dist/modules/resource/services/search-resource.js +1 -1
  61. package/dist/modules/resource/services/suggest-resource.js +1 -1
  62. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  63. package/dist/modules/resource/services/update-resource.js +1 -1
  64. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  65. package/dist/modules/system/route.d.ts.map +1 -1
  66. package/dist/modules/system/route.js +1 -1
  67. package/dist/modules/system/schema.d.ts +25 -2
  68. package/dist/modules/system/schema.d.ts.map +1 -1
  69. package/dist/modules/system/schema.js +1 -1
  70. package/dist/modules/system/services/check-system.js +1 -1
  71. package/dist/modules/system/services/get-access.d.ts +1 -0
  72. package/dist/modules/system/services/get-access.d.ts.map +1 -1
  73. package/dist/modules/system/services/get-access.js +1 -1
  74. package/dist/modules/system/services/get-api-list.js +1 -1
  75. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  76. package/dist/modules/system/services/get-audit-log.js +1 -1
  77. package/dist/modules/system/services/get-dictionary.js +1 -1
  78. package/dist/modules/system/services/get-resource-access.d.ts +23 -0
  79. package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
  80. package/dist/modules/system/services/get-resource-access.js +1 -0
  81. package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
  82. package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
  83. package/dist/modules/system/services/get-resource-scopes.js +1 -0
  84. package/dist/modules/system/services/get-system-log.js +1 -1
  85. package/dist/modules/system/services/get-system-settings.js +1 -1
  86. package/dist/modules/system/services/list-dictionaries.js +1 -1
  87. package/dist/modules/system/services/set-access.d.ts +3 -1
  88. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  89. package/dist/modules/system/services/set-access.js +1 -1
  90. package/dist/modules/system/services/set-resource-access.d.ts +18 -0
  91. package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
  92. package/dist/modules/system/services/set-resource-access.js +1 -0
  93. package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
  94. package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
  95. package/dist/modules/system/services/set-resource-scopes.js +1 -0
  96. package/dist/modules/system/services/update-dictionary.js +1 -1
  97. package/dist/modules/system/services/update-system-settings.js +1 -1
  98. package/dist/modules/utils/require-admin.js +1 -1
  99. package/dist/modules/utils/safe-user.js +1 -1
  100. package/dist/modules/utils/unsupported.js +1 -1
  101. package/dist/plugins/audit/audit.js +1 -1
  102. package/dist/plugins/audit/audit.types.d.ts +1 -1
  103. package/dist/plugins/audit/audit.types.d.ts.map +1 -1
  104. package/dist/plugins/audit/services/write-audit.js +1 -1
  105. package/dist/plugins/auth/get-user-permissions.js +1 -1
  106. package/dist/plugins/auth/index.d.ts.map +1 -1
  107. package/dist/plugins/auth/index.js +1 -1
  108. package/dist/plugins/auth/verifyUser.js +1 -1
  109. package/dist/plugins/dictionary.js +1 -1
  110. package/dist/plugins/file.d.ts +7 -3
  111. package/dist/plugins/file.d.ts.map +1 -1
  112. package/dist/plugins/file.js +1 -1
  113. package/dist/plugins/jwt.js +1 -1
  114. package/dist/plugins/logger/index.js +1 -1
  115. package/dist/plugins/logger/transport.js +1 -1
  116. package/dist/plugins/pg.d.ts +4 -2
  117. package/dist/plugins/pg.d.ts.map +1 -1
  118. package/dist/plugins/pg.js +1 -1
  119. package/dist/plugins/redis.d.ts.map +1 -1
  120. package/dist/plugins/redis.js +1 -1
  121. package/dist/plugins/resource/resource.d.ts +1 -1
  122. package/dist/plugins/resource/resource.d.ts.map +1 -1
  123. package/dist/plugins/resource/resource.js +1 -1
  124. package/dist/plugins/resource/resource.registry.d.ts +3 -2
  125. package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
  126. package/dist/plugins/resource/resource.registry.js +1 -1
  127. package/dist/plugins/resource/resource.types.d.ts +66 -14
  128. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  129. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  130. package/dist/plugins/resource/services/add-file-token.js +1 -1
  131. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  132. package/dist/plugins/resource/services/create-relation.d.ts +5 -2
  133. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  134. package/dist/plugins/resource/services/create-relation.js +1 -1
  135. package/dist/plugins/resource/services/create.d.ts +5 -2
  136. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  137. package/dist/plugins/resource/services/create.js +1 -1
  138. package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
  139. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  140. package/dist/plugins/resource/services/delete-relation.js +1 -1
  141. package/dist/plugins/resource/services/delete.d.ts +9 -2
  142. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  143. package/dist/plugins/resource/services/delete.js +1 -1
  144. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  145. package/dist/plugins/resource/services/find-one.js +1 -1
  146. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  147. package/dist/plugins/resource/services/find-relation.js +1 -1
  148. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  149. package/dist/plugins/resource/services/find.js +1 -1
  150. package/dist/plugins/resource/services/get-table-columns.d.ts +8 -0
  151. package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
  152. package/dist/plugins/resource/services/get-table-columns.js +1 -0
  153. package/dist/plugins/resource/services/update-relation.d.ts +5 -2
  154. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
  155. package/dist/plugins/resource/services/update-relation.js +1 -1
  156. package/dist/plugins/resource/services/update.d.ts +9 -2
  157. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  158. package/dist/plugins/resource/services/update.js +1 -1
  159. package/dist/plugins/resource/utils/auto-index.js +1 -1
  160. package/dist/plugins/resource/utils/fields.js +1 -1
  161. package/dist/plugins/resource/utils/filters.d.ts +2 -1
  162. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  163. package/dist/plugins/resource/utils/filters.js +1 -1
  164. package/dist/plugins/resource/utils/permissions.js +1 -1
  165. package/dist/plugins/resource/utils/scope.d.ts +10 -0
  166. package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
  167. package/dist/plugins/resource/utils/scope.js +1 -0
  168. package/dist/plugins/resource/utils/sort.d.ts +1 -1
  169. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  170. package/dist/plugins/resource/utils/sort.js +1 -1
  171. package/dist/plugins/resource/utils/sql.d.ts +1 -1
  172. package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
  173. package/dist/plugins/resource/utils/sql.js +1 -1
  174. package/dist/plugins/resource/utils/summary.d.ts +7 -0
  175. package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
  176. package/dist/plugins/resource/utils/summary.js +1 -0
  177. package/dist/shared/getIP.js +1 -1
  178. package/migrations/20260903120000_core_schema.sql +5 -2
  179. package/migrations/20260903130001_add_file_fields.sql +5 -0
  180. package/migrations/20260910170000_core_schema.sql +22 -0
  181. package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
  182. package/migrations/20260929_role_scope.sql +32 -0
  183. package/package.json +2 -2
@@ -1 +1 @@
1
- function c(J,e){J=J-0x135;const p=L();let b=p[J];return b;}export async function addNote(J,e){const b=c,p=await e['pg']['query'](b(0x135),[J[b(0x136)],String(J['id']),J[b(0x137)]]);return p['rows'][0x0];}function L(){const F=['INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','resource','body'];L=function(){return F;};return L();}
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 +1 @@
1
- function L(){const F=['query','rows'];L=function(){return F;};return L();}function c(J,e){J=J-0xdd;const p=L();let b=p[J];return b;}export async function addResourceFile(J,e){const b=c,p=await e['pg'][b(0xdd)]('\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',[J['resource'],String(J['id']),J['filePath'],J['size']??null]);return p[b(0xde)][0x0];}
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 +1 @@
1
- export async function createResourceRelation(J,e){const u=c,{resource:p,id:b,relation:F,data:P,user:h}=J;return e['resource'][u(0x100)]({'name':p,'id':b,'relation':F,'data':P,'user':h});}function c(J,e){J=J-0x100;const p=L();let b=p[J];return b;}function L(){const H=['createRelation'];L=function(){return H;};return L();}
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 +1 @@
1
- function c(J,e){J=J-0xa4;var p=L();var b=p[J];return b;}export async function createResource(J,e){var p=c;return e['resource'][p(0xa4)]({'name':J['resource'],'data':J['data'],'user':J['user']});}function L(){var b=['create'];L=function(){return b;};return L();}
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 +1 @@
1
- export async function deleteResourceRelation(J,e){const h=c,{resource:p,id:b,relation:F,relationId:P}=J;return e['resource'][h(0x110)]({'name':p,'id':b,'relation':F,'relationId':P});}function c(J,e){J=J-0x110;const p=L();let b=p[J];return b;}function L(){const u=['deleteRelation'];L=function(){return u;};return L();}
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 +1 @@
1
- function L(){var b=['resource'];L=function(){return b;};return L();}function c(J,e){J=J-0xd5;var p=L();var b=p[J];return b;}export async function deleteResource(J,e){var p=c;return e['resource']['delete']({'name':J[p(0xd5)],'id':J['id'],'user':J['user']});}
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 +1 @@
1
- function c(J,e){J=J-0x16c;const p=L();let b=p[J];return b;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function L(){const F=['find','resource','user'];L=function(){return F;};return L();}export async function exportResource(J,e){const b=c,p=await e['resource'][b(0x16c)]({'name':J[b(0x16d)],'query':{'filter':parseFilterQuery(J),'sort':J['sort'],'search':J['search'],'limit':J['limit'],'offset':J['offset'],'fields':J['fields']},'user':J[b(0x16e)]});return p['rows'];}
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'];}
@@ -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 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};}
@@ -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(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 +1 @@
1
- export async function getResource(J,e){var p=c;return e[p(0x1ce)][p(0x1cf)]({'name':J[p(0x1ce)],'id':J['id'],'query':{'include':J[p(0x1d0)]},'user':J['user']});}function c(J,e){J=J-0x1ce;var p=L();var b=p[J];return b;}function L(){var b=['resource','findOne','include'];L=function(){return b;};return L();}
1
+ export async function getResource(P,G){return G['resource']['findOne']({'name':P['resource'],'id':P['id'],'query':{'include':P['include']},'user':P['user']});}
@@ -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
+ 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};}
@@ -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 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 +1 @@
1
- export async function listResourceRelation(J,e){const {resource:p,id:b,relation:F,query:P,user:h}=J;return e['resource']['findRelation']({'name':p,'id':b,'relation':F,'query':P,'user':h});}
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 +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,CAY9E"}
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 L(){var b=['resource','max'];L=function(){return b;};return L();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function c(J,e){J=J-0xbb;var p=L();var b=p[J];return b;}export async function listResources(J,e){var p=c;return e[p(0xbb)]['find']({'name':J['resource'],'query':{'filter':parseFilterQuery(J),'sort':J['sort'],'search':J['search'],'limit':J['limit'],'offset':J['offset']??(J['page']?Math[p(0xbc)](J['page']-0x1,0x0):0x0)*(J['limit']??0x14)},'user':J['user']});}
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 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function c(J,e){J=J-0x139;var p=L();var b=p[J];return b;}function L(){var b=['find'];L=function(){return b;};return L();}export async function searchResource(J,e){var p=c;return e['resource'][p(0x139)]({'name':J['resource'],'query':{...J,'filter':parseFilterQuery(J)},'user':J['user']});}
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 +1 @@
1
- function c(J,e){J=J-0x1af;const p=L();let b=p[J];return b;}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(J,e){const T=c,p=e['resource']['get'](J['resource']),b=String(J['search']??J['q']??'')['toLowerCase'](),F=Math['min'](Math['max'](Number(J['limit']??0x14),0x1),0xc8),P=Date['now'](),h=p[T(0x1af)][J['field']],u=h?.['dictionary'],H=h?.['lookup']?.[T(0x1b0)];if(H){const w=h['lookup']?.['text']??'name',X=h['lookup']?.[T(0x1b1)]??'id';autoIndex(H,w,'text',e['pg']);const E=await e['pg']['query'](T(0x1b2)+X+'\x20as\x20id,\x20'+w+T(0x1b3)+H+'\x20WHERE\x20lower('+w+T(0x1b4),[''+b['toLowerCase'](),F])[T(0x1b5)](Q=>Q[T(0x1b6)]);return{'limit':F,'count':E['length'],'search':b,'time':Date[T(0x1b7)]()-P,'data':E};}if(!u)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+J['field']);const D=await e['dictionary']['get'](u),U=D[T(0x1b8)](Q=>!b||Q['code']['startsWith'](b)||Q['name'][T(0x1b9)](b))['slice'](0x0,F)['map'](Q=>({'id':Q['code']||Q['id'],'text':Q[T(0x1ba)]||Q[T(0x1bb)]}));return{'search':b,'limit':F,'count':U[T(0x1bc)],'time':Date['now']()-P,'data':U};}function L(){const l=['fields','table','value','SELECT\x20','\x20as\x20text\x20FROM\x20',')\x20~\x20$1\x20LIMIT\x20$2','then','rows','now','filter','startsWith','name','text','length'];L=function(){return l;};return L();}
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 +1 @@
1
- function c(J,e){J=J-0x12b;const p=L();let b=p[J];return b;}export async function updateResourceRelation(J,e){const H=c,{resource:p,id:b,relation:F,relationId:P,data:h,user:u}=J;return e[H(0x12b)][H(0x12c)]({'name':p,'id':b,'relation':F,'relationId':P,'data':h,'user':u});}function L(){const D=['resource','updateRelation'];L=function(){return D;};return L();}
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 +1 @@
1
- export async function updateResource(J,e){return e['resource']['update']({'name':J['resource'],'id':J['id'],'data':J['patch'],'user':J['user']});}
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 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function L(){const u=['resource','access','user','includes','Missing\x20permission:\x20','name',':update','file','fileName','replace','File\x20name\x20is\x20required','files/','put','Uploaded\x20file\x20not\x20found','query','length'];L=function(){return u;};return L();}function c(J,e){J=J-0x166;const p=L();let b=p[J];return b;}export async function uploadResourceFile(J,e){const h=c,p=e[h(0x166)]['get'](J['resource']);if(p[h(0x167)]==='admin'&&J[h(0x168)]?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(J[h(0x168)]?.['type']!=='admin'&&!J[h(0x168)]?.['permissions']?.[h(0x169)]((p['permission']??p['name'])+':update'))throw new ForbiddenError(h(0x16a)+(p['permission']??p[h(0x16b)])+h(0x16c));if(!Buffer['isBuffer'](J[h(0x16d)])||J['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const b=J[h(0x16e)][h(0x16f)](/[^A-Za-z0-9._-]/g,'_');if(!b)throw new ValidationError(h(0x170));const F=h(0x171)+J['resource']+'/'+String(J['id'])+'/'+b;await e[h(0x16d)][h(0x172)](F,J['file']);if(!await e['file']['exists'](F))throw new NotFoundError(h(0x173));const P=await e['pg'][h(0x174)]('\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',[J['resource'],String(J['id']),F,J['file'][h(0x175)]]);return P['rows'][0x0];}
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 +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
- 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';function c(J,e){J=J-0xc9;const p=L();let b=p[J];return b;}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{setAccess}from'./services/set-access.js';function L(){const w=['system','system:dictionaries','post','fcore','user','dictionaryName','body','params','get','/api/access/:type/:id','system:access','Set\x20access\x20rules','/api/system/settings','system:settings','/api/system/logger','system:logs','query','Get\x20audit\x20log','system:audit','Checks\x20the\x20availability\x20of\x20system\x20dependencies.','/api/system/list'];L=function(){return w;};return L();}import{systemSchemas}from'./schema.js';const u=J=>J['user'];export function systemRoutes(J,e=new Map()){return async p=>{const D=c;p['get']('/api/dictionary/:name',{'schema':{'tags':['fcore',D(0xc9)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':[D(0xca)],'params':systemSchemas['dictionaryName']}},async F=>({'items':await getDictionary({...F['params'],'user':u(F)},J)})),p[D(0xcb)]('/api/dictionary/:name',{'schema':{'tags':[D(0xcc),'system'],'summary':'Update\x20platform\x20dictionary','description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':D(0xcd),'permissions':['system:dictionaries'],'params':systemSchemas[D(0xce)],'body':systemSchemas['dictionaryItems']}},async F=>updateDictionary({...F['params'],...F[D(0xcf)],'user':u(F)},J));const b=async F=>getAccess({...F[D(0xd0)],'user':u(F)},J);p[D(0xd1)](D(0xd2),{'schema':{'tags':[D(0xcc),'system'],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[D(0xd3)],'params':systemSchemas['accessTarget']}},b),p['post'](D(0xd2),{'schema':{'tags':['fcore','system'],'summary':D(0xd4),'description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[D(0xd3)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async F=>setAccess({...F[D(0xd0)],...F[D(0xcf)],'user':u(F)},J)),p[D(0xd1)](D(0xd5),{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[D(0xd6)]}},async F=>getSystemSettings({...F['params'],'user':u(F)},J)),p['post']('/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)},J)),p[D(0xd1)](D(0xd7),{'schema':{'tags':[D(0xcc),'system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':[D(0xd8)],'querystring':systemSchemas['logger']}},async(F,P)=>{const U=D,{contentType:h,body:H}=await getSystemLog({...F[U(0xd9)],'user':u(F)},J);return P['type'](h)['send'](H);}),p['get']('/api/system/audit',{'schema':{'tags':[D(0xcc),D(0xc9)],'summary':D(0xda),'description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':'user','permissions':[D(0xdb)]}},async F=>getAuditLog({...F['query'],'user':u(F)},J)),p[D(0xd1)]('/api/system/check',{'schema':{'tags':['fcore',D(0xc9)],'summary':'Check\x20system\x20health','description':D(0xdc),'access':'user','permissions':['system:check']}},async F=>checkSystem({'user':u(F)},J)),p['get'](D(0xdd),{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas['apiListQuery']}},async F=>getApiList({'user':u(F),'apiRoutes':e,...F[D(0xd9)]},J));};}
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));};}
@@ -15,11 +15,34 @@ 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<{
19
- access: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
40
+ roles: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
41
+ permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
42
+ access: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
20
43
  resource: import("@sinclair/typebox").TString;
21
44
  actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
22
- }>>;
45
+ }>>>;
23
46
  }>;
24
47
  apiListQuery: import("@sinclair/typebox").TObject<{
25
48
  format: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"short">, import("@sinclair/typebox").TLiteral<"extended">]>>;
@@ -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;;;;;;IAQN,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
- const J=c;function c(J,e){J=J-0x78;const p=L();let b=p[J];return b;}function L(){const e=['Object','Union','Null','String','Optional','Unknown'];L=function(){return e;};return L();}import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type[J(0x78)]({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type[J(0x78)]({'id':Type['Optional'](Type['Union']([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type[J(0x79)]([Type['String'](),Type['Number'](),Type[J(0x7a)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'access':Type[J(0x78)]({'access':Type['Array'](Type[J(0x78)]({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type[J(0x7b)]({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})}))}),'apiListQuery':Type[J(0x78)]({'format':Type[J(0x7c)](Type['Union']([Type['Literal']('short'),Type['Literal']('extended')]))}),'settingsEntity':Type[J(0x78)]({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type[J(0x7d)]()),'logger':Type['Object']({'path':Type[J(0x7c)](Type[J(0x7b)]({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
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 +1 @@
1
- function c(J,e){J=J-0x14a;const p=L();let b=p[J];return b;}export async function checkSystem(J,e){const F=c,[p,b]=await Promise['allSettled']([e['pg'][F(0x14a)]('SELECT\x201'),e[F(0x14b)]['ping']()]);return{'status':p['status']===F(0x14c)&&b['status']==='fulfilled'?'ok':'degraded','pg':p[F(0x14d)],'redis':b[F(0x14d)]};}function L(){const P=['query','redis','fulfilled','status'];L=function(){return P;};return L();}
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();}
@@ -10,5 +10,6 @@ export declare function getAccess(params: {
10
10
  user: User;
11
11
  }, ctx: AppContext): Promise<{
12
12
  access: AccessRecord[];
13
+ resources: string[];
13
14
  }>;
14
15
  //# sourceMappingURL=get-access.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAkBrC"}
1
+ {"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwB1D"}
@@ -1 +1 @@
1
- function L(){const P=['query'];L=function(){return P;};return L();}function c(J,e){J=J-0x118;const p=L();let b=p[J];return b;}export async function getAccess(J,e){const F=c,p=J['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',b=await e['pg'][F(0x118)](p,[J['id']]);return{'access':b['rows']};}
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 +1 @@
1
- function c(J,e){J=J-0x10a;const p=L();let b=p[J];return b;}export async function getApiList(J,e){const u=c,p=[...J['apiRoutes'][u(0x10a)]()][u(0x10b)]((b,F)=>(b['endpoint']+'\x20'+b[u(0x10c)])['localeCompare'](F[u(0x10d)]+'\x20'+F['method']));if(J['format']!=='short')return p;return p[u(0x10e)](({method:b,endpoint:F,access:P,permissions:h})=>b+'\x20'+F);}function L(){const H=['values','sort','method','endpoint','map'];L=function(){return H;};return L();}
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 +1 @@
1
- {"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAcd"}
1
+ {"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAmBd"}
@@ -1 +1 @@
1
- export async function getAuditLog(J,e){const P=c,p=Math['min'](Math[P(0x1a7)](J['limit']??0x32,0x1),0xc8),b=Math['max']((J[P(0x1a8)]??0x1)-0x1,0x0)*p,F=await e['pg']['query'](P(0x1a9),[p,b]);return{'rows':F['rows'],'page':J[P(0x1a8)]??0x1,'limit':p};}function c(J,e){J=J-0x1a7;const p=L();let b=p[J];return b;}function L(){const h=['max','page','SELECT\x20*\x20FROM\x20admin.audit_log\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2'];L=function(){return h;};return L();}
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 +1 @@
1
- function c(J,e){J=J-0x1b3;var p=L();var b=p[J];return b;}function L(){var b=['dictionary'];L=function(){return b;};return L();}export async function getDictionary(J,e){var p=c;return e[p(0x1b3)]['get'](J['name']);}
1
+ export async function getDictionary(P,G){return G['dictionary']['get'](P['name']);}
@@ -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 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();}
@@ -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
+ 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 +1 @@
1
- const Q=c;import J from'node:fs/promises';import e from'node:path';function L(){const Y=['logs','Log\x20path\x20not\x20found','name','isDirectory','toISOString','split','join','directory','map','type','logs/','<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>','replace','Invalid\x20log\x20path','min','read','toString'];L=function(){return Y;};return L();}import{NotFoundError,ValidationError}from'../../../errors.js';function c(J,e){J=J-0xf5;const p=L();let b=p[J];return b;}const LOGS_ROOT=e['resolve'](process['cwd'](),Q(0xf5)),TAIL_LINES=0x64;export async function getSystemLog(p,b){const T=Q,F=normalizePath(p['path']),P=e['resolve'](LOGS_ROOT,F);if(P!==LOGS_ROOT&&!P['startsWith'](LOGS_ROOT+e['sep']))throw new ValidationError('Invalid\x20log\x20path');const h=await J['stat'](P)['catch'](()=>null);if(!h)throw new NotFoundError(T(0xf6));if(h['isDirectory']()){const H=await J['readdir'](P,{'withFileTypes':!![]}),D=await Promise['all'](H['map'](async U=>{const l=T,w=await J['stat'](e['join'](P,U[l(0xf7)]));return{'name':U['name'],'path':F?F+'/'+U[l(0xf7)]:U['name'],'type':U[l(0xf8)]()?'directory':'file','size':U[l(0xf8)]()?undefined:w['size'],'modified':w['mtime'][l(0xf9)]()};}));D['sort']((U,w)=>U['name']['localeCompare'](w['name']));if(F){const U=F[T(0xfa)]('/')['slice'](0x0,-0x1)[T(0xfb)]('/');D['unshift']({'name':'..','path':U,'type':T(0xfc)});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(F,D)};}const u=await tailFile(P,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':u['join']('\x0a')};}function renderDirectory(p,b){const a=Q,F=b[a(0xfd)](h=>{const M=a,u='?path='+encodeURIComponent(h['path']),H=h[M(0xfe)]===M(0xfc)?h['name']+'/':h['name'];return'<li><a\x20href=\x22'+u+'\x22>'+escapeHtml(H)+'</a></li>';})['join']('\x0a'),P=escapeHtml(a(0xff)+p);return a(0x100)+P+'</title></head>\x0a<body>\x0a<h1>'+P+'</h1>\x0a<ul>\x0a'+F+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(p){return p['replace'](/&/g,'&amp;')['replace'](/</g,'&lt;')['replace'](/>/g,'&gt;')['replace'](/"/g,'&quot;');}function normalizePath(p){const d=Q,b=(p??'')[d(0x101)](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(b['split']('/')['some'](F=>F==='..'))throw new ValidationError(d(0x102));return b;}async function tailFile(p,b){const A=Q,F=await J['open'](p,'r');try{const {size:P}=await F['stat'](),h=0x40*0x400;let u=P,H=Buffer['alloc'](0x0),D=0x0;while(u>0x0&&D<=b){const w=Math[A(0x103)](h,u);u-=w;const X=Buffer['alloc'](w);await F[A(0x104)](X,0x0,w,u),H=Buffer['concat']([X,H]),D+=countNewlines(X);}const U=H[A(0x105)]('utf8')['split']('\x0a')['filter'](E=>E['length']>0x0);return U['slice'](-b)['reverse']();}finally{await F['close']();}}function countNewlines(p){let b=0x0;for(const F of p){if(F===0xa)b++;}return b;}
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 +1 @@
1
- export async function getSystemSettings(J,e){const H=c,p=await e['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 p[H(0x154)]['reduce']((b,F)=>{const P=String(F['key'])['split']('.');let h=b;for(const u of P['slice'](0x0,-0x1)){h[u]??={},h=h[u];}return h[P['at'](-0x1)]=F['value'],b;},{});}function c(J,e){J=J-0x154;const p=L();let b=p[J];return b;}function L(){const D=['rows'];L=function(){return D;};return L();}
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 +1 @@
1
- export async function listDictionaries(J,e){var p=c;return e['dictionary'][p(0x169)]();}function c(J,e){J=J-0x169;var p=L();var b=p[J];return b;}function L(){var b=['list'];L=function(){return b;};return L();}
1
+ export async function listDictionaries(P,G){return G['dictionary']['list']();}
@@ -7,7 +7,9 @@ type AccessInput = {
7
7
  export declare function setAccess(params: {
8
8
  type: "user" | "role";
9
9
  id: string;
10
- access: AccessInput[];
10
+ access?: AccessInput[];
11
+ permissions?: string[];
12
+ roles?: string[];
11
13
  user: User;
12
14
  }, ctx: AppContext): Promise<{
13
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;AAE5D,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;AAEF,wBAAsB,SAAS,CAC3B,MAAM,EAAE;IACJ,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,IAAI,EAAE,IAAI,CAAC;CACd,EACD,GAAG,EAAE,UAAU,GAChB,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CA6CrC"}
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"}