@opengis/fcore 0.0.1-beta.12 → 0.0.1-beta.13
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/get-resource.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-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/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/resource.types.d.ts +6 -0
- 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.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/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/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError}from'../../../errors.js';
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(T,w){const j=createRemove(T,w);return async function N({name:Y,id:J,relation:q,relationId:O,user:X},b){const u=k,E=b?.['pg']??T['pg'],e=w[u(0x107)](Y);if(['notes','files']['includes'](q)&&!e['capabilities']?.['includes'](q))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+q+u(0x108)+q+'\x22');if(q==='notes')return await E['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[O,Y,String(J)]),{'success':!![]};if(q==='files')return await E['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[O,Y,String(J)]),{'success':!![]};const p=e['relations']?.[q];if(!p?.['resource']||!p['foreignKey'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+q+'\x22\x20requires\x20a\x20project/provider\x20implementation');const m=await j({'name':p['resource'],'id':O,'user':X,'where':{'column':p[u(0x109)],'value':J}},b);return{'success':m};};}function k(T,w){T=T-0x107;const j=t();let N=j[T];return N;}function t(){const r=['get','\x22\x20requires\x20a\x20capabilities\x20\x22','foreignKey'];t=function(){return r;};return t();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function k(T,w){T=T-0x13e;const j=t();let N=j[T];return N;}import{clearTableLookupCache}from'./add-table-lookup-data.js';function t(){const u=['get','WHERE\x20','key','push','\x20AND\x20','length','write'];t=function(){return u;};return t();}export function createRemove(T,w){return async function j({name:N,id:Y,user:J,where:q},O){const m=k,X=w[m(0x13e)](N);assertOperation(X,'delete',J);const b=O?.['pg']??T['pg'],E=[Y];let e=m(0x13f)+qi(X[m(0x140)])+'\x20=\x20$1';q&&(E[m(0x141)](q['value']),e+=m(0x142)+qi(q['column'])+'\x20=\x20$'+E[m(0x143)]);const p=await b['query']('DELETE\x20FROM\x20'+qt(X['table'])+'\x20'+e,E);if((p['rowCount']??0x0)>0x0)clearTableLookupCache(X['table'],b);if((p['rowCount']??0x0)>0x0)await(O?.['audit']??T['audit'])?.[m(0x144)]({'module':X['module'],'resource':X['name'],'resourceId':Y,'action':'delete'});return(p['rowCount']??0x0)>0x0;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
function k(T,w){T=T-0x153;const j=t();let N=j[T];return N;}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 t(){const H=['read','key','type','integer','isInteger','\x20name:','map','query','\x20t\x20','include','relations','foreignKey','Unknown\x20relation:\x20','join','\x20WHERE\x20','table','rows','dictionary','now'];t=function(){return H;};return t();}export function createFindOne(T,w){return async function j({name:N,id:Y,query:query={},user:J}){const a=k,q=Date['now'](),O=w['get'](N);assertOperation(O,a(0x153),J);if(O['fields'][O[a(0x154)]]?.[a(0x155)]===a(0x156)&&!Number[a(0x157)](Number(Y)))throw new ValidationError('Invalid\x20id:\x20'+Y+a(0x158)+N);const X=O['joins']?.[a(0x159)](p=>p['sql']+'\x20')['join']('\x20')||'',b=await T['pg'][a(0x15a)]('SELECT\x20'+readableFields(O)['join'](',\x20')+'\x20FROM\x20'+qt(O['table'])+a(0x15b)+X+'\x20WHERE\x20'+qi(O['key'])+'=$1\x20LIMIT\x201',[Y]),E=b['rows'][0x0];if(!E)return null;await addDictionaryLookupData([E],O['fields'],T['dictionary']),await addTableLookupData([E],O['fields'],T['pg']),addFileToken([E],O['fields'],T['file']);const e=Array['isArray'](query[a(0x15c)])?query[a(0x15c)]:query[a(0x15c)]?.['split'](',')??[];for(const p of e){const m=O[a(0x15d)]?.[p];if(!m?.[a(0x15e)]||!m['resource']&&!m['table'])throw new ValidationError(a(0x15f)+p);const u=m['resource']?w['get'](m['resource']):undefined,r=m['table']??u['table'],Z=u?.['key']??'id',f=u?readableFields(u)[a(0x160)](',\x20'):'*',P='SELECT\x20'+f+'\x20FROM\x20'+qt(r)+a(0x161)+qi(Z)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(m[a(0x15e)])+'\x20FROM\x20'+qt(O[a(0x162)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(O[a(0x154)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',h=(await T['pg'][a(0x15a)](P,[Y]))[a(0x163)];u&&(await addDictionaryLookupData(h,u['fields'],T[a(0x164)]),await addTableLookupData(h,u['fields'],T['pg']),addFileToken(h,u['fields'],T['file'])),E[p]=h;}return E['time']=Date[a(0x165)]()-q,E;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function t(){const D=['offset','isFinite','Invalid\x20pagination','notes','files','includes','Generic\x20Resource\x20relation\x20\x22','length','now','query','file','rows','junctionTable','junctionForeignKey','\x22\x20requires\x20a\x20project/provider\x20implementation','resource','key','join','\x20FROM\x20','SELECT\x20','dictionary'];t=function(){return D;};return t();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}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 k(T,w){T=T-0xc8;const j=t();let N=j[T];return N;}import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(T,w){return async function j({name:N,id:Y,relation:J,query:query={}}){const H=k,q=Date['now'](),O=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),X=Math['max'](query[H(0xc8)]??0x0,0x0);if(!Number[H(0xc9)](O)||!Number['isFinite'](X))throw new ValidationError(H(0xca));const b=w['get'](N),E=b['relations']?.[J];if([H(0xcb),H(0xcc)][H(0xcd)](J)&&!b['capabilities']?.['includes'](J))throw new UnsupportedError(H(0xce)+J+'\x22\x20requires\x20a\x20capabilities\x20\x22'+J+'\x22');if(J==='notes'){const P=await T['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[N,String(Y)]);return{'total':P['rows'][H(0xcf)],'time':Date[H(0xd0)]()-q,'rows':P['rows']};}if(J==='files'){const h=await T['pg'][H(0xd1)]('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[N,String(Y)]);return addFileToken(h['rows'],{'file_path':{'type':'file'}},T[H(0xd2)]),{'total':h[H(0xd3)]['length'],'time':Date['now']()-q,'rows':h['rows']};}const e=!!(E?.[H(0xd4)]&&E['junctionLocalKey']&&E[H(0xd5)]);if(!E||!e&&!E['foreignKey']||!E['resource']&&!E['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+H(0xd6));const p=E[H(0xd7)]?w['get'](E[H(0xd7)]):undefined,m=E['table']??p['table'],u=p?.[H(0xd8)]??'id',r=E['fields']?.['length']?E['fields']['map'](a=>e?'t.'+qi(a):qi(a))[H(0xd9)](',\x20'):e?'t.*':'*';E['foreignKey']&&autoIndex(m,E['foreignKey'],'btree',T['pg']);const Z=e?'SELECT\x20'+r+H(0xda)+qt(m)+'\x20t\x0a\x20\x20\x20\x20JOIN\x20'+qt(E['junctionTable'])+'\x20j\x20ON\x20j.'+qi(E['junctionForeignKey'])+'\x20=\x20t.'+qi(u)+'\x0a\x20\x20\x20\x20WHERE\x20j.'+qi(E['junctionLocalKey'])+'\x20=\x20$1\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':H(0xdb)+r+'\x20FROM\x20'+qt(m)+'\x20WHERE\x20'+qi(E['foreignKey'])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3',f=await T['pg']['query'](Z,[Y,O,X]);return p&&(await addDictionaryLookupData(f['rows'],p['fields'],T[H(0xdc)]),await addTableLookupData(f['rows'],p['fields'],T['pg']),addFileToken(f['rows'],p['fields'],T['file'])),{'limit':O,'offset':X,'total':f['rows']['length'],'time':Date['now']()-q,'rows':f['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAgDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';function k(T,w){T=T-0x1c3;const j=t();let N=j[T];return N;}function t(){const P=['get','read','max','isFinite','keys','fields','filter','searchable','search','length','values','sql','join','\x20OR\x20','item','map','SELECT\x20','all','FROM\x20','query','now'];t=function(){return P;};return t();}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';import{autoIndex}from'../utils/auto-index.js';export function createFind(T,w){return async function j({name:N,query:query={},user:Y}){const f=k,J=Date['now'](),q=w[f(0x1c3)](N);assertOperation(q,f(0x1c4),Y);const O=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),X=Math[f(0x1c5)](query['offset']??0x0,0x0),b=buildFilters(q,query['filter'],0x1,T['pg']),E=buildSort(q,query['sort']);if(!Number[f(0x1c6)](O)||!Number[f(0x1c6)](X))throw new ValidationError('Invalid\x20pagination');const e=q['searchable']||Object[f(0x1c7)](q[f(0x1c8)])[f(0x1c9)](Z=>q['fields'][Z]?.[f(0x1ca)]);query[f(0x1cb)]&&e[f(0x1cc)]&&(e['map'](Z=>autoIndex(q['table'],Z,'text',T['pg'])),b[f(0x1cd)]['push'](query['search']['toLowerCase']()+'%'),b[f(0x1ce)]+=(b['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+e?.['map'](Z=>'lower('+qt(Z)+')\x20LIKE\x20$'+b['values']['length'])[f(0x1cf)](f(0x1d0))+')'));const p=q['joins']?.['filter'](Z=>Z['scope']!==f(0x1d1))[f(0x1d2)](Z=>Z['sql']+'\x20')['join']('\x20')||'',m=f(0x1d3)+readableFields(q,f(0x1d4))['join'](',\x20')+'\x20'+(f(0x1d5)+qt(q['table'])+'\x20t\x20')+(p+'\x20'+b[f(0x1ce)]+'\x20'+E+'\x20')+('LIMIT\x20$'+(b['values'][f(0x1cc)]+0x1)+'\x20')+('OFFSET\x20$'+(b['values']['length']+0x2)),u=await T['pg'][f(0x1d6)](m,[...b['values'],O,X]),r=u['rows'];return await addDictionaryLookupData(r,q[f(0x1c8)],T['dictionary']),await addTableLookupData(r,q['fields'],T['pg']),addFileToken(r,q['fields'],T['file']),{'limit':O,'offset':X,'total':u['rowCount'],'time':Date[f(0x1d7)]()-J,'rows':r};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function t(){const u=['get','foreignKey'];t=function(){return u;};return t();}function k(T,w){T=T-0x1f3;const j=t();let N=j[T];return N;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(T,w){const j=createUpdate(T,w);return async function N({name:Y,id:J,relation:q,relationId:O,data:X,user:b},E){const m=k,e=w[m(0x1f3)](Y),p=e['relations']?.[q];if(!p?.['resource']||!p[m(0x1f4)])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+q);if(Object['hasOwn'](X,p['foreignKey'])&&X[p['foreignKey']]!==J)throw new ValidationError('Cannot\x20change\x20relation:\x20'+p[m(0x1f4)]);return j({'name':p['resource'],'id':O,'data':X,'user':b,'where':{'column':p['foreignKey'],'value':J}},E);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';function k(T,w){T=T-0x17f;const j=t();let N=j[T];return N;}import{assertOperation}from'../utils/permissions.js';function t(){const a=['update','No\x20writable\x20fields','fields','map','WHERE\x20','RETURNING\x20','keys','rows','audit','write','module'];t=function(){return a;};return t();}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(T,w){return async function j({name:N,id:Y,data:J,user:q,where:O},X){const h=k,b=w['get'](N);assertOperation(b,h(0x17f),q);const E=writableData(b,J);if(!E['length'])throw new ValidationError(h(0x180));const e=X?.['pg']??T['pg'];validateInputData({'resource':b,'data':J,'update':!![]});b[h(0x181)]['updated_at']&&E['push'](['updated_at',new Date()]);b['fields']['updated_by']&&E['push'](['updated_by',q?.['id']]);delete J['user_type'];const p=E['map'](([f],P)=>qi(f)+'\x20=\x20$'+(P+0x1)),m=[...E[h(0x182)](([,f])=>f),Y];let u=h(0x183)+qi(b['key'])+'\x20=\x20$'+m['length'];O&&(m['push'](O['value']),u+='\x20AND\x20'+qi(O['column'])+'\x20=\x20$'+m['length']);const r=await e['query']('UPDATE\x20'+qt(b['table'])+'\x20'+('SET\x20'+p['join'](',\x20')+'\x20')+(u+'\x20')+(h(0x184)+Object[h(0x185)](J)['map'](qi)['join'](',\x20')),m),Z=r[h(0x186)][0x0];if(!Z)throw new NotFoundError(N+':'+Y);return clearTableLookupCache(b['table'],e),await(X?.[h(0x187)]??T['audit'])?.[h(0x188)]({'userId':q?.['id'],'module':b[h(0x189)],'resource':b['name'],'resourceId':Y,'action':'update','fields':Object[h(0x185)](J)}),Z;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(T,w){T=T-0x145;const j=t();let N=j[T];return N;}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();function t(){const E=['get','split','public','replace','text','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','query','\x20ON\x20','\x20USING\x20gin\x20(lower(',')\x20gin_trgm_ops)'];t=function(){return E;};return t();}export function autoIndex(T,w,j='btree',N){const X=k,Y=requestedIndexes[X(0x145)](N)??new Set();requestedIndexes['set'](N,Y);const J=T+':'+w+':'+j;if(Y['has'](J))return;Y['add'](J),void ensureIndex(T,w,j,N)['catch'](()=>{Y['delete'](J);});}async function ensureIndex(T,w,j,N){const b=k,Y=T[b(0x146)]('.'),J=Y['length']===0x2?Y[0x0]:b(0x147),q=(T+'_'+w+'_'+j+'_idx')[b(0x148)](/[^A-Za-z0-9_]/g,'_'),O=await N['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[J,q]);if(O['rowCount'])return;if(j===b(0x149)){await N['query'](b(0x14a)),await N['query'](b(0x14b)+qi(q+'_l')+'\x20ON\x20'+qt(T)+'\x20USING\x20btree\x20(lower('+qi(w)+')\x20text_pattern_ops)'),await N[b(0x14c)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(q)+b(0x14d)+qt(T)+b(0x14e)+qi(w)+b(0x14f));return;}await N['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(q)+b(0x14d)+qt(T)+'\x20USING\x20'+j+'\x20('+qi(w)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function t(){const J=['writable','Required\x20field:\x20','minLength','length','maxLength','string','\x20should\x20be\x20>=\x20','\x20should\x20be\x20<=\x20','enum'];t=function(){return J;};return t();}export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:T,data:w,update:update=![]})=>{const Y=k;for(const [j,N]of Object['entries'](T['fields'])){if(N['required']&&N['writable']!==![]&&(w[j]===undefined||w[j]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+j);if(N['required']&&N[Y(0xc3)]!==![]&&Object['hasOwn'](w,j)&&(w[j]===undefined||w[j]===null)&&update)throw new ValidationError(Y(0xc4)+j);if(N[Y(0xc5)]&&typeof w[j]==='string'&&w[j][Y(0xc6)]<N[Y(0xc5)])throw new ValidationError('minLength\x20not\x20met:\x20'+j);if(N[Y(0xc7)]&&typeof w[j]===Y(0xc8)&&w[j]['length']>N['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+j);if(N['minimum']&&typeof w[j]==='number'&&w[j]<N['minimum'])throw new ValidationError(j+Y(0xc9)+N['minimum']);if(N['maximum']&&typeof w[j]==='number'&&w[j]>N['maximum'])throw new ValidationError(j+Y(0xca)+N['maximum']);if(N[Y(0xcb)]&&w[j]&&!N['enum']['includes'](w[j]))throw new ValidationError(j+'\x20should\x20be\x20one\x20of\x20('+N['enum']['join'](',\x20')+')');if(N['pattern']&&typeof w[j]==='string'&&!new RegExp(N['pattern'])['test'](w[j]))throw new ValidationError(j+'\x20should\x20match\x20regular\x20expression\x20('+N['pattern']+')');}};function k(T,w){T=T-0xc3;const j=t();let N=j[T];return N;}export{validateInputData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Z=k;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';function t(){const H=['lte','nin','like','Unsupported\x20filter\x20operator:\x20','string','split','length','filter','text','\x20requires\x20a\x20text\x20field:\x20','type','\x20IS\x20','NOT\x20','NULL','TRUE','<>\x20ALL','push','\x20WHERE\x20','object','isArray','true'];t=function(){return H;};return t();}function k(T,w){T=T-0x13b;const j=t();let N=j[T];return N;}const filterOperators=new Set(['eq','ne','gt','gte','lt',Z(0x13b),'in',Z(0x13c),Z(0x13d),'ilike','null']);export function parseFilterQuery(T){const f=Z,w={...isRecord(T['filter'])?T['filter']:{}};for(const [j,N]of Object['entries'](T)){const Y=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](j);if(!Y)continue;const [,J,q]=Y;if(!J)continue;if(!q){w[J]=N;continue;}if(!filterOperators['has'](q))throw new ValidationError(f(0x13e)+q);const O=isRecord(w[J])?w[J]:{};O[q]=(q==='in'||q==='nin')&&typeof N===f(0x13f)?N[f(0x140)](','):N,w[J]=O;}return Object['keys'](w)[f(0x141)]?w:undefined;}export function buildFilters(T,w,j=0x1,N){const P=Z,Y=[],J=[];for(const [q,O]of Object['entries'](w??{})){const X=T['fields'][q];if(!X||X[P(0x142)]!==!![]&&X['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+q);const b=qi(fieldColumn(T,q)),E=isRecord(O)?O:{'eq':O};for(const [e,p]of Object['entries'](E)){if(!filterOperators['has'](e))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+e);if((e===P(0x13d)||e==='ilike')&&X['type']!=='string'&&X['type']!==P(0x143))throw new ValidationError('Operator\x20'+e+P(0x144)+q);N&&autoIndex(T['table'],fieldColumn(T,q),indexTypeFor(X[P(0x145)],e),N);if(e==='null'){Y['push'](b+P(0x146)+(isTruthy(p)?'':P(0x147))+P(0x148));continue;}if(e==='in'||e==='nin'){const r=Array['isArray'](p)?p:[p];if(r['length']===0x0){Y['push'](e==='in'?'FALSE':P(0x149));continue;}J['push'](r),Y['push'](b+'\x20'+(e==='in'?'=\x20ANY':P(0x14a))+'($'+(j+J['length']-0x1)+')');continue;}const m={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':P(0x13d)},u='$'+(j+J['length']);if(e==='like'){J[P(0x14b)](p+'%'),Y['push']('lower('+b+')\x20like\x20lower('+u+')');continue;}J['push'](p),Y['push'](b+'\x20'+m[e]+'\x20'+u);}}return{'sql':Y[P(0x141)]?P(0x14c)+Y['join']('\x20AND\x20'):'','values':J};}function isRecord(T){const h=Z;return typeof T===h(0x14d)&&T!==null&&!Array[h(0x14e)](T);}function isTruthy(T){const a=Z;return T===!![]||T===a(0x14f)||T==='1'||T===0x1;}function indexTypeFor(T,w){if(w==='like'||w==='ilike')return'text';if(T==='geom'||T==='geometry')return'gist';return'btree';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../../errors.js';function
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';function k(T,w){T=T-0x13d;const j=t();let N=j[T];return N;}function t(){const q=['config','operations','includes','public','admin','name'];t=function(){return q;};return t();}import{getContext}from'../../../index.js';export function assertOperation(T,w,j){const J=k,N=getContext()[J(0x13d)];if(N['debug'])return;if(!T[J(0x13e)][J(0x13f)](w))throw new ForbiddenError(T['name']+'.'+w+'\x20is\x20disabled');if(T['access']!==J(0x140)&&j===undefined)throw new ForbiddenError('Authentication\x20required');if(T['access']==='admin'&&j?.['type']!==J(0x141))throw new ForbiddenError('Admin\x20access\x20required');if(j?.['type']!==J(0x141)){const Y=(T['permission']??T[J(0x142)])+':'+w;if(!j?.['permissions']?.['includes'](Y))throw new ForbiddenError('Missing\x20permission:\x20'+Y);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(T,w){T=T-0xd7;const j=t();let N=j[T];return N;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function t(){const b=['string','Field\x20is\x20not\x20sortable:\x20'];t=function(){return b;};return t();}export function buildSort(T,w){const O=k;if(!w?.['length'])return'';typeof w===O(0xd7)&&(w=[w]);const j=w['map'](N=>{const X=O,Y=N['startsWith']('-'),J=Y?N['slice'](0x1):N,q=T['fields'][J];if(!q||q['sort']!==!![]&&q['sortable']!==!![])throw new ValidationError(X(0xd8)+J);return qi(fieldColumn(T,J))+'\x20'+(Y?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+j['join'](',\x20');}
|
|
@@ -4,7 +4,7 @@ export declare const quoteIdentifier: (value: string) => string;
|
|
|
4
4
|
/** Quote a schema-qualified PostgreSQL table name. */
|
|
5
5
|
export declare const quoteTable: (value: string) => string;
|
|
6
6
|
export declare function fieldColumn(resource: ResourceContract, name: string): string;
|
|
7
|
-
export declare function readableFields(resource: ResourceContract): string[];
|
|
7
|
+
export declare function readableFields(resource: ResourceContract, scope?: string): string[];
|
|
8
8
|
export declare function writableData(resource: ResourceContract, data: Record<string, unknown>): Array<[
|
|
9
9
|
string,
|
|
10
10
|
unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3F,MAAM;IACN,OAAO;CACV,CAAC,CAmBD;AAED,eAAO,MAAM,EAAE,wBAAkB,CAAC;AAClC,eAAO,MAAM,EAAE,mBAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const q=k;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=T=>'\x22'+T[q(0xd1)](/"/g,'\x22\x22')+'\x22';export const quoteTable=T=>T[q(0xd2)]('.')['map'](quoteIdentifier)[q(0xd3)]('.');export function fieldColumn(T,w){if(w===T['key'])return T['key'];const j=T['fields'][w];if(!j)throw new ValidationError('Unknown\x20field:\x20'+w);return j['column']??w;}export function readableFields(T,w){const O=q,j=Object['entries'](T['fields'])['filter'](([,N])=>N[O(0xd4)]!==![]&&N['readable']!==![]&&(w?(N['scope']??O(0xd5))===w:!![]))[O(0xd6)](([N,Y])=>quoteIdentifier(Y['column']??N)+'\x20AS\x20'+quoteIdentifier(N));return!T['fields'][T['key']]&&j['unshift'](quoteIdentifier(T['key'])),j;}export function writableData(T,w){const X=q,j=[];for(const [N,Y]of Object['entries'](w)){const J=T['fields'][N];if(!J||J['write']===![]||J['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+N);if((J[X(0xd7)]??J[X(0xd8)])!==!![])continue;if(J['type']===X(0xd9)&&!w[N])continue;j['push']([J['column']??N,Y]);}return j;}export const qi=quoteIdentifier;function t(){const b=['replace','split','join','read','all','map','write','writable','date'];t=function(){return b;};return t();}function k(T,w){T=T-0xd1;const j=t();let N=j[T];return N;}export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const getIP=T=>(T['headers']?.['x-real-ip']||T['headers']?.['x-forwarded-for']||T['ip']||T['connection']?.['remoteAddress']||'')['split'](':')['pop']();export default getIP;
|