@opengis/fcore 0.0.1-beta.5 → 0.0.1-beta.7
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.d.ts +2 -1
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.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.d.ts +3 -0
- package/dist/modules/auth/schema.d.ts.map +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 +1 -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.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- 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 +0 -3
- 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 +3 -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.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +2 -0
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +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.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- 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.js +1 -1
- package/dist/modules/system/services/check-system.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- 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.d.ts.map +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-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +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.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -1
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.d.ts.map +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/index.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.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +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.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +18 -3
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -1
- 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.js +1 -1
- 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 +3 -2
- 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 +3 -2
- 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/update-relation.d.ts +11 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- 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.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- 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.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260905120000_add_user_foreign_keys.sql +42 -42
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function U(){const f=['slice','join','date','stream','values','end','level','stringify'];U=function(){return f;};return U();}import C from'node:fs';import N from'node:path';function z(C,N){C=C-0x8e;const r=U();let p=r[C];return p;}import r from'pino-abstract-transport';const LEVELS={0x1e:'info',0x28:'warn',0x32:'error',0x3c:'error'},streams=new Map();function getDate(){const Q=z;return new Date()['toISOString']()[Q(0x8e)](0x0,0xa);}function createStream(p,c){const u=z,x=N['resolve']('logs',p);return C['mkdirSync'](x,{'recursive':!![]}),C['createWriteStream'](N[u(0x8f)](x,c+'.log'),{'flags':'a'});}function getStream(p){const L=z,c=getDate(),x=streams['get'](p);if(x&&x[L(0x90)]===c)return x['stream'];x?.[L(0x91)]['end']();const m=createStream(p,c);return streams['set'](p,{'date':c,'stream':m}),m;}function closeStreams(){const T=z;for(const {stream:p}of streams[T(0x92)]()){p[T(0x93)]();}streams['clear']();}export default async function loggerTransport(){return r(writeLogs,{'close':async()=>{closeStreams();}});}async function writeLogs(p){const Y=z;for await(const c of p){const x=LEVELS[c[Y(0x94)]];if(!x)continue;const m=getStream(c['file']||x);delete c['file'],m['write'](JSON[Y(0x95)](c)+'\x0a');}}
|
package/dist/plugins/pg.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"pg.d.ts","sourceRoot":"","sources":["../../src/plugins/pg.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,wBAAgB,cAAc,CAC1B,MAAM,EAAE,cAAc,qBAuBzB;AACD,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC,IAAI,CAAC"}
|
package/dist/plugins/pg.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function z(C,N){C=C-0x1f0;const r=U();let p=r[C];return p;}import C from'pg';const {Pool}=C;function U(){const f=['captureStackTrace','sql','callerStack'];U=function(){return f;};return U();}export function createDatabase(N){const r=new Pool(N),p=r['query']['bind'](r);function c(x,m){const T=z,Q=new Error();return Error[T(0x1f0)]?.(Q,c),p(x,m)['catch'](u=>{const Y=T,L=u;L[Y(0x1f1)]=x,L[Y(0x1f2)]=Q['stack'];throw L;});}return r['query']=c,r;}
|
package/dist/plugins/redis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function z(C,N){C=C-0xae;const r=U();let p=r[C];return p;}import{Redis}from'ioredis';export function createRedis(C){const m=z,N=new Redis(C);return{'get':r=>N['get'](r),'set':(r,p,c,x)=>{if(x)return N['set'](r,p,'EX',x);if(typeof c==='number')return N['set'](r,p,'EX',c);return N['set'](r,p);},'del':r=>N['del'](r),'delete':r=>N[m(0xae)](r),'close':()=>N['quit'](),'ping':()=>N['ping'](),'hincrby':(r,p,c)=>N[m(0xaf)](r,p,c),'incrby':(r,p)=>N['incrby'](r,p)};}function U(){const Q=['del','hincrby'];U=function(){return Q;};return U();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from'./resource.types.js';export*from'./resource.registry.js';export*from'./resource.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUhF,wBAAgB,cAAc,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA2BzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ResourceRegistry}from'./resource.registry.js';import{createFind}from'./services/find.js';import{createFindOne}from'./services/find-one.js';import{createCreate}from'./services/create.js';import{createUpdate}from'./services/update.js';import{createRemove}from'./services/delete.js';import{createFindRelation}from'./services/find-relation.js';import{createCreateRelation}from'./services/create-relation.js';import{createDeleteRelation}from'./services/delete-relation.js';import{createUpdateRelation}from'./services/update-relation.js';export function createResource(C){const N=new ResourceRegistry(),r=createFind(C,N),p=createFindOne(C,N),c=createCreate(C,N),x=createUpdate(C,N),m=createRemove(C,N),Q=createFindRelation(C,N),u=createCreateRelation(C,N),L=createUpdateRelation(C,N),T=createDeleteRelation(C,N);return{'register':N['register']['bind'](N),'has':N['has']['bind'](N),'get':N['get']['bind'](N),'list':N['list']['bind'](N),'find':r,'findOne':p,'create':c,'update':x,'delete':m,'findRelation':Q,'createRelation':u,'updateRelation':L,'deleteRelation':T};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const x=z;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';function z(C,N){C=C-0x164;const r=U();let p=r[C];return p;}function U(){const u=['split','test','name','get','Resource\x20not\x20registered:\x20','version','table','entries','fields'];U=function(){return u;};return U();}const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(C){const p=z;return C['split']('.')['length']<=0x2&&C[p(0x164)]('.')['every'](N=>ident[p(0x165)](N));}export class ResourceRegistry{['resources']=new Map();['register'](C){const c=z;for(const N of Array['isArray'](C)?C:[C]){this['validate'](N);if(this['resources']['has'](N[c(0x166)]))throw new ConflictError('Resource\x20already\x20registered:\x20'+N[c(0x166)]);this['resources']['set'](N['name'],N);}}['has'](C){return this['resources']['has'](C);}[x(0x167)](C){const m=x,N=this['resources']['get'](C);if(!N)throw new NotFoundError(m(0x168)+C);return N;}['list'](){return[...this['resources']['values']()];}['validate'](C){const Q=x;if(C[Q(0x169)]!==0x1||!ident['test'](C['name'])||!validQualified(C[Q(0x16a)])||!ident['test'](C['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+C['name']);for(const [N,r]of Object[Q(0x16b)](C[Q(0x16c)])){if(!ident['test'](N)||!ident['test'](r['column']??N))throw new ValidationError('Invalid\x20resource\x20field:\x20'+N);}}}
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import type { DatabaseAdapter } from "../pg.js";
|
|
5
5
|
import type { AppLogger } from "../logger/index.js";
|
|
6
6
|
import type { AuditPlugin } from "../audit/index.js";
|
|
7
|
+
import type { DictionaryPlugin } from "../dictionary.js";
|
|
8
|
+
import type { FileAdapter } from "../file.js";
|
|
7
9
|
import { User } from "../../context.js";
|
|
8
10
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
9
11
|
export interface ResourceFieldContract {
|
|
10
12
|
column?: string;
|
|
11
|
-
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid";
|
|
13
|
+
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
12
14
|
read?: boolean;
|
|
13
15
|
write?: boolean;
|
|
14
16
|
readable?: boolean;
|
|
@@ -40,6 +42,7 @@ export interface ResourceRelationContract {
|
|
|
40
42
|
sourceField?: string;
|
|
41
43
|
foreignKey?: string;
|
|
42
44
|
targetField?: string;
|
|
45
|
+
type?: "one" | "many";
|
|
43
46
|
fields?: string[];
|
|
44
47
|
}
|
|
45
48
|
export interface ResourceContract {
|
|
@@ -54,11 +57,11 @@ export interface ResourceContract {
|
|
|
54
57
|
permission?: string;
|
|
55
58
|
fields: Record<string, ResourceFieldContract>;
|
|
56
59
|
relations?: Record<string, ResourceRelationContract>;
|
|
57
|
-
children?: Record<string, ResourceRelationContract>;
|
|
58
60
|
access?: "public" | "user" | "admin";
|
|
59
61
|
}
|
|
60
62
|
export interface ResourceQuery {
|
|
61
63
|
filter?: Record<string, unknown>;
|
|
64
|
+
include?: string | string[];
|
|
62
65
|
sort?: string[];
|
|
63
66
|
search?: string;
|
|
64
67
|
limit?: number;
|
|
@@ -74,9 +77,11 @@ export interface ResourceListResult<T = Record<string, unknown>> {
|
|
|
74
77
|
}
|
|
75
78
|
export type ResourceUser = User;
|
|
76
79
|
export interface ResourceDependencies {
|
|
77
|
-
pg: DatabaseAdapter
|
|
80
|
+
pg: DatabaseAdapter;
|
|
78
81
|
logger?: AppLogger;
|
|
79
82
|
audit?: AuditPlugin;
|
|
83
|
+
dictionary?: DictionaryPlugin;
|
|
84
|
+
file?: FileAdapter;
|
|
80
85
|
}
|
|
81
86
|
export interface ResourcePlugin {
|
|
82
87
|
register(input: ResourceContract | ResourceContract[]): void;
|
|
@@ -91,6 +96,7 @@ export interface ResourcePlugin {
|
|
|
91
96
|
findOne(params: {
|
|
92
97
|
name: string;
|
|
93
98
|
id: string | number;
|
|
99
|
+
query?: ResourceQuery;
|
|
94
100
|
user?: ResourceUser;
|
|
95
101
|
}): Promise<Record<string, unknown> | null>;
|
|
96
102
|
create(params: {
|
|
@@ -113,6 +119,7 @@ export interface ResourcePlugin {
|
|
|
113
119
|
name: string;
|
|
114
120
|
id: string | number;
|
|
115
121
|
relation: string;
|
|
122
|
+
query?: ResourceQuery;
|
|
116
123
|
user?: ResourceUser;
|
|
117
124
|
}): Promise<any>;
|
|
118
125
|
createRelation(params: {
|
|
@@ -122,6 +129,14 @@ export interface ResourcePlugin {
|
|
|
122
129
|
data?: Record<string, unknown>;
|
|
123
130
|
user?: ResourceUser;
|
|
124
131
|
}): Promise<any>;
|
|
132
|
+
updateRelation(params: {
|
|
133
|
+
name: string;
|
|
134
|
+
id: string | number;
|
|
135
|
+
relation: string;
|
|
136
|
+
relationId: string;
|
|
137
|
+
data: Record<string, unknown>;
|
|
138
|
+
user?: ResourceUser;
|
|
139
|
+
}): Promise<Record<string, unknown>>;
|
|
125
140
|
deleteRelation(params: {
|
|
126
141
|
name: string;
|
|
127
142
|
id: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.types.d.ts","sourceRoot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,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACrC,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addDictionaryLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], dictionary: ResourceDependencies["dictionary"]): Promise<Record<string, unknown>[]>;
|
|
3
|
+
//# sourceMappingURL=add-dictionary-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dictionary-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-dictionary-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsDnF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function U(){const h=['get','set','revision','length','all','has','color','icon','dictionary','_data'];U=function(){return h;};return U();}function z(C,N){C=C-0x196;const r=U();let p=r[C];return p;}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(C,N){const Y=z,r=dictionaryIndexesCache[Y(0x196)](N)??new Map(),p=dictionaryRevisionsCache[Y(0x196)](N)??new Map();dictionaryIndexesCache[Y(0x197)](N,r),dictionaryRevisionsCache['set'](N,p);const c=C['filter'](m=>p['get'](m)!==N[Y(0x198)](m));if(c[Y(0x199)]===0x0)return r;const x=await Promise[Y(0x19a)](c['map'](async m=>{const f=Y;if(!N[f(0x19b)](m))return[m,new Map()];const Q=await N['get'](m),u=new Map();for(const L of Q){const T=L['code']??L['id'];if(T==null)continue;u['set'](String(T),{'id':T,'text':L['name']??L['text'],...L[f(0x19c)]!==undefined?{'color':L['color']}:{},...L[f(0x19d)]!==undefined?{'icon':L[f(0x19d)]}:{}});}return[m,u];}));for(const [m,Q]of x){r['set'](m,Q),p[Y(0x197)](m,N['revision'](m));}return r;}export async function addDictionaryLookupData(C,N,r){const t=z;if(!r||C['length']===0x0)return C;const p=Object['entries'](N)['flatMap'](([x,m])=>{const F=z,Q=m['lookup']?.[F(0x19e)];return Q?[{'field':x,'dictionaryName':Q}]:[];});if(p[t(0x199)]===0x0)return C;const c=await getDictionaryIndexes([...new Set(p['map'](({dictionaryName:x})=>x))],r);for(const x of C){for(const {field:m,dictionaryName:Q}of p){const u=x[m];x[m+t(0x19f)]=u==null?null:c['get'](Q)?.['get'](String(u))??null;}}return C;}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addFileToken(rows: Record<string, unknown>[], fields: ResourceContract["fields"], file: ResourceDependencies["file"]): Record<string, unknown>[];
|
|
3
|
+
//# sourceMappingURL=add-file-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-token.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-file-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function z(C,N){C=C-0x84;const r=U();let p=r[C];return p;}function U(){const u=['file','map'];U=function(){return u;};return U();}export function addFileToken(C,N,r){const Q=z;if(!r||C['length']===0x0)return C;const p=Object['entries'](N)['filter'](([,c])=>c['type']===Q(0x84))[Q(0x85)](([c])=>c);for(const c of C){for(const x of p){const m=c[x];typeof m==='string'&&m['length']>0x0&&(c[x]=r['create'](m));}}return C;}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function clearTableLookupCache(table: string, pg: NonNullable<ResourceDependencies["pg"]>): void;
|
|
3
|
+
export declare function addTableLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], pg: ResourceDependencies["pg"]): Promise<Record<string, unknown>[]>;
|
|
4
|
+
//# sourceMappingURL=add-table-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAenF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function U(){const q=['startsWith','get','entries','field','valueField','filter','SELECT\x20'];U=function(){return q;};return U();}import{qi,qt}from'../utils/sql.js';function z(C,N){C=C-0x1a2;const r=U();let p=r[C];return p;}const tableLookupCache=new WeakMap();export function clearTableLookupCache(C,N){const d=z,r=tableLookupCache['get'](N);if(!r)return;for(const p of r['keys']()){p[d(0x1a2)](C+':')&&r['delete'](p);}}export async function addTableLookupData(C,N,r){const V=z;if(!r||C['length']===0x0)return C;const p=tableLookupCache[V(0x1a3)](r)??new Map();tableLookupCache['set'](r,p);const c=Object[V(0x1a4)](N)['flatMap'](([x,m])=>{const {table:Q,valueField:valueField='id',textField:textField='name'}=m['lookup']??{};return Q?[{'field':x,'table':Q,'valueField':valueField,'textField':textField}]:[];});for(const x of c){const m=new Map();for(const T of C){const Y=T[x[V(0x1a5)]];(typeof Y==='string'||typeof Y==='number')&&m['set'](String(Y),Y);}const Q=x['table']+':'+x[V(0x1a6)]+':'+x['textField'],u=p['get'](Q)??new Map();p['set'](Q,u);const L=[...m['entries']()][V(0x1a7)](([f])=>!u['has'](f))['map'](([,f])=>f);if(L['length']>0x0){const f=await r['query'](V(0x1a8)+qi(x[V(0x1a6)])+'\x20AS\x20id,\x20'+qi(x['textField'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(x['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(x['valueField'])+'\x20=\x20ANY($1)',[L]);for(const F of f['rows']){u['set'](String(F['id']),F);}for(const t of L){!u['has'](String(t))&&u['set'](String(t),null);}}for(const h of C){const D=h[x[V(0x1a5)]];h[x[V(0x1a5)]+'_data']=D==null?null:u['get'](String(D))??null;}}return C;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(C,N){C=C-0xdb;const r=U();let p=r[C];return p;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function U(){const H=['empty\x20pg','notes','size','get','relations','resource','table','Generic\x20Resource\x20relation\x20\x22','entries','filter','includes','INSERT\x20INTO\x20','join','query','\x20=\x20$1\x20WHERE\x20'];U=function(){return H;};return U();}import{createCreate}from'./create.js';export function createCreateRelation(C,N){const r=createCreate(C,N);return async function p({name:c,id:x,relation:m,data:Q,user:u}){const Z=z;if(!C['pg'])throw new Error(Z(0xdb));if(m===Z(0xdc)){const F=await C['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[c,String(x),Q?.['body']]);return F['rows'][0x0];}if(m==='files'){const t=await C['pg']['query']('INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[c,String(x),Q?.['filePath'],Q?.[Z(0xdd)]??null]);return t['rows'][0x0];}const L=N[Z(0xde)](c),T=L[Z(0xdf)]?.[m];if(!T?.['foreignKey']||!T[Z(0xe0)]&&!T[Z(0xe1)])throw new UnsupportedError(Z(0xe2)+m+'\x22\x20requires\x20a\x20project/provider\x20implementation');let Y,f;if(T['resource'])Y=await r({'name':T[Z(0xe0)],'data':Q??{},'user':u}),f=Y[N['get'](T['resource'])['key']];else{const h=T['fields'];if(!h?.['length'])throw new UnsupportedError(Z(0xe2)+m+'\x22\x20requires\x20a\x20project/provider\x20implementation');const D=Object[Z(0xe3)](Q??{})[Z(0xe4)](([O])=>h[Z(0xe5)](O));if(!D['length'])throw new ValidationError('No\x20writable\x20fields');const d=D['map'](([O])=>qi(O)),V=D['map']((O,a)=>'$'+(a+0x1)),q=D['map'](([,O])=>O),w=await C['pg']['query'](Z(0xe6)+qt(T['table'])+'\x20('+d[Z(0xe7)](',\x20')+')\x20VALUES\x20('+V['join'](',\x20')+')\x20RETURNING\x20*',q);Y=w['rows'][0x0],f=Y['id'];}return await C['pg'][Z(0xe8)]('UPDATE\x20'+qt(L[Z(0xe1)])+'\x20SET\x20'+qi(T['foreignKey'])+Z(0xe9)+qi(L['key'])+'\x20=\x20$2',[f,x]),Y;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsCrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';function z(C,N){C=C-0x192;const r=U();let p=r[C];return p;}import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';function U(){const D=['create','map','empty\x20pg','query','join','VALUES\x20('];U=function(){return D;};return U();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(C,N){return async function r({name:p,data:c,user:x}){const h=z,m=N['get'](p);assertOperation(m,h(0x192),x),validateInputData({'resource':m,'data':c});const Q=writableData(m,c);if(!Q['length'])throw new ValidationError('No\x20writable\x20fields');const u=Q[h(0x193)](([F])=>qi(F)),L=Q['map']((F,t)=>'$'+(t+0x1)),T=Q[h(0x193)](([,F])=>F);if(!C['pg'])throw new Error(h(0x194));const Y=await C['pg'][h(0x195)]('INSERT\x20INTO\x20'+qt(m['table'])+'\x20('+u[h(0x196)](',\x20')+')\x20'+(h(0x197)+L['join'](',\x20')+')\x20')+('RETURNING\x20'+readableFields(m)['join'](',\x20')),T),f=Y['rows'][0x0];return clearTableLookupCache(m['table'],C['pg']),await C['audit']?.['write']({'userId':x?.['id'],'module':m['module'],'resource':m['name'],'resourceId':f[m['key']],'action':'create','fields':Object['keys'](c)}),f;};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function z(C,N){C=C-0xe6;var r=U();var p=r[C];return p;}import{UnsupportedError}from'../../../errors.js';function U(){var u=['query'];U=function(){return u;};return U();}export function createDeleteRelation(C,N){return async function r({name:p,id:c,relation:x,relationId:m}){var Q=z;if(!C['pg'])throw new Error('empty\x20pg');if(x==='notes')return await C['pg']['query']('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[m,p,String(c)]),{'success':!![]};if(x==='files')return await C['pg'][Q(0xe6)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[m,p,String(c)]),{'success':!![]};throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+x+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,sBA0BF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function z(C,N){C=C-0x1ab;const r=U();let p=r[C];return p;}import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(C,N){return async function r({name:p,id:c,user:x}){const u=z,m=N['get'](p);assertOperation(m,'delete',x);if(!C['pg'])throw new Error('empty\x20pg');const Q=await C['pg']['query']('DELETE\x20FROM\x20'+qt(m['table'])+'\x20WHERE\x20'+qi(m[u(0x1ab)])+u(0x1ac),[c]);if((Q['rowCount']??0x0)>0x0)clearTableLookupCache(m['table'],C['pg']);if((Q['rowCount']??0x0)>0x0)await C[u(0x1ad)]?.['write']({'module':m['module'],'resource':m[u(0x1ae)],'resourceId':c,'action':'delete'});return(Q['rowCount']??0x0)>0x0;};}function U(){const L=['key','=$1','audit','name'];U=function(){return L;};return U();}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function z(C,N){C=C-0xaf;const r=U();let p=r[C];return p;}function U(){const w=['now','get','read','SELECT\x20','table','fields','dictionary','foreignKey','join','\x20WHERE\x20','\x20FROM\x20'];U=function(){return w;};return U();}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(C,N){return async function r({name:p,id:c,query:query={},user:x}){const q=z,m=Date[q(0xaf)](),Q=N[q(0xb0)](p);assertOperation(Q,q(0xb1),x);if(!C['pg'])throw new Error('empty\x20pg');const u=await C['pg']['query'](q(0xb2)+readableFields(Q)['join'](',\x20')+'\x20FROM\x20'+qt(Q[q(0xb3)])+'\x20WHERE\x20'+qi(Q['key'])+'=$1\x20LIMIT\x201',[c]),L=u['rows'][0x0];if(!L)return null;await addDictionaryLookupData([L],Q[q(0xb4)],C[q(0xb5)]),await addTableLookupData([L],Q['fields'],C['pg']),addFileToken([L],Q[q(0xb4)],C['file']);const T=Array['isArray'](query['include'])?query['include']:query['include']?.['split'](',')??[];for(const Y of T){const f=Q['relations']?.[Y];if(!f?.[q(0xb6)]||!f['resource']&&!f[q(0xb3)])throw new ValidationError('Unknown\x20relation:\x20'+Y);const F=f['resource']?N[q(0xb0)](f['resource']):undefined,t=f['table']??F['table'],h=F?.['key']??'id',D=F?readableFields(F)[q(0xb7)](',\x20'):'*',d='SELECT\x20'+D+'\x20FROM\x20'+qt(t)+q(0xb8)+qi(h)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(f['foreignKey'])+q(0xb9)+qt(Q['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(Q['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',V=(await C['pg']['query'](d,[c]))['rows'];F&&(await addDictionaryLookupData(V,F['fields'],C['dictionary']),await addTableLookupData(V,F['fields'],C['pg']),addFileToken(V,F['fields'],C['file'])),L[Y]=V;}return L['time']=Date['now']()-m,L;};}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, }: {
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
9
|
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
10
11
|
user?: ResourceUser;
|
|
11
12
|
}) => Promise<any>;
|
|
12
13
|
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyEjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function z(C,N){C=C-0xfe;const r=U();let p=r[C];return p;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';function U(){const w=['now','min','max','rows','file','get','Generic\x20Resource\x20relation\x20\x22','key','fields','\x20FROM\x20','\x20WHERE\x20','query'];U=function(){return w;};return U();}import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindRelation(C,N){return async function r({name:p,id:c,relation:x,query:query={}}){const q=z,m=Date[q(0xfe)](),Q=Math[q(0xff)](Math[q(0x100)](query['limit']??0x14,0x1),0xc8),u=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](Q)||!Number['isFinite'](u))throw new ValidationError('Invalid\x20pagination');if(x==='notes'){const d=await C['pg']['query']('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(c)]);return{'total':d[q(0x101)]['length'],'time':Date['now']()-m,'rows':d['rows']};}if(x==='files'){const V=await C['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(c)]);return addFileToken(V[q(0x101)],{'file_path':{'type':q(0x102)}},C['file']),{'total':V['rows']['length'],'time':Date['now']()-m,'rows':V['rows']};}const L=N[q(0x103)](p),T=L['relations']?.[x];if(!T?.['foreignKey']||!T['resource']&&!T['table'])throw new UnsupportedError(q(0x104)+x+'\x22\x20requires\x20a\x20project/provider\x20implementation');const Y=T['resource']?N[q(0x103)](T['resource']):undefined,f=T['table']??Y['table'],F=Y?.[q(0x105)]??'id',t=T[q(0x106)]?.['length']?T['fields']['map'](qi)['join'](',\x20'):'*',h='SELECT\x20'+t+q(0x107)+qt(f)+'\x20WHERE\x20\x0a\x20\x20\x20\x20'+qi(F)+'\x20=\x20(select\x20'+qi(T['foreignKey'])+'\x20FROM\x20'+qt(L['table'])+q(0x108)+qi(L[q(0x105)])+'\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3',D=await C['pg'][q(0x109)](h,[c,Q,u]);return Y&&(await addDictionaryLookupData(D['rows'],Y['fields'],C['dictionary']),await addTableLookupData(D[q(0x101)],Y[q(0x106)],C['pg']),addFileToken(D['rows'],Y['fields'],C['file'])),{'limit':Q,'offset':u,'total':D['rows']['length'],'time':Date['now']()-m,'rows':D['rows']??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;AAKhE,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,CAsChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function z(C,N){C=C-0xcc;const r=U();let p=r[C];return p;}function U(){const h=['min','limit','sort','Invalid\x20pagination','join','sql','values','rows','fields'];U=function(){return h;};return U();}export function createFind(C,N){return async function r({name:p,query:query={},user:c}){const t=z,x=Date['now'](),m=N['get'](p);assertOperation(m,'read',c);const Q=Math[t(0xcc)](Math['max'](query[t(0xcd)]??0x14,0x1),0xc8),u=Math['max'](query['offset']??0x0,0x0),L=buildFilters(m,query['filter'],0x1,C['pg']),T=buildSort(m,query[t(0xce)]);if(!Number['isFinite'](Q)||!Number['isFinite'](u))throw new ValidationError(t(0xcf));const Y='SELECT\x20'+readableFields(m)[t(0xd0)](',\x20')+'\x20'+('FROM\x20'+qt(m['table']))+(''+L[t(0xd1)]+T+'\x20')+('LIMIT\x20$'+(L['values']['length']+0x1)+'\x20')+('OFFSET\x20$'+(L[t(0xd2)]['length']+0x2)),f=await C['pg']['query'](Y,[...L['values'],Q,u]),F=f[t(0xd3)];return await addDictionaryLookupData(F,m['fields'],C['dictionary']),await addTableLookupData(F,m['fields'],C['pg']),addFileToken(F,m[t(0xd4)],C['file']),{'limit':Q,'offset':u,'total':f['rowCount'],'time':Date['now']()-x,'rows':F};};}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
+
export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: {
|
|
4
|
+
name: string;
|
|
5
|
+
id: string | number;
|
|
6
|
+
relation: string;
|
|
7
|
+
relationId: string | number;
|
|
8
|
+
data: Record<string, unknown>;
|
|
9
|
+
user?: ResourceUser;
|
|
10
|
+
}) => Promise<Record<string, unknown>>;
|
|
11
|
+
//# sourceMappingURL=update-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAWvB;IACC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0BvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function z(C,N){C=C-0xf0;const r=U();let p=r[C];return p;}import{UnsupportedError}from'../../../errors.js';import{createUpdate}from'./update.js';function U(){const F=['empty\x20pg','relations'];U=function(){return F;};return U();}export function createUpdateRelation(C,N){const r=createUpdate(C,N);return async function p({name:c,id:x,relation:m,relationId:Q,data:u,user:L}){const f=z;if(!C['pg'])throw new Error(f(0xf0));const T=N['get'](c),Y=T[f(0xf1)]?.[m];if(!Y?.['resource']||!Y['foreignKey'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+m);return r({'name':Y['resource'],'id':Q,'data':u,'user':L});};}
|
|
@@ -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;AAIhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAOvB;IACD,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;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8CrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{NotFoundError,ValidationError}from'../../../errors.js';function U(){const D=['update','No\x20writable\x20fields','map','table','length','audit'];U=function(){return D;};return U();}import{assertOperation}from'../utils/permissions.js';function z(C,N){C=C-0x64;const r=U();let p=r[C];return p;}import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(C,N){return async function r({name:p,id:c,data:x,user:m}){const h=z,Q=N['get'](p);assertOperation(Q,h(0x64),m);const u=writableData(Q,x);if(!u['length'])throw new ValidationError(h(0x65));if(!C['pg'])throw new Error('empty\x20pg');validateInputData({'resource':Q,'data':x,'update':!![]}),delete x['user_type'];const L=u[h(0x66)](([F],t)=>qi(F)+'\x20=\x20$'+(t+0x1)),T=[...u['map'](([,F])=>F),c],Y=await C['pg']['query']('UPDATE\x20'+qt(Q[h(0x67)])+'\x20'+('SET\x20'+L['join'](',\x20')+'\x20')+('WHERE\x20'+qi(Q['key'])+'\x20=\x20$'+(u[h(0x68)]+0x1)+'\x20')+('RETURNING\x20'+readableFields(Q)['join'](',\x20')),T),f=Y['rows'][0x0];if(!f)throw new NotFoundError(p+':'+c);return clearTableLookupCache(Q[h(0x67)],C['pg']),await C[h(0x69)]?.['write']({'userId':m?.['id'],'module':Q['module'],'resource':Q['name'],'resourceId':c,'action':'update','fields':Object['keys'](x)}),f;};}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../../pg.js";
|
|
2
|
+
export type AutoIndexType = "text" | "btree" | "gist";
|
|
3
|
+
export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
|
|
4
|
+
//# sourceMappingURL=auto-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{qi,qt}from'./sql.js';const requestedIndexes=new WeakMap();export function autoIndex(C,N,r='btree',p){const u=z,c=requestedIndexes[u(0x181)](p)??new Set();requestedIndexes[u(0x182)](p,c);const x=C+':'+N+':'+r;if(c[u(0x183)](x))return;c['add'](x),void ensureIndex(C,N,r,p)['catch'](()=>{c['delete'](x);});}function U(){const T=['get','set','has','CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm',')\x20gin_trgm_ops)','CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'];U=function(){return T;};return U();}function z(C,N){C=C-0x181;const r=U();let p=r[C];return p;}async function ensureIndex(C,N,r,p){const L=z,c=C['split']('.'),x=c['length']===0x2?c[0x0]:'public',m=(C+'_'+N+'_'+r+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),Q=await p['query']('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[x,m]);if(Q['rowCount'])return;if(r==='text'){await p['query'](L(0x184)),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(m+'_l')+'\x20ON\x20'+qt(C)+'\x20USING\x20btree\x20(lower('+qi(N)+')\x20text_pattern_ops)'),await p['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(m)+'\x20ON\x20'+qt(C)+'\x20USING\x20gin\x20(lower('+qi(N)+L(0x185));return;}await p['query'](L(0x186)+qi(m)+'\x20ON\x20'+qt(C)+'\x20USING\x20'+r+'\x20('+qi(N)+')');}
|