@opengis/fcore 0.0.1-beta.15 → 0.0.1-beta.16

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.
Files changed (90) hide show
  1. package/dist/config.js +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/errors.js +1 -1
  4. package/dist/fastify.js +1 -1
  5. package/dist/fcore.js +1 -1
  6. package/dist/migrations/cli.js +1 -1
  7. package/dist/migrations/runner.js +1 -1
  8. package/dist/modules/auth/adduser-cli.js +1 -1
  9. package/dist/modules/auth/passwd-cli.js +1 -1
  10. package/dist/modules/auth/permission-cli.js +1 -1
  11. package/dist/modules/auth/route.js +1 -1
  12. package/dist/modules/auth/schema.js +1 -1
  13. package/dist/modules/auth/services/change-password.js +1 -1
  14. package/dist/modules/auth/services/get-current-user.js +1 -1
  15. package/dist/modules/auth/services/registration.js +1 -1
  16. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  17. package/dist/modules/file/mime.js +1 -1
  18. package/dist/modules/file/route.js +1 -1
  19. package/dist/modules/file/schema.js +1 -1
  20. package/dist/modules/file/services/get-file.js +1 -1
  21. package/dist/modules/file/services/resize-file.js +1 -1
  22. package/dist/modules/file/services/upload-file.js +1 -1
  23. package/dist/modules/resource/route.js +1 -1
  24. package/dist/modules/resource/schema.js +1 -1
  25. package/dist/modules/resource/services/add-note.js +1 -1
  26. package/dist/modules/resource/services/add-resource-file.js +1 -1
  27. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  28. package/dist/modules/resource/services/create-resource.js +1 -1
  29. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  30. package/dist/modules/resource/services/delete-resource.js +1 -1
  31. package/dist/modules/resource/services/export-resource.js +1 -1
  32. package/dist/modules/resource/services/get-resource.js +1 -1
  33. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  34. package/dist/modules/resource/services/list-resources.js +1 -1
  35. package/dist/modules/resource/services/search-resource.js +1 -1
  36. package/dist/modules/resource/services/suggest-resource.js +1 -1
  37. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  38. package/dist/modules/resource/services/update-resource.js +1 -1
  39. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  40. package/dist/modules/system/route.js +1 -1
  41. package/dist/modules/system/schema.js +1 -1
  42. package/dist/modules/system/services/check-system.js +1 -1
  43. package/dist/modules/system/services/get-access.js +1 -1
  44. package/dist/modules/system/services/get-api-list.js +1 -1
  45. package/dist/modules/system/services/get-audit-log.js +1 -1
  46. package/dist/modules/system/services/get-dictionary.js +1 -1
  47. package/dist/modules/system/services/get-system-log.js +1 -1
  48. package/dist/modules/system/services/get-system-settings.js +1 -1
  49. package/dist/modules/system/services/list-dictionaries.js +1 -1
  50. package/dist/modules/system/services/set-access.js +1 -1
  51. package/dist/modules/system/services/update-dictionary.js +1 -1
  52. package/dist/modules/system/services/update-system-settings.js +1 -1
  53. package/dist/modules/utils/require-admin.js +1 -1
  54. package/dist/modules/utils/safe-user.js +1 -1
  55. package/dist/modules/utils/unsupported.js +1 -1
  56. package/dist/plugins/audit/audit.js +1 -1
  57. package/dist/plugins/audit/services/write-audit.js +1 -1
  58. package/dist/plugins/auth/get-user-permissions.js +1 -1
  59. package/dist/plugins/auth/index.js +1 -1
  60. package/dist/plugins/auth/verifyUser.js +1 -1
  61. package/dist/plugins/dictionary.js +1 -1
  62. package/dist/plugins/file.js +1 -1
  63. package/dist/plugins/jwt.js +1 -1
  64. package/dist/plugins/logger/index.js +1 -1
  65. package/dist/plugins/logger/transport.js +1 -1
  66. package/dist/plugins/pg.js +1 -1
  67. package/dist/plugins/redis.js +1 -1
  68. package/dist/plugins/resource/resource.js +1 -1
  69. package/dist/plugins/resource/resource.registry.js +1 -1
  70. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  71. package/dist/plugins/resource/services/add-file-token.js +1 -1
  72. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  73. package/dist/plugins/resource/services/create-relation.js +1 -1
  74. package/dist/plugins/resource/services/create.js +1 -1
  75. package/dist/plugins/resource/services/delete-relation.js +1 -1
  76. package/dist/plugins/resource/services/delete.js +1 -1
  77. package/dist/plugins/resource/services/find-one.js +1 -1
  78. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  79. package/dist/plugins/resource/services/find-relation.js +1 -1
  80. package/dist/plugins/resource/services/find.js +1 -1
  81. package/dist/plugins/resource/services/update-relation.js +1 -1
  82. package/dist/plugins/resource/services/update.js +1 -1
  83. package/dist/plugins/resource/utils/auto-index.js +1 -1
  84. package/dist/plugins/resource/utils/fields.js +1 -1
  85. package/dist/plugins/resource/utils/filters.js +1 -1
  86. package/dist/plugins/resource/utils/permissions.js +1 -1
  87. package/dist/plugins/resource/utils/sort.js +1 -1
  88. package/dist/plugins/resource/utils/sql.js +1 -1
  89. package/dist/shared/getIP.js +1 -1
  90. package/package.json +1 -1
