@opengis/fcore 0.0.1-beta.25 → 0.0.1-beta.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/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +2 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +13 -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 +22 -0
- 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.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.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 +1 -0
- 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/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +23 -4
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.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.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.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +5 -1
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -1
- package/dist/plugins/resource/utils/summary.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +2 -2
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import'dotenv/config';const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function required(h){const n=process.env[h];if(!n)throw new Error('Missing\x20environment\x20variable:\x20'+h);return n;}function Q(){const f=['./storage','split','true','map','parse','x5y30KBsEKCENT04tu6549Vxx3No1ztJ2q2K8r79S59420RaZ5','session_user_auth','0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','strict','auth'];Q=function(){return f;};return Q();}export function loadConfig(h={}){const G=k,n={'env':process.env.NODE_ENV??'development','debug':process.env.DEBUG==='true','port':Number(process.env.PORT??0xbb8),'maxFileSize':+(process.env.MAX_FILE_SIZE||0x200),'rateLimit':{'disabled':process.env.RATE_LIMIT==='false','max':+(process.env.RATE_LIMIT_MAX||0x64),'timeWindow':+(process.env.RATE_LIMIT_TIME_WINDOW||0xea60)},'storageType':(process.env.STORAGE_TYPE??'s3')['toLowerCase']()==='local'||!process.env.S3_ENDPOINT?'local':'s3','storagePath':process.env.STORAGE_PATH??G(0x19c),'redactionList':(process.env.REDACTION_LIST||'password')[G(0x19d)](','),'logger':{'level':process.env.LOG_LEVEL??'info','responses':process.env.LOG_RESPONSES===G(0x19e)?!![]:![],'responseCodes':process.env.LOG_RESPONSE_STATUS_CODES?process.env.LOG_RESPONSE_STATUS_CODES['split'](',')[G(0x19f)](B=>B-0x0):DEFAULT_LOG_RESPONSE_STATUS_CODES,'directory':process.env.LOG_DIRECTORY||process['cwd']()+'/log'},'pg':{'host':process.env.PG_HOST??'localhost','port':Number(process.env.PG_PORT??0x1538),'database':process.env.PG_DATABASE??'','user':process.env.PG_USER??'','password':process.env.PG_PASSWORD??''},'redis':{'host':process.env.REDIS_HOST??'','port':Number(process.env.REDIS_PORT??0x18eb),'password':process.env.REDIS_PASSWORD,'lazyConnect':!![],'db':process.env.REDIS_DB?Number(process.env.REDIS_DB):undefined},'s3':{'endpoint':process.env.S3_ENDPOINT,'region':process.env.S3_REGION??'us-east-1','bucket':process.env.S3_BUCKET??'','accessKey':process.env.S3_ACCESS_KEY,'secretKey':process.env.S3_SECRET_KEY,'folder':process.env.S3_FOLDER,'forcePathStyle':process.env.S3_FORCE_PATH_STYLE!=='false','tokenSecret':process.env.FILE_TOKEN_SECRET,'tokenTtl':Number(process.env.FILE_TOKEN_TTL??0xe10)},'auth':{'accessToken':process.env.AUTH_ACCESS_TOKEN||'Ch7QR4e73Jg0wx0xOjm','user':process.env.AUTH_USER?JSON[G(0x1a0)](process.env.AUTH_USER):undefined,'sessionTimeout':+(process.env.AUTH_SESSION_TIMEOUT||0x258),'secret':process.env.AUTH_SECRET??G(0x1a1),'cookieName':process.env.AUTH_COOKIE_NAME??G(0x1a2),'jwtSecret':process.env.AUTH_JWT_SECRET??G(0x1a3),'redirect':process.env.AUTH_REDIRECT??'/','twoFactorRedirect':process.env.AUTH_TWOFACTOR_REDIRECT??'/','cookieOptions':process.env.AUTH_COOKIE_OPTIONS_DOMAIN?{'domain':process.env.AUTH_COOKIE_OPTIONS_DOMAIN,'path':process.env.AUTH_COOKIE_OPTIONS_PATH||'/','httpOnly':Boolean(process.env.AUTH_COOKIE_OPTIONS_HTTP_ONLY||'true'),'secure':Boolean(process.env.AUTH_COOKIE_OPTIONS_SECURE||'true'),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&['lax',G(0x1a4),'none']['includes'](process.env.AUTH_COOKIE_OPTIONS_SAME_SITE)?process.env.AUTH_COOKIE_OPTIONS_SAME_SITE:Boolean(process.env.AUTH_COOKIE_OPTIONS_SAME_SITE||'true')}:{'path':'/','httpOnly':!![],'secure':![],'sameSite':!![]}}};return{...n,...h,'logger':{...n['logger'],...h['logger']},'pg':{...n['pg'],...h['pg']},'redis':{...n['redis'],...h['redis']},'s3':{...n['s3'],...h['s3']},'auth':{...n[G(0x1a5)],...h['auth']}};}function k(h,n){h=h-0x19c;const B=Q();let G=B[h];return G;}export{required as requireEnv};
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
let defaultContext;function k(h,n){h=h-0x1e9;const B=Q();let G=B[h];return G;}function Q(){const B=['Application\x20context\x20is\x20not\x20initialized'];Q=function(){return B;};return Q();}export function setContext(h){defaultContext=h;}export function getContext(){const n=k;if(!defaultContext)throw new Error(n(0x1e9));return defaultContext;}export function createContext(h){return{...h,async 'close'(){await Promise['allSettled']([h['redis']?.['close'](),h['pg']?.['end']()]),await h['logger']['close']();}};}
|
package/dist/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var f=k;export class FCoreError extends Error{[f(0x151)];['statusCode'];['details'];constructor(h,n,B=0x1f4,G){var j=f;super(n),this[j(0x151)]=h,this[j(0x152)]=B,this['details']=G,this[j(0x153)]=new.target.name;}}function Q(){var P=['code','statusCode','name','BAD_REQUEST_ERROR','FORBIDDEN','Not\x20found','Conflict','CONFLICT'];Q=function(){return P;};return Q();}export class BadRequestError extends FCoreError{constructor(h,n){var Z=f;super(Z(0x154),h,0x190,n);}}function k(h,n){h=h-0x151;var B=Q();var G=B[h];return G;}export class UnauthorizedError extends FCoreError{constructor(h='Authentication\x20required'){super('UNAUTHORIZED',h,0x191);}}export class ForbiddenError extends FCoreError{constructor(h='Access\x20denied'){var e=f;super(e(0x155),h,0x193);}}export class NotFoundError extends FCoreError{constructor(h=f(0x156)){super('NOT_FOUND',h,0x194);}}export class ConflictError extends FCoreError{constructor(h=f(0x157)){var b=f;super(b(0x158),h,0x199);}}export class ValidationError extends FCoreError{constructor(h,n){super('VALIDATION_ERROR',h,0x1a6,n);}}export class UnsupportedError extends FCoreError{constructor(h='Operation\x20is\x20not\x20configured'){super('UNSUPPORTED',h,0x1f5);}}
|
package/dist/fastify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import h from'fastify-plugin';import{FCoreError}from'./errors.js';function k(h,n){h=h-0x162;const B=Q();let G=B[h];return G;}import{authRoutes}from'./modules/auth/route.js';import{fileRoutes}from'./modules/file/route.js';import{resourceRoutes}from'./modules/resource/route.js';import{systemRoutes}from'./modules/system/route.js';import{createSessionStore}from'./plugins/auth/index.js';import{ForbiddenError}from'./errors.js';function Q(){const O=['reduce','onRoute','method','summary','description','url','win32','user','config','headers','authorization','startsWith','Bearer\x20','length','admin','$resource','maxFileSize','setErrorHandler','logger','message','details','error','code','send','auth','resource','register','application/x-www-form-urlencoded','buffer','disabled','@fastify/rate-limit','rateLimit','timeWindow','split','log'];Q=function(){return O;};return Q();}import{jwtVerifyToken}from'./plugins/jwt.js';function urlencodedContentParser(n,B,G){const z=k,f=decodeURIComponent(B['toString']())['split']('&')[z(0x162)]((j,Z)=>{const [e,b]=Z['split']('=');return{...j,[e]:b};},{});G(null,f);}export default function fcoreFastify(n,B){return h(async G=>{const t=k;G['decorate']('ctx',n);const {config:f}=n,j=new Map();G['addHook'](t(0x163),e=>{const m=t,b=e['schema'],P=Array['isArray'](e['method'])?e[m(0x164)]:[e[m(0x164)]];for(const u of P){if(u==='HEAD')continue;const X={'method':u,'endpoint':e['url'],'package':b?.['package']??'fcore','tags':b?.['tags']??[],'summary':b?.[m(0x165)]??'','description':b?.[m(0x166)]??'','access':b?.['access']??'public','permissions':b?.['permissions']??[]};j['set'](u+'\x20'+e['url'],X);}}),G['addHook']('preHandler',async e=>{const A=t;if(e['routeOptions']['url']==='*')return!![];const b=j['get'](e['method']+'\x20'+e['routeOptions'][A(0x167)]),P=!e['user']&&process['platform']===A(0x168)&&n['config']?.['auth']?.[A(0x169)]?n[A(0x16a)]?.['auth']?.['user']:null,u=e['raw'][A(0x16b)]?.[A(0x16c)],X=u?.[A(0x16d)](A(0x16e))?u['slice'](0x7):null,H=e[A(0x169)]??(X?await jwtVerifyToken(X):P);!e['user']&&X&&process.env.AUTH_JWT_SECRET&&(e[A(0x169)]=await jwtVerifyToken(X));if(!b?.['access'])throw new ForbiddenError('Route\x20access\x20not\x20defined');if(b['access']==='public')return!![];if(!H)throw new ForbiddenError('User\x20required');if(b['access']===A(0x169)&&!b['permissions']?.[A(0x16f)])return!![];if(H['type']==A(0x170))return!![];if(b['access']==='admin')throw new ForbiddenError('Admin\x20access\x20required');for(const i of b['permissions']){const p=i?.['replace'](A(0x171),e['params']['resource']??'');if(!H['permissions']?.['includes'](p))throw new ForbiddenError('Missing\x20permission:\x20'+p);}return!![];}),await createSessionStore(G,n),await G['register'](import('@fastify/multipart'),{'limits':{'fileSize':f[t(0x172)]*0x400*0x400}}),G[t(0x173)]((e,b,P)=>{const U=t;if(e instanceof FCoreError||e['code']==='FST_ERR_VALIDATION'||e['statusCode']<0x1f4)return e['statusCode']<0x1f4&&n[U(0x174)]['warn'](e),P['code'](e['statusCode'])['send']({'error':e['code'],'message':e[U(0x175)],'details':e[U(0x176)]});return n['logger'][U(0x177)](e),(f['debug']||process.env.NODE_ENV==='test'||process.env.VITEST)&&console[U(0x177)](e),P[U(0x178)](0x1f4)[U(0x179)]({'error':'INTERNAL_ERROR','message':'Internal\x20server\x20error'});});const Z=e=>!B||B['includes'](e);if(Z(t(0x17a)))await G['register'](authRoutes(n));if(Z(t(0x17b)))await G['register'](resourceRoutes(n));if(Z('file'))await G[t(0x17c)](fileRoutes(n));if(Z('system'))await G[t(0x17c)](systemRoutes(n,j));G['addContentTypeParser'](t(0x17d),{'parseAs':t(0x17e)},urlencodedContentParser),!f['rateLimit']?.[t(0x17f)]?G['register'](import(t(0x180)),{'max':f[t(0x181)]?.['max']||0x64,'timeWindow':f['rateLimit']?.[t(0x182)]||0xea60,'hook':'preHandler','global':!![],'keyGenerator':e=>(e['user']?.['id']||e['ip'])+'-'+e['raw'][t(0x167)][t(0x183)]('?')[0x0]}):console[t(0x184)]('⚠️\x20rate\x20limit\x20is\x20disabled');});}
|
package/dist/fcore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';
|
|
1
|
+
function k(h,n){h=h-0x156;const B=Q();let G=B[h];return G;}import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';function Q(){const X=['folder','tokenTtl','region','tokenSecret','dictionaries','length','register'];Q=function(){return X;};return Q();}import{createAudit,createDatabase,createDictionary,createFileLocal,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';export async function createFCore(h={}){const u=k,n=loadConfig(h['config']),B=createRedis(n['redis']),G=createLogger(),f=createDatabase(n['pg']),j=n['storageType']==='local'?createFileLocal({'storagePath':n['storagePath'],'folder':n['s3'][u(0x156)],'tokenSecret':n['s3']['tokenSecret'],'tokenTtl':n['s3'][u(0x157)]}):createFileS3({'endpoint':n['s3']['endpoint'],'region':n['s3'][u(0x158)],'bucket':n['s3']['bucket'],'accessKey':n['s3']['accessKey'],'secretKey':n['s3']['secretKey'],'folder':n['s3']['folder'],'forcePathStyle':n['s3']['forcePathStyle'],'tokenSecret':n['s3'][u(0x159)],'tokenTtl':n['s3'][u(0x157)]}),Z=createAudit({'pg':f,'logger':G}),e=createDictionary({'pg':f,'dictionaries':h[u(0x15a)]}),b=createResource({'pg':f,'logger':G,'audit':Z,'dictionary':e,'file':j});h['resources']?.[u(0x15b)]&&b[u(0x15c)](h['resources']);const P=createContext({'config':n,'logger':G,'redis':B,'pg':f,'file':j,'resource':b,'audit':Z,'dictionary':e});return setContext(P),P;}
|
package/dist/migrations/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function
|
|
2
|
+
const e=k;function Q(){const P=['../../migrations','--dir','includes','startsWith','slice','log','Using\x20migration\x20directory:','run','error','exitCode'];Q=function(){return P;};return Q();}import{runMigrations}from'./runner.js';function k(h,n){h=h-0x119;const B=Q();let G=B[h];return G;}import{loadConfig}from'../config.js';import h from'node:path';import{fileURLToPath}from'node:url';const packageMigrations=fileURLToPath(new URL(e(0x119),import.meta.url));function migrationDirectory(n){const b=e,B=n['indexOf'](b(0x11a));if(B>=0x0){const f=n[B+0x1];if(!f)throw new Error('--dir\x20requires\x20a\x20folder\x20path');return h['resolve'](f);}if(n[b(0x11b)]('--fcore'))return packageMigrations;const G=n['find'](j=>!j[b(0x11c)]('--'));return h['resolve'](G??'migrations');}try{const config=loadConfig(),dir=migrationDirectory(process['argv'][e(0x11d)](0x2));console['log']('Loaded\x20configuration:',{...config['pg'],'user':'****','password':'****'}),console[e(0x11e)](e(0x11f),dir,process['argv'][e(0x11d)](0x2));for(const r of await runMigrations({'database':config['pg'],'dir':dir}))console['log']((r['status']===e(0x120)?'OK\x20\x20':'SKIP')+'\x20'+r['file']);}catch(Z){console[e(0x121)](Z),process[e(0x122)]=0x1;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function Q(){const t=['resolve','migrations','empty\x20pg','query','rows','map','endsWith','has','readFile','join','connect','run','hostname'];Q=function(){return t;};return Q();}import h from'node:fs/promises';import n from'node:path';import{createDatabase}from'../plugins/pg.js';export async function runMigrations(B={}){const p=k,G=n[p(0x163)](B['dir']??p(0x164)),f=B['database']??databaseFromUrl(B['databaseUrl']??process.env.DATABASE_URL);if(!f)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const j=createDatabase(f);if(!j)throw new Error(p(0x165));const Z=[];try{await j[p(0x166)]('\x0a\x20\x20\x20\x20\x20\x20CREATE\x20TABLE\x20IF\x20NOT\x20EXISTS\x20schema_migrations\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20version\x20varchar(255)\x20PRIMARY\x20KEY,\x0a\x20\x20\x20\x20\x20\x20\x20\x20applied_at\x20timestamptz\x20NOT\x20NULL\x20DEFAULT\x20now()\x0a\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20');const e=await j['query']('SELECT\x20version\x20FROM\x20schema_migrations'),b=new Set(e[p(0x167)][p(0x168)](u=>u['version'])),P=(await h['readdir'](G))['filter'](u=>u[p(0x169)]('.sql'))['sort']();for(const u of P){if(b[p(0x16a)](u)){Z['push']({'file':u,'status':'skip'});continue;}const X=await h[p(0x16b)](n[p(0x16c)](G,u),'utf8'),H=await j[p(0x16d)]();try{await H[p(0x166)]('BEGIN'),await H['query'](X),await H['query']('INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)',[u]),await H['query']('COMMIT');}catch(i){await H[p(0x166)]('ROLLBACK');throw i;}finally{H['release']();}Z['push']({'file':u,'status':p(0x16e)});}return Z;}finally{await j['end']();}}function k(h,n){h=h-0x163;const B=Q();let G=B[h];return G;}function databaseFromUrl(B){const z=k;if(!B)return undefined;const G=new URL(B);return{'host':G[z(0x16f)],'port':Number(G['port']||0x1538),'database':G['pathname']['slice'](0x1),'user':decodeURIComponent(G['username']),'password':decodeURIComponent(G['password'])};}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const B=k;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';import h from'./services/registration.js';const [user,password,type]=process['argv']['slice'](0x2);if(!user||!password)console['error']('Usage:\x20fcore-registration\x20<login>\x20<password>\x20[type]'),process[B(0xc5)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const {user:data}=await h({'user':user,'password':password,'type':type},{'pg':pg});console['log']('Registered\x20user\x20'+data['id']+'\x20('+data[B(0xc6)]+')');}catch(n){console[B(0xc7)](n),process['exitCode']=0x1;}finally{await pg['end']();}}function k(h,n){h=h-0xc5;const B=Q();let G=B[h];return G;}function Q(){const G=['exitCode','type','error'];Q=function(){return G;};return Q();}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function
|
|
2
|
+
function Q(){const G=['exitCode','error','end'];Q=function(){return G;};return Q();}function k(h,n){h=h-0x1ec;const B=Q();let G=B[h];return G;}const B=k;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';import h from'./services/change-password.js';const [login,password]=process['argv']['slice'](0x2);if(!login||!password)console['error']('Usage:\x20fcore-password\x20<login>\x20<password>'),process[B(0x1ec)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg['query']('SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201',[login]),user=result['rows'][0x0];if(!user)throw new Error('User\x20not\x20found');await h({'userId':user['id'],'password':password},{'pg':pg}),console['log']('Password\x20changed\x20for\x20'+login);}catch(n){console[B(0x1ed)](n),process[B(0x1ec)]=0x1;}finally{await pg[B(0x1ee)]();}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const b=k;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function Q(){const u=['logs','check','settings','dictionaries','read','split','includes','system','query','rows','User\x20not\x20found','trim','log','get','set','BEGIN','UPDATE\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SET\x20actions\x20=\x20$1,\x20updated_by\x20=\x20$2,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20access_id\x20=\x20$3','access_id','Granted\x20permissions\x20for\x20','join','end'];Q=function(){return u;};return Q();}const SYSTEM_ACTIONS=[b(0x13b),'audit','list',b(0x13c),'access',b(0x13d),b(0x13e)],RESOURCE_ACTIONS=[b(0x13f),'update','create','delete'],[login,permissionArg]=process['argv']['slice'](0x2);function expandPermissions(h){const P=b,n=h[P(0x140)](',')['map'](G=>G['trim']())['filter'](Boolean),B=new Set();for(const G of n){if(G[P(0x141)](':')){B['add'](G);continue;}const f=G===P(0x142)?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const j of f){B['add'](G+':'+j);}}return[...B];}function k(h,n){h=h-0x13b;const B=Q();let G=B[h];return G;}if(!login||!permissionArg)console['error']('Usage:\x20fcore-permission\x20<login>\x20<system|resource|resource:action[,...]|clear>'),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[b(0x143)]('SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201',[login]),user=result[b(0x144)][0x0];if(!user)throw new Error(b(0x145));if(permissionArg[b(0x146)]()==='clear')await pg[b(0x143)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[user['id']]),console[b(0x147)]('Permissions\x20cleared\x20for\x20'+login);else{const permissions=expandPermissions(permissionArg),byResource=new Map();for(const permission of permissions){const [resource,action]=permission['split'](':'),actions=byResource[b(0x148)](resource)??[];actions['push'](action),byResource[b(0x149)](resource,actions);}const client=await pg['connect']();try{await client['query'](b(0x14a));for(const [resource,actions]of byResource){const existing=await client['query']('SELECT\x20access_id,\x20actions\x20FROM\x20admin.role_access\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL\x20AND\x20resource\x20=\x20$2',[user['id'],resource]),row=existing['rows'][0x0];if(row){const merged=[...new Set([...row['actions']??[],...actions])];await client['query'](b(0x14b),[merged,user['id'],row[b(0x14c)]]);}else await client[b(0x143)]('INSERT\x20INTO\x20admin.role_access\x0a\x20\x20\x20\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\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$4)',[resource,actions,user['id'],user['id']]);}await client['query']('COMMIT');}catch(Z){await client['query']('ROLLBACK');throw Z;}finally{client['release']();}console['log'](b(0x14d)+login+':\x20'+permissions[b(0x14e)](',\x20'));}}catch(e){console['error'](e),process['exitCode']=0x1;}finally{await pg[b(0x14f)]();}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAYnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CA0K9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0x112;const B=Q();let G=B[h];return G;}import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';import h from'./services/get-current-user.js';import n from'./services/registration.js';import B from'./services/change-password.js';import{authSchemas}from'./schema.js';import G from'../../shared/getIP.js';import{UnauthorizedError}from'../../errors.js';export function authRoutes(f){return async j=>{const p=k,Z=async e=>{const i=k,b=e[i(0x112)]==='GET'?e['query']:e['body'],P=G(e),u=await verifyUser({...b,'ip':P},f);u[i(0x113)]=await getUserPermissions(u['id'],f);const X=u[i(0x114)]?f['config'][i(0x115)][i(0x116)]:f['config'][i(0x115)][i(0x117)];await e['login'](u);const H=f['config']['auth']['sessionTimeout']*0x3e8*0x3c;return e[i(0x118)]?.['cookie']&&(e[i(0x118)]['cookie']['maxAge']=H),await e[i(0x118)]['save'](),await f['audit']?.['write']?.({'module':'auth','resource':i(0x118),'resourceId':e[i(0x118)]['sessionId'],'action':i(0x119),'userId':u['id'],'ipAddress':P}),{'user':{'id':u['id'],'type':u[i(0x11a)],'permissions':u[i(0x113)]},'redirectUrl':X};};j[p(0x11b)](p(0x11c),{'schema':{'tags':['fcore',p(0x115)],'summary':'Sign\x20in','description':p(0x11d),'access':'public','permissions':[],'querystring':authSchemas['credentials']}},Z),j[p(0x11e)](p(0x11c),{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20in','description':p(0x11d),'access':p(0x11f),'permissions':[],'body':authSchemas['credentials']}},Z),j['post'](p(0x120),{'schema':{'tags':['fcore',p(0x115)],'summary':'Register','description':'Creates\x20a\x20regular\x20user\x20account.','access':'admin','permissions':[p(0x121)],'body':authSchemas['credentials']}},async e=>n(e[p(0x122)],f)),j['post']('/api/auth/password',{'schema':{'tags':['fcore','auth'],'summary':'Change\x20password','description':'Changes\x20the\x20password\x20for\x20the\x20current\x20user.','access':'user','permissions':[],'body':authSchemas['password']}},async e=>{const z=p;if(!e['user'])throw new UnauthorizedError('Not\x20authorized');return await B({'userId':e['user']['id'],...e[z(0x122)]},f),{'success':!![]};}),j['post'](p(0x123),{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20out','description':p(0x124),'access':'user','permissions':[]}},async(e,b)=>{const t=p,P={'redirectUrl':'/'};if(!e['user'])return P;return await f[t(0x125)]?.[t(0x126)]?.({'module':t(0x115),'resource':'session','resourceId':e['session'][t(0x127)],'action':t(0x128),'userId':e[t(0x129)]?.['id']}),await e['session']['destroy'](),b[t(0x12a)](f['config'][t(0x115)][t(0x12b)]),Object['defineProperty'](e,'session',{'value':null,'writable':![],'configurable':![]}),P;}),j['get']('/api/auth/user',{'schema':{'tags':[p(0x12c),p(0x115)],'summary':p(0x12d),'description':'Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','access':p(0x129),'permissions':[],'querystring':authSchemas['query']}},async e=>{const m=p;return h({'user':e[m(0x129)],'token':e['query'][m(0x12e)],'maxAge':e[m(0x118)]?.['cookie']?.[m(0x12f)],'originalExpires':e[m(0x118)]?.[m(0x130)]?.['originalExpires']?.[m(0x131)]?.()});});};}function Q(){const A=['method','permissions','twofa','auth','twoFactorRedirect','redirect','session','login','type','get','/api/auth/login','Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','post','public','/api/auth/registration','user:create','body','/api/auth/logout','Terminates\x20the\x20current\x20user\x20session.','audit','write','sessionId','logout','user','clearCookie','cookieName','fcore','Get\x20current\x20user','token','maxAge','cookie','toISOString'];Q=function(){return A;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const h=k;import{Type}from'@sinclair/typebox';function k(h,n){h=h-0x81;const B=Q();let G=B[h];return G;}function Q(){const n=['Boolean','Object','String','Optional'];Q=function(){return n;};return Q();}export const authSchemas={'query':Type['Object']({'token':Type['Optional'](Type[h(0x81)]())}),'credentials':Type[h(0x82)]({'user':Type[h(0x83)]({'minLength':0x1,'maxLength':0x64}),'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'type':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'id':Type[h(0x84)](Type[h(0x83)]({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type['Object']({'code':Type['String']({'minLength':0x1})})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{hashPassword}from'../../../plugins/auth/index.js';function Q(){const Z=['query'];Q=function(){return Z;};return Q();}function k(h,n){h=h-0x1e4;const B=Q();let G=B[h];return G;}export default async function changePassword({id:h,password:n,userId:B},{pg:G}){const j=k,f=await hashPassword(n);await G[j(0x1e4)]('UPDATE\x20admin.users\x0a\x20\x20\x20\x20\x20SET\x20password_hash\x20=\x20$1,\x20updated_at\x20=\x20now(),\x20updated_by\x20=\x20$3\x0a\x20\x20\x20\x20\x20WHERE\x20uid\x20=\x20$2',[f,h||B,B]);}
|
|
@@ -5,5 +5,7 @@ import type { User } from "../../../context.js";
|
|
|
5
5
|
export default function getCurrentUser(params: {
|
|
6
6
|
user: User | undefined;
|
|
7
7
|
token: boolean | undefined;
|
|
8
|
+
maxAge: number | undefined;
|
|
9
|
+
originalExpires: string | undefined;
|
|
8
10
|
}): Promise<Record<string, unknown>>;
|
|
9
11
|
//# sourceMappingURL=get-current-user.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/get-current-user.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAA8B,cAAc,CAAC,MAAM,EAAE;IACnD,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"get-current-user.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/services/get-current-user.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAA8B,cAAc,CAAC,MAAM,EAAE;IACnD,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkBnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const Z=['permissions','map','split'];Q=function(){return Z;};return Q();}import{safeUser}from'../../utils/safe-user.js';function k(h,n){h=h-0x123;const B=Q();let G=B[h];return G;}export default async function getCurrentUser(h){const j=k,{user:n}=h;if(!n)return{};if(h['token']){const {jwtSignToken:B}=await import('../../../plugins/jwt.js'),G=await B(n);n['token']=G;}return n['resources']=[...new Set(n?.[j(0x123)][j(0x124)](f=>f[j(0x125)](':')[0x0]))],{...safeUser(n),'session':{'maxAge':h['maxAge'],'originalExpires':h['maxAge']}};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ConflictError}from'../../../errors.js';import{hashPassword}from'../../../plugins/auth/index.js';function k(h,n){h=h-0xc8;const B=Q();let G=B[h];return G;}export default async function registration({user:h,password:n,type:B},{pg:G}){const e=k,f=await hashPassword(n),j=await G['query']('INSERT\x20INTO\x20admin.users\x20(login,\x20password_hash,\x20user_type)\x0a\x20\x20\x20\x20\x20SELECT\x20$1,\x20$2,\x20$3\x0a\x20\x20\x20\x20\x20WHERE\x20NOT\x20EXISTS\x20(SELECT\x201\x20FROM\x20admin.users\x20WHERE\x20login\x20=\x20$1)\x0a\x20\x20\x20\x20\x20RETURNING\x20uid\x20AS\x20id,\x20user_type\x20AS\x20type',[h,f,B||e(0xc8)]),Z=j['rows'][0x0];if(!Z)throw new ConflictError('Login\x20is\x20already\x20in\x20use');return{'user':Z};}function Q(){const b=['regular'];Q=function(){return b;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{unsupported}from'../../utils/unsupported.js';export default async function verifyTwoFactor(h,n){return unsupported('Two-factor\x20provider');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function k(h,n){h=h-0x1c0;var B=Q();var G=B[h];return G;}var h=k;function Q(){var n=['image/jpeg','image/png','image/webp','image/tiff','application/pdf','application/vnd.ms-powerpoint','application/vnd.openxmlformats-officedocument.presentationml.presentation','application/vnd.oasis.opendocument.text','text/csv','application/json','application/geo+json','application/x-7z-compressed','application/gzip','application/x-gzip','audio/wav','audio/ogg','audio/webm','video/quicktime'];Q=function(){return n;};return Q();}export default new Set([h(0x1c0),h(0x1c1),'image/gif',h(0x1c2),'image/bmp',h(0x1c3),'image/svg+xml','image/x-icon','image/avif',h(0x1c4),'application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',h(0x1c5),h(0x1c6),h(0x1c7),'application/vnd.oasis.opendocument.spreadsheet','application/vnd.oasis.opendocument.presentation','text/plain',h(0x1c8),'text/markdown',h(0x1c9),'application/xml','text/xml',h(0x1ca),'application/vnd.google-earth.kml+xml','application/vnd.google-earth.kmz','application/zip','application/x-zip-compressed',h(0x1cb),'application/x-rar-compressed','application/vnd.rar',h(0x1cc),h(0x1cd),'application/x-tar','audio/mpeg',h(0x1ce),h(0x1cf),h(0x1d0),'audio/mp4','video/mp4','video/mpeg','video/webm',h(0x1d1),'video/x-msvideo','application/octet-stream']);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileTypeFromBuffer}from'file-type';function
|
|
1
|
+
function k(h,n){h=h-0x12a;const B=Q();let G=B[h];return G;}import{fileTypeFromBuffer}from'file-type';function Q(){const z=['fileToken','verify','token','download','startsWith','image/','pop','file','Content-Disposition','header','Cache-Control','fcore','Uploads\x20a\x20file\x20and\x20stores\x20its\x20metadata.','fields','/api/file/:token/resize','user','type'];Q=function(){return z;};return Q();}import{getFile}from'./services/get-file.js';import{uploadFile}from'./services/upload-file.js';import{resizeFile}from'./services/resize-file.js';import{fileSchemas}from'./schema.js';export function fileRoutes(h){return async n=>{const X=k;n['get']('/api/file/:token',{'schema':{'tags':['fcore','file'],'summary':'Get\x20file\x20by\x20token','description':'Returns\x20a\x20file\x20after\x20verifying\x20its\x20signed\x20access\x20token.','access':'public','permissions':[],'params':fileSchemas[X(0x12a)],'querystring':fileSchemas['fileDownloadQuery']}},async(B,G)=>{const H=X,f=h['file'][H(0x12b)](B['params'][H(0x12c)]),j=await getFile({'pathOrToken':f},h),Z=await fileTypeFromBuffer(j),e=Z?.['mime']??'application/octet-stream',b=B['query'][H(0x12d)]===!![],P=e[H(0x12e)](H(0x12f))||e==='application/pdf',u=f['split']('/')[H(0x130)]()?.['replace'](/[^A-Za-z0-9._-]/g,'_')??H(0x131);return G['type'](e),G['header'](H(0x132),(b||!P?'attachment':'inline')+';\x20filename=\x22'+u+'\x22')[H(0x133)](H(0x134),'public,\x20max-age=86400,\x20immutable'),G['send'](j);}),n['post']('/api/file/upload',{'schema':{'tags':[X(0x135),X(0x131)],'summary':'Upload\x20file','description':X(0x136),'access':'user','permissions':['files:create']}},async B=>{const i=X,G=await B['file']();if(!G)throw new Error('File\x20is\x20required');return uploadFile({'file':G,'metadata':{'name':G['filename'],'path':G['fields']['path']?.['value'],'resource':G['fields']['resource']?.['value'],'resourceId':G[i(0x137)]['resourceId']?.['value']},'user':B['user']},h);}),n['get'](X(0x138),{'schema':{'tags':['fcore','file'],'summary':'Resize\x20file','description':'Returns\x20a\x20resized\x20image\x20file.','access':X(0x139),'permissions':['files:read'],'params':fileSchemas['fileToken'],'querystring':fileSchemas['resizeQuery']}},async(B,G)=>{const p=X,f=await resizeFile({'pathOrToken':h[p(0x131)]?.['verify'](B['params']['token']),...B['query']},h),j=await fileTypeFromBuffer(f);return G[p(0x13a)](j?.['mime']??'image/png'),G['header'](p(0x132),'inline')['header'](p(0x134),'public,\x20max-age=86400,\x20immutable'),G['send'](f);});};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const h=k;function Q(){const n=['Object','String','Any','Optional','Integer','Union','cover','Literal','contain','outside'];Q=function(){return n;};return Q();}function k(h,n){h=h-0x146;const B=Q();let G=B[h];return G;}import{Type}from'@sinclair/typebox';export const fileSchemas={'fileId':Type['Object']({'id':Type['String']({'minLength':0x1,'maxLength':0x80})}),'fileToken':Type[h(0x146)]({'token':Type[h(0x147)]({'minLength':0x1,'maxLength':0x800})}),'fileDownloadQuery':Type['Object']({'download':Type['Optional'](Type['Boolean']())}),'filePath':Type[h(0x146)]({'*':Type[h(0x147)]({'minLength':0x1,'maxLength':0x400})}),'upload':Type['Object']({'file':Type[h(0x148)](),'metadata':Type['Object']({'name':Type[h(0x149)](Type['String']({'minLength':0x1})),'path':Type['Optional'](Type['String']({'minLength':0x1})),'entityType':Type['Optional'](Type['String']({'minLength':0x1})),'entityId':Type['Optional'](Type['String']({'minLength':0x1}))})}),'filePatch':Type['Object']({'entityType':Type[h(0x149)](Type['String']({'minLength':0x1})),'entityId':Type[h(0x149)](Type[h(0x147)]({'minLength':0x1}))}),'resizeQuery':Type['Object']({'width':Type['Optional'](Type[h(0x14a)]({'minimum':0x1,'default':0xc8})),'height':Type[h(0x149)](Type['Integer']({'minimum':0x1})),'fit':Type['Optional'](Type[h(0x14b)]([Type['Literal'](h(0x14c)),Type[h(0x14d)](h(0x14e)),Type[h(0x14d)]('fill'),Type['Literal']('inside'),Type['Literal'](h(0x14f))]))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError}from'../../../errors.js';function
|
|
1
|
+
import{NotFoundError}from'../../../errors.js';function k(h,n){h=h-0x113;var B=Q();var G=B[h];return G;}export async function getFile(h,n){var B=k;if(!n['file'])throw new Error(B(0x113));if(!await n['file'][B(0x114)](h['pathOrToken']))throw new NotFoundError(B(0x115)+h['pathOrToken']);return n['file'][B(0x116)](h['pathOrToken']);}function Q(){var G=['empty\x20file','exists','File\x20not\x20found','get'];Q=function(){return G;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{fileTypeFromBuffer}from'file-type';import{createHash}from'node:crypto';import{mkdir,readFile,writeFile}from'node:fs/promises';import
|
|
1
|
+
function Q(){const z=['path','height','digest','join','file','mime','Only\x20image\x20files\x20can\x20be\x20resized','resize'];Q=function(){return z;};return Q();}import{NotFoundError,ValidationError}from'../../../errors.js';import{fileTypeFromBuffer}from'file-type';import{createHash}from'node:crypto';import{mkdir,readFile,writeFile}from'node:fs/promises';import h from'node:path';import n from'sharp';export async function resizeFile(B,G){const p=k,f=B['pathOrToken']??B[p(0xc0)];if(!f)throw new ValidationError('File\x20path\x20is\x20required');const j=parseDimension(B['width'],'width')??0xc8,Z=parseDimension(B['height'],p(0xc1)),e=createHash('sha256')['update'](f+':'+j+':'+(Z??'auto')+':'+(B['fit']??'cover'))[p(0xc2)]('hex'),b=h['resolve']('logs','resize'),P=h[p(0xc3)](b,e+'.jpg');try{return await readFile(P);}catch(i){if(i['code']!=='ENOENT')throw i;}if(!await G['file']['exists'](f))throw new NotFoundError('File\x20not\x20found');const u=await G[p(0xc4)]['get'](f),X=await fileTypeFromBuffer(u);if(!X?.[p(0xc5)]['startsWith']('image/'))throw new ValidationError(p(0xc6));const H=await n(u)[p(0xc7)]({'width':j,'height':Z,'fit':B['fit']??'cover'})['toBuffer']();return await mkdir(b,{'recursive':!![]}),await writeFile(P,H),H;}function k(h,n){h=h-0xc0;const B=Q();let G=B[h];return G;}function parseDimension(B,G){if(B===undefined||B==='')return undefined;const f=Number(B);if(!Number['isInteger'](f)||f<=0x0)throw new ValidationError(G+'\x20must\x20be\x20a\x20positive\x20integer');return f;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileTypeFromBuffer}from'file-type';import
|
|
1
|
+
import{fileTypeFromBuffer}from'file-type';import h from'../mime.js';function Q(){const z=['name','slice','path','metadata','toBuffer','mimetype','SELECT\x20file_id\x20FROM\x20admin.files\x0a\x20\x20\x20\x20\x20\x20\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20AND\x20file_name\x20=\x20$3\x0a\x20\x20\x20\x20\x20\x20\x20LIMIT\x201','\x22\x20already\x20exists\x20for\x20resource\x20\x22','resource','resourceId','put','file','pop','attached','pending','rows'];Q=function(){return z;};return Q();}import{randomUUID}from'node:crypto';function k(h,n){h=h-0x188;const B=Q();let G=B[h];return G;}import{ValidationError}from'../../../errors.js';export async function uploadFile(n,B){const p=k,G=(n['metadata'][p(0x188)]??randomUUID())['replace'](/[^a-zA-Z0-9._-]/g,'_'),f=new Date(),j=String(f['getFullYear']())[p(0x189)](-0x2),Z=String(f['getMonth']()+0x1)['padStart'](0x2,'0'),e=String(f['getDate']())['padStart'](0x2,'0'),b=n['metadata'][p(0x18a)]??(n['metadata']['resource']?n['metadata']['resource']+'/'+(n[p(0x18b)]['resourceId']??randomUUID())+'/'+G:null)??'uploads/'+j+'/'+Z+'-'+e+'/'+G,P=await n['file'][p(0x18c)](),u=await fileTypeFromBuffer(P);if(!h['has'](n['file']['mimetype'])&&(u?.['mime']?!h['has'](u['mime']):!![]))throw new Error('Unsupported\x20file\x20type:\x20'+n['file'][p(0x18d)]);const X=Boolean(n['metadata']['resource']&&n['metadata']['resourceId']);if(X){const i=await B['pg']['query'](p(0x18e),[n['metadata']['resource'],String(n['metadata']['resourceId']),G]);if((i['rowCount']??0x0)>0x0)throw new ValidationError('File\x20with\x20name\x20\x22'+G+p(0x18f)+n['metadata'][p(0x190)]+'\x22\x20and\x20id\x20\x22'+n['metadata'][p(0x191)]+'\x22');}await B['file'][p(0x192)](b,P);const H=await B['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20file_type,\x20size,\x20uploaded_name,\x20file_name,\x20ext,\x20status,\x20created_by)\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,\x20$10)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[n['metadata']['resource']??null,n[p(0x18b)]['resourceId']??null,b,n['file']['mimetype'],n['file'][p(0x193)]['bytesRead'],n['metadata'][p(0x188)],G,n['file']['mimetype']['split']('/')[p(0x194)]()??null,X?p(0x195):p(0x196),n['user']?.['id']??null]);return{...H[p(0x197)][0x0],'token':B['file']['create'](b)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/route.ts"],"names":[],"mappings":"AAIA,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/resource/route.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAwBnD,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CAoblE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listResources}from'./services/list-resources.js';
|
|
1
|
+
import{listResources}from'./services/list-resources.js';function k(h,n){h=h-0x94;const B=Q();let G=B[h];return G;}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';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';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=h=>h['user'];function Q(){const H=['get','fcore','params','user','Suggest\x20resource\x20values','resourceField','/api/resource/:resource/export','Export\x20resource\x20records','$resource:read','exportResourceQuery','/api/resource/:resource/code','Generates\x20a\x20code\x20from\x20an\x20explicit\x20template\x20or\x20a\x20field\x20code_template.','resource','auth','post','config','$resource:delete','Upload\x20resource\x20file','delete','rowCount','/api/resource/:resource/:id/:relation','List\x20resource\x20relations','Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','query','$resource:create','body'];Q=function(){return H;};return Q();}export function resourceRoutes(h){return async n=>{const P=k;n[P(0x94)]('/api/resource/:resource/search',{'schema':{'tags':[P(0x95),'resource'],'summary':'Search\x20resource','description':'Searches\x20records\x20in\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resource']}},async B=>searchResource({...B['query'],...B[P(0x96)],'user':user(B)||h['config']?.['auth']?.[P(0x97)]},h)),n[P(0x94)]('/api/suggest/:resource/:field',{'schema':{'tags':['fcore','resource'],'summary':P(0x98),'description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':'user','permissions':['$resource:read'],'params':resourceSchemas[P(0x99)],'querystring':resourceSchemas['suggestQuery']}},async B=>suggestResource({...B['query'],...B[P(0x96)],'user':user(B)||h['config']?.['auth']?.['user']},h)),n['get'](P(0x9a),{'schema':{'tags':['fcore','resource'],'summary':P(0x9b),'description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[P(0x9c)],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas[P(0x9d)]}},async B=>exportResource({...B['query'],...B['params'],'user':user(B)||h['config']?.['auth']?.['user']},h)),n['get']('/api/resource/:resource/schema',{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20schema','description':'Returns\x20the\x20resource\x20variables\x20and\x20nested\x20relation\x20schema.','access':P(0x97),'permissions':['$resource:read'],'params':resourceSchemas['resource']}},async B=>getResourceSchema(B['params'],h)),n[P(0x94)](P(0x9e),{'schema':{'tags':['fcore','resource'],'summary':'Generate\x20a\x20resource\x20code','description':P(0x9f),'access':'user','permissions':['$resource:read'],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceCodeQuery']}},async B=>generateResourceCode({...B['params'],...B['query']},h)),n[P(0x94)]('/api/resource/:resource/scope/:user',{'schema':{'tags':[P(0x95),P(0xa0)],'summary':'List\x20resource\x20as\x20a\x20user\x20for\x20scope\x20testing','description':'Returns\x20resource\x20records\x20using\x20the\x20specified\x20user\x27s\x20permissions\x20and\x20access\x20scopes.\x20Admin\x20only.','access':'admin','permissions':['system:access'],'params':resourceSchemas['resourceScopeTarget']}},async B=>listResourceAsUser({...B['params'],...B['query'],'requester':user(B)},h)),n[P(0x94)]('/api/resource/:resource',{'schema':{'tags':[P(0x95),P(0xa0)],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':P(0x97),'permissions':['$resource:read'],'params':resourceSchemas['resource']}},async B=>listResources({...B['query'],...B['params'],'user':user(B)||h['config']?.[P(0xa1)]?.[P(0x97)]},h)),n[P(0xa2)]('/api/resource/:resource',{'schema':{'tags':[P(0x95),'resource'],'summary':'Create\x20resource\x20record','description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':['$resource:create'],'params':resourceSchemas['resource']}},async B=>createResource({...B[P(0x96)],'data':B['body'],'user':user(B)||h['config']?.['auth']?.[P(0x97)]},h)),n['get']('/api/resource/:resource/:id',{'schema':{'tags':[P(0x95),'resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':P(0x97),'permissions':['$resource:read'],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async B=>getResource({...B['query'],...B[P(0x96)],'user':user(B)||h[P(0xa3)]?.[P(0xa1)]?.['user']},h)),n['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore',P(0xa0)],'summary':'Update\x20resource\x20record','description':'Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':P(0x97),'permissions':['$resource:update'],'params':resourceSchemas['resourceId']}},async B=>updateResource({...B[P(0x96)],'patch':B['body'],'user':user(B)||h[P(0xa3)]?.['auth']?.['user']},h)),n['delete']('/api/resource/:resource/:id',{'schema':{'tags':[P(0x95),P(0xa0)],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[P(0xa4)],'params':resourceSchemas['resourceId']}},async B=>deleteResource({...B[P(0x96)],'user':user(B)||h['config']?.['auth']?.['user']},h)),n['post']('/api/resource/:resource/:id/upload',{'schema':{'tags':[P(0x95),'resource'],'summary':P(0xa5),'description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':['$resource:update'],'params':resourceSchemas['uploadResourceFile']}},async B=>{const u=P,G=await B['file']();if(!G)throw new Error('File\x20is\x20required');const f=B['params'][u(0xa0)],j=B['params']['id'];return uploadFile({'file':G,'metadata':{'name':G['filename'],'path':G['fields']['path']?.['value'],'resource':f,'resourceId':j},'user':B['user']},h);}),n[P(0xa6)]('/api/resource/:resource/:id/file/:fid',{'schema':{'tags':[P(0x95),'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 B=>{const X=P,{resource:G,id:f,fid:j}=B['params'],Z=await h['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',[j,G,String(f)]);if(!Z[X(0xa7)])throw new Error('File\x20not\x20found\x20for\x20this\x20resource\x20and\x20record');const e=Z['rows'][0x0]?.['file_path'],b=await h['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[j,G,String(f)]);return await h['file']['delete'](e),{'success':(b['rowCount']??0x0)>0x0,'resource':G,'resourceId':f,'fileId':j};}),n['get']('/api/resource/:resource/list',{'schema':{'tags':['fcore',P(0xa0)],'summary':'List\x20resource\x20items','description':'Returns\x20resource\x20identifiers\x20and\x20display\x20text,\x20optionally\x20filtered\x20by\x20searchable\x20fields.','access':'user','permissions':['$resource:read'],'params':resourceSchemas['resource'],'querystring':resourceSchemas['resourceListQuery']}},async B=>listResourceList({...B['params'],...B['query'],'user':user(B)||h['config']?.['auth']?.[P(0x97)]},h)),n['get'](P(0xa8),{'schema':{'tags':['fcore','resource'],'summary':P(0xa9),'description':P(0xaa),'access':'user','params':resourceSchemas['resourceIdRelation'],'permissions':['$resource:read']}},async B=>listResourceRelation({...B[P(0xab)],...B['params'],'user':user(B)||h['config']?.[P(0xa1)]?.[P(0x97)]},h)),n['post'](P(0xa8),{'schema':{'tags':['fcore',P(0xa0)],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':[P(0xac)],'params':resourceSchemas['resourceIdRelation']}},async B=>createResourceRelation({...B['params'],'data':B['body'],'user':user(B)||h[P(0xa3)]?.['auth']?.['user']},h)),n[P(0xa6)]('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[P(0x95),'resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':P(0x97),'permissions':['$resource:delete'],'params':resourceSchemas['resourceIdRelationId']}},async B=>deleteResourceRelation({...B['params'],'user':user(B)||h['config']?.['auth']?.['user']},h)),n['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20relation','description':'Updates\x20a\x20related\x20resource\x20record.','access':'user','permissions':['$resource:update'],'params':resourceSchemas['resourceIdRelationId']}},async B=>updateResourceRelation({...B['params'],'data':B[P(0xad)],'user':user(B)||h['config']?.[P(0xa1)]?.[P(0x97)]},h));};}
|
|
@@ -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;
|
|
@@ -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,gBAAgB;;;;;IAKhB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;;CASpB,CAAC"}
|
|
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
|
-
const
|
|
1
|
+
function k(h,n){h=h-0x1cd;const B=Q();let G=B[h];return G;}const h=k;import{Type}from'@sinclair/typebox';export const identifier=Type['String']({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});function Q(){const n=['Object','String','Optional','Any','Array','Integer'];Q=function(){return n;};return Q();}export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type['Object']({'resource':identifier}),'resourceScopeTarget':Type[h(0x1cd)]({'resource':identifier,'user':identifier}),'exportResource':Type[h(0x1cd)]({'resource':identifier}),'resourceField':Type[h(0x1cd)]({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type['Optional'](Type['String']()),'search':Type['Optional'](Type[h(0x1ce)]()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceListQuery':Type[h(0x1cd)]({'search':Type['Optional'](Type['String']()),'limit':Type[h(0x1cf)](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceCodeQuery':Type[h(0x1cd)]({'id':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x80})),'field':Type['Optional'](identifier),'template':Type['Optional'](Type['String']({'maxLength':0x3e8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[h(0x1cd)]({'include':Type[h(0x1cf)](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type[h(0x1cd)]({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'resourceIdFileId':Type['Object']({'resource':identifier,'id':identifier,'fid':identifier}),'uploadResourceFile':Type['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type[h(0x1d0)](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type[h(0x1cf)](Type['Record'](Type['String'](),Type['Unknown']())),'sort':Type['Optional'](Type[h(0x1d1)](Type['String']({'minLength':0x1}))),'search':Type[h(0x1cf)](Type['String']()),'scope':Type[h(0x1cf)](Type[h(0x1ce)]()),'limit':Type[h(0x1cf)](Type[h(0x1d2)]({'minimum':0x1,'maximum':0xc8})),'offset':Type[h(0x1cf)](Type['Integer']({'minimum':0x0})),'fields':Type[h(0x1cf)](Type['Array'](identifier))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const f=['query'];Q=function(){return f;};return Q();}function k(h,n){h=h-0x11a;const B=Q();let G=B[h];return G;}export async function addNote(h,n){const G=k,B=await n['pg'][G(0x11a)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[h['resource'],String(h['id']),h['body']]);return B['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function addResourceFile(
|
|
1
|
+
function k(h,n){h=h-0x1ce;const B=Q();let G=B[h];return G;}export async function addResourceFile(h,n){const G=k,B=await n['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20',[h['resource'],String(h['id']),h['filePath'],h[G(0x1ce)]??null]);return B[G(0x1cf)][0x0];}function Q(){const f=['size','rows'];Q=function(){return f;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0x169;const B=Q();let G=B[h];return G;}export async function createResourceRelation(h,n){const e=k,{resource:B,id:G,relation:f,data:j,user:Z}=h;return n['resource'][e(0x169)]({'name':B,'id':G,'relation':f,'data':j,'user':Z});}function Q(){const b=['createRelation'];Q=function(){return b;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0x17c;var B=Q();var G=B[h];return G;}export async function createResource(h,n){var B=k;return n['resource']['create']({'name':h['resource'],'data':h['data'],'user':h[B(0x17c)]});}function Q(){var G=['user'];Q=function(){return G;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export async function deleteResourceRelation(h,n){const {resource:B,id:G,relation:f,relationId:j}=h;return n['resource']['deleteRelation']({'name':B,'id':G,'relation':f,'relationId':j});}
|