@opengis/fcore 0.0.1-beta.6 → 0.0.1-beta.7
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.d.ts +2 -1
- package/dist/fastify.d.ts.map +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.d.ts +3 -0
- package/dist/modules/auth/schema.d.ts.map +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 +1 -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.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- 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 +0 -3
- 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 +3 -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.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +2 -0
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- 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.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- 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.d.ts.map +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-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +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.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.d.ts.map +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.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +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.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +18 -3
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -1
- 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.js +1 -1
- 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 +3 -2
- 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 +3 -2
- 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/update-relation.d.ts +11 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- 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.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260905120000_add_user_foreign_keys.sql +42 -42
- package/package.json +3 -2
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(C,N){C=C-0x1b7;const r=U();let p=r[C];return p;}import'dotenv/config';const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function required(C){const N=process.env[C];if(!N)throw new Error('Missing\x20environment\x20variable:\x20'+C);return N;}export function loadConfig(C={}){const p=z,N={'env':process.env.NODE_ENV??'development','debug':process.env.DEBUG===p(0x1b7),'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)},'storagePath':process.env.STORAGE_PATH??'./storage','redactionList':(process.env.REDACTION_LIST||'password')['split'](','),'logger':{'level':process.env.LOG_LEVEL??'info','responses':process.env.LOG_RESPONSES==='true'?!![]:![],'responseCodes':process.env.LOG_RESPONSE_STATUS_CODES?process.env.LOG_RESPONSE_STATUS_CODES['split'](',')['map'](r=>r-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['parse'](process.env.AUTH_USER):undefined,'sessionTimeout':+(process.env.AUTH_SESSION_TIMEOUT||0x258),'secret':process.env.AUTH_SECRET??'x5y30KBsEKCENT04tu6549Vxx3No1ztJ2q2K8r79S59420RaZ5','cookieName':process.env.AUTH_COOKIE_NAME??'session_user_auth','jwtSecret':process.env.AUTH_JWT_SECRET??p(0x1b8),'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||p(0x1b7)),'secure':Boolean(process.env.AUTH_COOKIE_OPTIONS_SECURE||'true'),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&[p(0x1b9),'strict','none'][p(0x1ba)](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,...C,'logger':{...N['logger'],...C['logger']},'pg':{...N['pg'],...C['pg']},'redis':{...N[p(0x1bb)],...C[p(0x1bb)]},'s3':{...N['s3'],...C['s3']},'auth':{...N['auth'],...C[p(0x1bc)]}};}export{required as requireEnv};function U(){const c=['true','0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','lax','includes','redis','auth'];U=function(){return c;};return U();}
|
package/dist/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function z(C,N){C=C-0xbb;const r=U();let p=r[C];return p;}let defaultContext;export function setContext(C){defaultContext=C;}export function getContext(){if(!defaultContext)throw new Error('Application\x20context\x20is\x20not\x20initialized');return defaultContext;}function U(){const r=['redis'];U=function(){return r;};return U();}export function createContext(C){return{...C,async 'close'(){const N=z;await Promise['allSettled']([C[N(0xbb)]?.['close'](),C['pg']?.['end']()]),await C['logger']['close']();}};}
|
package/dist/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=z;export class FCoreError extends Error{[c(0x10b)];['statusCode'];[c(0x10c)];constructor(C,N,r=0x1f4,p){super(N),this['code']=C,this['statusCode']=r,this['details']=p,this['name']=new.target.name;}}export class BadRequestError extends FCoreError{constructor(C,N){var x=c;super(x(0x10d),C,0x190,N);}}export class UnauthorizedError extends FCoreError{constructor(C='Authentication\x20required'){var m=c;super(m(0x10e),C,0x191);}}export class ForbiddenError extends FCoreError{constructor(C='Access\x20denied'){super('FORBIDDEN',C,0x193);}}function z(C,N){C=C-0x10b;var r=U();var p=r[C];return p;}export class NotFoundError extends FCoreError{constructor(C='Not\x20found'){var Q=c;super(Q(0x10f),C,0x194);}}export class ConflictError extends FCoreError{constructor(C='Conflict'){super('CONFLICT',C,0x199);}}export class ValidationError extends FCoreError{constructor(C,N){var u=c;super(u(0x110),C,0x1a6,N);}}export class UnsupportedError extends FCoreError{constructor(C=c(0x111)){super('UNSUPPORTED',C,0x1f5);}}function U(){var L=['code','details','BAD_REQUEST_ERROR','UNAUTHORIZED','NOT_FOUND','VALIDATION_ERROR','Operation\x20is\x20not\x20configured'];U=function(){return L;};return U();}
|
package/dist/fastify.d.ts
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { type FastifyPluginAsync } from "fastify";
|
|
5
5
|
import type { AppContext } from "./context.js";
|
|
6
|
-
export
|
|
6
|
+
export type FCoreApiModule = "auth" | "resource" | "file" | "system";
|
|
7
|
+
export default function fcoreFastify(ctx: AppContext, modules?: readonly FCoreApiModule[]): FastifyPluginAsync;
|
|
7
8
|
//# sourceMappingURL=fastify.d.ts.map
|
package/dist/fastify.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAY/C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAarE,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE,SAAS,cAAc,EAAE,GAClC,kBAAkB,CAgIpB"}
|
package/dist/fastify.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FCoreError}from'./errors.js';
|
|
1
|
+
import{FCoreError}from'./errors.js';function U(){const d=['split','decorate','ctx','onRoute','startsWith','method','package','tags','public','permissions','url','authorization','Route\x20access\x20not\x20defined','access','includes','Missing\x20permission:\x20','@fastify/multipart','message','logger','debug','test','auth','buffer','disabled','register','max','timeWindow','log'];U=function(){return d;};return U();}import{authRoutes}from'./modules/auth/route.js';import{fileRoutes}from'./modules/file/route.js';function z(C,N){C=C-0x6e;const r=U();let p=r[C];return p;}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';import{jwtVerifyToken}from'./plugins/jwt.js';function urlencodedContentParser(C,N,r){const p=decodeURIComponent(N['toString']())['split']('&')['reduce']((c,x)=>{const f=z,[m,Q]=x[f(0x6e)]('=');return{...c,[m]:Q};},{});r(null,p);}export default function fcoreFastify(C,N){return async r=>{const F=z;r[F(0x6f)](F(0x70),C);const {config:p}=C,c=new Map();r['addHook'](F(0x71),m=>{const t=F;if(m['url'][t(0x72)]('/api/')){const Q=m['schema'],u=Array['isArray'](m[t(0x73)])?m['method']:[m['method']];for(const L of u){if(L==='HEAD')continue;const T={'method':L,'endpoint':m['url'],'package':Q?.[t(0x74)]??'fcore','tags':Q?.[t(0x75)]??[],'summary':Q?.['summary']??'','description':Q?.['description']??'','access':Q?.['access']??t(0x76),'permissions':Q?.[t(0x77)]??[]};c['set'](L+'\x20'+m[t(0x78)],T);}}}),r['addHook']('preHandler',async m=>{const h=F,Q=c['get'](m['method']+'\x20'+m['routeOptions']['url']),u=m['raw']['headers']?.[h(0x79)],L=u?.['startsWith']('Bearer\x20')?u['slice'](0x7):null,T=m['user']??(L?await jwtVerifyToken(L):null);!m['user']&&L&&process.env.AUTH_JWT_SECRET&&(m['user']=await jwtVerifyToken(L));if(!Q?.['access'])throw new Error(h(0x7a));if(Q['access']==='public')return!![];if(!T)throw new ForbiddenError('User\x20required');if(Q['access']==='user'&&!Q['permissions']?.['length'])return!![];if(T['type']=='admin')return!![];if(Q[h(0x7b)]==='admin')throw new ForbiddenError('Admin\x20access\x20required');for(const Y of Q['permissions']){if(!T['permissions']?.[h(0x7c)](Y))throw new ForbiddenError(h(0x7d)+Y);}return!![];}),await createSessionStore(r,C),await r['register'](import(F(0x7e)),{'limits':{'fileSize':p['maxFileSize']*0x400*0x400}}),r['setErrorHandler']((m,Q,u)=>{const D=F;if(m instanceof FCoreError||m['code']==='FST_ERR_VALIDATION')return u['code'](m['statusCode'])['send']({'error':m['code'],'message':m[D(0x7f)],'details':m['details']});return C[D(0x80)]['error'](m),(p[D(0x81)]||process.env.NODE_ENV===D(0x82)||process.env.VITEST)&&console['error'](m),u['code'](0x1f4)['send']({'error':'INTERNAL_ERROR','message':'Internal\x20server\x20error'});});const x=m=>!N||N[F(0x7c)](m);if(x(F(0x83)))await r['register'](authRoutes(C));if(x('resource'))await r['register'](resourceRoutes(C));if(x('file'))await r['register'](fileRoutes(C));if(x('system'))await r['register'](systemRoutes(C,c));r['addContentTypeParser']('application/x-www-form-urlencoded',{'parseAs':F(0x84)},urlencodedContentParser),!p['rateLimit']?.[F(0x85)]?r[F(0x86)](import('@fastify/rate-limit'),{'max':p['rateLimit']?.[F(0x87)]||0x64,'timeWindow':p['rateLimit']?.[F(0x88)]||0xea60,'hook':'preHandler','global':!![],'keyGenerator':m=>(m['user']?.['id']||m['ip'])+'-'+m['raw'][F(0x78)]['split']('?')[0x0]}):console[F(0x89)]('⚠️\x20rate\x20limit\x20is\x20disabled');};};
|
package/dist/fcore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(C,N){C=C-0xc6;const r=U();let p=r[C];return p;}import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';import{createAudit,createDatabase,createDictionary,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';function U(){const Y=['redis','endpoint','forcePathStyle','resources'];U=function(){return Y;};return U();}export async function createFCore(C={}){const T=z,N=loadConfig(C['config']),r=createRedis(N[T(0xc6)]),p=createLogger(),c=createDatabase(N['pg']),x=createFileS3({'endpoint':N['s3'][T(0xc7)],'region':N['s3']['region'],'bucket':N['s3']['bucket'],'accessKey':N['s3']['accessKey'],'secretKey':N['s3']['secretKey'],'folder':N['s3']['folder'],'forcePathStyle':N['s3'][T(0xc8)],'tokenSecret':N['s3']['tokenSecret'],'tokenTtl':N['s3']['tokenTtl']}),m=createAudit({'pg':c,'logger':p}),Q=createDictionary({'pg':c,'dictionaries':C['dictionaries']}),u=createResource({'pg':c,'logger':p,'audit':m,'dictionary':Q,'file':x});C[T(0xc9)]?.['length']&&u['register'](C['resources']);const L=createContext({'config':N,'logger':p,'redis':r,'pg':c,'file':x,'resource':u,'audit':m,'dictionary':Q});return setContext(L),L;}
|
package/dist/migrations/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
function
|
|
2
|
+
function U(){const p=['status','error','exitCode'];U=function(){return p;};return U();}const N=z;import{runMigrations}from'./runner.js';function z(C,N){C=C-0x7b;const r=U();let p=r[C];return p;}import{loadConfig}from'../config.js';try{const config=loadConfig();console['log']('Loaded\x20configuration:',config['pg']);for(const r of await runMigrations({'database':config['pg']}))console['log']((r[N(0x7b)]==='run'?'OK\x20\x20':'SKIP')+'\x20'+r['file']);}catch(C){console[N(0x7c)](C),process[N(0x7d)]=0x1;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import C from'node:fs/promises';import N from'node:path';function z(C,N){C=C-0xff;const r=U();let p=r[C];return p;}function U(){const h=['dir','migrations','databaseUrl','rows','map','version','release','push','end'];U=function(){return h;};return U();}import{createDatabase}from'../plugins/pg.js';export async function runMigrations(r={}){const t=z,p=N['resolve'](r[t(0xff)]??t(0x100)),c=r['database']??databaseFromUrl(r[t(0x101)]??process.env.DATABASE_URL);if(!c)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const x=createDatabase(c);if(!x)throw new Error('empty\x20pg');const m=[];try{await x['query']('\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 Q=await x['query']('SELECT\x20version\x20FROM\x20schema_migrations'),u=new Set(Q[t(0x102)][t(0x103)](T=>T[t(0x104)])),L=(await C['readdir'](p))['filter'](T=>T['endsWith']('.sql'))['sort']();for(const T of L){if(u['has'](T)){m['push']({'file':T,'status':'skip'});continue;}const Y=await C['readFile'](N['join'](p,T),'utf8'),f=await x['connect']();try{await f['query']('BEGIN'),await f['query'](Y),await f['query']('INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)',[T]),await f['query']('COMMIT');}catch(F){await f['query']('ROLLBACK');throw F;}finally{f[t(0x105)]();}m[t(0x106)]({'file':T,'status':'run'});}return m;}finally{await x[t(0x107)]();}}function databaseFromUrl(r){if(!r)return undefined;const p=new URL(r);return{'host':p['hostname'],'port':Number(p['port']||0x1538),'database':p['pathname']['slice'](0x1),'user':decodeURIComponent(p['username']),'password':decodeURIComponent(p['password'])};}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const r=z;function U(){const p=['argv','Usage:\x20fcore-registration\x20<login>\x20<password>\x20[type]','exitCode','log','Registered\x20user\x20'];U=function(){return p;};return U();}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function z(C,N){C=C-0x102;const r=U();let p=r[C];return p;}import C from'./services/registration.js';const [user,password,type]=process[r(0x102)]['slice'](0x2);if(!user||!password)console['error'](r(0x103)),process[r(0x104)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const {user:data}=await C({'user':user,'password':password,'type':type},{'pg':pg});console[r(0x105)](r(0x106)+data['id']+'\x20('+data['type']+')');}catch(N){console['error'](N),process[r(0x104)]=0x1;}finally{await pg['end']();}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const r=z;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function z(C,N){C=C-0x149;const r=U();let p=r[C];return p;}function U(){const p=['error','Usage:\x20fcore-password\x20<login>\x20<password>','query','User\x20not\x20found','log','Password\x20changed\x20for\x20'];U=function(){return p;};return U();}import C from'./services/change-password.js';const [login,password]=process['argv']['slice'](0x2);if(!login||!password)console[r(0x149)](r(0x14a)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[r(0x14b)]('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(r(0x14c));await C({'userId':user['id'],'password':password},{'pg':pg}),console[r(0x14d)](r(0x14e)+login);}catch(N){console['error'](N),process['exitCode']=0x1;}finally{await pg['end']();}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const
|
|
2
|
+
const u=z;function U(){const T=['audit','access','settings','create','slice','add','error','Usage:\x20fcore-permission\x20<login>\x20<system|resource|resource:action[,...]|clear>','query','User\x20not\x20found','trim','split','get','BEGIN','actions','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','end'];U=function(){return T;};return U();}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';const SYSTEM_ACTIONS=['logs',u(0x13a),'list','check',u(0x13b),u(0x13c),'dictionaries'],RESOURCE_ACTIONS=['read','update',u(0x13d),'delete'],[login,permissionArg]=process['argv'][u(0x13e)](0x2);function z(C,N){C=C-0x13a;const r=U();let p=r[C];return p;}function expandPermissions(C){const L=u,N=C['split'](',')['map'](p=>p['trim']())['filter'](Boolean),r=new Set();for(const p of N){if(p['includes'](':')){r[L(0x13f)](p);continue;}const c=p==='system'?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const x of c){r[L(0x13f)](p+':'+x);}}return[...r];}if(!login||!permissionArg)console[u(0x140)](u(0x141)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[u(0x142)]('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(u(0x143));if(permissionArg[u(0x144)]()==='clear')await pg[u(0x142)]('DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL',[user['id']]),console['log']('Permissions\x20cleared\x20for\x20'+login);else{const permissions=expandPermissions(permissionArg),byResource=new Map();for(const permission of permissions){const [resource,action]=permission[u(0x145)](':'),actions=byResource[u(0x146)](resource)??[];actions['push'](action),byResource['set'](resource,actions);}const client=await pg['connect']();try{await client[u(0x142)](u(0x147));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[u(0x148)]??[],...actions])];await client['query'](u(0x149),[merged,user['id'],row['access_id']]);}else await client['query']('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[u(0x142)]('COMMIT');}catch(m){await client['query']('ROLLBACK');throw m;}finally{client['release']();}console['log']('Granted\x20permissions\x20for\x20'+login+':\x20'+permissions['join'](',\x20'));}}catch(Q){console['error'](Q),process['exitCode']=0x1;}finally{await pg[u(0x14a)]();}}
|
|
@@ -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,CAoK9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';import C from'./services/get-current-user.js';function z(C,N){C=C-0x1d4;const r=U();let p=r[C];return p;}import N from'./services/registration.js';import r from'./services/change-password.js';import{authSchemas}from'./schema.js';import p from'../../shared/getIP.js';import{UnauthorizedError}from'../../errors.js';function U(){const d=['GET','permissions','config','auth','redirect','cookie','maxAge','Sign\x20in','public','/api/auth/login','credentials','fcore','admin','post','/api/auth/password','Changes\x20the\x20password\x20for\x20the\x20current\x20user.','user','Terminates\x20the\x20current\x20user\x20session.','write','session','cookieName','/api/auth/user','query'];U=function(){return d;};return U();}export function authRoutes(c){return async x=>{const t=z,m=async Q=>{const F=z,u=Q['method']===F(0x1d4)?Q['query']:Q['body'],L=p(Q),T=await verifyUser({...u,'ip':L},c);T[F(0x1d5)]=await getUserPermissions(T['id'],c);const Y=T['twofa']?c[F(0x1d6)][F(0x1d7)]['twoFactorRedirect']:c['config']['auth'][F(0x1d8)];await Q['login'](T);const f=c['config']['auth']['sessionTimeout']*0x3e8*0x3c;return Q['session']?.[F(0x1d9)]&&(Q['session']['cookie'][F(0x1da)]=f),await Q['session']['save'](),await c['audit']?.['write']?.({'module':'auth','resource':'session','resourceId':Q['session']['sessionId'],'action':'login','userId':T['id'],'ipAddress':L}),{'user':{'id':T['id'],'type':T['type'],'permissions':T['permissions']},'redirectUrl':Y};};x['get']('/api/auth/login',{'schema':{'tags':['fcore','auth'],'summary':t(0x1db),'description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':t(0x1dc),'permissions':[],'querystring':authSchemas['credentials']}},m),x['post'](t(0x1dd),{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20in','description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'body':authSchemas[t(0x1de)]}},m),x['post']('/api/auth/registration',{'schema':{'tags':[t(0x1df),'auth'],'summary':'Register','description':'Creates\x20a\x20regular\x20user\x20account.','access':t(0x1e0),'permissions':['user:create'],'body':authSchemas['credentials']}},async Q=>N(Q['body'],c)),x[t(0x1e1)](t(0x1e2),{'schema':{'tags':['fcore','auth'],'summary':'Change\x20password','description':t(0x1e3),'access':'user','permissions':[],'body':authSchemas['password']}},async Q=>{const h=t;if(!Q['user'])throw new UnauthorizedError('Not\x20authorized');return await r({'userId':Q[h(0x1e4)]['id'],...Q['body']},c),{'success':!![]};}),x['post']('/api/auth/logout',{'schema':{'tags':['fcore',t(0x1d7)],'summary':'Sign\x20out','description':t(0x1e5),'access':'user','permissions':[]}},async(Q,u)=>{const D=t,L={'redirectUrl':'/'};if(!Q['user'])return L;return await c['audit']?.[D(0x1e6)]?.({'module':'auth','resource':'session','resourceId':Q['session']['sessionId'],'action':'logout','userId':Q['user']?.['id']}),await Q[D(0x1e7)]['destroy'](),u['clearCookie'](c['config']['auth'][D(0x1e8)]),Object['defineProperty'](Q,'session',{'value':null,'writable':![],'configurable':![]}),L;}),x['get'](t(0x1e9),{'schema':{'tags':['fcore',t(0x1d7)],'summary':'Get\x20current\x20user','description':'Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','access':'user','permissions':[],'querystring':authSchemas['query']}},async Q=>C({'user':Q[t(0x1e4)],'token':Q[t(0x1ea)]['token']}));};}
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Static } from "@sinclair/typebox";
|
|
5
5
|
export declare const authSchemas: {
|
|
6
|
+
query: import("@sinclair/typebox").TObject<{
|
|
7
|
+
token: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
8
|
+
}>;
|
|
6
9
|
credentials: import("@sinclair/typebox").TObject<{
|
|
7
10
|
user: import("@sinclair/typebox").TString;
|
|
8
11
|
password: import("@sinclair/typebox").TString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,WAAW;IACtB,WAAW;;;;;IAKX,QAAQ;;;;IAIR,SAAS;;;CAGV,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/auth/schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEjD,eAAO,MAAM,WAAW;IACtB,KAAK;;;IAGL,WAAW;;;;;IAKX,QAAQ;;;;IAIR,SAAS;;;CAGV,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=
|
|
1
|
+
function z(C,N){C=C-0xb8;const r=U();let p=r[C];return p;}const C=z;import{Type}from'@sinclair/typebox';function U(){const N=['Optional','String','Object'];U=function(){return N;};return U();}export const authSchemas={'query':Type['Object']({'token':Type['Optional'](Type['Boolean']())}),'credentials':Type['Object']({'user':Type['String']({'minLength':0x1,'maxLength':0x64}),'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'type':Type[C(0xb8)](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type[C(0xb9)]({'minLength':0x1,'maxLength':0x64}),'id':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type[C(0xba)]({'code':Type['String']({'minLength':0x1})})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{hashPassword}from'../../../plugins/auth/index.js';export default async function changePassword({id:C,password:N,userId:r},{pg:p}){const c=await hashPassword(N);await p['query']('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',[c,C||r,r]);}
|
|
@@ -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;
|
|
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;CAC5B,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAenC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{safeUser}from'../../utils/safe-user.js';export default async function getCurrentUser(
|
|
1
|
+
import{safeUser}from'../../utils/safe-user.js';export default async function getCurrentUser(C){const {user:N}=C;if(!N)return{};if(C['token']){const {jwtSignToken:r}=await import('../../../plugins/jwt.js'),p=await r(N);N['token']=p;}return N['resources']=[...new Set(N?.['permissions']['map'](c=>c['split'](':')[0x0]))],safeUser(N);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConflictError}from'../../../errors.js';import{hashPassword}from'../../../plugins/auth/index.js';export default async function registration({user:
|
|
1
|
+
function z(C,N){C=C-0x1a6;const r=U();let p=r[C];return p;}import{ConflictError}from'../../../errors.js';function U(){const u=['query','Login\x20is\x20already\x20in\x20use'];U=function(){return u;};return U();}import{hashPassword}from'../../../plugins/auth/index.js';export default async function registration({user:C,password:N,type:r},{pg:p}){const Q=z,c=await hashPassword(N),x=await p[Q(0x1a6)]('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',[C,c,r||'regular']),m=x['rows'][0x0];if(!m)throw new ConflictError(Q(0x1a7));return{'user':m};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{unsupported}from'../../utils/unsupported.js';
|
|
1
|
+
import{unsupported}from'../../utils/unsupported.js';export default async function verifyTwoFactor(C,N){return unsupported('Two-factor\x20provider');}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mime.d.ts","sourceRoot":"","sources":["../../../src/modules/file/mime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=z;export default new Set(['image/jpeg','image/png','image/gif','image/webp',C(0x1e6),'image/tiff','image/svg+xml',C(0x1e7),C(0x1e8),C(0x1e9),'application/msword','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.ms-excel','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.ms-powerpoint',C(0x1ea),'application/vnd.oasis.opendocument.text',C(0x1eb),'application/vnd.oasis.opendocument.presentation','text/plain',C(0x1ec),'text/markdown','application/json',C(0x1ed),C(0x1ee),'application/geo+json','application/vnd.google-earth.kml+xml','application/vnd.google-earth.kmz','application/zip','application/x-zip-compressed','application/x-7z-compressed','application/x-rar-compressed','application/vnd.rar','application/gzip',C(0x1ef),'application/x-tar','audio/mpeg','audio/wav',C(0x1f0),'audio/webm','audio/mp4','video/mp4','video/mpeg','video/webm','video/quicktime','video/x-msvideo','application/octet-stream']);function z(C,N){C=C-0x1e6;var r=U();var p=r[C];return p;}function U(){var N=['image/bmp','image/x-icon','image/avif','application/pdf','application/vnd.openxmlformats-officedocument.presentationml.presentation','application/vnd.oasis.opendocument.spreadsheet','text/csv','application/xml','text/xml','application/x-gzip','audio/ogg'];U=function(){return N;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/file/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/file/route.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAMnD,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CA8F9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fileTypeFromBuffer}from'file-type';import{getFile}from'./services/get-file.js';import{uploadFile}from'./services/upload-file.js';function U(){const h=['fcore','Get\x20file\x20by\x20token','fileDownloadQuery','verify','query','startsWith','split','replace','attachment','Uploads\x20a\x20file\x20and\x20stores\x20its\x20metadata.','filename','resource','Resize\x20file','files:read','resizeQuery','mime','image/png','Cache-Control'];U=function(){return h;};return U();}function z(C,N){C=C-0xa7;const r=U();let p=r[C];return p;}import{resizeFile}from'./services/resize-file.js';import{fileSchemas}from'./schema.js';export function fileRoutes(C){return async N=>{const Y=z;N['get']('/api/file/:token',{'schema':{'tags':[Y(0xa7),'file'],'summary':Y(0xa8),'description':'Returns\x20a\x20file\x20after\x20verifying\x20its\x20signed\x20access\x20token.','access':'public','permissions':[],'params':fileSchemas['fileToken'],'querystring':fileSchemas[Y(0xa9)]}},async(r,p)=>{const f=Y,c=C['file'][f(0xaa)](r['params']['token']),x=await getFile({'pathOrToken':c},C),m=await fileTypeFromBuffer(x),Q=m?.['mime']??'application/octet-stream',u=r[f(0xab)]['download']===!![],L=Q[f(0xac)]('image/')||Q==='application/pdf',T=c[f(0xad)]('/')['pop']()?.[f(0xae)](/[^A-Za-z0-9._-]/g,'_')??'file';return p['type'](Q),p['header']('Content-Disposition',(u||!L?f(0xaf):'inline')+';\x20filename=\x22'+T+'\x22')['header']('Cache-Control','public,\x20max-age=86400,\x20immutable'),p['send'](x);}),N['post']('/api/file/upload',{'schema':{'tags':['fcore','file'],'summary':'Upload\x20file','description':Y(0xb0),'access':'user','permissions':['files:create']}},async r=>{const F=Y,p=await r['file']();if(!p)throw new Error('File\x20is\x20required');return uploadFile({'file':p,'metadata':{'name':p[F(0xb1)],'path':p['fields']['path']?.['value'],'resource':p['fields'][F(0xb2)]?.['value'],'resourceId':p['fields']['resourceId']?.['value']},'user':r['user']},C);}),N['get']('/api/file/:token/resize',{'schema':{'tags':['fcore','file'],'summary':Y(0xb3),'description':'Returns\x20a\x20resized\x20image\x20file.','access':'user','permissions':[Y(0xb4)],'params':fileSchemas['fileToken'],'querystring':fileSchemas[Y(0xb5)]}},async(r,p)=>{const t=Y,c=await resizeFile({'pathOrToken':C['file']?.['verify'](r['params']['token']),...r['query']},C),x=await fileTypeFromBuffer(c);return p['type'](x?.[t(0xb6)]??t(0xb7)),p['header']('Content-Disposition','inline')['header'](t(0xb8),'public,\x20max-age=86400,\x20immutable'),p['send'](c);});};}
|
|
@@ -5,6 +5,9 @@ export declare const fileSchemas: {
|
|
|
5
5
|
fileToken: import("@sinclair/typebox").TObject<{
|
|
6
6
|
token: import("@sinclair/typebox").TString;
|
|
7
7
|
}>;
|
|
8
|
+
fileDownloadQuery: import("@sinclair/typebox").TObject<{
|
|
9
|
+
download: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
10
|
+
}>;
|
|
8
11
|
filePath: import("@sinclair/typebox").TObject<{
|
|
9
12
|
"*": import("@sinclair/typebox").TString;
|
|
10
13
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/file/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;IACvB,MAAM;;;IAGN,SAAS;;;IAGT,QAAQ;;;IAGR,MAAM;;;;;;;;;IASN,SAAS;;;;IAIT,WAAW;;;;;CAWX,CAAC"}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/modules/file/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;IACvB,MAAM;;;IAGN,SAAS;;;IAGT,iBAAiB;;;IAGjB,QAAQ;;;IAGR,MAAM;;;;;;;;;IASN,SAAS;;;;IAIT,WAAW;;;;;CAWX,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function U(){const N=['Object','String','Optional','Literal','outside'];U=function(){return N;};return U();}function z(C,N){C=C-0xc1;const r=U();let p=r[C];return p;}const C=z;import{Type}from'@sinclair/typebox';export const fileSchemas={'fileId':Type['Object']({'id':Type['String']({'minLength':0x1,'maxLength':0x80})}),'fileToken':Type['Object']({'token':Type['String']({'minLength':0x1,'maxLength':0x800})}),'fileDownloadQuery':Type[C(0xc1)]({'download':Type['Optional'](Type['Boolean']())}),'filePath':Type['Object']({'*':Type['String']({'minLength':0x1,'maxLength':0x400})}),'upload':Type['Object']({'file':Type['Any'](),'metadata':Type['Object']({'name':Type['Optional'](Type[C(0xc2)]({'minLength':0x1})),'path':Type['Optional'](Type['String']({'minLength':0x1})),'entityType':Type[C(0xc3)](Type['String']({'minLength':0x1})),'entityId':Type['Optional'](Type['String']({'minLength':0x1}))})}),'filePatch':Type[C(0xc1)]({'entityType':Type[C(0xc3)](Type['String']({'minLength':0x1})),'entityId':Type[C(0xc3)](Type['String']({'minLength':0x1}))}),'resizeQuery':Type[C(0xc1)]({'width':Type['Optional'](Type['Integer']({'minimum':0x1,'default':0xc8})),'height':Type[C(0xc3)](Type['Integer']({'minimum':0x1})),'fit':Type['Optional'](Type['Union']([Type['Literal']('cover'),Type[C(0xc4)]('contain'),Type['Literal']('fill'),Type['Literal']('inside'),Type['Literal'](C(0xc5))]))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError}from'../../../errors.js';
|
|
1
|
+
import{NotFoundError}from'../../../errors.js';export async function getFile(C,N){var r=z;if(!N[r(0x183)])throw new Error('empty\x20file');if(!await N['file']['exists'](C['pathOrToken']))throw new NotFoundError('File\x20not\x20found'+C['pathOrToken']);return N[r(0x183)][r(0x184)](C['pathOrToken']);}function z(C,N){C=C-0x183;var r=U();var p=r[C];return p;}function U(){var p=['file','get'];U=function(){return p;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize-file.d.ts","sourceRoot":"","sources":["../../../../src/modules/file/services/resize-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resize-file.d.ts","sourceRoot":"","sources":["../../../../src/modules/file/services/resize-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQtD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CAC3D;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,MAAM,CAAC,CAuCjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function U(){const D=['width','height','fit','cover','logs','file','File\x20not\x20found','startsWith','image/','Only\x20image\x20files\x20can\x20be\x20resized','isInteger','\x20must\x20be\x20a\x20positive\x20integer'];U=function(){return D;};return U();}function z(C,N){C=C-0x6f;const r=U();let p=r[C];return p;}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 C from'node:path';import N from'sharp';export async function resizeFile(r,p){const t=z,c=r['pathOrToken']??r['path'];if(!c)throw new ValidationError('File\x20path\x20is\x20required');const x=parseDimension(r[t(0x6f)],t(0x6f))??0xc8,m=parseDimension(r[t(0x70)],'height'),Q=createHash('sha256')['update'](c+':'+x+':'+(m??'auto')+':'+(r[t(0x71)]??t(0x72)))['digest']('hex'),u=C['resolve'](t(0x73),'resize'),L=C['join'](u,Q+'.jpg');try{return await readFile(L);}catch(F){if(F['code']!=='ENOENT')throw F;}if(!await p[t(0x74)]['exists'](c))throw new NotFoundError(t(0x75));const T=await p[t(0x74)]['get'](c),Y=await fileTypeFromBuffer(T);if(!Y?.['mime'][t(0x76)](t(0x77)))throw new ValidationError(t(0x78));const f=await N(T)['resize']({'width':x,'height':m,'fit':r[t(0x71)]??'cover'})['toBuffer']();return await mkdir(u,{'recursive':!![]}),await writeFile(L,f),f;}function parseDimension(r,p){const h=z;if(r===undefined||r==='')return undefined;const c=Number(r);if(!Number[h(0x79)](c)||c<=0x0)throw new ValidationError(p+h(0x7a));return c;}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Implements the upload file application service for the File module.
|
|
3
|
-
*/
|
|
4
1
|
import type { AppContext, User } from "../../../context.js";
|
|
2
|
+
import type { MultipartFile } from "@fastify/multipart";
|
|
5
3
|
export interface UploadFileParams {
|
|
6
4
|
user?: User;
|
|
7
|
-
file:
|
|
5
|
+
file: MultipartFile;
|
|
8
6
|
metadata: {
|
|
9
7
|
name?: string;
|
|
10
8
|
path?: string;
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
resource?: string;
|
|
10
|
+
resourceId?: string;
|
|
13
11
|
};
|
|
14
12
|
}
|
|
15
13
|
export declare function uploadFile(params: UploadFileParams, ctx: AppContext): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../../../src/modules/file/services/upload-file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../../../src/modules/file/services/upload-file.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE;QACR,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AACD,wBAAsB,UAAU,CAC9B,MAAM,EAAE,gBAAgB,EACxB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,CAqDd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(C,N){C=C-0x12a;const r=U();let p=r[C];return p;}import{fileTypeFromBuffer}from'file-type';import C from'../mime.js';import{randomUUID}from'node:crypto';function U(){const F=['metadata','replace','getFullYear','getDate','padStart','resourceId','file','put','\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20file_type,\x20size,uploaded_name,file_name,ext,created_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)\x0a\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*\x0a\x20\x20\x20\x20\x20\x20','resource','name','split','pop'];U=function(){return F;};return U();}export async function uploadFile(N,r){const f=z,p=(N[f(0x12a)]['name']??randomUUID())[f(0x12b)](/[^a-zA-Z0-9._-]/g,'_'),c=new Date(),x=String(c[f(0x12c)]())['slice'](-0x2),m=String(c['getMonth']()+0x1)['padStart'](0x2,'0'),Q=String(c[f(0x12d)]())[f(0x12e)](0x2,'0'),u=N['metadata']['path']??(N['metadata']['resource']?N['metadata']['resource']+'/'+(N['metadata'][f(0x12f)]??randomUUID())+'/'+p:null)??'uploads/'+x+'/'+m+'-'+Q+'/'+p,L=await N['file']['toBuffer'](),T=await fileTypeFromBuffer(L);if(!C['has'](N[f(0x130)]['mimetype'])&&(T?.['mime']?!C['has'](T['mime']):!![]))throw new Error('Unsupported\x20file\x20type:\x20'+N[f(0x130)]['mimetype']);await r['file'][f(0x131)](u,L);const Y=await r['pg']['query'](f(0x132),[N[f(0x12a)][f(0x133)]??null,N['metadata']['resourceId']??null,u,N[f(0x130)]['mimetype'],N['file'][f(0x130)]['bytesRead'],N['metadata'][f(0x134)],p,N['file']['mimetype'][f(0x135)]('/')[f(0x136)]()??null,N['user']?.['id']??null]);return Y['rows'][0x0];}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers HTTP routes for this FCore module and delegates operations to application services.
|
|
3
|
-
*/
|
|
4
1
|
import type { FastifyPluginAsync } from "fastify";
|
|
5
2
|
import type { AppContext } from "../../context.js";
|
|
6
3
|
export declare function resourceRoutes(ctx: AppContext): FastifyPluginAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/modules/resource/route.ts"],"names":[],"mappings":"
|
|
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;AAsBnD,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,kBAAkB,CA+RlE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const m=z;function U(){const L=['user','get','/api/resource/:resource/search','resource','Searches\x20records\x20in\x20a\x20registered\x20resource.','/api/suggest/:resource/:field','fcore','Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','suggestQuery','/api/resource/:resource/export','Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','params','/api/resource/:resource/:id','resourceIncludeQuery','post','/api/resource/:resource/:id/upload','uploadResourceFile','permissions',':update','fields','resourceIdRelation','/api/resource/:resource/:id/:relation','Delete\x20resource\x20relation'];U=function(){return L;};return U();}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';function z(C,N){C=C-0x1bf;const r=U();let p=r[C];return p;}import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=C=>C[m(0x1bf)];export function resourceRoutes(C){return async N=>{const Q=z;N[Q(0x1c0)](Q(0x1c1),{'schema':{'tags':['fcore',Q(0x1c2)],'summary':'Search\x20resource','description':Q(0x1c3),'access':'user','permissions':[],'params':resourceSchemas['resource']}},async r=>searchResource({...r['query'],...r['params'],'user':user(r)},C)),N[Q(0x1c0)](Q(0x1c4),{'schema':{'tags':[Q(0x1c5),Q(0x1c2)],'summary':'Suggest\x20resource\x20values','description':Q(0x1c6),'access':Q(0x1bf),'permissions':[],'params':resourceSchemas['resourceField'],'querystring':resourceSchemas[Q(0x1c7)]}},async r=>suggestResource({...r['query'],...r['params'],'user':user(r)},C)),N['get'](Q(0x1c8),{'schema':{'tags':['fcore',Q(0x1c2)],'summary':'Export\x20resource\x20records','description':Q(0x1c9),'access':'user','permissions':['*:read'],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async r=>exportResource({...r['query'],...r['params'],'user':user(r)},C)),N['get']('/api/resource/:resource',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas[Q(0x1c2)]}},async r=>listResources({...r['query'],...r['params'],'user':user(r)},C)),N['post']('/api/resource/:resource',{'schema':{'tags':['fcore',Q(0x1c2)],'summary':'Create\x20resource\x20record','description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resource']}},async r=>createResource({...r[Q(0x1ca)],'data':r['body'],'user':user(r)},C)),N['get'](Q(0x1cb),{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas[Q(0x1cc)]}},async r=>getResource({...r['query'],...r['params'],'user':user(r)},C)),N['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20record','description':'Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':Q(0x1bf),'permissions':[],'params':resourceSchemas['resourceId']}},async r=>updateResource({...r[Q(0x1ca)],'patch':r['body'],'user':user(r)},C)),N['delete']('/api/resource/:resource/:id',{'schema':{'tags':[Q(0x1c5),'resource'],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async r=>deleteResource({...r[Q(0x1ca)],'user':user(r)},C)),N[Q(0x1cd)](Q(0x1ce),{'schema':{'tags':[Q(0x1c5),'resource'],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':'user','permissions':[],'params':resourceSchemas[Q(0x1cf)]}},async r=>{const u=Q,p=await r['file']();if(!p)throw new Error('File\x20is\x20required');const c=r['params'][u(0x1c2)],x=r['params']['id'];if(r['user']?.['type']!=='admin'&&!r[u(0x1bf)]?.[u(0x1d0)]['includes'](c+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+c+u(0x1d1));return uploadFile({'file':p,'metadata':{'name':p['filename'],'path':p[u(0x1d2)]['path']?.['value'],'resource':c,'resourceId':x},'user':r['user']},C);}),N['get']('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20relations','description':'Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','access':'user','permissions':[],'schema':{'params':resourceSchemas[Q(0x1d3)]}}},async r=>listResourceRelation({...r['query'],...r['params'],'user':user(r)},C)),N['post'](Q(0x1d4),{'schema':{'tags':[Q(0x1c5),'resource'],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas[Q(0x1d3)]}},async r=>createResourceRelation({...r['params'],'data':r['body'],'user':user(r)},C)),N['delete']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':Q(0x1d5),'description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':Q(0x1bf),'permissions':[],'params':resourceSchemas['resourceIdRelationId']}},async r=>deleteResourceRelation({...r['params'],'user':user(r)},C)),N['put']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[Q(0x1c5),'resource'],'summary':'Update\x20resource\x20relation','description':'Updates\x20a\x20related\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas['resourceIdRelationId']}},async r=>updateResourceRelation({...r[Q(0x1ca)],'data':r['body'],'user':user(r)},C));};}
|
|
@@ -36,6 +36,9 @@ export declare const resourceSchemas: {
|
|
|
36
36
|
resource: import("@sinclair/typebox").TString;
|
|
37
37
|
id: import("@sinclair/typebox").TString;
|
|
38
38
|
}>;
|
|
39
|
+
resourceIncludeQuery: import("@sinclair/typebox").TObject<{
|
|
40
|
+
include: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
41
|
+
}>;
|
|
39
42
|
resourceIdRelation: import("@sinclair/typebox").TObject<{
|
|
40
43
|
resource: import("@sinclair/typebox").TString;
|
|
41
44
|
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,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;CAQpB,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,cAAc;;;IACd,aAAa;;;;IACb,YAAY;;;;;IAKZ,UAAU;;;;IACV,oBAAoB;;;IAGpB,kBAAkB;;;;;IAKlB,oBAAoB;;;;;;IAMpB,kBAAkB;;;;IAIlB,sBAAsB;;;;IAItB,mBAAmB;;;;;;;;CAQpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=
|
|
1
|
+
const C=z;function z(C,N){C=C-0x1cc;const r=U();let p=r[C];return p;}import{Type}from'@sinclair/typebox';function U(){const N=['Object','Optional','String','Any','Unknown'];U=function(){return N;};return U();}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[C(0x1cc)]({'name':identifier}),'resource':Type[C(0x1cc)]({'resource':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type[C(0x1cd)](Type[C(0x1ce)]()),'search':Type['Optional'](Type['String']()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[C(0x1cc)]({'include':Type['Optional'](Type[C(0x1ce)]({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'uploadResourceFile':Type['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type[C(0x1cf)](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type['Optional'](Type['Record'](Type[C(0x1ce)](),Type[C(0x1d0)]())),'sort':Type[C(0x1cd)](Type['Array'](Type['String']({'minLength':0x1}))),'search':Type['Optional'](Type[C(0x1ce)]()),'limit':Type['Optional'](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type['Integer']({'minimum':0x0})),'fields':Type[C(0x1cd)](Type['Array'](identifier))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function addNote(
|
|
1
|
+
export async function addNote(C,N){const p=await N['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[C['resource'],String(C['id']),C['body']]);return p['rows'][0x0];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function addResourceFile(
|
|
1
|
+
function z(C,N){C=C-0x9b;const r=U();let p=r[C];return p;}export async function addResourceFile(C,N){const p=z,r=await N['pg']['query'](p(0x9b),[C['resource'],String(C['id']),C[p(0x9c)],C[p(0x9d)]??null]);return r[p(0x9e)][0x0];}function U(){const c=['\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','filePath','size','rows'];U=function(){return c;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export async function createResourceRelation(
|
|
1
|
+
function z(C,N){C=C-0x64;const r=U();let p=r[C];return p;}export async function createResourceRelation(C,N){const Q=z,{resource:r,id:p,relation:c,data:x,user:m}=C;return N['resource'][Q(0x64)]({'name':r,'id':p,'relation':c,'data':x,'user':m});}function U(){const u=['createRelation'];U=function(){return u;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
export async function createResource(C,N){var r=z;return N[r(0xd3)]['create']({'name':C[r(0xd3)],'data':C[r(0xd4)],'user':C['user']});}function z(C,N){C=C-0xd3;var r=U();var p=r[C];return p;}function U(){var p=['resource','data'];U=function(){return p;};return U();}
|