@opengis/fcore 0.0.1-beta.23 → 0.0.1-beta.25
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.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +6 -0
- package/dist/modules/resource/schema.d.ts.map +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.d.ts.map +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.d.ts.map +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.d.ts +7 -3
- package/dist/plugins/file.d.ts.map +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.d.ts.map +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/resource.types.d.ts +22 -0
- 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.d.ts +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 +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.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.d.ts.map +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.d.ts +2 -1
- package/dist/plugins/resource/utils/filters.d.ts.map +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.d.ts +3 -0
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
- package/dist/plugins/resource/utils/summary.js +1 -0
- 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/20260910170000_core_schema.sql +22 -0
- package/package.json +93 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{listResources}from'./services/list-resources.js';import{getResource}from'./services/get-resource.js';import{createResource}from'./services/create-resource.js';function Y(w,y){w=w-0x93;const d=f();let Z=d[w];return Z;}import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';function f(){const T=['get','resource','query','params','/api/suggest/:resource/:field','suggestQuery','/api/resource/:resource/export','exportResource','user','post','Create\x20resource\x20record','config','/api/resource/:resource/:id','Get\x20resource\x20record','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','$resource:update','fcore','resourceId','uploadResourceFile','delete','rowCount','rows','List\x20resource\x20relations','auth','/api/resource/:resource/:id/:relation/:relationId','Updates\x20a\x20related\x20resource\x20record.','resourceIdRelationId'];f=function(){return T;};return f();}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 y=>{const n=Y;y[n(0x93)]('/api/resource/:resource/search',{'schema':{'tags':['fcore',n(0x94)],'summary':'Search\x20resource','description':'Searches\x20records\x20in\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas[n(0x94)]}},async d=>searchResource({...d[n(0x95)],...d[n(0x96)],'user':user(d)||w['config']?.['auth']?.['user']},w)),y[n(0x93)](n(0x97),{'schema':{'tags':['fcore','resource'],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resourceField'],'querystring':resourceSchemas[n(0x98)]}},async d=>suggestResource({...d['query'],...d[n(0x96)],'user':user(d)||w['config']?.['auth']?.['user']},w)),y['get'](n(0x99),{'schema':{'tags':['fcore',n(0x94)],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas[n(0x9a)],'querystring':resourceSchemas['exportResourceQuery']}},async d=>exportResource({...d[n(0x95)],...d['params'],'user':user(d)||w['config']?.['auth']?.['user']},w)),y['get']('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':n(0x9b),'permissions':['$resource:read'],'params':resourceSchemas[n(0x94)]}},async d=>listResources({...d['query'],...d['params'],'user':user(d)||w['config']?.['auth']?.[n(0x9b)]},w)),y[n(0x9c)]('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':n(0x9d),'description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':n(0x9b),'permissions':['$resource:create'],'params':resourceSchemas['resource']}},async d=>createResource({...d['params'],'data':d['body'],'user':user(d)||w[n(0x9e)]?.['auth']?.['user']},w)),y['get'](n(0x9f),{'schema':{'tags':['fcore','resource'],'summary':n(0xa0),'description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async d=>getResource({...d['query'],...d[n(0x96)],'user':user(d)||w['config']?.['auth']?.['user']},w)),y['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20record','description':n(0xa1),'access':'user','permissions':[n(0xa2)],'params':resourceSchemas['resourceId']}},async d=>updateResource({...d['params'],'patch':d['body'],'user':user(d)||w['config']?.['auth']?.['user']},w)),y['delete']('/api/resource/:resource/:id',{'schema':{'tags':[n(0xa3),'resource'],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:delete'],'params':resourceSchemas[n(0xa4)]}},async d=>deleteResource({...d['params'],'user':user(d)||w['config']?.['auth']?.[n(0x9b)]},w)),y['post']('/api/resource/:resource/:id/upload',{'schema':{'tags':['fcore',n(0x94)],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':[n(0xa2)],'params':resourceSchemas[n(0xa5)]}},async d=>{const t=n,Z=await d['file']();if(!Z)throw new Error('File\x20is\x20required');const M=d[t(0x96)]['resource'],H=d['params']['id'];return uploadFile({'file':Z,'metadata':{'name':Z['filename'],'path':Z['fields']['path']?.['value'],'resource':M,'resourceId':H},'user':d['user']},w);}),y[n(0xa6)]('/api/resource/:resource/:id/file/:fid',{'schema':{'tags':['fcore','resource'],'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':['$resource:update'],'params':resourceSchemas['resourceIdFileId']}},async d=>{const K=n,{resource:Z,id:M,fid:H}=d['params'],Q=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',[H,Z,String(M)]);if(!Q[K(0xa7)])throw new Error('File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record');const s=Q[K(0xa8)][0x0]?.['file_path'],j=await w['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[H,Z,String(M)]);return await w['file'][K(0xa6)](s),{'success':(j['rowCount']??0x0)>0x0,'resource':Z,'resourceId':M,'fileId':H};}),y['get']('/api/resource/:resource/:id/:relation',{'schema':{'tags':[n(0xa3),n(0x94)],'summary':n(0xa9),'description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':'user','params':resourceSchemas['resourceIdRelation'],'permissions':['$resource:read']}},async d=>listResourceRelation({...d[n(0x95)],...d['params'],'user':user(d)||w[n(0x9e)]?.[n(0xaa)]?.['user']},w)),y[n(0x9c)]('/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 d=>createResourceRelation({...d['params'],'data':d['body'],'user':user(d)||w[n(0x9e)]?.['auth']?.['user']},w)),y[n(0xa6)](n(0xab),{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':['$resource:delete'],'params':resourceSchemas['resourceIdRelationId']}},async d=>deleteResourceRelation({...d['params'],'user':user(d)||w['config']?.['auth']?.['user']},w)),y['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[n(0xa3),'resource'],'summary':'Update\x20resource\x20relation','description':n(0xac),'access':'user','permissions':[n(0xa2)],'params':resourceSchemas[n(0xad)]}},async d=>updateResourceRelation({...d['params'],'data':d['body'],'user':user(d)||w[n(0x9e)]?.[n(0xaa)]?.['user']},w));};}
|
|
@@ -50,6 +50,11 @@ export declare const resourceSchemas: {
|
|
|
50
50
|
relation: import("@sinclair/typebox").TString;
|
|
51
51
|
relationId: import("@sinclair/typebox").TString;
|
|
52
52
|
}>;
|
|
53
|
+
resourceIdFileId: import("@sinclair/typebox").TObject<{
|
|
54
|
+
resource: import("@sinclair/typebox").TString;
|
|
55
|
+
id: import("@sinclair/typebox").TString;
|
|
56
|
+
fid: import("@sinclair/typebox").TString;
|
|
57
|
+
}>;
|
|
53
58
|
uploadResourceFile: import("@sinclair/typebox").TObject<{
|
|
54
59
|
resource: import("@sinclair/typebox").TString;
|
|
55
60
|
id: import("@sinclair/typebox").TString;
|
|
@@ -62,6 +67,7 @@ export declare const resourceSchemas: {
|
|
|
62
67
|
filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
63
68
|
sort: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
64
69
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
70
|
+
scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
65
71
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
66
72
|
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
67
73
|
fields: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;QACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB;CACF;AAED,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,eAAe;IAC1B,cAAc;;;IACd,QAAQ;;;IACR,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;IAKZ,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,aAAa;QACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;QACrC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB;CACF;AAED,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,eAAe;IAC1B,cAAc;;;IACd,QAAQ;;;IACR,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;IAKZ,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,gBAAgB;;;;;IAKhB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;;CASpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const w=Y;import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':w(0x190)});function Y(w,y){w=w-0x190;const d=f();let Z=d[w];return Z;}export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type[w(0x191)]({'resource':identifier}),'exportResource':Type[w(0x191)]({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type[w(0x192)](Type[w(0x193)]()),'search':Type['Optional'](Type[w(0x193)]()),'limit':Type[w(0x192)](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[w(0x191)]({'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[w(0x191)]({'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(0x193)](),Type['Unknown']())),'sort':Type['Optional'](Type['Array'](Type[w(0x193)]({'minLength':0x1}))),'search':Type['Optional'](Type['String']()),'scope':Type['Optional'](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type[w(0x194)]({'minimum':0x0})),'fields':Type['Optional'](Type['Array'](identifier))})};function f(){const y=['^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Optional','String','Integer'];f=function(){return y;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0xbb;const d=f();let Z=d[w];return Z;}function f(){const M=['body'];f=function(){return M;};return f();}export async function addNote(w,y){const Z=Y,d=await y['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[w['resource'],String(w['id']),w[Z(0xbb)]]);return d['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function addResourceFile(w,y){const Z=Y,d=await y['pg'][Z(0x85)]('\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['resource'],String(w['id']),w[Z(0x86)],w['size']??null]);return d[Z(0x87)][0x0];}function Y(w,y){w=w-0x85;const d=f();let Z=d[w];return Z;}function f(){const M=['query','filePath','rows'];f=function(){return M;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x10e;const d=f();let Z=d[w];return Z;}export async function createResourceRelation(w,y){const s=Y,{resource:d,id:Z,relation:M,data:H,user:Q}=w;return y['resource'][s(0x10e)]({'name':d,'id':Z,'relation':M,'data':H,'user':Q});}function f(){const j=['createRelation'];f=function(){return j;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(){var Z=['resource'];f=function(){return Z;};return f();}function Y(w,y){w=w-0x15f;var d=f();var Z=d[w];return Z;}export async function createResource(w,y){var d=Y;return y[d(0x15f)]['create']({'name':w['resource'],'data':w['data'],'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResourceRelation(
|
|
1
|
+
function f(){const s=['resource','deleteRelation'];f=function(){return s;};return f();}function Y(w,y){w=w-0xf8;const d=f();let Z=d[w];return Z;}export async function deleteResourceRelation(w,y){const Q=Y,{resource:d,id:Z,relation:M,relationId:H}=w;return y[Q(0xf8)][Q(0xf9)]({'name':d,'id':Z,'relation':M,'relationId':H});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function deleteResource(
|
|
1
|
+
export async function deleteResource(w,y){return y['resource']['delete']({'name':w['resource'],'id':w['id'],'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x78;const d=f();let Z=d[w];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){const M=['offset','user'];f=function(){return M;};return f();}export async function exportResource(w,y){const Z=Y,d=await y['resource']['find']({'name':w['resource'],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'limit':w['limit'],'offset':w[Z(0x78)],'fields':w['fields']},'user':w[Z(0x79)]});return d['rows'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getResource(
|
|
1
|
+
export async function getResource(w,y){return y['resource']['findOne']({'name':w['resource'],'id':w['id'],'query':{'include':w['include']},'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listResourceRelation(
|
|
1
|
+
export async function listResourceRelation(w,y){const s=Y,{resource:d,id:Z,relation:M,query:H,user:Q}=w;return y['resource'][s(0x18b)]({'name':d,'id':Z,'relation':M,'query':H,'user':Q});}function Y(w,y){w=w-0x18b;const d=f();let Z=d[w];return Z;}function f(){const j=['findRelation'];f=function(){return j;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAa9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x93;var d=f();var Z=d[w];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){var Z=['offset','max','page','limit'];f=function(){return Z;};return f();}export async function listResources(w,y){var d=Y;return y['resource']['find']({'name':w['resource'],'query':{'filter':parseFilterQuery(w),'sort':w['sort'],'search':w['search'],'scope':w['scope'],'limit':w['limit'],'offset':w[d(0x93)]??(w['page']?Math[d(0x94)](w[d(0x95)]-0x1,0x0):0x0)*(w[d(0x96)]??0x14)},'user':w['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(){var Z=['resource','user'];f=function(){return Z;};return f();}function Y(w,y){w=w-0xe6;var d=f();var Z=d[w];return Z;}export async function searchResource(w,y){var d=Y;return y['resource']['find']({'name':w[d(0xe6)],'query':{...w,'filter':parseFilterQuery(w)},'user':w[d(0xe7)]});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(){const U=['resource','get','now','lookup','query','\x20as\x20text\x20FROM\x20','toLowerCase','then','dictionary','filter','code','name'];f=function(){return U;};return f();}import{ValidationError}from'../../../errors.js';function Y(w,y){w=w-0x1eb;const d=f();let Z=d[w];return Z;}import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';export async function suggestResource(w,y){const G=Y,d=y[G(0x1eb)][G(0x1ec)](w['resource']),Z=String(w['search']??w['q']??'')['toLowerCase'](),M=Math['min'](Math['max'](Number(w['limit']??0x14),0x1),0xc8),H=Date[G(0x1ed)](),Q=d['fields'][w['field']],s=Q?.['dictionary'],j=Q?.[G(0x1ee)]?.['table'];if(j){const K=Q['lookup']?.['text']??'name',T=Q[G(0x1ee)]?.['value']??'id';autoIndex(j,K,'text',y['pg']);const h=await y['pg'][G(0x1ef)]('SELECT\x20'+T+'\x20as\x20id,\x20'+K+G(0x1f0)+j+'\x20WHERE\x20lower('+K+')\x20~\x20$1\x20LIMIT\x20$2',[''+Z[G(0x1f1)](),M])[G(0x1f2)](i=>i['rows']);return{'limit':M,'count':h['length'],'search':Z,'time':Date[G(0x1ed)]()-H,'data':h};}if(!s)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+w['field']);const n=await y[G(0x1f3)]['get'](s),t=n[G(0x1f4)](i=>!Z||i['code']['startsWith'](Z)||i['name']['startsWith'](Z))['slice'](0x0,M)['map'](i=>({'id':i[G(0x1f5)]||i['id'],'text':i[G(0x1f6)]||i['text']}));return{'search':Z,'limit':M,'count':t['length'],'time':Date['now']()-H,'data':t};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateResourceRelation(
|
|
1
|
+
function f(){const n=['resource'];f=function(){return n;};return f();}function Y(w,y){w=w-0xcf;const d=f();let Z=d[w];return Z;}export async function updateResourceRelation(w,y){const j=Y,{resource:d,id:Z,relation:M,relationId:H,data:Q,user:s}=w;return y[j(0xcf)]['updateRelation']({'name':d,'id':Z,'relation':M,'relationId':H,'data':Q,'user':s});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function updateResource(
|
|
1
|
+
function Y(w,y){w=w-0x14c;var d=f();var Z=d[w];return Z;}function f(){var Z=['resource','user'];f=function(){return Z;};return f();}export async function updateResource(w,y){var d=Y;return y[d(0x14c)]['update']({'name':w[d(0x14c)],'id':w['id'],'data':w['patch'],'user':w[d(0x14d)]});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(){const s=['resource','get','admin','user','name','permission',':update','isBuffer','file','length','File\x20name\x20is\x20required','Uploaded\x20file\x20not\x20found','rows'];f=function(){return s;};return f();}function Y(w,y){w=w-0x1ac;const d=f();let Z=d[w];return Z;}export async function uploadResourceFile(w,y){const Q=Y,d=y[Q(0x1ac)][Q(0x1ad)](w['resource']);if(d['access']==='admin'&&w['user']?.['type']!==Q(0x1ae))throw new ForbiddenError('Admin\x20access\x20required');if(w['user']?.['type']!==Q(0x1ae)&&!w[Q(0x1af)]?.['permissions']?.['includes']((d['permission']??d[Q(0x1b0)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(d[Q(0x1b1)]??d[Q(0x1b0)])+Q(0x1b2));if(!Buffer[Q(0x1b3)](w['file'])||w[Q(0x1b4)][Q(0x1b5)]===0x0)throw new ValidationError('File\x20is\x20required');const Z=w['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!Z)throw new ValidationError(Q(0x1b6));const M='files/'+w['resource']+'/'+String(w['id'])+'/'+Z;await y['file']['put'](M,w['file']);if(!await y['file']['exists'](M))throw new NotFoundError(Q(0x1b7));const H=await y['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[w[Q(0x1ac)],String(w['id']),M,w[Q(0x1b4)]['length']]);return H[Q(0x1b8)][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';
|
|
1
|
+
const j=Y;import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';function f(){const t=['user','system','dictionaryName','/api/dictionary/:name','system:dictionaries','body','get','/api/access/:type/:id','fcore','admin','post','Set\x20access\x20rules','system:access','/api/system/settings','Update\x20system\x20settings','Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','apiListQuery'];f=function(){return t;};return f();}import{getAccess}from'./services/get-access.js';import{setAccess}from'./services/set-access.js';function Y(w,y){w=w-0x186;const d=f();let Z=d[w];return Z;}import{systemSchemas}from'./schema.js';const u=w=>w[j(0x186)];export function systemRoutes(w,y=new Map()){return async d=>{const n=Y;d['get']('/api/dictionary/:name',{'schema':{'tags':['fcore',n(0x187)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':['system:dictionaries'],'params':systemSchemas[n(0x188)]}},async M=>({'items':await getDictionary({...M['params'],'user':u(M)},w)})),d['post'](n(0x189),{'schema':{'tags':['fcore',n(0x187)],'summary':'Update\x20platform\x20dictionary','description':'Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','access':'user','permissions':[n(0x18a)],'params':systemSchemas[n(0x188)],'body':systemSchemas['dictionaryItems']}},async M=>updateDictionary({...M['params'],...M[n(0x18b)],'user':u(M)},w));const Z=async M=>getAccess({...M['params'],'user':u(M)},w);d[n(0x18c)](n(0x18d),{'schema':{'tags':[n(0x18e),n(0x187)],'summary':'Get\x20access\x20rules','description':'Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':n(0x18f),'permissions':['system:access'],'params':systemSchemas['accessTarget']}},Z),d[n(0x190)](n(0x18d),{'schema':{'tags':[n(0x18e),'system'],'summary':n(0x191),'description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[n(0x192)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async M=>setAccess({...M['params'],...M['body'],'user':u(M)},w)),d['get']('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20settings','description':'Returns\x20system\x20settings\x20as\x20nested\x20JSON.','access':n(0x18f),'permissions':['system:settings']}},async M=>getSystemSettings({...M['params'],'user':u(M)},w)),d['post'](n(0x193),{'schema':{'tags':['fcore','system'],'summary':n(0x194),'description':n(0x195),'access':'admin','permissions':['system:settings'],'body':systemSchemas['settings']}},async M=>updateSystemSettings({...M['params'],'patch':M['body'],'user':u(M)},w)),d['get']('/api/system/logger',{'schema':{'tags':['fcore','system'],'summary':'Get\x20system\x20log','description':'Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','access':'user','permissions':['system:logs'],'querystring':systemSchemas['logger']}},async(M,H)=>{const {contentType:Q,body:s}=await getSystemLog({...M['query'],'user':u(M)},w);return H['type'](Q)['send'](s);}),d[n(0x18c)]('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':'Returns\x20the\x20system\x20audit\x20log\x20entries.','access':n(0x186),'permissions':['system:audit']}},async M=>getAuditLog({...M['query'],'user':u(M)},w)),d['get']('/api/system/check',{'schema':{'tags':[n(0x18e),'system'],'summary':'Check\x20system\x20health','description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async M=>checkSystem({'user':u(M)},w)),d['get']('/api/system/list',{'schema':{'tags':[n(0x18e),'system'],'summary':'List\x20APIs','description':n(0x196),'access':n(0x18f),'permissions':[],'querystring':systemSchemas[n(0x197)]}},async M=>getApiList({'user':u(M),'apiRoutes':y,...M['query']},w));};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(){const y=['Object','Optional','Number','user','Literal','String','Union','Unknown'];f=function(){return y;};return f();}const w=Y;import{Type}from'@sinclair/typebox';function Y(w,y){w=w-0x108;const d=f();let Z=d[w];return Z;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type[w(0x108)]({'name':identifier}),'dictionaryItems':Type[w(0x108)]({'items':Type['Array'](Type['Object']({'id':Type[w(0x109)](Type['Union']([Type['String'](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type[w(0x10a)](),Type['Null']()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal'](w(0x10b)),Type[w(0x10c)]('role')]),'id':identifier}),'access':Type[w(0x108)]({'permissions':Type[w(0x109)](Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$'}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type[w(0x10d)]({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type[w(0x108)]({'format':Type[w(0x109)](Type[w(0x10e)]([Type['Literal']('short'),Type[w(0x10c)]('extended')]))}),'settingsEntity':Type[w(0x108)]({'entity':Type['Optional'](identifier)}),'settings':Type['Record'](Type[w(0x10d)]({'minLength':0x1}),Type[w(0x10f)]()),'logger':Type['Object']({'path':Type['Optional'](Type[w(0x10d)]({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function checkSystem(
|
|
1
|
+
export async function checkSystem(w,y){const M=Y,[d,Z]=await Promise['allSettled']([y['pg'][M(0x15a)]('SELECT\x201'),y[M(0x15b)]['ping']()]);return{'status':d['status']==='fulfilled'&&Z[M(0x15c)]===M(0x15d)?'ok':'degraded','pg':d[M(0x15c)],'redis':Z['status']};}function Y(w,y){w=w-0x15a;const d=f();let Z=d[w];return Z;}function f(){const H=['query','redis','status','fulfilled'];f=function(){return H;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x119;const d=f();let Z=d[w];return Z;}export async function getAccess(w,y){const Q=Y,d=w['type']==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':Q(0x119),Z=await y['pg']['query'](d,[w['id']]),M=[...new Set(Z['rows']['map'](H=>H[Q(0x11a)])['filter'](H=>H!==null))];return{'access':Z['rows'],'resources':M};}function f(){const s=['\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20','resource'];f=function(){return s;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getApiList(
|
|
1
|
+
function Y(w,y){w=w-0x187;const d=f();let Z=d[w];return Z;}function f(){const j=['values','sort','method','short'];f=function(){return j;};return f();}export async function getApiList(w,y){const s=Y,d=[...w['apiRoutes'][s(0x187)]()][s(0x188)]((Z,M)=>(Z['endpoint']+'\x20'+Z['method'])['localeCompare'](M['endpoint']+'\x20'+M[s(0x189)]));if(w['format']!==s(0x18a))return d;return d['map'](({method:Z,endpoint:M,access:H,permissions:Q})=>Z+'\x20'+M);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getAuditLog(
|
|
1
|
+
function Y(w,y){w=w-0x9d;const d=f();let Z=d[w];return Z;}function f(){const Q=['limit','page'];f=function(){return Q;};return f();}export async function getAuditLog(w,y){const H=Y,d=Math['min'](Math['max'](w[H(0x9d)]??0x32,0x1),0xc8),Z=Math['max']((w[H(0x9e)]??0x1)-0x1,0x0)*d,M=await y['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[d,Z]);return{'rows':M['rows'],'page':w[H(0x9e)]??0x1,'limit':d};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getDictionary(
|
|
1
|
+
export async function getDictionary(w,y){return y['dictionary']['get'](w['name']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import w from'node:fs/promises';import y from'node:path';import{NotFoundError,ValidationError}from'../../../errors.js';const LOGS_ROOT=y['resolve'](process['cwd'](),'logs'),TAIL_LINES=0x64;export async function getSystemLog(d,Z){const i=Y,M=normalizePath(d['path']),H=y['resolve'](LOGS_ROOT,M);if(H!==LOGS_ROOT&&!H['startsWith'](LOGS_ROOT+y['sep']))throw new ValidationError('Invalid\x20log\x20path');const Q=await w[i(0xbc)](H)[i(0xbd)](()=>null);if(!Q)throw new NotFoundError('Log\x20path\x20not\x20found');if(Q['isDirectory']()){const j=await w['readdir'](H,{'withFileTypes':!![]}),n=await Promise['all'](j[i(0xbe)](async t=>{const G=i,K=await w['stat'](y['join'](H,t['name']));return{'name':t[G(0xbf)],'path':M?M+'/'+t['name']:t['name'],'type':t[G(0xc0)]()?G(0xc1):'file','size':t[G(0xc0)]()?undefined:K['size'],'modified':K['mtime'][G(0xc2)]()};}));n['sort']((t,K)=>t['name'][i(0xc3)](K[i(0xbf)]));if(M){const t=M['split']('/')['slice'](0x0,-0x1)['join']('/');n['unshift']({'name':'..','path':t,'type':i(0xc1)});}return{'contentType':'text/html;\x20charset=utf-8','body':renderDirectory(M,n)};}const s=await tailFile(H,TAIL_LINES);return{'contentType':'text/plain;\x20charset=utf-8','body':s['join']('\x0a')};}function renderDirectory(d,Z){const U=Y,M=Z['map'](Q=>{const s='?path='+encodeURIComponent(Q['path']),j=Q['type']==='directory'?Q['name']+'/':Q['name'];return'<li><a\x20href=\x22'+s+'\x22>'+escapeHtml(j)+'</a></li>';})['join']('\x0a'),H=escapeHtml('logs/'+d);return'<!DOCTYPE\x20html>\x0a<html>\x0a<head><meta\x20charset=\x22utf-8\x22><title>'+H+'</title></head>\x0a<body>\x0a<h1>'+H+U(0xc4)+M+'\x0a</ul>\x0a</body>\x0a</html>';}function escapeHtml(d){const E=Y;return d['replace'](/&/g,'&')['replace'](/</g,'<')['replace'](/>/g,'>')['replace'](/"/g,E(0xc5));}function Y(w,y){w=w-0xbc;const d=f();let Z=d[w];return Z;}function normalizePath(d){const e=Y,Z=(d??'')['replace'](/\\/g,'/')['replace'](/^\/+|\/+$/g,'');if(Z['split']('/')[e(0xc6)](M=>M==='..'))throw new ValidationError('Invalid\x20log\x20path');return Z;}function f(){const A=['stat','catch','map','name','isDirectory','directory','toISOString','localeCompare','</h1>\x0a<ul>\x0a','"','some','open','alloc','read','utf8','split','close'];f=function(){return A;};return f();}async function tailFile(d,Z){const l=Y,M=await w[l(0xc7)](d,'r');try{const {size:H}=await M['stat'](),Q=0x40*0x400;let s=H,j=Buffer[l(0xc8)](0x0),n=0x0;while(s>0x0&&n<=Z){const K=Math['min'](Q,s);s-=K;const T=Buffer['alloc'](K);await M[l(0xc9)](T,0x0,K,s),j=Buffer['concat']([T,j]),n+=countNewlines(T);}const t=j['toString'](l(0xca))[l(0xcb)]('\x0a')['filter'](h=>h['length']>0x0);return t['slice'](-Z)['reverse']();}finally{await M[l(0xcc)]();}}function countNewlines(d){let Z=0x0;for(const M of d){if(M===0xa)Z++;}return Z;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
export async function getSystemSettings(w,y){const j=Y,d=await y['pg']['query'](j(0x1b1));return d['rows']['reduce']((Z,M)=>{const n=j,H=String(M['key'])[n(0x1b2)]('.');let Q=Z;for(const s of H[n(0x1b3)](0x0,-0x1)){Q[s]??={},Q=Q[s];}return Q[H['at'](-0x1)]=M[n(0x1b4)],Z;},{});}function Y(w,y){w=w-0x1b1;const d=f();let Z=d[w];return Z;}function f(){const t=['\x0a\x20\x20\x20\x20\x20\x20SELECT\x20key,\x20value\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.settings\x0a\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20\x27system\x27\x20AND\x20resource_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20key\x0a\x20\x20\x20\x20','split','slice','value'];f=function(){return t;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function listDictionaries(
|
|
1
|
+
function f(){var Z=['list'];f=function(){return Z;};return f();}function Y(w,y){w=w-0x1ce;var d=f();var Z=d[w];return Z;}export async function listDictionaries(w,y){var d=Y;return y['dictionary'][d(0x1ce)]();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const t=Y;function Y(w,y){w=w-0x7d;const d=f();let Z=d[w];return Z;}import{getAccess}from'./get-access.js';const CRUD_ACTIONS=[t(0x7d),'update','create','delete'];function permissionsToAccess(w){const K=t,y=new Map();for(const d of w){const [Z,M]=d['split'](':');if(!Z)continue;const H=M==='edit'?'update':M,Q=y['get'](Z)??new Set();for(const s of H?[H]:CRUD_ACTIONS)Q['add'](s);y[K(0x7e)](Z,Q);}return[...y][K(0x7f)](([j,n])=>({'resource':j,'actions':[...n]}));}export async function setAccess(w,y){const T=t,d=await y['pg'][T(0x80)]();try{await d['query'](T(0x81));w['type']==='user'?await d[T(0x82)](T(0x83),[w['id']]):await d[T(0x82)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20role_id\x20=\x20$1\x20AND\x20user_uid\x20IS\x20NULL',[w['id']]);const Z=w['permissions']?permissionsToAccess(w['permissions']):w[T(0x84)]??[];for(const M of Z){w[T(0x85)]==='user'?await d['query'](T(0x86),[M['resource'],M[T(0x87)],w['id'],w['user']['id'],w['user']['id']]):await d[T(0x82)](T(0x88),[M[T(0x89)],M['actions'],w['id'],w['user']['id'],w[T(0x8a)]['id']]);}await d['query']('COMMIT');}catch(H){await d['query']('ROLLBACK');throw H;}finally{d[T(0x8b)]();}return getAccess(w,y);}function f(){const h=['read','set','map','connect','BEGIN','query','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','access','type','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20user_uid,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','actions','INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20(\x20resource,\x20actions,\x20role_id,\x20created_by,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)','resource','user','release'];f=function(){return h;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(){var Z=['name','items'];f=function(){return Z;};return f();}function Y(w,y){w=w-0xe7;var d=f();var Z=d[w];return Z;}export async function updateDictionary(w,y){var d=Y;return await y['dictionary']['put'](w[d(0xe7)],w[d(0xe8)]),{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0xc4;const d=f();let Z=d[w];return Z;}import{ValidationError}from'../../../errors.js';function f(){const H=['patch','length','query','user'];f=function(){return H;};return f();}export async function updateSystemSettings(w,y){const M=Y;if(!Object['keys'](w[M(0xc4)])[M(0xc5)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [d,Z]of Object['entries'](w['patch'])){if(!d['trim']()||d['includes']('..'))throw new ValidationError('Invalid\x20setting\x20key:\x20'+d);await y['pg'][M(0xc6)]('\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',[d,JSON['stringify'](Z),w[M(0xc7)]['id']]);}return{'success':!![]};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function f(){var Z=['User\x20required','type','Admin\x20access\x20required','permissions'];f=function(){return Z;};return f();}function Y(w,y){w=w-0x6a;var d=f();var Z=d[w];return Z;}export function requireAdmin(w,y){var d=Y;if(!w)throw new ForbiddenError(d(0x6a));if(w[d(0x6b)]!=='admin')throw new ForbiddenError(d(0x6c));if(w['type']!=='admin'&&y&&!w[d(0x6d)]?.['includes'](y))throw new ForbiddenError('Missing\x20permission:\x20'+y);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(){const H=['password','secret','some'];f=function(){return H;};return f();}function Y(w,y){w=w-0xd2;const d=f();let Z=d[w];return Z;}export const safeUser=w=>{const M=Y,y=[M(0xd2),'salt',M(0xd3),'credentials'];return Object['fromEntries'](Object['entries'](w)['filter'](([d])=>!y[M(0xd4)](Z=>d['toLowerCase']()['includes'](Z))));};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';function f(){var d=['\x20requires\x20a\x20project/provider\x20implementation'];f=function(){return d;};return f();}function Y(w,y){w=w-0xbb;var d=f();var Z=d[w];return Z;}export function unsupported(w){var y=Y;throw new UnsupportedError(w+y(0xbb));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(w){const y=writeAudit(w);return{'write':y};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(){const i=['fromEntries','entries','query','then','map','audit_log_data','logger','warn','audit','module','ipAddress','metadata','\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'];f=function(){return i;};return f();}const secretPattern=/password|token|secret|credential|salt/i;function clean(w){const n=Y;if(Array['isArray'](w))return w['map'](clean);if(w&&typeof w==='object')return Object[n(0x1b9)](Object[n(0x1ba)](w)['map'](([y,d])=>[y,secretPattern['test'](y)?'[REDACTED]':clean(d)]));return w;}function Y(w,y){w=w-0x1b9;const d=f();let Z=d[w];return Z;}export function writeAudit(w){let y,d;async function Z(){const t=Y;if(!w['pg'])return![];if(y!==undefined)return y;return d??=w['pg'][t(0x1bb)]('\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')[t(0x1bc)](M=>{const K=t,H=new Set(M['rows'][K(0x1bd)](Q=>Q['table_name']));return y=H['has']('audit_log')&&H['has'](K(0x1be)),!y&&w[K(0x1bf)][K(0x1c0)]({'expectedTables':['admin.audit_log','admin.audit_log_data'],'foundTables':[...H]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),y;})['catch'](M=>{const T=t;return y=![],w[T(0x1bf)][T(0x1c0)]({'err':M},'Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled'),![];}),d;}return async function M(H){const h=Y;if(!await Z())return w[h(0x1bf)]['info']({'auditFallback':!![],'event':clean({...H,'changes':H['changes']?.['map'](j=>({...j,'oldValue':clean(j['oldValue']),'newValue':clean(j['newValue'])}))})},h(0x1c1)),0x0;if(!w['pg'])throw new Error('empty\x20pg');const Q=await w['pg']['query']('\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',[H['userId']??null,H[h(0x1c2)],H['resource'],H['resourceId']==null?null:String(H['resourceId']),H['fields']??null,H['action'],H['requestId']??null,H[h(0x1c3)]??null,clean(H[h(0x1c4)]??{})]),s=Q['rows'][0x0]['id'];for(const j of H['changes']??[]){if(secretPattern['test'](j['field']))continue;await w['pg'][h(0x1bb)](h(0x1c5),[s,j['field'],JSON['stringify'](clean(j['oldValue'])),JSON['stringify'](clean(j['newValue']))]);}return s;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x151;const d=f();let Z=d[w];return Z;}export async function getUserPermissions(w,y){const M=Y,d=await y['pg'][M(0x151)]('\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 d['rows']['map'](Z=>Z['permission']);}function f(){const H=['query'];f=function(){return H;};return f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAYhC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAwD5D,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAE1C,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAKpE;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC,CAalB;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,mBAAmB,iBAmDzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from'./auth.types.js';import{randomBytes,scrypt as
|
|
1
|
+
const T=Y;export*from'./auth.types.js';import{randomBytes,scrypt as w,timingSafeEqual}from'node:crypto';import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';import{join,resolve}from'node:path';function Y(w,y){w=w-0x75;const d=f();let Z=d[w];return Z;}import{promisify}from'node:util';const scrypt=promisify(w);import y from'@fastify/cookie';import d from'@fastify/session';import{Authenticator}from'@fastify/passport';import Z from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';function f(){const e=['path','fileFor','code','stringify','from','warn','cookieOptions','host','auth','database'];f=function(){return e;};return f();}const fastifyPassport=new Authenticator();class FileSessionStore{[T(0x75)];constructor(M){const h=T;this[h(0x75)]=M,void mkdir(this[h(0x75)],{'recursive':!![]});}[T(0x76)](M){return join(this['path'],M+'.json');}async['get'](M,H){const i=T;try{const Q=await readFile(this[i(0x76)](M),'utf8');H(null,JSON['parse'](Q));}catch(s){const j=s;if(j[i(0x77)]==='ENOENT'){H(null,undefined);return;}H(j,undefined);}}async['set'](M,H,Q){const G=T;try{await mkdir(this['path'],{'recursive':!![]}),await writeFile(this['fileFor'](M),JSON[G(0x78)](H),'utf8'),Q();}catch(s){Q(s);}}async['destroy'](M,H){try{await unlink(this['fileFor'](M))['catch'](Q=>{if(Q['code']!=='ENOENT')throw Q;}),H();}catch(Q){H(Q);}}}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(M){const H=randomBytes(0x10),Q=await scrypt(M,H,0x40);return'scrypt$'+H['toString']('hex')+'$'+Q['toString']('hex');}export async function verifyPassword(M,H){const U=T,[Q,s,j]=H?.['split']('$')||[];if(Q!=='scrypt'||!s||!j)return![];const n=Buffer['from'](s,'hex'),t=Buffer[U(0x79)](j,'hex'),K=await scrypt(M,n,t['length']);return timingSafeEqual(K,t);}export async function createSessionStore(M,H){const E=T,{config:Q,redis:s}=H;if(!Q){console[E(0x7a)]('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV==='test'||process.env.VITEST)return;await M['register'](y,{'parseOptions':Q['auth'][E(0x7b)]});const j=Q['redis'][E(0x7c)]?new Z({'prefix':Q[E(0x7d)]['cookieName']+':'+(Q['pg']?.[E(0x7e)]||'db')+':','client':s}):new FileSessionStore(resolve(Q['storagePath']??'./storage','sessions'));await M['register'](d,{'secret':Q['auth']['secret'],'cookieName':Q['auth']['cookieName'],'cookie':Q['auth']['cookieOptions'],'store':j}),await M['register'](fastifyPassport['initialize']()),await M['register'](fastifyPassport['secureSession']()),fastifyPassport['registerUserSerializer'](async n=>({'user':n})),fastifyPassport['registerUserDeserializer'](async n=>{const t=n?.['user']||n;return t?.['id']&&(t['permissions']=await getUserPermissions(t['id'],H)),t;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Y(w,y){w=w-0x77;const d=f();let Z=d[w];return Z;}import{BadRequestError}from'../../errors.js';function f(){const K=['not\x20enough\x20params:\x20user','not\x20enough\x20params:\x20password','metrics','then','info'];f=function(){return K;};return f();}import{verifyPassword}from'./index.js';export async function verifyUser({user:w,password:y,ip:d},{pg:Z,logger:M}){const t=Y;if(!w||w==='')throw new BadRequestError(t(0x77));if(!y||y==='')throw new BadRequestError(t(0x78));M[t(0x79)]('user.login');const H='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',Q=await Z['query'](H,[w])[t(0x7a)](j=>j['rows']?.[0x0]);if(!Q){const j='user\x20not\x20found';M[t(0x7b)]({'file':'auth/warn','error':j,'user':w,'ip':d});throw new BadRequestError(j);}const s=await verifyPassword(y,Q['password_hash']);if(!s){const n='Wrong\x20password';M['info']({'file':'auth/warn','error':n,'user':w,'ip':d});throw new BadRequestError(n);}return delete Q['password_hash'],Q;}
|