package/dist/config.js CHANGED
@@ -1 +1 @@
1
- import'dotenv/config';function t(){const Q=['development','password','split','us-east-1','x5y30KBsEKCENT04tu6549Vxx3No1ztJ2q2K8r79S59420RaZ5','true','lax','strict','logger'];t=function(){return Q;};return t();}const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function required(x){const K=process.env[x];if(!K)throw new Error('Missing\x20environment\x20variable:\x20'+x);return K;}export function loadConfig(x={}){const b=f,K={'env':process.env.NODE_ENV??b(0xb9),'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)},'storagePath':process.env.STORAGE_PATH??'./storage','redactionList':(process.env.REDACTION_LIST||b(0xba))['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[b(0xbb)](',')['map'](Z=>Z-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??b(0xbc),'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??b(0xbd),'cookieName':process.env.AUTH_COOKIE_NAME??'session_user_auth','jwtSecret':process.env.AUTH_JWT_SECRET??'0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','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||b(0xbe)),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&[b(0xbf),b(0xc0),'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{...K,...x,'logger':{...K[b(0xc1)],...x[b(0xc1)]},'pg':{...K['pg'],...x['pg']},'redis':{...K['redis'],...x['redis']},'s3':{...K['s3'],...x['s3']},'auth':{...K['auth'],...x['auth']}};}function f(x,K){x=x-0xb9;const Z=t();let b=Z[x];return b;}export{required as requireEnv};
1
+ import'dotenv/config';function S(c,N){c=c-0x1dd;const H=F();let d=H[c];return d;}const DEFAULT_LOG_RESPONSE_STATUS_CODES=[0x193,0x199,0x19d,0x19f,0x1ad];function F(){const U=['map','/log','parse','x5y30KBsEKCENT04tu6549Vxx3No1ztJ2q2K8r79S59420RaZ5','true','strict','logger','redis'];F=function(){return U;};return F();}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 d=S,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)},'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'](',')[d(0x1dd)](H=>H-0x0):DEFAULT_LOG_RESPONSE_STATUS_CODES,'directory':process.env.LOG_DIRECTORY||process['cwd']()+d(0x1de)},'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[d(0x1df)](process.env.AUTH_USER):undefined,'sessionTimeout':+(process.env.AUTH_SESSION_TIMEOUT||0x258),'secret':process.env.AUTH_SECRET??d(0x1e0),'cookieName':process.env.AUTH_COOKIE_NAME??'session_user_auth','jwtSecret':process.env.AUTH_JWT_SECRET??'0ua4b1Tz21m47z13U3EO0uN9e0WE7hqRFbcZ72cbdWqZBzemf9cAU865xan1s81TdNpUKKfF','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||d(0x1e1)),'sameSite':process.env.AUTH_COOKIE_OPTIONS_SAME_SITE&&['lax',d(0x1e2),'none']['includes'](process.env.AUTH_COOKIE_OPTIONS_SAME_SITE)?process.env.AUTH_COOKIE_OPTIONS_SAME_SITE:Boolean(process.env.AUTH_COOKIE_OPTIONS_SAME_SITE||d(0x1e1))}:{'path':'/','httpOnly':!![],'secure':![],'sameSite':!![]}}};return{...N,...c,'logger':{...N['logger'],...c[d(0x1e3)]},'pg':{...N['pg'],...c['pg']},'redis':{...N[d(0x1e4)],...c['redis']},'s3':{...N['s3'],...c['s3']},'auth':{...N['auth'],...c['auth']}};}export{required as requireEnv};
package/dist/context.js CHANGED
@@ -1 +1 @@
1
- let defaultContext;function f(x,K){x=x-0x105;const Z=t();let b=Z[x];return b;}export function setContext(x){defaultContext=x;}export function getContext(){if(!defaultContext)throw new Error('Application\x20context\x20is\x20not\x20initialized');return defaultContext;}export function createContext(x){return{...x,async 'close'(){const K=f;await Promise[K(0x105)]([x[K(0x106)]?.[K(0x107)](),x['pg']?.[K(0x108)]()]),await x['logger'][K(0x107)]();}};}function t(){const Z=['allSettled','redis','close','end'];t=function(){return Z;};return t();}
1
+ let defaultContext;function S(c,N){c=c-0x7b;const H=F();let d=H[c];return d;}export function setContext(c){defaultContext=c;}export function getContext(){if(!defaultContext)throw new Error('Application\x20context\x20is\x20not\x20initialized');return defaultContext;}function F(){const H=['redis','logger','close'];F=function(){return H;};return F();}export function createContext(c){return{...c,async 'close'(){const N=S;await Promise['allSettled']([c[N(0x7b)]?.['close'](),c['pg']?.['end']()]),await c[N(0x7c)][N(0x7d)]();}};}
package/dist/errors.js CHANGED
@@ -1 +1 @@
1
- var Q=f;export class FCoreError extends Error{['code'];[Q(0x174)];[Q(0x175)];constructor(x,K,Z=0x1f4,b){var J=Q;super(K),this['code']=x,this['statusCode']=Z,this[J(0x175)]=b,this[J(0x176)]=new.target.name;}}export class BadRequestError extends FCoreError{constructor(x,K){var a=Q;super(a(0x177),x,0x190,K);}}function f(x,K){x=x-0x174;var Z=t();var b=Z[x];return b;}export class UnauthorizedError extends FCoreError{constructor(x=Q(0x178)){super('UNAUTHORIZED',x,0x191);}}export class ForbiddenError extends FCoreError{constructor(x='Access\x20denied'){super('FORBIDDEN',x,0x193);}}export class NotFoundError extends FCoreError{constructor(x=Q(0x179)){super('NOT_FOUND',x,0x194);}}export class ConflictError extends FCoreError{constructor(x=Q(0x17a)){super('CONFLICT',x,0x199);}}export class ValidationError extends FCoreError{constructor(x,K){super('VALIDATION_ERROR',x,0x1a6,K);}}export class UnsupportedError extends FCoreError{constructor(x='Operation\x20is\x20not\x20configured'){super('UNSUPPORTED',x,0x1f5);}}function t(){var U=['statusCode','details','name','BAD_REQUEST_ERROR','Authentication\x20required','Not\x20found','Conflict'];t=function(){return U;};return t();}
1
+ var U=S;export class FCoreError extends Error{['code'];['statusCode'];[U(0x6f)];constructor(c,N,H=0x1f4,d){var e=U;super(N),this['code']=c,this[e(0x70)]=H,this['details']=d,this[e(0x71)]=new.target.name;}}function S(c,N){c=c-0x6f;var H=F();var d=H[c];return d;}export class BadRequestError extends FCoreError{constructor(c,N){super('BAD_REQUEST_ERROR',c,0x190,N);}}export class UnauthorizedError extends FCoreError{constructor(c=U(0x72)){var K=U;super(K(0x73),c,0x191);}}export class ForbiddenError extends FCoreError{constructor(c='Access\x20denied'){var m=U;super(m(0x74),c,0x193);}}export class NotFoundError extends FCoreError{constructor(c='Not\x20found'){var D=U;super(D(0x75),c,0x194);}}export class ConflictError extends FCoreError{constructor(c='Conflict'){var W=U;super(W(0x76),c,0x199);}}export class ValidationError extends FCoreError{constructor(c,N){super('VALIDATION_ERROR',c,0x1a6,N);}}export class UnsupportedError extends FCoreError{constructor(c='Operation\x20is\x20not\x20configured'){super('UNSUPPORTED',c,0x1f5);}}function F(){var p=['details','statusCode','name','Authentication\x20required','UNAUTHORIZED','FORBIDDEN','NOT_FOUND','CONFLICT'];F=function(){return p;};return F();}
package/dist/fastify.js CHANGED
@@ -1 +1 @@
1
- function t(){const W=['split','decorate','method','package','fcore','tags','public','raw','authorization','startsWith','user','Route\x20access\x20not\x20defined','length','type','setErrorHandler','statusCode','logger','debug','test','INTERNAL_ERROR','includes','auth','register','resource','buffer','disabled','@fastify/rate-limit','preHandler','log'];t=function(){return W;};return t();}import x from'fastify-plugin';import{FCoreError}from'./errors.js';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';function f(x,K){x=x-0x169;const Z=t();let b=Z[x];return b;}import{createSessionStore}from'./plugins/auth/index.js';import{ForbiddenError}from'./errors.js';import{jwtVerifyToken}from'./plugins/jwt.js';function urlencodedContentParser(K,Z,b){const z=f,Q=decodeURIComponent(Z['toString']())[z(0x169)]('&')['reduce']((J,a)=>{const P=z,[U,I]=a[P(0x169)]('=');return{...J,[U]:I};},{});b(null,Q);}export default function fcoreFastify(K,Z){return x(async b=>{const S=f;b[S(0x16a)]('ctx',K);const {config:Q}=K,J=new Map();b['addHook']('onRoute',U=>{const k=S,I=U['schema'],Y=Array['isArray'](U[k(0x16b)])?U['method']:[U['method']];for(const w of Y){if(w==='HEAD')continue;const C={'method':w,'endpoint':U['url'],'package':I?.[k(0x16c)]??k(0x16d),'tags':I?.[k(0x16e)]??[],'summary':I?.['summary']??'','description':I?.['description']??'','access':I?.['access']??k(0x16f),'permissions':I?.['permissions']??[]};J['set'](w+'\x20'+U['url'],C);}}),b['addHook']('preHandler',async U=>{const y=S;if(U['routeOptions']['url']==='*')return!![];const I=J['get'](U['method']+'\x20'+U['routeOptions']['url']),Y=U[y(0x170)]['headers']?.[y(0x171)],w=Y?.[y(0x172)]('Bearer\x20')?Y['slice'](0x7):null,C=U[y(0x173)]??(w?await jwtVerifyToken(w):null);!U['user']&&w&&process.env.AUTH_JWT_SECRET&&(U[y(0x173)]=await jwtVerifyToken(w));if(!I?.['access'])throw new Error(y(0x174));if(I['access']==='public')return!![];if(!C)throw new ForbiddenError('User\x20required');if(I['access']==='user'&&!I['permissions']?.[y(0x175)])return!![];if(C[y(0x176)]=='admin')return!![];if(I['access']==='admin')throw new ForbiddenError('Admin\x20access\x20required');for(const V of I['permissions']){if(!C['permissions']?.['includes'](V))throw new ForbiddenError('Missing\x20permission:\x20'+V);}return!![];}),await createSessionStore(b,K),await b['register'](import('@fastify/multipart'),{'limits':{'fileSize':Q['maxFileSize']*0x400*0x400}}),b[S(0x177)]((U,I,Y)=>{const l=S;if(U instanceof FCoreError||U['code']==='FST_ERR_VALIDATION'||U['statusCode']<0x1f4)return U[l(0x178)]<0x1f4&&K['logger']['warn'](U),Y['code'](U['statusCode'])['send']({'error':U['code'],'message':U['message'],'details':U['details']});return K[l(0x179)]['error'](U),(Q[l(0x17a)]||process.env.NODE_ENV===l(0x17b)||process.env.VITEST)&&console['error'](U),Y['code'](0x1f4)['send']({'error':l(0x17c),'message':'Internal\x20server\x20error'});});const a=U=>!Z||Z[S(0x17d)](U);if(a(S(0x17e)))await b[S(0x17f)](authRoutes(K));if(a(S(0x180)))await b['register'](resourceRoutes(K));if(a('file'))await b['register'](fileRoutes(K));if(a('system'))await b[S(0x17f)](systemRoutes(K,J));b['addContentTypeParser']('application/x-www-form-urlencoded',{'parseAs':S(0x181)},urlencodedContentParser),!Q['rateLimit']?.[S(0x182)]?b['register'](import(S(0x183)),{'max':Q['rateLimit']?.['max']||0x64,'timeWindow':Q['rateLimit']?.['timeWindow']||0xea60,'hook':S(0x184),'global':!![],'keyGenerator':U=>(U[S(0x173)]?.['id']||U['ip'])+'-'+U['raw']['url']['split']('?')[0x0]}):console[S(0x185)]('⚠️\x20rate\x20limit\x20is\x20disabled');});};
1
+ import c from'fastify-plugin';function F(){const T=['decorate','schema','isArray','method','package','summary','addHook','preHandler','url','get','routeOptions','headers','authorization','startsWith','Bearer\x20','slice','user','access','Admin\x20access\x20required','permissions','includes','@fastify/multipart','setErrorHandler','code','FST_ERR_VALIDATION','statusCode','logger','error','INTERNAL_ERROR','auth','addContentTypeParser','buffer','rateLimit','register','@fastify/rate-limit','raw'];F=function(){return T;};return F();}import{FCoreError}from'./errors.js';function S(c,N){c=c-0x151;const H=F();let d=H[c];return d;}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';import{jwtVerifyToken}from'./plugins/jwt.js';function urlencodedContentParser(N,H,d){const U=decodeURIComponent(H['toString']())['split']('&')['reduce']((e,K)=>{const [m,D]=K['split']('=');return{...e,[m]:D};},{});d(null,U);}export default function fcoreFastify(N,H){return c(async d=>{const r=S;d[r(0x151)]('ctx',N);const {config:U}=N,e=new Map();d['addHook']('onRoute',m=>{const w=r,D=m[w(0x152)],W=Array[w(0x153)](m[w(0x154)])?m['method']:[m['method']];for(const p of W){if(p==='HEAD')continue;const a={'method':p,'endpoint':m['url'],'package':D?.[w(0x155)]??'fcore','tags':D?.['tags']??[],'summary':D?.[w(0x156)]??'','description':D?.['description']??'','access':D?.['access']??'public','permissions':D?.['permissions']??[]};e['set'](p+'\x20'+m['url'],a);}}),d[r(0x157)](r(0x158),async m=>{const x=r;if(m['routeOptions'][x(0x159)]==='*')return!![];const D=e[x(0x15a)](m[x(0x154)]+'\x20'+m[x(0x15b)]['url']),W=m['raw'][x(0x15c)]?.[x(0x15d)],p=W?.[x(0x15e)](x(0x15f))?W[x(0x160)](0x7):null,a=m[x(0x161)]??(p?await jwtVerifyToken(p):null);!m['user']&&p&&process.env.AUTH_JWT_SECRET&&(m['user']=await jwtVerifyToken(p));if(!D?.[x(0x162)])throw new Error('Route\x20access\x20not\x20defined');if(D[x(0x162)]==='public')return!![];if(!a)throw new ForbiddenError('User\x20required');if(D['access']==='user'&&!D['permissions']?.['length'])return!![];if(a['type']=='admin')return!![];if(D['access']==='admin')throw new ForbiddenError(x(0x163));for(const I of D[x(0x164)]){if(!a['permissions']?.[x(0x165)](I))throw new ForbiddenError('Missing\x20permission:\x20'+I);}return!![];}),await createSessionStore(d,N),await d['register'](import(r(0x166)),{'limits':{'fileSize':U['maxFileSize']*0x400*0x400}}),d[r(0x167)]((m,D,W)=>{const V=r;if(m instanceof FCoreError||m[V(0x168)]===V(0x169)||m['statusCode']<0x1f4)return m[V(0x16a)]<0x1f4&&N['logger']['warn'](m),W['code'](m['statusCode'])['send']({'error':m[V(0x168)],'message':m['message'],'details':m['details']});return N[V(0x16b)][V(0x16c)](m),(U['debug']||process.env.NODE_ENV==='test'||process.env.VITEST)&&console[V(0x16c)](m),W['code'](0x1f4)['send']({'error':V(0x16d),'message':'Internal\x20server\x20error'});});const K=m=>!H||H['includes'](m);if(K(r(0x16e)))await d['register'](authRoutes(N));if(K('resource'))await d['register'](resourceRoutes(N));if(K('file'))await d['register'](fileRoutes(N));if(K('system'))await d['register'](systemRoutes(N,e));d[r(0x16f)]('application/x-www-form-urlencoded',{'parseAs':r(0x170)},urlencodedContentParser),!U[r(0x171)]?.['disabled']?d[r(0x172)](import(r(0x173)),{'max':U['rateLimit']?.['max']||0x64,'timeWindow':U['rateLimit']?.['timeWindow']||0xea60,'hook':r(0x158),'global':!![],'keyGenerator':m=>(m[r(0x161)]?.['id']||m['ip'])+'-'+m[r(0x174)][r(0x159)]['split']('?')[0x0]}):console['log']('⚠️\x20rate\x20limit\x20is\x20disabled');});};
package/dist/fcore.js CHANGED
@@ -1 +1 @@
1
- import{loadConfig}from'./config.js';import{createContext,setContext}from'./context.js';function t(){const C=['config','dictionaries','resources'];t=function(){return C;};return t();}import{createAudit,createDatabase,createDictionary,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';function f(x,K){x=x-0x1bd;const Z=t();let b=Z[x];return b;}export async function createFCore(x={}){const w=f,K=loadConfig(x[w(0x1bd)]),Z=createRedis(K['redis']),b=createLogger(),Q=createDatabase(K['pg']),J=createFileS3({'endpoint':K['s3']['endpoint'],'region':K['s3']['region'],'bucket':K['s3']['bucket'],'accessKey':K['s3']['accessKey'],'secretKey':K['s3']['secretKey'],'folder':K['s3']['folder'],'forcePathStyle':K['s3']['forcePathStyle'],'tokenSecret':K['s3']['tokenSecret'],'tokenTtl':K['s3']['tokenTtl']}),a=createAudit({'pg':Q,'logger':b}),U=createDictionary({'pg':Q,'dictionaries':x[w(0x1be)]}),I=createResource({'pg':Q,'logger':b,'audit':a,'dictionary':U,'file':J});x['resources']?.['length']&&I['register'](x[w(0x1bf)]);const Y=createContext({'config':K,'logger':b,'redis':Z,'pg':Q,'file':J,'resource':I,'audit':a,'dictionary':U});return setContext(Y),Y;}
1
+ import{loadConfig}from'./config.js';function S(c,N){c=c-0x169;const H=F();let d=H[c];return d;}import{createContext,setContext}from'./context.js';function F(){const a=['redis','region','accessKey','tokenSecret','tokenTtl','dictionaries','length'];F=function(){return a;};return F();}import{createAudit,createDatabase,createDictionary,createFileS3,createLogger,createRedis,createResource}from'./plugins/index.js';export async function createFCore(c={}){const p=S,N=loadConfig(c['config']),H=createRedis(N[p(0x169)]),d=createLogger(),U=createDatabase(N['pg']),e=createFileS3({'endpoint':N['s3']['endpoint'],'region':N['s3'][p(0x16a)],'bucket':N['s3']['bucket'],'accessKey':N['s3'][p(0x16b)],'secretKey':N['s3']['secretKey'],'folder':N['s3']['folder'],'forcePathStyle':N['s3']['forcePathStyle'],'tokenSecret':N['s3'][p(0x16c)],'tokenTtl':N['s3'][p(0x16d)]}),K=createAudit({'pg':U,'logger':d}),m=createDictionary({'pg':U,'dictionaries':c[p(0x16e)]}),D=createResource({'pg':U,'logger':d,'audit':K,'dictionary':m,'file':e});c['resources']?.[p(0x16f)]&&D['register'](c['resources']);const W=createContext({'config':N,'logger':d,'redis':H,'pg':U,'file':e,'resource':D,'audit':K,'dictionary':m});return setContext(W),W;}
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const K=f;import{runMigrations}from'./runner.js';function t(){const Z=['Loaded\x20configuration:','OK\x20\x20','SKIP','file'];t=function(){return Z;};return t();}import{loadConfig}from'../config.js';function f(x,K){x=x-0x9b;const Z=t();let b=Z[x];return b;}try{const config=loadConfig();console['log'](K(0x9b),config['pg']);for(const r of await runMigrations({'database':config['pg']}))console['log']((r['status']==='run'?K(0x9c):K(0x9d))+'\x20'+r[K(0x9e)]);}catch(x){console['error'](x),process['exitCode']=0x1;}
2
+ function S(c,N){c=c-0xbe;const H=F();let d=H[c];return d;}const N=S;import{runMigrations}from'./runner.js';import{loadConfig}from'../config.js';function F(){const H=['SKIP','file','exitCode'];F=function(){return H;};return F();}try{const config=loadConfig();console['log']('Loaded\x20configuration:',config['pg']);for(const r of await runMigrations({'database':config['pg']}))console['log']((r['status']==='run'?'OK\x20\x20':N(0xbe))+'\x20'+r[N(0xbf)]);}catch(c){console['error'](c),process[N(0xc0)]=0x1;}
@@ -1 +1 @@
1
- import x from'node:fs/promises';import K from'node:path';import{createDatabase}from'../plugins/pg.js';function f(x,K){x=x-0x157;const Z=t();let b=Z[x];return b;}function t(){const k=['resolve','\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','join','query','BEGIN','ROLLBACK','slice','username'];t=function(){return k;};return t();}export async function runMigrations(Z={}){const P=f,b=K[P(0x157)](Z['dir']??'migrations'),Q=Z['database']??databaseFromUrl(Z['databaseUrl']??process.env.DATABASE_URL);if(!Q)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const J=createDatabase(Q);if(!J)throw new Error('empty\x20pg');const a=[];try{await J['query'](P(0x158));const U=await J['query']('SELECT\x20version\x20FROM\x20schema_migrations'),I=new Set(U['rows']['map'](w=>w['version'])),Y=(await x['readdir'](b))['filter'](w=>w['endsWith']('.sql'))['sort']();for(const w of Y){if(I['has'](w)){a['push']({'file':w,'status':'skip'});continue;}const C=await x['readFile'](K[P(0x159)](b,w),'utf8'),V=await J['connect']();try{await V[P(0x15a)](P(0x15b)),await V['query'](C),await V[P(0x15a)]('INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)',[w]),await V[P(0x15a)]('COMMIT');}catch(z){await V[P(0x15a)](P(0x15c));throw z;}finally{V['release']();}a['push']({'file':w,'status':'run'});}return a;}finally{await J['end']();}}function databaseFromUrl(Z){const S=f;if(!Z)return undefined;const b=new URL(Z);return{'host':b['hostname'],'port':Number(b['port']||0x1538),'database':b['pathname'][S(0x15d)](0x1),'user':decodeURIComponent(b[S(0x15e)]),'password':decodeURIComponent(b['password'])};}
1
+ function S(c,N){c=c-0x96;const H=F();let d=H[c];return d;}import c from'node:fs/promises';import N from'node:path';import{createDatabase}from'../plugins/pg.js';function F(){const V=['databaseUrl','query','SELECT\x20version\x20FROM\x20schema_migrations','readdir','filter','sort','run','port','username','password'];F=function(){return V;};return F();}export async function runMigrations(H={}){const w=S,d=N['resolve'](H['dir']??'migrations'),U=H['database']??databaseFromUrl(H[w(0x96)]??process.env.DATABASE_URL);if(!U)throw new Error('DATABASE_URL\x20or\x20database\x20config\x20is\x20required');const e=createDatabase(U);if(!e)throw new Error('empty\x20pg');const K=[];try{await e[w(0x97)]('\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 m=await e['query'](w(0x98)),D=new Set(m['rows']['map'](p=>p['version'])),W=(await c[w(0x99)](d))[w(0x9a)](p=>p['endsWith']('.sql'))[w(0x9b)]();for(const p of W){if(D['has'](p)){K['push']({'file':p,'status':'skip'});continue;}const a=await c['readFile'](N['join'](d,p),'utf8'),I=await e['connect']();try{await I['query']('BEGIN'),await I['query'](a),await I['query']('INSERT\x20INTO\x20schema_migrations(version)\x20VALUES\x20($1)',[p]),await I['query']('COMMIT');}catch(r){await I['query']('ROLLBACK');throw r;}finally{I['release']();}K['push']({'file':p,'status':w(0x9c)});}return K;}finally{await e['end']();}}function databaseFromUrl(H){const x=S;if(!H)return undefined;const d=new URL(H);return{'host':d['hostname'],'port':Number(d[x(0x9d)]||0x1538),'database':d['pathname']['slice'](0x1),'user':decodeURIComponent(d[x(0x9e)]),'password':decodeURIComponent(d[x(0x9f)])};}
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const Z=f;function t(){const b=['slice','Usage:\x20fcore-registration\x20<login>\x20<password>\x20[type]','exitCode','error'];t=function(){return b;};return t();}function f(x,K){x=x-0x128;const Z=t();let b=Z[x];return b;}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';import x from'./services/registration.js';const [user,password,type]=process['argv'][Z(0x128)](0x2);if(!user||!password)console['error'](Z(0x129)),process[Z(0x12a)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const {user:data}=await x({'user':user,'password':password,'type':type},{'pg':pg});console['log']('Registered\x20user\x20'+data['id']+'\x20('+data['type']+')');}catch(K){console[Z(0x12b)](K),process['exitCode']=0x1;}finally{await pg['end']();}}
2
+ const H=S;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';function F(){const d=['exitCode','Registered\x20user\x20','type'];F=function(){return d;};return F();}import c from'./services/registration.js';const [user,password,type]=process['argv']['slice'](0x2);function S(c,N){c=c-0xb1;const H=F();let d=H[c];return d;}if(!user||!password)console['error']('Usage:\x20fcore-registration\x20<login>\x20<password>\x20[type]'),process[H(0xb1)]=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const {user:data}=await c({'user':user,'password':password,'type':type},{'pg':pg});console['log'](H(0xb2)+data['id']+'\x20('+data[H(0xb3)]+')');}catch(N){console['error'](N),process[H(0xb1)]=0x1;}finally{await pg['end']();}}
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const Z=f;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';import x from'./services/change-password.js';function t(){const b=['argv','slice','SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201','exitCode','end'];t=function(){return b;};return t();}const [login,password]=process[Z(0x6e)][Z(0x6f)](0x2);function f(x,K){x=x-0x6e;const Z=t();let b=Z[x];return b;}if(!login||!password)console['error']('Usage:\x20fcore-password\x20<login>\x20<password>'),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg['query'](Z(0x70),[login]),user=result['rows'][0x0];if(!user)throw new Error('User\x20not\x20found');await x({'userId':user['id'],'password':password},{'pg':pg}),console['log']('Password\x20changed\x20for\x20'+login);}catch(K){console['error'](K),process[Z(0x71)]=0x1;}finally{await pg[Z(0x72)]();}}
2
+ const H=S;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';import c from'./services/change-password.js';function F(){const d=['slice','error','query','rows','log'];F=function(){return d;};return F();}const [login,password]=process['argv'][H(0x15c)](0x2);function S(c,N){c=c-0x15c;const H=F();let d=H[c];return d;}if(!login||!password)console[H(0x15d)]('Usage:\x20fcore-password\x20<login>\x20<password>'),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[H(0x15e)]('SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201',[login]),user=result[H(0x15f)][0x0];if(!user)throw new Error('User\x20not\x20found');await c({'userId':user['id'],'password':password},{'pg':pg}),console[H(0x160)]('Password\x20changed\x20for\x20'+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 I=f;function t(){const w=['check','read','update','create','delete','add','Usage:\x20fcore-permission\x20<login>\x20<system|resource|resource:action[,...]|clear>','query','rows','User\x20not\x20found','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','COMMIT','Granted\x20permissions\x20for\x20'];t=function(){return w;};return t();}import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';const SYSTEM_ACTIONS=['logs','audit','list',I(0xe1),'access','settings','dictionaries'],RESOURCE_ACTIONS=[I(0xe2),I(0xe3),I(0xe4),I(0xe5)],[login,permissionArg]=process['argv']['slice'](0x2);function expandPermissions(x){const Y=I,K=x['split'](',')['map'](b=>b['trim']())['filter'](Boolean),Z=new Set();for(const b of K){if(b['includes'](':')){Z['add'](b);continue;}const Q=b==='system'?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const J of Q){Z[Y(0xe6)](b+':'+J);}}return[...Z];}function f(x,K){x=x-0xe1;const Z=t();let b=Z[x];return b;}if(!login||!permissionArg)console['error'](I(0xe7)),process['exitCode']=0x1;else{const pg=createDatabase(loadConfig()['pg']);try{const result=await pg[I(0xe8)]('SELECT\x20uid\x20AS\x20id\x20FROM\x20admin.users\x20WHERE\x20$1\x20IN\x20(login,\x20email,\x20phone)\x20LIMIT\x201',[login]),user=result[I(0xe9)][0x0];if(!user)throw new Error(I(0xea));if(permissionArg['trim']()==='clear')await pg['query']('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['split'](':'),actions=byResource['get'](resource)??[];actions['push'](action),byResource['set'](resource,actions);}const client=await pg['connect']();try{await client['query']('BEGIN');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'](I(0xeb),[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['query'](I(0xec));}catch(a){await client['query']('ROLLBACK');throw a;}finally{client['release']();}console['log'](I(0xed)+login+':\x20'+permissions['join'](',\x20'));}}catch(U){console['error'](U),process['exitCode']=0x1;}finally{await pg['end']();}}
2
+ function S(c,N){c=c-0x17c;const H=F();let d=H[c];return d;}const D=S;import{loadConfig}from'../../config.js';import{createDatabase}from'../../plugins/pg.js';const SYSTEM_ACTIONS=['logs',D(0x17c),'list','check','access','settings','dictionaries'],RESOURCE_ACTIONS=['read','update','create','delete'],[login,permissionArg]=process[D(0x17d)]['slice'](0x2);function expandPermissions(c){const W=D,N=c['split'](',')['map'](d=>d['trim']())['filter'](Boolean),H=new Set();for(const d of N){if(d[W(0x17e)](':')){H['add'](d);continue;}const U=d==='system'?SYSTEM_ACTIONS:RESOURCE_ACTIONS;for(const e of U){H['add'](d+':'+e);}}return[...H];}function F(){const p=['audit','argv','includes','DELETE\x20FROM\x20admin.role_access\x20WHERE\x20user_uid\x20=\x20$1\x20AND\x20role_id\x20IS\x20NULL','query','rows','access_id','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)','log'];F=function(){return p;};return F();}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['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');if(permissionArg['trim']()==='clear')await pg['query'](D(0x17f),[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['split'](':'),actions=byResource['get'](resource)??[];actions['push'](action),byResource['set'](resource,actions);}const client=await pg['connect']();try{await client['query']('BEGIN');for(const [resource,actions]of byResource){const existing=await client[D(0x180)]('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[D(0x181)][0x0];if(row){const merged=[...new Set([...row['actions']??[],...actions])];await client['query']('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',[merged,user['id'],row[D(0x182)]]);}else await client['query'](D(0x183),[resource,actions,user['id'],user['id']]);}await client['query']('COMMIT');}catch(K){await client[D(0x180)]('ROLLBACK');throw K;}finally{client['release']();}console[D(0x184)]('Granted\x20permissions\x20for\x20'+login+':\x20'+permissions['join'](',\x20'));}}catch(m){console['error'](m),process['exitCode']=0x1;}finally{await pg['end']();}}
@@ -1 +1 @@
1
- import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';import x from'./services/get-current-user.js';function f(x,K){x=x-0xbf;const Z=t();let b=Z[x];return b;}import K from'./services/registration.js';import Z from'./services/change-password.js';import{authSchemas}from'./schema.js';import b from'../../shared/getIP.js';function t(){const k=['method','twofa','config','auth','twoFactorRedirect','login','sessionTimeout','maxAge','Sign\x20in','public','/api/auth/login','post','user:create','credentials','body','user','Terminates\x20the\x20current\x20user\x20session.','audit','cookieName','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','query'];t=function(){return k;};return t();}import{UnauthorizedError}from'../../errors.js';export function authRoutes(Q){return async J=>{const P=f,a=async U=>{const z=f,I=U[z(0xbf)]==='GET'?U['query']:U['body'],Y=b(U),w=await verifyUser({...I,'ip':Y},Q);w['permissions']=await getUserPermissions(w['id'],Q);const C=w[z(0xc0)]?Q[z(0xc1)][z(0xc2)][z(0xc3)]:Q['config'][z(0xc2)]['redirect'];await U[z(0xc4)](w);const V=Q['config']['auth'][z(0xc5)]*0x3e8*0x3c;return U['session']?.['cookie']&&(U['session']['cookie'][z(0xc6)]=V),await U['session']['save'](),await Q['audit']?.['write']?.({'module':'auth','resource':'session','resourceId':U['session']['sessionId'],'action':'login','userId':w['id'],'ipAddress':Y}),{'user':{'id':w['id'],'type':w['type'],'permissions':w['permissions']},'redirectUrl':C};};J['get']('/api/auth/login',{'schema':{'tags':['fcore','auth'],'summary':P(0xc7),'description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':P(0xc8),'permissions':[],'querystring':authSchemas['credentials']}},a),J['post'](P(0xc9),{'schema':{'tags':['fcore',P(0xc2)],'summary':'Sign\x20in','description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':P(0xc8),'permissions':[],'body':authSchemas['credentials']}},a),J[P(0xca)]('/api/auth/registration',{'schema':{'tags':['fcore','auth'],'summary':'Register','description':'Creates\x20a\x20regular\x20user\x20account.','access':'admin','permissions':[P(0xcb)],'body':authSchemas[P(0xcc)]}},async U=>K(U[P(0xcd)],Q)),J['post']('/api/auth/password',{'schema':{'tags':['fcore','auth'],'summary':'Change\x20password','description':'Changes\x20the\x20password\x20for\x20the\x20current\x20user.','access':P(0xce),'permissions':[],'body':authSchemas['password']}},async U=>{if(!U['user'])throw new UnauthorizedError('Not\x20authorized');return await Z({'userId':U['user']['id'],...U['body']},Q),{'success':!![]};}),J['post']('/api/auth/logout',{'schema':{'tags':['fcore','auth'],'summary':'Sign\x20out','description':P(0xcf),'access':P(0xce),'permissions':[]}},async(U,I)=>{const S=P,Y={'redirectUrl':'/'};if(!U['user'])return Y;return await Q[S(0xd0)]?.['write']?.({'module':S(0xc2),'resource':'session','resourceId':U['session']['sessionId'],'action':'logout','userId':U['user']?.['id']}),await U['session']['destroy'](),I['clearCookie'](Q['config']['auth'][S(0xd1)]),Object['defineProperty'](U,'session',{'value':null,'writable':![],'configurable':![]}),Y;}),J['get']('/api/auth/user',{'schema':{'tags':['fcore','auth'],'summary':'Get\x20current\x20user','description':P(0xd2),'access':P(0xce),'permissions':[],'querystring':authSchemas['query']}},async U=>x({'user':U[P(0xce)],'token':U[P(0xd3)]['token']}));};}
1
+ import{getUserPermissions,verifyUser}from'../../plugins/auth/index.js';import c from'./services/get-current-user.js';import N from'./services/registration.js';import H from'./services/change-password.js';import{authSchemas}from'./schema.js';function F(){const T=['method','GET','query','redirect','login','sessionTimeout','session','save','permissions','auth','Sign\x20in','credentials','/api/auth/login','fcore','Register','admin','/api/auth/password','Changes\x20the\x20password\x20for\x20the\x20current\x20user.','password','user','body','post','/api/auth/logout','Sign\x20out','logout','get','Returns\x20the\x20authenticated\x20user\x27s\x20safe\x20profile.','token'];F=function(){return T;};return F();}import d from'../../shared/getIP.js';function S(c,N){c=c-0x16f;const H=F();let d=H[c];return d;}import{UnauthorizedError}from'../../errors.js';export function authRoutes(U){return async e=>{const w=S,K=async m=>{const r=S,D=m[r(0x16f)]===r(0x170)?m[r(0x171)]:m['body'],W=d(m),p=await verifyUser({...D,'ip':W},U);p['permissions']=await getUserPermissions(p['id'],U);const a=p['twofa']?U['config']['auth']['twoFactorRedirect']:U['config']['auth'][r(0x172)];await m[r(0x173)](p);const I=U['config']['auth'][r(0x174)]*0x3e8*0x3c;return m['session']?.['cookie']&&(m[r(0x175)]['cookie']['maxAge']=I),await m['session'][r(0x176)](),await U['audit']?.['write']?.({'module':'auth','resource':r(0x175),'resourceId':m['session']['sessionId'],'action':'login','userId':p['id'],'ipAddress':W}),{'user':{'id':p['id'],'type':p['type'],'permissions':p[r(0x177)]},'redirectUrl':a};};e['get']('/api/auth/login',{'schema':{'tags':['fcore',w(0x178)],'summary':w(0x179),'description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'querystring':authSchemas[w(0x17a)]}},K),e['post'](w(0x17b),{'schema':{'tags':[w(0x17c),w(0x178)],'summary':'Sign\x20in','description':'Authenticates\x20a\x20user\x20and\x20returns\x20a\x20bearer\x20access\x20token.','access':'public','permissions':[],'body':authSchemas['credentials']}},K),e['post']('/api/auth/registration',{'schema':{'tags':['fcore','auth'],'summary':w(0x17d),'description':'Creates\x20a\x20regular\x20user\x20account.','access':w(0x17e),'permissions':['user:create'],'body':authSchemas['credentials']}},async m=>N(m['body'],U)),e['post'](w(0x17f),{'schema':{'tags':['fcore','auth'],'summary':'Change\x20password','description':w(0x180),'access':'user','permissions':[],'body':authSchemas[w(0x181)]}},async m=>{const x=w;if(!m['user'])throw new UnauthorizedError('Not\x20authorized');return await H({'userId':m[x(0x182)]['id'],...m[x(0x183)]},U),{'success':!![]};}),e[w(0x184)](w(0x185),{'schema':{'tags':['fcore','auth'],'summary':w(0x186),'description':'Terminates\x20the\x20current\x20user\x20session.','access':w(0x182),'permissions':[]}},async(m,D)=>{const V=w,W={'redirectUrl':'/'};if(!m[V(0x182)])return W;return await U['audit']?.['write']?.({'module':'auth','resource':'session','resourceId':m['session']['sessionId'],'action':V(0x187),'userId':m[V(0x182)]?.['id']}),await m['session']['destroy'](),D['clearCookie'](U['config'][V(0x178)]['cookieName']),Object['defineProperty'](m,'session',{'value':null,'writable':![],'configurable':![]}),W;}),e[w(0x188)]('/api/auth/user',{'schema':{'tags':[w(0x17c),'auth'],'summary':'Get\x20current\x20user','description':w(0x189),'access':'user','permissions':[],'querystring':authSchemas[w(0x171)]}},async m=>c({'user':m['user'],'token':m[w(0x171)][w(0x18a)]}));};}
@@ -1 +1 @@
1
- const x=f;import{Type}from'@sinclair/typebox';export const authSchemas={'query':Type['Object']({'token':Type[x(0x168)](Type[x(0x169)]())}),'credentials':Type['Object']({'user':Type['String']({'minLength':0x1,'maxLength':0x64}),'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'type':Type[x(0x168)](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'id':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type['Object']({'code':Type['String']({'minLength':0x1})})};function f(x,K){x=x-0x168;const Z=t();let b=Z[x];return b;}function t(){const K=['Optional','Boolean'];t=function(){return K;};return t();}
1
+ const c=S;function F(){const N=['Optional','String'];F=function(){return N;};return F();}function S(c,N){c=c-0x7c;const H=F();let d=H[c];return d;}import{Type}from'@sinclair/typebox';export const authSchemas={'query':Type['Object']({'token':Type[c(0x7c)](Type['Boolean']())}),'credentials':Type['Object']({'user':Type['String']({'minLength':0x1,'maxLength':0x64}),'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'type':Type[c(0x7c)](Type[c(0x7d)]({'minLength':0x1,'maxLength':0x64}))}),'password':Type['Object']({'password':Type['String']({'minLength':0x1,'maxLength':0x64}),'id':Type['Optional'](Type['String']({'minLength':0x1,'maxLength':0x64}))}),'twoFactor':Type['Object']({'code':Type[c(0x7d)]({'minLength':0x1})})};
@@ -1 +1 @@
1
- function f(x,K){x=x-0x1a0;const Z=t();let b=Z[x];return b;}function t(){const a=['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'];t=function(){return a;};return t();}import{hashPassword}from'../../../plugins/auth/index.js';export default async function changePassword({id:x,password:K,userId:Z},{pg:b}){const J=f,Q=await hashPassword(K);await b[J(0x1a0)](J(0x1a1),[Q,x||Z,Z]);}
1
+ import{hashPassword}from'../../../plugins/auth/index.js';export default async function changePassword({id:c,password:N,userId:H},{pg:d}){const U=await hashPassword(N);await d['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',[U,c||H,H]);}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x1de;const Z=t();let b=Z[x];return b;}import{safeUser}from'../../utils/safe-user.js';function t(){const a=['resources','permissions','map'];t=function(){return a;};return t();}export default async function getCurrentUser(x){const J=f,{user:K}=x;if(!K)return{};if(x['token']){const {jwtSignToken:Z}=await import('../../../plugins/jwt.js'),b=await Z(K);K['token']=b;}return K[J(0x1de)]=[...new Set(K?.[J(0x1df)][J(0x1e0)](Q=>Q['split'](':')[0x0]))],safeUser(K);}
1
+ function S(c,N){c=c-0x1cc;const H=F();let d=H[c];return d;}import{safeUser}from'../../utils/safe-user.js';export default async function getCurrentUser(c){const e=S,{user:N}=c;if(!N)return{};if(c['token']){const {jwtSignToken:H}=await import(e(0x1cc)),d=await H(N);N[e(0x1cd)]=d;}return N['resources']=[...new Set(N?.[e(0x1ce)]['map'](U=>U['split'](':')[0x0]))],safeUser(N);}function F(){const K=['../../../plugins/jwt.js','token','permissions'];F=function(){return K;};return F();}
@@ -1 +1 @@
1
- function f(x,K){x=x-0xbf;const Z=t();let b=Z[x];return b;}import{ConflictError}from'../../../errors.js';import{hashPassword}from'../../../plugins/auth/index.js';function t(){const I=['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','regular','rows'];t=function(){return I;};return t();}export default async function registration({user:x,password:K,type:Z},{pg:b}){const U=f,Q=await hashPassword(K),J=await b['query'](U(0xbf),[x,Q,Z||U(0xc0)]),a=J[U(0xc1)][0x0];if(!a)throw new ConflictError('Login\x20is\x20already\x20in\x20use');return{'user':a};}
1
+ function S(c,N){c=c-0xd6;const H=F();let d=H[c];return d;}import{ConflictError}from'../../../errors.js';function F(){const D=['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','Login\x20is\x20already\x20in\x20use'];F=function(){return D;};return F();}import{hashPassword}from'../../../plugins/auth/index.js';export default async function registration({user:c,password:N,type:H},{pg:d}){const m=S,U=await hashPassword(N),e=await d['query'](m(0xd6),[c,U,H||'regular']),K=e['rows'][0x0];if(!K)throw new ConflictError(m(0xd7));return{'user':K};}
@@ -1 +1 @@
1
- import{unsupported}from'../../utils/unsupported.js';function f(x,K){x=x-0xac;var Z=t();var b=Z[x];return b;}export default async function verifyTwoFactor(x,K){var Z=f;return unsupported(Z(0xac));}function t(){var b=['Two-factor\x20provider'];t=function(){return b;};return t();}
1
+ function S(c,N){c=c-0xa0;var H=F();var d=H[c];return d;}import{unsupported}from'../../utils/unsupported.js';export default async function verifyTwoFactor(c,N){var H=S;return unsupported(H(0xa0));}function F(){var d=['Two-factor\x20provider'];F=function(){return d;};return F();}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x71;var Z=t();var b=Z[x];return b;}var x=f;function t(){var K=['image/webp','image/bmp','image/svg+xml','image/x-icon','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.ms-excel','application/vnd.oasis.opendocument.text','application/vnd.oasis.opendocument.spreadsheet','application/vnd.google-earth.kmz','application/gzip','application/x-gzip','audio/wav','video/mp4','video/webm','video/x-msvideo'];t=function(){return K;};return t();}export default new Set(['image/jpeg','image/png','image/gif',x(0x71),x(0x72),'image/tiff',x(0x73),x(0x74),'image/avif','application/pdf','application/msword',x(0x75),x(0x76),'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.ms-powerpoint','application/vnd.openxmlformats-officedocument.presentationml.presentation',x(0x77),x(0x78),'application/vnd.oasis.opendocument.presentation','text/plain','text/csv','text/markdown','application/json','application/xml','text/xml','application/geo+json','application/vnd.google-earth.kml+xml',x(0x79),'application/zip','application/x-zip-compressed','application/x-7z-compressed','application/x-rar-compressed','application/vnd.rar',x(0x7a),x(0x7b),'application/x-tar','audio/mpeg',x(0x7c),'audio/ogg','audio/webm','audio/mp4',x(0x7d),'video/mpeg',x(0x7e),'video/quicktime',x(0x7f),'application/octet-stream']);
1
+ var c=S;function S(c,N){c=c-0x191;var H=F();var d=H[c];return d;}export default new Set(['image/jpeg','image/png',c(0x191),'image/webp','image/bmp','image/tiff',c(0x192),c(0x193),c(0x194),'application/pdf','application/msword',c(0x195),'application/vnd.ms-excel',c(0x196),'application/vnd.ms-powerpoint',c(0x197),'application/vnd.oasis.opendocument.text',c(0x198),'application/vnd.oasis.opendocument.presentation','text/plain','text/csv','text/markdown',c(0x199),c(0x19a),'text/xml',c(0x19b),c(0x19c),c(0x19d),'application/zip','application/x-zip-compressed','application/x-7z-compressed',c(0x19e),'application/vnd.rar','application/gzip','application/x-gzip','application/x-tar','audio/mpeg','audio/wav','audio/ogg','audio/webm','audio/mp4','video/mp4','video/mpeg',c(0x19f),c(0x1a0),c(0x1a1),c(0x1a2)]);function F(){var N=['image/gif','image/svg+xml','image/x-icon','image/avif','application/vnd.openxmlformats-officedocument.wordprocessingml.document','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet','application/vnd.openxmlformats-officedocument.presentationml.presentation','application/vnd.oasis.opendocument.spreadsheet','application/json','application/xml','application/geo+json','application/vnd.google-earth.kml+xml','application/vnd.google-earth.kmz','application/x-rar-compressed','video/webm','video/quicktime','video/x-msvideo','application/octet-stream'];F=function(){return N;};return F();}
@@ -1 +1 @@
1
- import{fileTypeFromBuffer}from'file-type';import{getFile}from'./services/get-file.js';import{uploadFile}from'./services/upload-file.js';function t(){const S=['Get\x20file\x20by\x20token','public','file','mime','download','application/pdf','split','pop','type','Content-Disposition','attachment','inline','Cache-Control','public,\x20max-age=86400,\x20immutable','user','filename','value','fields','Resize\x20file','Returns\x20a\x20resized\x20image\x20file.','files:read','params','query','header'];t=function(){return S;};return t();}function f(x,K){x=x-0xa8;const Z=t();let b=Z[x];return b;}import{resizeFile}from'./services/resize-file.js';import{fileSchemas}from'./schema.js';export function fileRoutes(x){return async K=>{const C=f;K['get']('/api/file/:token',{'schema':{'tags':['fcore','file'],'summary':C(0xa8),'description':'Returns\x20a\x20file\x20after\x20verifying\x20its\x20signed\x20access\x20token.','access':C(0xa9),'permissions':[],'params':fileSchemas['fileToken'],'querystring':fileSchemas['fileDownloadQuery']}},async(Z,b)=>{const V=C,Q=x[V(0xaa)]['verify'](Z['params']['token']),J=await getFile({'pathOrToken':Q},x),a=await fileTypeFromBuffer(J),U=a?.[V(0xab)]??'application/octet-stream',I=Z['query'][V(0xac)]===!![],Y=U['startsWith']('image/')||U===V(0xad),w=Q[V(0xae)]('/')[V(0xaf)]()?.['replace'](/[^A-Za-z0-9._-]/g,'_')??'file';return b[V(0xb0)](U),b['header'](V(0xb1),(I||!Y?V(0xb2):V(0xb3))+';\x20filename=\x22'+w+'\x22')['header'](V(0xb4),V(0xb5)),b['send'](J);}),K['post']('/api/file/upload',{'schema':{'tags':['fcore','file'],'summary':'Upload\x20file','description':'Uploads\x20a\x20file\x20and\x20stores\x20its\x20metadata.','access':C(0xb6),'permissions':['files:create']}},async Z=>{const z=C,b=await Z['file']();if(!b)throw new Error('File\x20is\x20required');return uploadFile({'file':b,'metadata':{'name':b[z(0xb7)],'path':b['fields']['path']?.[z(0xb8)],'resource':b[z(0xb9)]['resource']?.['value'],'resourceId':b['fields']['resourceId']?.['value']},'user':Z[z(0xb6)]},x);}),K['get']('/api/file/:token/resize',{'schema':{'tags':['fcore','file'],'summary':C(0xba),'description':C(0xbb),'access':C(0xb6),'permissions':[C(0xbc)],'params':fileSchemas['fileToken'],'querystring':fileSchemas['resizeQuery']}},async(Z,b)=>{const P=C,Q=await resizeFile({'pathOrToken':x['file']?.['verify'](Z[P(0xbd)]['token']),...Z[P(0xbe)]},x),J=await fileTypeFromBuffer(Q);return b['type'](J?.[P(0xab)]??'image/png'),b[P(0xbf)](P(0xb1),'inline')['header'](P(0xb4),'public,\x20max-age=86400,\x20immutable'),b['send'](Q);});};}
1
+ import{fileTypeFromBuffer}from'file-type';import{getFile}from'./services/get-file.js';function S(c,N){c=c-0xc4;const H=F();let d=H[c];return d;}import{uploadFile}from'./services/upload-file.js';import{resizeFile}from'./services/resize-file.js';import{fileSchemas}from'./schema.js';function F(){const x=['fcore','file','fileDownloadQuery','mime','application/octet-stream','query','startsWith','application/pdf','Content-Disposition','Cache-Control','Upload\x20file','user','fields','get','Resize\x20file','Returns\x20a\x20resized\x20image\x20file.','files:read','fileToken','params','token','header'];F=function(){return x;};return F();}export function fileRoutes(c){return async N=>{const a=S;N['get']('/api/file/:token',{'schema':{'tags':[a(0xc4),a(0xc5)],'summary':'Get\x20file\x20by\x20token','description':'Returns\x20a\x20file\x20after\x20verifying\x20its\x20signed\x20access\x20token.','access':'public','permissions':[],'params':fileSchemas['fileToken'],'querystring':fileSchemas[a(0xc6)]}},async(H,d)=>{const I=a,U=c[I(0xc5)]['verify'](H['params']['token']),e=await getFile({'pathOrToken':U},c),K=await fileTypeFromBuffer(e),m=K?.[I(0xc7)]??I(0xc8),D=H[I(0xc9)]['download']===!![],W=m[I(0xca)]('image/')||m===I(0xcb),p=U['split']('/')['pop']()?.['replace'](/[^A-Za-z0-9._-]/g,'_')??I(0xc5);return d['type'](m),d['header'](I(0xcc),(D||!W?'attachment':'inline')+';\x20filename=\x22'+p+'\x22')['header'](I(0xcd),'public,\x20max-age=86400,\x20immutable'),d['send'](e);}),N['post']('/api/file/upload',{'schema':{'tags':['fcore',a(0xc5)],'summary':a(0xce),'description':'Uploads\x20a\x20file\x20and\x20stores\x20its\x20metadata.','access':a(0xcf),'permissions':['files:create']}},async H=>{const r=a,d=await H['file']();if(!d)throw new Error('File\x20is\x20required');return uploadFile({'file':d,'metadata':{'name':d['filename'],'path':d[r(0xd0)]['path']?.['value'],'resource':d[r(0xd0)]['resource']?.['value'],'resourceId':d['fields']['resourceId']?.['value']},'user':H['user']},c);}),N[a(0xd1)]('/api/file/:token/resize',{'schema':{'tags':[a(0xc4),'file'],'summary':a(0xd2),'description':a(0xd3),'access':a(0xcf),'permissions':[a(0xd4)],'params':fileSchemas[a(0xd5)],'querystring':fileSchemas['resizeQuery']}},async(H,d)=>{const w=a,U=await resizeFile({'pathOrToken':c['file']?.['verify'](H[w(0xd6)][w(0xd7)]),...H['query']},c),e=await fileTypeFromBuffer(U);return d['type'](e?.['mime']??'image/png'),d['header'](w(0xcc),'inline')[w(0xd8)]('Cache-Control','public,\x20max-age=86400,\x20immutable'),d['send'](U);});};}
@@ -1 +1 @@
1
- const x=f;function f(x,K){x=x-0x10b;const Z=t();let b=Z[x];return b;}import{Type}from'@sinclair/typebox';export const fileSchemas={'fileId':Type[x(0x10b)]({'id':Type['String']({'minLength':0x1,'maxLength':0x80})}),'fileToken':Type[x(0x10b)]({'token':Type['String']({'minLength':0x1,'maxLength':0x800})}),'fileDownloadQuery':Type[x(0x10b)]({'download':Type['Optional'](Type['Boolean']())}),'filePath':Type[x(0x10b)]({'*':Type[x(0x10c)]({'minLength':0x1,'maxLength':0x400})}),'upload':Type[x(0x10b)]({'file':Type['Any'](),'metadata':Type[x(0x10b)]({'name':Type[x(0x10d)](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['Optional'](Type[x(0x10c)]({'minLength':0x1})),'entityId':Type[x(0x10d)](Type['String']({'minLength':0x1}))}),'resizeQuery':Type['Object']({'width':Type['Optional'](Type['Integer']({'minimum':0x1,'default':0xc8})),'height':Type['Optional'](Type[x(0x10e)]({'minimum':0x1})),'fit':Type['Optional'](Type['Union']([Type['Literal'](x(0x10f)),Type['Literal'](x(0x110)),Type['Literal']('fill'),Type['Literal']('inside'),Type['Literal'](x(0x111))]))})};function t(){const K=['Object','String','Optional','Integer','cover','contain','outside'];t=function(){return K;};return t();}
1
+ function F(){const N=['Object','String','Boolean','Optional','Integer','Union','Literal','inside','outside'];F=function(){return N;};return F();}function S(c,N){c=c-0xf3;const H=F();let d=H[c];return d;}const c=S;import{Type}from'@sinclair/typebox';export const fileSchemas={'fileId':Type[c(0xf3)]({'id':Type['String']({'minLength':0x1,'maxLength':0x80})}),'fileToken':Type['Object']({'token':Type[c(0xf4)]({'minLength':0x1,'maxLength':0x800})}),'fileDownloadQuery':Type['Object']({'download':Type['Optional'](Type[c(0xf5)]())}),'filePath':Type[c(0xf3)]({'*':Type[c(0xf4)]({'minLength':0x1,'maxLength':0x400})}),'upload':Type[c(0xf3)]({'file':Type['Any'](),'metadata':Type['Object']({'name':Type[c(0xf6)](Type['String']({'minLength':0x1})),'path':Type['Optional'](Type[c(0xf4)]({'minLength':0x1})),'entityType':Type['Optional'](Type['String']({'minLength':0x1})),'entityId':Type['Optional'](Type[c(0xf4)]({'minLength':0x1}))})}),'filePatch':Type[c(0xf3)]({'entityType':Type['Optional'](Type['String']({'minLength':0x1})),'entityId':Type[c(0xf6)](Type[c(0xf4)]({'minLength':0x1}))}),'resizeQuery':Type['Object']({'width':Type['Optional'](Type[c(0xf7)]({'minimum':0x1,'default':0xc8})),'height':Type['Optional'](Type[c(0xf7)]({'minimum':0x1})),'fit':Type[c(0xf6)](Type[c(0xf8)]([Type[c(0xf9)]('cover'),Type['Literal']('contain'),Type['Literal']('fill'),Type['Literal'](c(0xfa)),Type['Literal'](c(0xfb))]))})};
@@ -1 +1 @@
1
- import{NotFoundError}from'../../../errors.js';export async function getFile(x,K){var Z=f;if(!K['file'])throw new Error('empty\x20file');if(!await K[Z(0xd1)]['exists'](x['pathOrToken']))throw new NotFoundError('File\x20not\x20found'+x['pathOrToken']);return K['file']['get'](x['pathOrToken']);}function f(x,K){x=x-0xd1;var Z=t();var b=Z[x];return b;}function t(){var b=['file'];t=function(){return b;};return t();}
1
+ function S(c,N){c=c-0xc4;var H=F();var d=H[c];return d;}import{NotFoundError}from'../../../errors.js';export async function getFile(c,N){var H=S;if(!N['file'])throw new Error('empty\x20file');if(!await N['file']['exists'](c['pathOrToken']))throw new NotFoundError(H(0xc4)+c[H(0xc5)]);return N['file']['get'](c['pathOrToken']);}function F(){var d=['File\x20not\x20found','pathOrToken'];F=function(){return d;};return F();}
@@ -1 +1 @@
1
- import{NotFoundError,ValidationError}from'../../../errors.js';function t(){const S=['width','sha256','update','.jpg','file','get','startsWith','image/','resize','cover'];t=function(){return S;};return t();}import{fileTypeFromBuffer}from'file-type';import{createHash}from'node:crypto';import{mkdir,readFile,writeFile}from'node:fs/promises';import x from'node:path';function f(x,K){x=x-0x130;const Z=t();let b=Z[x];return b;}import K from'sharp';export async function resizeFile(Z,b){const P=f,Q=Z['pathOrToken']??Z['path'];if(!Q)throw new ValidationError('File\x20path\x20is\x20required');const J=parseDimension(Z[P(0x130)],'width')??0xc8,a=parseDimension(Z['height'],'height'),U=createHash(P(0x131))[P(0x132)](Q+':'+J+':'+(a??'auto')+':'+(Z['fit']??'cover'))['digest']('hex'),I=x['resolve']('logs','resize'),Y=x['join'](I,U+P(0x133));try{return await readFile(Y);}catch(z){if(z['code']!=='ENOENT')throw z;}if(!await b[P(0x134)]['exists'](Q))throw new NotFoundError('File\x20not\x20found');const w=await b['file'][P(0x135)](Q),C=await fileTypeFromBuffer(w);if(!C?.['mime'][P(0x136)](P(0x137)))throw new ValidationError('Only\x20image\x20files\x20can\x20be\x20resized');const V=await K(w)[P(0x138)]({'width':J,'height':a,'fit':Z['fit']??P(0x139)})['toBuffer']();return await mkdir(I,{'recursive':!![]}),await writeFile(Y,V),V;}function parseDimension(Z,b){if(Z===undefined||Z==='')return undefined;const Q=Number(Z);if(!Number['isInteger'](Q)||Q<=0x0)throw new ValidationError(b+'\x20must\x20be\x20a\x20positive\x20integer');return Q;}
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';function S(c,N){c=c-0x139;const H=F();let d=H[c];return d;}import c from'node:path';function F(){const x=['width','digest','resolve','logs','join','ENOENT','file','File\x20not\x20found','toBuffer'];F=function(){return x;};return F();}import N from'sharp';export async function resizeFile(H,d){const w=S,U=H['pathOrToken']??H['path'];if(!U)throw new ValidationError('File\x20path\x20is\x20required');const e=parseDimension(H[w(0x139)],'width')??0xc8,K=parseDimension(H['height'],'height'),m=createHash('sha256')['update'](U+':'+e+':'+(K??'auto')+':'+(H['fit']??'cover'))[w(0x13a)]('hex'),D=c[w(0x13b)](w(0x13c),'resize'),W=c[w(0x13d)](D,m+'.jpg');try{return await readFile(W);}catch(r){if(r['code']!==w(0x13e))throw r;}if(!await d[w(0x13f)]['exists'](U))throw new NotFoundError(w(0x140));const p=await d[w(0x13f)]['get'](U),a=await fileTypeFromBuffer(p);if(!a?.['mime']['startsWith']('image/'))throw new ValidationError('Only\x20image\x20files\x20can\x20be\x20resized');const I=await N(p)['resize']({'width':e,'height':K,'fit':H['fit']??'cover'})[w(0x141)]();return await mkdir(D,{'recursive':!![]}),await writeFile(W,I),I;}function parseDimension(H,d){if(H===undefined||H==='')return undefined;const U=Number(H);if(!Number['isInteger'](U)||U<=0x0)throw new ValidationError(d+'\x20must\x20be\x20a\x20positive\x20integer');return U;}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x16c;const Z=t();let b=Z[x];return b;}import{fileTypeFromBuffer}from'file-type';function t(){const z=['getFullYear','padStart','file','mime','mimetype','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','metadata','resourceId','name','split'];t=function(){return z;};return t();}import x from'../mime.js';import{randomUUID}from'node:crypto';export async function uploadFile(K,Z){const V=f,b=(K['metadata']['name']??randomUUID())['replace'](/[^a-zA-Z0-9._-]/g,'_'),Q=new Date(),J=String(Q[V(0x16c)]())['slice'](-0x2),a=String(Q['getMonth']()+0x1)['padStart'](0x2,'0'),U=String(Q['getDate']())[V(0x16d)](0x2,'0'),I=K['metadata']['path']??(K['metadata']['resource']?K['metadata']['resource']+'/'+(K['metadata']['resourceId']??randomUUID())+'/'+b:null)??'uploads/'+J+'/'+a+'-'+U+'/'+b,Y=await K[V(0x16e)]['toBuffer'](),w=await fileTypeFromBuffer(Y);if(!x['has'](K[V(0x16e)]['mimetype'])&&(w?.[V(0x16f)]?!x['has'](w['mime']):!![]))throw new Error('Unsupported\x20file\x20type:\x20'+K['file'][V(0x170)]);await Z['file'][V(0x171)](I,Y);const C=await Z['pg']['query'](V(0x172),[K[V(0x173)]['resource']??null,K['metadata'][V(0x174)]??null,I,K['file'][V(0x170)],K['file']['file']['bytesRead'],K['metadata'][V(0x175)],b,K['file']['mimetype'][V(0x176)]('/')['pop']()??null,K['user']?.['id']??null]);return C['rows'][0x0];}
1
+ import{fileTypeFromBuffer}from'file-type';import c from'../mime.js';import{randomUUID}from'node:crypto';function F(){const r=['getFullYear','padStart','path','metadata','toBuffer','mimetype','\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','resourceId','file','user','rows'];F=function(){return r;};return F();}function S(c,N){c=c-0x18c;const H=F();let d=H[c];return d;}export async function uploadFile(N,H){const I=S,d=(N['metadata']['name']??randomUUID())['replace'](/[^a-zA-Z0-9._-]/g,'_'),U=new Date(),e=String(U[I(0x18c)]())['slice'](-0x2),K=String(U['getMonth']()+0x1)[I(0x18d)](0x2,'0'),m=String(U['getDate']())['padStart'](0x2,'0'),D=N['metadata'][I(0x18e)]??(N['metadata']['resource']?N[I(0x18f)]['resource']+'/'+(N[I(0x18f)]['resourceId']??randomUUID())+'/'+d:null)??'uploads/'+e+'/'+K+'-'+m+'/'+d,W=await N['file'][I(0x190)](),p=await fileTypeFromBuffer(W);if(!c['has'](N['file'][I(0x191)])&&(p?.['mime']?!c['has'](p['mime']):!![]))throw new Error('Unsupported\x20file\x20type:\x20'+N['file']['mimetype']);await H['file']['put'](D,W);const a=await H['pg']['query'](I(0x192),[N['metadata'][I(0x193)]??null,N['metadata'][I(0x194)]??null,D,N['file']['mimetype'],N['file'][I(0x195)]['bytesRead'],N['metadata']['name'],d,N['file']['mimetype']['split']('/')['pop']()??null,N[I(0x196)]?.['id']??null]);return a[I(0x197)][0x0];}
@@ -1 +1 @@
1
- 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';function f(x,K){x=x-0x1b1;const Z=t();let b=Z[x];return b;}import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';import{createResourceRelation}from'./services/create-resource-relation.js';import{updateResourceRelation}from'./services/update-resource-relation.js';import{deleteResourceRelation}from'./services/delete-resource-relation.js';import{searchResource}from'./services/search-resource.js';import{exportResource}from'./services/export-resource.js';import{suggestResource}from'./services/suggest-resource.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=x=>x['user'];function t(){const I=['Searches\x20records\x20in\x20a\x20registered\x20resource.','resource','fcore','resourceField','params','*:read','/api/resource/:resource','query','post','Create\x20resource\x20record','/api/resource/:resource/:id','user','resourceId','Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','body','/api/resource/:resource/:id/upload','Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','filename','get','Returns\x20related\x20records\x20for\x20a\x20resource\x20record.','Create\x20resource\x20relation','resourceIdRelation','resourceIdRelationId','/api/resource/:resource/:id/:relation/:relationId','Updates\x20a\x20related\x20resource\x20record.'];t=function(){return I;};return t();}export function resourceRoutes(x){return async K=>{const a=f;K['get']('/api/resource/:resource/search',{'schema':{'tags':['fcore','resource'],'summary':'Search\x20resource','description':a(0x1b1),'access':'user','permissions':[],'params':resourceSchemas[a(0x1b2)]}},async Z=>searchResource({...Z['query'],...Z['params'],'user':user(Z)},x)),K['get']('/api/suggest/:resource/:field',{'schema':{'tags':[a(0x1b3),'resource'],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':'user','permissions':[],'params':resourceSchemas[a(0x1b4)],'querystring':resourceSchemas['suggestQuery']}},async Z=>suggestResource({...Z['query'],...Z[a(0x1b5)],'user':user(Z)},x)),K['get']('/api/resource/:resource/export',{'schema':{'tags':[a(0x1b3),'resource'],'summary':'Export\x20resource\x20records','description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[a(0x1b6)],'params':resourceSchemas['exportResource'],'querystring':resourceSchemas['exportResourceQuery']}},async Z=>exportResource({...Z['query'],...Z['params'],'user':user(Z)},x)),K['get'](a(0x1b7),{'schema':{'tags':[a(0x1b3),a(0x1b2)],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resource']}},async Z=>listResources({...Z[a(0x1b8)],...Z[a(0x1b5)],'user':user(Z)},x)),K[a(0x1b9)]('/api/resource/:resource',{'schema':{'tags':[a(0x1b3),a(0x1b2)],'summary':a(0x1ba),'description':'Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resource']}},async Z=>createResource({...Z['params'],'data':Z['body'],'user':user(Z)},x)),K['get'](a(0x1bb),{'schema':{'tags':['fcore','resource'],'summary':'Get\x20resource\x20record','description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':a(0x1bc),'permissions':[],'params':resourceSchemas[a(0x1bd)],'querystring':resourceSchemas['resourceIncludeQuery']}},async Z=>getResource({...Z['query'],...Z['params'],'user':user(Z)},x)),K['put']('/api/resource/:resource/:id',{'schema':{'tags':[a(0x1b3),'resource'],'summary':'Update\x20resource\x20record','description':a(0x1be),'access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async Z=>updateResource({...Z['params'],'patch':Z[a(0x1bf)],'user':user(Z)},x)),K['delete']('/api/resource/:resource/:id',{'schema':{'tags':['fcore',a(0x1b2)],'summary':'Delete\x20resource\x20record','description':'Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async Z=>deleteResource({...Z[a(0x1b5)],'user':user(Z)},x)),K['post'](a(0x1c0),{'schema':{'tags':['fcore','resource'],'summary':'Upload\x20resource\x20file','description':a(0x1c1),'access':'user','permissions':[],'params':resourceSchemas['uploadResourceFile']}},async Z=>{const U=a,b=await Z['file']();if(!b)throw new Error('File\x20is\x20required');const Q=Z[U(0x1b5)]['resource'],J=Z[U(0x1b5)]['id'];if(Z['user']?.['type']!=='admin'&&!Z[U(0x1bc)]?.['permissions']['includes'](Q+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+Q+':update');return uploadFile({'file':b,'metadata':{'name':b[U(0x1c2)],'path':b['fields']['path']?.['value'],'resource':Q,'resourceId':J},'user':Z['user']},x);}),K[a(0x1c3)]('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20relations','description':a(0x1c4),'access':a(0x1bc),'permissions':[],'schema':{'params':resourceSchemas['resourceIdRelation']}}},async Z=>listResourceRelation({...Z['query'],...Z['params'],'user':user(Z)},x)),K['post']('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore','resource'],'summary':a(0x1c5),'description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas[a(0x1c6)]}},async Z=>createResourceRelation({...Z['params'],'data':Z['body'],'user':user(Z)},x)),K['delete']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':['fcore','resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas[a(0x1c7)]}},async Z=>deleteResourceRelation({...Z['params'],'user':user(Z)},x)),K['put'](a(0x1c8),{'schema':{'tags':[a(0x1b3),'resource'],'summary':'Update\x20resource\x20relation','description':a(0x1c9),'access':a(0x1bc),'permissions':[],'params':resourceSchemas['resourceIdRelationId']}},async Z=>updateResourceRelation({...Z['params'],'data':Z['body'],'user':user(Z)},x));};}
1
+ import{ForbiddenError}from'../../errors.js';import{listResources}from'./services/list-resources.js';function S(c,N){c=c-0xb5;const H=F();let d=H[c];return d;}import{getResource}from'./services/get-resource.js';function F(){const D=['/api/resource/:resource/search','resource','query','get','user','resourceField','params','/api/resource/:resource/export','Export\x20resource\x20records','exportResource','/api/resource/:resource','fcore','Create\x20resource\x20record','Creates\x20a\x20record\x20in\x20a\x20registered\x20resource.','Get\x20resource\x20record','body','Delete\x20resource\x20record','Deletes\x20a\x20record\x20from\x20a\x20registered\x20resource.','post','resourceIdRelation','resourceIdRelationId','put','/api/resource/:resource/:id/:relation/:relationId','Update\x20resource\x20relation'];F=function(){return D;};return F();}import{createResource}from'./services/create-resource.js';import{updateResource}from'./services/update-resource.js';import{deleteResource}from'./services/delete-resource.js';import{listResourceRelation}from'./services/list-resource-relation.js';import{createResourceRelation}from'./services/create-resource-relation.js';import{updateResourceRelation}from'./services/update-resource-relation.js';import{deleteResourceRelation}from'./services/delete-resource-relation.js';import{searchResource}from'./services/search-resource.js';import{exportResource}from'./services/export-resource.js';import{suggestResource}from'./services/suggest-resource.js';import{resourceSchemas}from'./schema.js';import{uploadFile}from'../file/services/upload-file.js';const user=c=>c['user'];export function resourceRoutes(c){return async N=>{const K=S;N['get'](K(0xb5),{'schema':{'tags':['fcore',K(0xb6)],'summary':'Search\x20resource','description':'Searches\x20records\x20in\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas[K(0xb6)]}},async H=>searchResource({...H[K(0xb7)],...H['params'],'user':user(H)},c)),N[K(0xb8)]('/api/suggest/:resource/:field',{'schema':{'tags':['fcore',K(0xb6)],'summary':'Suggest\x20resource\x20values','description':'Returns\x20suggested\x20values\x20for\x20a\x20resource\x20field.','access':K(0xb9),'permissions':[],'params':resourceSchemas[K(0xba)],'querystring':resourceSchemas['suggestQuery']}},async H=>suggestResource({...H['query'],...H[K(0xbb)],'user':user(H)},c)),N[K(0xb8)](K(0xbc),{'schema':{'tags':['fcore','resource'],'summary':K(0xbd),'description':'Exports\x20readable\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':['*:read'],'params':resourceSchemas[K(0xbe)],'querystring':resourceSchemas['exportResourceQuery']}},async H=>exportResource({...H['query'],...H['params'],'user':user(H)},c)),N['get'](K(0xbf),{'schema':{'tags':['fcore','resource'],'summary':'List\x20resource\x20records','description':'Returns\x20records\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas[K(0xb6)]}},async H=>listResources({...H['query'],...H[K(0xbb)],'user':user(H)},c)),N['post']('/api/resource/:resource',{'schema':{'tags':[K(0xc0),'resource'],'summary':K(0xc1),'description':K(0xc2),'access':'user','permissions':[],'params':resourceSchemas[K(0xb6)]}},async H=>createResource({...H[K(0xbb)],'data':H['body'],'user':user(H)},c)),N['get']('/api/resource/:resource/:id',{'schema':{'tags':['fcore',K(0xb6)],'summary':K(0xc3),'description':'Returns\x20one\x20record\x20from\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resourceId'],'querystring':resourceSchemas['resourceIncludeQuery']}},async H=>getResource({...H['query'],...H['params'],'user':user(H)},c)),N['put']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':'Update\x20resource\x20record','description':'Updates\x20a\x20record\x20in\x20a\x20registered\x20resource.','access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async H=>updateResource({...H['params'],'patch':H[K(0xc4)],'user':user(H)},c)),N['delete']('/api/resource/:resource/:id',{'schema':{'tags':['fcore','resource'],'summary':K(0xc5),'description':K(0xc6),'access':'user','permissions':[],'params':resourceSchemas['resourceId']}},async H=>deleteResource({...H['params'],'user':user(H)},c)),N[K(0xc7)]('/api/resource/:resource/:id/upload',{'schema':{'tags':[K(0xc0),K(0xb6)],'summary':'Upload\x20resource\x20file','description':'Uploads\x20a\x20file\x20to\x20a\x20Resource\x20record\x20and\x20stores\x20its\x20metadata.','access':K(0xb9),'permissions':[],'params':resourceSchemas['uploadResourceFile']}},async H=>{const m=K,d=await H['file']();if(!d)throw new Error('File\x20is\x20required');const U=H['params']['resource'],e=H['params']['id'];if(H[m(0xb9)]?.['type']!=='admin'&&!H['user']?.['permissions']['includes'](U+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+U+':update');return uploadFile({'file':d,'metadata':{'name':d['filename'],'path':d['fields']['path']?.['value'],'resource':U,'resourceId':e},'user':H['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[K(0xc8)]}}},async H=>listResourceRelation({...H['query'],...H['params'],'user':user(H)},c)),N['post']('/api/resource/:resource/:id/:relation',{'schema':{'tags':['fcore',K(0xb6)],'summary':'Create\x20resource\x20relation','description':'Creates\x20a\x20relation\x20for\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas[K(0xc8)]}},async H=>createResourceRelation({...H['params'],'data':H['body'],'user':user(H)},c)),N['delete']('/api/resource/:resource/:id/:relation/:relationId',{'schema':{'tags':[K(0xc0),'resource'],'summary':'Delete\x20resource\x20relation','description':'Deletes\x20a\x20relation\x20from\x20a\x20resource\x20record.','access':'user','permissions':[],'params':resourceSchemas[K(0xc9)]}},async H=>deleteResourceRelation({...H['params'],'user':user(H)},c)),N[K(0xca)](K(0xcb),{'schema':{'tags':[K(0xc0),'resource'],'summary':K(0xcc),'description':'Updates\x20a\x20related\x20resource\x20record.','access':K(0xb9),'permissions':[],'params':resourceSchemas['resourceIdRelationId']}},async H=>updateResourceRelation({...H['params'],'data':H[K(0xc4)],'user':user(H)},c));};}
@@ -1 +1 @@
1
- const x=f;import{Type}from'@sinclair/typebox';function f(x,K){x=x-0x14e;const Z=t();let b=Z[x];return b;}export const identifier=Type[x(0x14e)]({'minLength':0x1,'maxLength':0x80,'pattern':'^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$'});export const resourceSchemas={'dictionaryName':Type[x(0x14f)]({'name':identifier}),'resource':Type[x(0x14f)]({'resource':identifier}),'exportResource':Type['Object']({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type[x(0x14f)]({'q':Type[x(0x150)](Type['String']()),'search':Type['Optional'](Type['String']()),'limit':Type[x(0x150)](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceId':Type['Object']({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type['Object']({'include':Type['Optional'](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type[x(0x14f)]({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type[x(0x14f)]({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'uploadResourceFile':Type['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type[x(0x14f)]({'file':Type['Any'](),'fileName':Type['String']({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type[x(0x150)](Type[x(0x151)](Type['String'](),Type[x(0x152)]())),'sort':Type['Optional'](Type['Array'](Type['String']({'minLength':0x1}))),'search':Type['Optional'](Type[x(0x14e)]()),'limit':Type[x(0x150)](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type['Integer']({'minimum':0x0})),'fields':Type['Optional'](Type['Array'](identifier))})};function t(){const K=['String','Object','Optional','Record','Unknown'];t=function(){return K;};return t();}
1
+ const c=S;function S(c,N){c=c-0xe3;const H=F();let d=H[c];return d;}import{Type}from'@sinclair/typebox';export const identifier=Type[c(0xe3)]({'minLength':0x1,'maxLength':0x80,'pattern':c(0xe4)});export const resourceSchemas={'dictionaryName':Type['Object']({'name':identifier}),'resource':Type['Object']({'resource':identifier}),'exportResource':Type[c(0xe5)]({'resource':identifier}),'resourceField':Type['Object']({'resource':identifier,'field':identifier}),'suggestQuery':Type['Object']({'q':Type['Optional'](Type[c(0xe3)]()),'search':Type['Optional'](Type['String']()),'limit':Type[c(0xe6)](Type['Integer']({'minimum':0x1,'maximum':0xc8}))}),'resourceId':Type[c(0xe5)]({'resource':identifier,'id':identifier}),'resourceIncludeQuery':Type[c(0xe5)]({'include':Type['Optional'](Type['String']({'minLength':0x1}))}),'resourceIdRelation':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier}),'resourceIdRelationId':Type['Object']({'resource':identifier,'id':identifier,'relation':identifier,'relationId':identifier}),'uploadResourceFile':Type['Object']({'resource':identifier,'id':identifier}),'uploadResourceFileBody':Type['Object']({'file':Type[c(0xe7)](),'fileName':Type[c(0xe3)]({'minLength':0x1,'maxLength':0xff})}),'exportResourceQuery':Type['Object']({'filter':Type[c(0xe6)](Type['Record'](Type['String'](),Type['Unknown']())),'sort':Type['Optional'](Type[c(0xe8)](Type['String']({'minLength':0x1}))),'search':Type['Optional'](Type['String']()),'limit':Type[c(0xe6)](Type['Integer']({'minimum':0x1,'maximum':0xc8})),'offset':Type['Optional'](Type[c(0xe9)]({'minimum':0x0})),'fields':Type['Optional'](Type[c(0xe8)](identifier))})};function F(){const N=['String','^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$','Object','Optional','Any','Array','Integer'];F=function(){return N;};return F();}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x114;const Z=t();let b=Z[x];return b;}function t(){const Q=['INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','resource','rows'];t=function(){return Q;};return t();}export async function addNote(x,K){const b=f,Z=await K['pg']['query'](b(0x114),[x[b(0x115)],String(x['id']),x['body']]);return Z[b(0x116)][0x0];}
1
+ function S(c,N){c=c-0x169;const H=F();let d=H[c];return d;}export async function addNote(c,N){const d=S,H=await N['pg'][d(0x169)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[c['resource'],String(c['id']),c['body']]);return H['rows'][0x0];}function F(){const U=['query'];F=function(){return U;};return F();}
@@ -1 +1 @@
1
- export async function addResourceFile(x,K){const Z=await K['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',[x['resource'],String(x['id']),x['filePath'],x['size']??null]);return Z['rows'][0x0];}
1
+ export async function addResourceFile(c,N){const d=S,H=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',[c['resource'],String(c['id']),c[d(0x116)],c['size']??null]);return H[d(0x117)][0x0];}function S(c,N){c=c-0x116;const H=F();let d=H[c];return d;}function F(){const U=['filePath','rows'];F=function(){return U;};return F();}
@@ -1 +1 @@
1
- export async function createResourceRelation(x,K){const {resource:Z,id:b,relation:Q,data:J,user:a}=x;return K['resource']['createRelation']({'name':Z,'id':b,'relation':Q,'data':J,'user':a});}
1
+ export async function createResourceRelation(c,N){const {resource:H,id:d,relation:U,data:e,user:K}=c;return N['resource']['createRelation']({'name':H,'id':d,'relation':U,'data':e,'user':K});}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x111;var Z=t();var b=Z[x];return b;}export async function createResource(x,K){var Z=f;return K['resource']['create']({'name':x['resource'],'data':x[Z(0x111)],'user':x['user']});}function t(){var b=['data'];t=function(){return b;};return t();}
1
+ export async function createResource(c,N){var H=S;return N['resource']['create']({'name':c['resource'],'data':c['data'],'user':c[H(0xf4)]});}function S(c,N){c=c-0xf4;var H=F();var d=H[c];return d;}function F(){var d=['user'];F=function(){return d;};return F();}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x89;const Z=t();let b=Z[x];return b;}export async function deleteResourceRelation(x,K){const a=f,{resource:Z,id:b,relation:Q,relationId:J}=x;return K[a(0x89)][a(0x8a)]({'name':Z,'id':b,'relation':Q,'relationId':J});}function t(){const U=['resource','deleteRelation'];t=function(){return U;};return t();}
1
+ export async function deleteResourceRelation(c,N){const {resource:H,id:d,relation:U,relationId:e}=c;return N['resource']['deleteRelation']({'name':H,'id':d,'relation':U,'relationId':e});}
@@ -1 +1 @@
1
- export async function deleteResource(x,K){var Z=f;return K[Z(0x192)]['delete']({'name':x[Z(0x192)],'id':x['id'],'user':x['user']});}function f(x,K){x=x-0x192;var Z=t();var b=Z[x];return b;}function t(){var b=['resource'];t=function(){return b;};return t();}
1
+ function S(c,N){c=c-0x67;var H=F();var d=H[c];return d;}function F(){var d=['delete'];F=function(){return d;};return F();}export async function deleteResource(c,N){var H=S;return N['resource'][H(0x67)]({'name':c['resource'],'id':c['id'],'user':c['user']});}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function f(x,K){x=x-0x1f4;const Z=t();let b=Z[x];return b;}function t(){const Q=['resource','sort'];t=function(){return Q;};return t();}export async function exportResource(x,K){const b=f,Z=await K[b(0x1f4)]['find']({'name':x[b(0x1f4)],'query':{'filter':parseFilterQuery(x),'sort':x[b(0x1f5)],'search':x['search'],'limit':x['limit'],'offset':x['offset'],'fields':x['fields']},'user':x['user']});return Z['rows'];}
1
+ function S(c,N){c=c-0xc4;const H=F();let d=H[c];return d;}function F(){const U=['search','limit','offset'];F=function(){return U;};return F();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function exportResource(c,N){const d=S,H=await N['resource']['find']({'name':c['resource'],'query':{'filter':parseFilterQuery(c),'sort':c['sort'],'search':c[d(0xc4)],'limit':c[d(0xc5)],'offset':c[d(0xc6)],'fields':c['fields']},'user':c['user']});return H['rows'];}
@@ -1 +1 @@
1
- function t(){var b=['findOne','user'];t=function(){return b;};return t();}function f(x,K){x=x-0x82;var Z=t();var b=Z[x];return b;}export async function getResource(x,K){var Z=f;return K['resource'][Z(0x82)]({'name':x['resource'],'id':x['id'],'query':{'include':x['include']},'user':x[Z(0x83)]});}
1
+ function S(c,N){c=c-0x10a;var H=F();var d=H[c];return d;}export async function getResource(c,N){var H=S;return N['resource']['findOne']({'name':c['resource'],'id':c['id'],'query':{'include':c[H(0x10a)]},'user':c['user']});}function F(){var d=['include'];F=function(){return d;};return F();}
@@ -1 +1 @@
1
- function f(x,K){x=x-0x88;const Z=t();let b=Z[x];return b;}function t(){const I=['findRelation'];t=function(){return I;};return t();}export async function listResourceRelation(x,K){const U=f,{resource:Z,id:b,relation:Q,query:J,user:a}=x;return K['resource'][U(0x88)]({'name':Z,'id':b,'relation':Q,'query':J,'user':a});}
1
+ export async function listResourceRelation(c,N){const m=S,{resource:H,id:d,relation:U,query:e,user:K}=c;return N['resource'][m(0xcf)]({'name':H,'id':d,'relation':U,'query':e,'user':K});}function S(c,N){c=c-0xcf;const H=F();let d=H[c];return d;}function F(){const D=['findRelation'];F=function(){return D;};return F();}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function listResources(x,K){var Z=f;return K['resource'][Z(0x148)]({'name':x['resource'],'query':{'filter':parseFilterQuery(x),'sort':x['sort'],'search':x[Z(0x149)],'limit':x['limit'],'offset':x['offset']??(x['page']?Math['max'](x['page']-0x1,0x0):0x0)*(x['limit']??0x14)},'user':x['user']});}function f(x,K){x=x-0x148;var Z=t();var b=Z[x];return b;}function t(){var b=['find','search'];t=function(){return b;};return t();}
1
+ function S(c,N){c=c-0xa2;var H=F();var d=H[c];return d;}function F(){var d=['limit','page'];F=function(){return d;};return F();}import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';export async function listResources(c,N){var H=S;return N['resource']['find']({'name':c['resource'],'query':{'filter':parseFilterQuery(c),'sort':c['sort'],'search':c['search'],'limit':c[H(0xa2)],'offset':c['offset']??(c[H(0xa3)]?Math['max'](c['page']-0x1,0x0):0x0)*(c[H(0xa2)]??0x14)},'user':c['user']});}
@@ -1 +1 @@
1
- import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function t(){var b=['resource'];t=function(){return b;};return t();}function f(x,K){x=x-0x1bc;var Z=t();var b=Z[x];return b;}export async function searchResource(x,K){var Z=f;return K['resource']['find']({'name':x[Z(0x1bc)],'query':{...x,'filter':parseFilterQuery(x)},'user':x['user']});}
1
+ import{parseFilterQuery}from'../../../plugins/resource/utils/filters.js';function F(){var d=['find'];F=function(){return d;};return F();}function S(c,N){c=c-0x1f0;var H=F();var d=H[c];return d;}export async function searchResource(c,N){var H=S;return N['resource'][H(0x1f0)]({'name':c['resource'],'query':{...c,'filter':parseFilterQuery(c)},'user':c['user']});}
@@ -1 +1 @@
1
- function t(){const k=['search','max','limit','fields','lookup','query','\x20WHERE\x20lower(','then','length','field','code','map','text'];t=function(){return k;};return t();}import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function f(x,K){x=x-0xa2;const Z=t();let b=Z[x];return b;}export async function suggestResource(x,K){const S=f,Z=K['resource']['get'](x['resource']),b=String(x[S(0xa2)]??x['q']??'')['toLowerCase'](),Q=Math['min'](Math[S(0xa3)](Number(x[S(0xa4)]??0x14),0x1),0xc8),J=Date['now'](),a=Z[S(0xa5)][x['field']],U=a?.['dictionary'],I=a?.['lookup']?.['table'];if(I){const C=a[S(0xa6)]?.['text']??'name',V=a['lookup']?.['value']??'id';autoIndex(I,C,'text',K['pg']);const z=await K['pg'][S(0xa7)]('SELECT\x20'+V+'\x20as\x20id,\x20'+C+'\x20as\x20text\x20FROM\x20'+I+S(0xa8)+C+')\x20~\x20$1\x20LIMIT\x20$2',[''+b['toLowerCase'](),Q])[S(0xa9)](P=>P['rows']);return{'limit':Q,'count':z[S(0xaa)],'search':b,'time':Date['now']()-J,'data':z};}if(!U)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+x[S(0xab)]);const Y=await K['dictionary']['get'](U),w=Y['filter'](P=>!b||P[S(0xac)]['startsWith'](b)||P['name']['startsWith'](b))['slice'](0x0,Q)[S(0xad)](P=>({'id':P[S(0xac)]||P['id'],'text':P['name']||P[S(0xae)]}));return{'search':b,'limit':Q,'count':w['length'],'time':Date['now']()-J,'data':w};}
1
+ import{ValidationError}from'../../../errors.js';import{autoIndex}from'../../../plugins/resource/utils/auto-index.js';function F(){const V=['resource','toLowerCase','limit','fields','field','lookup','text','query','\x20WHERE\x20lower(','now','dictionary','startsWith','slice','name'];F=function(){return V;};return F();}function S(c,N){c=c-0x1f3;const H=F();let d=H[c];return d;}export async function suggestResource(c,N){const x=S,H=N[x(0x1f3)]['get'](c['resource']),d=String(c['search']??c['q']??'')[x(0x1f4)](),U=Math['min'](Math['max'](Number(c[x(0x1f5)]??0x14),0x1),0xc8),e=Date['now'](),K=H[x(0x1f6)][c[x(0x1f7)]],m=K?.['dictionary'],D=K?.['lookup']?.['table'];if(D){const a=K[x(0x1f8)]?.['text']??'name',I=K['lookup']?.['value']??'id';autoIndex(D,a,x(0x1f9),N['pg']);const r=await N['pg'][x(0x1fa)]('SELECT\x20'+I+'\x20as\x20id,\x20'+a+'\x20as\x20text\x20FROM\x20'+D+x(0x1fb)+a+')\x20~\x20$1\x20LIMIT\x20$2',[''+d['toLowerCase'](),U])['then'](w=>w['rows']);return{'limit':U,'count':r['length'],'search':d,'time':Date[x(0x1fc)]()-e,'data':r};}if(!m)throw new ValidationError('Field\x20has\x20no\x20lookup\x20dictionary:\x20'+c[x(0x1f7)]);const W=await N[x(0x1fd)]['get'](m),p=W['filter'](w=>!d||w['code']['startsWith'](d)||w['name'][x(0x1fe)](d))[x(0x1ff)](0x0,U)['map'](w=>({'id':w['code']||w['id'],'text':w[x(0x200)]||w['text']}));return{'search':d,'limit':U,'count':p['length'],'time':Date['now']()-e,'data':p};}
@@ -1 +1 @@
1
- function t(){const Y=['resource'];t=function(){return Y;};return t();}function f(x,K){x=x-0x1ad;const Z=t();let b=Z[x];return b;}export async function updateResourceRelation(x,K){const I=f,{resource:Z,id:b,relation:Q,relationId:J,data:a,user:U}=x;return K[I(0x1ad)]['updateRelation']({'name':Z,'id':b,'relation':Q,'relationId':J,'data':a,'user':U});}
1
+ export async function updateResourceRelation(c,N){const D=S,{resource:H,id:d,relation:U,relationId:e,data:K,user:m}=c;return N[D(0x1a6)]['updateRelation']({'name':H,'id':d,'relation':U,'relationId':e,'data':K,'user':m});}function S(c,N){c=c-0x1a6;const H=F();let d=H[c];return d;}function F(){const W=['resource'];F=function(){return W;};return F();}
@@ -1 +1 @@
1
- export async function updateResource(x,K){var Z=f;return K[Z(0x1b6)]['update']({'name':x['resource'],'id':x['id'],'data':x['patch'],'user':x['user']});}function f(x,K){x=x-0x1b6;var Z=t();var b=Z[x];return b;}function t(){var b=['resource'];t=function(){return b;};return t();}
1
+ function F(){var d=['resource','patch','user'];F=function(){return d;};return F();}function S(c,N){c=c-0x1a3;var H=F();var d=H[c];return d;}export async function updateResource(c,N){var H=S;return N[H(0x1a3)]['update']({'name':c['resource'],'id':c['id'],'data':c[H(0x1a4)],'user':c[H(0x1a5)]});}
@@ -1 +1 @@
1
- import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';function f(x,K){x=x-0x1f3;const Z=t();let b=Z[x];return b;}function t(){const U=['Admin\x20access\x20required','admin','user','includes','name','isBuffer','file','File\x20is\x20required','File\x20name\x20is\x20required','put','\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','length'];t=function(){return U;};return t();}export async function uploadResourceFile(x,K){const a=f,Z=K['resource']['get'](x['resource']);if(Z['access']==='admin'&&x['user']?.['type']!=='admin')throw new ForbiddenError(a(0x1f3));if(x['user']?.['type']!==a(0x1f4)&&!x[a(0x1f5)]?.['permissions']?.[a(0x1f6)]((Z['permission']??Z[a(0x1f7)])+':update'))throw new ForbiddenError('Missing\x20permission:\x20'+(Z['permission']??Z['name'])+':update');if(!Buffer[a(0x1f8)](x['file'])||x[a(0x1f9)]['length']===0x0)throw new ValidationError(a(0x1fa));const b=x['fileName']['replace'](/[^A-Za-z0-9._-]/g,'_');if(!b)throw new ValidationError(a(0x1fb));const Q='files/'+x['resource']+'/'+String(x['id'])+'/'+b;await K['file'][a(0x1fc)](Q,x[a(0x1f9)]);if(!await K['file']['exists'](Q))throw new NotFoundError('Uploaded\x20file\x20not\x20found');const J=await K['pg']['query'](a(0x1fd),[x['resource'],String(x['id']),Q,x['file'][a(0x1fe)]]);return J['rows'][0x0];}
1
+ import{ForbiddenError,NotFoundError,ValidationError}from'../../../errors.js';export async function uploadResourceFile(c,N){const K=S,H=N['resource']['get'](c[K(0xdb)]);if(H['access']==='admin'&&c[K(0xdc)]?.['type']!=='admin')throw new ForbiddenError(K(0xdd));if(c['user']?.[K(0xde)]!==K(0xdf)&&!c[K(0xdc)]?.['permissions']?.['includes']((H['permission']??H['name'])+K(0xe0)))throw new ForbiddenError(K(0xe1)+(H['permission']??H['name'])+':update');if(!Buffer[K(0xe2)](c[K(0xe3)])||c['file']['length']===0x0)throw new ValidationError('File\x20is\x20required');const d=c[K(0xe4)]['replace'](/[^A-Za-z0-9._-]/g,'_');if(!d)throw new ValidationError('File\x20name\x20is\x20required');const U=K(0xe5)+c[K(0xdb)]+'/'+String(c['id'])+'/'+d;await N[K(0xe3)]['put'](U,c['file']);if(!await N['file']['exists'](U))throw new NotFoundError(K(0xe6));const e=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',[c[K(0xdb)],String(c['id']),U,c['file']['length']]);return e[K(0xe7)][0x0];}function S(c,N){c=c-0xdb;const H=F();let d=H[c];return d;}function F(){const m=['resource','user','Admin\x20access\x20required','type','admin',':update','Missing\x20permission:\x20','isBuffer','file','fileName','files/','Uploaded\x20file\x20not\x20found','rows'];F=function(){return m;};return F();}