@opengis/fcore 0.0.1-beta.8 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +0 -3
- 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.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.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 +19 -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/generate-resource-code.d.ts +16 -0
- package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
- package/dist/modules/resource/services/generate-resource-code.js +1 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
- package/dist/modules/resource/services/get-resource-schema.js +1 -0
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
- package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-as-user.js +1 -0
- package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
- package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-list.js +1 -0
- 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.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +25 -2
- package/dist/modules/system/schema.d.ts.map +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.d.ts +1 -0
- package/dist/modules/system/services/get-access.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.d.ts +23 -0
- package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-access.js +1 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-scopes.js +1 -0
- 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.d.ts +3 -1
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.d.ts +18 -0
- package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-access.js +1 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-scopes.js +1 -0
- 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/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +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.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +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.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 +71 -17
- 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.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +5 -2
- 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.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
- 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.d.ts +9 -2
- package/dist/plugins/resource/services/delete.d.ts.map +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.d.ts +8 -0
- package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
- package/dist/plugins/resource/services/get-table-columns.js +1 -0
- package/dist/plugins/resource/services/update-relation.d.ts +5 -2
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts +9 -2
- package/dist/plugins/resource/services/update.d.ts.map +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/scope.d.ts +10 -0
- package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
- package/dist/plugins/resource/utils/scope.js +1 -0
- package/dist/plugins/resource/utils/sort.d.ts +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +7 -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/20260903120000_core_schema.sql +5 -2
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260907090000_core_schema.sql +32 -2
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +93 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
const i=A;import{ForbiddenError}from'../../errors.js';import{listResources}from'./services/list-resources.js';import{getResource}from'./services/get-resource.js';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';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';function A(z,j){z=z-0xc7;const c=U();let p=c[z];return p;}import{uploadFile}from'../file/services/upload-file.js';const user=z=>z[i(0xc7)];export function resourceRoutes(z){return async j=>{const b=A;j['get'](b(0xc8),{'schema':{'tags':['fcore','resource'],'summary':'Search\x20resource','description':b(0xc9),'access':b(0xc7),'permissions':[],'params':resourceSchemas['resource']}},async c=>searchResource({...c['query'],...c['params'],'user':user(c)},z)),j[b(0xca)]('/api/suggest/:resource/:field',{'schema':{'tags':['fcore',b(0xcb)],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':b(0xc7),'permissions':[],'params':resourceSchemas[b(0xcc)],'querystring':resourceSchemas['suggestQuery']}},async c=>suggestResource({...c['query'],...c['params'],'user':user(c)},z)),j[b(0xca)]('/api/resource/:resource/export',{'schema':{'tags':[b(0xcd),'resource'],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':b(0xc7),'permissions':['*:read'],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async c=>exportResource({...c['query'],...c['params'],'user':user(c)},z)),j[b(0xca)]('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resource']}},async c=>listResources({...c[b(0xce)],...c['params'],'user':user(c)},z)),j[b(0xcf)]('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':'Create\x20resource\x20record','description':b(0xd0),'access':'user','permissions':[],'params':resourceSchemas['resource']}},async c=>createResource({...c[b(0xd1)],'data':c['body'],'user':user(c)},z)),j[b(0xca)]('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20record','description':b(0xd2),'access':'user','permissions':[],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async c=>getResource({...c[b(0xce)],...c['params'],'user':user(c)},z)),j['put'](b(0xd3),{'schema':{'tags':['fcore',b(0xcb)],'summary':'Update\x20resource\x20record','description':b(0xd4),'access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async c=>updateResource({...c['params'],'patch':c['body'],'user':user(c)},z)),j['delete']('/api/resource/:resource/:id',{'schema':{'tags':['fcore',b(0xcb)],'summary':b(0xd5),'description':b(0xd6),'access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async c=>deleteResource({...c['params'],'user':user(c)},z)),j['post']('/api/resource/:resource/:id/upload',{'schema':{'tags':['fcore',b(0xcb)],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':[],'params':resourceSchemas[b(0xd7)]}},async c=>{const n=b,p=await c['file']();if(!p)throw new Error('File\x20is\x20required');const M=c[n(0xd1)][n(0xcb)],H=c['params']['id'];if(c[n(0xc7)]?.[n(0xd8)]!==n(0xd9)&&!c['user']?.[n(0xda)][n(0xdb)](M+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+M+n(0xdc));return uploadFile({'file':p,'metadata':{'name':p['filename'],'path':p[n(0xdd)]['path']?.['value'],'resource':M,'resourceId':H},'user':c[n(0xc7)]},z);}),j[b(0xca)](b(0xde),{'schema':{'tags':['fcore','resource'],'summary':b(0xdf),'description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':b(0xc7),'permissions':[],'schema':{'params':resourceSchemas['resourceIdRelation']}}},async c=>listResourceRelation({...c['query'],...c['params'],'user':user(c)},z)),j['post'](b(0xde),{'schema':{'tags':['fcore','resource'],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':b(0xc7),'permissions':[],'params':resourceSchemas['resourceIdRelation']}},async c=>createResourceRelation({...c['params'],'data':c['body'],'user':user(c)},z)),j['delete']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore',b(0xcb)],'summary':b(0xe0),'description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas['resourceIdRelationId']}},async c=>deleteResourceRelation({...c[b(0xd1)],'user':user(c)},z)),j['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':b(0xe1),'description':b(0xe2),'access':'user','permissions':[],'params':resourceSchemas[b(0xe3)]}},async c=>updateResourceRelation({...c[b(0xd1)],'data':c[b(0xe4)],'user':user(c)},z));};}function U(){const v=['user','/api/resource/:resource/search','Searches\x20records\x20in\x20a\x20registered\x20resource.','get','resource','resourceField','fcore','query','post','Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','params','Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','/api/resource/:resource/:id','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','Delete\x20resource\x20record','Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','uploadResourceFile','type','admin','permissions','includes',':update','fields','/api/resource/:resource/:id/:relation','List\x20resource\x20relations','Delete\x20resource\x20relation','Update\x20resource\x20relation','Updates\x20a\x20related\x20resource\x20record.','resourceIdRelationId','body'];U=function(){return v;};return U();}
|
|
1
|
+
import{listResources}from'./services/list-resources.js';import{listResourceAsUser}from'./services/list-resource-as-user.js';import{getResource}from'./services/get-resource.js';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 C(P,G){P=P-0x77;const j=m();let Z=j[P];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{listResourceList}from'./services/list-resource-list.js';function m(){const z=['get','fcore','Searches\x20records\x20in\x20a\x20registered\x20resource.','$resource:read','params','user','config','auth','Get\x20resource\x20schema','Returns\x20the\x20resource\x20variables\x20and\x20nested\x20relation\x20schema.','/api/resource/:resource/code','Generate\x20a\x20resource\x20code','query','/api/resource/:resource/scope/:user','Returns\x20resource\x20records\x20using\x20the\x20specified\x20user\x27s\x20permissions\x20and\x20access\x20scopes.\x20Admin\x20only.','system:access','/api/resource/:resource','$resource:create','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','resourceId','post','/api/resource/:resource/:id/upload','resource','$resource:update','value','/api/resource/:resource/:id/file/:fid','Delete\x20resource\x20file','Deletes\x20a\x20file\x20linked\x20to\x20a\x20resource\x20record\x20after\x20validating\x20it\x20belongs\x20to\x20this\x20resource\x20and\x20record.','File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record','rows','file_path','file','/api/resource/:resource/list','List\x20resource\x20items','Returns\x20resource\x20identifiers\x20and\x20display\x20text,\x20optionally\x20filtered\x20by\x20searchable\x20fields.','List\x20resource\x20relations','/api/resource/:resource/:id/:relation','body'];m=function(){return z;};return m();}import{getResourceSchema}from'./services/get-resource-schema.js';import{generateResourceCode}from'./services/generate-resource-code.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=P=>P['user'];export function resourceRoutes(P){return async G=>{const H=C;G[H(0x77)]('/api/resource/:resource/search',{'schema':{'tags':[H(0x78),'resource'],'summary':'Search\x20resource','description':H(0x79),'access':'user','permissions':[H(0x7a)],'params':resourceSchemas['resource']}},async j=>searchResource({...j['query'],...j[H(0x7b)],'user':user(j)||P['config']?.['auth']?.['user']},P)),G[H(0x77)]('/api/suggest/:resource/:field',{'schema':{'tags':['fcore','resource'],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':H(0x7c),'permissions':['$resource:read'],'params':resourceSchemas['resourceField'],'querystring':resourceSchemas['suggestQuery']}},async j=>suggestResource({...j['query'],...j['params'],'user':user(j)||P[H(0x7d)]?.[H(0x7e)]?.['user']},P)),G['get']('/api/resource/:resource/export',{'schema':{'tags':['fcore','resource'],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[H(0x7a)],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async j=>exportResource({...j['query'],...j[H(0x7b)],'user':user(j)||P['config']?.['auth']?.['user']},P)),G['get']('/api/resource/:resource/schema',{'schema':{'tags':['fcore','resource'],'summary':H(0x7f),'description':H(0x80),'access':'user','permissions':[H(0x7a)],'params':resourceSchemas['resource']}},async j=>getResourceSchema(j[H(0x7b)],P)),G['get'](H(0x81),{'schema':{'tags':['fcore','resource'],'summary':H(0x82),'description':'Generates\x20a\x20code\x20from\x20an\x20explicit\x20template\x20or\x20a\x20field\x20code_template.','access':'user','permissions':[H(0x7a)],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceCodeQuery']}},async j=>generateResourceCode({...j['params'],...j[H(0x83)]},P)),G['get'](H(0x84),{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20as\x20a\x20user\x20for\x20scope\x20testing','description':H(0x85),'access':'admin','permissions':[H(0x86)],'params':resourceSchemas['resourceScopeTarget']}},async j=>listResourceAsUser({...j['params'],...j[H(0x83)],'requester':user(j)},P)),G[H(0x77)](H(0x87),{'schema':{'tags':[H(0x78),'resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':H(0x7c),'permissions':[H(0x7a)],'params':resourceSchemas['resource']}},async j=>listResources({...j['query'],...j['params'],'user':user(j)||P[H(0x7d)]?.['auth']?.['user']},P)),G['post']('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':'Create\x20resource\x20record','description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':H(0x7c),'permissions':[H(0x88)],'params':resourceSchemas['resource']}},async j=>createResource({...j['params'],'data':j['body'],'user':user(j)||P['config']?.['auth']?.[H(0x7c)]},P)),G['get']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':H(0x7c),'permissions':[H(0x7a)],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async j=>getResource({...j[H(0x83)],...j[H(0x7b)],'user':user(j)||P['config']?.['auth']?.['user']},P)),G['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20record','description':H(0x89),'access':H(0x7c),'permissions':['$resource:update'],'params':resourceSchemas[H(0x8a)]}},async j=>updateResource({...j['params'],'patch':j['body'],'user':user(j)||P['config']?.['auth']?.['user']},P)),G['delete']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:delete'],'params':resourceSchemas['resourceId']}},async j=>deleteResource({...j['params'],'user':user(j)||P['config']?.[H(0x7e)]?.['user']},P)),G[H(0x8b)](H(0x8c),{'schema':{'tags':['fcore',H(0x8d)],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':[H(0x8e)],'params':resourceSchemas['uploadResourceFile']}},async j=>{const b=H,Z=await j['file']();if(!Z)throw new Error('File\x20is\x20required');const q=j['params'][b(0x8d)],p=j[b(0x7b)]['id'];return uploadFile({'file':Z,'metadata':{'name':Z['filename'],'path':Z['fields']['path']?.[b(0x8f)],'resource':q,'resourceId':p},'user':j[b(0x7c)]},P);}),G['delete'](H(0x90),{'schema':{'tags':['fcore','resource'],'summary':H(0x91),'description':H(0x92),'access':'user','permissions':['$resource:update'],'params':resourceSchemas['resourceIdFileId']}},async j=>{const E=H,{resource:Z,id:q,fid:p}=j[E(0x7b)],X=await P['pg'][E(0x83)]('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',[p,Z,String(q)]);if(!X['rowCount'])throw new Error(E(0x93));const F=X[E(0x94)][0x0]?.[E(0x95)],A=await P['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[p,Z,String(q)]);return await P[E(0x96)]['delete'](F),{'success':(A['rowCount']??0x0)>0x0,'resource':Z,'resourceId':q,'fileId':p};}),G[H(0x77)](H(0x97),{'schema':{'tags':['fcore',H(0x8d)],'summary':H(0x98),'description':H(0x99),'access':H(0x7c),'permissions':['$resource:read'],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceListQuery']}},async j=>listResourceList({...j['params'],...j[H(0x83)],'user':user(j)||P['config']?.[H(0x7e)]?.['user']},P)),G[H(0x77)]('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':H(0x9a),'description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':'user','params':resourceSchemas['resourceIdRelation'],'permissions':[H(0x7a)]}},async j=>listResourceRelation({...j['query'],...j[H(0x7b)],'user':user(j)||P[H(0x7d)]?.['auth']?.[H(0x7c)]},P)),G['post'](H(0x9b),{'schema':{'tags':['fcore',H(0x8d)],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':['$resource:create'],'params':resourceSchemas['resourceIdRelation']}},async j=>createResourceRelation({...j['params'],'data':j['body'],'user':user(j)||P['config']?.['auth']?.['user']},P)),G['delete']('/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':['$resource:delete'],'params':resourceSchemas['resourceIdRelationId']}},async j=>deleteResourceRelation({...j[H(0x7b)],'user':user(j)||P[H(0x7d)]?.['auth']?.['user']},P)),G['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[H(0x78),H(0x8d)],'summary':'Update\x20resource\x20relation','description':'Updates\x20a\x20related\x20resource\x20record.','access':H(0x7c),'permissions':['$resource:update'],'params':resourceSchemas['resourceIdRelationId']}},async j=>updateResourceRelation({...j['params'],'data':j[H(0x9c)],'user':user(j)||P[H(0x7d)]?.['auth']?.[H(0x7c)]},P));};}
|
|
@@ -20,6 +20,10 @@ export declare const resourceSchemas: {
|
|
|
20
20
|
resource: import("@sinclair/typebox").TObject<{
|
|
21
21
|
resource: import("@sinclair/typebox").TString;
|
|
22
22
|
}>;
|
|
23
|
+
resourceScopeTarget: import("@sinclair/typebox").TObject<{
|
|
24
|
+
resource: import("@sinclair/typebox").TString;
|
|
25
|
+
user: import("@sinclair/typebox").TString;
|
|
26
|
+
}>;
|
|
23
27
|
exportResource: import("@sinclair/typebox").TObject<{
|
|
24
28
|
resource: import("@sinclair/typebox").TString;
|
|
25
29
|
}>;
|
|
@@ -32,6 +36,15 @@ export declare const resourceSchemas: {
|
|
|
32
36
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
37
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
34
38
|
}>;
|
|
39
|
+
resourceListQuery: import("@sinclair/typebox").TObject<{
|
|
40
|
+
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
41
|
+
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
42
|
+
}>;
|
|
43
|
+
resourceCodeQuery: import("@sinclair/typebox").TObject<{
|
|
44
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
|
+
field: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
46
|
+
template: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
47
|
+
}>;
|
|
35
48
|
resourceId: import("@sinclair/typebox").TObject<{
|
|
36
49
|
resource: import("@sinclair/typebox").TString;
|
|
37
50
|
id: import("@sinclair/typebox").TString;
|
|
@@ -50,6 +63,11 @@ export declare const resourceSchemas: {
|
|
|
50
63
|
relation: import("@sinclair/typebox").TString;
|
|
51
64
|
relationId: import("@sinclair/typebox").TString;
|
|
52
65
|
}>;
|
|
66
|
+
resourceIdFileId: import("@sinclair/typebox").TObject<{
|
|
67
|
+
resource: import("@sinclair/typebox").TString;
|
|
68
|
+
id: import("@sinclair/typebox").TString;
|
|
69
|
+
fid: import("@sinclair/typebox").TString;
|
|
70
|
+
}>;
|
|
53
71
|
uploadResourceFile: import("@sinclair/typebox").TObject<{
|
|
54
72
|
resource: import("@sinclair/typebox").TString;
|
|
55
73
|
id: import("@sinclair/typebox").TString;
|
|
@@ -62,6 +80,7 @@ export declare const resourceSchemas: {
|
|
|
62
80
|
filter: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
63
81
|
sort: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
64
82
|
search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
83
|
+
scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
65
84
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
66
85
|
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
67
86
|
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,mBAAmB;;;;IACnB,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;IAKZ,iBAAiB;;;;IAIjB,iBAAiB;;;;;IAKjB,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,gBAAgB;;;;;IAKhB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;;CASpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const P=C;import{Type}from'@sinclair/typebox';function C(P,G){P=P-0x174;const j=m();let Z=j[P];return Z;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type['Object']({'resource':identifier}),'resourceScopeTarget':Type['Object']({'resource':identifier,'user':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type[P(0x174)](Type[P(0x175)]()),'search':Type[P(0x174)](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceListQuery':Type['Object']({'search':Type[P(0x174)](Type[P(0x175)]()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type['Object']({'id':Type[P(0x174)](Type[P(0x175)]({'minLength':0x1,'maxLength':0x80})),'field':Type['Optional'](identifier),'template':Type['Optional'](Type['String']({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type['Object']({'include':Type['Optional'](Type[P(0x175)]({'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[P(0x176)]({'file':Type[P(0x177)](),'fileName':Type[P(0x175)]({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type['Optional'](Type['Record'](Type[P(0x175)](),Type['Unknown']())),'sort':Type[P(0x174)](Type['Array'](Type[P(0x175)]({'minLength':0x1}))),'search':Type['Optional'](Type['String']()),'scope':Type[P(0x174)](Type['String']()),'limit':Type[P(0x174)](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type[P(0x174)](Type['Integer']({'minimum':0x0})),'fields':Type[P(0x174)](Type[P(0x178)](identifier))})};function m(){const G=['Optional','String','Object','Any','Array'];m=function(){return G;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const q=['body'];m=function(){return q;};return m();}function C(P,G){P=P-0x171;const j=m();let Z=j[P];return Z;}export async function addNote(P,G){const Z=C,j=await G['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[P['resource'],String(P['id']),P[Z(0x171)]]);return j['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const q=['query','rows'];m=function(){return q;};return m();}function C(P,G){P=P-0x183;const j=m();let Z=j[P];return Z;}export async function addResourceFile(P,G){const Z=C,j=await G['pg'][Z(0x183)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[P['resource'],String(P['id']),P['filePath'],P['size']??null]);return j[Z(0x184)][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function createResourceRelation(
|
|
1
|
+
function m(){const A=['createRelation'];m=function(){return A;};return m();}function C(P,G){P=P-0x17d;const j=m();let Z=j[P];return Z;}export async function createResourceRelation(P,G){const F=C,{resource:j,id:Z,relation:q,data:p,user:X}=P;return G['resource'][F(0x17d)]({'name':j,'id':Z,'relation':q,'data':p,'user':X});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(P,G){P=P-0x12f;var j=m();var Z=j[P];return Z;}export async function createResource(P,G){var j=C;return G[j(0x12f)][j(0x130)]({'name':P['resource'],'data':P['data'],'user':P[j(0x131)]});}function m(){var Z=['resource','create','user'];m=function(){return Z;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function deleteResourceRelation(P,G){const X=C,{resource:j,id:Z,relation:q,relationId:p}=P;return G[X(0x193)]['deleteRelation']({'name':j,'id':Z,'relation':q,'relationId':p});}function C(P,G){P=P-0x193;const j=m();let Z=j[P];return Z;}function m(){const F=['resource'];m=function(){return F;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){var Z=['resource','delete'];m=function(){return Z;};return m();}function C(P,G){P=P-0xff;var j=m();var Z=j[P];return Z;}export async function deleteResource(P,G){var j=C;return G[j(0xff)][j(0x100)]({'name':P[j(0xff)],'id':P['id'],'user':P['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function m(){const q=['user'];m=function(){return q;};return m();}function C(P,G){P=P-0x11f;const j=m();let Z=j[P];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(P,G){const Z=C,j=await G['resource']['find']({'name':P['resource'],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'limit':P['limit'],'offset':P['offset'],'fields':P['fields']},'user':P[Z(0x11f)]});return j['rows'];}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppContext } from "../../../context.js";
|
|
2
|
+
type CodeParams = {
|
|
3
|
+
resource: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
field?: string;
|
|
6
|
+
template?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function generateResourceCode(params: CodeParams, ctx: AppContext): Promise<{
|
|
9
|
+
resource: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
field?: string;
|
|
12
|
+
template: string | null;
|
|
13
|
+
code: string | null;
|
|
14
|
+
}>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=generate-resource-code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-resource-code.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/generate-resource-code.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AA2GF,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC,CAyED"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{qi,qt}from'../../../plugins/resource/utils/sql.js';function m(){const O=['column','foreignKey','key','\x20LIMIT\x201','length','where','push','\x20<>\x20$','\x20AND\x20','getFullYear','\x20t\x20','rows','SELECT\x20count(*)::int\x20+\x201\x20AS\x20num\x20FROM\x20','table','resource','field','name','num','mnum','getMonth','padStart','Cannot\x20resolve\x20code\x20template\x20variable:\x20{'];m=function(){return O;};return m();}function C(P,G){P=P-0xf8;const j=m();let Z=j[P];return Z;}function relationValue(P,G,j){const T=C,Z=G['fields'][j]?.[T(0xf8)]??j;return P[Z]??P[j];}async function resolvePath(P,G,j,Z){const D=C,[q,...p]=P['split']('.');if(!q)return undefined;const X=j['relations']?.[q];if(!X||!p['length']||!X['resource'])return relationValue(G,j,P);const F=Z['resource']['get'](X['resource']),A=F['key'];let H,b;if(X['localKey'])H=relationValue(G,j,X['localKey']),b=A;else{if(X[D(0xf9)])H=relationValue(G,j,j[D(0xfa)]),b=X[D(0xf9)];else return undefined;}if(H===null||H===undefined)return undefined;const E=F['fields'][b]?.['column']??b,z=await Z['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(F['table'])+'\x20t\x20WHERE\x20t.'+qi(E)+'\x20=\x20$1'+(X['where']?'\x20AND\x20('+X['where']+')':'')+D(0xfb),[H]),x=z['rows'][0x0];if(!x)return undefined;const o=p[0x0];if(!o)return undefined;if(p[D(0xfc)]===0x1)return relationValue(x,F,o);return resolvePath(p['join']('.'),x,F,Z);}async function countValues(P,G,j,Z){const h=C,q=[],p=P['where']?['('+P[h(0xfd)]+')']:[];G!==undefined&&(q[h(0xfe)](G),p['push']('t.'+qi(P['key'])+h(0xff)+q['length']));const X=p['length']?'WHERE\x20'+p['join'](h(0x100)):'',F=P['fields']['created_at'],A=F?'t.'+qi(F[h(0xf8)]??'created_at'):undefined,H=new Date(Z['getFullYear'](),0x0,0x1),b=new Date(Z[h(0x101)](),Z['getMonth'](),0x1);if(A){q[h(0xfe)](H,b);const x='$'+(q['length']-0x1),o='$'+q[h(0xfc)],i=await j['pg']['query']('SELECT\x20count(*)::int\x20+\x201\x20AS\x20num,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+A+'\x20>=\x20'+x+')::int\x20+\x201\x20AS\x20ynum,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20count(*)\x20FILTER\x20(WHERE\x20'+A+'\x20>=\x20'+o+')::int\x20+\x201\x20AS\x20mnum\x0a\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(P['table'])+h(0x102)+X,q),y=i[h(0x103)][0x0];return{'num':Number(y?.['num']??0x1),'ynum':Number(y?.['ynum']??0x1),'mnum':Number(y?.['mnum']??0x1)};}const E=await j['pg']['query'](h(0x104)+qt(P[h(0x105)])+'\x20t\x20'+X,q),z=Number(E[h(0x103)][0x0]?.['num']??0x1);return{'num':z,'ynum':z,'mnum':z};}export async function generateResourceCode(P,G){const L=C,j=G['resource']['get'](P[L(0x106)]);if(P['field']&&!j['fields'][P['field']])throw new ValidationError('Unknown\x20resource\x20field:\x20'+P[L(0x107)]);const Z=P['template']??(P['field']?j['fields'][P['field']]?.['code_template']:undefined);if(!Z)return{'resource':j[L(0x108)],...P['id']!==undefined?{'id':P['id']}:{},...P['field']?{'field':P['field']}:{},'template':null,'code':null};const q=new Date(),p=await countValues(j,P['id'],G,q);let X={};if(P['id']!==undefined){const b=await G['pg']['query']('SELECT\x20*\x20FROM\x20'+qt(j['table'])+'\x20t\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20t.'+qi(j['key'])+'\x20=\x20$1'+(j['where']?'\x20AND\x20('+j[L(0xfd)]+')':'')+'\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201',[P['id']]);X=b['rows'][0x0]??{};}const F=[...Z['matchAll'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g)],A=new Map();for(const E of F){const z=E[0x1];if(!z||A['has'](E[0x0]))continue;const x=Number(E[0x2]??0x0);let o;switch(z){case'num':o=p[L(0x109)];break;case'ynum':o=p['ynum'];break;case'mnum':o=p[L(0x10a)];break;case'yyyy':o=String(q[L(0x101)]());break;case'yy':o=String(q['getFullYear']())['slice'](-0x2);break;case'mm':o=String(q[L(0x10b)]()+0x1)[L(0x10c)](0x2,'0');break;case'dd':o=String(q['getDate']())[L(0x10c)](0x2,'0');break;case'resource':o=j['name'];break;case'resource_id':o=P['id'];break;default:o=P['id']===undefined?undefined:await resolvePath(z,X,j,G);}if(o===null||o===undefined||o==='')throw new ValidationError(L(0x10d)+z+'}');const i=String(o);A['set'](E[0x0],x&&/^\d+$/['test'](i)?i['padStart'](x,'0'):i);}const H=Z['replace'](/\{([A-Za-z_][A-Za-z0-9_.]*)(?::(\d+))?\}/g,y=>A['get'](y)??y);return{'resource':j[L(0x108)],...P['id']!==undefined?{'id':P['id']}:{},...P[L(0x107)]?{'field':P['field']}:{},'template':Z,'code':H};}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AppContext } from "../../../context.js";
|
|
2
|
+
import type { ResourceSchemaDto } from "../../../plugins/resource/resource.types.js";
|
|
3
|
+
export declare function getResourceSchema(params: {
|
|
4
|
+
resource: string;
|
|
5
|
+
}, ctx: AppContext): ResourceSchemaDto;
|
|
6
|
+
//# sourceMappingURL=get-resource-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-resource-schema.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/get-resource-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAEV,iBAAiB,EAElB,MAAM,6CAA6C,CAAC;AAyDrD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC5B,GAAG,EAAE,UAAU,GACd,iBAAiB,CAOnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function variableType(P){const o=C;switch(P){case o(0xc1):case o(0xc2):return'number';case o(0xc3):return'boolean';case o(0xc4):case'geometry':case'geom':return'object';default:return'string';}}function C(P,G){P=P-0xc1;const j=m();let Z=j[P];return Z;}function buildVariables(P,G,j='',Z=new Set()){const i=C,q=new Set(Z)['add'](P['name']),p=[];for(const [X,F]of Object[i(0xc5)](P['fields'])){if(F['read']===![]||F[i(0xc6)]===![])continue;p['push']({'key':X,'path':j?j+'.'+X:X,'type':variableType(F['type'])});}for(const [A,H]of Object[i(0xc5)](P[i(0xc7)]??{})){if(!H['resource']||!G['resource'][i(0xc8)](H['resource']))continue;const b=G['resource']['get'](H[i(0xc9)]),E=j?j+'.'+A:A,z=H['type']===i(0xca),x={'key':A,'path':E,'type':z?'array':'object','resource':H[i(0xc9)],'variables':q['has'](b['name'])?[]:buildVariables(b,G,E,q)};p[i(0xcb)](x);}return p;}export function getResourceSchema(P,G){const y=C,j=G['resource']['get'](P[y(0xc9)]);return{'resource':j['name'],...j['title']?{'title':j['title']}:{},'variables':buildVariables(j,G)};}function m(){const T=['number','integer','boolean','json','entries','readable','relations','has','resource','many','push'];m=function(){return T;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getResource(
|
|
1
|
+
export async function getResource(P,G){return G['resource']['findOne']({'name':P['resource'],'id':P['id'],'query':{'include':P['include']},'user':P['user']});}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
export declare function listResourceAsUser(params: {
|
|
3
|
+
resource: string;
|
|
4
|
+
user: string;
|
|
5
|
+
requester?: User;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}, ctx: AppContext): Promise<unknown>;
|
|
8
|
+
//# sourceMappingURL=list-resource-as-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-resource-as-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resource-as-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAM5D,wBAAsB,kBAAkB,CACtC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,OAAO,CAAC,CAyClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(){const A=['query','user','uid','all','limit','offset'];m=function(){return A;};return m();}import{ForbiddenError,NotFoundError}from'../../../errors.js';import{getUserPermissions}from'../../../plugins/auth/get-user-permissions.js';import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';import{getUserResourceScopes}from'../../../plugins/resource/utils/scope.js';function C(P,G){P=P-0x1e2;const j=m();let Z=j[P];return Z;}export async function listResourceAsUser(P,G){const F=C;if(P['requester']?.['type']!=='admin')throw new ForbiddenError('Only\x20admins\x20can\x20test\x20resource\x20scopes\x20for\x20another\x20user');const j=await G['pg'][F(0x1e2)]('SELECT\x20uid,\x20user_type\x20AS\x20type\x20FROM\x20admin.users\x20WHERE\x20uid\x20=\x20$1\x20OR\x20login\x20=\x20$1\x20LIMIT\x201',[P['user']]),Z=j['rows'][0x0];if(!Z)throw new NotFoundError('User\x20not\x20found:\x20'+P[F(0x1e3)]);const q={'id':Z['uid'],'type':Z['type'],'permissions':await getUserPermissions(Z[F(0x1e4)],G)},[p,X]=await Promise[F(0x1e5)]([G['resource']['find']({'name':P['resource'],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'include':P['include'],'scope':P['scope'],'limit':P[F(0x1e6)],'offset':P[F(0x1e7)]??(P['page']?Math['max'](Number(P['page'])-0x1,0x0):0x0)*Number(P[F(0x1e6)]??0x14)},'user':q}),getUserResourceScopes(q['id'],P['resource'],G['pg'])]);return{...p,'scopes':X};}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AppContext } from "../../../context.js";
|
|
2
|
+
import type { ResourceUser } from "../../../plugins/resource/resource.types.js";
|
|
3
|
+
type ResourceListItem = {
|
|
4
|
+
id: unknown;
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function listResourceList(params: {
|
|
8
|
+
resource: string;
|
|
9
|
+
search?: string;
|
|
10
|
+
limit?: number;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}, ctx: AppContext): Promise<{
|
|
13
|
+
search: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
count: number;
|
|
16
|
+
time: number;
|
|
17
|
+
data: ResourceListItem[];
|
|
18
|
+
}>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=list-resource-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-resource-list.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resource-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,OAAO,KAAK,EAAoB,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAElG,KAAK,gBAAgB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAkDtD,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,EAAE,CAAC;CAC1B,CAAC,CA2CD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../../../plugins/resource/utils/permissions.js';function C(P,G){P=P-0x104;const j=m();let Z=j[P];return Z;}import{quoteIdentifier,quoteTable}from'../../../plugins/resource/utils/sql.js';function m(){const D=['fields','join','display','name','map','matchAll','Invalid\x20display\x20template\x20for\x20resource:\x20','push','::text,\x20\x27\x27)','length','concat(','resource','get','read','max','searchable','where','WHERE\x20','key','table'];m=function(){return D;};return m();}function columnExpression(P,G){const i=C;if(G!==P['key']&&!P['fields'][G])throw new ValidationError('Unknown\x20display/search\x20field:\x20'+G);const j=P[i(0x104)][G]?.['column']??G;return j['split']('.')['map'](Z=>quoteIdentifier(Z))[i(0x105)]('.');}function displayExpression(P){const y=C,G=P[y(0x106)];if(!G||Array['isArray'](G)&&G['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20display\x20fields:\x20'+P[y(0x107)]);if(Array['isArray'](G))return'concat_ws(\x27\x20\x27,\x20'+G[y(0x108)](p=>'COALESCE('+columnExpression(P,p)+'::text,\x20\x27\x27)')['join'](',\x20')+')';const j=[],Z=/\{([^{}]+)\}/g;let q=0x0;for(const p of G[y(0x109)](Z)){const X=p['index']??0x0,F=p[0x1];if(!F)throw new ValidationError(y(0x10a)+P['name']);X>q&&j['push']('\x27'+G['slice'](q,X)['replace'](/'/g,'\x27\x27')+'\x27'),j[y(0x10b)]('COALESCE('+columnExpression(P,F)+y(0x10c)),q=X+p[0x0][y(0x10d)];}q<G['length']&&j['push']('\x27'+G['slice'](q)['replace'](/'/g,'\x27\x27')+'\x27');if(j[y(0x10d)]===0x0)throw new ValidationError(y(0x10a)+P[y(0x107)]);return y(0x10e)+j['join'](',\x20')+')';}export async function listResourceList(P,G){const T=C,j=Date['now'](),Z=G[T(0x10f)][T(0x110)](P[T(0x10f)]);assertOperation(Z,T(0x111),P['user']);const q=P['search']??'',p=Math['min'](Math[T(0x112)](Number(P['limit']??0x14),0x1),0xc8),X=Z[T(0x113)]??Object['entries'](Z[T(0x104)])['filter'](([,x])=>x[T(0x113)])['map'](([x])=>x);if(q&&X['length']===0x0)throw new ValidationError('Resource\x20has\x20no\x20searchable\x20fields:\x20'+Z['name']);const F=displayExpression(Z),A=[],H=[];if(Z[T(0x114)])A[T(0x10b)]('('+Z['where']+')');if(q){const x=X['map'](o=>columnExpression(Z,o)+'::text\x20ILIKE\x20$1');A[T(0x10b)]('('+x['join']('\x20OR\x20')+')'),H[T(0x10b)]('%'+q+'%');}H['push'](p);const b=A[T(0x10d)]?T(0x115)+A['join']('\x20AND\x20'):'',E=Z['joins']?.[T(0x108)](o=>o['sql'])['join']('\x20')??'',z=await G['pg']['query']('SELECT\x20'+quoteIdentifier(Z[T(0x116)])+'\x20AS\x20id,\x20'+F+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20FROM\x20'+quoteTable(Z[T(0x117)])+'\x20t\x20'+E+'\x0a\x20\x20\x20\x20\x20'+b+'\x0a\x20\x20\x20\x20\x20LIMIT\x20$'+H[T(0x10d)],H);return{'search':q,'limit':p,'count':z['rows']['length'],'time':Date['now']()-j,'data':z['rows']};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function listResourceRelation(P,G){const F=C,{resource:j,id:Z,relation:q,query:p,user:X}=P;return G['resource'][F(0x11e)]({'name':j,'id':Z,'relation':q,'query':p,'user':X});}function C(P,G){P=P-0x11e;const j=m();let Z=j[P];return Z;}function m(){const A=['findRelation'];m=function(){return A;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"list-resources.d.ts","sourceRoot":"","sources":["../../../../src/modules/resource/services/list-resources.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,wBAAsB,aAAa,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAgB9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function C(P,G){P=P-0x135;const j=m();let Z=j[P];return Z;}export async function listResources(P,G){const Z=C,j=P['user'];return G[Z(0x135)]['find']({'name':P[Z(0x135)],'query':{'filter':parseFilterQuery(P),'sort':P['sort'],'search':P['search'],'include':P['include'],'scope':P['scope'],'limit':P['limit'],'offset':P['offset']??(P['page']?Math[Z(0x136)](P[Z(0x137)]-0x1,0x0):0x0)*(P['limit']??0x14)},'user':j});}function m(){const q=['resource','max','page'];m=function(){return q;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){var Z=['user'];m=function(){return Z;};return m();}function C(P,G){P=P-0xed;var j=m();var Z=j[P];return Z;}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function searchResource(P,G){var j=C;return G['resource']['find']({'name':P['resource'],'query':{...P,'filter':parseFilterQuery(P)},'user':P[j(0xed)]});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function m(){const y=['resource','min','fields','lookup','name','value','text','query','SELECT\x20','\x20as\x20text\x20FROM\x20',')\x20~\x20$1\x20LIMIT\x20$2','length','now'];m=function(){return y;};return m();}function C(P,G){P=P-0x10c;const j=m();let Z=j[P];return Z;}export async function suggestResource(P,G){const i=C,j=G[i(0x10c)]['get'](P['resource']),Z=String(P['search']??P['q']??'')['toLowerCase'](),q=Math[i(0x10d)](Math['max'](Number(P['limit']??0x14),0x1),0xc8),p=Date['now'](),X=j[i(0x10e)][P['field']],F=X?.['dictionary'],A=X?.['lookup']?.['table'];if(A){const E=X[i(0x10f)]?.['text']??i(0x110),z=X['lookup']?.[i(0x111)]??'id';autoIndex(A,E,i(0x112),G['pg']);const x=await G['pg'][i(0x113)](i(0x114)+z+'\x20as\x20id,\x20'+E+i(0x115)+A+'\x20WHERE\x20lower('+E+i(0x116),[''+Z['toLowerCase'](),q])['then'](o=>o['rows']);return{'limit':q,'count':x[i(0x117)],'search':Z,'time':Date[i(0x118)]()-p,'data':x};}if(!F)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+P['field']);const H=await G['dictionary']['get'](F),b=H['filter'](o=>!Z||o['code']['startsWith'](Z)||o['name']['startsWith'](Z))['slice'](0x0,q)['map'](o=>({'id':o['code']||o['id'],'text':o[i(0x110)]||o['text']}));return{'search':Z,'limit':q,'count':b[i(0x117)],'time':Date['now']()-p,'data':b};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(P,G){P=P-0x184;const j=m();let Z=j[P];return Z;}function m(){const H=['resource','updateRelation'];m=function(){return H;};return m();}export async function updateResourceRelation(P,G){const A=C,{resource:j,id:Z,relation:q,relationId:p,data:X,user:F}=P;return G[A(0x184)][A(0x185)]({'name':j,'id':Z,'relation':q,'relationId':p,'data':X,'user':F});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){var Z=['resource'];m=function(){return Z;};return m();}function C(P,G){P=P-0x8c;var j=m();var Z=j[P];return Z;}export async function updateResource(P,G){var j=C;return G['resource']['update']({'name':P[j(0x8c)],'id':P['id'],'data':P['patch'],'user':P['user']});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(P,G){const X=C,j=G['resource']['get'](P['resource']);if(j['access']==='admin'&&P['user']?.[X(0xe9)]!==X(0xea))throw new ForbiddenError(X(0xeb));if(P['user']?.['type']!==X(0xea)&&!P['user']?.[X(0xec)]?.['includes']((j['permission']??j['name'])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(j[X(0xed)]??j['name'])+X(0xee));if(!Buffer['isBuffer'](P[X(0xef)])||P['file'][X(0xf0)]===0x0)throw new ValidationError('File\x20is\x20required');const Z=P[X(0xf1)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!Z)throw new ValidationError('File\x20name\x20is\x20required');const q='files/'+P['resource']+'/'+String(P['id'])+'/'+Z;await G['file']['put'](q,P[X(0xef)]);if(!await G['file'][X(0xf2)](q))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const p=await G['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20',[P[X(0xf3)],String(P['id']),q,P[X(0xef)][X(0xf0)]]);return p[X(0xf4)][0x0];}function C(P,G){P=P-0xe9;const j=m();let Z=j[P];return Z;}function m(){const F=['type','admin','Admin\x20access\x20required','permissions','permission',':update','file','length','fileName','exists','resource','rows'];m=function(){return F;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/system/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/system/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAiBnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C,wBAAgB,YAAY,CAC1B,GAAG,EAAE,UAAU,EACf,SAAS,GAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAa,GACnD,kBAAkB,CAsOpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const A=C;import{getSystemSettings}from'./services/get-system-settings.js';import{updateSystemSettings}from'./services/update-system-settings.js';import{getAuditLog}from'./services/get-audit-log.js';import{checkSystem}from'./services/check-system.js';function m(){const b=['user','get','/api/dictionary/:name','fcore','system','system:dictionaries','params','Update\x20platform\x20dictionary','Replaces\x20the\x20items\x20of\x20a\x20registered\x20platform\x20dictionary.','dictionaryItems','Returns\x20user-specific\x20and\x20role-level\x20scopes\x20for\x20a\x20resource.','system:access','resourceScope','Set\x20resource\x20access\x20scopes','admin','body','Get\x20user\x20access\x20for\x20a\x20resource','accessResourceParams','resourceAccess','Returns\x20direct\x20and\x20role-based\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','post','Get\x20system\x20settings','Returns\x20system\x20settings\x20as\x20nested\x20JSON.','settings','Returns\x20system\x20logger\x20entries\x20for\x20the\x20requested\x20path.','system:logs','Returns\x20the\x20system\x20audit\x20log\x20entries.','system:audit','query','Check\x20system\x20health'];m=function(){return b;};return m();}import{getApiList}from'./services/get-api-list.js';import{getSystemLog}from'./services/get-system-log.js';function C(P,G){P=P-0x81;const j=m();let Z=j[P];return Z;}import{getDictionary}from'./services/get-dictionary.js';import{updateDictionary}from'./services/update-dictionary.js';import{getAccess}from'./services/get-access.js';import{getResourceAccess}from'./services/get-resource-access.js';import{setAccess}from'./services/set-access.js';import{setResourceAccess}from'./services/set-resource-access.js';import{getResourceScopes}from'./services/get-resource-scopes.js';import{setResourceScopes}from'./services/set-resource-scopes.js';import{systemSchemas}from'./schema.js';const u=P=>P[A(0x81)];export function systemRoutes(P,G=new Map()){return async j=>{const H=C;j[H(0x82)](H(0x83),{'schema':{'tags':[H(0x84),H(0x85)],'summary':'Get\x20platform\x20dictionary','description':'Returns\x20a\x20registered\x20platform\x20dictionary\x20by\x20name.','access':'user','permissions':[H(0x86)],'params':systemSchemas['dictionaryName']}},async q=>({'items':await getDictionary({...q[H(0x87)],'user':u(q)},P)})),j['post'](H(0x83),{'schema':{'tags':['fcore','system'],'summary':H(0x88),'description':H(0x89),'access':'user','permissions':[H(0x86)],'params':systemSchemas['dictionaryName'],'body':systemSchemas[H(0x8a)]}},async q=>updateDictionary({...q['params'],...q['body'],'user':u(q)},P));const Z=async q=>getAccess({...q[H(0x87)],'user':u(q)},P);j[H(0x82)]('/api/access/scope/:resource',{'schema':{'tags':['fcore','system'],'summary':'Get\x20resource\x20access\x20scopes','description':H(0x8b),'access':'admin','permissions':[H(0x8c)],'params':systemSchemas[H(0x8d)]}},async q=>getResourceScopes(q[H(0x87)],P)),j['post']('/api/access/scope/:resource',{'schema':{'tags':[H(0x84),H(0x85)],'summary':H(0x8e),'description':'Replaces\x20scopes\x20for\x20a\x20role,\x20optionally\x20for\x20a\x20specific\x20user.','access':H(0x8f),'permissions':['system:access'],'params':systemSchemas['resourceScope'],'body':systemSchemas['resourceScopeBody']}},async q=>setResourceScopes({...q['params'],...q[H(0x90)],'user':u(q)},P)),j['get']('/api/access/resource/:resource',{'schema':{'tags':['fcore',H(0x85)],'summary':H(0x91),'description':'Returns\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':['system:access'],'params':systemSchemas['accessResourceParams']}},async q=>getResourceAccess(q['params'],P)),j['post']('/api/access/resource/:resource',{'schema':{'tags':[H(0x84),'system'],'summary':'Set\x20user\x20access\x20for\x20a\x20resource','description':'Replaces\x20direct\x20user\x20access\x20rules\x20for\x20the\x20specified\x20resource.','access':'admin','permissions':[H(0x8c)],'params':systemSchemas[H(0x92)],'body':systemSchemas[H(0x93)]}},async q=>setResourceAccess({...q['params'],...q[H(0x90)],'user':u(q)},P)),j['get']('/api/access/:type/:id',{'schema':{'tags':[H(0x84),'system'],'summary':'Get\x20access\x20rules','description':H(0x94),'access':H(0x8f),'permissions':[H(0x8c)],'params':systemSchemas['accessTarget']}},Z),j[H(0x95)]('/api/access/:type/:id',{'schema':{'tags':['fcore','system'],'summary':'Set\x20access\x20rules','description':'Replaces\x20direct\x20access\x20rules\x20for\x20a\x20user\x20or\x20role.','access':'admin','permissions':[H(0x8c)],'params':systemSchemas['accessTarget'],'body':systemSchemas['access']}},async q=>setAccess({...q['params'],...q['body'],'user':u(q)},P)),j['get']('/api/system/settings',{'schema':{'tags':['fcore','system'],'summary':H(0x96),'description':H(0x97),'access':'admin','permissions':['system:settings']}},async q=>getSystemSettings({...q[H(0x87)],'user':u(q)},P)),j['post']('/api/system/settings',{'schema':{'tags':['fcore',H(0x85)],'summary':'Update\x20system\x20settings','description':'Updates\x20system\x20settings\x20using\x20flat\x20dot-notation\x20keys.','access':'admin','permissions':['system:settings'],'body':systemSchemas[H(0x98)]}},async q=>updateSystemSettings({...q['params'],'patch':q['body'],'user':u(q)},P)),j['get']('/api/system/logger',{'schema':{'tags':['fcore',H(0x85)],'summary':'Get\x20system\x20log','description':H(0x99),'access':'user','permissions':[H(0x9a)],'querystring':systemSchemas['logger']}},async(q,p)=>{const {contentType:X,body:F}=await getSystemLog({...q['query'],'user':u(q)},P);return p['type'](X)['send'](F);}),j['get']('/api/system/audit',{'schema':{'tags':['fcore','system'],'summary':'Get\x20audit\x20log','description':H(0x9b),'access':'user','permissions':[H(0x9c)]}},async q=>getAuditLog({...q[H(0x9d)],'user':u(q)},P)),j['get']('/api/system/check',{'schema':{'tags':['fcore','system'],'summary':H(0x9e),'description':'Checks\x20the\x20availability\x20of\x20system\x20dependencies.','access':'user','permissions':['system:check']}},async q=>checkSystem({'user':u(q)},P)),j['get']('/api/system/list',{'schema':{'tags':['fcore','system'],'summary':'List\x20APIs','description':'Returns\x20the\x20list\x20of\x20registered\x20platform\x20APIs.','access':H(0x8f),'permissions':[],'querystring':systemSchemas['apiListQuery']}},async q=>getApiList({'user':u(q),'apiRoutes':G,...q[H(0x9d)]},P));};}
|
|
@@ -15,11 +15,34 @@ export declare const systemSchemas: {
|
|
|
15
15
|
type: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"user">, import("@sinclair/typebox").TLiteral<"role">]>;
|
|
16
16
|
id: import("@sinclair/typebox").TString;
|
|
17
17
|
}>;
|
|
18
|
+
accessResourceParams: import("@sinclair/typebox").TObject<{
|
|
19
|
+
resource: import("@sinclair/typebox").TString;
|
|
20
|
+
}>;
|
|
21
|
+
resourceScope: import("@sinclair/typebox").TObject<{
|
|
22
|
+
resource: import("@sinclair/typebox").TString;
|
|
23
|
+
}>;
|
|
24
|
+
resourceScopeBody: import("@sinclair/typebox").TObject<{
|
|
25
|
+
user_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
26
|
+
role_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
27
|
+
scopes: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>, import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>>;
|
|
28
|
+
}>;
|
|
29
|
+
resourceAccess: import("@sinclair/typebox").TObject<{
|
|
30
|
+
users: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
31
|
+
uid: import("@sinclair/typebox").TString;
|
|
32
|
+
actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
33
|
+
}>>>;
|
|
34
|
+
roles: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
35
|
+
role_id: import("@sinclair/typebox").TString;
|
|
36
|
+
actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
37
|
+
}>>>;
|
|
38
|
+
}>;
|
|
18
39
|
access: import("@sinclair/typebox").TObject<{
|
|
19
|
-
|
|
40
|
+
roles: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
41
|
+
permissions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
42
|
+
access: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
20
43
|
resource: import("@sinclair/typebox").TString;
|
|
21
44
|
actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
22
|
-
}
|
|
45
|
+
}>>>;
|
|
23
46
|
}>;
|
|
24
47
|
apiListQuery: import("@sinclair/typebox").TObject<{
|
|
25
48
|
format: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"short">, import("@sinclair/typebox").TLiteral<"extended">]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/system/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,eAAO,MAAM,aAAa;IACxB,cAAc;;;IAGd,eAAe;;;;;;;;IAef,YAAY;;;;IAIZ,MAAM
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/system/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,qCAIrB,CAAC;AAEH,eAAO,MAAM,aAAa;IACxB,cAAc;;;IAGd,eAAe;;;;;;;;IAef,YAAY;;;;IAIZ,oBAAoB;;;IAGpB,aAAa;;;IAGb,iBAAiB;;;;;IAcjB,cAAc;;;;;;;;;;IAcd,MAAM;;;;;;;;IAcN,YAAY;;;IAGZ,cAAc;;;IACd,QAAQ;IACR,MAAM;;;CAKP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const P=C;import{Type}from'@sinclair/typebox';function C(P,G){P=P-0x149;const j=m();let Z=j[P];return Z;}export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const systemSchemas={'dictionaryName':Type['Object']({'name':identifier}),'dictionaryItems':Type[P(0x149)]({'items':Type[P(0x14a)](Type[P(0x149)]({'id':Type['Optional'](Type['Union']([Type[P(0x14b)](),Type['Number']()])),'code':Type['String']({'minLength':0x1}),'name':Type['String']({'minLength':0x1}),'parentId':Type['Optional'](Type['Union']([Type['String'](),Type[P(0x14c)](),Type[P(0x14d)]()]))},{'additionalProperties':!![]}))}),'accessTarget':Type['Object']({'type':Type['Union']([Type['Literal']('user'),Type['Literal']('role')]),'id':identifier}),'accessResourceParams':Type['Object']({'resource':identifier}),'resourceScope':Type['Object']({'resource':identifier}),'resourceScopeBody':Type[P(0x149)]({'user_id':Type['Optional'](identifier),'role_id':Type['Optional'](identifier),'scopes':Type['Record'](identifier,Type['Union']([Type['Array'](Type[P(0x14e)]()),Type['String'](),Type['Number'](),Type['Boolean'](),Type['Null']()]))}),'resourceAccess':Type[P(0x149)]({'users':Type['Optional'](Type['Array'](Type['Object']({'uid':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))}))),'roles':Type['Optional'](Type['Array'](Type[P(0x149)]({'role_id':identifier,'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}))})))},{'minProperties':0x1}),'access':Type['Object']({'roles':Type[P(0x14f)](Type['Array'](identifier)),'permissions':Type['Optional'](Type[P(0x14a)](Type[P(0x14b)]({'minLength':0x1,'maxLength':0x80,'pattern':P(0x150)}))),'access':Type['Optional'](Type['Array'](Type['Object']({'resource':Type['String']({'minLength':0x1,'maxLength':0x80}),'actions':Type['Array'](Type['String']({'minLength':0x1,'maxLength':0x80}),{'minItems':0x1})})))}),'apiListQuery':Type['Object']({'format':Type['Optional'](Type[P(0x151)]([Type[P(0x152)]('short'),Type[P(0x152)]('extended')]))}),'settingsEntity':Type[P(0x149)]({'entity':Type[P(0x14f)](identifier)}),'settings':Type['Record'](Type[P(0x14b)]({'minLength':0x1}),Type[P(0x14e)]()),'logger':Type['Object']({'path':Type[P(0x14f)](Type['String']({'maxLength':0x100,'pattern':'^[A-Za-z0-9_.\x5c-/]*$'}))})};function m(){const G=['Object','Array','String','Number','Null','Unknown','Optional','^[A-Za-z0-9_-]+(?::[A-Za-z0-9_-]+)?$','Union','Literal'];m=function(){return G;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function checkSystem(P,G){const q=C,[j,Z]=await Promise['allSettled']([G['pg']['query'](q(0x194)),G['redis']['ping']()]);return{'status':j['status']===q(0x195)&&Z['status']==='fulfilled'?'ok':q(0x196),'pg':j[q(0x197)],'redis':Z[q(0x197)]};}function C(P,G){P=P-0x194;const j=m();let Z=j[P];return Z;}function m(){const p=['SELECT\x201','fulfilled','degraded','status'];m=function(){return p;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"get-access.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACzD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwB1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getAccess(P,G){const X=C,j=P['type']==='user'?'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20ur.role_id\x20=\x20ra.role_id\x20AND\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20':'\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ra.resource,\x20ra.actions,\x20ra.role_id\x20AS\x20role\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ra.role_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20',Z=await G['pg']['query'](j,[P['id']]),q=[...new Set(Z['rows']['map'](p=>p[X(0xd1)])['filter'](p=>p!==null))];return{'access':Z['rows'],'resources':q};}function C(P,G){P=P-0xd1;const j=m();let Z=j[P];return Z;}function m(){const F=['resource'];m=function(){return F;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(P,G){P=P-0x1c1;const j=m();let Z=j[P];return Z;}export async function getApiList(P,G){const F=C,j=[...P[F(0x1c1)]['values']()]['sort']((Z,q)=>(Z[F(0x1c2)]+'\x20'+Z[F(0x1c3)])['localeCompare'](q['endpoint']+'\x20'+q['method']));if(P[F(0x1c4)]!=='short')return j;return j['map'](({method:Z,endpoint:q,access:p,permissions:X})=>Z+'\x20'+q);}function m(){const A=['apiRoutes','endpoint','method','format'];m=function(){return A;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-audit-log.d.ts","sourceRoot":"","sources":["../../../../src/modules/system/services/get-audit-log.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG5D,wBAAsB,WAAW,CAC/B,MAAM,EAAE;IACN,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EACD,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAmBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function getAuditLog(P,G){const p=C,j=Math[p(0x1df)](Math['max'](P['limit']??0x32,0x1),0xc8),Z=Math[p(0x1e0)]((P[p(0x1e1)]??0x1)-0x1,0x0)*j,q=await G['pg']['query']('SELECT\x0a\x20\x20\x20\x20\x20\x20l.*,\x0a\x20\x20\x20\x20\x20\x20case\x20when\x20u.first_name\x20is\x20not\x20null\x20then\x20coalesce(u.last_name,\x27\x27)||coalesce(\x27\x20\x27||u.first_name,\x27\x27)\x20else\x20coalesce(u.login,\x20u.email,\x27\x27)\x20end\x20as\x20user_id_text\x0a\x20\x20\x20\x20FROM\x20admin.audit_log\x20l\x0a\x20\x20\x20\x20JOIN\x20admin.users\x20u\x20ON\x20l.user_id=u.uid\x0a\x20\x20\x20\x20ORDER\x20BY\x20id\x20DESC\x20LIMIT\x20$1\x20OFFSET\x20$2',[j,Z]);return{'rows':q[p(0x1e2)],'page':P['page']??0x1,'limit':j};}function C(P,G){P=P-0x1df;const j=m();let Z=j[P];return Z;}function m(){const X=['min','max','page','rows'];m=function(){return X;};return m();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function getDictionary(
|
|
1
|
+
export async function getDictionary(P,G){return G['dictionary']['get'](P['name']);}
|