@opengis/fcore 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/generate-resource-code.js +1 -1
- package/dist/modules/resource/services/get-resource-schema.js +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.js +1 -1
- package/dist/modules/resource/services/list-resource-list.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.js +1 -1
- package/dist/modules/system/services/get-resource-scopes.js +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.js +1 -1
- package/dist/modules/system/services/set-resource-scopes.js +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/get-table-columns.js +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/scope.js +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +1 -1
- package/package.json +92 -92
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(p,Z){p=p-0x15b;const A=s();let I=A[p];return I;}function s(){const Z=['String','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Integer','Optional','Array'];s=function(){return Z;};return s();}const p=f;import{Type}from'@sinclair/typebox';export const identifier=Type[p(0x15b)]({'minLength':0x1,'maxLength':0x80,'pattern':p(0x15c)});export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type[p(0x15d)]({'resource':identifier}),'resourceScopeTarget':Type['Object']({'resource':identifier,'user':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type['Optional'](Type['String']()),'search':Type['Optional'](Type[p(0x15b)]()),'limit':Type['Optional'](Type[p(0x15e)]({'minimum':0x1,'maximum':0xc8}))}),'resourceListQuery':Type['Object']({'search':Type['Optional'](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type['Object']({'id':Type[p(0x15f)](Type[p(0x15b)]({'minLength':0x1,'maxLength':0x80})),'field':Type[p(0x15f)](identifier),'template':Type['Optional'](Type['String']({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type['Object']({'include':Type['Optional'](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'resourceIdFileId':Type['Object']({'resource':identifier,'id':identifier,'fid':identifier}),'uploadResourceFile':Type[p(0x15d)]({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type['Any'](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type[p(0x15d)]({'filter':Type['Optional'](Type['Record'](Type[p(0x15b)](),Type['Unknown']())),'sort':Type[p(0x15f)](Type['Array'](Type['String']({'minLength':0x1}))),'search':Type[p(0x15f)](Type['String']()),'scope':Type['Optional'](Type['String']()),'limit':Type[p(0x15f)](Type[p(0x15e)]({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type['Integer']({'minimum':0x0})),'fields':Type[p(0x15f)](Type[p(0x160)](identifier))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function addNote(p,Z){const A=await Z['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[p['resource'],String(p['id']),p['body']]);return A['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function addResourceFile(p,Z){const I=f,A=await Z['pg'][I(0xe1)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[p[I(0xe2)],String(p['id']),p[I(0xe3)],p['size']??null]);return A['rows'][0x0];}function f(p,Z){p=p-0xe1;const A=s();let I=A[p];return I;}function s(){const j=['query','resource','filePath'];s=function(){return j;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0x1c8;const A=s();let I=A[p];return I;}export async function createResourceRelation(p,Z){const R=f,{resource:A,id:I,relation:j,data:D,user:o}=p;return Z[R(0x1c8)][R(0x1c9)]({'name':A,'id':I,'relation':j,'data':D,'user':o});}function s(){const B=['resource','createRelation'];s=function(){return B;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0xae;var A=s();var I=A[p];return I;}export async function createResource(p,Z){var A=f;return Z[A(0xae)]['create']({'name':p[A(0xae)],'data':p['data'],'user':p['user']});}function s(){var I=['resource'];s=function(){return I;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResourceRelation(
|
|
1
|
+
export async function deleteResourceRelation(p,Z){const {resource:A,id:I,relation:j,relationId:D}=p;return Z['resource']['deleteRelation']({'name':A,'id':I,'relation':j,'relationId':D});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0x13b;var A=s();var I=A[p];return I;}function s(){var I=['resource'];s=function(){return I;};return s();}export async function deleteResource(p,Z){var A=f;return Z['resource']['delete']({'name':p[A(0x13b)],'id':p['id'],'user':p['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0x8e;const A=s();let I=A[p];return I;}function s(){const j=['resource','limit','offset','rows'];s=function(){return j;};return s();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(p,Z){const I=f,A=await Z[I(0x8e)]['find']({'name':p[I(0x8e)],'query':{'filter':parseFilterQuery(p),'sort':p['sort'],'search':p['search'],'limit':p[I(0x8f)],'offset':p[I(0x90)],'fields':p['fields']},'user':p['user']});return A[I(0x91)];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function s(){const V=['key','column','query','SELECT\x20*\x20FROM\x20','table','where','\x20<>\x20$','length','\x20AND\x20','created_at','SELECT\x20count(*)::int\x20+\x201\x20AS\x20num,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20','\x20>=\x20',')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20','\x20t\x20','rows','mnum','num','field','code_template','has','resource','set'];s=function(){return V;};return s();}function f(p,Z){p=p-0xfb;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function relationValue(p,Z,A){const I=Z['fields'][A]?.['column']??A;return p[I]??p[A];}async function resolvePath(p,Z,A,I){const K=f,[j,...D]=p['split']('.');if(!j)return undefined;const o=A['relations']?.[j];if(!o||!D['length']||!o['resource'])return relationValue(Z,A,p);const R=I['resource']['get'](o['resource']),B=R[K(0xfb)];let H,e;if(o['localKey'])H=relationValue(Z,A,o['localKey']),e=B;else{if(o['foreignKey'])H=relationValue(Z,A,A['key']),e=o['foreignKey'];else return undefined;}if(H===null||H===undefined)return undefined;const g=R['fields'][e]?.[K(0xfc)]??e,N=await I['pg'][K(0xfd)](K(0xfe)+qt(R[K(0xff)])+'\x20t\x20WHERE\x20t.'+qi(g)+'\x20=\x20$1'+(o['where']?'\x20AND\x20('+o['where']+')':'')+'\x20LIMIT\x201',[H]),h=N['rows'][0x0];if(!h)return undefined;const E=D[0x0];if(!E)return undefined;if(D['length']===0x1)return relationValue(h,R,E);return resolvePath(D['join']('.'),h,R,I);}async function countValues(p,Z,A,I){const Q=f,j=[],D=p['where']?['('+p[Q(0x100)]+')']:[];Z!==undefined&&(j['push'](Z),D['push']('t.'+qi(p[Q(0xfb)])+Q(0x101)+j['length']));const o=D[Q(0x102)]?'WHERE\x20'+D['join'](Q(0x103)):'',R=p['fields'][Q(0x104)],B=R?'t.'+qi(R['column']??'created_at'):undefined,H=new Date(I['getFullYear'](),0x0,0x1),e=new Date(I['getFullYear'](),I['getMonth'](),0x1);if(B){j['push'](H,e);const h='$'+(j['length']-0x1),E='$'+j['length'],a=await A['pg']['query'](Q(0x105)+B+Q(0x106)+h+Q(0x107)+B+'\x20>=\x20'+E+')::int\x20+\x201\x20AS\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(p['table'])+Q(0x108)+o,j),X=a[Q(0x109)][0x0];return{'num':Number(X?.['num']??0x1),'ynum':Number(X?.['ynum']??0x1),'mnum':Number(X?.[Q(0x10a)]??0x1)};}const g=await A['pg']['query']('SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20'+qt(p['table'])+'\x20t\x20'+o,j),N=Number(g['rows'][0x0]?.[Q(0x10b)]??0x1);return{'num':N,'ynum':N,'mnum':N};}export async function generateResourceCode(p,Z){const G=f,A=Z['resource']['get'](p['resource']);if(p['field']&&!A['fields'][p['field']])throw new ValidationError('Unknown\x20resource\x20field:\x20'+p[G(0x10c)]);const I=p['template']??(p['field']?A['fields'][p['field']]?.[G(0x10d)]:undefined);if(!I)return{'resource':A['name'],...p['id']!==undefined?{'id':p['id']}:{},...p['field']?{'field':p[G(0x10c)]}:{},'template':null,'code':null};const j=new Date(),D=await countValues(A,p['id'],Z,j);let o={};if(p['id']!==undefined){const e=await Z['pg']['query'](G(0xfe)+qt(A[G(0xff)])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(A['key'])+'\x20=\x20$1'+(A['where']?'\x20AND\x20('+A[G(0x100)]+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[p['id']]);o=e[G(0x109)][0x0]??{};}const R=[...I['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],B=new Map();for(const g of R){const N=g[0x1];if(!N||B[G(0x10e)](g[0x0]))continue;const h=Number(g[0x2]??0x0);let E;switch(N){case G(0x10b):E=D['num'];break;case'ynum':E=D['ynum'];break;case G(0x10a):E=D['mnum'];break;case'yyyy':E=String(j['getFullYear']());break;case'yy':E=String(j['getFullYear']())['slice'](-0x2);break;case'mm':E=String(j['getMonth']()+0x1)['padStart'](0x2,'0');break;case'dd':E=String(j['getDate']())['padStart'](0x2,'0');break;case G(0x10f):E=A['name'];break;case'resource_id':E=p['id'];break;default:E=p['id']===undefined?undefined:await resolvePath(N,o,A,Z);}if(E===null||E===undefined||E==='')throw new ValidationError('Cannot\x20resolve\x20code\x20template\x20variable:\x20{'+N+'}');const a=String(E);B[G(0x110)](g[0x0],h&&/^\d+$/['test'](a)?a['padStart'](h,'0'):a);}const H=I['replace'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,X=>B['get'](X)??X);return{'resource':A['name'],...p['id']!==undefined?{'id':p['id']}:{},...p['field']?{'field':p['field']}:{},'template':I,'code':H};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0xf0;const A=s();let I=A[p];return I;}function s(){const K=['geometry','string','add','name','fields','read','resource','get','type','array','title'];s=function(){return K;};return s();}function variableType(p){const E=f;switch(p){case'number':case'integer':return'number';case'boolean':return'boolean';case'json':case E(0xf0):case'geom':return'object';default:return E(0xf1);}}function buildVariables(p,Z,A='',I=new Set()){const a=f,j=new Set(I)[a(0xf2)](p[a(0xf3)]),D=[];for(const [o,R]of Object['entries'](p[a(0xf4)])){if(R[a(0xf5)]===![]||R['readable']===![])continue;D['push']({'key':o,'path':A?A+'.'+o:o,'type':variableType(R['type'])});}for(const [B,H]of Object['entries'](p['relations']??{})){if(!H['resource']||!Z[a(0xf6)]['has'](H['resource']))continue;const e=Z['resource'][a(0xf7)](H['resource']),g=A?A+'.'+B:B,N=H[a(0xf8)]==='many',h={'key':B,'path':g,'type':N?a(0xf9):'object','resource':H['resource'],'variables':j['has'](e['name'])?[]:buildVariables(e,Z,g,j)};D['push'](h);}return D;}export function getResourceSchema(p,Z){const X=f,A=Z[X(0xf6)]['get'](p['resource']);return{'resource':A['name'],...A['title']?{'title':A[X(0xfa)]}:{},'variables':buildVariables(A,Z)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getResource(
|
|
1
|
+
function f(p,Z){p=p-0x10f;var A=s();var I=A[p];return I;}function s(){var I=['findOne','resource'];s=function(){return I;};return s();}export async function getResource(p,Z){var A=f;return Z['resource'][A(0x10f)]({'name':p[A(0x110)],'id':p['id'],'query':{'include':p['include']},'user':p['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';function s(){const B=['query','user','User\x20not\x20found:\x20','scope','resource'];s=function(){return B;};return s();}function f(p,Z){p=p-0x15f;const A=s();let I=A[p];return I;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';export async function listResourceAsUser(p,Z){const R=f;if(p['requester']?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const A=await Z['pg'][R(0x15f)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[p[R(0x160)]]),I=A['rows'][0x0];if(!I)throw new NotFoundError(R(0x161)+p['user']);const j={'id':I['uid'],'type':I['type'],'permissions':await getUserPermissions(I['uid'],Z)},[D,o]=await Promise['all']([Z['resource']['find']({'name':p['resource'],'query':{'filter':parseFilterQuery(p),'sort':p['sort'],'search':p['search'],'include':p['include'],'scope':p[R(0x162)],'limit':p['limit'],'offset':p['offset']??(p['page']?Math['max'](Number(p['page'])-0x1,0x0):0x0)*Number(p['limit']??0x14)},'user':j}),getUserResourceScopes(j['id'],p[R(0x163)],Z['pg'])]);return{...D,'scopes':o};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';
|
|
1
|
+
function f(p,Z){p=p-0x79;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function columnExpression(p,Z){const a=f;if(Z!==p['key']&&!p['fields'][Z])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+Z);const A=p[a(0x79)][Z]?.[a(0x7a)]??Z;return A['split']('.')['map'](I=>quoteIdentifier(I))[a(0x7b)]('.');}function displayExpression(p){const X=f,Z=p[X(0x7c)];if(!Z||Array['isArray'](Z)&&Z[X(0x7d)]===0x0)throw new ValidationError(X(0x7e)+p['name']);if(Array['isArray'](Z))return X(0x7f)+Z[X(0x80)](D=>X(0x81)+columnExpression(p,D)+X(0x82))['join'](',\x20')+')';const A=[],I=/\{([^{}]+)\}/g;let j=0x0;for(const D of Z['matchAll'](I)){const o=D[X(0x83)]??0x0,R=D[0x1];if(!R)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);o>j&&A['push']('\x27'+Z[X(0x84)](j,o)['replace'](/'/g,'\x27\x27')+'\x27'),A['push']('COALESCE('+columnExpression(p,R)+'::text,\x20\x27\x27)'),j=o+D[0x0]['length'];}j<Z['length']&&A[X(0x85)]('\x27'+Z[X(0x84)](j)['replace'](/'/g,'\x27\x27')+'\x27');if(A[X(0x7d)]===0x0)throw new ValidationError('Invalid\x20display\x20template\x20for\x20resource:\x20'+p['name']);return'concat('+A['join'](',\x20')+')';}export async function listResourceList(p,Z){const K=f,A=Date['now'](),I=Z['resource']['get'](p['resource']);assertOperation(I,K(0x86),p['user']);const j=p['search']??'',D=Math['min'](Math['max'](Number(p['limit']??0x14),0x1),0xc8),o=I['searchable']??Object['entries'](I[K(0x79)])['filter'](([,h])=>h['searchable'])[K(0x80)](([h])=>h);if(j&&o[K(0x7d)]===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+I['name']);const R=displayExpression(I),B=[],H=[];if(I['where'])B[K(0x85)]('('+I['where']+')');if(j){const h=o[K(0x80)](E=>columnExpression(I,E)+K(0x87));B['push']('('+h[K(0x7b)]('\x20OR\x20')+')'),H['push']('%'+j+'%');}H[K(0x85)](D);const e=B[K(0x7d)]?'WHERE\x20'+B['join'](K(0x88)):'',g=I['joins']?.['map'](E=>E[K(0x89)])[K(0x7b)]('\x20')??'',N=await Z['pg']['query']('SELECT\x20'+quoteIdentifier(I[K(0x8a)])+'\x20AS\x20id,\x20'+R+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(I[K(0x8b)])+'\x20t\x20'+g+K(0x8c)+e+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+H['length'],H);return{'search':j,'limit':D,'count':N[K(0x8d)][K(0x7d)],'time':Date['now']()-A,'data':N[K(0x8d)]};}function s(){const Q=['fields','column','join','display','length','Resource\x20has\x20no\x20display\x20fields:\x20','concat_ws(\x27\x20\x27,\x20','map','COALESCE(','::text,\x20\x27\x27)','index','slice','push','read','::text\x20ILIKE\x20$1','\x20AND\x20','sql','key','table','\x0a\x20\x20\x20\x20\x20','rows'];s=function(){return Q;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listResourceRelation(
|
|
1
|
+
export async function listResourceRelation(p,Z){const {resource:A,id:I,relation:j,query:D,user:o}=p;return Z['resource']['findRelation']({'name':A,'id':I,'relation':j,'query':D,'user':o});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(p,Z){p=p-0x13a;const A=s();let I=A[p];return I;}function s(){const j=['user','resource','sort','search','scope','offset','page','limit'];s=function(){return j;};return s();}export async function listResources(p,Z){const I=f,A=p[I(0x13a)];return Z['resource']['find']({'name':p[I(0x13b)],'query':{'filter':parseFilterQuery(p),'sort':p[I(0x13c)],'search':p[I(0x13d)],'include':p['include'],'scope':p[I(0x13e)],'limit':p['limit'],'offset':p[I(0x13f)]??(p[I(0x140)]?Math['max'](p['page']-0x1,0x0):0x0)*(p[I(0x141)]??0x14)},'user':A});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function s(){var I=['user'];s=function(){return I;};return s();}function f(p,Z){p=p-0x1cc;var A=s();var I=A[p];return I;}export async function searchResource(p,Z){var A=f;return Z['resource']['find']({'name':p['resource'],'query':{...p,'filter':parseFilterQuery(p)},'user':p[A(0x1cc)]});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x15b;const A=s();let I=A[p];return I;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function s(){const X=['resource','search','min','dictionary','lookup','value','text','\x20as\x20id,\x20','\x20as\x20text\x20FROM\x20','\x20WHERE\x20lower(','then','startsWith','slice','name','length'];s=function(){return X;};return s();}export async function suggestResource(p,Z){const a=f,A=Z['resource']['get'](p[a(0x15b)]),I=String(p[a(0x15c)]??p['q']??'')['toLowerCase'](),j=Math[a(0x15d)](Math['max'](Number(p['limit']??0x14),0x1),0xc8),D=Date['now'](),o=A['fields'][p['field']],R=o?.[a(0x15e)],B=o?.[a(0x15f)]?.['table'];if(B){const g=o[a(0x15f)]?.['text']??'name',N=o['lookup']?.[a(0x160)]??'id';autoIndex(B,g,a(0x161),Z['pg']);const h=await Z['pg']['query']('SELECT\x20'+N+a(0x162)+g+a(0x163)+B+a(0x164)+g+')\x20~\x20$1\x20LIMIT\x20$2',[''+I['toLowerCase'](),j])[a(0x165)](E=>E['rows']);return{'limit':j,'count':h['length'],'search':I,'time':Date['now']()-D,'data':h};}if(!R)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+p['field']);const H=await Z['dictionary']['get'](R),e=H['filter'](E=>!I||E['code'][a(0x166)](I)||E['name']['startsWith'](I))[a(0x167)](0x0,j)['map'](E=>({'id':E['code']||E['id'],'text':E[a(0x168)]||E['text']}));return{'search':I,'limit':j,'count':e[a(0x169)],'time':Date['now']()-D,'data':e};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function updateResourceRelation(p,Z){const {resource:A,id:I,relation:j,relationId:D,data:o,user:R}=p;return Z['resource']['updateRelation']({'name':A,'id':I,'relation':j,'relationId':D,'data':o,'user':R});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function updateResource(p,Z){var A=f;return Z[A(0x8e)]['update']({'name':p[A(0x8e)],'id':p['id'],'data':p[A(0x8f)],'user':p['user']});}function f(p,Z){p=p-0x8e;var A=s();var I=A[p];return I;}function s(){var I=['resource','patch'];s=function(){return I;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(
|
|
1
|
+
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x1d3;const A=s();let I=A[p];return I;}function s(){const R=['resource','type','user','permission','name','replace','File\x20name\x20is\x20required','files/'];s=function(){return R;};return s();}export async function uploadResourceFile(p,Z){const o=f,A=Z[o(0x1d3)]['get'](p[o(0x1d3)]);if(A['access']==='admin'&&p['user']?.[o(0x1d4)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p[o(0x1d5)]?.['type']!=='admin'&&!p['user']?.['permissions']?.['includes']((A[o(0x1d6)]??A[o(0x1d7)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(A['permission']??A['name'])+':update');if(!Buffer['isBuffer'](p['file'])||p['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const I=p['fileName'][o(0x1d8)](/[^A-Za-z0-9._-]/g,'_');if(!I)throw new ValidationError(o(0x1d9));const j=o(0x1da)+p['resource']+'/'+String(p['id'])+'/'+I;await Z['file']['put'](j,p['file']);if(!await Z['file']['exists'](j))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const D=await Z['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[p['resource'],String(p['id']),j,p['file']['length']]);return D['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const B=f;import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';function f(p,Z){p=p-0xde;const A=s();let I=A[p];return I;}import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';function s(){const g=['user','Get\x20platform\x20dictionary','dictionaryName','/api/dictionary/:name','system','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','system:dictionaries','params','/api/access/scope/:resource','fcore','Set\x20resource\x20access\x20scopes','Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','admin','get','Get\x20user\x20access\x20for\x20a\x20resource','Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','resourceAccess','Get\x20access\x20rules','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','post','Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','system:access','system:settings','/api/system/settings','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','system:logs','logger','query','send','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','List\x20APIs'];s=function(){return g;};return s();}import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=p=>p[B(0xde)];export function systemRoutes(p,Z=new Map()){return async A=>{const H=f;A['get']('/api/dictionary/:name',{'schema':{'tags':['fcore','system'],'summary':H(0xdf),'description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[H(0xe0)]}},async j=>({'items':await getDictionary({...j['params'],'user':u(j)},p)})),A['post'](H(0xe1),{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xe3),'description':H(0xe4),'access':'user','permissions':[H(0xe5)],'params':systemSchemas['dictionaryName'],'body':systemSchemas['dictionaryItems']}},async j=>updateDictionary({...j['params'],...j['body'],'user':u(j)},p));const I=async j=>getAccess({...j[H(0xe6)],'user':u(j)},p);A['get'](H(0xe7),{'schema':{'tags':['fcore',H(0xe2)],'summary':'Get\x20resource\x20access\x20scopes','description':'Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['resourceScope']}},async j=>getResourceScopes(j['params'],p)),A['post']('/api/access/scope/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':H(0xe9),'description':H(0xea),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async j=>setResourceScopes({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/resource/:resource',{'schema':{'tags':['fcore',H(0xe2)],'summary':H(0xed),'description':H(0xee),'access':H(0xeb),'permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async j=>getResourceAccess(j['params'],p)),A['post']('/api/access/resource/:resource',{'schema':{'tags':[H(0xe8),'system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':H(0xef),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams'],'body':systemSchemas[H(0xf0)]}},async j=>setResourceAccess({...j['params'],...j['body'],'user':u(j)},p)),A[H(0xec)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':H(0xf1),'description':H(0xf2),'access':'admin','permissions':['system:access'],'params':systemSchemas['accessTarget']}},I),A[H(0xf3)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':H(0xf4),'access':'admin','permissions':[H(0xf5)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async j=>setAccess({...j['params'],...j['body'],'user':u(j)},p)),A['get']('/api/system/settings',{'schema':{'tags':[H(0xe8),H(0xe2)],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':'admin','permissions':[H(0xf6)]}},async j=>getSystemSettings({...j[H(0xe6)],'user':u(j)},p)),A['post'](H(0xf7),{'schema':{'tags':['fcore','system'],'summary':H(0xf8),'description':H(0xf9),'access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async j=>updateSystemSettings({...j['params'],'patch':j['body'],'user':u(j)},p)),A['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':[H(0xfa)],'querystring':systemSchemas[H(0xfb)]}},async(j,D)=>{const e=H,{contentType:o,body:R}=await getSystemLog({...j[e(0xfc)],'user':u(j)},p);return D['type'](o)[e(0xfd)](R);}),A[H(0xec)]('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':H(0xfe),'access':'user','permissions':[H(0xff)]}},async j=>getAuditLog({...j['query'],'user':u(j)},p)),A[H(0xec)]('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async j=>checkSystem({'user':u(j)},p)),A['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':H(0x100),'description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':H(0xeb),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async j=>getApiList({'user':u(j),'apiRoutes':Z,...j['query']},p));};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p=f;import{Type}from'@sinclair/typebox';export const identifier=Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}function s(){const Z=['String','Object','Number','Union','Literal','user','role','Optional','Array','Unknown','^[A-Za-z0-9_.\x5c-/]*$'];s=function(){return Z;};return s();}export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type['Object']({'items':Type['Array'](Type[p(0x1a1)]({'id':Type['Optional'](Type['Union']([Type[p(0x1a0)](),Type[p(0x1a2)]()])),'code':Type[p(0x1a0)]({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type['Number'](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type[p(0x1a3)]([Type[p(0x1a4)](p(0x1a5)),Type['Literal'](p(0x1a6))]),'id':identifier}),'accessResourceParams':Type['Object']({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type['Object']({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type[p(0x1a3)]([Type['Array'](Type['Unknown']()),Type['String'](),Type[p(0x1a2)](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type['Object']({'users':Type[p(0x1a7)](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type[p(0x1a8)](Type['Object']({'role_id':identifier,'actions':Type['Array'](Type[p(0x1a0)]({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type['Optional'](Type[p(0x1a8)](identifier)),'permissions':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type[p(0x1a3)]([Type[p(0x1a4)]('short'),Type['Literal']('extended')]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type[p(0x1a0)]({'minLength':0x1}),Type[p(0x1a9)]()),'logger':Type[p(0x1a1)]({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':p(0x1aa)}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function checkSystem(
|
|
1
|
+
function f(p,Z){p=p-0x1c6;const A=s();let I=A[p];return I;}export async function checkSystem(p,Z){const j=f,[A,I]=await Promise['allSettled']([Z['pg']['query']('SELECT\x201'),Z[j(0x1c6)][j(0x1c7)]()]);return{'status':A['status']==='fulfilled'&&I['status']==='fulfilled'?'ok':'degraded','pg':A['status'],'redis':I['status']};}function s(){const D=['redis','ping'];s=function(){return D;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getAccess(
|
|
1
|
+
function f(p,Z){p=p-0x1a0;const A=s();let I=A[p];return I;}export async function getAccess(p,Z){const o=f,A=p['type']==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20',I=await Z['pg']['query'](A,[p['id']]),j=[...new Set(I['rows'][o(0x1a0)](D=>D['resource'])[o(0x1a1)](D=>D!==null))];return{'access':I['rows'],'resources':j};}function s(){const R=['map','filter'];s=function(){return R;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0x66;const A=s();let I=A[p];return I;}export async function getApiList(p,Z){const R=f,A=[...p[R(0x66)][R(0x67)]()][R(0x68)]((I,j)=>(I['endpoint']+'\x20'+I[R(0x69)])['localeCompare'](j['endpoint']+'\x20'+j['method']));if(p['format']!=='short')return A;return A['map'](({method:I,endpoint:j,access:D,permissions:o})=>I+'\x20'+j);}function s(){const B=['apiRoutes','values','sort','method'];s=function(){return B;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getAuditLog(
|
|
1
|
+
export async function getAuditLog(p,Z){const D=f,A=Math[D(0xd7)](Math[D(0xd8)](p['limit']??0x32,0x1),0xc8),I=Math['max']((p['page']??0x1)-0x1,0x0)*A,j=await Z['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[A,I]);return{'rows':j['rows'],'page':p['page']??0x1,'limit':A};}function f(p,Z){p=p-0xd7;const A=s();let I=A[p];return I;}function s(){const o=['min','max'];s=function(){return o;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getDictionary(
|
|
1
|
+
export async function getDictionary(p,Z){return Z['dictionary']['get'](p['name']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0xaa;const A=s();let I=A[p];return I;}export async function getResourceAccess(p,Z){const K=f,[A,I,j]=await Promise['all']([Z['pg']['query'](K(0xaa),[p[K(0xab)]]),Z['pg'][K(0xac)](K(0xad),[p[K(0xab)]]),Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE',[p['resource']])]),D=new Map(),o=new Map();for(const H of j['rows']){if(H['user_id']!==null){const e=D[K(0xae)](H['user_id'])??{};e[H['scope']]=H[K(0xaf)],D[K(0xb0)](H['user_id'],e);}else{if(H['role_id']!==null){const g=o['get'](H['role_id'])??{};g[H['scope']]=H['value'],o[K(0xb0)](H['role_id'],g);}}}const R=A['rows'][K(0xb1)](N=>({...N,...D['has'](N[K(0xb2)])?{'scopes':D[K(0xae)](N['uid'])}:{}}));for(const [N,h]of D){!R['some'](E=>E[K(0xb2)]===N)&&R[K(0xb3)]({'type':'user','uid':N,'actions':[],'scopes':h});}const B=I['rows']['map'](E=>({...E,...o['has'](E['role_id'])?{'scopes':o['get'](E['role_id'])}:{}}));for(const [E,a]of o){!B['some'](X=>X['role_id']===E)&&B['push']({'type':'role','role_id':E,'name':null,'actions':[],'users_count':0x0,'scopes':a});}return{'resource':p[K(0xab)],'users':R,'roles':B};}function s(){const Q=['SELECT\x20\x27user\x27::text\x20AS\x20type,\x20user_uid\x20AS\x20uid,\x20actions\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20user_uid','resource','query','SELECT\x20\x27role\x27::text\x20AS\x20type,\x20ra.role_id,\x20r.name,\x20ra.actions,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(DISTINCT\x20ur.user_uid)::int\x20AS\x20users_count\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.roles\x20r\x20ON\x20r.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.resource\x20=\x20$1\x20AND\x20ra.role_id\x20IS\x20NOT\x20NULL\x20AND\x20ra.user_uid\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20GROUP\x20BY\x20ra.role_id,\x20r.name,\x20ra.actions\x0a\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20r.name,\x20ra.role_id','get','value','set','map','uid','push'];s=function(){return Q;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){const e=['role_id','set','resource','values'];s=function(){return e;};return s();}function f(p,Z){p=p-0x1e7;const A=s();let I=A[p];return I;}export async function getResourceScopes(p,Z){const H=f,{rows:A}=await Z['pg']['query']('SELECT\x20user_id,\x20role_id,\x20scope,\x20value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20ORDER\x20BY\x20role_id,\x20user_id\x20NULLS\x20FIRST,\x20scope',[p['resource']]),I=new Map(),j=new Map();for(const D of A){if(D['user_id']!==null){const o=D['user_id']+':'+(D['role_id']??''),R=I['get'](o)??{'user_id':D['user_id'],'role_id':D[H(0x1e7)],'scopes':{}};R['scopes'][D['scope']]=D['value'],I['set'](o,R);continue;}if(D['role_id']!==null){const B=j['get'](D['role_id'])??{'role_id':D['role_id'],'scopes':{}};B['scopes'][D['scope']]=D['value'],j[H(0x1e8)](D['role_id'],B);}}return{'resource':p[H(0x1e9)],'users':[...I['values']()],'roles':[...j[H(0x1ea)]()]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(p,Z){p=p-0x1d1;const A=s();let I=A[p];return I;}import p from'node:fs/promises';import Z from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=Z['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(A,I){const E=f,j=normalizePath(A['path']),D=Z['resolve'](LOGS_ROOT,j);if(D!==LOGS_ROOT&&!D['startsWith'](LOGS_ROOT+Z[E(0x1d1)]))throw new ValidationError('Invalid\x20log\x20path');const o=await p['stat'](D)['catch'](()=>null);if(!o)throw new NotFoundError('Log\x20path\x20not\x20found');if(o[E(0x1d2)]()){const B=await p['readdir'](D,{'withFileTypes':!![]}),H=await Promise['all'](B['map'](async e=>{const a=E,g=await p['stat'](Z['join'](D,e['name']));return{'name':e['name'],'path':j?j+'/'+e['name']:e['name'],'type':e['isDirectory']()?'directory':'file','size':e['isDirectory']()?undefined:g['size'],'modified':g[a(0x1d3)]['toISOString']()};}));H['sort']((e,g)=>e['name'][E(0x1d4)](g['name']));if(j){const e=j['split']('/')['slice'](0x0,-0x1)[E(0x1d5)]('/');H['unshift']({'name':'..','path':e,'type':'directory'});}return{'contentType':E(0x1d6),'body':renderDirectory(j,H)};}const R=await tailFile(D,TAIL_LINES);return{'contentType':E(0x1d7),'body':R[E(0x1d5)]('\x0a')};}function renderDirectory(A,I){const K=f,j=I['map'](o=>{const X=f,R=X(0x1d8)+encodeURIComponent(o['path']),B=o['type']==='directory'?o[X(0x1d9)]+'/':o['name'];return'<li><a\x20href=\x22'+R+'\x22>'+escapeHtml(B)+'</a></li>';})[K(0x1d5)]('\x0a'),D=escapeHtml('logs/'+A);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+D+K(0x1da)+D+K(0x1db)+j+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(A){const Q=f;return A['replace'](/&/g,'&')[Q(0x1dc)](/</g,Q(0x1dd))['replace'](/>/g,Q(0x1de))[Q(0x1dc)](/"/g,Q(0x1df));}function normalizePath(A){const G=f,I=(A??'')[G(0x1dc)](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(I['split']('/')['some'](j=>j==='..'))throw new ValidationError('Invalid\x20log\x20path');return I;}async function tailFile(A,I){const V=f,j=await p[V(0x1e0)](A,'r');try{const {size:D}=await j['stat'](),o=0x40*0x400;let R=D,B=Buffer['alloc'](0x0),H=0x0;while(R>0x0&&H<=I){const g=Math['min'](o,R);R-=g;const N=Buffer['alloc'](g);await j['read'](N,0x0,g,R),B=Buffer['concat']([N,B]),H+=countNewlines(N);}const e=B['toString']('utf8')['split']('\x0a')['filter'](h=>h['length']>0x0);return e[V(0x1e1)](-I)['reverse']();}finally{await j['close']();}}function countNewlines(A){let I=0x0;for(const j of A){if(j===0xa)I++;}return I;}function s(){const O=['sep','isDirectory','mtime','localeCompare','join','text/html;\x20charset=utf-8','text/plain;\x20charset=utf-8','?path=','name','</title></head>\x0a<body>\x0a<h1>','</h1>\x0a<ul>\x0a','replace','<','>','"','open','slice'];s=function(){return O;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getSystemSettings(p,Z){const B=f,A=await Z['pg'][B(0xfe)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20');return A['rows']['reduce']((I,j)=>{const D=String(j['key'])['split']('.');let o=I;for(const R of D['slice'](0x0,-0x1)){o[R]??={},o=o[R];}return o[D['at'](-0x1)]=j['value'],I;},{});}function f(p,Z){p=p-0xfe;const A=s();let I=A[p];return I;}function s(){const H=['query'];s=function(){return H;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listDictionaries(
|
|
1
|
+
export async function listDictionaries(p,Z){return Z['dictionary']['list']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function f(p,Z){p=p-0xf9;const A=s();let I=A[p];return I;}const e=f;import{getAccess}from'./get-access.js';function s(){const h=['read','update','create','split','map','BEGIN','user','roles','query','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','resource','actions'];s=function(){return h;};return s();}const CRUD_ACTIONS=[e(0xf9),e(0xfa),e(0xfb),'delete'];function permissionsToAccess(p){const g=e,Z=new Map();for(const A of p){const [I,j]=A[g(0xfc)](':');if(!I)continue;const D=j==='edit'?'update':j,o=Z['get'](I)??new Set();for(const R of D?[D]:CRUD_ACTIONS)o['add'](R);Z['set'](I,o);}return[...Z][g(0xfd)](([B,H])=>({'resource':B,'actions':[...H]}));}export async function setAccess(p,Z){const N=e,A=await Z['pg']['connect']();try{await A['query'](N(0xfe));if(p['type']===N(0xff)){await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[p['id']]);if(p[N(0x100)]!==undefined){await A['query']('DELETE\x20FROM\x20admin.user_roles\x20WHERE\x20user_uid\x20=\x20$1',[p['id']]);for(const j of p[N(0x100)]){await A[N(0x101)]('INSERT\x20INTO\x20admin.user_roles\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(user_uid,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)',[p['id'],j,p[N(0xff)]['id'],p['user']['id']]);}}}else await A['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[p['id']]);const I=p['permissions']?permissionsToAccess(p['permissions']):p['access']??[];for(const D of I){p['type']==='user'?await A['query'](N(0x102),[D[N(0x103)],D['actions'],p['id'],p['user']['id'],p[N(0xff)]['id']]):await A['query']('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)',[D[N(0x103)],D[N(0x104)],p['id'],p['user']['id'],p['user']['id']]);}await A[N(0x101)]('COMMIT');}catch(o){await A['query']('ROLLBACK');throw o;}finally{A['release']();}return getAccess(p,Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x6d;const A=s();let I=A[p];return I;}function s(){const g=['roles','uid','has','role_id','query','length','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)','resource'];s=function(){return g;};return s();}import{getResourceAccess}from'./get-resource-access.js';export async function setResourceAccess(p,Z){const e=f;if(p['users']===undefined&&p[e(0x6d)]===undefined)throw new ValidationError('At\x20least\x20one\x20of\x20users\x20or\x20roles\x20must\x20be\x20provided');const A=new Set();for(const D of p['users']??[]){if(A['has'](D['uid']))throw new ValidationError('Duplicate\x20user\x20in\x20access\x20list:\x20'+D['uid']);A['add'](D[e(0x6e)]);}const I=new Set();for(const o of p[e(0x6d)]??[]){if(I[e(0x6f)](o['role_id']))throw new ValidationError('Duplicate\x20role\x20in\x20access\x20list:\x20'+o['role_id']);I['add'](o[e(0x70)]);}const j=await Z['pg']['connect']();try{await j[e(0x71)]('BEGIN');if(p['users']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NOT\x20NULL\x20AND\x20role_id\x20IS\x20NULL',[p['resource']]);for(const R of p['users']){if(R['actions'][e(0x72)]===0x0)continue;await j['query'](e(0x73),[p['resource'],R['actions'],R['uid'],p['user']['id']]);}}if(p['roles']!==undefined){await j['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20resource\x20=\x20$1\x20AND\x20role_id\x20IS\x20NOT\x20NULL\x20AND\x20user_uid\x20IS\x20NULL',[p['resource']]);for(const B of p['roles']){if(B[e(0x74)]['length']===0x0)continue;await j[e(0x71)](e(0x75),[p[e(0x76)],B['actions'],B['role_id'],p['user']['id']]);}}await j[e(0x71)]('COMMIT');}catch(H){await j['query']('ROLLBACK');throw H;}finally{j['release']();}return getResourceAccess({'resource':p['resource']},Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function s(){const R=['Provide\x20exactly\x20one\x20of\x20user_id\x20or\x20role_id','keys','BEGIN','query','COMMIT','ROLLBACK','release'];s=function(){return R;};return s();}import{clearResourceScopeCache}from'../../../plugins/resource/utils/scope.js';function f(p,Z){p=p-0x16d;const A=s();let I=A[p];return I;}import{getResourceScopes}from'./get-resource-scopes.js';export async function setResourceScopes(p,Z){const o=f;if(Boolean(p['user_id'])===Boolean(p['role_id']))throw new ValidationError(o(0x16d));if(Object[o(0x16e)](p['scopes'])['length']===0x0)throw new ValidationError('At\x20least\x20one\x20scope\x20must\x20be\x20provided');const A=await Z['pg']['connect']();try{await A['query'](o(0x16f)),await A['query']('DELETE\x20FROM\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20role_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20user_id\x20IS\x20NOT\x20DISTINCT\x20FROM\x20$3',[p['resource'],p['role_id']??null,p['user_id']??null]);for(const [I,j]of Object['entries'](p['scopes'])){await A[o(0x170)]('INSERT\x20INTO\x20admin.role_access_scope\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(resource,\x20role_id,\x20user_id,\x20scope,\x20value,\x20enabled,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5::jsonb,\x20TRUE,\x20$6,\x20$6)',[p['resource'],p['role_id']??null,p['user_id']??null,I,JSON['stringify'](j),p['user']['id']]);}await A['query'](o(0x171));}catch(D){await A['query'](o(0x172));throw D;}finally{A[o(0x173)]();}return clearResourceScopeCache(),getResourceScopes({'resource':p['resource']},Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateDictionary(
|
|
1
|
+
function s(){var I=['dictionary','items'];s=function(){return I;};return s();}function f(p,Z){p=p-0xc7;var A=s();var I=A[p];return I;}export async function updateDictionary(p,Z){var A=f;return await Z[A(0xc7)]['put'](p['name'],p[A(0xc8)]),{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function s(){const D=['patch','length','entries','user'];s=function(){return D;};return s();}function f(p,Z){p=p-0x135;const A=s();let I=A[p];return I;}export async function updateSystemSettings(p,Z){const j=f;if(!Object['keys'](p[j(0x135)])[j(0x136)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [A,I]of Object[j(0x137)](p['patch'])){if(!A['trim']()||A['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+A);await Z['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[A,JSON['stringify'](I),p[j(0x138)]['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function s(){var I=['permissions','Missing\x20permission:\x20'];s=function(){return I;};return s();}function f(p,Z){p=p-0x19c;var A=s();var I=A[p];return I;}export function requireAdmin(p,Z){var A=f;if(!p)throw new ForbiddenError('User\x20required');if(p['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(p['type']!=='admin'&&Z&&!p[A(0x19c)]?.['includes'](Z))throw new ForbiddenError(A(0x19d)+Z);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){const D=['salt','entries','some','toLowerCase'];s=function(){return D;};return s();}function f(p,Z){p=p-0x154;const A=s();let I=A[p];return I;}export const safeUser=p=>{const j=f,Z=['password',j(0x154),'secret','credentials'];return Object['fromEntries'](Object[j(0x155)](p)['filter'](([A])=>!Z[j(0x156)](I=>A[j(0x157)]()['includes'](I))));};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';export function unsupported(
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(p){throw new UnsupportedError(p+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(p){const Z=writeAudit(p);return{'write':Z};}
|