@opengis/fcore 0.0.1-beta.20 → 0.0.1-beta.21
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 +2 -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.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.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.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function r(n,k){n=n-0xca;const Z=g();let K=Z[n];return K;}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(n,k){const Z=createRemove(n,k);return async function K({name:d,id:J,relation:B,relationId:l,user:f},R){const I=r,Q=R?.['pg']??n['pg'],a=k[I(0xca)](d);if(['notes','files']['includes'](B)&&!a['capabilities']?.[I(0xcb)](B))throw new UnsupportedError(I(0xcc)+B+'\x22\x20requires\x20a\x20capabilities\x20\x22'+B+'\x22');if(B===I(0xcd))return await Q['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,d,String(J)]),{'success':!![]};if(B===I(0xce))return await Q['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[l,d,String(J)]),{'success':!![]};const H=a['relations']?.[B];if(!H?.['resource']||!H['foreignKey'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+B+'\x22\x20requires\x20a\x20project/provider\x20implementation');const A=await Z({'name':H['resource'],'id':l,'user':f,'where':{'column':H['foreignKey'],'value':J}},R);return{'success':A};};}function g(){const O=['get','includes','Generic\x20Resource\x20relation\x20\x22','notes','files'];g=function(){return O;};return g();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function g(){const I=['get','delete','WHERE\x20','value','column','length','module','name'];g=function(){return I;};return g();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function r(n,k){n=n-0x1d2;const Z=g();let K=Z[n];return K;}export function createRemove(n,k){return async function Z({name:K,id:d,user:J,where:B},l){const A=r,f=k[A(0x1d2)](K);assertOperation(f,A(0x1d3),J);const R=l?.['pg']??n['pg'],Q=[d];let a=A(0x1d4)+qi(f['key'])+'\x20=\x20$1';B&&(Q['push'](B[A(0x1d5)]),a+='\x20AND\x20'+qi(B[A(0x1d6)])+'\x20=\x20$'+Q[A(0x1d7)]);f['where']&&(a+='\x20AND\x20('+f['where']+')');const H=await R['query']('DELETE\x20FROM\x20'+qt(f['table'])+'\x20'+a,Q);if((H['rowCount']??0x0)>0x0)clearTableLookupCache(f['table'],R);if((H['rowCount']??0x0)>0x0)await(l?.['audit']??n['audit'])?.['write']({'module':f[A(0x1d8)],'resource':f[A(0x1d9)],'resourceId':d,'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,
|
|
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,gCAOvB;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,6CAsGF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function r(n,k){n=n-0x166;const Z=g();let K=Z[n];return K;}import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';function g(){const z=['key','integer','Invalid\x20id:\x20','where','SELECT\x20','\x20FROM\x20','\x20LIMIT\x201','fields','split','junctionTable','junctionForeignKey','foreignKey','resource','table','targetKey','\x20t\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20','\x20j\x20ON\x20j.','junctionLocalKey','query','dictionary','time','now'];g=function(){return z;};return g();}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(n,k){return async function Z({name:K,id:d,query:query={},user:J}){const q=r,B=Date['now'](),l=k['get'](K);assertOperation(l,'read',J);if(l['fields'][l[q(0x166)]]?.['type']===q(0x167)&&!Number['isInteger'](Number(d)))throw new ValidationError(q(0x168)+d+'\x20name:'+K);const f=l['joins']?.['map'](A=>A['sql']+'\x20')['join']('\x20')||'',R=l[q(0x169)]?'\x20AND\x20('+l['where']+')':'',Q=await n['pg']['query'](q(0x16a)+readableFields(l)['join'](',\x20')+q(0x16b)+qt(l['table'])+'\x20t\x20'+f+'\x20WHERE\x20'+qi(l['key'])+'=$1'+R+q(0x16c),[d]),a=Q['rows'][0x0];if(!a)return null;await addDictionaryLookupData([a],l['fields'],n['dictionary']),await addTableLookupData([a],l['fields'],n['pg']),addFileToken([a],l[q(0x16d)],n['file']);const H=Array['isArray'](query['include'])?query['include']:query['include']?.[q(0x16e)](',')??[];for(const A of H){const I=l['relations']?.[A];if(!I)throw new ValidationError('Unknown\x20relation:\x20'+A);const O=!!(I?.[q(0x16f)]&&I['junctionLocalKey']&&I[q(0x170)]);if(!I?.[q(0x171)]&&!O||!I[q(0x172)]&&!I['table'])throw new ValidationError('Invalid\x20relation:\x20'+A);const m=I['resource']?k['get'](I['resource']):undefined,p=I[q(0x173)]??m['table'],C=m?.['key']??'id',T=m?readableFields(m)['join'](',\x20'):'*',c=I[q(0x171)]?'SELECT\x20'+T+'\x20FROM\x20'+qt(p)+'\x20WHERE\x20'+(I[q(0x174)]||qi(C))+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(I['foreignKey'])+'\x20FROM\x20'+qt(l['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l[q(0x166)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)':q(0x16a)+T+q(0x16b)+qt(p)+q(0x175)+qt(I['junctionTable'])+q(0x176)+qi(I['junctionForeignKey'])+'\x20=\x20t.'+(I['junctionTargetKey']||qi(C))+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(I[q(0x177)])+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(l['key'])+q(0x16b)+qt(l['table'])+'\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(l['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',b=(await n['pg'][q(0x178)](c,[d]))['rows'];m&&(await addDictionaryLookupData(b,m['fields'],n[q(0x179)]),await addTableLookupData(b,m[q(0x16d)],n['pg']),addFileToken(b,m[q(0x16d)],n['file'])),a[A]=b;}return a[q(0x17a)]=Date[q(0x17b)]()-B,a;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CA6IjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function r(n,k){n=n-0x162;const Z=g();let K=Z[n];return K;}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';function g(){const w=['offset','isFinite','get','relations','length','now','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','rows','foreignKey','localKey','table','\x22\x20requires\x20a\x20project/provider\x20implementation','fields','filter','read','item','join','joins','scope','\x20AND\x20(','\x20t\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20','\x20j\x20ON\x20j.','junctionTargetKey','\x20=\x20$1','\x20FROM\x20','\x20LIMIT\x20$2\x20OFFSET\x20$3','\x20=\x20$1\x20limit\x201)'];g=function(){return w;};return g();}export function createFindRelation(n,k){return async function Z({name:K,id:d,relation:J,query:query={}}){const j=r,B=Date['now'](),l=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),f=Math['max'](query[j(0x162)]??0x0,0x0);if(!Number[j(0x163)](l)||!Number['isFinite'](f))throw new ValidationError('Invalid\x20pagination');const R=k[j(0x164)](K),Q=R[j(0x165)]?.[J];if(['notes','files']['includes'](J)&&!R['capabilities']?.['includes'](J))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+'\x22\x20requires\x20a\x20capabilities\x20\x22'+J+'\x22');if(J==='notes'){const b=await n['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[K,String(d)]);return{'total':b['rows'][j(0x166)],'time':Date[j(0x167)]()-B,'rows':b['rows']};}if(J==='files'){const q=await n['pg']['query'](j(0x168),[K,String(d)]);return addFileToken(q['rows'],{'file_path':{'type':'file'}},n['file']),{'total':q[j(0x169)]['length'],'time':Date['now']()-B,'rows':q['rows']};}const a=!!(Q?.['junctionTable']&&Q['junctionLocalKey']&&Q['junctionForeignKey']);if(!Q||!a&&!Q[j(0x16a)]&&!Q[j(0x16b)]||!Q['resource']&&!Q[j(0x16c)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+J+j(0x16d));const H=Q['resource']?k['get'](Q['resource']):undefined,A=Q['table']??H[j(0x16c)],I=H?.['key']??'id',O=!a&&Object['keys'](H?.[j(0x16e)]??{})[j(0x16f)](z=>H?.[j(0x16e)][z]?.[j(0x170)]&&H?.['fields'][z]?.['scope']!==j(0x171))['map'](qi)['join'](',\x20'),m=Q['fields']?.[j(0x172)](',\x20')||O||'*';Q['foreignKey']&&autoIndex(A,Q['foreignKey'],'btree',n['pg']);const p=H?.[j(0x173)]?.['filter'](z=>z[j(0x174)]!=='item')['map'](z=>z['sql']+'\x20')['join']('\x20')||'',C=Q['where']?j(0x175)+Q['where']+')':'',T=(a?'SELECT\x20'+m+'\x20FROM\x20'+qt(A)+j(0x176)+p+j(0x177)+qt(Q['junctionTable'])+j(0x178)+qi(Q['junctionForeignKey'])+'\x20=\x20t.'+(Q[j(0x179)]||qi(I))+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(Q['junctionLocalKey'])+j(0x17a)+C+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3':'')||(Q['foreignKey']?'SELECT\x20'+m+j(0x17b)+qt(A)+'\x20t\x20'+p+'\x20WHERE\x20t.'+qi(Q['foreignKey'])+'\x20=\x20$1'+C+j(0x17c):'SELECT\x20'+m+'\x20FROM\x20'+qt(A)+'\x20t\x20'+p+'\x20WHERE\x20t.'+qi(Q[j(0x16a)]||I)+'\x20=\x20(select\x20'+qi(Q[j(0x16b)])+'\x20FROM\x20'+qt(R['table'])+'\x20where\x20'+qi(R['key'])+j(0x17d)+C+j(0x17c)),c=await n['pg']['query'](T,[d,l,f]);return H&&(await addDictionaryLookupData(c['rows'],H['fields'],n['dictionary']),await addTableLookupData(c['rows'],H['fields'],n['pg']),addFileToken(c[j(0x169)],H['fields'],n['file'])),{'limit':l,'offset':f,'total':c[j(0x169)]['length'],'time':Date[j(0x167)]()-B,'rows':c[j(0x169)]??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';function r(n,k){n=n-0x9f;const Z=g();let K=Z[n];return K;}function g(){const C=['now','sql','Invalid\x20pagination','fields','search','text','values','toLowerCase','\x20AND\x20','joins','join','table','\x20t\x20','LIMIT\x20$','OFFSET\x20$','query','rows','file','rowCount'];g=function(){return C;};return g();}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';import{autoIndex}from'../utils/auto-index.js';export function createFind(n,k){return async function Z({name:K,query:query={},user:d}){const p=r,J=Date[p(0x9f)](),B=k['get'](K);assertOperation(B,'read',d);const l=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),f=Math['max'](query['offset']??0x0,0x0),R=buildFilters(B,query['filter'],0x1,n['pg']);B['where']&&(R['sql']+=(R[p(0xa0)]?'\x20AND\x20':'\x20WHERE\x20')+('('+B['where']+')'));const Q=buildSort(B,query['sort']);if(!Number['isFinite'](l)||!Number['isFinite'](f))throw new ValidationError(p(0xa1));const a=B['searchable']||Object['keys'](B['fields'])['filter'](m=>B[p(0xa2)][m]?.['searchable']);query[p(0xa3)]&&a['length']&&(a['map'](m=>autoIndex(B['table'],m,p(0xa4),n['pg'])),R[p(0xa5)]['push'](query['search'][p(0xa6)]()+'%'),R[p(0xa0)]+=(R['sql']?p(0xa7):'\x20WHERE\x20')+('\x20('+a?.['map'](m=>'lower('+qt(m)+')\x20LIKE\x20$'+R['values']['length'])['join']('\x20OR\x20')+')'));const H=B[p(0xa8)]?.['filter'](m=>m['scope']!=='item')['map'](m=>m['sql']+'\x20')[p(0xa9)]('\x20')||'',A='SELECT\x20'+readableFields(B,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(B[p(0xaa)])+p(0xab))+(H+'\x20'+R['sql']+'\x20'+Q+'\x20')+(p(0xac)+(R[p(0xa5)]['length']+0x1)+'\x20')+(p(0xad)+(R['values']['length']+0x2)),I=await n['pg'][p(0xae)](A,[...R[p(0xa5)],l,f]),O=I[p(0xaf)];return await addDictionaryLookupData(O,B['fields'],n['dictionary']),await addTableLookupData(O,B[p(0xa2)],n['pg']),addFileToken(O,B['fields'],n[p(0xb0)]),{'limit':l,'offset':f,'total':I[p(0xb1)],'time':Date['now']()-J,'rows':O};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(n,k){n=n-0x11b;const Z=g();let K=Z[n];return K;}function g(){const I=['relations'];g=function(){return I;};return g();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(n,k){const Z=createUpdate(n,k);return async function K({name:d,id:J,relation:B,relationId:l,data:f,user:R},Q){const A=r,a=k['get'](d),H=a[A(0x11b)]?.[B];if(!H?.['resource']||!H['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+B);if(Object['hasOwn'](f,H['foreignKey'])&&f[H['foreignKey']]!==J)throw new ValidationError('Cannot\x20change\x20relation:\x20'+H['foreignKey']);return Z({'name':H['resource'],'id':l,'data':f,'user':R,'where':{'column':H['foreignKey'],'value':J}},Q);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{NotFoundError,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 g(){const c=['fields','updated_by','user_type','\x20=\x20$','value','length','keys','join','audit','write'];g=function(){return c;};return g();}function r(n,k){n=n-0x1a6;const Z=g();let K=Z[n];return K;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(n,k){return async function Z({name:K,id:d,data:J,user:B,where:l},f){const T=r,R=k['get'](K);assertOperation(R,'update',B);const Q=writableData(R,J);if(!Q['length'])throw new ValidationError('No\x20writable\x20fields');const a=f?.['pg']??n['pg'];validateInputData({'resource':R,'data':J,'update':!![]});R['fields']['updated_at']&&Q['push'](['updated_at',new Date()]);R[T(0x1a6)][T(0x1a7)]&&Q['push'](['updated_by',B?.['id']]);delete J[T(0x1a8)];const H=Q['map'](([p],C)=>qi(p)+T(0x1a9)+(C+0x1)),A=[...Q['map'](([,p])=>p),d];let I='WHERE\x20'+qi(R['key'])+'\x20=\x20$'+A['length'];l&&(A['push'](l[T(0x1aa)]),I+='\x20AND\x20'+qi(l['column'])+'\x20=\x20$'+A[T(0x1ab)]);R['where']&&(I+='\x20AND\x20('+R['where']+')');const O=await a['query']('UPDATE\x20'+qt(R['table'])+'\x20'+('SET\x20'+H['join'](',\x20')+'\x20')+(I+'\x20')+('RETURNING\x20'+Object[T(0x1ac)](J)['map'](qi)[T(0x1ad)](',\x20')),A),m=O['rows'][0x0];if(!m)throw new NotFoundError(K+':'+d);return clearTableLookupCache(R['table'],a),await(f?.[T(0x1ae)]??n['audit'])?.[T(0x1af)]({'userId':B?.['id'],'module':R['module'],'resource':R['name'],'resourceId':d,'action':'update','fields':Object['keys'](J)}),m;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function r(n,k){n=n-0x102;const Z=g();let K=Z[n];return K;}const f=r;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(n,k,Z=f(0x102),K){const R=f,d=requestedIndexes['get'](K)??new Set();requestedIndexes['set'](K,d);const J=n+':'+k+':'+Z;if(d['has'](J))return;d['add'](J),void ensureIndex(n,k,Z,K)[R(0x103)](()=>{d['delete'](J);});}async function ensureIndex(n,k,Z,K){const Q=f,d=n['split']('.'),J=d['length']===0x2?d[0x0]:'public',B=(n+'_'+k+'_'+Z+'_idx')[Q(0x104)](/[^A-Za-z0-9_]/g,'_'),l=await K[Q(0x105)](Q(0x106),[J,B]);if(l[Q(0x107)])return;if(Z==='text'){await K['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await K['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B+'_l')+Q(0x108)+qt(n)+Q(0x109)+qi(k)+')\x20text_pattern_ops)'),await K[Q(0x105)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B)+'\x20ON\x20'+qt(n)+'\x20USING\x20gin\x20(lower('+qi(k)+')\x20gin_trgm_ops)');return;}await K['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(B)+Q(0x108)+qt(n)+Q(0x10a)+Z+'\x20('+qi(k)+')');}function g(){const a=['btree','catch','replace','query','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','rowCount','\x20ON\x20','\x20USING\x20btree\x20(lower(','\x20USING\x20'];g=function(){return a;};return g();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(n,k){n=n-0x18c;const Z=g();let K=Z[n];return K;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:n,data:k,update:update=![]})=>{const d=r;for(const [Z,K]of Object['entries'](n['fields'])){if(K['required']&&K['writable']!==![]&&(k[Z]===undefined||k[Z]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+Z);if(K['required']&&K[d(0x18c)]!==![]&&Object[d(0x18d)](k,Z)&&(k[Z]===undefined||k[Z]===null)&&update)throw new ValidationError('Required\x20field:\x20'+Z);if(K['minLength']&&typeof k[Z]==='string'&&k[Z]['length']<K[d(0x18e)])throw new ValidationError('minLength\x20not\x20met:\x20'+Z);if(K[d(0x18f)]&&typeof k[Z]===d(0x190)&&k[Z][d(0x191)]>K[d(0x18f)])throw new ValidationError('maxLength\x20exceeded:\x20'+Z);if(K[d(0x192)]&&typeof k[Z]==='number'&&k[Z]<K['minimum'])throw new ValidationError(Z+'\x20should\x20be\x20>=\x20'+K['minimum']);if(K['maximum']&&typeof k[Z]==='number'&&k[Z]>K['maximum'])throw new ValidationError(Z+'\x20should\x20be\x20<=\x20'+K['maximum']);if(K['enum']&&k[Z]&&!K['enum'][d(0x193)](k[Z]))throw new ValidationError(Z+'\x20should\x20be\x20one\x20of\x20('+K['enum']['join'](',\x20')+')');if(K['pattern']&&typeof k[Z]==='string'&&!new RegExp(K[d(0x194)])[d(0x195)](k[Z]))throw new ValidationError(Z+'\x20should\x20match\x20regular\x20expression\x20('+K[d(0x194)]+')');}};function g(){const J=['writable','hasOwn','minLength','maxLength','string','length','minimum','includes','pattern','test'];g=function(){return J;};return g();}export{validateInputData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function r(n,k){n=n-0x122;const Z=g();let K=Z[n];return K;}import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(n){const m=r,k={...isRecord(n['filter'])?n['filter']:{}};for(const [Z,K]of Object['entries'](n)){const d=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](Z);if(!d)continue;const [,J,B]=d;if(!J)continue;if(!B){k[J]=K;continue;}if(!filterOperators['has'](B))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+B);const l=isRecord(k[J])?k[J]:{};l[B]=(B==='in'||B==='nin')&&typeof K==='string'?K['split'](','):K,k[J]=l;}return Object[m(0x122)](k)['length']?k:undefined;}export function buildFilters(n,k,Z=0x1,K){const p=r,d=[],J=[];for(const [B,l]of Object['entries'](k??{})){const f=n['fields'][B];if(!f||f[p(0x123)]!==!![]&&f[p(0x124)]!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+B);const R=qi(fieldColumn(n,B)),Q=isRecord(l)?l:{'eq':l};for(const [a,H]of Object['entries'](Q)){if(!filterOperators['has'](a))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+a);if((a===p(0x125)||a==='ilike')&&f['type']!=='string'&&f[p(0x126)]!=='text')throw new ValidationError('Operator\x20'+a+p(0x127)+B);K&&autoIndex(n[p(0x128)],fieldColumn(n,B),indexTypeFor(f['type'],a),K);if(a==='null'){d['push'](R+'\x20IS\x20'+(isTruthy(H)?'':'NOT\x20')+p(0x129));continue;}if(a==='in'||a===p(0x12a)){const O=Array['isArray'](H)?H:[H];if(O[p(0x12b)]===0x0){d[p(0x12c)](a==='in'?'FALSE':'TRUE');continue;}J[p(0x12c)](O),d['push'](R+'\x20'+(a==='in'?p(0x12d):'<>\x20ALL')+'($'+(Z+J['length']-0x1)+')');continue;}const A={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':'like'},I='$'+(Z+J['length']);if(a==='like'){J['push'](H+'%'),d['push']('lower('+R+')\x20like\x20lower('+I+')');continue;}J['push'](H),d['push'](R+'\x20'+A[a]+'\x20'+I);}}return{'sql':d['length']?'\x20WHERE\x20'+d['join']('\x20AND\x20'):'','values':J};}function isRecord(n){const C=r;return typeof n==='object'&&n!==null&&!Array[C(0x12e)](n);}function isTruthy(n){return n===!![]||n==='true'||n==='1'||n===0x1;}function indexTypeFor(n,k){const T=r;if(k==='like'||k==='ilike')return T(0x12f);if(n==='geom'||n==='geometry')return'gist';return'btree';}function g(){const c=['keys','filter','filterable','like','type','\x20requires\x20a\x20text\x20field:\x20','table','NULL','nin','length','push','=\x20ANY','isArray','text'];g=function(){return c;};return g();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';function g(){const B=['config','debug','public','access','admin','permissions','Missing\x20permission:\x20'];g=function(){return B;};return g();}function r(n,k){n=n-0x123;const Z=g();let K=Z[n];return K;}import{getContext}from'../../../index.js';export function assertOperation(n,k,Z){const J=r,K=getContext()[J(0x123)];if(K[J(0x124)])return;if(!n['operations']['includes'](k))throw new ForbiddenError(n['name']+'.'+k+'\x20is\x20disabled');if(n['access']!==J(0x125)&&Z===undefined)throw new ForbiddenError('Authentication\x20required');if(n[J(0x126)]===J(0x127)&&Z?.['type']!==J(0x127))throw new ForbiddenError('Admin\x20access\x20required');if(Z?.['type']!=='admin'){const d=(n['permission']??n['name'])+':'+k;if(!Z?.[J(0x128)]?.['includes'](d))throw new ForbiddenError(J(0x129)+d);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function g(){const R=['map','DESC','join'];g=function(){return R;};return g();}function r(n,k){n=n-0x6b;const Z=g();let K=Z[n];return K;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(n,k){const l=r;if(!k?.['length'])return'';typeof k==='string'&&(k=[k]);const Z=k[l(0x6b)](K=>{const f=l,d=K['startsWith']('-'),J=d?K['slice'](0x1):K,B=n['fields'][J];if(!B||B['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+J);return qi(fieldColumn(n,J))+'\x20'+(d?f(0x6c):'ASC');});return'\x20ORDER\x20BY\x20'+Z[l(0x6d)](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function r(n,k){n=n-0xee;const Z=g();let K=Z[n];return K;}import{ValidationError}from'../../../errors.js';export const quoteIdentifier=n=>'\x22'+n['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=n=>n['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(n,k){const B=r;if(k===n['key'])return n[B(0xee)];const Z=n['fields'][k];if(!Z)throw new ValidationError(B(0xef)+k);return Z['column']??k;}function g(){const R=['key','Unknown\x20field:\x20','entries','read','all','map','column','\x20AS\x20','unshift','write','date','push'];g=function(){return R;};return g();}export function readableFields(n,k){const l=r,Z=Object[l(0xf0)](n['fields'])['filter'](([,K])=>K[l(0xf1)]!==![]&&K['readable']!==![]&&(k?(K['scope']??l(0xf2))===k:!![]))[l(0xf3)](([K,d])=>quoteIdentifier(d[l(0xf4)]??K)+l(0xf5)+quoteIdentifier(K));return!n['fields'][n['key']]&&Z[l(0xf6)](quoteIdentifier(n['key'])),Z;}export function writableData(n,k){const f=r,Z=[];for(const [K,d]of Object['entries'](k)){const J=n['fields'][K];if(!J||J[f(0xf7)]===![]||J['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+K);if((J['write']??J['writable'])!==!![])continue;if(J['type']===f(0xf8)&&!k[K])continue;Z[f(0xf9)]([J[f(0xf4)]??K,d]);}return Z;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function r(n,k){n=n-0x190;const Z=g();let K=Z[n];return K;}const k=r,getIP=n=>(n['headers']?.['x-real-ip']||n['headers']?.[k(0x190)]||n['ip']||n['connection']?.[k(0x191)]||'')[k(0x192)](':')['pop']();function g(){const Z=['x-forwarded-for','remoteAddress','split'];g=function(){return Z;};return g();}export default getIP;
|