@opengis/fcore 0.0.1-beta.25 → 0.0.1-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +2 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +13 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
- package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
- package/dist/modules/resource/services/generate-resource-code.js +1 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
- package/dist/modules/resource/services/get-resource-schema.js +1 -0
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
- package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-as-user.js +1 -0
- package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
- package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-list.js +1 -0
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +22 -0
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.d.ts +23 -0
- package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-access.js +1 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-scopes.js +1 -0
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +1 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.d.ts +18 -0
- package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-access.js +1 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-scopes.js +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +23 -4
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/get-table-columns.js +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/scope.d.ts +10 -0
- package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
- package/dist/plugins/resource/utils/scope.js +1 -0
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +5 -1
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -1
- package/dist/plugins/resource/utils/summary.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
export async function updateDictionary(h,n){var B=k;return await n['dictionary'][B(0x156)](h[B(0x157)],h[B(0x158)]),{'success':!![]};}function k(h,n){h=h-0x156;var B=Q();var G=B[h];return G;}function Q(){var G=['put','name','items'];Q=function(){return G;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';export async function updateSystemSettings(h,n){const f=k;if(!Object['keys'](h[f(0x1bb)])[f(0x1bc)])throw new ValidationError('Settings\x20patch\x20is\x20empty');for(const [B,G]of Object['entries'](h['patch'])){if(!B['trim']()||B['includes']('..'))throw new ValidationError(f(0x1bd)+B);await n['pg'][f(0x1be)]('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.settings\x20(resource,\x20resource_id,\x20key,\x20value,\x20updated_by)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20(\x27system\x27,\x20NULL,\x20$1,\x20$2::jsonb,\x20$3)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ON\x20CONFLICT\x20(resource,\x20resource_id,\x20key)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20DO\x20UPDATE\x20SET\x20value\x20=\x20EXCLUDED.value,\x20updated_by\x20=\x20EXCLUDED.updated_by,\x20updated_at\x20=\x20now()\x0a\x20\x20\x20\x20\x20\x20\x20\x20',[B,JSON['stringify'](G),h['user']['id']]);}return{'success':!![]};}function k(h,n){h=h-0x1bb;const B=Q();let G=B[h];return G;}function Q(){const j=['patch','length','Invalid\x20setting\x20key:\x20','query'];Q=function(){return j;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../errors.js';function
|
|
1
|
+
import{ForbiddenError}from'../../errors.js';function Q(){var G=['User\x20required','admin','permissions','includes'];Q=function(){return G;};return Q();}function k(h,n){h=h-0x10b;var B=Q();var G=B[h];return G;}export function requireAdmin(h,n){var B=k;if(!h)throw new ForbiddenError(B(0x10b));if(h['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(h['type']!==B(0x10c)&&n&&!h[B(0x10d)]?.[B(0x10e)](n))throw new ForbiddenError('Missing\x20permission:\x20'+n);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export const safeUser=h=>{const f=k,n=['password','salt','secret',f(0x1c2)];return Object[f(0x1c3)](Object['entries'](h)['filter'](([B])=>!n[f(0x1c4)](G=>B[f(0x1c5)]()['includes'](G))));};function k(h,n){h=h-0x1c2;const B=Q();let G=B[h];return G;}function Q(){const j=['credentials','fromEntries','some','toLowerCase'];Q=function(){return j;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../errors.js';function
|
|
1
|
+
import{UnsupportedError}from'../../errors.js';export function unsupported(h){throw new UnsupportedError(h+'\x20requires\x20a\x20project/provider\x20implementation');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{writeAudit}from'./services/write-audit.js';export function createAudit(
|
|
1
|
+
import{writeAudit}from'./services/write-audit.js';export function createAudit(h){const n=writeAudit(h);return{'write':n};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0xfb;const B=Q();let G=B[h];return G;}function Q(){const p=['isArray','entries','[REDACTED]','query','then','rows','admin.audit_log','admin.audit_log_data','Unable\x20to\x20check\x20audit\x20tables;\x20audit\x20writes\x20are\x20disabled','changes','map','oldValue','newValue','resource','fields','metadata','test','field'];Q=function(){return p;};return Q();}const secretPattern=/password|token|secret|credential|salt/i;function clean(h){const P=k;if(Array[P(0xfb)](h))return h['map'](clean);if(h&&typeof h==='object')return Object['fromEntries'](Object[P(0xfc)](h)['map'](([n,B])=>[n,secretPattern['test'](n)?P(0xfd):clean(B)]));return h;}export function writeAudit(h){let n,B;async function G(){const u=k;if(!h['pg'])return![];if(n!==undefined)return n;return B??=h['pg'][u(0xfe)]('\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\x20IN\x20(\x27audit_log\x27,\x20\x27audit_log_data\x27)\x0a\x20\x20\x20\x20\x20\x20\x20\x20')[u(0xff)](f=>{const X=u,j=new Set(f[X(0x100)]['map'](Z=>Z['table_name']));return n=j['has']('audit_log')&&j['has']('audit_log_data'),!n&&h['logger']['warn']({'expectedTables':[X(0x101),X(0x102)],'foundTables':[...j]},'Audit\x20tables\x20are\x20unavailable;\x20audit\x20writes\x20are\x20disabled'),n;})['catch'](f=>{const H=u;return n=![],h['logger']['warn']({'err':f},H(0x103)),![];}),B;}return async function f(j){const i=k;if(!await G())return h['logger']['info']({'auditFallback':!![],'event':clean({...j,'changes':j[i(0x104)]?.[i(0x105)](b=>({...b,'oldValue':clean(b[i(0x106)]),'newValue':clean(b[i(0x107)])}))})},'audit'),0x0;if(!h['pg'])throw new Error('empty\x20pg');const Z=await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20user_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20resource_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fields,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20action,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ip_address,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20metadata\x0a\x20\x20\x20\x20\x20\x20\x20\x20)\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\x20id\x0a\x20\x20\x20\x20\x20\x20',[j['userId']??null,j['module'],j[i(0x108)],j['resourceId']==null?null:String(j['resourceId']),j[i(0x109)]??null,j['action'],j['requestId']??null,j['ipAddress']??null,clean(j[i(0x10a)]??{})]),e=Z['rows'][0x0]['id'];for(const b of j['changes']??[]){if(secretPattern[i(0x10b)](b['field']))continue;await h['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20INSERT\x20INTO\x20admin.audit_log_data\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20audit_log_id,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20field,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20old_value,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20new_value\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\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',[e,b[i(0x10c)],JSON['stringify'](clean(b['oldValue'])),JSON['stringify'](clean(b['newValue']))]);}return e;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const j=['rows'];Q=function(){return j;};return Q();}function k(h,n){h=h-0x17c;const B=Q();let G=B[h];return G;}export async function getUserPermissions(h,n){const f=k,B=await n['pg']['query']('\x0a\x20\x20\x20\x20\x20\x20SELECT\x20DISTINCT\x20ra.resource\x20||\x20\x27:\x27\x20||\x20action\x20AS\x20permission\x0a\x20\x20\x20\x20\x20\x20FROM\x20admin.role_access\x20ra\x0a\x20\x20\x20\x20\x20\x20LEFT\x20JOIN\x20admin.user_roles\x20ur\x20ON\x20ur.role_id\x20=\x20ra.role_id\x0a\x20\x20\x20\x20\x20\x20CROSS\x20JOIN\x20LATERAL\x20unnest(COALESCE(ra.actions,\x20\x27{}\x27::text[]))\x20AS\x20action\x0a\x20\x20\x20\x20\x20\x20WHERE\x20ra.user_uid\x20=\x20$1\x20OR\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20',[h]);return B[f(0x17c)]['map'](G=>G['permission']);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const H=k;export*from'./auth.types.js';import{randomBytes,scrypt as h,timingSafeEqual}from'node:crypto';import{mkdir,readFile,unlink,writeFile}from'node:fs/promises';function Q(){const U=['get','code','set','stringify','destroy','catch','toString','hex','from','test','redis','host','database','./storage','register','secureSession','registerUserDeserializer'];Q=function(){return U;};return Q();}import{join,resolve}from'node:path';import{promisify}from'node:util';const scrypt=promisify(h);function k(h,n){h=h-0x102;const B=Q();let G=B[h];return G;}import n from'@fastify/cookie';import B from'@fastify/session';import{Authenticator}from'@fastify/passport';import G from'fastify-session-redis-store';import{getUserPermissions}from'./get-user-permissions.js';const fastifyPassport=new Authenticator();class FileSessionStore{['path'];constructor(f){this['path']=f,void mkdir(this['path'],{'recursive':!![]});}['fileFor'](f){return join(this['path'],f+'.json');}async[H(0x102)](f,j){const i=H;try{const Z=await readFile(this['fileFor'](f),'utf8');j(null,JSON['parse'](Z));}catch(e){const b=e;if(b[i(0x103)]==='ENOENT'){j(null,undefined);return;}j(b,undefined);}}async[H(0x104)](f,j,Z){const p=H;try{await mkdir(this['path'],{'recursive':!![]}),await writeFile(this['fileFor'](f),JSON[p(0x105)](j),'utf8'),Z();}catch(e){Z(e);}}async[H(0x106)](f,j){const z=H;try{await unlink(this['fileFor'](f))[z(0x107)](Z=>{if(Z['code']!=='ENOENT')throw Z;}),j();}catch(Z){j(Z);}}}export*from'./verifyUser.js';export*from'./get-user-permissions.js';export async function hashPassword(f){const t=H,j=randomBytes(0x10),Z=await scrypt(f,j,0x40);return'scrypt$'+j[t(0x108)](t(0x109))+'$'+Z['toString']('hex');}export async function verifyPassword(f,j){const m=H,[Z,e,b]=j?.['split']('$')||[];if(Z!=='scrypt'||!e||!b)return![];const P=Buffer[m(0x10a)](e,'hex'),u=Buffer[m(0x10a)](b,'hex'),X=await scrypt(f,P,u['length']);return timingSafeEqual(X,u);}export async function createSessionStore(f,j){const A=H,{config:Z,redis:e}=j;if(!Z){console['warn']('Missing\x20config\x20-\x20skipping\x20session\x20store\x20creation');return;}if(process.env.NODE_ENV===A(0x10b)||process.env.VITEST)return;await f['register'](n,{'parseOptions':Z['auth']['cookieOptions']});const b=Z[A(0x10c)][A(0x10d)]?new G({'prefix':Z['auth']['cookieName']+':'+(Z['pg']?.[A(0x10e)]||'db')+':','client':e}):new FileSessionStore(resolve(Z['storagePath']??A(0x10f),'sessions'));await f['register'](B,{'secret':Z['auth']['secret'],'cookieName':Z['auth']['cookieName'],'cookie':Z['auth']['cookieOptions'],'store':b}),await f['register'](fastifyPassport['initialize']()),await f[A(0x110)](fastifyPassport[A(0x111)]()),fastifyPassport['registerUserSerializer'](async P=>({'user':P})),fastifyPassport[A(0x112)](async P=>{const u=P?.['user']||P;return u?.['id']&&(u['permissions']=await getUserPermissions(u['id'],j)),u;});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{BadRequestError}from'../../errors.js';import{verifyPassword}from'./index.js';function Q(){const X=['metrics','rows','info'];Q=function(){return X;};return Q();}function k(h,n){h=h-0xe6;const B=Q();let G=B[h];return G;}export async function verifyUser({user:h,password:n,ip:B},{pg:G,logger:f}){const u=k;if(!h||h==='')throw new BadRequestError('not\x20enough\x20params:\x20user');if(!n||n==='')throw new BadRequestError('not\x20enough\x20params:\x20password');f[u(0xe6)]('user.login');const j='select\x20uid\x20as\x20id,\x20user_type\x20as\x20type,\x20password_hash,\x20twofa,\x20first_name,\x20middle_name,last_name,email,phone,avatar,last_activity_date\x20from\x20admin.users\x20where\x20$1\x20in\x20(login,email,phone)\x20and\x20enabled\x20limit\x201',Z=await G['query'](j,[h])['then'](b=>b[u(0xe7)]?.[0x0]);if(!Z){const b='user\x20not\x20found';f[u(0xe8)]({'file':'auth/warn','error':b,'user':h,'ip':B});throw new BadRequestError(b);}const e=await verifyPassword(n,Z['password_hash']);if(!e){const P='Wrong\x20password';f['info']({'file':'auth/warn','error':P,'user':h,'ip':B});throw new BadRequestError(P);}return G['query']('update\x20admin.users\x20set\x20last_activity_date\x20=\x20now()\x20where\x20uid\x20=\x20$1',[Z['id']]),delete Z['password_hash'],Z;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function
|
|
1
|
+
import{ConflictError,NotFoundError,ValidationError}from'../errors.js';function k(h,n){h=h-0x12f;const B=Q();let G=B[h];return G;}const dictionaryName=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;function Q(){const r=['\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','test','isArray','code','set','static','checked','rows','items','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','fcore','DELETE\x20FROM\x20admin.dictionary_items\x20WHERE\x20dictionary_id\x20=\x20$1','name'];Q=function(){return r;};return Q();}export function createDictionary({pg:h,dictionaries:dictionaries=[]}){const n=new Map(),B=new Map();let G,f;async function j(){const d=k;if(G!==undefined)return G;if(!h)throw new Error('empty\x20pg');return f??=h['query'](d(0x12f))['then'](p=>{const z=p['rows'][0x0]?.['table_name'];G=z==='dictionaries'?z:null;}),await f,G;}function Z(p){const W=k;if(!dictionaryName[W(0x130)](p))throw new ValidationError('Invalid\x20dictionary\x20name:\x20'+p);}function e(p){const V=k;for(const z of Array[V(0x131)](p)?p:[p]){Z(z[V(0x132)]);if(!Array[V(0x131)](z['items']))throw new ValidationError('Invalid\x20dictionary\x20items:\x20'+z['code']);if(n['has'](z[V(0x132)]))throw new ConflictError('Dictionary\x20already\x20registered:\x20'+z['code']);n[V(0x133)](z[V(0x132)],{...z,'source':V(0x134)});}}function b(p){return n['has'](p);}async function P(p){const q=k;Z(p);const z=n['get'](p);if(z&&z[q(0x135)])return z['items'];const t=await j();if(!t)throw new NotFoundError('Dictionary\x20table\x20not\x20found');const m=await h?.['query']('\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',[p]);if(m?.[q(0x136)]?.['length']){const A=m?.['rows'];return n['set'](p,{'code':p,'name':p,'items':A,'source':'database','checked':!![]}),A;}if(!z?.[q(0x137)])throw new NotFoundError('Dictionary\x20not\x20found:\x20'+p);return z[q(0x135)]=!![],z[q(0x137)];}async function u(p,z){const y=k;Z(p);if(!Array['isArray'](z))throw new ValidationError(y(0x138));const t=await j();if(!t)throw new NotFoundError('Dictionary\x20table\x20not\x20found');if(!h)throw new Error(y(0x139));const m=await h['connect']();try{await m[y(0x13a)]('BEGIN');const A=await m['query'](y(0x13b),[p,p,y(0x13c),'custom',!![]]),U=A['rows'][0x0]['id'];await m['query'](y(0x13d),[U]);for(const O of z){await m['query']('\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',[U,O['code'],O[y(0x13e)],O['parentId']??null]);}await m[y(0x13a)]('COMMIT');}catch(T){await m[y(0x13a)]('ROLLBACK');throw T;}finally{m['release']();}n[y(0x133)](p,{'items':z,'code':p,'source':y(0x134),'checked':!![]}),B['set'](p,(B['get'](p)??0x0)+0x1);}function X(p){return Z(p),B['set'](p,(B['get'](p)??0x0)+0x1),n['delete'](p);}function H(p){return B['get'](p)??0x0;}async function i(){const Y=k,p=[...n['values']()]['map'](({code:m,name:A,source:U})=>({'code':m,'name':A??m,'source':U})),z=await j();if(!z)return p;if(!h)throw new Error(Y(0x139));const t=await h[Y(0x13a)]('\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 m of t['rows']){!n['has'](m[Y(0x132)])&&p['push'](m);}return p;}return e(dictionaries),{'register':e,'get':P,'put':u,'clear':X,'revision':H,'list':i,'has':b};}
|
package/dist/plugins/file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import h from'node:fs/promises';import n from'node:path';import{DeleteObjectCommand,GetObjectCommand,HeadObjectCommand,PutObjectCommand,S3Client}from'@aws-sdk/client-s3';import B from'node:crypto';import{ValidationError}from'../errors.js';import{UnauthorizedError}from'../errors.js';function normalizeRelativePath(G){const t=k;if(!G||G['startsWith']('/')||G[t(0x7b)]('..'))throw new ValidationError('Invalid\x20file\x20path');return G[t(0x7c)](/\\/g,'/')[t(0x7c)](/^\/+/,'');}function Q(){const R=['includes','replace','storagePath','join','toString','relative','Invalid\x20file\x20path','readFile','mkdir','rename','tokenTtl','from','base64url','sha256','update','digest','length','timingSafeEqual','tokenSecret','region','us-east-1','forcePathStyle','secretKey','bucket','send','httpStatusCode','Invalid\x20file\x20token'];Q=function(){return R;};return Q();}function keyFor(G,f){const m=k;return''+((G??'')[m(0x7c)](/^\/+|\/+$/g,'')?(G??'')[m(0x7c)](/^\/+|\/+$/g,'')+'/':'')+normalizeRelativePath(f);}async function bodyToBuffer(G){if(!G)return Buffer['alloc'](0x0);const f=G;if(typeof f['transformToByteArray']==='function')return Buffer['from'](await f['transformToByteArray']());const j=[];for await(const Z of G){j['push'](Buffer['from'](Z));}return Buffer['concat'](j);}function k(h,n){h=h-0x7b;const B=Q();let G=B[h];return G;}export function createFileLocal(G){const A=k,f=n['resolve'](G[A(0x7d)]||'./storage'),j=n[A(0x7e)](f,'removed'),Z=G['tokenSecret']??process.env.FILE_TOKEN_SECRET??B['randomBytes'](0x20)[A(0x7f)]('hex'),e=u=>{const X=normalizeRelativePath(u),H=(G['folder']??'files')['replace'](/^\/+|\/+$/g,'');return H?n['join'](H,X):X;},b=u=>{const X=e(u),H=n['resolve'](f,X),i=n['relative'](f,H);if(i['startsWith']('..')||n['isAbsolute'](i))throw new ValidationError('Invalid\x20file\x20path');return H;},P=u=>{const U=A,X=e(u),H=n['resolve'](j,X),i=n[U(0x80)](j,H);if(i['startsWith']('..')||n['isAbsolute'](i))throw new ValidationError(U(0x81));return H;};return{async 'put'(u,X){const H=b(u);await h['mkdir'](n['dirname'](H),{'recursive':!![]}),await h['writeFile'](H,X instanceof Buffer?X:await bodyToBuffer(X));},async 'get'(u){const O=A;return h[O(0x82)](b(u));},async 'exists'(u){try{return await h['access'](b(u)),!![];}catch{return![];}},async 'delete'(u){const T=A,X=b(u),H=P(u);try{await h[T(0x83)](n['dirname'](H),{'recursive':!![]}),await h[T(0x84)](X,H);}catch(i){const p=i;if(p['code']!=='ENOENT')throw i;}},'create'(u,X=G[A(0x85)]??0xe10){const d=A,H=Buffer[d(0x86)](u)['toString'](d(0x87)),i=B['createHmac'](d(0x88),Z)[d(0x89)](H)[d(0x8a)]('base64url');return H+'.'+i;},'verify'(u){const W=A,[X,H]=u['split']('.');if(!X||!H)throw new UnauthorizedError('Invalid\x20file\x20token');const i=B['createHmac'](W(0x88),Z)['update'](X)['digest'](),p=Buffer['from'](H,W(0x87));if(i[W(0x8b)]!==p['length']||!B[W(0x8c)](i,p))throw new UnauthorizedError('Invalid\x20file\x20token');const z=Buffer[W(0x86)](X,W(0x87))['toString']('utf8');return z;}};}export function createFileS3(G){const V=k,f=G[V(0x8d)]??process.env.FILE_TOKEN_SECRET??B['randomBytes'](0x20)['toString']('hex'),j=new S3Client({'endpoint':G['endpoint'],'region':G[V(0x8e)]??V(0x8f),'forcePathStyle':G[V(0x90)]??!![],'credentials':G['accessKeyId']||G['accessKey']?{'accessKeyId':G['accessKeyId']??G['accessKey'],'secretAccessKey':G['secretAccessKey']??G[V(0x91)]}:undefined}),Z=e=>keyFor(G['folder'],e);return{async 'put'(e,b){const q=V;await j['send'](new PutObjectCommand({'Bucket':G[q(0x92)],'Key':Z(e),'Body':b}));},async 'get'(e){const y=V,b=await j[y(0x93)](new GetObjectCommand({'Bucket':G[y(0x92)],'Key':Z(e)}));return bodyToBuffer(b['Body']);},async 'exists'(e){const Y=V;try{return await j['send'](new HeadObjectCommand({'Bucket':G[Y(0x92)],'Key':Z(e)})),!![];}catch(b){const P=b;if(P['$metadata']?.[Y(0x94)]===0x194||P['name']==='NotFound')return![];throw b;}},async 'delete'(e){await j['send'](new DeleteObjectCommand({'Bucket':G['bucket'],'Key':Z(e)}));},'create'(e,b=G['tokenTtl']??0xe10){const r=V,P=Buffer[r(0x86)](e)['toString']('base64url'),u=B['createHmac'](r(0x88),f)['update'](P)['digest']('base64url');return P+'.'+u;},'verify'(e){const v=V,[b,P]=e['split']('.');if(!b||!P)throw new UnauthorizedError('Invalid\x20file\x20token');const u=B['createHmac']('sha256',f)[v(0x89)](b)['digest'](),X=Buffer['from'](P,'base64url');if(u['length']!==X['length']||!B['timingSafeEqual'](u,X))throw new UnauthorizedError(v(0x95));const H=Buffer['from'](b,v(0x87))['toString']('utf8');return H;}};}
|
package/dist/plugins/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{SignJWT,jwtVerify}from'jose';function k(h,n){h=h-0x120;const B=Q();let G=B[h];return G;}const secret=new TextEncoder()['encode'](process.env.AUTH_JWT_SECRET);function Q(){const e=['catch','log','message','payload'];Q=function(){return e;};return Q();}export async function jwtSignToken(h){if(!process.env.AUTH_JWT_SECRET)return;const {id:n,type:B,permissions:G}=h,f=await new SignJWT({'id':n,'type':B,'permissions':G})['setProtectedHeader']({'alg':'HS256'})['setIssuedAt']()['setExpirationTime']('1h')['sign'](secret);return f;}export async function jwtVerifyToken(h){const j=k,n=await jwtVerify(h,secret,{'algorithms':['HS256']})[j(0x120)](B=>{const Z=j;console[Z(0x121)](B[Z(0x122)]);});return n?.[j(0x123)];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import h from'pino';export function createLogger(){const e=k,n=h['transport']({'target':'./transport.js'}),B=h({'level':'info','timestamp':h[e(0x1ef)][e(0x1f0)],'base':{'service':'app'},'redact':{'paths':['req.headers.authorization',e(0x1f1),'token','accessToken',e(0x1f2)],'censor':'[REDACTED]'}},n),G={};function f(j,Z){if(j===undefined)return{...G};G[j]=(G[j]??0x0)+(Z??0x1);}return Object[e(0x1f3)](B,{'close':async()=>n[e(0x1f4)](),'metrics':f,'file':()=>B[e(0x1f5)]['bind'](B)});}function k(h,n){h=h-0x1ef;const B=Q();let G=B[h];return G;}function Q(){const b=['stdTimeFunctions','isoTime','password','refreshToken','assign','end','info'];Q=function(){return b;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=k;import h from'node:fs';import n from'node:path';import B from'pino-abstract-transport';function Q(){const X=['info','warn','error','slice','createWriteStream','set'];Q=function(){return X;};return Q();}const LEVELS={0x1e:e(0x16a),0x28:e(0x16b),0x32:e(0x16c),0x3c:'error'},streams=new Map();function getDate(){const b=e;return new Date()['toISOString']()[b(0x16d)](0x0,0xa);}function createStream(G,f){const P=e,j=n['resolve']('logs',G);return h['mkdirSync'](j,{'recursive':!![]}),h[P(0x16e)](n['join'](j,f+'.log'),{'flags':'a'});}function getStream(G){const u=e,f=getDate(),j=streams['get'](G);if(j&&j['date']===f)return j['stream'];j?.['stream']['end']();const Z=createStream(G,f);return streams[u(0x16f)](G,{'date':f,'stream':Z}),Z;}function k(h,n){h=h-0x16a;const B=Q();let G=B[h];return G;}function closeStreams(){for(const {stream:G}of streams['values']()){G['end']();}streams['clear']();}export default async function loggerTransport(){return B(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(G){for await(const f of G){const j=LEVELS[f['level']];if(!j)continue;const Z=getStream(f['file']||j);delete f['file'],Z['write'](JSON['stringify'](f)+'\x0a');}}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import h from'pg';function k(h,n){h=h-0x8b;const B=Q();let G=B[h];return G;}const {Pool}=h;export function createDatabase(n){const H=k,B=new Pool(n),G=B['query']['bind'](B);function f(j,Z){const X=k,e=new Error();return Error['captureStackTrace']?.(e,f),G(j,Z)[X(0x8b)](b=>{const P=b;P['sql']=j,P['callerStack']=e['stack'];throw P;});}return B['query']=f,B[H(0x8c)]=async function(j){const i=H,Z=new Error();Error[i(0x8d)]?.(Z,B[i(0x8c)]);const e=await B[i(0x8e)]();try{await e['query']('BEGIN');const b=await j(e);return await e['query']('COMMIT'),b;}catch(P){await e['query'](i(0x8f));const u=P;u[i(0x90)]=Z['stack'];throw u;}finally{e[i(0x91)]();}},B;}function Q(){const p=['catch','transaction','captureStackTrace','connect','ROLLBACK','callerStack','release'];Q=function(){return p;};return Q();}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{Redis}from'ioredis';export function createRedis(h){const Z=k;console[Z(0xcd)](Z(0xce),h);const n=new Redis(h);return{'get':B=>n[Z(0xcf)](B),'set':(B,G,f,j)=>{if(j)return n['set'](B,G,'EX',j);if(typeof f==='number')return n['set'](B,G,'EX',f);return n['set'](B,G);},'del':B=>n['del'](B),'delete':B=>n[Z(0xd0)](B),'close':()=>n['quit'](),'ping':()=>n['ping'](),'hincrby':(B,G,f)=>n['hincrby'](B,G,f),'incrby':(B,G)=>n['incrby'](B,G)};}function k(h,n){h=h-0xcd;const B=Q();let G=B[h];return G;}function Q(){const e=['log','Creating\x20Redis\x20client\x20with\x20config:','get','del'];Q=function(){return e;};return Q();}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ResourceDependencies, ResourcePlugin } from
|
|
1
|
+
import type { ResourceDependencies, ResourcePlugin } from "./resource.types.js";
|
|
2
2
|
export declare function createResource(deps: ResourceDependencies): ResourcePlugin;
|
|
3
3
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA4BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';function Q(){const H=['bind','has','get'];Q=function(){return H;};return Q();}import{createFindOne}from'./services/find-one.js';function k(h,n){h=h-0x1a5;const B=Q();let G=B[h];return G;}import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';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(h){const X=k,n=new ResourceRegistry(),B=createFind(h,n),G=createFindOne(h,n),f=createCreate(h,n),j=createUpdate(h,n),Z=createRemove(h,n),e=createFindRelation(h,n),b=createCreateRelation(h,n),P=createUpdateRelation(h,n),u=createDeleteRelation(h,n);return{'register':n['register']['bind'](n),'unregister':n['unregister'][X(0x1a5)](n),'has':n[X(0x1a6)][X(0x1a5)](n),'get':n[X(0x1a7)][X(0x1a5)](n),'list':n['list']['bind'](n),'find':B,'findOne':G,'create':f,'update':j,'delete':Z,'findRelation':e,'createRelation':b,'updateRelation':P,'deleteRelation':u};}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ResourceContract } from
|
|
1
|
+
import type { ResourceContract } from "./resource.types.js";
|
|
2
2
|
export declare class ResourceRegistry {
|
|
3
3
|
private readonly resources;
|
|
4
|
-
|
|
4
|
+
unregister(name: string): void;
|
|
5
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
5
6
|
has(name: string): boolean;
|
|
6
7
|
get(name: string): ResourceContract;
|
|
7
8
|
list(): ResourceContract[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IACjE,UAAU,CAAC,IAAI,EAAE,MAAM,QAEtB;IACD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,SAAS,UAAQ,QAUvE;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,WAEf;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,oBAIf;IAED,IAAI,uBAEH;IAED,OAAO,CAAC,QAAQ;CAajB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0x111;const B=Q();let G=B[h];return G;}function Q(){const u=['split','test','resources','register','name','set','get','values','table'];Q=function(){return u;};return Q();}const f=k;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(h){const G=k;return h[G(0x111)]('.')['length']<=0x2&&h['split']('.')['every'](n=>ident[G(0x112)](n));}export class ResourceRegistry{[f(0x113)]=new Map();['unregister'](h){const j=f;this[j(0x113)]['delete'](h);}[f(0x114)](h,n=![]){const Z=f;for(const B of Array['isArray'](h)?h:[h]){this['validate'](B);if(this['resources']['has'](B[Z(0x115)])&&!n)throw new ConflictError('Resource\x20already\x20registered:\x20'+B['name']);this['resources'][Z(0x116)](B[Z(0x115)],B);}}['has'](h){return this['resources']['has'](h);}['get'](h){const e=f,n=this[e(0x113)][e(0x117)](h);if(!n)throw new NotFoundError('Resource\x20not\x20registered:\x20'+h);return n;}['list'](){const b=f;return[...this['resources'][b(0x118)]()];}['validate'](h){const P=f;if(h['version']!==0x1||!ident['test'](h['name'])||!validQualified(h[P(0x119)])||!ident['test'](h['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+h['name']);for(const [n,B]of Object['entries'](h['fields'])){if(!ident['test'](n)||!ident['test'](B['column']??n))throw new ValidationError('Invalid\x20resource\x20field:\x20'+n);}}}
|
|
@@ -8,12 +8,12 @@ import type { DictionaryPlugin } from "../dictionary.js";
|
|
|
8
8
|
import type { FileAdapter } from "../file.js";
|
|
9
9
|
import { User } from "../../context.js";
|
|
10
10
|
import type { AppContext } from "../../context.js";
|
|
11
|
-
export type ResourceAggregate =
|
|
11
|
+
export type ResourceAggregate = "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
|
|
12
12
|
export type ResourceSummaryItem = {
|
|
13
|
-
aggregate:
|
|
13
|
+
aggregate: "count";
|
|
14
14
|
where?: string;
|
|
15
15
|
} | {
|
|
16
|
-
aggregate:
|
|
16
|
+
aggregate: "countDistinct" | "sum" | "avg" | "min" | "max";
|
|
17
17
|
field: string;
|
|
18
18
|
where?: string;
|
|
19
19
|
} | {
|
|
@@ -38,6 +38,7 @@ export interface ResourceFieldContract {
|
|
|
38
38
|
readable?: boolean;
|
|
39
39
|
writable?: boolean;
|
|
40
40
|
required?: boolean;
|
|
41
|
+
code_template?: string;
|
|
41
42
|
nullable?: boolean;
|
|
42
43
|
filterable?: boolean;
|
|
43
44
|
searchable?: boolean;
|
|
@@ -58,7 +59,9 @@ export interface ResourceFieldContract {
|
|
|
58
59
|
maximum?: number;
|
|
59
60
|
pattern?: string;
|
|
60
61
|
}
|
|
62
|
+
export type ResourceRelationType = 'one' | 'many';
|
|
61
63
|
export interface ResourceRelationContract {
|
|
64
|
+
type?: ResourceRelationType;
|
|
62
65
|
resource?: string;
|
|
63
66
|
table?: string;
|
|
64
67
|
where?: string;
|
|
@@ -79,6 +82,7 @@ export interface ResourceContract {
|
|
|
79
82
|
table: string;
|
|
80
83
|
where?: string;
|
|
81
84
|
key: string;
|
|
85
|
+
display?: string[] | string;
|
|
82
86
|
operations: ResourceOperation[];
|
|
83
87
|
searchable?: string[];
|
|
84
88
|
capabilities?: string[];
|
|
@@ -90,6 +94,19 @@ export interface ResourceContract {
|
|
|
90
94
|
summary?: Record<string, ResourceSummaryItem>;
|
|
91
95
|
scopes?: Record<string, string | ResourceScope>;
|
|
92
96
|
}
|
|
97
|
+
export interface ResourceVariableDto {
|
|
98
|
+
key: string;
|
|
99
|
+
path: string;
|
|
100
|
+
title?: string;
|
|
101
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
102
|
+
resource?: string;
|
|
103
|
+
variables?: ResourceVariableDto[];
|
|
104
|
+
}
|
|
105
|
+
export interface ResourceSchemaDto {
|
|
106
|
+
resource: string;
|
|
107
|
+
title?: string;
|
|
108
|
+
variables: ResourceVariableDto[];
|
|
109
|
+
}
|
|
93
110
|
export interface ResourceQuery {
|
|
94
111
|
filter?: Record<string, unknown>;
|
|
95
112
|
include?: string | string[];
|
|
@@ -105,6 +122,7 @@ export interface ResourceListResult<T = Record<string, unknown>> {
|
|
|
105
122
|
summary: Record<string, unknown>;
|
|
106
123
|
limit: number;
|
|
107
124
|
time: number;
|
|
125
|
+
fields?: Record<string, ResourceFieldContract>;
|
|
108
126
|
count: number | null;
|
|
109
127
|
total: number | null;
|
|
110
128
|
offset: number;
|
|
@@ -118,7 +136,8 @@ export interface ResourceDependencies {
|
|
|
118
136
|
file?: FileAdapter;
|
|
119
137
|
}
|
|
120
138
|
export interface ResourcePlugin {
|
|
121
|
-
register(input: ResourceContract | ResourceContract[]): void;
|
|
139
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
140
|
+
unregister(name: string): void;
|
|
122
141
|
has(name: string): boolean;
|
|
123
142
|
get(name: string): ResourceContract;
|
|
124
143
|
list(): ResourceContract[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,eAAe,GACf,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAC3B;
|
|
1
|
+
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,eAAe,GACf,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAC3B;IACE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACD;IACE,SAAS,EAAE,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACD;IACE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEN,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,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AM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EACD,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC,GAAG,CAAC,CAAC;IAChB,cAAc,CACZ,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EACD,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACpC,cAAc,CACZ,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EACD,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const p=['get','set','length','all','code','color','icon','revision','map','_data'];Q=function(){return p;};return Q();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();function k(h,n){h=h-0x103;const B=Q();let G=B[h];return G;}async function getDictionaryIndexes(h,n){const X=k,B=dictionaryIndexesCache[X(0x103)](n)??new Map(),G=dictionaryRevisionsCache[X(0x103)](n)??new Map();dictionaryIndexesCache['set'](n,B),dictionaryRevisionsCache[X(0x104)](n,G);const f=h['filter'](Z=>G['get'](Z)!==n['revision'](Z));if(f[X(0x105)]===0x0)return B;const j=await Promise[X(0x106)](f['map'](async Z=>{const H=X;if(!n['has'](Z))return[Z,new Map()];const e=await n['get'](Z),b=new Map();for(const P of e){const u=P[H(0x107)]??P['id'];if(u==null)continue;b['set'](String(u),{'id':u,'text':P['name']??P['text'],...P['color']!==undefined?{'color':P[H(0x108)]}:{},...P['icon']!==undefined?{'icon':P[H(0x109)]}:{}});}return[Z,b];}));for(const [Z,e]of j){B['set'](Z,e),G['set'](Z,n[X(0x10a)](Z));}return B;}export async function addDictionaryLookupData(h,n,B){const i=k;if(!B||h[i(0x105)]===0x0)return h;const G=Object['entries'](n)['flatMap'](([j,Z])=>{const e=Z['dictionary'];return e?[{'field':j,'dictionaryName':e}]:[];});if(G['length']===0x0)return h;const f=await getDictionaryIndexes([...new Set(G[i(0x10b)](({dictionaryName:j})=>j))],B);for(const j of h){for(const {field:Z,dictionaryName:e}of G){const b=j[Z];j[Z+i(0x10c)]=b==null?null:f['get'](e)?.['get'](String(b))??null;}}return h;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const b=['string','length','create'];Q=function(){return b;};return Q();}function k(h,n){h=h-0x188;const B=Q();let G=B[h];return G;}export function addFileToken(h,n,B){const e=k;if(!B||h['length']===0x0)return h;const G=Object['entries'](n)['filter'](([,f])=>f['type']==='file')['map'](([f])=>f);for(const f of h){for(const j of G){const Z=f[j];typeof Z===e(0x188)&&Z[e(0x189)]>0x0&&(f[j]=B[e(0x18a)](Z));}}return h;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();export function clearTableLookupCache(
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';function k(h,n){h=h-0x19c;const B=Q();let G=B[h];return G;}const tableLookupCache=new WeakMap();export function clearTableLookupCache(h,n){const m=k,B=tableLookupCache[m(0x19c)](n);if(!B)return;for(const G of B[m(0x19d)]()){G['startsWith'](h+':')&&B['delete'](G);}}function Q(){const U=['get','keys','length','set','flatMap','field','table','text','filter','SELECT\x20','\x20AS\x20id,\x20','\x20=\x20ANY($1)','_data'];Q=function(){return U;};return Q();}export async function addTableLookupData(h,n,B){const A=k;if(!B||h[A(0x19e)]===0x0)return h;const G=tableLookupCache[A(0x19c)](B)??new Map();tableLookupCache[A(0x19f)](B,G);const f=Object['entries'](n)[A(0x1a0)](([j,Z])=>{const {table:e,value:value='id',text:text='name'}=Z['lookup']??{};return e?[{'field':j,'table':e,'value':value,'text':text}]:[];});for(const j of f){const Z=new Map();for(const u of h){const X=u[j[A(0x1a1)]];(typeof X==='string'||typeof X==='number')&&Z['set'](String(X),X);}const e=j[A(0x1a2)]+':'+j['value']+':'+j[A(0x1a3)],b=G[A(0x19c)](e)??new Map();G['set'](e,b);const P=[...Z['entries']()][A(0x1a4)](([H])=>!b['has'](H))['map'](([,H])=>H);if(P[A(0x19e)]>0x0){const H=await B['query'](A(0x1a5)+qi(j['value'])+A(0x1a6)+qi(j[A(0x1a3)])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(j['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(j['value'])+A(0x1a7),[P]);for(const i of H['rows']){b['set'](String(i['id']),i);}for(const p of P){!b['has'](String(p))&&b[A(0x19f)](String(p),null);}}for(const z of h){const t=z[j[A(0x1a1)]];z[j['field']+A(0x1a8)]=t==null?null:b['get'](String(t))??null;}}return h;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';function k(h,n){h=h-0xed;const B=Q();let G=B[h];return G;}function Q(){const A=['get','gallery','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20capabilities\x20\x22','query','filePath','rows','INSERT\x20INTO\x20admin.gallery\x20(resource,\x20resource_id,\x20file_path,\x20size,\x20mime_type)\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*','size','resource','Relation\x20update\x20is\x20not\x20configured:\x20'];Q=function(){return A;};return Q();}import{createCreate}from'./create.js';export function createCreateRelation(h,n){const B=createCreate(h,n);return async function G({name:f,id:j,relation:Z,data:e,user:b},P){const m=k,u=P?.['pg']??h['pg'],X=n[m(0xed)](f);if(['notes','files',m(0xee)]['includes'](Z)&&!X['capabilities']?.['includes'](Z))throw new UnsupportedError(m(0xef)+Z+m(0xf0)+Z+'\x22');if(Z==='notes'){const p=await u[m(0xf1)]('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[f,String(j),e?.['body']]);return p['rows'][0x0];}if(Z==='files'){const z=await u['query']('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*',[f,String(j),e?.[m(0xf2)],e?.['size']??null]);return z[m(0xf3)][0x0];}if(Z==='gallery'){const t=await u['query'](m(0xf4),[f,String(j),e?.['filePath'],e?.[m(0xf5)]??null,e?.['mimeType']??'image/jpeg']);return t['rows'][0x0];}const H=X['relations']?.[Z];if(!H?.['foreignKey']||!H['resource']&&!H['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!e)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+e);if(!H[m(0xf6)])throw new UnsupportedError(m(0xf7)+Z);e[H['foreignKey']]=j;const i=await B({'name':H[m(0xf6)],'data':e??{},'user':b});return i;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function Q(){const A=['get','create','length','No\x20writable\x20fields','query','write','module','key','keys'];Q=function(){return A;};return Q();}function k(h,n){h=h-0x17c;const B=Q();let G=B[h];return G;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(h,n){return async function B({name:G,data:f,user:j},Z){const m=k,e=n[m(0x17c)](G);assertOperation(e,m(0x17d),j),validateInputData({'resource':e,'data':f});const b=writableData(e,f);e['fields']['created_at']&&b['push'](['created_at',new Date()]);e['fields']['created_by']&&b['push'](['created_by',j?.['id']]);if(!b[m(0x17e)])throw new ValidationError(m(0x17f));const P=b['map'](([z])=>qi(z)),u=b['map']((z,t)=>'$'+(t+0x1)),X=b['map'](([,z])=>z),H=Z?.['pg']??h['pg'],i=await H[m(0x180)]('INSERT\x20INTO\x20'+qt(e['table'])+'\x20('+P['join'](',\x20')+')\x20'+('VALUES\x20('+u['join'](',\x20')+')\x20')+'RETURNING\x20*',X),p=i['rows'][0x0];return clearTableLookupCache(e['table'],H),await(Z?.['audit']??h['audit'])?.[m(0x181)]({'userId':j?.['id'],'module':e[m(0x182)],'resource':e['name'],'resourceId':p[e[m(0x183)]],'action':m(0x17d),'fields':Object[m(0x184)](f)}),p;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';function
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function k(h,n){h=h-0x1a2;const B=Q();let G=B[h];return G;}export function createDeleteRelation(h,n){const B=createRemove(h,n);return async function G({name:f,id:j,relation:Z,relationId:e,user:b},P){const p=k,u=P?.['pg']??h['pg'],X=n['get'](f);if(['notes','files','gallery']['includes'](Z)&&!X['capabilities']?.['includes'](Z))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+Z+p(0x1a2)+Z+'\x22');if(Z==='notes')return await u[p(0x1a3)](p(0x1a4),[e,f,String(j)]),{'success':!![]};if(Z==='files')return await u['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[e,f,String(j)]),{'success':!![]};if(Z==='gallery')return await u[p(0x1a3)](p(0x1a5),[e,f,String(j)]),{'success':!![]};const H=X['relations']?.[Z];if(!H?.[p(0x1a6)]||!H['foreignKey'])throw new UnsupportedError(p(0x1a7)+Z+'\x22\x20requires\x20a\x20project/provider\x20implementation');const i=await B({'name':H['resource'],'id':e,'user':b,'where':{'column':H['foreignKey'],'value':j}},P);return{'success':i};};}function Q(){const z=['\x22\x20requires\x20a\x20capabilities\x20\x22','query','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','DELETE\x20FROM\x20admin.gallery\x20WHERE\x20id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','resource','Generic\x20Resource\x20relation\x20\x22'];Q=function(){return z;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function k(h,n){h=h-0x11c;const B=Q();let G=B[h];return G;}function Q(){const p=['\x20=\x20$1','\x20=\x20$','where','rowCount','audit','name'];Q=function(){return p;};return Q();}import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(h,n){return async function B({name:G,id:f,user:j,where:Z},e){const i=k,b=n['get'](G);assertOperation(b,'delete',j);const P=e?.['pg']??h['pg'],u=[f];let X='WHERE\x20'+qi(b['key'])+i(0x11c);Z&&(u['push'](Z['value']),X+='\x20AND\x20'+qi(Z['column'])+i(0x11d)+u['length']);b[i(0x11e)]&&(X+='\x20AND\x20('+b['where']+')');const H=await P['query']('DELETE\x20FROM\x20'+qt(b['table'])+'\x20'+X,u);if((H[i(0x11f)]??0x0)>0x0)clearTableLookupCache(b['table'],P);if((H['rowCount']??0x0)>0x0)await(e?.[i(0x120)]??h['audit'])?.['write']({'module':b['module'],'resource':b[i(0x121)],'resourceId':f,'action':'delete'});return(H['rowCount']??0x0)>0x0;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAQvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAQvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAkDF"}
|