@opengis/fcore 0.0.1-beta.15 → 0.0.1-beta.17
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/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.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
|
-
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,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,
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,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,CAsGjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function u(i,n){i=i-0xa2;const U=D();let O=U[i];return O;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function D(){const V=['offset','notes','capabilities','includes','Generic\x20Resource\x20relation\x20\x22','files','rows','length','junctionForeignKey','table','resource','filter','fields','read','join','item','sql','SELECT\x20','\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','\x20FROM\x20','\x20where\x20','key','file'];D=function(){return V;};return D();}import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(i,n){return async function U({name:O,id:o,relation:I,query:query={}}){const x=u,X=Date['now'](),T=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),R=Math['max'](query[x(0xa2)]??0x0,0x0);if(!Number['isFinite'](T)||!Number['isFinite'](R))throw new ValidationError('Invalid\x20pagination');const g=n['get'](O),k=g['relations']?.[I];if([x(0xa3),'files']['includes'](I)&&!g[x(0xa4)]?.[x(0xa5)](I))throw new UnsupportedError(x(0xa6)+I+'\x22\x20requires\x20a\x20capabilities\x20\x22'+I+'\x22');if(I==='notes'){const A=await i['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[O,String(o)]);return{'total':A['rows']['length'],'time':Date['now']()-X,'rows':A['rows']};}if(I===x(0xa7)){const K=await i['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[O,String(o)]);return addFileToken(K[x(0xa8)],{'file_path':{'type':'file'}},i['file']),{'total':K['rows'][x(0xa9)],'time':Date['now']()-X,'rows':K['rows']};}const d=!!(k?.['junctionTable']&&k['junctionLocalKey']&&k[x(0xaa)]);if(!k||!d&&!k['foreignKey']&&!k['localKey']||!k['resource']&&!k[x(0xab)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+I+'\x22\x20requires\x20a\x20project/provider\x20implementation');const L=k['resource']?n['get'](k[x(0xac)]):undefined,h=k[x(0xab)]??L['table'],q=L?.['key']??'id',M=!d&&Object['keys'](L?.['fields']??{})[x(0xad)](l=>L?.[x(0xae)][l]?.[x(0xaf)])['map'](qi)[x(0xb0)](',\x20'),y=k[x(0xae)]?.[x(0xb0)](',\x20')||M||'*';k['foreignKey']&&autoIndex(h,k['foreignKey'],'btree',i['pg']);const Z=L?.['joins']?.['filter'](l=>l['scope']!==x(0xb1))['map'](l=>l[x(0xb2)]+'\x20')[x(0xb0)]('\x20')||'',b=(d?x(0xb3)+y+'\x20FROM\x20'+qt(h)+'\x20t\x20'+Z+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20'+qt(k['junctionTable'])+'\x20j\x20ON\x20j.'+qi(k['junctionForeignKey'])+'\x20=\x20t.'+qi(q)+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(k['junctionLocalKey'])+x(0xb4):'')||(k['foreignKey']?'SELECT\x20'+y+'\x20FROM\x20'+qt(h)+'\x20t\x20'+Z+'\x20WHERE\x20t.'+qi(k['foreignKey'])+'\x20=\x20$1\x20LIMIT\x20$2\x20OFFSET\x20$3':'SELECT\x20'+y+x(0xb5)+qt(h)+'\x20t\x20'+Z+'\x20WHERE\x20t.'+qi(k['foreignKey']||q)+'\x20=\x20(select\x20'+qi(k['localKey'])+'\x20FROM\x20'+qt(g[x(0xab)])+x(0xb6)+qi(g[x(0xb7)])+'\x20=\x20$1\x20limit\x201)\x20LIMIT\x20$2\x20OFFSET\x20$3'),c=await i['pg']['query'](b,[o,T,R]);return L&&(await addDictionaryLookupData(c['rows'],L['fields'],i['dictionary']),await addTableLookupData(c['rows'],L[x(0xae)],i['pg']),addFileToken(c['rows'],L['fields'],i[x(0xb8)])),{'limit':T,'offset':R,'total':c[x(0xa8)]['length'],'time':Date['now']()-X,'rows':c['rows']??null};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';function u(i,n){i=i-0x103;const U=D();let O=U[i];return O;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function D(){const b=['now','min','offset','isFinite','Invalid\x20pagination','fields','searchable','map','text','push','toLowerCase','sql',')\x20LIKE\x20$','joins','join','FROM\x20','\x20t\x20','LIMIT\x20$','values','length','rows'];D=function(){return b;};return D();}import{autoIndex}from'../utils/auto-index.js';export function createFind(i,n){return async function U({name:O,query:query={},user:o}){const Z=u,I=Date[Z(0x103)](),X=n['get'](O);assertOperation(X,'read',o);const T=Math[Z(0x104)](Math['max'](query['limit']??0x14,0x1),0xc8),R=Math['max'](query[Z(0x105)]??0x0,0x0),g=buildFilters(X,query['filter'],0x1,i['pg']),k=buildSort(X,query['sort']);if(!Number['isFinite'](T)||!Number[Z(0x106)](R))throw new ValidationError(Z(0x107));const d=X['searchable']||Object['keys'](X[Z(0x108)])['filter'](y=>X['fields'][y]?.[Z(0x109)]);query['search']&&d['length']&&(d[Z(0x10a)](y=>autoIndex(X['table'],y,Z(0x10b),i['pg'])),g['values'][Z(0x10c)](query['search'][Z(0x10d)]()+'%'),g[Z(0x10e)]+=(g[Z(0x10e)]?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+d?.['map'](y=>'lower('+qt(y)+Z(0x10f)+g['values']['length'])['join']('\x20OR\x20')+')'));const L=X[Z(0x110)]?.['filter'](y=>y['scope']!=='item')['map'](y=>y[Z(0x10e)]+'\x20')[Z(0x111)]('\x20')||'',h='SELECT\x20'+readableFields(X,'all')['join'](',\x20')+'\x20'+(Z(0x112)+qt(X['table'])+Z(0x113))+(L+'\x20'+g['sql']+'\x20'+k+'\x20')+(Z(0x114)+(g[Z(0x115)][Z(0x116)]+0x1)+'\x20')+('OFFSET\x20$'+(g[Z(0x115)]['length']+0x2)),q=await i['pg']['query'](h,[...g['values'],T,R]),M=q[Z(0x117)];return await addDictionaryLookupData(M,X['fields'],i['dictionary']),await addTableLookupData(M,X[Z(0x108)],i['pg']),addFileToken(M,X['fields'],i['file']),{'limit':T,'offset':R,'total':q['rowCount'],'time':Date['now']()-I,'rows':M};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function u(i,n){i=i-0x196;const U=D();let O=U[i];return O;}function D(){const q=['relations','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn','foreignKey','resource'];D=function(){return q;};return D();}export function createUpdateRelation(i,n){const U=createUpdate(i,n);return async function O({name:o,id:I,relation:X,relationId:T,data:R,user:g},k){const h=u,d=n['get'](o),L=d[h(0x196)]?.[X];if(!L?.['resource']||!L['foreignKey'])throw new UnsupportedError(h(0x197)+X);if(Object[h(0x198)](R,L['foreignKey'])&&R[L['foreignKey']]!==I)throw new ValidationError('Cannot\x20change\x20relation:\x20'+L[h(0x199)]);return U({'name':L[h(0x19a)],'id':T,'data':R,'user':g,'where':{'column':L['foreignKey'],'value':I}},k);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function D(){const A=['fields','updated_at','updated_by','RETURNING\x20','module','update'];D=function(){return A;};return D();}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function u(i,n){i=i-0x137;const U=D();let O=U[i];return O;}export function createUpdate(i,n){return async function U({name:O,id:o,data:I,user:X,where:T},R){const c=u,g=n['get'](O);assertOperation(g,'update',X);const k=writableData(g,I);if(!k['length'])throw new ValidationError('No\x20writable\x20fields');const d=R?.['pg']??i['pg'];validateInputData({'resource':g,'data':I,'update':!![]});g[c(0x137)][c(0x138)]&&k['push'](['updated_at',new Date()]);g[c(0x137)][c(0x139)]&&k['push']([c(0x139),X?.['id']]);delete I['user_type'];const L=k['map'](([Z],b)=>qi(Z)+'\x20=\x20$'+(b+0x1)),h=[...k['map'](([,Z])=>Z),o];let q='WHERE\x20'+qi(g['key'])+'\x20=\x20$'+h['length'];T&&(h['push'](T['value']),q+='\x20AND\x20'+qi(T['column'])+'\x20=\x20$'+h['length']);const M=await d['query']('UPDATE\x20'+qt(g['table'])+'\x20'+('SET\x20'+L['join'](',\x20')+'\x20')+(q+'\x20')+(c(0x13a)+Object['keys'](I)['map'](qi)['join'](',\x20')),h),y=M['rows'][0x0];if(!y)throw new NotFoundError(O+':'+o);return clearTableLookupCache(g['table'],d),await(R?.['audit']??i['audit'])?.['write']({'userId':X?.['id'],'module':g[c(0x13b)],'resource':g['name'],'resourceId':o,'action':c(0x13c),'fields':Object['keys'](I)}),y;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const R=u;function u(i,n){i=i-0x18f;const U=D();let O=U[i];return O;}function D(){const d=['btree','has','add','split','rowCount','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm','\x20ON\x20','query',')\x20gin_trgm_ops)'];D=function(){return d;};return D();}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(i,n,U=R(0x18f),O){const g=R,o=requestedIndexes['get'](O)??new Set();requestedIndexes['set'](O,o);const I=i+':'+n+':'+U;if(o[g(0x190)](I))return;o[g(0x191)](I),void ensureIndex(i,n,U,O)['catch'](()=>{o['delete'](I);});}async function ensureIndex(i,n,U,O){const k=R,o=i[k(0x192)]('.'),I=o['length']===0x2?o[0x0]:'public',X=(i+'_'+n+'_'+U+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),T=await O['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[I,X]);if(T[k(0x193)])return;if(U==='text'){await O['query'](k(0x194)),await O['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(X+'_l')+k(0x195)+qt(i)+'\x20USING\x20btree\x20(lower('+qi(n)+')\x20text_pattern_ops)'),await O[k(0x196)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(X)+'\x20ON\x20'+qt(i)+'\x20USING\x20gin\x20(lower('+qi(n)+k(0x197));return;}await O['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(X)+'\x20ON\x20'+qt(i)+'\x20USING\x20'+U+'\x20('+qi(n)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function u(i,n){i=i-0x117;const U=D();let O=U[i];return O;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function D(){const I=['length','minimum','number','\x20should\x20be\x20>=\x20','maximum','enum','includes','string','pattern','test'];D=function(){return I;};return D();}const validateInputData=({resource:i,data:n,update:update=![]})=>{const o=u;for(const [U,O]of Object['entries'](i['fields'])){if(O['required']&&O['writable']!==![]&&(n[U]===undefined||n[U]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+U);if(O['required']&&O['writable']!==![]&&Object['hasOwn'](n,U)&&(n[U]===undefined||n[U]===null)&&update)throw new ValidationError('Required\x20field:\x20'+U);if(O['minLength']&&typeof n[U]==='string'&&n[U][o(0x117)]<O['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+U);if(O['maxLength']&&typeof n[U]==='string'&&n[U]['length']>O['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+U);if(O[o(0x118)]&&typeof n[U]===o(0x119)&&n[U]<O[o(0x118)])throw new ValidationError(U+o(0x11a)+O['minimum']);if(O['maximum']&&typeof n[U]===o(0x119)&&n[U]>O['maximum'])throw new ValidationError(U+'\x20should\x20be\x20<=\x20'+O[o(0x11b)]);if(O[o(0x11c)]&&n[U]&&!O[o(0x11c)][o(0x11d)](n[U]))throw new ValidationError(U+'\x20should\x20be\x20one\x20of\x20('+O['enum']['join'](',\x20')+')');if(O['pattern']&&typeof n[U]===o(0x11e)&&!new RegExp(O[o(0x11f)])[o(0x120)](n[U]))throw new ValidationError(U+'\x20should\x20match\x20regular\x20expression\x20('+O['pattern']+')');}};export{validateInputData};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function u(i,n){i=i-0xdf;const U=D();let O=U[i];return O;}const y=u;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt',y(0xdf),'lt','lte','in','nin','like','ilike','null']);export function parseFilterQuery(i){const Z=y,n={...isRecord(i['filter'])?i['filter']:{}};for(const [U,O]of Object['entries'](i)){const o=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](U);if(!o)continue;const [,I,X]=o;if(!I)continue;if(!X){n[I]=O;continue;}if(!filterOperators['has'](X))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+X);const T=isRecord(n[I])?n[I]:{};T[X]=(X==='in'||X==='nin')&&typeof O==='string'?O[Z(0xe0)](','):O,n[I]=T;}return Object['keys'](n)[Z(0xe1)]?n:undefined;}export function buildFilters(i,n,U=0x1,O){const b=y,o=[],I=[];for(const [X,T]of Object[b(0xe2)](n??{})){const R=i['fields'][X];if(!R||R['filter']!==!![]&&R['filterable']!==!![])throw new ValidationError(b(0xe3)+X);const g=qi(fieldColumn(i,X)),k=isRecord(T)?T:{'eq':T};for(const [d,L]of Object['entries'](k)){if(!filterOperators[b(0xe4)](d))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+d);if((d==='like'||d==='ilike')&&R['type']!=='string'&&R['type']!=='text')throw new ValidationError('Operator\x20'+d+'\x20requires\x20a\x20text\x20field:\x20'+X);O&&autoIndex(i['table'],fieldColumn(i,X),indexTypeFor(R[b(0xe5)],d),O);if(d===b(0xe6)){o['push'](g+'\x20IS\x20'+(isTruthy(L)?'':b(0xe7))+b(0xe8));continue;}if(d==='in'||d==='nin'){const M=Array['isArray'](L)?L:[L];if(M['length']===0x0){o[b(0xe9)](d==='in'?b(0xea):'TRUE');continue;}I['push'](M),o[b(0xe9)](g+'\x20'+(d==='in'?'=\x20ANY':b(0xeb))+'($'+(U+I[b(0xe1)]-0x1)+')');continue;}const h={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':b(0xec)},q='$'+(U+I['length']);if(d===b(0xec)){I['push'](L+'%'),o[b(0xe9)](b(0xed)+g+')\x20like\x20lower('+q+')');continue;}I['push'](L),o['push'](g+'\x20'+h[d]+'\x20'+q);}}return{'sql':o['length']?'\x20WHERE\x20'+o['join']('\x20AND\x20'):'','values':I};}function D(){const l=['gte','split','length','entries','Field\x20is\x20not\x20filterable:\x20','has','type','null','NOT\x20','NULL','push','FALSE','<>\x20ALL','like','lower(','isArray','true','geom'];D=function(){return l;};return D();}function isRecord(i){const c=y;return typeof i==='object'&&i!==null&&!Array[c(0xee)](i);}function isTruthy(i){const A=y;return i===!![]||i===A(0xef)||i==='1'||i===0x1;}function indexTypeFor(i,n){const K=y;if(n===K(0xec)||n==='ilike')return'text';if(i===K(0xf0)||i==='geometry')return'gist';return'btree';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ForbiddenError}from'../../../errors.js';function
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';function D(){const X=['config','operations','includes','Authentication\x20required','admin','permissions'];D=function(){return X;};return D();}import{getContext}from'../../../index.js';function u(i,n){i=i-0x1c5;const U=D();let O=U[i];return O;}export function assertOperation(i,n,U){const I=u,O=getContext()[I(0x1c5)];if(O['debug'])return;if(!i[I(0x1c6)][I(0x1c7)](n))throw new ForbiddenError(i['name']+'.'+n+'\x20is\x20disabled');if(i['access']!=='public'&&U===undefined)throw new ForbiddenError(I(0x1c8));if(i['access']===I(0x1c9)&&U?.['type']!==I(0x1c9))throw new ForbiddenError('Admin\x20access\x20required');if(U?.['type']!=='admin'){const o=(i['permission']??i['name'])+':'+n;if(!U?.[I(0x1ca)]?.[I(0x1c7)](o))throw new ForbiddenError('Missing\x20permission:\x20'+o);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function D(){const g=['length','startsWith','fields','sort'];D=function(){return g;};return D();}function u(i,n){i=i-0xc4;const U=D();let O=U[i];return O;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(i,n){const T=u;if(!n?.[T(0xc4)])return'';typeof n==='string'&&(n=[n]);const U=n['map'](O=>{const R=T,o=O[R(0xc5)]('-'),I=o?O['slice'](0x1):O,X=i[R(0xc6)][I];if(!X||X[R(0xc7)]!==!![]&&X['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+I);return qi(fieldColumn(i,I))+'\x20'+(o?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+U['join'](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function D(){const R=['fields','filter','read','all','map','\x20AS\x20'];D=function(){return R;};return D();}import{ValidationError}from'../../../errors.js';function u(i,n){i=i-0x6c;const U=D();let O=U[i];return O;}export const quoteIdentifier=i=>'\x22'+i['replace'](/"/g,'\x22\x22')+'\x22';export const quoteTable=i=>i['split']('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(i,n){const X=u;if(n===i['key'])return i['key'];const U=i[X(0x6c)][n];if(!U)throw new ValidationError('Unknown\x20field:\x20'+n);return U['column']??n;}export function readableFields(i,n){const T=u,U=Object['entries'](i['fields'])[T(0x6d)](([,O])=>O[T(0x6e)]!==![]&&O['readable']!==![]&&(n?(O['scope']??T(0x6f))===n:!![]))[T(0x70)](([O,o])=>quoteIdentifier(o['column']??O)+T(0x71)+quoteIdentifier(O));return!i['fields'][i['key']]&&U['unshift'](quoteIdentifier(i['key'])),U;}export function writableData(i,n){const U=[];for(const [O,o]of Object['entries'](n)){const I=i['fields'][O];if(!I||I['write']===![]||I['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+O);if((I['write']??I['writable'])!==!![])continue;if(I['type']==='date'&&!n[O])continue;U['push']([I['column']??O,o]);}return U;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const getIP=
|
|
1
|
+
function D(){const U=['headers','split','pop'];D=function(){return U;};return D();}const n=u,getIP=i=>(i['headers']?.['x-real-ip']||i[n(0x128)]?.['x-forwarded-for']||i['ip']||i['connection']?.['remoteAddress']||'')[n(0x129)](':')[n(0x12a)]();function u(i,n){i=i-0x128;const U=D();let O=U[i];return O;}export default getIP;
|