@opengis/fcore 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/generate-resource-code.js +1 -1
- package/dist/modules/resource/services/get-resource-schema.js +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.js +1 -1
- package/dist/modules/resource/services/list-resource-list.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.js +1 -1
- package/dist/modules/system/services/get-resource-scopes.js +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.js +1 -1
- package/dist/modules/system/services/set-resource-scopes.js +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/get-table-columns.js +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/scope.js +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +1 -1
- package/migrations/20260905120000_add_user_foreign_keys.sql +15 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function O(){const F=['test','has','Dictionary\x20already\x20registered:\x20','code','set','Dictionary\x20table\x20not\x20found','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20di.code,\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionary_items\x20di\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20admin.dictionaries\x20d\x20ON\x20d.id\x20=\x20di.dictionary_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20d.code\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20di.name\x0a\x20\x20\x20\x20\x20\x20\x20\x20','database','checked','isArray','Dictionary\x20items\x20must\x20be\x20an\x20array','empty\x20pg','query','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionaries\x20(code,\x20name,\x20module,\x20source,\x20editable)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4,\x20$5)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(code)\x20DO\x20UPDATE\x20SET\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20name\x20=\x20EXCLUDED.name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20=\x20EXCLUDED.module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20source\x20=\x20EXCLUDED.source,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20editable\x20=\x20EXCLUDED.editable,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','name','static','get','delete','values','map'];O=function(){return F;};return O();}import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function c(S,Z){S=S-0x113;const h=O();let U=h[S];return U;}const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;export function createDictionary({pg:S,dictionaries:dictionaries=[]}){const Z=new Map(),h=new Map();let U,D;async function u(){if(U!==undefined)return U;if(!S)throw new Error('empty\x20pg');return D??=S['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_schema\x20=\x20\x27admin\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20\x27dictionaries\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20')['then'](i=>{const l=i['rows'][0x0]?.['table_name'];U=l==='dictionaries'?l:null;}),await D,U;}function e(i){const k=c;if(!dictionaryName[k(0x113)](i))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+i);}function q(i){const I=c;for(const l of Array['isArray'](i)?i:[i]){e(l['code']);if(!Array['isArray'](l['items']))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+l['code']);if(Z[I(0x114)](l['code']))throw new ConflictError(I(0x115)+l[I(0x116)]);Z[I(0x117)](l['code'],{...l,'source':'static'});}}function x(i){const B=c;return Z[B(0x114)](i);}async function n(i){const M=c;e(i);const l=Z['get'](i);if(l&&l['checked'])return l['items'];const b=await u();if(!b)throw new NotFoundError(M(0x118));const Y=await S?.['query'](M(0x119),[i]);if(Y?.['rows']?.['length']){const r=Y?.['rows'];return Z[M(0x117)](i,{'code':i,'name':i,'items':r,'source':M(0x11a),'checked':!![]}),r;}if(!l?.['items'])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+i);return l[M(0x11b)]=!![],l['items'];}async function N(i,l){const g=c;e(i);if(!Array[g(0x11c)](l))throw new ValidationError(g(0x11d));const b=await u();if(!b)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!S)throw new Error(g(0x11e));const Y=await S['connect']();try{await Y[g(0x11f)]('BEGIN');const r=await Y[g(0x11f)](g(0x120),[i,i,'fcore','custom',!![]]),E=r['rows'][0x0]['id'];await Y['query'](g(0x121),[E]);for(const L of l){await Y[g(0x11f)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.dictionary_items\x20(dictionary_id,\x20code,\x20name,\x20parent_id)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',[E,L['code'],L[g(0x122)],L['parentId']??null]);}await Y[g(0x11f)]('COMMIT');}catch(V){await Y['query']('ROLLBACK');throw V;}finally{Y['release']();}Z[g(0x117)](i,{'items':l,'code':i,'source':g(0x123),'checked':!![]}),h[g(0x117)](i,(h[g(0x124)](i)??0x0)+0x1);}function o(i){const d=c;return e(i),h[d(0x117)](i,(h['get'](i)??0x0)+0x1),Z[d(0x125)](i);}function j(i){return h['get'](i)??0x0;}async function X(){const J=c,i=[...Z[J(0x126)]()][J(0x127)](({code:Y,name:r,source:E})=>({'code':Y,'name':r??Y,'source':E})),l=await u();if(!l)return i;if(!S)throw new Error(J(0x11e));const b=await S['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20code,\x20name,\x20\x27database\x27\x20AS\x20source\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.dictionaries\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20');for(const Y of b['rows']){!Z['has'](Y['code'])&&i['push'](Y);}return i;}return q(dictionaries),{'register':q,'get':n,'put':N,'clear':o,'revision':j,'list':X,'has':x};}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import S from'node:fs/promises';function O(){const T=['replace','alloc','from','randomBytes','relative','Invalid\x20file\x20path','readFile','dirname','rename','code','tokenTtl','toString','base64url','createHmac','split','update','digest','length','timingSafeEqual','region','accessKey','accessKeyId','send','bucket','sha256'];O=function(){return T;};return O();}import Z from'node:path';import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import h from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function normalizeRelativePath(U){const b=c;if(!U||U['startsWith']('/')||U['includes']('..'))throw new ValidationError('Invalid\x20file\x20path');return U[b(0x1a5)](/\\/g,'/')['replace'](/^\/+/,'');}function keyFor(U,D){const Y=c;return''+((U??'')[Y(0x1a5)](/^\/+|\/+$/g,'')?(U??'')[Y(0x1a5)](/^\/+|\/+$/g,'')+'/':'')+normalizeRelativePath(D);}async function bodyToBuffer(U){const r=c;if(!U)return Buffer[r(0x1a6)](0x0);const D=U;if(typeof D['transformToByteArray']==='function')return Buffer[r(0x1a7)](await D['transformToByteArray']());const u=[];for await(const e of U){u['push'](Buffer['from'](e));}return Buffer['concat'](u);}function c(S,Z){S=S-0x1a5;const h=O();let U=h[S];return U;}export function createFileLocal(U){const E=c,D=Z['resolve'](U['storagePath']||'./storage'),u=Z['join'](D,'removed'),e=U['tokenSecret']??process.env.FILE_TOKEN_SECRET??h[E(0x1a8)](0x20)['toString']('hex'),q=N=>{const L=E,o=normalizeRelativePath(N),j=(U['folder']??'files')[L(0x1a5)](/^\/+|\/+$/g,'');return j?Z['join'](j,o):o;},x=N=>{const V=E,o=q(N),j=Z['resolve'](D,o),X=Z[V(0x1a9)](D,j);if(X['startsWith']('..')||Z['isAbsolute'](X))throw new ValidationError(V(0x1aa));return j;},n=N=>{const o=q(N),j=Z['resolve'](u,o),X=Z['relative'](u,j);if(X['startsWith']('..')||Z['isAbsolute'](X))throw new ValidationError('Invalid\x20file\x20path');return j;};return{async 'put'(N,o){const j=x(N);await S['mkdir'](Z['dirname'](j),{'recursive':!![]}),await S['writeFile'](j,o instanceof Buffer?o:await bodyToBuffer(o));},async 'get'(N){const k=E;return S[k(0x1ab)](x(N));},async 'exists'(N){try{return await S['access'](x(N)),!![];}catch{return![];}},async 'delete'(N){const I=E,o=x(N),j=n(N);try{await S['mkdir'](Z[I(0x1ac)](j),{'recursive':!![]}),await S[I(0x1ad)](o,j);}catch(X){const i=X;if(i[I(0x1ae)]!=='ENOENT')throw X;}},'create'(N,o=U[E(0x1af)]??0xe10){const B=E,j=Buffer['from'](N)[B(0x1b0)](B(0x1b1)),X=h[B(0x1b2)]('sha256',e)['update'](j)['digest']('base64url');return j+'.'+X;},'verify'(N){const M=E,[o,j]=N[M(0x1b3)]('.');if(!o||!j)throw new UnauthorizedError('Invalid\x20file\x20token');const X=h['createHmac']('sha256',e)[M(0x1b4)](o)[M(0x1b5)](),i=Buffer['from'](j,'base64url');if(X[M(0x1b6)]!==i['length']||!h[M(0x1b7)](X,i))throw new UnauthorizedError('Invalid\x20file\x20token');const l=Buffer['from'](o,M(0x1b1))['toString']('utf8');return l;}};}export function createFileS3(U){const g=c,D=U['tokenSecret']??process.env.FILE_TOKEN_SECRET??h[g(0x1a8)](0x20)['toString']('hex'),u=new S3Client({'endpoint':U['endpoint'],'region':U[g(0x1b8)]??'us-east-1','forcePathStyle':U['forcePathStyle']??!![],'credentials':U['accessKeyId']||U[g(0x1b9)]?{'accessKeyId':U[g(0x1ba)]??U['accessKey'],'secretAccessKey':U['secretAccessKey']??U['secretKey']}:undefined}),e=q=>keyFor(U['folder'],q);return{async 'put'(q,x){const d=g;await u[d(0x1bb)](new PutObjectCommand({'Bucket':U[d(0x1bc)],'Key':e(q),'Body':x}));},async 'get'(q){const J=g,x=await u['send'](new GetObjectCommand({'Bucket':U[J(0x1bc)],'Key':e(q)}));return bodyToBuffer(x['Body']);},async 'exists'(q){try{return await u['send'](new HeadObjectCommand({'Bucket':U['bucket'],'Key':e(q)})),!![];}catch(x){const n=x;if(n['$metadata']?.['httpStatusCode']===0x194||n['name']==='NotFound')return![];throw x;}},async 'delete'(q){await u['send'](new DeleteObjectCommand({'Bucket':U['bucket'],'Key':e(q)}));},'create'(q,x=U[g(0x1af)]??0xe10){const F=g,n=Buffer['from'](q)['toString']('base64url'),N=h['createHmac'](F(0x1bd),D)['update'](n)[F(0x1b5)]('base64url');return n+'.'+N;},'verify'(q){const G=g,[x,n]=q['split']('.');if(!x||!n)throw new UnauthorizedError('Invalid\x20file\x20token');const N=h['createHmac']('sha256',D)['update'](x)[G(0x1b5)](),o=Buffer['from'](n,'base64url');if(N['length']!==o['length']||!h['timingSafeEqual'](N,o))throw new UnauthorizedError('Invalid\x20file\x20token');const j=Buffer[G(0x1a7)](x,'base64url')['toString']('utf8');return j;}};}
|
package/dist/plugins/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function c(S,Z){S=S-0x7d;const h=O();let U=h[S];return U;}import{SignJWT,jwtVerify}from'jose';const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);export async function jwtSignToken(S){const u=c;if(!process.env.AUTH_JWT_SECRET)return;const {id:Z,type:h,permissions:U}=S,D=await new SignJWT({'id':Z,'type':h,'permissions':U})['setProtectedHeader']({'alg':'HS256'})[u(0x7d)]()['setExpirationTime']('1h')[u(0x7e)](secret);return D;}function O(){const x=['setIssuedAt','sign','catch','log','message'];O=function(){return x;};return O();}export async function jwtVerifyToken(S){const e=c,Z=await jwtVerify(S,secret,{'algorithms':['HS256']})[e(0x7f)](h=>{const q=e;console[q(0x80)](h[q(0x81)]);});return Z?.['payload'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import S from'pino';function O(){const x=['req.headers.authorization','password','refreshToken'];O=function(){return x;};return O();}function c(S,Z){S=S-0x163;const h=O();let U=h[S];return U;}export function createLogger(){const q=c,Z=S['transport']({'target':'./transport.js'}),h=S({'level':'info','timestamp':S['stdTimeFunctions']['isoTime'],'base':{'service':'app'},'redact':{'paths':[q(0x163),q(0x164),'token','accessToken',q(0x165)],'censor':'[REDACTED]'}},Z),U={};function D(u,e){if(u===undefined)return{...U};U[u]=(U[u]??0x0)+(e??0x1);}return Object['assign'](h,{'close':async()=>Z['end'](),'metrics':D,'file':()=>h['info']['bind'](h)});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const q=c;import S from'node:fs';import Z from'node:path';import h from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:q(0x82),0x3c:'error'},streams=new Map();function c(S,Z){S=S-0x82;const h=O();let U=h[S];return U;}function getDate(){return new Date()['toISOString']()['slice'](0x0,0xa);}function createStream(U,D){const x=q,u=Z['resolve']('logs',U);return S[x(0x83)](u,{'recursive':!![]}),S['createWriteStream'](Z[x(0x84)](u,D+x(0x85)),{'flags':'a'});}function O(){const j=['error','mkdirSync','join','.log','stream','set','values','file'];O=function(){return j;};return O();}function getStream(U){const n=q,D=getDate(),u=streams['get'](U);if(u&&u['date']===D)return u[n(0x86)];u?.['stream']['end']();const e=createStream(U,D);return streams[n(0x87)](U,{'date':D,'stream':e}),e;}function closeStreams(){const N=q;for(const {stream:U}of streams[N(0x88)]()){U['end']();}streams['clear']();}export default async function loggerTransport(){return h(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(U){const o=q;for await(const D of U){const u=LEVELS[D['level']];if(!u)continue;const e=getStream(D['file']||u);delete D[o(0x89)],e['write'](JSON['stringify'](D)+'\x0a');}}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import S from'pg';function O(){const i=['catch','stack','BEGIN','COMMIT','query','ROLLBACK'];O=function(){return i;};return O();}const {Pool}=S;function c(S,Z){S=S-0x176;const h=O();let U=h[S];return U;}export function createDatabase(Z){const h=new Pool(Z),U=h['query']['bind'](h);function D(u,e){const o=c,q=new Error();return Error['captureStackTrace']?.(q,D),U(u,e)[o(0x176)](x=>{const j=o,n=x;n['sql']=u,n['callerStack']=q[j(0x177)];throw n;});}return h['query']=D,h['transaction']=async function(u){const X=c,e=new Error();Error['captureStackTrace']?.(e,h['transaction']);const q=await h['connect']();try{await q['query'](X(0x178));const x=await u(q);return await q['query'](X(0x179)),x;}catch(n){await q[X(0x17a)](X(0x17b));const N=n;N['callerStack']=e[X(0x177)];throw N;}finally{q['release']();}},h;}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Redis}from'ioredis';
|
|
1
|
+
import{Redis}from'ioredis';function O(){const q=['set'];O=function(){return q;};return O();}function c(S,Z){S=S-0x1a1;const h=O();let U=h[S];return U;}export function createRedis(S){console['log']('Creating\x20Redis\x20client\x20with\x20config:',S);const Z=new Redis(S);return{'get':h=>Z['get'](h),'set':(h,U,D,u)=>{const e=c;if(u)return Z['set'](h,U,'EX',u);if(typeof D==='number')return Z[e(0x1a1)](h,U,'EX',D);return Z[e(0x1a1)](h,U);},'del':h=>Z['del'](h),'delete':h=>Z['del'](h),'close':()=>Z['quit'](),'ping':()=>Z['ping'](),'hincrby':(h,U,D)=>Z['hincrby'](h,U,D),'incrby':(h,U)=>Z['incrby'](h,U)};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';function c(S,Z){S=S-0x16e;const h=O();let U=h[S];return U;}import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';function O(){const j=['register','bind'];O=function(){return j;};return O();}import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(S){const o=c,Z=new ResourceRegistry(),h=createFind(S,Z),U=createFindOne(S,Z),D=createCreate(S,Z),u=createUpdate(S,Z),e=createRemove(S,Z),q=createFindRelation(S,Z),x=createCreateRelation(S,Z),n=createUpdateRelation(S,Z),N=createDeleteRelation(S,Z);return{'register':Z[o(0x16e)]['bind'](Z),'unregister':Z['unregister']['bind'](Z),'has':Z['has']['bind'](Z),'get':Z['get'][o(0x16f)](Z),'list':Z['list'][o(0x16f)](Z),'find':h,'findOne':U,'create':D,'update':u,'delete':e,'findRelation':q,'createRelation':x,'updateRelation':n,'deleteRelation':N};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';function c(S,Z){S=S-0x95;const h=O();let U=h[S];return U;}const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(S){const U=c;return S['split']('.')[U(0x95)]<=0x2&&S['split']('.')['every'](Z=>ident['test'](Z));}function O(){const n=['length','resources','delete','Resource\x20already\x20registered:\x20','name','get','version','Invalid\x20resource\x20contract:\x20','test'];O=function(){return n;};return O();}export class ResourceRegistry{['resources']=new Map();['unregister'](S){const D=c;this[D(0x96)][D(0x97)](S);}['register'](S,Z=![]){const u=c;for(const h of Array['isArray'](S)?S:[S]){this['validate'](h);if(this['resources']['has'](h['name'])&&!Z)throw new ConflictError(u(0x98)+h[u(0x99)]);this[u(0x96)]['set'](h['name'],h);}}['has'](S){const e=c;return this[e(0x96)]['has'](S);}['get'](S){const q=c,Z=this['resources'][q(0x9a)](S);if(!Z)throw new NotFoundError('Resource\x20not\x20registered:\x20'+S);return Z;}['list'](){return[...this['resources']['values']()];}['validate'](S){const x=c;if(S[x(0x9b)]!==0x1||!ident['test'](S['name'])||!validQualified(S['table'])||!ident['test'](S['key']))throw new ValidationError(x(0x9c)+S['name']);for(const [Z,h]of Object['entries'](S['fields'])){if(!ident[x(0x9d)](Z)||!ident['test'](h['column']??Z))throw new ValidationError('Invalid\x20resource\x20field:\x20'+Z);}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(
|
|
1
|
+
const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(S,Z){const o=c,h=dictionaryIndexesCache['get'](Z)??new Map(),U=dictionaryRevisionsCache['get'](Z)??new Map();dictionaryIndexesCache[o(0x7d)](Z,h),dictionaryRevisionsCache[o(0x7d)](Z,U);const D=S['filter'](e=>U['get'](e)!==Z[o(0x7e)](e));if(D[o(0x7f)]===0x0)return h;const u=await Promise[o(0x80)](D['map'](async e=>{const j=o;if(!Z['has'](e))return[e,new Map()];const q=await Z[j(0x81)](e),x=new Map();for(const n of q){const N=n[j(0x82)]??n['id'];if(N==null)continue;x['set'](String(N),{'id':N,'text':n['name']??n['text'],...n['color']!==undefined?{'color':n[j(0x83)]}:{},...n['icon']!==undefined?{'icon':n['icon']}:{}});}return[e,x];}));for(const [e,q]of u){h['set'](e,q),U['set'](e,Z['revision'](e));}return h;}export async function addDictionaryLookupData(S,Z,h){const i=c;if(!h||S['length']===0x0)return S;const U=Object['entries'](Z)['flatMap'](([u,e])=>{const X=c,q=e[X(0x84)];return q?[{'field':u,'dictionaryName':q}]:[];});if(U['length']===0x0)return S;const D=await getDictionaryIndexes([...new Set(U['map'](({dictionaryName:u})=>u))],h);for(const u of S){for(const {field:e,dictionaryName:q}of U){const x=u[e];u[e+'_data']=x==null?null:D['get'](q)?.[i(0x81)](String(x))??null;}}return S;}function c(S,Z){S=S-0x7d;const h=O();let U=h[S];return U;}function O(){const l=['set','revision','length','all','get','code','color','dictionary'];O=function(){return l;};return O();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function addFileToken(
|
|
1
|
+
function O(){const x=['length'];O=function(){return x;};return O();}function c(S,Z){S=S-0x1b4;const h=O();let U=h[S];return U;}export function addFileToken(S,Z,h){const q=c;if(!h||S[q(0x1b4)]===0x0)return S;const U=Object['entries'](Z)['filter'](([,D])=>D['type']==='file')['map'](([D])=>D);for(const D of S){for(const u of U){const e=D[u];typeof e==='string'&&e['length']>0x0&&(D[u]=h['create'](e));}}return S;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();function c(S,Z){S=S-0xda;const h=O();let U=h[S];return U;}function O(){const E=['get','startsWith','string','number','table','set','\x20AS\x20id,\x20','value','has','field','_data'];O=function(){return E;};return O();}export function clearTableLookupCache(S,Z){const Y=c,h=tableLookupCache[Y(0xda)](Z);if(!h)return;for(const U of h['keys']()){U[Y(0xdb)](S+':')&&h['delete'](U);}}export async function addTableLookupData(S,Z,h){const r=c;if(!h||S['length']===0x0)return S;const U=tableLookupCache[r(0xda)](h)??new Map();tableLookupCache['set'](h,U);const D=Object['entries'](Z)['flatMap'](([u,e])=>{const {table:q,value:value='id',text:text='name'}=e['lookup']??{};return q?[{'field':u,'table':q,'value':value,'text':text}]:[];});for(const u of D){const e=new Map();for(const N of S){const o=N[u['field']];(typeof o===r(0xdc)||typeof o===r(0xdd))&&e['set'](String(o),o);}const q=u[r(0xde)]+':'+u['value']+':'+u['text'],x=U[r(0xda)](q)??new Map();U[r(0xdf)](q,x);const n=[...e['entries']()]['filter'](([j])=>!x['has'](j))['map'](([,j])=>j);if(n['length']>0x0){const j=await h['query']('SELECT\x20'+qi(u['value'])+r(0xe0)+qi(u['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(u['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(u[r(0xe1)])+'\x20=\x20ANY($1)',[n]);for(const X of j['rows']){x['set'](String(X['id']),X);}for(const i of n){!x[r(0xe2)](String(i))&&x['set'](String(i),null);}}for(const l of S){const b=l[u[r(0xe3)]];l[u[r(0xe3)]+r(0xe4)]=b==null?null:x['get'](String(b))??null;}}return S;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';function c(S,Z){S=S-0xd7;const h=O();let U=h[S];return U;}function O(){const Y=['includes','\x22\x20requires\x20a\x20capabilities\x20\x22','query','body','INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*','filePath','size','foreignKey','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','Relation\x20update\x20is\x20not\x20configured:\x20'];O=function(){return Y;};return O();}import{createCreate}from'./create.js';export function createCreateRelation(S,Z){const h=createCreate(S,Z);return async function U({name:D,id:u,relation:e,data:q,user:x},n){const b=c,N=n?.['pg']??S['pg'],o=Z['get'](D);if(['notes','files'][b(0xd7)](e)&&!o['capabilities']?.['includes'](e))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+e+b(0xd8)+e+'\x22');if(e==='notes'){const i=await N[b(0xd9)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[D,String(u),q?.[b(0xda)]]);return i['rows'][0x0];}if(e==='files'){const l=await N['query'](b(0xdb),[D,String(u),q?.[b(0xdc)],q?.[b(0xdd)]??null]);return l['rows'][0x0];}const j=o['relations']?.[e];if(!j?.[b(0xde)]||!j['resource']&&!j['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+e+b(0xdf));if(!q)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+q);if(!j[b(0xe0)])throw new UnsupportedError(b(0xe1)+e);q[j['foreignKey']]=u;const X=await h({'name':j['resource'],'data':q??{},'user':x});return X;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function c(S,Z){S=S-0x14d;const h=O();let U=h[S];return U;}function O(){const r=['get','fields','created_by','push','No\x20writable\x20fields','map','query','join','audit','module','name','keys'];O=function(){return r;};return O();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(S,Z){return async function h({name:U,data:D,user:u},e){const Y=c,q=Z[Y(0x14d)](U);assertOperation(q,'create',u),validateInputData({'resource':q,'data':D});const x=writableData(q,D);q[Y(0x14e)]['created_at']&&x['push'](['created_at',new Date()]);q['fields'][Y(0x14f)]&&x[Y(0x150)]([Y(0x14f),u?.['id']]);if(!x['length'])throw new ValidationError(Y(0x151));const n=x[Y(0x152)](([l])=>qi(l)),N=x[Y(0x152)]((l,b)=>'$'+(b+0x1)),o=x['map'](([,l])=>l),j=e?.['pg']??S['pg'],X=await j[Y(0x153)]('INSERT\x20INTO\x20'+qt(q['table'])+'\x20('+n['join'](',\x20')+')\x20'+('VALUES\x20('+N[Y(0x154)](',\x20')+')\x20')+'RETURNING\x20*',o),i=X['rows'][0x0];return clearTableLookupCache(q['table'],j),await(e?.[Y(0x155)]??S['audit'])?.['write']({'userId':u?.['id'],'module':q[Y(0x156)],'resource':q[Y(0x157)],'resourceId':i[q['key']],'action':'create','fields':Object[Y(0x158)](D)}),i;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(){const l=['get','\x22\x20requires\x20a\x20capabilities\x20\x22','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','relations','foreignKey'];O=function(){return l;};return O();}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function c(S,Z){S=S-0x98;const h=O();let U=h[S];return U;}export function createDeleteRelation(S,Z){const h=createRemove(S,Z);return async function U({name:D,id:u,relation:e,relationId:q,user:x},n){const i=c,N=n?.['pg']??S['pg'],o=Z[i(0x98)](D);if(['notes','files']['includes'](e)&&!o['capabilities']?.['includes'](e))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+e+i(0x99)+e+'\x22');if(e==='notes')return await N['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[q,D,String(u)]),{'success':!![]};if(e==='files')return await N['query'](i(0x9a),[q,D,String(u)]),{'success':!![]};const j=o[i(0x9b)]?.[e];if(!j?.['resource']||!j[i(0x9c)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+e+'\x22\x20requires\x20a\x20project/provider\x20implementation');const X=await h({'name':j['resource'],'id':q,'user':x,'where':{'column':j['foreignKey'],'value':u}},n);return{'success':X};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function O(){const i=['push','value','column','\x20=\x20$','table','rowCount','audit','module','name'];O=function(){return i;};return O();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function c(S,Z){S=S-0x140;const h=O();let U=h[S];return U;}export function createRemove(S,Z){return async function h({name:U,id:D,user:u,where:e},q){const X=c,x=Z['get'](U);assertOperation(x,'delete',u);const n=q?.['pg']??S['pg'],N=[D];let o='WHERE\x20'+qi(x['key'])+'\x20=\x20$1';e&&(N[X(0x140)](e[X(0x141)]),o+='\x20AND\x20'+qi(e[X(0x142)])+X(0x143)+N['length']);x['where']&&(o+='\x20AND\x20('+x['where']+')');const j=await n['query']('DELETE\x20FROM\x20'+qt(x[X(0x144)])+'\x20'+o,N);if((j['rowCount']??0x0)>0x0)clearTableLookupCache(x[X(0x144)],n);if((j[X(0x145)]??0x0)>0x0)await(q?.[X(0x146)]??S[X(0x146)])?.['write']({'module':x[X(0x147)],'resource':x[X(0x148)],'resourceId':D,'action':'delete'});return(j[X(0x145)]??0x0)>0x0;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function O(){const Y=['type','integer','isInteger','Invalid\x20id:\x20','join','where','rows','fields','include','isArray','then','one','time','now'];O=function(){return Y;};return O();}function c(S,Z){S=S-0x161;const h=O();let U=h[S];return U;}import{createFindRelation}from'./find-relation.js';export function createFindOne(S,Z){return async function h({name:U,id:D,query:query={},user:u}){const b=c,e=Date['now'](),q=Z['get'](U);assertOperation(q,'read',u);if(q['fields'][q['key']]?.[b(0x161)]===b(0x162)&&!Number[b(0x163)](Number(D)))throw new ValidationError(b(0x164)+D+'\x20name:'+U);const x=q['joins']?.['map'](i=>i['sql']+'\x20')[b(0x165)]('\x20')||'',n=q[b(0x166)]?'\x20AND\x20('+q[b(0x166)]+')':'',N=await S['pg']['query']('SELECT\x20'+readableFields(q)['join'](',\x20')+'\x20FROM\x20'+qt(q['table'])+'\x20t\x20'+x+'\x20WHERE\x20'+qi(q['key'])+'=$1'+n+'\x20LIMIT\x201',[D]),o=N[b(0x167)][0x0];if(!o)return null;await addDictionaryLookupData([o],q['fields'],S['dictionary']),await addTableLookupData([o],q['fields'],S['pg']),addFileToken([o],q[b(0x168)],S['file']);const j=(query[b(0x169)]==='all'?Object['keys'](q['relations']||{}):null)||(Array[b(0x16a)](query['include'])?query['include']:query['include']?.['split'](',')??[]),X=createFindRelation(S,Z);for(const i of j){o[i]=await X({'name':U,'id':D,'relation':i,'query':query,'user':u})[b(0x16b)](l=>l['rows']??[])['then'](l=>q['relations']?.[i]?.['type']===b(0x16c)?l[0x0]??null:l);}return o[b(0x16d)]=Date[b(0x16e)]()-e,o;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function O(){const B=['limit','isFinite','get','relations','notes','includes','now','files','resource','fields','filter','scope','foreignKey','btree','JOIN\x20','junctionTable','\x20j\x20ON\x20j.','junctionForeignKey','localKey','where','join','\x20t\x20','query','file'];O=function(){return B;};return O();}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function c(S,Z){S=S-0x1d1;const h=O();let U=h[S];return U;}import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(S,Z){return async function h({name:U,id:D,relation:u,query:query={}}){const I=c,e=Date['now'](),q=Math['min'](Math['max'](query[I(0x1d1)]??0x14,0x1),0xc8),x=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](q)||!Number[I(0x1d2)](x))throw new ValidationError('Invalid\x20pagination');const n=Z[I(0x1d3)](U),N=n[I(0x1d4)]?.[u];if([I(0x1d5),'files']['includes'](u)&&!n['capabilities']?.[I(0x1d6)](u))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+u+'\x22\x20requires\x20a\x20capabilities\x20\x22'+u+'\x22');if(u==='notes'){const L=await S['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[U,String(D)]);return{'total':L['rows']['length'],'time':Date[I(0x1d7)]()-e,'rows':L['rows']};}if(u===I(0x1d8)){const V=await S['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[U,String(D)]);return addFileToken(V['rows'],{'file_path':{'type':'file'}},S['file']),{'total':V['rows']['length'],'time':Date['now']()-e,'rows':V['rows']};}if(!N?.[I(0x1d9)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+u+'\x22\x20requires\x20a\x20project/provider\x20implementation');const o=Z['get'](N['resource']),j=o?.['key']??'id',X=o?.['table'],i=Object['keys'](o?.[I(0x1da)]??{})[I(0x1db)](k=>o?.[I(0x1da)][k]?.['read']&&o?.['fields'][k]?.[I(0x1dc)]!=='item')['map'](qi)['join'](',\x20'),l=N['fields']?.['join'](',\x20')||i||'*';N[I(0x1dd)]&&autoIndex(X,N[I(0x1dd)],I(0x1de),S['pg']);const b=N['junctionTable']?I(0x1df)+qt(N[I(0x1e0)])+I(0x1e1)+qi(N[I(0x1e2)])+'\x20=\x20t.'+(N['junctionTargetKey']||qi(j))+'\x20WHERE\x20'+qi(N['junctionLocalKey'])+'\x20=\x20$1\x20':'where\x20'+(N['foreignKey']||qi(j))+'\x20=\x20(SELECT\x20'+qi(N[I(0x1e3)]||n['key'])+'\x20FROM\x20'+qt(n['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(n['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x20'+(N[I(0x1e4)]?'AND\x20('+N[I(0x1e4)]+')':''),Y=o['joins']?.['map'](k=>k['sql']+'\x20')[I(0x1e5)]('\x20')||'',r='SELECT\x20'+l+'\x20FROM\x20'+qt(X)+I(0x1e6)+Y+'\x20'+b+'\x20LIMIT\x20$2\x20OFFSET\x20$3',E=await S['pg'][I(0x1e7)](r,[D,q,x]);return o&&(await addDictionaryLookupData(E['rows'],o[I(0x1da)],S['dictionary']),await addTableLookupData(E['rows'],o['fields'],S['pg']),addFileToken(E['rows'],o['fields'],S[I(0x1e8)])),{'limit':q,'offset':x,'total':E['rows']['length'],'time':Date['now']()-e,'rows':E['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function O(){const k=['get','read','max','limit','sql','\x20AND\x20','Invalid\x20pagination','fields','filter','map','text','values',')\x20LIKE\x20$','scope','\x20WHERE\x20','true','joins','join','NULL','LIMIT\x20$','length','dictionary','rowCount','include'];O=function(){return k;};return O();}import{autoIndex}from'../utils/auto-index.js';function c(S,Z){S=S-0x16c;const h=O();let U=h[S];return U;}import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(S,Z){return async function h({name:U,query:query={},user:D}){const V=c,u=Date['now'](),e=Z[V(0x16c)](U);assertOperation(e,V(0x16d),D);const q=Math['min'](Math[V(0x16e)](query[V(0x16f)]??0x14,0x1),0xc8),x=Math['max'](query['offset']??0x0,0x0);buildIndex(e,query['filter'],S['pg']);const n=buildFilters(e,query['filter']);e['where']&&(n['sql']+=(n[V(0x170)]?V(0x171):'\x20WHERE\x20')+('('+e['where']+')'));const N=buildSort(e,query['sort']);if(!Number['isFinite'](q)||!Number['isFinite'](x))throw new ValidationError(V(0x172));const o=e['searchable']||Object['keys'](e[V(0x173)])[V(0x174)](L=>e['fields'][L]?.['searchable']);query['search']&&o['length']&&(o[V(0x175)](L=>autoIndex(e['table'],L,V(0x176),S['pg'])),n[V(0x177)]['push'](query['search']['toLowerCase']()+'%'),n['sql']+=(n[V(0x170)]?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+o?.['map'](L=>'lower('+qt(L)+V(0x178)+n[V(0x177)]['length'])['join']('\x20OR\x20')+')'));if(query['scope']&&e['scopes']?.[query['scope']]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query[V(0x179)]);const j=query['scope']||(e['scopes']?.['default']?'default':undefined);j&&(n['sql']+=(n[V(0x170)]?'\x20AND\x20':V(0x17a))+('('+(e['scopes']?.[j]||V(0x17b))+')'));const X=await buildUserResourceScopeFilter(e,D,S['pg'],n[V(0x177)]['length']+0x1);X['sql']&&(n[V(0x170)]+=(n[V(0x170)]?'\x20AND\x20':'\x20WHERE\x20')+('('+X['sql']+')'),n['values']['push'](...X['values']));const i=e[V(0x17c)]?.['filter'](L=>L[V(0x179)]!=='item')['map'](L=>L['sql']+'\x20')['join']('\x20')||'',l='SELECT\x20'+readableFields(e,'all')[V(0x17d)](',\x20')+'\x20'+('FROM\x20'+qt(e['table'])+'\x20t\x20')+(i+'\x20'+n['sql']['replace'](/:uid/g,'\x27'+(D?.['id']??V(0x17e))+'\x27')+'\x20'+N+'\x20')+(V(0x17f)+(n[V(0x177)][V(0x180)]+0x1)+'\x20')+('OFFSET\x20$'+(n['values']['length']+0x2)),b=buildSummary(e,query,D,X),[Y,r]=await Promise['all']([S['pg']['query'](l,[...n['values'],q,x]),S['pg']['query'](b['sql'],b['values'])['then'](L=>L['rows'][0x0]??{})]),E=Y['rows'];return await addDictionaryLookupData(E,e['fields'],S[V(0x181)]),await addTableLookupData(E,e['fields'],S['pg']),addFileToken(E,e[V(0x173)],S['file']),{'time':Date['now']()-u,'limit':q,'offset':x,'count':Y[V(0x182)],'total':r?.['count']??0x0,'summary':r,'rows':E,...query[V(0x183)]?.['includes']('fields')?{'fields':e['fields']}:{}};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(){const u=['rows'];O=function(){return u;};return O();}function c(S,Z){S=S-0xab;const h=O();let U=h[S];return U;}export async function getTableColumns(S,Z){const D=c;if(!S)throw new Error('not\x20enough\x20params:\x20table');if(!Z?.['pg'])return[];const h=await Z['pg']['query']('\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped',[S])['then'](U=>U[D(0xab)]||[]);return h;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function O(){const i=['foreignKey'];O=function(){return i;};return O();}function c(S,Z){S=S-0x9c;const h=O();let U=h[S];return U;}export function createUpdateRelation(S,Z){const h=createUpdate(S,Z);return async function U({name:D,id:u,relation:e,relationId:q,data:x,user:n},N){const X=c,o=Z['get'](D),j=o['relations']?.[e];if(!j?.['resource']||!j['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+e);if(Object['hasOwn'](x,j['foreignKey'])&&x[j['foreignKey']]!==u)throw new ValidationError('Cannot\x20change\x20relation:\x20'+j['foreignKey']);return h({'name':j['resource'],'id':q,'data':x,'user':n,'where':{'column':j[X(0x9c)],'value':u}},N);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';function O(){const L=['update','length','No\x20writable\x20fields','fields','updated_by','push','map','\x20=\x20$','where','query','join','table','module'];O=function(){return L;};return O();}import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function c(S,Z){S=S-0xea;const h=O();let U=h[S];return U;}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(S,Z){return async function h({name:U,id:D,data:u,user:e,where:q},x){const E=c,n=Z['get'](U);assertOperation(n,E(0xea),e);const N=writableData(n,u);if(!N[E(0xeb)])throw new ValidationError(E(0xec));const o=x?.['pg']??S['pg'];validateInputData({'resource':n,'data':u,'update':!![]});n['fields']['updated_at']&&N['push'](['updated_at',new Date()]);n[E(0xed)][E(0xee)]&&N[E(0xef)](['updated_by',e?.['id']]);delete u['user_type'];const j=N[E(0xf0)](([Y],r)=>qi(Y)+E(0xf1)+(r+0x1)),X=[...N[E(0xf0)](([,Y])=>Y),D];let i='WHERE\x20'+qi(n['key'])+'\x20=\x20$'+X['length'];q&&(X['push'](q['value']),i+='\x20AND\x20'+qi(q['column'])+'\x20=\x20$'+X['length']);n[E(0xf2)]&&(i+='\x20AND\x20('+n['where']+')');const l=await o[E(0xf3)]('UPDATE\x20'+qt(n['table'])+'\x20'+('SET\x20'+j['join'](',\x20')+'\x20')+(i+'\x20')+('RETURNING\x20'+Object['keys'](u)['map'](qi)[E(0xf4)](',\x20')),X),b=l['rows'][0x0];if(!b)throw new NotFoundError(U+':'+D);return clearTableLookupCache(n[E(0xf5)],o),await(x?.['audit']??S['audit'])?.['write']({'userId':e?.['id'],'module':n[E(0xf6)],'resource':n['name'],'resourceId':D,'action':E(0xea),'fields':Object['keys'](u)}),b;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const x=c;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(S,Z,h=x(0x152),U){const n=x,D=requestedIndexes['get'](U)??new Set();requestedIndexes['set'](U,D);const u=S+':'+Z+':'+h;if(D['has'](u))return;D['add'](u),void ensureIndex(S,Z,h,U)[n(0x153)](()=>{D['delete'](u);});}function c(S,Z){S=S-0x152;const h=O();let U=h[S];return U;}function O(){const o=['btree','catch','length','query','\x20USING\x20btree\x20(lower(',')\x20text_pattern_ops)','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20USING\x20gin\x20(lower('];O=function(){return o;};return O();}async function ensureIndex(S,Z,h,U){const N=x,D=S['split']('.'),u=D[N(0x154)]===0x2?D[0x0]:'public',e=(S+'_'+Z+'_'+h+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),q=await U['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[u,e]);if(q['rowCount'])return;if(h==='text'){await U['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await U[N(0x155)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(e+'_l')+'\x20ON\x20'+qt(S)+N(0x156)+qi(Z)+N(0x157)),await U['query'](N(0x158)+qi(e)+'\x20ON\x20'+qt(S)+N(0x159)+qi(Z)+')\x20gin_trgm_ops)');return;}await U['query'](N(0x158)+qi(e)+'\x20ON\x20'+qt(S)+'\x20USING\x20'+h+'\x20('+qi(Z)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function O(){const u=['entries','fields','writable','Required\x20field:\x20','minLength','string','minLength\x20not\x20met:\x20','maxLength\x20exceeded:\x20','minimum','\x20should\x20be\x20>=\x20','pattern'];O=function(){return u;};return O();}function c(S,Z){S=S-0x128;const h=O();let U=h[S];return U;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:S,data:Z,update:update=![]})=>{const D=c;for(const [h,U]of Object[D(0x128)](S[D(0x129)])){if(U['required']&&U[D(0x12a)]!==![]&&(Z[h]===undefined||Z[h]===null)&&!update)throw new ValidationError(D(0x12b)+h);if(U['required']&&U[D(0x12a)]!==![]&&Object['hasOwn'](Z,h)&&(Z[h]===undefined||Z[h]===null)&&update)throw new ValidationError('Required\x20field:\x20'+h);if(U[D(0x12c)]&&typeof Z[h]===D(0x12d)&&Z[h]['length']<U['minLength'])throw new ValidationError(D(0x12e)+h);if(U['maxLength']&&typeof Z[h]==='string'&&Z[h]['length']>U['maxLength'])throw new ValidationError(D(0x12f)+h);if(U['minimum']&&typeof Z[h]==='number'&&Z[h]<U[D(0x130)])throw new ValidationError(h+D(0x131)+U[D(0x130)]);if(U['maximum']&&typeof Z[h]==='number'&&Z[h]>U['maximum'])throw new ValidationError(h+'\x20should\x20be\x20<=\x20'+U['maximum']);if(U['enum']&&Z[h]&&!U['enum']['includes'](Z[h]))throw new ValidationError(h+'\x20should\x20be\x20one\x20of\x20('+U['enum']['join'](',\x20')+')');if(U['pattern']&&typeof Z[h]==='string'&&!new RegExp(U[D(0x132)])['test'](Z[h]))throw new ValidationError(h+'\x20should\x20match\x20regular\x20expression\x20('+U['pattern']+')');}};export{validateInputData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function O(){const L=['exec','Unsupported\x20filter\x20operator:\x20','keys','entries','fields','filter','has','type','text','Operator\x20','\x20IS\x20','isArray','push','\x20WHERE\x20','like','geom'];O=function(){return L;};return O();}const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(S){const l=c,Z={...isRecord(S['filter'])?S['filter']:{}};for(const [h,U]of Object['entries'](S)){const D=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/[l(0x167)](h);if(!D)continue;const [,u,e]=D;if(!u)continue;if(!e){Z[u]=U;continue;}if(!filterOperators['has'](e))throw new ValidationError(l(0x168)+e);const q=isRecord(Z[u])?Z[u]:{};q[e]=(e==='in'||e==='nin')&&typeof U==='string'?U['split'](','):U,Z[u]=q;}return Object[l(0x169)](Z)['length']?Z:undefined;}function c(S,Z){S=S-0x167;const h=O();let U=h[S];return U;}export function buildIndex(S,Z,h){const b=c;for(const [U,D]of Object[b(0x16a)](Z??{})){const u=S[b(0x16b)][U];if(!u||u['filter']!==!![]&&u['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+U);h&&autoIndex(S['table'],fieldColumn(S,U),indexTypeFor(u['type'],'eq'),h);}}export function buildFilters(S,Z,h=0x1){const Y=c,U=[],D=[];for(const [u,e]of Object['entries'](Z??{})){const q=S['fields'][u];if(!q||q[Y(0x16c)]!==!![]&&q['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+u);const x=qi(fieldColumn(S,u)),n=isRecord(e)?e:{'eq':e};for(const [N,o]of Object['entries'](n)){if(!filterOperators[Y(0x16d)](N))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+N);if((N==='like'||N==='ilike')&&q[Y(0x16e)]!=='string'&&q['type']!==Y(0x16f))throw new ValidationError(Y(0x170)+N+'\x20requires\x20a\x20text\x20field:\x20'+u);if(N==='null'){U['push'](x+Y(0x171)+(isTruthy(o)?'':'NOT\x20')+'NULL');continue;}if(N==='in'||N==='nin'){const i=Array[Y(0x172)](o)?o:[o];if(i['length']===0x0){U['push'](N==='in'?'FALSE':'TRUE');continue;}D[Y(0x173)](i),U[Y(0x173)](x+'\x20'+(N==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(h+D['length']-0x1)+')');continue;}const j={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},X='$'+(h+D['length']);if(N==='like'){D[Y(0x173)](o+'%'),U['push']('lower('+x+')\x20like\x20lower('+X+')');continue;}D[Y(0x173)](o),U['push'](x+'\x20'+j[N]+'\x20'+X);}}return{'sql':U['length']?Y(0x174)+U['join']('\x20AND\x20'):'','values':D};}function isRecord(S){const r=c;return typeof S==='object'&&S!==null&&!Array[r(0x172)](S);}function isTruthy(S){return S===!![]||S==='true'||S==='1'||S===0x1;}function indexTypeFor(S,Z){const E=c;if(Z===E(0x175)||Z==='ilike')return E(0x16f);if(S===E(0x176)||S==='geometry')return'gist';return'btree';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function c(S,Z){S=S-0x75;const h=O();let U=h[S];return U;}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(S,Z,h){const u=c,U=getContext()[u(0x75)];if(U['debug'])return;if(!S['operations']['includes'](Z))throw new ForbiddenError(S['name']+'.'+Z+u(0x76));if(S['access']!=='public'&&h===undefined)throw new ForbiddenError(u(0x77));if(S['access']==='admin'&&h?.[u(0x78)]!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(h?.['type']!=='admin'){const D=(S['permission']??S['name'])+':'+Z;if(!h?.['permissions']?.[u(0x79)](D))throw new ForbiddenError('Missing\x20permission:\x20'+D);}}function O(){const e=['config','\x20is\x20disabled','Authentication\x20required','type','includes'];O=function(){return e;};return O();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{qi}from'./sql.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{qi}from'./sql.js';const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(S,Z){const o=c;if(S&&Z){scopeCache[o(0x1e8)](S+':'+Z);return;}if(S){for(const h of scopeCache[o(0x1e9)]()){if(h[o(0x1ea)](S+':'))scopeCache['delete'](h);}return;}scopeCache['clear']();}async function loadScopeRows(S,Z,h){const j=c,U=S+':'+Z,D=scopeCache[j(0x1eb)](U);if(D&&D['expiresAt']>Date[j(0x1ec)]())return D['promise'];const u=h[j(0x1ed)]('SELECT\x20DISTINCT\x20ras.scope,\x20ras.value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x20ras\x0a\x20\x20\x20\x20\x20WHERE\x20ras.resource\x20=\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20ras.enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20OR\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20ras.role_id\x20IN\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ur.role_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20(ur.expiration\x20IS\x20NULL\x20OR\x20ur.expiration\x20>=\x20CURRENT_DATE)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20)',[S,Z])['then'](({rows:e})=>{const X=j,q=new Map();for(const x of e){const n=q['get'](x['scope'])??[];if(Array['isArray'](x['value']))n[X(0x1ee)](...x['value']);else{if(x['value']!==null&&x['value']!==undefined)n['push'](x['value']);}q['set'](x[X(0x1ef)],n);}return q;})['catch'](e=>{scopeCache['delete'](U);throw e;});return scopeCache['set'](U,{'expiresAt':Date['now']()+CACHE_TTL_MS,'promise':u}),u;}export async function getUserResourceScopes(S,Z,h){const i=c,U=await loadScopeRows(S,Z,h);return Object['fromEntries']([...U][i(0x1f0)](([D,u])=>[D,D==='me'?S:u]));}function columnForScope(S,Z){const l=c;if(Z===S['name'])return S['key'];if(Z==='me'){const U=['user_id',l(0x1f1),l(0x1f2),'created_by']['find'](D=>S['fields'][D]);if(!U)throw new ValidationError(l(0x1f3)+S[l(0x1f4)]);return S[l(0x1f5)][U]?.['column']??U;}const h=S['fields'][Z];if(!h)return'';return h['column']??Z;}export async function buildUserResourceScopeFilter(S,Z,h,U){const b=c;if(!Z||Z['type']==='admin')return{'sql':'','values':[]};const D=await loadScopeRows(Z['id'],S[b(0x1f4)],h),u=[],e=[];for(const [q,x]of D){const n=columnForScope(S,q);if(!n){u['push'](b(0x1f6));continue;}const N='t.'+qi(n);if(q==='me'){e[b(0x1ee)](Z['id']),u['push']('('+N+b(0x1f7)+(U+e[b(0x1f8)]-0x1)+')');continue;}if(x['length']===0x0){u['push']('(FALSE)');continue;}e['push'](x),u[b(0x1ee)]('('+N+b(0x1f9)+(U+e[b(0x1f8)]-0x1)+'))');}return{'sql':u[b(0x1fa)](b(0x1fb)),'values':e};}function c(S,Z){S=S-0x1e8;const h=O();let U=h[S];return U;}function O(){const Y=['delete','keys','startsWith','get','now','query','push','scope','map','user_uid','owner_id','Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20','name','fields','(FALSE)','\x20=\x20$','length','\x20=\x20ANY($','join','\x20AND\x20'];O=function(){return Y;};return O();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function c(S,Z){S=S-0x159;const h=O();let U=h[S];return U;}import{fieldColumn,qi}from'./sql.js';function O(){const n=['string','sortable','Field\x20is\x20not\x20sortable:\x20','DESC','ASC','\x20ORDER\x20BY\x20'];O=function(){return n;};return O();}import{ValidationError}from'../../../errors.js';export function buildSort(S,Z){const q=c;if(!Z?.['length'])return'';typeof Z===q(0x159)&&(Z=[Z]);const h=Z['map'](U=>{const x=q,D=U['startsWith']('-'),u=D?U['slice'](0x1):U,e=S['fields'][u];if(!e||e[x(0x15a)]!==!![])throw new ValidationError(x(0x15b)+u);return qi(fieldColumn(S,u))+'\x20'+(D?x(0x15c):x(0x15d));});return q(0x15e)+h['join'](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function O(){const N=['split','join','Unknown\x20field:\x20','column','entries','read','all','key','write'];O=function(){return N;};return O();}const e=c;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=S=>'\x22'+S['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=S=>S[e(0x113)]('.')['map'](quoteIdentifier)[e(0x114)]('.');export function fieldColumn(S,Z){const q=e;if(Z===S['key'])return S['key'];const h=S['fields'][Z];if(!h)throw new ValidationError(q(0x115)+Z);return h[q(0x116)]??Z;}export function readableFields(S,Z){const x=e,h=Object[x(0x117)](S['fields'])['filter'](([,U])=>U[x(0x118)]!==![]&&U['readable']!==![]&&(Z?(U['scope']??x(0x119))===Z:!![]))['map'](([U,D])=>quoteIdentifier(D['column']??U)+'\x20AS\x20'+quoteIdentifier(U));return!S['fields'][S[x(0x11a)]]&&h['unshift'](quoteIdentifier(S[x(0x11a)])),h;}export function writableData(S,Z){const n=e,h=[];for(const [U,D]of Object['entries'](Z)){const u=S['fields'][U];if(!u||u[n(0x11b)]===![]||u['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+U);if((u['write']??u['writable'])!==!![])continue;if(u['type']==='date'&&!Z[U])continue;h['push']([u['column']??U,D]);}return h;}export const qi=quoteIdentifier;function c(S,Z){S=S-0x113;const h=O();let U=h[S];return U;}export const qt=quoteTable;
|