@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
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function Q(){const m=['now','get','key','isInteger','Invalid\x20id:\x20','where','\x20AND\x20(','SELECT\x20','join','\x20t\x20','\x20LIMIT\x201','fields','isArray','include','rows','relations','one'];Q=function(){return m;};return Q();}import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function k(h,n){h=h-0xb8;const B=Q();let G=B[h];return G;}import{addFileToken}from'./add-file-token.js';import{createFindRelation}from'./find-relation.js';export function createFindOne(h,n){return async function B({name:G,id:f,query:query={},user:j}){const t=k,Z=Date[t(0xb8)](),e=n[t(0xb9)](G);assertOperation(e,'read',j);if(e['fields'][e[t(0xba)]]?.['type']==='integer'&&!Number[t(0xbb)](Number(f)))throw new ValidationError(t(0xbc)+f+'\x20name:'+G);const b=e['joins']?.['map'](p=>p['sql']+'\x20')['join']('\x20')||'',P=e[t(0xbd)]?t(0xbe)+e[t(0xbd)]+')':'',u=await h['pg']['query'](t(0xbf)+readableFields(e)[t(0xc0)](',\x20')+'\x20FROM\x20'+qt(e['table'])+t(0xc1)+b+'\x20WHERE\x20'+qi(e[t(0xba)])+'=$1'+P+t(0xc2),[f]),X=u['rows'][0x0];if(!X)return null;await addDictionaryLookupData([X],e[t(0xc3)],h['dictionary']),await addTableLookupData([X],e['fields'],h['pg']),addFileToken([X],e['fields'],h['file']);const H=(query['include']==='all'?Object['keys'](e['relations']||{}):null)||(Array[t(0xc4)](query['include'])?query['include']:query[t(0xc5)]?.['split'](',')??[]),i=createFindRelation(h,n);for(const p of H){X[p]=await i({'name':G,'id':f,'relation':p,'query':query,'user':j})['then'](z=>z[t(0xc6)]??[])['then'](z=>e[t(0xc7)]?.[p]?.['type']===t(0xc8)?z[0x0]??null:z);}return X['time']=Date['now']()-Z,X;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
function k(h,n){h=h-0x16a;const B=Q();let G=B[h];return G;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function Q(){const V=['min','limit','relations','Generic\x20Resource\x20relation\x20\x22','query','length','files','rows','file','scope','join','\x20=\x20$1\x20','localKey','key','\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x20','where','joins','\x20LIMIT\x20$2\x20OFFSET\x20$3','fields'];Q=function(){return V;};return Q();}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 createFindRelation(h,n){return async function B({name:G,id:f,relation:j,query:query={}}){const W=k,Z=Date['now'](),e=Math[W(0x16a)](Math['max'](query[W(0x16b)]??0x14,0x1),0xc8),b=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](e)||!Number['isFinite'](b))throw new ValidationError('Invalid\x20pagination');const P=n['get'](G),u=P[W(0x16c)]?.[j];if(['notes','files']['includes'](j)&&!P['capabilities']?.['includes'](j))throw new UnsupportedError(W(0x16d)+j+'\x22\x20requires\x20a\x20capabilities\x20\x22'+j+'\x22');if(j==='notes'){const O=await h['pg'][W(0x16e)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[G,String(f)]);return{'total':O['rows'][W(0x16f)],'time':Date['now']()-Z,'rows':O['rows']};}if(j===W(0x170)){const T=await h['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[G,String(f)]);return addFileToken(T[W(0x171)],{'file_path':{'type':W(0x172)}},h['file']),{'total':T['rows']['length'],'time':Date['now']()-Z,'rows':T['rows']};}if(!u?.['resource'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+j+'\x22\x20requires\x20a\x20project/provider\x20implementation');const X=n['get'](u['resource']),H=X?.['key']??'id',i=X?.['table'],p=Object['keys'](X?.['fields']??{})['filter'](d=>X?.['fields'][d]?.['read']&&X?.['fields'][d]?.[W(0x173)]!=='item')['map'](qi)[W(0x174)](',\x20'),z=u['fields']?.[W(0x174)](',\x20')||p||'*';u['foreignKey']&&autoIndex(i,u['foreignKey'],'btree',h['pg']);const t=u['junctionTable']?'JOIN\x20'+qt(u['junctionTable'])+'\x20j\x20ON\x20j.'+qi(u['junctionForeignKey'])+'\x20=\x20t.'+(u['junctionTargetKey']||qi(H))+'\x20WHERE\x20'+qi(u['junctionLocalKey'])+W(0x175):'where\x20'+(u['foreignKey']||qi(H))+'\x20=\x20(SELECT\x20'+qi(u[W(0x176)]||P['key'])+'\x20FROM\x20'+qt(P['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(P[W(0x177)])+W(0x178)+(u[W(0x179)]?'AND\x20('+u['where']+')':''),m=X[W(0x17a)]?.['map'](d=>d['sql']+'\x20')['join']('\x20')||'',A='SELECT\x20'+z+'\x20FROM\x20'+qt(i)+'\x20t\x20'+m+'\x20'+t+W(0x17b),U=await h['pg']['query'](A,[f,e,b]);return X&&(await addDictionaryLookupData(U[W(0x171)],X['fields'],h['dictionary']),await addTableLookupData(U['rows'],X[W(0x17c)],h['pg']),addFileToken(U['rows'],X[W(0x17c)],h['file'])),{'limit':e,'offset':b,'total':U['rows']['length'],'time':Date['now']()-Z,'rows':U[W(0x171)]??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;
|
|
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;AAQhE,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,CAwFhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';function k(h,n){h=h-0x1af;const B=Q();let G=B[h];return G;}import{addTableLookupData}from'./add-table-lookup-data.js';function Q(){const d=['now','offset','filter','sql','search','table','values','map','scopes','scope','Unknown\x20scope:\x20','default','length','push','joins','join','all','FROM\x20','replace','query','rows','fields'];Q=function(){return d;};return Q();}import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(h,n){return async function B({name:G,query:query={},user:f}){const T=k,j=Date[T(0x1af)](),Z=n['get'](G);assertOperation(Z,'read',f);const e=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),b=Math['max'](query[T(0x1b0)]??0x0,0x0);buildIndex(Z,query[T(0x1b1)],h['pg']);const P=buildFilters(Z,query['filter']);Z['where']&&(P['sql']+=(P[T(0x1b2)]?'\x20AND\x20':'\x20WHERE\x20')+('('+Z['where']+')'));const u=buildSort(Z,query['sort']);if(!Number['isFinite'](e)||!Number['isFinite'](b))throw new ValidationError('Invalid\x20pagination');const X=Z['searchable']||Object['keys'](Z['fields'])[T(0x1b1)](O=>Z['fields'][O]?.['searchable']);query[T(0x1b3)]&&X['length']&&(X['map'](O=>autoIndex(Z[T(0x1b4)],O,'text',h['pg'])),P[T(0x1b5)]['push'](query[T(0x1b3)]['toLowerCase']()+'%'),P['sql']+=(P['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+X?.[T(0x1b6)](O=>'lower('+qt(O)+')\x20LIKE\x20$'+P['values']['length'])['join']('\x20OR\x20')+')'));if(query['scope']&&Z[T(0x1b7)]?.[query[T(0x1b8)]]===undefined)throw new ValidationError(T(0x1b9)+query[T(0x1b8)]);const H=query['scope']||(Z['scopes']?.[T(0x1ba)]?'default':undefined);H&&(P[T(0x1b2)]+=(P['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+(Z['scopes']?.[H]||'true')+')'));const i=await buildUserResourceScopeFilter(Z,f,h['pg'],P['values'][T(0x1bb)]+0x1);i[T(0x1b2)]&&(P['sql']+=(P['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+i['sql']+')'),P['values'][T(0x1bc)](...i['values']));const p=Z[T(0x1bd)]?.['filter'](O=>O['scope']!=='item')['map'](O=>O['sql']+'\x20')[T(0x1be)]('\x20')||'',z='SELECT\x20'+readableFields(Z,T(0x1bf))[T(0x1be)](',\x20')+'\x20'+(T(0x1c0)+qt(Z['table'])+'\x20t\x20')+(p+'\x20'+P['sql'][T(0x1c1)](/:uid/g,'\x27'+(f?.['id']??'NULL')+'\x27')+'\x20'+u+'\x20')+('LIMIT\x20$'+(P[T(0x1b5)]['length']+0x1)+'\x20')+('OFFSET\x20$'+(P['values']['length']+0x2)),t=buildSummary(Z,query,f,i),[m,A]=await Promise['all']([h['pg'][T(0x1c2)](z,[...P['values'],e,b]),h['pg']['query'](t['sql'],t['values'])['then'](O=>O[T(0x1c3)][0x0]??{})]),U=m['rows'];return await addDictionaryLookupData(U,Z[T(0x1c4)],h['dictionary']),await addTableLookupData(U,Z['fields'],h['pg']),addFileToken(U,Z['fields'],h['file']),{'time':Date['now']()-j,'limit':e,'offset':b,'count':m['rowCount'],'total':A?.['count']??0x0,'summary':A,'rows':U,...query['include']?.['includes'](T(0x1c4))?{'fields':Z['fields']}:{}};};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const j=['\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped','then'];Q=function(){return j;};return Q();}function k(h,n){h=h-0x1e1;const B=Q();let G=B[h];return G;}export async function getTableColumns(h,n){const f=k;if(!h)throw new Error('not\x20enough\x20params:\x20table');if(!n?.['pg'])return[];const B=await n['pg']['query'](f(0x1e1),[h])[f(0x1e2)](G=>G['rows']||[]);return B;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function Q(){const p=['resource','Relation\x20update\x20is\x20not\x20configured:\x20','foreignKey'];Q=function(){return p;};return Q();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function k(h,n){h=h-0xc4;const B=Q();let G=B[h];return G;}export function createUpdateRelation(h,n){const B=createUpdate(h,n);return async function G({name:f,id:j,relation:Z,relationId:e,data:b,user:P},u){const i=k,X=n['get'](f),H=X['relations']?.[Z];if(!H?.[i(0xc4)]||!H['foreignKey'])throw new UnsupportedError(i(0xc5)+Z);if(Object['hasOwn'](b,H[i(0xc6)])&&b[H['foreignKey']]!==j)throw new ValidationError('Cannot\x20change\x20relation:\x20'+H['foreignKey']);return B({'name':H[i(0xc4)],'id':e,'data':b,'user':P,'where':{'column':H['foreignKey'],'value':j}},u);};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function Q(){const O=['update','fields','updated_at','push','updated_by','user_type','map','\x20=\x20$','length','RETURNING\x20','rows','table','name'];Q=function(){return O;};return Q();}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function k(h,n){h=h-0x97;const B=Q();let G=B[h];return G;}export function createUpdate(h,n){return async function B({name:G,id:f,data:j,user:Z,where:e},b){const U=k,P=n['get'](G);assertOperation(P,U(0x97),Z);const u=writableData(P,j);if(!u['length'])throw new ValidationError('No\x20writable\x20fields');const X=b?.['pg']??h['pg'];validateInputData({'resource':P,'data':j,'update':!![]});P[U(0x98)][U(0x99)]&&u[U(0x9a)](['updated_at',new Date()]);P['fields'][U(0x9b)]&&u['push']([U(0x9b),Z?.['id']]);delete j[U(0x9c)];const H=u[U(0x9d)](([m],A)=>qi(m)+U(0x9e)+(A+0x1)),i=[...u['map'](([,m])=>m),f];let p='WHERE\x20'+qi(P['key'])+'\x20=\x20$'+i['length'];e&&(i['push'](e['value']),p+='\x20AND\x20'+qi(e['column'])+'\x20=\x20$'+i[U(0x9f)]);P['where']&&(p+='\x20AND\x20('+P['where']+')');const z=await X['query']('UPDATE\x20'+qt(P['table'])+'\x20'+('SET\x20'+H['join'](',\x20')+'\x20')+(p+'\x20')+(U(0xa0)+Object['keys'](j)['map'](qi)['join'](',\x20')),i),t=z[U(0xa1)][0x0];if(!t)throw new NotFoundError(G+':'+f);return clearTableLookupCache(P[U(0xa2)],X),await(b?.['audit']??h['audit'])?.['write']({'userId':Z?.['id'],'module':P['module'],'resource':P[U(0xa3)],'resourceId':f,'action':'update','fields':Object['keys'](j)}),t;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function Q(){const u=['has','replace','query','rowCount','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20','\x20USING\x20btree\x20(lower(',')\x20text_pattern_ops)','\x20ON\x20'];Q=function(){return u;};return Q();}function k(h,n){h=h-0x120;const B=Q();let G=B[h];return G;}import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(h,n,B='btree',G){const b=k,f=requestedIndexes['get'](G)??new Set();requestedIndexes['set'](G,f);const j=h+':'+n+':'+B;if(f[b(0x120)](j))return;f['add'](j),void ensureIndex(h,n,B,G)['catch'](()=>{f['delete'](j);});}async function ensureIndex(h,n,B,G){const P=k,f=h['split']('.'),j=f['length']===0x2?f[0x0]:'public',Z=(h+'_'+n+'_'+B+'_idx')[P(0x121)](/[^A-Za-z0-9_]/g,'_'),e=await G[P(0x122)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[j,Z]);if(e[P(0x123)])return;if(B==='text'){await G['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await G['query'](P(0x124)+qi(Z+'_l')+'\x20ON\x20'+qt(h)+P(0x125)+qi(n)+P(0x126)),await G['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Z)+'\x20ON\x20'+qt(h)+'\x20USING\x20gin\x20(lower('+qi(n)+')\x20gin_trgm_ops)');return;}await G['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Z)+P(0x127)+qt(h)+'\x20USING\x20'+B+'\x20('+qi(n)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function k(h,n){h=h-0x19b;const B=Q();let G=B[h];return G;}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:h,data:n,update:update=![]})=>{const f=k;for(const [B,G]of Object['entries'](h['fields'])){if(G[f(0x19b)]&&G[f(0x19c)]!==![]&&(n[B]===undefined||n[B]===null)&&!update)throw new ValidationError(f(0x19d)+B);if(G['required']&&G['writable']!==![]&&Object['hasOwn'](n,B)&&(n[B]===undefined||n[B]===null)&&update)throw new ValidationError('Required\x20field:\x20'+B);if(G['minLength']&&typeof n[B]==='string'&&n[B][f(0x19e)]<G['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+B);if(G[f(0x19f)]&&typeof n[B]==='string'&&n[B]['length']>G['maxLength'])throw new ValidationError(f(0x1a0)+B);if(G['minimum']&&typeof n[B]==='number'&&n[B]<G['minimum'])throw new ValidationError(B+'\x20should\x20be\x20>=\x20'+G[f(0x1a1)]);if(G['maximum']&&typeof n[B]==='number'&&n[B]>G[f(0x1a2)])throw new ValidationError(B+f(0x1a3)+G['maximum']);if(G['enum']&&n[B]&&!G['enum'][f(0x1a4)](n[B]))throw new ValidationError(B+'\x20should\x20be\x20one\x20of\x20('+G['enum'][f(0x1a5)](',\x20')+')');if(G[f(0x1a6)]&&typeof n[B]==='string'&&!new RegExp(G['pattern'])['test'](n[B]))throw new ValidationError(B+f(0x1a7)+G['pattern']+')');}};export{validateInputData};function Q(){const j=['required','writable','Required\x20field:\x20','length','maxLength','maxLength\x20exceeded:\x20','minimum','maximum','\x20should\x20be\x20<=\x20','includes','join','pattern','\x20should\x20match\x20regular\x20expression\x20('];Q=function(){return j;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const G=
|
|
1
|
+
function k(h,n){h=h-0xcb;const B=Q();let G=B[h];return G;}function Q(){const O=['gte','null','entries','split','keys','fields','Field\x20is\x20not\x20filterable:\x20','type','filter','filterable','has','\x20requires\x20a\x20text\x20field:\x20','NOT\x20','length','FALSE','like','push','geometry','gist'];Q=function(){return O;};return Q();}const z=k;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt',z(0xcb),'lt','lte','in','nin','like','ilike',z(0xcc)]);export function parseFilterQuery(h){const t=z,n={...isRecord(h['filter'])?h['filter']:{}};for(const [B,G]of Object[t(0xcd)](h)){const f=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](B);if(!f)continue;const [,j,Z]=f;if(!j)continue;if(!Z){n[j]=G;continue;}if(!filterOperators['has'](Z))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+Z);const e=isRecord(n[j])?n[j]:{};e[Z]=(Z==='in'||Z==='nin')&&typeof G==='string'?G[t(0xce)](','):G,n[j]=e;}return Object[t(0xcf)](n)['length']?n:undefined;}export function buildIndex(h,n,B){const m=z;for(const [G,f]of Object[m(0xcd)](n??{})){const j=h[m(0xd0)][G];if(!j||j['filter']!==!![]&&j['filterable']!==!![])throw new ValidationError(m(0xd1)+G);B&&autoIndex(h['table'],fieldColumn(h,G),indexTypeFor(j[m(0xd2)],'eq'),B);}}export function buildFilters(h,n,B=0x1){const A=z,G=[],f=[];for(const [j,Z]of Object[A(0xcd)](n??{})){const e=h['fields'][j];if(!e||e[A(0xd3)]!==!![]&&e[A(0xd4)]!==!![])throw new ValidationError(A(0xd1)+j);const b=qi(fieldColumn(h,j)),P=isRecord(Z)?Z:{'eq':Z};for(const [u,X]of Object['entries'](P)){if(!filterOperators[A(0xd5)](u))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+u);if((u==='like'||u==='ilike')&&e['type']!=='string'&&e[A(0xd2)]!=='text')throw new ValidationError('Operator\x20'+u+A(0xd6)+j);if(u==='null'){G['push'](b+'\x20IS\x20'+(isTruthy(X)?'':A(0xd7))+'NULL');continue;}if(u==='in'||u==='nin'){const p=Array['isArray'](X)?X:[X];if(p[A(0xd8)]===0x0){G['push'](u==='in'?A(0xd9):'TRUE');continue;}f['push'](p),G['push'](b+'\x20'+(u==='in'?'=\x20ANY':'<>\x20ALL')+'($'+(B+f[A(0xd8)]-0x1)+')');continue;}const H={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':A(0xda)},i='$'+(B+f['length']);if(u===A(0xda)){f['push'](X+'%'),G[A(0xdb)]('lower('+b+')\x20like\x20lower('+i+')');continue;}f['push'](X),G['push'](b+'\x20'+H[u]+'\x20'+i);}}return{'sql':G['length']?'\x20WHERE\x20'+G['join']('\x20AND\x20'):'','values':f};}function isRecord(h){return typeof h==='object'&&h!==null&&!Array['isArray'](h);}function isTruthy(h){return h===!![]||h==='true'||h==='1'||h===0x1;}function indexTypeFor(h,n){const U=z;if(n==='like'||n==='ilike')return'text';if(h==='geom'||h===U(0xdc))return U(0xdd);return'btree';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function k(h,n){h=h-0xc2;const B=Q();let G=B[h];return G;}function Q(){const Z=['\x20is\x20disabled','access','public','type','Missing\x20permission:\x20'];Q=function(){return Z;};return Q();}import{ForbiddenError}from'../../../errors.js';import{getContext}from'../../../index.js';export function assertOperation(h,n,B){const j=k,G=getContext()['config'];if(G['debug'])return;if(!h['operations']['includes'](n))throw new ForbiddenError(h['name']+'.'+n+j(0xc2));if(h[j(0xc3)]!==j(0xc4)&&B===undefined)throw new ForbiddenError('Authentication\x20required');if(h['access']==='admin'&&B?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(B?.[j(0xc5)]!=='admin'){const f=(h['permission']??h['name'])+':'+n;if(!B?.['permissions']?.['includes'](f))throw new ForbiddenError(j(0xc6)+f);}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../../pg.js";
|
|
2
|
+
import type { ResourceContract, ResourceUser } from "../resource.types.js";
|
|
3
|
+
export declare function clearResourceScopeCache(userId?: string, resourceName?: string): void;
|
|
4
|
+
export declare function getUserResourceScopes(userId: string, resourceName: string, pg: DatabaseAdapter): Promise<Record<string, unknown>>;
|
|
5
|
+
export interface UserResourceScopeFilter {
|
|
6
|
+
sql: string;
|
|
7
|
+
values: unknown[];
|
|
8
|
+
}
|
|
9
|
+
export declare function buildUserResourceScopeFilter(resource: ResourceContract, user: ResourceUser | undefined, pg: DatabaseAdapter, startIndex: number): Promise<UserResourceScopeFilter>;
|
|
10
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAa3E,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,QAY7E;AA+CD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,EAAE,EAAE,eAAe,GAClB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAQlC;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAsBD,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,EAAE,EAAE,eAAe,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,uBAAuB,CAAC,CA8BlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function Q(){const m=['keys','delete','now','then','isArray','push','value','scope','name','user_id','fields','column','type','length','\x20=\x20ANY($','join'];Q=function(){return m;};return Q();}import{qi}from'./sql.js';const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(h,n){const X=k;if(h&&n){scopeCache['delete'](h+':'+n);return;}if(h){for(const B of scopeCache[X(0xa7)]()){if(B['startsWith'](h+':'))scopeCache[X(0xa8)](B);}return;}scopeCache['clear']();}async function loadScopeRows(h,n,B){const H=k,G=h+':'+n,f=scopeCache['get'](G);if(f&&f['expiresAt']>Date[H(0xa9)]())return f['promise'];const j=B['query']('SELECT\x20DISTINCT\x20ras.scope,\x20ras.value\x0a\x20\x20\x20\x20\x20FROM\x20admin.role_access_scope\x20ras\x0a\x20\x20\x20\x20\x20WHERE\x20ras.resource\x20=\x20$2\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20ras.enabled\x20=\x20TRUE\x0a\x20\x20\x20\x20\x20\x20\x20AND\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20OR\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ras.user_id\x20IS\x20NULL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20ras.role_id\x20IN\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20ur.role_id\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20admin.user_roles\x20ur\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20ur.user_uid\x20=\x20$1\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20(ur.expiration\x20IS\x20NULL\x20OR\x20ur.expiration\x20>=\x20CURRENT_DATE)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x0a\x20\x20\x20\x20\x20\x20\x20)',[h,n])[H(0xaa)](({rows:Z})=>{const i=H,e=new Map();for(const b of Z){const P=e['get'](b['scope'])??[];if(Array[i(0xab)](b['value']))P[i(0xac)](...b['value']);else{if(b['value']!==null&&b['value']!==undefined)P[i(0xac)](b[i(0xad)]);}e['set'](b[i(0xae)],P);}return e;})['catch'](Z=>{const p=H;scopeCache[p(0xa8)](G);throw Z;});return scopeCache['set'](G,{'expiresAt':Date['now']()+CACHE_TTL_MS,'promise':j}),j;}export async function getUserResourceScopes(h,n,B){const G=await loadScopeRows(h,n,B);return Object['fromEntries']([...G]['map'](([f,j])=>[f,f==='me'?h:j]));}function k(h,n){h=h-0xa7;const B=Q();let G=B[h];return G;}function columnForScope(h,n){const z=k;if(n===h[z(0xaf)])return h['key'];if(n==='me'){const G=[z(0xb0),'user_uid','owner_id','created_by']['find'](f=>h[z(0xb1)][f]);if(!G)throw new ValidationError('Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20'+h[z(0xaf)]);return h['fields'][G]?.[z(0xb2)]??G;}const B=h['fields'][n];if(!B)return'';return B['column']??n;}export async function buildUserResourceScopeFilter(h,n,B,G){const t=k;if(!n||n[t(0xb3)]==='admin')return{'sql':'','values':[]};const f=await loadScopeRows(n['id'],h['name'],B),j=[],Z=[];for(const [e,b]of f){const P=columnForScope(h,e);if(!P){j['push']('(FALSE)');continue;}const u='t.'+qi(P);if(e==='me'){Z['push'](n['id']),j['push']('('+u+'\x20=\x20$'+(G+Z[t(0xb4)]-0x1)+')');continue;}if(b[t(0xb4)]===0x0){j['push']('(FALSE)');continue;}Z['push'](b),j['push']('('+u+t(0xb5)+(G+Z[t(0xb4)]-0x1)+'))');}return{'sql':j[t(0xb6)]('\x20AND\x20'),'values':Z};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function k(h,n){h=h-0x8b;const B=Q();let G=B[h];return G;}import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';export function buildSort(h,n){if(!n?.['length'])return'';typeof n==='string'&&(n=[n]);const B=n['map'](G=>{const e=k,f=G[e(0x8b)]('-'),j=f?G['slice'](0x1):G,Z=h[e(0x8c)][j];if(!Z||Z[e(0x8d)]!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+j);return qi(fieldColumn(h,j))+'\x20'+(f?'DESC':'ASC');});return'\x20ORDER\x20BY\x20'+B['join'](',\x20');}function Q(){const b=['startsWith','fields','sortable'];Q=function(){return b;};return Q();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Z=k;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=h=>'\x22'+h['replace'](/"/g,'\x22\x22')+'\x22';function Q(){const u=['split','key','fields','scope','column','writable'];Q=function(){return u;};return Q();}export const quoteTable=h=>h[Z(0x70)]('.')['map'](quoteIdentifier)['join']('.');export function fieldColumn(h,n){const e=Z;if(n===h[e(0x71)])return h['key'];const B=h['fields'][n];if(!B)throw new ValidationError('Unknown\x20field:\x20'+n);return B['column']??n;}function k(h,n){h=h-0x70;const B=Q();let G=B[h];return G;}export function readableFields(h,n){const b=Z,B=Object['entries'](h[b(0x72)])['filter'](([,G])=>G['read']!==![]&&G['readable']!==![]&&(n?(G[b(0x73)]??'all')===n:!![]))['map'](([G,f])=>quoteIdentifier(f[b(0x74)]??G)+'\x20AS\x20'+quoteIdentifier(G));return!h['fields'][h['key']]&&B['unshift'](quoteIdentifier(h['key'])),B;}export function writableData(h,n){const P=Z,B=[];for(const [G,f]of Object['entries'](n)){const j=h['fields'][G];if(!j||j['write']===![]||j[P(0x75)]===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+G);if((j['write']??j[P(0x75)])!==!![])continue;if(j['type']==='date'&&!n[G])continue;B['push']([j['column']??G,f]);}return B;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { ResourceContract, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
2
|
-
|
|
2
|
+
import type { UserResourceScopeFilter } from "./scope.js";
|
|
3
|
+
export declare function buildSummary(resource: ResourceContract, query: ResourceQuery, user: ResourceUser | undefined, accessScope?: UserResourceScopeFilter): {
|
|
4
|
+
sql: string;
|
|
5
|
+
values: unknown[];
|
|
6
|
+
};
|
|
3
7
|
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAuB,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAuB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE/G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAO1D,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,YAAY,GAAG,SAAS,EAC9B,WAAW,CAAC,EAAE,uBAAuB;;;EA2DxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildFilters}from'./filters.js';import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(
|
|
1
|
+
function k(h,n){h=h-0x14f;const B=Q();let G=B[h];return G;}import{buildFilters}from'./filters.js';function Q(){const z=['sql','aggregate','where',')\x20FILTER\x20(where\x20','true','SUM(','avg','MAX(','field','filter','\x20AND\x20','\x20WHERE\x20','scopes','fields','searchable','values',')\x20LIKE\x20$','push','map','join'];Q=function(){return z;};return Q();}import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(h,n,B,G){const p=k,f={...defaultSummary,...h['summary']??{}},j=Object['entries'](f)['map'](([X,H])=>{const i=k;if(i(0x14f)in H)return'('+H['sql']+')\x20AS\x20\x22'+X+'\x22';switch(H[i(0x150)]){case'count':return'(COUNT(*)\x20FILTER\x20(where\x20'+(H[i(0x151)]??'true')+'))::int\x20AS\x20\x22'+X+'\x22';case'countDistinct':return'(COUNT(DISTINCT\x20t.'+qt(H['field'])+i(0x152)+(H['where']??i(0x153))+'))::int\x20AS\x20\x22'+X+'\x22';case'sum':return i(0x154)+H['field']+i(0x152)+(H['where']??i(0x153))+')\x20AS\x20\x22'+X+'\x22';case i(0x155):return'AVG('+H['field']+')\x20FILTER\x20(where\x20'+(H[i(0x151)]??i(0x153))+')\x20AS\x20\x22'+X+'\x22';case'min':return'MIN('+H['field']+')\x20FILTER\x20(where\x20'+(H['where']??i(0x153))+')\x20AS\x20\x22'+X+'\x22';case'max':return i(0x156)+H[i(0x157)]+i(0x152)+(H[i(0x151)]??'true')+')\x20AS\x20\x22'+X+'\x22';}}),Z=buildFilters(h,n[p(0x158)]);h['where']&&(Z['sql']+=(Z['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+h['where']+')'));const e=n['scope']||(h['scopes']?.['default']?'default':undefined);e&&(Z['sql']+=(Z['sql']?p(0x159):p(0x15a))+('('+(h[p(0x15b)]?.[e]||'true')+')'));const b=h['searchable']||Object['keys'](h[p(0x15c)])[p(0x158)](X=>h['fields'][X]?.[p(0x15d)]);n['search']&&b['length']&&(Z[p(0x15e)]['push'](n['search']['toLowerCase']()+'%'),Z['sql']+=(Z[p(0x14f)]?'\x20AND\x20':p(0x15a))+('\x20('+b['map'](X=>'lower('+qt(X)+p(0x15f)+Z['values']['length'])['join']('\x20OR\x20')+')'));G?.['sql']&&(Z['sql']+=(Z[p(0x14f)]?'\x20AND\x20':'\x20WHERE\x20')+('('+G[p(0x14f)]+')'),Z[p(0x15e)][p(0x160)](...G['values']));const P=h['joins']?.['filter'](X=>X['scope']!=='item')[p(0x161)](X=>X['sql']+'\x20')['join']('\x20')||'',u='SELECT\x20'+j[p(0x162)](',\x20')+'\x20'+('FROM\x20'+qt(h['table'])+'\x20t\x20')+(P+'\x20'+Z['sql']['replace'](/:uid/g,'\x27'+(B?.['id']??'NULL')+'\x27'));return{'sql':u,'values':Z[p(0x15e)]};}
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const n=k,getIP=h=>(h['headers']?.['x-real-ip']||h[n(0x1a5)]?.['x-forwarded-for']||h['ip']||h['connection']?.['remoteAddress']||'')[n(0x1a6)](':')[n(0x1a7)]();export default getIP;function k(h,n){h=h-0x1a5;const B=Q();let G=B[h];return G;}function Q(){const B=['headers','split','pop'];Q=function(){return B;};return Q();}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS admin.role_access_scope (
|
|
2
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
3
|
+
|
|
4
|
+
role_id text ,
|
|
5
|
+
|
|
6
|
+
user_id text,
|
|
7
|
+
|
|
8
|
+
resource text,
|
|
9
|
+
|
|
10
|
+
scope text NOT NULL,
|
|
11
|
+
|
|
12
|
+
value jsonb,
|
|
13
|
+
|
|
14
|
+
enabled boolean NOT NULL DEFAULT true,
|
|
15
|
+
|
|
16
|
+
created_by text,
|
|
17
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
18
|
+
updated_by text,
|
|
19
|
+
updated_at timestamptz NOT NULL DEFAULT now()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX IF NOT EXISTS role_access_scope_role_idx
|
|
23
|
+
ON admin.role_access_scope(role_id);
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS role_access_scope_user_idx
|
|
26
|
+
ON admin.role_access_scope(user_id);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX IF NOT EXISTS role_access_scope_scope_idx
|
|
29
|
+
ON admin.role_access_scope(scope);
|
|
30
|
+
|
|
31
|
+
CREATE INDEX IF NOT EXISTS role_access_scope_resource_idx
|
|
32
|
+
ON admin.role_access_scope(resource);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fcore",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.27",
|
|
4
4
|
"description": "Reusable backend foundation for OpenGIS Node.js applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -90,4 +90,4 @@
|
|
|
90
90
|
"vitest": "4.1.11"
|
|
91
91
|
},
|
|
92
92
|
"license": "UNLICENSED"
|
|
93
|
-
}
|
|
93
|
+
}
|