@opengis/fcore 0.0.1-beta.25 → 0.0.1-beta.26
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.d.ts.map +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.d.ts +2 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +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/get-resource.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-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/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.d.ts +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +5 -4
- package/dist/plugins/resource/resource.types.d.ts.map +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.js +1 -1
- package/dist/plugins/resource/services/create.js +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/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/package.json +93 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listResources}from'./services/list-resources.js';import{getResource}from'./services/get-resource.js';
|
|
1
|
+
import{listResources}from'./services/list-resources.js';import{getResource}from'./services/get-resource.js';function G(w,h){w=w-0x12b;const S=z();let X=S[w];return X;}import{createResource}from'./services/create-resource.js';import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';function z(){const y=['/api/resource/:resource/search','resource','Searches\x20records\x20in\x20a\x20registered\x20resource.','$resource:read','config','get','/api/suggest/:resource/:field','fcore','user','resourceField','suggestQuery','/api/resource/:resource/export','auth','params','post','Create\x20resource\x20record','$resource:create','Update\x20resource\x20record','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','Delete\x20resource\x20record','Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','resourceId','Upload\x20resource\x20file','Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','$resource:update','/api/resource/:resource/:id/file/:fid','File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record','rows','query','delete','$resource:delete','resourceIdRelationId','put','Updates\x20a\x20related\x20resource\x20record.'];z=function(){return y;};return z();}import{createResourceRelation}from'./services/create-resource-relation.js';import{updateResourceRelation}from'./services/update-resource-relation.js';import{deleteResourceRelation}from'./services/delete-resource-relation.js';import{searchResource}from'./services/search-resource.js';import{exportResource}from'./services/export-resource.js';import{suggestResource}from'./services/suggest-resource.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=w=>w['user'];export function resourceRoutes(w){return async h=>{const e=G;h['get'](e(0x12b),{'schema':{'tags':['fcore',e(0x12c)],'summary':'Search\x20resource','description':e(0x12d),'access':'user','permissions':[e(0x12e)],'params':resourceSchemas['resource']}},async S=>searchResource({...S['query'],...S['params'],'user':user(S)||w[e(0x12f)]?.['auth']?.['user']},w)),h[e(0x130)](e(0x131),{'schema':{'tags':[e(0x132),'resource'],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':e(0x133),'permissions':['$resource:read'],'params':resourceSchemas[e(0x134)],'querystring':resourceSchemas[e(0x135)]}},async S=>suggestResource({...S['query'],...S['params'],'user':user(S)||w['config']?.['auth']?.['user']},w)),h[e(0x130)](e(0x136),{'schema':{'tags':['fcore','resource'],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async S=>exportResource({...S['query'],...S['params'],'user':user(S)||w['config']?.[e(0x137)]?.['user']},w)),h[e(0x130)]('/api/resource/:resource',{'schema':{'tags':[e(0x132),'resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':e(0x133),'permissions':['$resource:read'],'params':resourceSchemas['resource']}},async S=>listResources({...S['query'],...S[e(0x138)],'user':user(S)||w['config']?.['auth']?.['user']},w)),h[e(0x139)]('/api/resource/:resource',{'schema':{'tags':[e(0x132),'resource'],'summary':e(0x13a),'description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':[e(0x13b)],'params':resourceSchemas[e(0x12c)]}},async S=>createResource({...S['params'],'data':S['body'],'user':user(S)||w['config']?.[e(0x137)]?.[e(0x133)]},w)),h['get']('/api/resource/:resource/:id',{'schema':{'tags':[e(0x132),'resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async S=>getResource({...S['query'],...S['params'],'user':user(S)||w['config']?.['auth']?.[e(0x133)]},w)),h['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':e(0x13c),'description':e(0x13d),'access':e(0x133),'permissions':['$resource:update'],'params':resourceSchemas['resourceId']}},async S=>updateResource({...S['params'],'patch':S['body'],'user':user(S)||w[e(0x12f)]?.[e(0x137)]?.['user']},w)),h['delete']('/api/resource/:resource/:id',{'schema':{'tags':['fcore',e(0x12c)],'summary':e(0x13e),'description':e(0x13f),'access':'user','permissions':['$resource:delete'],'params':resourceSchemas[e(0x140)]}},async S=>deleteResource({...S[e(0x138)],'user':user(S)||w[e(0x12f)]?.['auth']?.['user']},w)),h['post']('/api/resource/:resource/:id/upload',{'schema':{'tags':[e(0x132),'resource'],'summary':e(0x141),'description':e(0x142),'access':e(0x133),'permissions':[e(0x143)],'params':resourceSchemas['uploadResourceFile']}},async S=>{const Z=e,X=await S['file']();if(!X)throw new Error('File\x20is\x20required');const Y=S['params'][Z(0x12c)],v=S['params']['id'];return uploadFile({'file':X,'metadata':{'name':X['filename'],'path':X['fields']['path']?.['value'],'resource':Y,'resourceId':v},'user':S[Z(0x133)]},w);}),h['delete'](e(0x144),{'schema':{'tags':['fcore',e(0x12c)],'summary':'Delete\x20resource\x20file','description':'Deletes\x20a\x20file\x20linked\x20to\x20a\x20resource\x20record\x20after\x20validating\x20it\x20belongs\x20to\x20this\x20resource\x20and\x20record.','access':'user','permissions':[e(0x143)],'params':resourceSchemas['resourceIdFileId']}},async S=>{const K=e,{resource:X,id:Y,fid:v}=S['params'],D=await w['pg']['query']('SELECT\x20file_path\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3\x20LIMIT\x201',[v,X,String(Y)]);if(!D['rowCount'])throw new Error(K(0x145));const o=D[K(0x146)][0x0]?.['file_path'],q=await w['pg'][K(0x147)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[v,X,String(Y)]);return await w['file'][K(0x148)](o),{'success':(q['rowCount']??0x0)>0x0,'resource':X,'resourceId':Y,'fileId':v};}),h[e(0x130)]('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20relations','description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':'user','params':resourceSchemas['resourceIdRelation'],'permissions':['$resource:read']}},async S=>listResourceRelation({...S[e(0x147)],...S[e(0x138)],'user':user(S)||w['config']?.[e(0x137)]?.['user']},w)),h['post']('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':['$resource:create'],'params':resourceSchemas['resourceIdRelation']}},async S=>createResourceRelation({...S[e(0x138)],'data':S['body'],'user':user(S)||w['config']?.['auth']?.[e(0x133)]},w)),h[e(0x148)]('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':[e(0x149)],'params':resourceSchemas[e(0x14a)]}},async S=>deleteResourceRelation({...S['params'],'user':user(S)||w['config']?.['auth']?.['user']},w)),h[e(0x14b)]('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[e(0x132),'resource'],'summary':'Update\x20resource\x20relation','description':e(0x14c),'access':e(0x133),'permissions':['$resource:update'],'params':resourceSchemas['resourceIdRelationId']}},async S=>updateResourceRelation({...S['params'],'data':S['body'],'user':user(S)||w['config']?.['auth']?.['user']},w));};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const w=
|
|
1
|
+
function G(w,h){w=w-0x111;const S=z();let X=S[w];return X;}const w=G;import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':w(0x111)});export const resourceSchemas={'dictionaryName':Type[w(0x112)]({'name':identifier}),'resource':Type['Object']({'resource':identifier}),'exportResource':Type[w(0x112)]({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type['Optional'](Type['String']()),'search':Type[w(0x113)](Type[w(0x114)]()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[w(0x112)]({'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['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type['Any'](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type['Optional'](Type['Record'](Type[w(0x114)](),Type['Unknown']())),'sort':Type[w(0x113)](Type[w(0x115)](Type['String']({'minLength':0x1}))),'search':Type[w(0x113)](Type['String']()),'scope':Type[w(0x113)](Type['String']()),'limit':Type['Optional'](Type[w(0x116)]({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type[w(0x116)]({'minimum':0x0})),'fields':Type['Optional'](Type[w(0x115)](identifier))})};function z(){const h=['^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Optional','String','Array','Integer'];z=function(){return h;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function addNote(w,h){const X=G,S=await h['pg'][X(0x7c)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[w['resource'],String(w['id']),w['body']]);return S['rows'][0x0];}function G(w,h){w=w-0x7c;const S=z();let X=S[w];return X;}function z(){const Y=['query'];z=function(){return Y;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function addResourceFile(w,
|
|
1
|
+
function G(w,h){w=w-0x155;const S=z();let X=S[w];return X;}export async function addResourceFile(w,h){const X=G,S=await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[w[X(0x155)],String(w['id']),w[X(0x156)],w['size']??null]);return S['rows'][0x0];}function z(){const Y=['resource','filePath'];z=function(){return Y;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function createResourceRelation(w,h){const {resource:S,id:X,relation:Y,data:v,user:D}=w;return h['resource']['createRelation']({'name':S,'id':X,'relation':Y,'data':v,'user':D});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(){var X=['create','data'];z=function(){return X;};return z();}function G(w,h){w=w-0x1d4;var S=z();var X=S[w];return X;}export async function createResource(w,h){var S=G;return h['resource'][S(0x1d4)]({'name':w['resource'],'data':w[S(0x1d5)],'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(w,h){w=w-0xe6;const S=z();let X=S[w];return X;}function z(){const o=['deleteRelation'];z=function(){return o;};return z();}export async function deleteResourceRelation(w,h){const D=G,{resource:S,id:X,relation:Y,relationId:v}=w;return h['resource'][D(0xe6)]({'name':S,'id':X,'relation':Y,'relationId':v});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResource(w,
|
|
1
|
+
function z(){var X=['resource'];z=function(){return X;};return z();}function G(w,h){w=w-0x1b5;var S=z();var X=S[w];return X;}export async function deleteResource(w,h){var S=G;return h[S(0x1b5)]['delete']({'name':w['resource'],'id':w['id'],'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(w,h){const X=G,S=await h['resource'][X(0x1f4)]({'name':w[X(0x1f5)],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'limit':w['limit'],'offset':w['offset'],'fields':w[X(0x1f6)]},'user':w['user']});return S['rows'];}function G(w,h){w=w-0x1f4;const S=z();let X=S[w];return X;}function z(){const Y=['find','resource','fields'];z=function(){return Y;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getResource(w,
|
|
1
|
+
function G(w,h){w=w-0x72;var S=z();var X=S[w];return X;}export async function getResource(w,h){var S=G;return h['resource']['findOne']({'name':w[S(0x72)],'id':w['id'],'query':{'include':w[S(0x73)]},'user':w[S(0x74)]});}function z(){var X=['resource','include','user'];z=function(){return X;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listResourceRelation(w,
|
|
1
|
+
export async function listResourceRelation(w,h){const {resource:S,id:X,relation:Y,query:v,user:D}=w;return h['resource']['findRelation']({'name':S,'id':X,'relation':Y,'query':v,'user':D});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function G(w,h){w=w-0x1a2;var S=z();var X=S[w];return X;}function z(){var X=['scope','offset'];z=function(){return X;};return z();}export async function listResources(w,h){var S=G;return h['resource']['find']({'name':w['resource'],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'scope':w[S(0x1a2)],'limit':w['limit'],'offset':w[S(0x1a3)]??(w['page']?Math['max'](w['page']-0x1,0x0):0x0)*(w['limit']??0x14)},'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function z(){var X=['resource','find'];z=function(){return X;};return z();}function G(w,h){w=w-0x10b;var S=z();var X=S[w];return X;}export async function searchResource(w,h){var S=G;return h[S(0x10b)][S(0x10c)]({'name':w['resource'],'query':{...w,'filter':parseFilterQuery(w)},'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function G(w,h){w=w-0xdf;const S=z();let X=S[w];return X;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(w,h){const H=G,S=h['resource']['get'](w[H(0xdf)]),X=String(w['search']??w['q']??'')['toLowerCase'](),Y=Math['min'](Math['max'](Number(w['limit']??0x14),0x1),0xc8),v=Date[H(0xe0)](),D=S['fields'][w[H(0xe1)]],o=D?.[H(0xe2)],q=D?.[H(0xe3)]?.['table'];if(q){const K=D['lookup']?.['text']??'name',y=D['lookup']?.[H(0xe4)]??'id';autoIndex(q,K,H(0xe5),h['pg']);const V=await h['pg'][H(0xe6)]('SELECT\x20'+y+'\x20as\x20id,\x20'+K+H(0xe7)+q+'\x20WHERE\x20lower('+K+')\x20~\x20$1\x20LIMIT\x20$2',[''+X['toLowerCase'](),Y])[H(0xe8)](O=>O[H(0xe9)]);return{'limit':Y,'count':V['length'],'search':X,'time':Date['now']()-v,'data':V};}if(!o)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+w['field']);const e=await h[H(0xe2)]['get'](o),Z=e['filter'](O=>!X||O['code'][H(0xea)](X)||O[H(0xeb)][H(0xea)](X))['slice'](0x0,Y)[H(0xec)](O=>({'id':O[H(0xed)]||O['id'],'text':O[H(0xeb)]||O['text']}));return{'search':X,'limit':Y,'count':Z['length'],'time':Date[H(0xe0)]()-v,'data':Z};}function z(){const R=['resource','now','field','dictionary','lookup','value','text','query','\x20as\x20text\x20FROM\x20','then','rows','startsWith','name','map','code'];z=function(){return R;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function updateResourceRelation(w,h){const {resource:S,id:X,relation:Y,relationId:v,data:D,user:o}=w;return h['resource']['updateRelation']({'name':S,'id':X,'relation':Y,'relationId':v,'data':D,'user':o});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(w,h){w=w-0x7d;var S=z();var X=S[w];return X;}function z(){var X=['resource','patch'];z=function(){return X;};return z();}export async function updateResource(w,h){var S=G;return h[S(0x7d)]['update']({'name':w['resource'],'id':w['id'],'data':w[S(0x7e)],'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';
|
|
1
|
+
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(w,h){const D=G,S=h['resource'][D(0xad)](w[D(0xae)]);if(S['access']===D(0xaf)&&w['user']?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(w['user']?.[D(0xb0)]!=='admin'&&!w[D(0xb1)]?.[D(0xb2)]?.[D(0xb3)]((S['permission']??S['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(S['permission']??S['name'])+':update');if(!Buffer['isBuffer'](w['file'])||w[D(0xb4)][D(0xb5)]===0x0)throw new ValidationError('File\x20is\x20required');const X=w[D(0xb6)][D(0xb7)](/[^A-Za-z0-9._-]/g,'_');if(!X)throw new ValidationError(D(0xb8));const Y='files/'+w['resource']+'/'+String(w['id'])+'/'+X;await h[D(0xb4)]['put'](Y,w['file']);if(!await h['file'][D(0xb9)](Y))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const v=await h['pg'][D(0xba)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[w['resource'],String(w['id']),Y,w['file']['length']]);return v['rows'][0x0];}function G(w,h){w=w-0xad;const S=z();let X=S[w];return X;}function z(){const o=['get','resource','admin','type','user','permissions','includes','file','length','fileName','replace','File\x20name\x20is\x20required','exists','query'];z=function(){return o;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const q=G;function z(){const Z=['user','/api/dictionary/:name','fcore','Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','system','Update\x20platform\x20dictionary','dictionaryName','params','body','get','system:access','post','/api/access/:type/:id','accessTarget','Get\x20system\x20settings','Returns\x20system\x20settings\x20as\x20nested\x20JSON.','admin','system:settings','settings','system:logs','/api/system/audit','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','Check\x20system\x20health'];z=function(){return Z;};return z();}import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';function G(w,h){w=w-0x69;const S=z();let X=S[w];return X;}import{getAccess}from'./services/get-access.js';import{setAccess}from'./services/set-access.js';import{systemSchemas}from'./schema.js';const u=w=>w[q(0x69)];export function systemRoutes(w,h=new Map()){return async S=>{const e=G;S['get'](e(0x6a),{'schema':{'tags':[e(0x6b),'system'],'summary':'Get\x20platform\x20dictionary','description':e(0x6c),'access':e(0x69),'permissions':['system:dictionaries'],'params':systemSchemas['dictionaryName']}},async Y=>({'items':await getDictionary({...Y['params'],'user':u(Y)},w)})),S['post'](e(0x6a),{'schema':{'tags':[e(0x6b),e(0x6d)],'summary':e(0x6e),'description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[e(0x6f)],'body':systemSchemas['dictionaryItems']}},async Y=>updateDictionary({...Y[e(0x70)],...Y[e(0x71)],'user':u(Y)},w));const X=async Y=>getAccess({...Y['params'],'user':u(Y)},w);S[e(0x72)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[e(0x73)],'params':systemSchemas['accessTarget']}},X),S[e(0x74)](e(0x75),{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':['system:access'],'params':systemSchemas[e(0x76)],'body':systemSchemas['access']}},async Y=>setAccess({...Y['params'],...Y['body'],'user':u(Y)},w)),S['get']('/api/system/settings',{'schema':{'tags':[e(0x6b),'system'],'summary':e(0x77),'description':e(0x78),'access':e(0x79),'permissions':[e(0x7a)]}},async Y=>getSystemSettings({...Y['params'],'user':u(Y)},w)),S['post']('/api/system/settings',{'schema':{'tags':['fcore',e(0x6d)],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':['system:settings'],'body':systemSchemas[e(0x7b)]}},async Y=>updateSystemSettings({...Y[e(0x70)],'patch':Y[e(0x71)],'user':u(Y)},w)),S['get']('/api/system/logger',{'schema':{'tags':['fcore',e(0x6d)],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':[e(0x7c)],'querystring':systemSchemas['logger']}},async(Y,v)=>{const {contentType:D,body:o}=await getSystemLog({...Y['query'],'user':u(Y)},w);return v['type'](D)['send'](o);}),S['get'](e(0x7d),{'schema':{'tags':[e(0x6b),'system'],'summary':'Get\x20audit\x20log','description':e(0x7e),'access':'user','permissions':[e(0x7f)]}},async Y=>getAuditLog({...Y['query'],'user':u(Y)},w)),S[e(0x72)]('/api/system/check',{'schema':{'tags':['fcore',e(0x6d)],'summary':e(0x80),'description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':e(0x69),'permissions':['system:check']}},async Y=>checkSystem({'user':u(Y)},w)),S['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':'admin','permissions':[],'querystring':systemSchemas['apiListQuery']}},async Y=>getApiList({'user':u(Y),'apiRoutes':h,...Y['query']},w));};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const w=G;import{Type}from'@sinclair/typebox';function G(w,h){w=w-0x162;const S=z();let X=S[w];return X;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':w(0x162)});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type[w(0x163)]({'items':Type[w(0x164)](Type['Object']({'id':Type['Optional'](Type['Union']([Type[w(0x165)](),Type[w(0x166)]()])),'code':Type[w(0x165)]({'minLength':0x1}),'name':Type[w(0x165)]({'minLength':0x1}),'parentId':Type[w(0x167)](Type[w(0x168)]([Type['String'](),Type['Number'](),Type[w(0x169)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal']('user'),Type['Literal'](w(0x16a))]),'id':identifier}),'access':Type['Object']({'permissions':Type['Optional'](Type['Array'](Type[w(0x165)]({'minLength':0x1,'maxLength':0x80,'pattern':w(0x16b)}))),'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[w(0x168)]([Type['Literal']('short'),Type[w(0x16c)](w(0x16d))]))}),'settingsEntity':Type['Object']({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type['String']({'minLength':0x1}),Type['Unknown']()),'logger':Type[w(0x163)]({'path':Type['Optional'](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};function z(){const h=['^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Array','String','Number','Optional','Union','Null','role','^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$','Literal','extended'];z=function(){return h;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function checkSystem(w,
|
|
1
|
+
export async function checkSystem(w,h){const Y=G,[S,X]=await Promise['allSettled']([h['pg'][Y(0xcd)]('SELECT\x201'),h['redis']['ping']()]);return{'status':S['status']==='fulfilled'&&X['status']==='fulfilled'?'ok':'degraded','pg':S['status'],'redis':X['status']};}function G(w,h){w=w-0xcd;const S=z();let X=S[w];return X;}function z(){const v=['query'];z=function(){return v;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getAccess(w,h){const D=G,S=w[D(0xef)]===D(0xf0)?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':D(0xf1),X=await h['pg'][D(0xf2)](S,[w['id']]),Y=[...new Set(X['rows']['map'](v=>v['resource'])['filter'](v=>v!==null))];return{'access':X['rows'],'resources':Y};}function G(w,h){w=w-0xef;const S=z();let X=S[w];return X;}function z(){const o=['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\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20','query'];z=function(){return o;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getApiList(w,h){const o=G,S=[...w['apiRoutes'][o(0x1a0)]()]['sort']((X,Y)=>(X[o(0x1a1)]+'\x20'+X['method'])['localeCompare'](Y['endpoint']+'\x20'+Y['method']));if(w['format']!==o(0x1a2))return S;return S[o(0x1a3)](({method:X,endpoint:Y,access:v,permissions:D})=>X+'\x20'+Y);}function G(w,h){w=w-0x1a0;const S=z();let X=S[w];return X;}function z(){const q=['values','endpoint','short','map'];z=function(){return q;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(w,h){w=w-0x18f;const S=z();let X=S[w];return X;}export async function getAuditLog(w,h){const v=G,S=Math['min'](Math['max'](w['limit']??0x32,0x1),0xc8),X=Math['max']((w['page']??0x1)-0x1,0x0)*S,Y=await h['pg'][v(0x18f)]('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',[S,X]);return{'rows':Y['rows'],'page':w['page']??0x1,'limit':S};}function z(){const D=['query'];z=function(){return D;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getDictionary(w,
|
|
1
|
+
function G(w,h){w=w-0xcd;var S=z();var X=S[w];return X;}export async function getDictionary(w,h){var S=G;return h['dictionary'][S(0xcd)](w['name']);}function z(){var X=['get'];z=function(){return X;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import w from'node:fs/promises';import
|
|
1
|
+
function z(){const C=['logs','path','sep','Invalid\x20log\x20path','stat','catch','isDirectory','readdir','all','map','join','name','size','sort','localeCompare','unshift','directory','type','<li><a\x20href=\x22','<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>','\x0a</ul>\x0a</body>\x0a</html>','replace','&','split','open','alloc','toString','slice','reverse'];z=function(){return C;};return z();}function G(w,h){w=w-0x161;const S=z();let X=S[w];return X;}const O=G;import w from'node:fs/promises';import h from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=h['resolve'](process['cwd'](),O(0x161)),TAIL_LINES=0x64;export async function getSystemLog(S,X){const H=O,Y=normalizePath(S[H(0x162)]),v=h['resolve'](LOGS_ROOT,Y);if(v!==LOGS_ROOT&&!v['startsWith'](LOGS_ROOT+h[H(0x163)]))throw new ValidationError(H(0x164));const D=await w[H(0x165)](v)[H(0x166)](()=>null);if(!D)throw new NotFoundError('Log\x20path\x20not\x20found');if(D[H(0x167)]()){const q=await w[H(0x168)](v,{'withFileTypes':!![]}),e=await Promise[H(0x169)](q[H(0x16a)](async Z=>{const R=H,K=await w[R(0x165)](h[R(0x16b)](v,Z['name']));return{'name':Z[R(0x16c)],'path':Y?Y+'/'+Z['name']:Z['name'],'type':Z[R(0x167)]()?'directory':'file','size':Z['isDirectory']()?undefined:K[R(0x16d)],'modified':K['mtime']['toISOString']()};}));e[H(0x16e)]((Z,K)=>Z['name'][H(0x16f)](K['name']));if(Y){const Z=Y['split']('/')['slice'](0x0,-0x1)[H(0x16b)]('/');e[H(0x170)]({'name':'..','path':Z,'type':H(0x171)});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(Y,e)};}const o=await tailFile(v,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':o[H(0x16b)]('\x0a')};}function renderDirectory(S,X){const Q=O,Y=X[Q(0x16a)](D=>{const P=Q,o='?path='+encodeURIComponent(D['path']),q=D[P(0x172)]==='directory'?D[P(0x16c)]+'/':D['name'];return P(0x173)+o+'\x22>'+escapeHtml(q)+'</a></li>';})['join']('\x0a'),v=escapeHtml('logs/'+S);return Q(0x174)+v+'</title></head>\x0a<body>\x0a<h1>'+v+'</h1>\x0a<ul>\x0a'+Y+Q(0x175);}function escapeHtml(S){const x=O;return S[x(0x176)](/&/g,x(0x177))[x(0x176)](/</g,'<')['replace'](/>/g,'>')['replace'](/"/g,'"');}function normalizePath(S){const c=O,X=(S??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(X[c(0x178)]('/')['some'](Y=>Y==='..'))throw new ValidationError('Invalid\x20log\x20path');return X;}async function tailFile(S,X){const d=O,Y=await w[d(0x179)](S,'r');try{const {size:v}=await Y['stat'](),D=0x40*0x400;let o=v,q=Buffer[d(0x17a)](0x0),e=0x0;while(o>0x0&&e<=X){const K=Math['min'](D,o);o-=K;const y=Buffer['alloc'](K);await Y['read'](y,0x0,K,o),q=Buffer['concat']([y,q]),e+=countNewlines(y);}const Z=q[d(0x17b)]('utf8')['split']('\x0a')['filter'](V=>V['length']>0x0);return Z[d(0x17c)](-X)[d(0x17d)]();}finally{await Y['close']();}}function countNewlines(S){let X=0x0;for(const Y of S){if(Y===0xa)X++;}return X;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function G(w,h){w=w-0xd2;const S=z();let X=S[w];return X;}export async function getSystemSettings(w,h){const q=G,S=await h['pg'][q(0xd2)]('\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 S['rows'][q(0xd3)]((X,Y)=>{const e=q,v=String(Y[e(0xd4)])[e(0xd5)]('.');let D=X;for(const o of v['slice'](0x0,-0x1)){D[o]??={},D=D[o];}return D[v['at'](-0x1)]=Y['value'],X;},{});}function z(){const Z=['query','reduce','key','split'];z=function(){return Z;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(){var X=['dictionary','list'];z=function(){return X;};return z();}function G(w,h){w=w-0x1ed;var S=z();var X=S[w];return X;}export async function listDictionaries(w,h){var S=G;return h[S(0x1ed)][S(0x1ee)]();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function z(){const V=['read','create','set','user','permissions','type','resource','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)','actions'];z=function(){return V;};return z();}function G(w,h){w=w-0xd9;const S=z();let X=S[w];return X;}const Z=G;import{getAccess}from'./get-access.js';const CRUD_ACTIONS=[Z(0xd9),'update',Z(0xda),'delete'];function permissionsToAccess(w){const K=Z,h=new Map();for(const S of w){const [X,Y]=S['split'](':');if(!X)continue;const v=Y==='edit'?'update':Y,D=h['get'](X)??new Set();for(const o of v?[v]:CRUD_ACTIONS)D['add'](o);h[K(0xdb)](X,D);}return[...h]['map'](([q,e])=>({'resource':q,'actions':[...e]}));}export async function setAccess(w,h){const y=Z,S=await h['pg']['connect']();try{await S['query']('BEGIN');w['type']===y(0xdc)?await S['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[w['id']]):await S['query']('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[w['id']]);const X=w[y(0xdd)]?permissionsToAccess(w[y(0xdd)]):w['access']??[];for(const Y of X){w[y(0xde)]===y(0xdc)?await S['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)',[Y[y(0xdf)],Y['actions'],w['id'],w[y(0xdc)]['id'],w['user']['id']]):await S[y(0xe0)](y(0xe1),[Y['resource'],Y[y(0xe2)],w['id'],w['user']['id'],w['user']['id']]);}await S['query']('COMMIT');}catch(v){await S['query']('ROLLBACK');throw v;}finally{S['release']();}return getAccess(w,h);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(w,h){w=w-0x9a;var S=z();var X=S[w];return X;}export async function updateDictionary(w,h){var S=G;return await h['dictionary']['put'](w['name'],w[S(0x9a)]),{'success':!![]};}function z(){var X=['items'];z=function(){return X;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(){const v=['entries'];z=function(){return v;};return z();}function G(w,h){w=w-0xc6;const S=z();let X=S[w];return X;}import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(w,h){const Y=G;if(!Object['keys'](w['patch'])['length'])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [S,X]of Object[Y(0xc6)](w['patch'])){if(!S['trim']()||S['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+S);await h['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',[S,JSON['stringify'](X),w['user']['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../errors.js';function
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function G(w,h){w=w-0x16a;var S=z();var X=S[w];return X;}function z(){var X=['type','Admin\x20access\x20required','permissions'];z=function(){return X;};return z();}export function requireAdmin(w,h){var S=G;if(!w)throw new ForbiddenError('User\x20required');if(w[S(0x16a)]!=='admin')throw new ForbiddenError(S(0x16b));if(w['type']!=='admin'&&h&&!w[S(0x16c)]?.['includes'](h))throw new ForbiddenError('Missing\x20permission:\x20'+h);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(w,h){w=w-0x69;const S=z();let X=S[w];return X;}export const safeUser=w=>{const Y=G,h=['password','salt',Y(0x69),'credentials'];return Object[Y(0x6a)](Object[Y(0x6b)](w)[Y(0x6c)](([S])=>!h[Y(0x6d)](X=>S['toLowerCase']()['includes'](X))));};function z(){const v=['secret','fromEntries','entries','filter','some'];z=function(){return v;};return z();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';function
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(w){throw new UnsupportedError(w+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(w){const
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(w){const h=writeAudit(w);return{'write':h};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const secretPattern=/password|token|secret|credential|salt/i;function z(){const V=['isArray','fromEntries','query','map','warn','admin.audit_log','newValue','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5,\x20$6,\x20$7,\x20$8,\x20$9)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20','resource','fields','test','field'];z=function(){return V;};return z();}function G(w,h){w=w-0x1a2;const S=z();let X=S[w];return X;}function clean(w){const e=G;if(Array[e(0x1a2)](w))return w['map'](clean);if(w&&typeof w==='object')return Object[e(0x1a3)](Object['entries'](w)['map'](([h,S])=>[h,secretPattern['test'](h)?'[REDACTED]':clean(S)]));return w;}export function writeAudit(w){let h,S;async function X(){const Z=G;if(!w['pg'])return![];if(h!==undefined)return h;return S??=w['pg'][Z(0x1a4)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](Y=>{const K=Z,v=new Set(Y['rows'][K(0x1a5)](D=>D['table_name']));return h=v['has']('audit_log')&&v['has']('audit_log_data'),!h&&w['logger'][K(0x1a6)]({'expectedTables':[K(0x1a7),'admin.audit_log_data'],'foundTables':[...v]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),h;})['catch'](Y=>{return h=![],w['logger']['warn']({'err':Y},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),S;}return async function Y(v){const y=G;if(!await X())return w['logger']['info']({'auditFallback':!![],'event':clean({...v,'changes':v['changes']?.['map'](q=>({...q,'oldValue':clean(q['oldValue']),'newValue':clean(q[y(0x1a8)])}))})},'audit'),0x0;if(!w['pg'])throw new Error('empty\x20pg');const D=await w['pg'][y(0x1a4)](y(0x1a9),[v['userId']??null,v['module'],v[y(0x1aa)],v['resourceId']==null?null:String(v['resourceId']),v[y(0x1ab)]??null,v['action'],v['requestId']??null,v['ipAddress']??null,clean(v['metadata']??{})]),o=D['rows'][0x0]['id'];for(const q of v['changes']??[]){if(secretPattern[y(0x1ac)](q['field']))continue;await w['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[o,q[y(0x1ad)],JSON['stringify'](clean(q['oldValue'])),JSON['stringify'](clean(q['newValue']))]);}return o;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(){const v=['query'];z=function(){return v;};return z();}function G(w,h){w=w-0x1e7;const S=z();let X=S[w];return X;}export async function getUserPermissions(w,h){const Y=G,S=await h['pg'][Y(0x1e7)]('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\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\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[w]);return S['rows']['map'](X=>X['permission']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./auth.types.js';import{randomBytes,scrypt as w,timingSafeEqual}from'node:crypto';function G(w,h){w=w-0x1f3;const S=z();let X=S[w];return X;}import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';import{join,resolve}from'node:path';function z(){const Q=['path','.json','code','scrypt$','toString','hex','from','warn','register','cookieOptions','database','storagePath','./storage','sessions','secret','registerUserDeserializer'];z=function(){return Q;};return z();}import{promisify}from'node:util';const scrypt=promisify(w);import h from'@fastify/cookie';import S from'@fastify/session';import{Authenticator}from'@fastify/passport';import X from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();class FileSessionStore{['path'];constructor(Y){this['path']=Y,void mkdir(this['path'],{'recursive':!![]});}['fileFor'](Y){const y=G;return join(this[y(0x1f3)],Y+y(0x1f4));}async['get'](Y,v){try{const D=await readFile(this['fileFor'](Y),'utf8');v(null,JSON['parse'](D));}catch(o){const q=o;if(q['code']==='ENOENT'){v(null,undefined);return;}v(q,undefined);}}async['set'](Y,v,D){try{await mkdir(this['path'],{'recursive':!![]}),await writeFile(this['fileFor'](Y),JSON['stringify'](v),'utf8'),D();}catch(o){D(o);}}async['destroy'](Y,v){try{await unlink(this['fileFor'](Y))['catch'](D=>{const V=G;if(D[V(0x1f5)]!=='ENOENT')throw D;}),v();}catch(D){v(D);}}}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(Y){const O=G,v=randomBytes(0x10),D=await scrypt(Y,v,0x40);return O(0x1f6)+v[O(0x1f7)]('hex')+'$'+D[O(0x1f7)](O(0x1f8));}export async function verifyPassword(Y,v){const H=G,[D,o,q]=v?.['split']('$')||[];if(D!=='scrypt'||!o||!q)return![];const e=Buffer['from'](o,'hex'),Z=Buffer[H(0x1f9)](q,'hex'),K=await scrypt(Y,e,Z['length']);return timingSafeEqual(K,Z);}export async function createSessionStore(Y,v){const R=G,{config:D,redis:o}=v;if(!D){console[R(0x1fa)]('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await Y[R(0x1fb)](h,{'parseOptions':D['auth'][R(0x1fc)]});const q=D['redis']['host']?new X({'prefix':D['auth']['cookieName']+':'+(D['pg']?.[R(0x1fd)]||'db')+':','client':o}):new FileSessionStore(resolve(D[R(0x1fe)]??R(0x1ff),R(0x200)));await Y[R(0x1fb)](S,{'secret':D['auth'][R(0x201)],'cookieName':D['auth']['cookieName'],'cookie':D['auth'][R(0x1fc)],'store':q}),await Y['register'](fastifyPassport['initialize']()),await Y['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async e=>({'user':e})),fastifyPassport[R(0x202)](async e=>{const Z=e?.['user']||e;return Z?.['id']&&(Z['permissions']=await getUserPermissions(Z['id'],v)),Z;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(){const K=['not\x20enough\x20params:\x20user','user\x20not\x20found','Wrong\x20password'];z=function(){return K;};return z();}function G(w,h){w=w-0x19c;const S=z();let X=S[w];return X;}import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';export async function verifyUser({user:w,password:h,ip:S},{pg:X,logger:Y}){const Z=G;if(!w||w==='')throw new BadRequestError(Z(0x19c));if(!h||h==='')throw new BadRequestError('not\x20enough\x20params:\x20password');Y['metrics']('user.login');const v='select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201',D=await X['query'](v,[w])['then'](q=>q['rows']?.[0x0]);if(!D){const q=Z(0x19d);Y['info']({'file':'auth/warn','error':q,'user':w,'ip':S});throw new BadRequestError(q);}const o=await verifyPassword(h,D['password_hash']);if(!o){const e=Z(0x19e);Y['info']({'file':'auth/warn','error':e,'user':w,'ip':S});throw new BadRequestError(e);}return delete D['password_hash'],D;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';
|
|
1
|
+
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:w,dictionaries:dictionaries=[]}){const h=new Map(),S=new Map();let X,Y;async function v(){const C=G;if(X!==undefined)return X;if(!w)throw new Error(C(0x18e));return Y??=w['query'](C(0x18f))['then'](O=>{const H=O['rows'][0x0]?.['table_name'];X=H==='dictionaries'?H:null;}),await Y,X;}function D(O){const A=G;if(!dictionaryName['test'](O))throw new ValidationError(A(0x190)+O);}function o(O){const L=G;for(const H of Array[L(0x191)](O)?O:[O]){D(H['code']);if(!Array['isArray'](H['items']))throw new ValidationError(L(0x192)+H[L(0x193)]);if(h['has'](H['code']))throw new ConflictError(L(0x194)+H['code']);h[L(0x195)](H[L(0x193)],{...H,'source':'static'});}}function q(O){const F=G;return h[F(0x196)](O);}async function e(O){const j=G;D(O);const H=h['get'](O);if(H&&H[j(0x197)])return H[j(0x198)];const R=await v();if(!R)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const Q=await w?.['query'](j(0x199),[O]);if(Q?.['rows']?.[j(0x19a)]){const P=Q?.['rows'];return h['set'](O,{'code':O,'name':O,'items':P,'source':j(0x19b),'checked':!![]}),P;}if(!H?.[j(0x198)])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+O);return H['checked']=!![],H[j(0x198)];}async function Z(O,H){const u=G;D(O);if(!Array['isArray'](H))throw new ValidationError(u(0x19c));const R=await v();if(!R)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!w)throw new Error('empty\x20pg');const Q=await w['connect']();try{await Q[u(0x19d)]('BEGIN');const P=await Q['query'](u(0x19e),[O,O,'fcore','custom',!![]]),x=P[u(0x19f)][0x0]['id'];await Q['query'](u(0x1a0),[x]);for(const c of H){await Q[u(0x19d)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[x,c['code'],c['name'],c['parentId']??null]);}await Q[u(0x19d)](u(0x1a1));}catch(d){await Q['query']('ROLLBACK');throw d;}finally{Q[u(0x1a2)]();}h['set'](O,{'items':H,'code':O,'source':'static','checked':!![]}),S['set'](O,(S['get'](O)??0x0)+0x1);}function K(O){const t=G;return D(O),S[t(0x195)](O,(S[t(0x1a3)](O)??0x0)+0x1),h[t(0x1a4)](O);}function y(O){return S['get'](O)??0x0;}async function V(){const O=[...h['values']()]['map'](({code:Q,name:P,source:x})=>({'code':Q,'name':P??Q,'source':x})),H=await v();if(!H)return O;if(!w)throw new Error('empty\x20pg');const R=await w['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const Q of R['rows']){!h['has'](Q['code'])&&O['push'](Q);}return O;}return o(dictionaries),{'register':o,'get':e,'put':Z,'clear':K,'revision':y,'list':V,'has':q};}function G(w,h){w=w-0x18e;const S=z();let X=S[w];return X;}function z(){const s=['empty\x20pg','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20','Invalid\x20dictionary\x20name:\x20','isArray','Invalid\x20dictionary\x20items:\x20','code','Dictionary\x20already\x20registered:\x20','set','has','checked','items','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','length','database','Dictionary\x20items\x20must\x20be\x20an\x20array','query','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','rows','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','COMMIT','release','get','delete'];z=function(){return s;};return z();}
|