@opengis/fcore 0.0.1-beta.23 → 0.0.1-beta.25
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/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.d.ts.map +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.d.ts.map +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 +6 -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/get-resource.js +1 -1
- 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.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.d.ts.map +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.d.ts +7 -3
- package/dist/plugins/file.d.ts.map +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.d.ts.map +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 +22 -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.d.ts +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts.map +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.d.ts +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts.map +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.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.d.ts +2 -1
- package/dist/plugins/resource/utils/filters.d.ts.map +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/plugins/resource/utils/summary.d.ts +3 -0
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
- package/dist/plugins/resource/utils/summary.js +1 -0
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/package.json +93 -93
|
@@ -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 f(){const A=['update','No\x20writable\x20fields','fields','updated_at','push','updated_by','user_type','\x20=\x20$','WHERE\x20','length','value','\x20AND\x20','UPDATE\x20','table','RETURNING\x20','join','audit','name'];f=function(){return A;};return f();}function Y(w,y){w=w-0xe3;const d=f();let Z=d[w];return Z;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(w,y){return async function d({name:Z,id:M,data:H,user:Q,where:s},j){const l=Y,n=y['get'](Z);assertOperation(n,l(0xe3),Q);const t=writableData(n,H);if(!t['length'])throw new ValidationError(l(0xe4));const K=j?.['pg']??w['pg'];validateInputData({'resource':n,'data':H,'update':!![]});n[l(0xe5)][l(0xe6)]&&t[l(0xe7)](['updated_at',new Date()]);n[l(0xe5)][l(0xe8)]&&t['push'](['updated_by',Q?.['id']]);delete H[l(0xe9)];const T=t['map'](([E],e)=>qi(E)+l(0xea)+(e+0x1)),h=[...t['map'](([,E])=>E),M];let i=l(0xeb)+qi(n['key'])+'\x20=\x20$'+h[l(0xec)];s&&(h['push'](s[l(0xed)]),i+=l(0xee)+qi(s['column'])+'\x20=\x20$'+h['length']);n['where']&&(i+='\x20AND\x20('+n['where']+')');const G=await K['query'](l(0xef)+qt(n[l(0xf0)])+'\x20'+('SET\x20'+T['join'](',\x20')+'\x20')+(i+'\x20')+(l(0xf1)+Object['keys'](H)['map'](qi)[l(0xf2)](',\x20')),h),U=G['rows'][0x0];if(!U)throw new NotFoundError(Z+':'+M);return clearTableLookupCache(n['table'],K),await(j?.[l(0xf3)]??w['audit'])?.['write']({'userId':Q?.['id'],'module':n['module'],'resource':n[l(0xf4)],'resourceId':M,'action':'update','fields':Object['keys'](H)}),U;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(
|
|
1
|
+
import{qi,qt}from'./sql.js';function f(){const K=['get','set','catch','delete','split','replace','SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2','rowCount','query','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm','\x20ON\x20','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];f=function(){return K;};return f();}const requestedIndexes=new WeakMap();export function autoIndex(w,y,d='btree',Z){const j=Y,M=requestedIndexes[j(0x6c)](Z)??new Set();requestedIndexes[j(0x6d)](Z,M);const H=w+':'+y+':'+d;if(M['has'](H))return;M['add'](H),void ensureIndex(w,y,d,Z)[j(0x6e)](()=>{const n=j;M[n(0x6f)](H);});}function Y(w,y){w=w-0x6c;const d=f();let Z=d[w];return Z;}async function ensureIndex(w,y,d,Z){const t=Y,M=w[t(0x70)]('.'),H=M['length']===0x2?M[0x0]:'public',Q=(w+'_'+y+'_'+d+'_idx')[t(0x71)](/[^A-Za-z0-9_]/g,'_'),s=await Z['query'](t(0x72),[H,Q]);if(s[t(0x73)])return;if(d==='text'){await Z[t(0x74)](t(0x75)),await Z['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Q+'_l')+t(0x76)+qt(w)+'\x20USING\x20btree\x20(lower('+qi(y)+')\x20text_pattern_ops)'),await Z['query'](t(0x77)+qi(Q)+'\x20ON\x20'+qt(w)+'\x20USING\x20gin\x20(lower('+qi(y)+')\x20gin_trgm_ops)');return;}await Z['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(Q)+'\x20ON\x20'+qt(w)+'\x20USING\x20'+d+'\x20('+qi(y)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function f(){const H=['required','writable','maxLength','enum','join','pattern'];f=function(){return H;};return f();}export{readableFields,writableData,fieldColumn}from'./sql.js';const validateInputData=({resource:w,data:y,update:update=![]})=>{const M=Y;for(const [d,Z]of Object['entries'](w['fields'])){if(Z[M(0xbf)]&&Z[M(0xc0)]!==![]&&(y[d]===undefined||y[d]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+d);if(Z['required']&&Z['writable']!==![]&&Object['hasOwn'](y,d)&&(y[d]===undefined||y[d]===null)&&update)throw new ValidationError('Required\x20field:\x20'+d);if(Z['minLength']&&typeof y[d]==='string'&&y[d]['length']<Z['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+d);if(Z[M(0xc1)]&&typeof y[d]==='string'&&y[d]['length']>Z[M(0xc1)])throw new ValidationError('maxLength\x20exceeded:\x20'+d);if(Z['minimum']&&typeof y[d]==='number'&&y[d]<Z['minimum'])throw new ValidationError(d+'\x20should\x20be\x20>=\x20'+Z['minimum']);if(Z['maximum']&&typeof y[d]==='number'&&y[d]>Z['maximum'])throw new ValidationError(d+'\x20should\x20be\x20<=\x20'+Z['maximum']);if(Z[M(0xc2)]&&y[d]&&!Z['enum']['includes'](y[d]))throw new ValidationError(d+'\x20should\x20be\x20one\x20of\x20('+Z[M(0xc2)][M(0xc3)](',\x20')+')');if(Z[M(0xc4)]&&typeof y[d]==='string'&&!new RegExp(Z['pattern'])['test'](y[d]))throw new ValidationError(d+'\x20should\x20match\x20regular\x20expression\x20('+Z['pattern']+')');}};function Y(w,y){w=w-0xbf;const d=f();let Z=d[w];return Z;}export{validateInputData};
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceContract, ResourceDependencies } from '../resource.types.js';
|
|
5
5
|
export declare function parseFilterQuery(query: Record<string, unknown>): Record<string, unknown> | undefined;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function buildIndex(resource: ResourceContract, filter: Record<string, unknown> | undefined, pg?: ResourceDependencies['pg']): void;
|
|
7
|
+
export declare function buildFilters(resource: ResourceContract, filter: Record<string, unknown> | undefined, start?: number): {
|
|
7
8
|
sql: string;
|
|
8
9
|
values: unknown[];
|
|
9
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;
|
|
1
|
+
{"version":3,"file":"filters.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/filters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AASnF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2BpG;AACD,wBAAgB,UAAU,CACtB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,EAAE,CAAC,EAAE,oBAAoB,CAAC,IAAI,CAAC,QAgBlC;AAED,wBAAgB,YAAY,CACxB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC3C,KAAK,SAAI;;;EAuDZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const G=Y;import{fieldColumn,qi}from'./sql.js';function f(){const x=['nin','filter','type','entries','Unsupported\x20filter\x20operator:\x20','ilike','null','push','NULL','<>\x20ALL','like','length','lower(','\x20AND\x20','isArray','true','geometry','btree'];f=function(){return x;};return f();}function Y(w,y){w=w-0x1b3;const d=f();let Z=d[w];return Z;}import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt','lte','in',G(0x1b3),'like','ilike','null']);export function parseFilterQuery(w){const U=G,y={...isRecord(w[U(0x1b4)])?w[U(0x1b4)]:{}};for(const [d,Z]of Object['entries'](w)){const M=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](d);if(!M)continue;const [,H,Q]=M;if(!H)continue;if(!Q){y[H]=Z;continue;}if(!filterOperators['has'](Q))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+Q);const s=isRecord(y[H])?y[H]:{};s[Q]=(Q==='in'||Q==='nin')&&typeof Z==='string'?Z['split'](','):Z,y[H]=s;}return Object['keys'](y)['length']?y:undefined;}export function buildIndex(w,y,d){const E=G;for(const [Z,M]of Object['entries'](y??{})){const H=w['fields'][Z];if(!H||H['filter']!==!![]&&H['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+Z);d&&autoIndex(w['table'],fieldColumn(w,Z),indexTypeFor(H[E(0x1b5)],'eq'),d);}}export function buildFilters(w,y,d=0x1){const e=G,Z=[],M=[];for(const [H,Q]of Object[e(0x1b6)](y??{})){const s=w['fields'][H];if(!s||s['filter']!==!![]&&s['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+H);const j=qi(fieldColumn(w,H)),n=isRecord(Q)?Q:{'eq':Q};for(const [t,K]of Object[e(0x1b6)](n)){if(!filterOperators['has'](t))throw new ValidationError(e(0x1b7)+t);if((t==='like'||t===e(0x1b8))&&s['type']!=='string'&&s['type']!=='text')throw new ValidationError('Operator\x20'+t+'\x20requires\x20a\x20text\x20field:\x20'+H);if(t===e(0x1b9)){Z[e(0x1ba)](j+'\x20IS\x20'+(isTruthy(K)?'':'NOT\x20')+e(0x1bb));continue;}if(t==='in'||t==='nin'){const i=Array['isArray'](K)?K:[K];if(i['length']===0x0){Z[e(0x1ba)](t==='in'?'FALSE':'TRUE');continue;}M['push'](i),Z[e(0x1ba)](j+'\x20'+(t==='in'?'=\x20ANY':e(0x1bc))+'($'+(d+M['length']-0x1)+')');continue;}const T={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':e(0x1bd)},h='$'+(d+M[e(0x1be)]);if(t===e(0x1bd)){M['push'](K+'%'),Z[e(0x1ba)](e(0x1bf)+j+')\x20like\x20lower('+h+')');continue;}M['push'](K),Z['push'](j+'\x20'+T[t]+'\x20'+h);}}return{'sql':Z['length']?'\x20WHERE\x20'+Z['join'](e(0x1c0)):'','values':M};}function isRecord(w){const l=G;return typeof w==='object'&&w!==null&&!Array[l(0x1c1)](w);}function isTruthy(w){const A=G;return w===!![]||w===A(0x1c2)||w==='1'||w===0x1;}function indexTypeFor(w,y){const c=G;if(y==='like'||y==='ilike')return'text';if(w==='geom'||w===c(0x1c3))return'gist';return c(0x1c4);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(){const Q=['debug','name','Authentication\x20required'];f=function(){return Q;};return f();}import{ForbiddenError}from'../../../errors.js';function Y(w,y){w=w-0x17a;const d=f();let Z=d[w];return Z;}import{getContext}from'../../../index.js';export function assertOperation(w,y,d){const H=Y,Z=getContext()['config'];if(Z[H(0x17a)])return;if(!w['operations']['includes'](y))throw new ForbiddenError(w[H(0x17b)]+'.'+y+'\x20is\x20disabled');if(w['access']!=='public'&&d===undefined)throw new ForbiddenError(H(0x17c));if(w['access']==='admin'&&d?.['type']!=='admin')throw new ForbiddenError('Admin\x20access\x20required');if(d?.['type']!=='admin'){const M=(w['permission']??w[H(0x17b)])+':'+y;if(!d?.['permissions']?.['includes'](M))throw new ForbiddenError('Missing\x20permission:\x20'+M);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function
|
|
1
|
+
import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';function Y(w,y){w=w-0x1a1;const d=f();let Z=d[w];return Z;}function f(){const n=['length','startsWith','sortable','\x20ORDER\x20BY\x20'];f=function(){return n;};return f();}export function buildSort(w,y){const s=Y;if(!y?.[s(0x1a1)])return'';typeof y==='string'&&(y=[y]);const d=y['map'](Z=>{const j=s,M=Z[j(0x1a2)]('-'),H=M?Z['slice'](0x1):Z,Q=w['fields'][H];if(!Q||Q[j(0x1a3)]!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+H);return qi(fieldColumn(w,H))+'\x20'+(M?'DESC':'ASC');});return s(0x1a4)+d['join'](',\x20');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Q=Y;function f(){const n=['replace','map','join','scope','fields','write','writable'];f=function(){return n;};return f();}import{ValidationError}from'../../../errors.js';export const quoteIdentifier=w=>'\x22'+w[Q(0x174)](/"/g,'\x22\x22')+'\x22';export const quoteTable=w=>w['split']('.')[Q(0x175)](quoteIdentifier)[Q(0x176)]('.');export function fieldColumn(w,y){if(y===w['key'])return w['key'];const d=w['fields'][y];if(!d)throw new ValidationError('Unknown\x20field:\x20'+y);return d['column']??y;}function Y(w,y){w=w-0x174;const d=f();let Z=d[w];return Z;}export function readableFields(w,y){const s=Q,d=Object['entries'](w['fields'])['filter'](([,Z])=>Z['read']!==![]&&Z['readable']!==![]&&(y?(Z[s(0x177)]??'all')===y:!![]))['map'](([Z,M])=>quoteIdentifier(M['column']??Z)+'\x20AS\x20'+quoteIdentifier(Z));return!w['fields'][w['key']]&&d['unshift'](quoteIdentifier(w['key'])),d;}export function writableData(w,y){const j=Q,d=[];for(const [Z,M]of Object['entries'](y)){const H=w[j(0x178)][Z];if(!H||H['write']===![]||H['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+Z);if((H[j(0x179)]??H[j(0x17a)])!==!![])continue;if(H['type']==='date'&&!y[Z])continue;d['push']([H['column']??Z,M]);}return d;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
|
@@ -0,0 +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;AAQ/G,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,YAAY,UA8CjG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildFilters}from'./filters.js';import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(w,y,d){const K=Y,Z={...defaultSummary,...w['summary']??{}},M=Object[K(0x75)](Z)[K(0x76)](([n,t])=>{const T=K;if('sql'in t)return'('+t[T(0x77)]+')\x20AS\x20\x22'+n+'\x22';switch(t['aggregate']){case T(0x78):return'(COUNT(*)\x20FILTER\x20(where\x20'+(t['where']??T(0x79))+'))::int\x20AS\x20\x22'+n+'\x22';case T(0x7a):return T(0x7b)+qt(t['field'])+T(0x7c)+(t['where']??'true')+'))::int\x20AS\x20\x22'+n+'\x22';case'sum':return'SUM('+t[T(0x7d)]+T(0x7c)+(t[T(0x7e)]??'true')+')\x20AS\x20\x22'+n+'\x22';case T(0x7f):return'AVG('+t['field']+T(0x7c)+(t['where']??'true')+')\x20AS\x20\x22'+n+'\x22';case'min':return'MIN('+t['field']+')\x20FILTER\x20(where\x20'+(t[T(0x7e)]??T(0x79))+')\x20AS\x20\x22'+n+'\x22';case'max':return'MAX('+t['field']+')\x20FILTER\x20(where\x20'+(t['where']??'true')+')\x20AS\x20\x22'+n+'\x22';}}),H=buildFilters(w,y['filter']);w[K(0x7e)]&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+w['where']+')'));const Q=y[K(0x80)]||(w['scopes']?.[K(0x81)]?'default':undefined);Q&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+(w['scopes']?.[Q]||K(0x79))+')'));const s=w['joins']?.[K(0x82)](n=>n[K(0x80)]!=='item')['map'](n=>n['sql']+'\x20')['join']('\x20')||'',j='SELECT\x20'+M['join'](',\x20')+'\x20'+(K(0x83)+qt(w['table'])+K(0x84))+(s+'\x20'+H['sql'][K(0x85)](/:uid/g,'\x27'+(d?.['id']??'NULL')+'\x27'));return j;}function Y(w,y){w=w-0x75;const d=f();let Z=d[w];return Z;}function f(){const h=['entries','map','sql','count','true','countDistinct','(COUNT(DISTINCT\x20t.',')\x20FILTER\x20(where\x20','field','where','avg','scope','default','filter','FROM\x20','\x20t\x20','replace'];f=function(){return h;};return f();}
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const y=Y,getIP=w=>(w['headers']?.['x-real-ip']||w['headers']?.['x-forwarded-for']||w['ip']||w['connection']?.['remoteAddress']||'')['split'](':')[y(0x132)]();function Y(w,y){w=w-0x132;const d=f();let Z=d[w];return Z;}function f(){const d=['pop'];f=function(){return d;};return f();}export default getIP;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
-
|
|
3
|
-
DO $$
|
|
4
|
-
BEGIN
|
|
5
|
-
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
-
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
-
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
-
END IF;
|
|
9
|
-
|
|
10
|
-
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
-
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
-
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
-
END IF;
|
|
14
|
-
END
|
|
15
|
-
$$;
|
|
16
|
-
|
|
17
|
-
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
DO $$
|
|
4
|
+
BEGIN
|
|
5
|
+
IF to_regclass('crm.notes') IS NOT NULL
|
|
6
|
+
AND to_regclass('admin.notes') IS NULL THEN
|
|
7
|
+
ALTER TABLE crm.notes SET SCHEMA admin;
|
|
8
|
+
END IF;
|
|
9
|
+
|
|
10
|
+
IF to_regclass('crm.files') IS NOT NULL
|
|
11
|
+
AND to_regclass('admin.files') IS NULL THEN
|
|
12
|
+
ALTER TABLE crm.files SET SCHEMA admin;
|
|
13
|
+
END IF;
|
|
14
|
+
END
|
|
15
|
+
$$;
|
|
16
|
+
|
|
17
|
+
ALTER INDEX IF EXISTS crm_notes_resource_idx RENAME TO admin_notes_resource_idx;
|
|
18
18
|
ALTER INDEX IF EXISTS crm_notes_uid_idx RENAME TO admin_notes_uid_idx;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
-
|
|
3
|
-
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
4
|
-
id text PRIMARY KEY DEFAULT next_id(),
|
|
5
|
-
resource text NOT NULL DEFAULT 'system',
|
|
6
|
-
resource_id text,
|
|
7
|
-
key text NOT NULL,
|
|
8
|
-
value jsonb,
|
|
9
|
-
updated_by text,
|
|
10
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
-
created_by text,
|
|
12
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
DROP INDEX IF EXISTS settings_resource_key_uidx;
|
|
16
|
-
|
|
17
|
-
CREATE UNIQUE INDEX settings_resource_key_uidx
|
|
18
|
-
ON admin.settings (resource, resource_id, key)
|
|
1
|
+
CREATE SCHEMA IF NOT EXISTS admin;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE IF NOT EXISTS admin.settings (
|
|
4
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
5
|
+
resource text NOT NULL DEFAULT 'system',
|
|
6
|
+
resource_id text,
|
|
7
|
+
key text NOT NULL,
|
|
8
|
+
value jsonb,
|
|
9
|
+
updated_by text,
|
|
10
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
11
|
+
created_by text,
|
|
12
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
DROP INDEX IF EXISTS settings_resource_key_uidx;
|
|
16
|
+
|
|
17
|
+
CREATE UNIQUE INDEX settings_resource_key_uidx
|
|
18
|
+
ON admin.settings (resource, resource_id, key)
|
|
19
19
|
NULLS NOT DISTINCT;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS admin.gallery (
|
|
2
|
+
id text PRIMARY KEY DEFAULT next_id(),
|
|
3
|
+
resource text,
|
|
4
|
+
resource_id text,
|
|
5
|
+
uploaded_name text,
|
|
6
|
+
file_type text,
|
|
7
|
+
file_status numeric,
|
|
8
|
+
file_name text,
|
|
9
|
+
size numeric,
|
|
10
|
+
mime_type text check (mime_type = any(array['image/png','image/jpeg','image/webp']) ),
|
|
11
|
+
tags text[],
|
|
12
|
+
file_path text,
|
|
13
|
+
field_name text,
|
|
14
|
+
status text DEFAULT 'pending', -- File processing status, e.g., 'pending', 'attached'
|
|
15
|
+
expires_at timestamptz DEFAULT now() + interval '1 day',
|
|
16
|
+
verified boolean DEFAULT false,
|
|
17
|
+
resized boolean,
|
|
18
|
+
created_by text REFERENCES admin.users(uid) ,
|
|
19
|
+
created_at timestamptz DEFAULT now(),
|
|
20
|
+
updated_by text REFERENCES admin.users(uid) ,
|
|
21
|
+
updated_at timestamptz default now()
|
|
22
|
+
);
|
package/package.json
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/fcore",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
4
|
-
"description": "Reusable backend foundation for OpenGIS Node.js applications",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist",
|
|
10
|
-
"migrations",
|
|
11
|
-
"README.md",
|
|
12
|
-
"LICENSE"
|
|
13
|
-
],
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/index.d.ts",
|
|
17
|
-
"import": "./dist/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./fastify": {
|
|
20
|
-
"types": "./dist/fastify.d.ts",
|
|
21
|
-
"import": "./dist/fastify.js"
|
|
22
|
-
},
|
|
23
|
-
"./migrate": {
|
|
24
|
-
"types": "./dist/migrations/runner.d.ts",
|
|
25
|
-
"import": "./dist/migrations/runner.js"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"bin": {
|
|
29
|
-
"fcore-migrate": "./dist/migrations/cli.js",
|
|
30
|
-
"fcore-adduser": "./dist/modules/auth/adduser-cli.js",
|
|
31
|
-
"fcore-passwd": "./dist/modules/auth/passwd-cli.js",
|
|
32
|
-
"fcore-permission": "./dist/modules/auth/permission-cli.js"
|
|
33
|
-
},
|
|
34
|
-
"scripts": {
|
|
35
|
-
"clean": "rm -rf dist",
|
|
36
|
-
"build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
|
|
37
|
-
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
-
"test": "node --test --import tsx test/**/*.test.ts",
|
|
39
|
-
"test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
|
|
40
|
-
"dev": "bun ./server.ts",
|
|
41
|
-
"adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
|
|
42
|
-
"passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
|
|
43
|
-
"permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
|
|
44
|
-
"migrate": "node --import tsx src/migrations/cli.ts",
|
|
45
|
-
"migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
|
|
46
|
-
"prepublishOnly": "npm run build",
|
|
47
|
-
"prepublishOnly1": "npm run build && npm test",
|
|
48
|
-
"patch": "npm version patch && git push && npm publish",
|
|
49
|
-
"minor": "npm version minor && git push && npm publish",
|
|
50
|
-
"major": "npm version major && git push && npm publish"
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">=20"
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"@aws-sdk/client-s3": "3.1125.0",
|
|
57
|
-
"@aws-sdk/lib-storage": "3.1125.0",
|
|
58
|
-
"@fastify/cookie": "11.1.2",
|
|
59
|
-
"@fastify/multipart": "10.1.1",
|
|
60
|
-
"@fastify/passport": "4.0.2",
|
|
61
|
-
"@fastify/rate-limit": "11.2.0",
|
|
62
|
-
"@fastify/session": "11.1.2",
|
|
63
|
-
"@sinclair/typebox": "^0.34.52",
|
|
64
|
-
"apache-crypt": "1.2.6",
|
|
65
|
-
"dotenv": "17.4.2",
|
|
66
|
-
"fastify-session-redis-store": "7.1.2",
|
|
67
|
-
"file-type": "22.0.2",
|
|
68
|
-
"ioredis": "6.0.0",
|
|
69
|
-
"jose": "^6.2.12",
|
|
70
|
-
"otplib": "13.5.0",
|
|
71
|
-
"pg": "8.23.0",
|
|
72
|
-
"pino": "10.3.1",
|
|
73
|
-
"pino-abstract-transport": "3.0.0",
|
|
74
|
-
"qrcode": "1.5.4",
|
|
75
|
-
"sharp": "0.35.4"
|
|
76
|
-
},
|
|
77
|
-
"peerDependencies": {
|
|
78
|
-
"fastify": ">=5.12.1"
|
|
79
|
-
},
|
|
80
|
-
"devDependencies": {
|
|
81
|
-
"@types/node": "22.20.1",
|
|
82
|
-
"@types/passport": "1.0.17",
|
|
83
|
-
"@types/passport-local": "1.0.38",
|
|
84
|
-
"@types/pg": "8.23.1",
|
|
85
|
-
"@types/qrcode": "1.5.6",
|
|
86
|
-
"fastify": "5.12.1",
|
|
87
|
-
"javascript-obfuscator": "5.6.0",
|
|
88
|
-
"tsx": "4.23.13",
|
|
89
|
-
"typescript": "7.0.2",
|
|
90
|
-
"vitest": "4.1.11"
|
|
91
|
-
},
|
|
92
|
-
"license": "UNLICENSED"
|
|
93
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@opengis/fcore",
|
|
3
|
+
"version": "0.0.1-beta.25",
|
|
4
|
+
"description": "Reusable backend foundation for OpenGIS Node.js applications",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"migrations",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./fastify": {
|
|
20
|
+
"types": "./dist/fastify.d.ts",
|
|
21
|
+
"import": "./dist/fastify.js"
|
|
22
|
+
},
|
|
23
|
+
"./migrate": {
|
|
24
|
+
"types": "./dist/migrations/runner.d.ts",
|
|
25
|
+
"import": "./dist/migrations/runner.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"fcore-migrate": "./dist/migrations/cli.js",
|
|
30
|
+
"fcore-adduser": "./dist/modules/auth/adduser-cli.js",
|
|
31
|
+
"fcore-passwd": "./dist/modules/auth/passwd-cli.js",
|
|
32
|
+
"fcore-permission": "./dist/modules/auth/permission-cli.js"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"clean": "rm -rf dist",
|
|
36
|
+
"build": "npm run clean && tsc -p tsconfig.json && node scripts/obfuscate.mjs",
|
|
37
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
38
|
+
"test": "node --test --import tsx test/**/*.test.ts",
|
|
39
|
+
"test-env": "node --env-file=.env.test --test --import tsx test/**/env.test.ts",
|
|
40
|
+
"dev": "bun ./server.ts",
|
|
41
|
+
"adduser": "node --import tsx ./src/modules/auth/adduser-cli.ts",
|
|
42
|
+
"passwd": "node --import tsx ./src/modules/auth/passwd-cli.ts",
|
|
43
|
+
"permission": "node --import tsx ./src/modules/auth/permission-cli.ts",
|
|
44
|
+
"migrate": "node --import tsx src/migrations/cli.ts",
|
|
45
|
+
"migration-test": "node --env-file=.env.test --import tsx src/migrations/cli.ts",
|
|
46
|
+
"prepublishOnly": "npm run build",
|
|
47
|
+
"prepublishOnly1": "npm run build && npm test",
|
|
48
|
+
"patch": "npm version patch && git push && npm publish",
|
|
49
|
+
"minor": "npm version minor && git push && npm publish",
|
|
50
|
+
"major": "npm version major && git push && npm publish"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@aws-sdk/client-s3": "3.1125.0",
|
|
57
|
+
"@aws-sdk/lib-storage": "3.1125.0",
|
|
58
|
+
"@fastify/cookie": "11.1.2",
|
|
59
|
+
"@fastify/multipart": "10.1.1",
|
|
60
|
+
"@fastify/passport": "4.0.2",
|
|
61
|
+
"@fastify/rate-limit": "11.2.0",
|
|
62
|
+
"@fastify/session": "11.1.2",
|
|
63
|
+
"@sinclair/typebox": "^0.34.52",
|
|
64
|
+
"apache-crypt": "1.2.6",
|
|
65
|
+
"dotenv": "17.4.2",
|
|
66
|
+
"fastify-session-redis-store": "7.1.2",
|
|
67
|
+
"file-type": "22.0.2",
|
|
68
|
+
"ioredis": "6.0.0",
|
|
69
|
+
"jose": "^6.2.12",
|
|
70
|
+
"otplib": "13.5.0",
|
|
71
|
+
"pg": "8.23.0",
|
|
72
|
+
"pino": "10.3.1",
|
|
73
|
+
"pino-abstract-transport": "3.0.0",
|
|
74
|
+
"qrcode": "1.5.4",
|
|
75
|
+
"sharp": "0.35.4"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"fastify": ">=5.12.1"
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@types/node": "22.20.1",
|
|
82
|
+
"@types/passport": "1.0.17",
|
|
83
|
+
"@types/passport-local": "1.0.38",
|
|
84
|
+
"@types/pg": "8.23.1",
|
|
85
|
+
"@types/qrcode": "1.5.6",
|
|
86
|
+
"fastify": "5.12.1",
|
|
87
|
+
"javascript-obfuscator": "5.6.0",
|
|
88
|
+
"tsx": "4.23.13",
|
|
89
|
+
"typescript": "7.0.2",
|
|
90
|
+
"vitest": "4.1.11"
|
|
91
|
+
},
|
|
92
|
+
"license": "UNLICENSED"
|
|
93
|
+
}
|