@opengis/fcore 0.0.1-beta.9 → 0.0.28
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 +0 -3
- 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.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.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 +19 -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 +25 -2
- 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.d.ts +1 -0
- package/dist/modules/system/services/get-access.d.ts.map +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.d.ts.map +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 +3 -1
- 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/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +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.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +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.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 +66 -14
- 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 +5 -2
- 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.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
- 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.d.ts +9 -2
- package/dist/plugins/resource/services/delete.d.ts.map +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.d.ts +8 -0
- package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
- package/dist/plugins/resource/services/get-table-columns.js +1 -0
- package/dist/plugins/resource/services/update-relation.d.ts +5 -2
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts +9 -2
- package/dist/plugins/resource/services/update.d.ts.map +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/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.d.ts +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +7 -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/20260903120000_core_schema.sql +5 -2
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +93 -93
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
id: string | number;
|
|
6
7
|
data: Record<string, unknown>;
|
|
7
8
|
user?: ResourceUser;
|
|
8
|
-
|
|
9
|
+
where?: {
|
|
10
|
+
column: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, where, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
15
|
+
export {};
|
|
9
16
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DjI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function f(p,Z){p=p-0x113;const A=s();let I=A[p];return I;}import{clearTableLookupCache}from'./add-table-lookup-data.js';function s(){const V=['get','length','updated_at','push','user_type','key','\x20=\x20$','column','query','UPDATE\x20','SET\x20','join','table','audit','update','keys'];s=function(){return V;};return s();}export function createUpdate(p,Z){return async function A({name:I,id:j,data:D,user:o,where:R},B){const G=f,H=Z[G(0x113)](I);assertOperation(H,'update',o);const e=writableData(H,D);if(!e[G(0x114)])throw new ValidationError('No\x20writable\x20fields');const g=B?.['pg']??p['pg'];validateInputData({'resource':H,'data':D,'update':!![]});H['fields']['updated_at']&&e['push']([G(0x115),new Date()]);H['fields']['updated_by']&&e[G(0x116)](['updated_by',o?.['id']]);delete D[G(0x117)];const N=e['map'](([K],Q)=>qi(K)+'\x20=\x20$'+(Q+0x1)),h=[...e['map'](([,K])=>K),j];let E='WHERE\x20'+qi(H[G(0x118)])+G(0x119)+h[G(0x114)];R&&(h['push'](R['value']),E+='\x20AND\x20'+qi(R[G(0x11a)])+'\x20=\x20$'+h[G(0x114)]);H['where']&&(E+='\x20AND\x20('+H['where']+')');const a=await g[G(0x11b)](G(0x11c)+qt(H['table'])+'\x20'+(G(0x11d)+N[G(0x11e)](',\x20')+'\x20')+(E+'\x20')+('RETURNING\x20'+Object['keys'](D)['map'](qi)['join'](',\x20')),h),X=a['rows'][0x0];if(!X)throw new NotFoundError(I+':'+j);return clearTableLookupCache(H[G(0x11f)],g),await(B?.[G(0x120)]??p['audit'])?.['write']({'userId':o?.['id'],'module':H['module'],'resource':H['name'],'resourceId':j,'action':G(0x121),'fields':Object[G(0x122)](D)}),X;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(
|
|
1
|
+
const B=f;import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(p,Z,A=B(0x1b2),I){const H=B,j=requestedIndexes[H(0x1b3)](I)??new Set();requestedIndexes['set'](I,j);const D=p+':'+Z+':'+A;if(j['has'](D))return;j[H(0x1b4)](D),void ensureIndex(p,Z,A,I)['catch'](()=>{j['delete'](D);});}function s(){const g=['btree','get','add','split','query','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];s=function(){return g;};return s();}function f(p,Z){p=p-0x1b2;const A=s();let I=A[p];return I;}async function ensureIndex(p,Z,A,I){const e=B,j=p[e(0x1b5)]('.'),D=j['length']===0x2?j[0x0]:'public',o=(p+'_'+Z+'_'+A+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),R=await I[e(0x1b6)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[D,o]);if(R['rowCount'])return;if(A==='text'){await I['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await I['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(o+'_l')+'\x20ON\x20'+qt(p)+'\x20USING\x20btree\x20(lower('+qi(Z)+')\x20text_pattern_ops)'),await I['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(o)+'\x20ON\x20'+qt(p)+'\x20USING\x20gin\x20(lower('+qi(Z)+')\x20gin_trgm_ops)');return;}await I['query'](e(0x1b7)+qi(o)+'\x20ON\x20'+qt(p)+'\x20USING\x20'+A+'\x20('+qi(Z)+')');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function s(){const D=['fields','writable','required','hasOwn','string','length','maximum','includes','\x20should\x20be\x20one\x20of\x20(','join','test','\x20should\x20match\x20regular\x20expression\x20('];s=function(){return D;};return s();}import{ValidationError}from'../../../errors.js';export{readableFields,writableData,fieldColumn}from'./sql.js';function f(p,Z){p=p-0x15a;const A=s();let I=A[p];return I;}const validateInputData=({resource:p,data:Z,update:update=![]})=>{const j=f;for(const [A,I]of Object['entries'](p[j(0x15a)])){if(I['required']&&I[j(0x15b)]!==![]&&(Z[A]===undefined||Z[A]===null)&&!update)throw new ValidationError('Required\x20field:\x20'+A);if(I[j(0x15c)]&&I['writable']!==![]&&Object[j(0x15d)](Z,A)&&(Z[A]===undefined||Z[A]===null)&&update)throw new ValidationError('Required\x20field:\x20'+A);if(I['minLength']&&typeof Z[A]===j(0x15e)&&Z[A]['length']<I['minLength'])throw new ValidationError('minLength\x20not\x20met:\x20'+A);if(I['maxLength']&&typeof Z[A]==='string'&&Z[A][j(0x15f)]>I['maxLength'])throw new ValidationError('maxLength\x20exceeded:\x20'+A);if(I['minimum']&&typeof Z[A]==='number'&&Z[A]<I['minimum'])throw new ValidationError(A+'\x20should\x20be\x20>=\x20'+I['minimum']);if(I['maximum']&&typeof Z[A]==='number'&&Z[A]>I[j(0x160)])throw new ValidationError(A+'\x20should\x20be\x20<=\x20'+I['maximum']);if(I['enum']&&Z[A]&&!I['enum'][j(0x161)](Z[A]))throw new ValidationError(A+j(0x162)+I['enum'][j(0x163)](',\x20')+')');if(I['pattern']&&typeof Z[A]==='string'&&!new RegExp(I['pattern'])[j(0x164)](Z[A]))throw new ValidationError(A+j(0x165)+I['pattern']+')');}};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
|
-
|
|
1
|
+
const a=f;import{fieldColumn,qi}from'./sql.js';import{ValidationError}from'../../../errors.js';import{autoIndex}from'./auto-index.js';const filterOperators=new Set(['eq','ne','gt','gte','lt',a(0x1b6),'in','nin',a(0x1b7),a(0x1b8),a(0x1b9)]);export function parseFilterQuery(p){const X=a,Z={...isRecord(p['filter'])?p[X(0x1ba)]:{}};for(const [A,I]of Object['entries'](p)){const j=/^filter\[([^\]]+)\](?:\[([^\]]+)\])?$/['exec'](A);if(!j)continue;const [,D,o]=j;if(!D)continue;if(!o){Z[D]=I;continue;}if(!filterOperators[X(0x1bb)](o))throw new ValidationError(X(0x1bc)+o);const R=isRecord(Z[D])?Z[D]:{};R[o]=(o==='in'||o===X(0x1bd))&&typeof I===X(0x1be)?I[X(0x1bf)](','):I,Z[D]=R;}return Object[X(0x1c0)](Z)[X(0x1c1)]?Z:undefined;}export function buildIndex(p,Z,A){for(const [I,j]of Object['entries'](Z??{})){const D=p['fields'][I];if(!D||D['filter']!==!![]&&D['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+I);A&&autoIndex(p['table'],fieldColumn(p,I),indexTypeFor(D['type'],'eq'),A);}}function f(p,Z){p=p-0x1b6;const A=s();let I=A[p];return I;}export function buildFilters(p,Z,A=0x1){const K=a,I=[],j=[];for(const [D,o]of Object[K(0x1c2)](Z??{})){const R=p['fields'][D];if(!R||R[K(0x1ba)]!==!![]&&R['filterable']!==!![])throw new ValidationError('Field\x20is\x20not\x20filterable:\x20'+D);const B=qi(fieldColumn(p,D)),H=isRecord(o)?o:{'eq':o};for(const [e,g]of Object[K(0x1c2)](H)){if(!filterOperators['has'](e))throw new ValidationError('Unsupported\x20filter\x20operator:\x20'+e);if((e==='like'||e===K(0x1b8))&&R['type']!=='string'&&R['type']!=='text')throw new ValidationError(K(0x1c3)+e+'\x20requires\x20a\x20text\x20field:\x20'+D);if(e===K(0x1b9)){I[K(0x1c4)](B+'\x20IS\x20'+(isTruthy(g)?'':K(0x1c5))+'NULL');continue;}if(e==='in'||e==='nin'){const E=Array['isArray'](g)?g:[g];if(E['length']===0x0){I['push'](e==='in'?'FALSE':K(0x1c6));continue;}j[K(0x1c4)](E),I['push'](B+'\x20'+(e==='in'?'=\x20ANY':K(0x1c7))+'($'+(A+j[K(0x1c1)]-0x1)+')');continue;}const N={'eq':'=','ne':'<>','gt':'>','gte':'>=','lt':'<','lte':'<=','like':K(0x1b7)},h='$'+(A+j['length']);if(e==='like'){j['push'](g+'%'),I[K(0x1c4)]('lower('+B+K(0x1c8)+h+')');continue;}j['push'](g),I['push'](B+'\x20'+N[e]+'\x20'+h);}}return{'sql':I[K(0x1c1)]?'\x20WHERE\x20'+I['join']('\x20AND\x20'):'','values':j};}function s(){const V=['lte','like','ilike','null','filter','has','Unsupported\x20filter\x20operator:\x20','nin','string','split','keys','length','entries','Operator\x20','push','NOT\x20','TRUE','<>\x20ALL',')\x20like\x20lower(','isArray','geom','gist','btree'];s=function(){return V;};return s();}function isRecord(p){const Q=a;return typeof p==='object'&&p!==null&&!Array[Q(0x1c9)](p);}function isTruthy(p){return p===!![]||p==='true'||p==='1'||p===0x1;}function indexTypeFor(p,Z){const G=a;if(Z==='like'||Z===G(0x1b8))return'text';if(p===G(0x1ca)||p==='geometry')return G(0x1cb);return G(0x1cc);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{ForbiddenError}from'../../../errors.js';function s(){const o=['config','public','admin','type','includes','Missing\x20permission:\x20'];s=function(){return o;};return s();}function f(p,Z){p=p-0x86;const A=s();let I=A[p];return I;}import{getContext}from'../../../index.js';export function assertOperation(p,Z,A){const D=f,I=getContext()[D(0x86)];if(I['debug'])return;if(!p['operations']['includes'](Z))throw new ForbiddenError(p['name']+'.'+Z+'\x20is\x20disabled');if(p['access']!==D(0x87)&&A===undefined)throw new ForbiddenError('Authentication\x20required');if(p['access']===D(0x88)&&A?.[D(0x89)]!==D(0x88))throw new ForbiddenError('Admin\x20access\x20required');if(A?.['type']!==D(0x88)){const j=(p['permission']??p['name'])+':'+Z;if(!A?.['permissions']?.[D(0x8a)](j))throw new ForbiddenError(D(0x8b)+j);}}
|
|
@@ -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';import{qi}from'./sql.js';function f(p,Z){p=p-0xe3;const A=s();let I=A[p];return I;}const scopeCache=new Map(),CACHE_TTL_MS=0x7530;export function clearResourceScopeCache(p,Z){const g=f;if(p&&Z){scopeCache['delete'](p+':'+Z);return;}if(p){for(const A of scopeCache['keys']()){if(A['startsWith'](p+':'))scopeCache['delete'](A);}return;}scopeCache[g(0xe3)]();}function s(){const K=['clear','get','promise','query','scope','value','set','fromEntries','name','key','user_uid','created_by','fields','type','admin','\x20=\x20$','push','length','\x20AND\x20'];s=function(){return K;};return s();}async function loadScopeRows(p,Z,A){const N=f,I=p+':'+Z,j=scopeCache[N(0xe4)](I);if(j&&j['expiresAt']>Date['now']())return j[N(0xe5)];const D=A[N(0xe6)]('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)',[p,Z])['then'](({rows:o})=>{const h=N,R=new Map();for(const B of o){const H=R['get'](B[h(0xe7)])??[];if(Array['isArray'](B['value']))H['push'](...B['value']);else{if(B['value']!==null&&B[h(0xe8)]!==undefined)H['push'](B['value']);}R['set'](B[h(0xe7)],H);}return R;})['catch'](o=>{scopeCache['delete'](I);throw o;});return scopeCache[N(0xe9)](I,{'expiresAt':Date['now']()+CACHE_TTL_MS,'promise':D}),D;}export async function getUserResourceScopes(p,Z,A){const E=f,I=await loadScopeRows(p,Z,A);return Object[E(0xea)]([...I]['map'](([j,D])=>[j,j==='me'?p:D]));}function columnForScope(p,Z){const a=f;if(Z===p[a(0xeb)])return p[a(0xec)];if(Z==='me'){const I=['user_id',a(0xed),'owner_id',a(0xee)]['find'](j=>p[a(0xef)][j]);if(!I)throw new ValidationError('Cannot\x20apply\x20\x22me\x22\x20scope\x20to\x20resource\x20without\x20an\x20owner\x20field:\x20'+p[a(0xeb)]);return p['fields'][I]?.['column']??I;}const A=p['fields'][Z];if(!A)return'';return A['column']??Z;}export async function buildUserResourceScopeFilter(p,Z,A,I){const X=f;if(!Z||Z[X(0xf0)]===X(0xf1))return{'sql':'','values':[]};const j=await loadScopeRows(Z['id'],p[X(0xeb)],A),D=[],o=[];for(const [R,B]of j){const H=columnForScope(p,R);if(!H){D['push']('(FALSE)');continue;}const e='t.'+qi(H);if(R==='me'){o['push'](Z['id']),D['push']('('+e+X(0xf2)+(I+o['length']-0x1)+')');continue;}if(B['length']===0x0){D[X(0xf3)]('(FALSE)');continue;}o[X(0xf3)](B),D['push']('('+e+'\x20=\x20ANY($'+(I+o[X(0xf4)]-0x1)+'))');}return{'sql':D['join'](X(0xf5)),'values':o};}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provides Resource helpers for sort handling.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceContract } from
|
|
4
|
+
import type { ResourceContract } from "../resource.types.js";
|
|
5
5
|
export declare function buildSort(resource: ResourceContract, sort?: string[]): string;
|
|
6
6
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sort.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,wBAAgB,SAAS,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,UAcpE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(){const H=['string','ASC','join'];s=function(){return H;};return s();}import{fieldColumn,qi}from'./sql.js';function f(p,Z){p=p-0x67;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';export function buildSort(p,Z){const R=f;if(!Z?.['length'])return'';typeof Z===R(0x67)&&(Z=[Z]);const A=Z['map'](I=>{const B=R,j=I['startsWith']('-'),D=j?I['slice'](0x1):I,o=p['fields'][D];if(!o||o['sortable']!==!![])throw new ValidationError('Field\x20is\x20not\x20sortable:\x20'+D);return qi(fieldColumn(p,D))+'\x20'+(j?'DESC':B(0x68));});return'\x20ORDER\x20BY\x20'+A[R(0x69)](',\x20');}
|
|
@@ -4,7 +4,7 @@ export declare const quoteIdentifier: (value: string) => string;
|
|
|
4
4
|
/** Quote a schema-qualified PostgreSQL table name. */
|
|
5
5
|
export declare const quoteTable: (value: string) => string;
|
|
6
6
|
export declare function fieldColumn(resource: ResourceContract, name: string): string;
|
|
7
|
-
export declare function readableFields(resource: ResourceContract): string[];
|
|
7
|
+
export declare function readableFields(resource: ResourceContract, scope?: string): string[];
|
|
8
8
|
export declare function writableData(resource: ResourceContract, data: Record<string, unknown>): Array<[
|
|
9
9
|
string,
|
|
10
10
|
unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/sql.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,6CAA6C;AAC7C,eAAO,MAAM,eAAe,UAAW,MAAM,KAAG,MAA0C,CAAC;AAC3F,sDAAsD;AACtD,eAAO,MAAM,UAAU,UAAW,MAAM,KAAG,MAAyD,CAAC;AACrG,wBAAgB,WAAW,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5E;AACD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQnF;AACD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;IAC3F,MAAM;IACN,OAAO;CACV,CAAC,CAmBD;AAED,eAAO,MAAM,EAAE,wBAAkB,CAAC;AAClC,eAAO,MAAM,EAAE,mBAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const o=f;import{ValidationError}from'../../../errors.js';export const quoteIdentifier=p=>'\x22'+p['replace'](/"/g,'\x22\x22')+'\x22';function s(){const e=['split','Unknown\x20field:\x20','fields','read','scope','column','unshift','write'];s=function(){return e;};return s();}export const quoteTable=p=>p[o(0x1cd)]('.')['map'](quoteIdentifier)['join']('.');function f(p,Z){p=p-0x1cd;const A=s();let I=A[p];return I;}export function fieldColumn(p,Z){const R=o;if(Z===p['key'])return p['key'];const A=p['fields'][Z];if(!A)throw new ValidationError(R(0x1ce)+Z);return A['column']??Z;}export function readableFields(p,Z){const B=o,A=Object['entries'](p[B(0x1cf)])['filter'](([,I])=>I[B(0x1d0)]!==![]&&I['readable']!==![]&&(Z?(I[B(0x1d1)]??'all')===Z:!![]))['map'](([I,j])=>quoteIdentifier(j[B(0x1d2)]??I)+'\x20AS\x20'+quoteIdentifier(I));return!p['fields'][p['key']]&&A[B(0x1d3)](quoteIdentifier(p['key'])),A;}export function writableData(p,Z){const H=o,A=[];for(const [I,j]of Object['entries'](Z)){const D=p['fields'][I];if(!D||D[H(0x1d4)]===![]||D['writable']===![])throw new ValidationError('Field\x20is\x20not\x20writable:\x20'+I);if((D[H(0x1d4)]??D['writable'])!==!![])continue;if(D['type']==='date'&&!Z[I])continue;A['push']([D[H(0x1d2)]??I,j]);}return A;}export const qi=quoteIdentifier;export const qt=quoteTable;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
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
|
+
};
|
|
7
|
+
//# sourceMappingURL=summary.d.ts.map
|
|
@@ -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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function f(p,Z){p=p-0x1ce;const A=s();let I=A[p];return I;}function s(){const a=['aggregate','where','))::int\x20AS\x20\x22',')\x20AS\x20\x22',')\x20FILTER\x20(where\x20','true','MIN(','max','filter','\x20AND\x20','default','keys','searchable','push','sql','values','item','map','SELECT\x20'];s=function(){return a;};return s();}import{buildFilters}from'./filters.js';import{qt}from'./sql.js';const defaultSummary={'count':{'aggregate':'count'}};export function buildSummary(p,Z,A,I){const E=f,j={...defaultSummary,...p['summary']??{}},D=Object['entries'](j)['map'](([g,N])=>{const h=f;if('sql'in N)return'('+N['sql']+')\x20AS\x20\x22'+g+'\x22';switch(N[h(0x1ce)]){case'count':return'(COUNT(*)\x20FILTER\x20(where\x20'+(N[h(0x1cf)]??'true')+h(0x1d0)+g+'\x22';case'countDistinct':return'(COUNT(DISTINCT\x20t.'+qt(N['field'])+')\x20FILTER\x20(where\x20'+(N['where']??'true')+'))::int\x20AS\x20\x22'+g+'\x22';case'sum':return'SUM('+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';case'avg':return'AVG('+N['field']+h(0x1d2)+(N['where']??h(0x1d3))+h(0x1d1)+g+'\x22';case'min':return h(0x1d4)+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';case h(0x1d5):return'MAX('+N['field']+')\x20FILTER\x20(where\x20'+(N['where']??'true')+h(0x1d1)+g+'\x22';}}),o=buildFilters(p,Z[E(0x1d6)]);p['where']&&(o['sql']+=(o['sql']?E(0x1d7):'\x20WHERE\x20')+('('+p['where']+')'));const R=Z['scope']||(p['scopes']?.[E(0x1d8)]?'default':undefined);R&&(o['sql']+=(o['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+(p['scopes']?.[R]||'true')+')'));const B=p['searchable']||Object[E(0x1d9)](p['fields'])[E(0x1d6)](g=>p['fields'][g]?.[E(0x1da)]);Z['search']&&B['length']&&(o['values'][E(0x1db)](Z['search']['toLowerCase']()+'%'),o[E(0x1dc)]+=(o[E(0x1dc)]?E(0x1d7):'\x20WHERE\x20')+('\x20('+B['map'](g=>'lower('+qt(g)+')\x20LIKE\x20$'+o[E(0x1dd)]['length'])['join']('\x20OR\x20')+')'));I?.['sql']&&(o['sql']+=(o[E(0x1dc)]?E(0x1d7):'\x20WHERE\x20')+('('+I[E(0x1dc)]+')'),o['values']['push'](...I['values']));const H=p['joins']?.['filter'](g=>g['scope']!==E(0x1de))[E(0x1df)](g=>g['sql']+'\x20')['join']('\x20')||'',e=E(0x1e0)+D['join'](',\x20')+'\x20'+('FROM\x20'+qt(p['table'])+'\x20t\x20')+(H+'\x20'+o[E(0x1dc)]['replace'](/:uid/g,'\x27'+(A?.['id']??'NULL')+'\x27'));return{'sql':e,'values':o['values']};}
|
package/dist/shared/getIP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function f(p,Z){p=p-0xb7;const A=s();let I=A[p];return I;}const Z=f,getIP=p=>(p['headers']?.['x-real-ip']||p[Z(0xb7)]?.[Z(0xb8)]||p['ip']||p[Z(0xb9)]?.[Z(0xba)]||'')['split'](':')['pop']();function s(){const A=['headers','x-forwarded-for','connection','remoteAddress'];s=function(){return A;};return s();}export default getIP;
|
|
@@ -182,9 +182,12 @@ CREATE TABLE IF NOT EXISTS admin.files (
|
|
|
182
182
|
file_status numeric,
|
|
183
183
|
file_name text,
|
|
184
184
|
size numeric,
|
|
185
|
-
|
|
185
|
+
mime_type text,
|
|
186
186
|
tags text[],
|
|
187
|
-
file_path text,
|
|
187
|
+
file_path text,
|
|
188
|
+
field_name text,
|
|
189
|
+
status text DEFAULT 'pending', -- File processing status, e.g., 'pending', 'attached'
|
|
190
|
+
expires_at timestamptz DEFAULT now() + interval '1 day',
|
|
188
191
|
verified boolean DEFAULT false,
|
|
189
192
|
resized boolean,
|
|
190
193
|
created_by text REFERENCES admin.users(uid) ,
|
|
@@ -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;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
alter table admin.files add column if not exists mime_type text;
|
|
3
|
+
alter table admin.files add column if not exists status text default 'pending';
|
|
4
|
+
alter table admin.files add column if not exists expires_at timestamptz default now() + interval '1 day';
|
|
5
|
+
alter table admin.files add column if not exists field_name text;
|
|
@@ -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
|
+
);
|
|
@@ -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,93 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@opengis/fcore",
|
|
3
|
-
"version": "0.0.
|
|
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.28",
|
|
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
|
+
}
|