@opengis/fcore 0.0.1-beta.8 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +71 -17
- 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.d.ts.map +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/20260907090000_core_schema.sql +32 -2
- 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IACjE,UAAU,CAAC,IAAI,EAAE,MAAM,QAEtB;IACD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,SAAS,UAAQ,QAUvE;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,WAEf;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,oBAIf;IAED,IAAI,uBAEH;IAED,OAAO,CAAC,QAAQ;CAajB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function C(P,G){P=P-0x10f;const j=m();let Z=j[P];return Z;}function validQualified(P){const Z=C;return P[Z(0x10f)]('.')['length']<=0x2&&P['split']('.')['every'](G=>ident['test'](G));}export class ResourceRegistry{['resources']=new Map();['unregister'](P){const q=C;this[q(0x110)]['delete'](P);}['register'](P,G=![]){const p=C;for(const j of Array['isArray'](P)?P:[P]){this[p(0x111)](j);if(this['resources'][p(0x112)](j['name'])&&!G)throw new ConflictError('Resource\x20already\x20registered:\x20'+j[p(0x113)]);this['resources'][p(0x114)](j[p(0x113)],j);}}['has'](P){return this['resources']['has'](P);}['get'](P){const G=this['resources']['get'](P);if(!G)throw new NotFoundError('Resource\x20not\x20registered:\x20'+P);return G;}['list'](){return[...this['resources']['values']()];}['validate'](P){const X=C;if(P['version']!==0x1||!ident[X(0x115)](P[X(0x113)])||!validQualified(P['table'])||!ident['test'](P[X(0x116)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+P[X(0x113)]);for(const [G,j]of Object[X(0x117)](P[X(0x118)])){if(!ident['test'](G)||!ident['test'](j['column']??G))throw new ValidationError(X(0x119)+G);}}}function m(){const F=['split','resources','validate','has','name','set','test','key','entries','fields','Invalid\x20resource\x20field:\x20'];m=function(){return F;};return m();}
|
|
@@ -7,7 +7,29 @@ import type { AuditPlugin } from "../audit/index.js";
|
|
|
7
7
|
import type { DictionaryPlugin } from "../dictionary.js";
|
|
8
8
|
import type { FileAdapter } from "../file.js";
|
|
9
9
|
import { User } from "../../context.js";
|
|
10
|
+
import type { AppContext } from "../../context.js";
|
|
11
|
+
export type ResourceAggregate = "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
|
|
12
|
+
export type ResourceSummaryItem = {
|
|
13
|
+
aggregate: "count";
|
|
14
|
+
where?: string;
|
|
15
|
+
} | {
|
|
16
|
+
aggregate: "countDistinct" | "sum" | "avg" | "min" | "max";
|
|
17
|
+
field: string;
|
|
18
|
+
where?: string;
|
|
19
|
+
} | {
|
|
20
|
+
sql: string;
|
|
21
|
+
};
|
|
22
|
+
interface ResourceScope {
|
|
23
|
+
where?: string;
|
|
24
|
+
fields?: string[];
|
|
25
|
+
sort?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
}
|
|
10
28
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
29
|
+
export interface ResourceJoinContract {
|
|
30
|
+
scope?: "all" | "item";
|
|
31
|
+
sql: string;
|
|
32
|
+
}
|
|
11
33
|
export interface ResourceFieldContract {
|
|
12
34
|
column?: string;
|
|
13
35
|
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
@@ -16,18 +38,19 @@ export interface ResourceFieldContract {
|
|
|
16
38
|
readable?: boolean;
|
|
17
39
|
writable?: boolean;
|
|
18
40
|
required?: boolean;
|
|
41
|
+
code_template?: string;
|
|
19
42
|
nullable?: boolean;
|
|
20
43
|
filterable?: boolean;
|
|
21
44
|
searchable?: boolean;
|
|
22
45
|
sortable?: boolean;
|
|
23
46
|
filter?: boolean;
|
|
24
|
-
|
|
25
|
-
|
|
47
|
+
scope?: "all" | "item";
|
|
48
|
+
dictionary?: string;
|
|
26
49
|
lookup?: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
50
|
+
table: string;
|
|
51
|
+
value: string;
|
|
52
|
+
text: string;
|
|
53
|
+
fields?: string[];
|
|
31
54
|
};
|
|
32
55
|
enum?: string[] | number[];
|
|
33
56
|
minLength?: number;
|
|
@@ -36,42 +59,71 @@ export interface ResourceFieldContract {
|
|
|
36
59
|
maximum?: number;
|
|
37
60
|
pattern?: string;
|
|
38
61
|
}
|
|
62
|
+
export type ResourceRelationType = 'one' | 'many';
|
|
39
63
|
export interface ResourceRelationContract {
|
|
64
|
+
type?: ResourceRelationType;
|
|
40
65
|
resource?: string;
|
|
41
66
|
table?: string;
|
|
42
|
-
|
|
67
|
+
where?: string;
|
|
68
|
+
localKey?: string;
|
|
43
69
|
foreignKey?: string;
|
|
44
|
-
|
|
45
|
-
type?: "one" | "many";
|
|
70
|
+
targetKey?: string;
|
|
46
71
|
fields?: string[];
|
|
72
|
+
junctionTable?: string;
|
|
73
|
+
junctionLocalKey?: string;
|
|
74
|
+
junctionForeignKey?: string;
|
|
75
|
+
junctionTargetKey?: string;
|
|
47
76
|
}
|
|
48
77
|
export interface ResourceContract {
|
|
49
78
|
version: 1;
|
|
50
79
|
name: string;
|
|
51
|
-
module
|
|
80
|
+
module?: string;
|
|
52
81
|
title?: string;
|
|
53
82
|
table: string;
|
|
83
|
+
where?: string;
|
|
54
84
|
key: string;
|
|
85
|
+
display?: string[] | string;
|
|
55
86
|
operations: ResourceOperation[];
|
|
87
|
+
searchable?: string[];
|
|
56
88
|
capabilities?: string[];
|
|
57
89
|
permission?: string;
|
|
58
90
|
fields: Record<string, ResourceFieldContract>;
|
|
59
91
|
relations?: Record<string, ResourceRelationContract>;
|
|
92
|
+
joins?: ResourceJoinContract[];
|
|
60
93
|
access?: "public" | "user" | "admin";
|
|
94
|
+
summary?: Record<string, ResourceSummaryItem>;
|
|
95
|
+
scopes?: Record<string, string | ResourceScope>;
|
|
96
|
+
}
|
|
97
|
+
export interface ResourceVariableDto {
|
|
98
|
+
key: string;
|
|
99
|
+
path: string;
|
|
100
|
+
title?: string;
|
|
101
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
102
|
+
resource?: string;
|
|
103
|
+
variables?: ResourceVariableDto[];
|
|
104
|
+
}
|
|
105
|
+
export interface ResourceSchemaDto {
|
|
106
|
+
resource: string;
|
|
107
|
+
title?: string;
|
|
108
|
+
variables: ResourceVariableDto[];
|
|
61
109
|
}
|
|
62
110
|
export interface ResourceQuery {
|
|
63
111
|
filter?: Record<string, unknown>;
|
|
64
112
|
include?: string | string[];
|
|
65
113
|
sort?: string[];
|
|
66
114
|
search?: string;
|
|
115
|
+
scope?: string;
|
|
67
116
|
limit?: number;
|
|
68
117
|
offset?: number;
|
|
69
118
|
fields?: string[];
|
|
70
119
|
}
|
|
71
120
|
export interface ResourceListResult<T = Record<string, unknown>> {
|
|
72
121
|
rows: T[];
|
|
122
|
+
summary: Record<string, unknown>;
|
|
73
123
|
limit: number;
|
|
74
124
|
time: number;
|
|
125
|
+
fields?: Record<string, ResourceFieldContract>;
|
|
126
|
+
count: number | null;
|
|
75
127
|
total: number | null;
|
|
76
128
|
offset: number;
|
|
77
129
|
}
|
|
@@ -84,7 +136,8 @@ export interface ResourceDependencies {
|
|
|
84
136
|
file?: FileAdapter;
|
|
85
137
|
}
|
|
86
138
|
export interface ResourcePlugin {
|
|
87
|
-
register(input: ResourceContract | ResourceContract[]): void;
|
|
139
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
140
|
+
unregister(name: string): void;
|
|
88
141
|
has(name: string): boolean;
|
|
89
142
|
get(name: string): ResourceContract;
|
|
90
143
|
list(): ResourceContract[];
|
|
@@ -103,18 +156,18 @@ export interface ResourcePlugin {
|
|
|
103
156
|
name: string;
|
|
104
157
|
data: Record<string, unknown>;
|
|
105
158
|
user?: ResourceUser;
|
|
106
|
-
}): Promise<Record<string, unknown>>;
|
|
159
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
107
160
|
update(params: {
|
|
108
161
|
name: string;
|
|
109
162
|
id: string | number;
|
|
110
163
|
data: Record<string, unknown>;
|
|
111
164
|
user?: ResourceUser;
|
|
112
|
-
}): Promise<Record<string, unknown>>;
|
|
165
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
113
166
|
delete(params: {
|
|
114
167
|
name: string;
|
|
115
168
|
id: string | number;
|
|
116
169
|
user?: ResourceUser;
|
|
117
|
-
}): Promise<boolean>;
|
|
170
|
+
}, ctx?: AppContext): Promise<boolean>;
|
|
118
171
|
findRelation(params: {
|
|
119
172
|
name: string;
|
|
120
173
|
id: string | number;
|
|
@@ -128,7 +181,7 @@ export interface ResourcePlugin {
|
|
|
128
181
|
relation: string;
|
|
129
182
|
data?: Record<string, unknown>;
|
|
130
183
|
user?: ResourceUser;
|
|
131
|
-
}): Promise<any>;
|
|
184
|
+
}, ctx?: AppContext): Promise<any>;
|
|
132
185
|
updateRelation(params: {
|
|
133
186
|
name: string;
|
|
134
187
|
id: string | number;
|
|
@@ -136,15 +189,16 @@ export interface ResourcePlugin {
|
|
|
136
189
|
relationId: string;
|
|
137
190
|
data: Record<string, unknown>;
|
|
138
191
|
user?: ResourceUser;
|
|
139
|
-
}): Promise<Record<string, unknown>>;
|
|
192
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
140
193
|
deleteRelation(params: {
|
|
141
194
|
name: string;
|
|
142
195
|
id: string | number;
|
|
143
196
|
relation: string;
|
|
144
197
|
relationId: string;
|
|
145
198
|
user?: ResourceUser;
|
|
146
|
-
}): Promise<{
|
|
199
|
+
}, ctx?: AppContext): Promise<{
|
|
147
200
|
success: boolean;
|
|
148
201
|
}>;
|
|
149
202
|
}
|
|
203
|
+
export {};
|
|
150
204
|
//# sourceMappingURL=resource.types.d.ts.map
|
|
@@ -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;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
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;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,eAAe,GACf,KAAK,G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EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAClC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const i=['filter','get','revision','set','text','color','icon','length','flatMap','dictionary','map'];m=function(){return i;};return m();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(P,G){const E=C,j=dictionaryIndexesCache['get'](G)??new Map(),Z=dictionaryRevisionsCache['get'](G)??new Map();dictionaryIndexesCache['set'](G,j),dictionaryRevisionsCache['set'](G,Z);const q=P[E(0x1f3)](X=>Z[E(0x1f4)](X)!==G[E(0x1f5)](X));if(q['length']===0x0)return j;const p=await Promise['all'](q['map'](async X=>{const z=E;if(!G['has'](X))return[X,new Map()];const F=await G['get'](X),A=new Map();for(const H of F){const b=H['code']??H['id'];if(b==null)continue;A[z(0x1f6)](String(b),{'id':b,'text':H['name']??H[z(0x1f7)],...H['color']!==undefined?{'color':H[z(0x1f8)]}:{},...H[z(0x1f9)]!==undefined?{'icon':H['icon']}:{}});}return[X,A];}));for(const [X,F]of p){j['set'](X,F),Z[E(0x1f6)](X,G['revision'](X));}return j;}function C(P,G){P=P-0x1f3;const j=m();let Z=j[P];return Z;}export async function addDictionaryLookupData(P,G,j){const x=C;if(!j||P[x(0x1fa)]===0x0)return P;const Z=Object['entries'](G)[x(0x1fb)](([p,X])=>{const o=x,F=X[o(0x1fc)];return F?[{'field':p,'dictionaryName':F}]:[];});if(Z['length']===0x0)return P;const q=await getDictionaryIndexes([...new Set(Z[x(0x1fd)](({dictionaryName:p})=>p))],j);for(const p of P){for(const {field:X,dictionaryName:F}of Z){const A=p[X];p[X+'_data']=A==null?null:q['get'](F)?.[x(0x1f4)](String(A))??null;}}return P;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function A(
|
|
1
|
+
function m(){const A=['file','string'];m=function(){return A;};return m();}function C(P,G){P=P-0x155;const j=m();let Z=j[P];return Z;}export function addFileToken(P,G,j){const F=C;if(!j||P['length']===0x0)return P;const Z=Object['entries'](G)['filter'](([,q])=>q['type']===F(0x155))['map'](([q])=>q);for(const q of P){for(const p of Z){const X=q[p];typeof X===F(0x156)&&X['length']>0x0&&(q[p]=j['create'](X));}}return P;}
|
|
@@ -1 +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;
|
|
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;AAQnF,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{qi,qt}from'../utils/sql.js';
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();function C(P,G){P=P-0xd7;const j=m();let Z=j[P];return Z;}export function clearTableLookupCache(P,G){const T=C,j=tableLookupCache['get'](G);if(!j)return;for(const Z of j['keys']()){Z[T(0xd7)](P+':')&&j['delete'](Z);}}export async function addTableLookupData(P,G,j){const D=C;if(!j||P['length']===0x0)return P;const Z=tableLookupCache[D(0xd8)](j)??new Map();tableLookupCache[D(0xd9)](j,Z);const q=Object['entries'](G)['flatMap'](([p,X])=>{const h=D,{table:F,value:value='id',text:text=h(0xda)}=X[h(0xdb)]??{};return F?[{'field':p,'table':F,'value':value,'text':text}]:[];});for(const p of q){const X=new Map();for(const b of P){const E=b[p['field']];(typeof E===D(0xdc)||typeof E==='number')&&X[D(0xd9)](String(E),E);}const F=p['table']+':'+p['value']+':'+p[D(0xdd)],A=Z[D(0xd8)](F)??new Map();Z[D(0xd9)](F,A);const H=[...X[D(0xde)]()]['filter'](([z])=>!A['has'](z))['map'](([,z])=>z);if(H['length']>0x0){const z=await j['query']('SELECT\x20'+qi(p[D(0xdf)])+'\x20AS\x20id,\x20'+qi(p['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(p[D(0xe0)])+D(0xe1)+qi(p['value'])+D(0xe2),[H]);for(const x of z['rows']){A[D(0xd9)](String(x['id']),x);}for(const o of H){!A['has'](String(o))&&A[D(0xd9)](String(o),null);}}for(const i of P){const y=i[p['field']];i[p['field']+D(0xe3)]=y==null?null:A['get'](String(y))??null;}}return P;}function m(){const L=['startsWith','get','set','name','lookup','string','text','entries','value','table','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','\x20=\x20ANY($1)','_data'];m=function(){return L;};return m();}
|
|
@@ -3,11 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type CreateRelationParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
relation: string;
|
|
10
11
|
data?: Record<string, unknown>;
|
|
11
12
|
user?: ResourceUser;
|
|
12
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
|
|
15
|
+
export {};
|
|
13
16
|
//# sourceMappingURL=create-relation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,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-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,wCAKY,oBAAoB,QAClD,UAAU,KACf,OAAO,CAAC,GAAG,CAAC,CAyFhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const D=['files','includes','\x22\x20requires\x20a\x20capabilities\x20\x22','query','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','filePath','rows','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','Relation\x20update\x20is\x20not\x20configured:\x20','resource'];m=function(){return D;};return m();}import{UnsupportedError}from'../../../errors.js';function C(P,G){P=P-0xf5;const j=m();let Z=j[P];return Z;}import{createCreate}from'./create.js';export function createCreateRelation(P,G){const j=createCreate(P,G);return async function Z({name:q,id:p,relation:X,data:F,user:A},H){const T=C,b=H?.['pg']??P['pg'],E=G['get'](q);if(['notes',T(0xf5),'gallery']['includes'](X)&&!E['capabilities']?.[T(0xf6)](X))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+X+T(0xf7)+X+'\x22');if(X==='notes'){const o=await b[T(0xf8)](T(0xf9),[q,String(p),F?.['body']]);return o['rows'][0x0];}if(X==='files'){const i=await b['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*',[q,String(p),F?.[T(0xfa)],F?.['size']??null]);return i['rows'][0x0];}if(X==='gallery'){const y=await b[T(0xf8)]('INSERT\x20INTO\x20admin.gallery\x20(resource,\x20resource_id,\x20file_path,\x20size,\x20mime_type)\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*',[q,String(p),F?.['filePath'],F?.['size']??null,F?.['mimeType']??'image/jpeg']);return y[T(0xfb)][0x0];}const z=E['relations']?.[X];if(!z?.['foreignKey']||!z['resource']&&!z['table'])throw new UnsupportedError(T(0xfc)+X+T(0xfd));if(!F)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+F);if(!z['resource'])throw new UnsupportedError(T(0xfe)+X);F[z['foreignKey']]=p;const x=await j({'name':z[T(0xff)],'data':F??{},'user':A});return x;};}
|
|
@@ -1,8 +1,11 @@
|
|
|
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 CreateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
data: Record<string, unknown>;
|
|
6
7
|
user?: ResourceUser;
|
|
7
|
-
}
|
|
8
|
+
};
|
|
9
|
+
export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: CreateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
10
|
+
export {};
|
|
8
11
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -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;AAKhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAE0B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4CtH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function m(){const D=['created_at','push','created_by','length','query','join','rows','table','audit','module','keys'];m=function(){return D;};return m();}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function C(P,G){P=P-0x1e0;const j=m();let Z=j[P];return Z;}export function createCreate(P,G){return async function j({name:Z,data:q,user:p},X){const T=C,F=G['get'](Z);assertOperation(F,'create',p),validateInputData({'resource':F,'data':q});const A=writableData(F,q);F['fields']['created_at']&&A['push']([T(0x1e0),new Date()]);F['fields']['created_by']&&A[T(0x1e1)]([T(0x1e2),p?.['id']]);if(!A[T(0x1e3)])throw new ValidationError('No\x20writable\x20fields');const H=A['map'](([i])=>qi(i)),b=A['map']((i,y)=>'$'+(y+0x1)),E=A['map'](([,i])=>i),z=X?.['pg']??P['pg'],x=await z[T(0x1e4)]('INSERT\x20INTO\x20'+qt(F['table'])+'\x20('+H['join'](',\x20')+')\x20'+('VALUES\x20('+b[T(0x1e5)](',\x20')+')\x20')+'RETURNING\x20*',E),o=x[T(0x1e6)][0x0];return clearTableLookupCache(F[T(0x1e7)],z),await(X?.[T(0x1e8)]??P['audit'])?.['write']({'userId':p?.['id'],'module':F[T(0x1e9)],'resource':F['name'],'resourceId':o[F['key']],'action':'create','fields':Object[T(0x1ea)](q)}),o;};}
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
relation: string;
|
|
10
|
-
relationId: string;
|
|
11
|
+
relationId: string | number;
|
|
11
12
|
user?: ResourceUser;
|
|
12
|
-
}
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
13
15
|
success: boolean;
|
|
14
16
|
}>;
|
|
17
|
+
export {};
|
|
15
18
|
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,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,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,8CAKkB,oBAAoB,QACxD,UAAU,KACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAuDjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function m(){const i=['get','notes','includes','query','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','foreignKey','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','resource'];m=function(){return i;};return m();}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function C(P,G){P=P-0x1b1;const j=m();let Z=j[P];return Z;}export function createDeleteRelation(P,G){const j=createRemove(P,G);return async function Z({name:q,id:p,relation:X,relationId:F,user:A},H){const o=C,b=H?.['pg']??P['pg'],E=G[o(0x1b1)](q);if([o(0x1b2),'files','gallery']['includes'](X)&&!E['capabilities']?.[o(0x1b3)](X))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+X+'\x22\x20requires\x20a\x20capabilities\x20\x22'+X+'\x22');if(X==='notes')return await b[o(0x1b4)](o(0x1b5),[F,q,String(p)]),{'success':!![]};if(X==='files')return await b[o(0x1b4)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[F,q,String(p)]),{'success':!![]};if(X==='gallery')return await b['query']('DELETE\x20FROM\x20admin.gallery\x20WHERE\x20id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[F,q,String(p)]),{'success':!![]};const z=E['relations']?.[X];if(!z?.['resource']||!z[o(0x1b6)])throw new UnsupportedError(o(0x1b7)+X+o(0x1b8));const x=await j({'name':z[o(0x1b9)],'id':F,'user':A,'where':{'column':z[o(0x1b6)],'value':p}},H);return{'success':x};};}
|
|
@@ -3,9 +3,16 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type RemoveParams = {
|
|
7
8
|
name: string;
|
|
8
9
|
id: string | number;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
|
|
11
|
+
where?: {
|
|
12
|
+
column: string;
|
|
13
|
+
value: string | number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, where, }: RemoveParams, ctx?: AppContext) => Promise<boolean>;
|
|
17
|
+
export {};
|
|
11
18
|
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -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;AAEhE,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,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,gCAE+B,YAAY,QAAQ,UAAU,sBAoCxF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{assertOperation}from'../utils/permissions.js';function
|
|
1
|
+
import{assertOperation}from'../utils/permissions.js';function C(P,G){P=P-0x17e;const j=m();let Z=j[P];return Z;}function m(){const o=['WHERE\x20','\x20=\x20$1','\x20=\x20$','length','\x20AND\x20(','DELETE\x20FROM\x20','table','write','module','delete'];m=function(){return o;};return m();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(P,G){return async function j({name:Z,id:q,user:p,where:X},F){const x=C,A=G['get'](Z);assertOperation(A,'delete',p);const H=F?.['pg']??P['pg'],b=[q];let E=x(0x17e)+qi(A['key'])+x(0x17f);X&&(b['push'](X['value']),E+='\x20AND\x20'+qi(X['column'])+x(0x180)+b[x(0x181)]);A['where']&&(E+=x(0x182)+A['where']+')');const z=await H['query'](x(0x183)+qt(A[x(0x184)])+'\x20'+E,b);if((z['rowCount']??0x0)>0x0)clearTableLookupCache(A[x(0x184)],H);if((z['rowCount']??0x0)>0x0)await(F?.['audit']??P['audit'])?.[x(0x185)]({'module':A[x(0x186)],'resource':A['name'],'resourceId':q,'action':x(0x187)});return(z['rowCount']??0x0)>0x0;};}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAQvB;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,6CAkDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function C(P,G){P=P-0x184;const j=m();let Z=j[P];return Z;}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';import{createFindRelation}from'./find-relation.js';function m(){const T=['now','read','Invalid\x20id:\x20','joins','sql','\x20AND\x20(','SELECT\x20','\x20FROM\x20','\x20WHERE\x20','dictionary','fields','file','keys','isArray','include','split','type'];m=function(){return T;};return m();}export function createFindOne(P,G){return async function j({name:Z,id:q,query:query={},user:p}){const y=C,X=Date[y(0x184)](),F=G['get'](Z);assertOperation(F,y(0x185),p);if(F['fields'][F['key']]?.['type']==='integer'&&!Number['isInteger'](Number(q)))throw new ValidationError(y(0x186)+q+'\x20name:'+Z);const A=F[y(0x187)]?.['map'](o=>o[y(0x188)]+'\x20')['join']('\x20')||'',H=F['where']?y(0x189)+F['where']+')':'',b=await P['pg']['query'](y(0x18a)+readableFields(F)['join'](',\x20')+y(0x18b)+qt(F['table'])+'\x20t\x20'+A+y(0x18c)+qi(F['key'])+'=$1'+H+'\x20LIMIT\x201',[q]),E=b['rows'][0x0];if(!E)return null;await addDictionaryLookupData([E],F['fields'],P[y(0x18d)]),await addTableLookupData([E],F[y(0x18e)],P['pg']),addFileToken([E],F['fields'],P[y(0x18f)]);const z=(query['include']==='all'?Object[y(0x190)](F['relations']||{}):null)||(Array[y(0x191)](query['include'])?query[y(0x192)]:query['include']?.[y(0x193)](',')??[]),x=createFindRelation(P,G);for(const o of z){E[o]=await x({'name':Z,'id':q,'relation':o,'query':query,'user':p})['then'](i=>i['rows']??[])['then'](i=>F['relations']?.[o]?.[y(0x194)]==='one'?i[0x0]??null:i);}return E['time']=Date['now']()-X,E;};}
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CA+GjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError,ValidationError}from'../../../errors.js';function
|
|
1
|
+
function C(P,G){P=P-0x137;const j=m();let Z=j[P];return Z;}import{UnsupportedError,ValidationError}from'../../../errors.js';function m(){const n=['now','max','isFinite','includes','\x22\x20requires\x20a\x20capabilities\x20\x22','notes','query','rows','files','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','resource','get','key','keys','junctionTable','JOIN\x20','junctionForeignKey','\x20=\x20t.','\x20=\x20(SELECT\x20','\x20FROM\x20','table','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','sql','\x20t\x20','fields'];m=function(){return n;};return m();}import{qi,qt}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';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(P,G){return async function j({name:Z,id:q,relation:p,query:query={}}){const a=C,X=Date[a(0x137)](),F=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[a(0x138)](query['offset']??0x0,0x0);if(!Number['isFinite'](F)||!Number[a(0x139)](A))throw new ValidationError('Invalid\x20pagination');const H=G['get'](Z),b=H['relations']?.[p];if(['notes','files'][a(0x13a)](p)&&!H['capabilities']?.['includes'](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+a(0x13b)+p+'\x22');if(p===a(0x13c)){const L=await P['pg'][a(0x13d)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[Z,String(q)]);return{'total':L[a(0x13e)]['length'],'time':Date['now']()-X,'rows':L['rows']};}if(p===a(0x13f)){const O=await P['pg'][a(0x13d)](a(0x140),[Z,String(q)]);return addFileToken(O['rows'],{'file_path':{'type':'file'}},P['file']),{'total':O[a(0x13e)]['length'],'time':Date['now']()-X,'rows':O['rows']};}if(!b?.[a(0x141)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');const E=G[a(0x142)](b['resource']),z=E?.[a(0x143)]??'id',x=E?.['table'],o=Object[a(0x144)](E?.['fields']??{})['filter'](N=>E?.['fields'][N]?.['read']&&E?.['fields'][N]?.['scope']!=='item')['map'](qi)['join'](',\x20'),i=b['fields']?.['join'](',\x20')||o||'*';b['foreignKey']&&autoIndex(x,b['foreignKey'],'btree',P['pg']);const y=b[a(0x145)]?a(0x146)+qt(b['junctionTable'])+'\x20j\x20ON\x20j.'+qi(b[a(0x147)])+a(0x148)+(b['junctionTargetKey']||qi(z))+'\x20WHERE\x20'+qi(b['junctionLocalKey'])+'\x20=\x20$1\x20':'where\x20'+(b['foreignKey']||qi(z))+a(0x149)+qi(b['localKey']||H[a(0x143)])+a(0x14a)+qt(H[a(0x14b)])+a(0x14c)+qi(H['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x20'+(b['where']?'AND\x20('+b['where']+')':''),T=E['joins']?.['map'](N=>N[a(0x14d)]+'\x20')['join']('\x20')||'',D='SELECT\x20'+i+'\x20FROM\x20'+qt(x)+a(0x14e)+T+'\x20'+y+'\x20LIMIT\x20$2\x20OFFSET\x20$3',h=await P['pg']['query'](D,[q,F,A]);return E&&(await addDictionaryLookupData(h[a(0x13e)],E[a(0x14f)],P['dictionary']),await addTableLookupData(h['rows'],E['fields'],P['pg']),addFileToken(h['rows'],E['fields'],P['file'])),{'limit':F,'offset':A,'total':h['rows']['length'],'time':Date['now']()-X,'rows':h['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;AAQhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAwFhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';function C(P,G){P=P-0x1bf;const j=m();let Z=j[P];return Z;}function m(){const N=['now','read','min','max','where','table','text','values','push','lower(',')\x20LIKE\x20$','length','scope','scopes','\x20WHERE\x20','true','sql','joins','item','join','\x20t\x20','replace','query','rowCount','fields'];m=function(){return N;};return m();}import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(P,G){return async function j({name:Z,query:query={},user:q}){const O=C,p=Date[O(0x1bf)](),X=G['get'](Z);assertOperation(X,O(0x1c0),q);const F=Math[O(0x1c1)](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[O(0x1c2)](query['offset']??0x0,0x0);buildIndex(X,query['filter'],P['pg']);const H=buildFilters(X,query['filter']);X[O(0x1c3)]&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+X[O(0x1c3)]+')'));const b=buildSort(X,query['sort']);if(!Number['isFinite'](F)||!Number['isFinite'](A))throw new ValidationError('Invalid\x20pagination');const E=X['searchable']||Object['keys'](X['fields'])['filter'](L=>X['fields'][L]?.['searchable']);query['search']&&E['length']&&(E['map'](L=>autoIndex(X[O(0x1c4)],L,O(0x1c5),P['pg'])),H[O(0x1c6)][O(0x1c7)](query['search']['toLowerCase']()+'%'),H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+E?.['map'](L=>O(0x1c8)+qt(L)+O(0x1c9)+H[O(0x1c6)][O(0x1ca)])['join']('\x20OR\x20')+')'));if(query[O(0x1cb)]&&X[O(0x1cc)]?.[query[O(0x1cb)]]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query[O(0x1cb)]);const z=query[O(0x1cb)]||(X[O(0x1cc)]?.['default']?'default':undefined);z&&(H['sql']+=(H['sql']?'\x20AND\x20':O(0x1cd))+('('+(X['scopes']?.[z]||O(0x1ce))+')'));const x=await buildUserResourceScopeFilter(X,q,P['pg'],H['values']['length']+0x1);x['sql']&&(H[O(0x1cf)]+=(H[O(0x1cf)]?'\x20AND\x20':'\x20WHERE\x20')+('('+x['sql']+')'),H[O(0x1c6)][O(0x1c7)](...x[O(0x1c6)]));const o=X[O(0x1d0)]?.['filter'](L=>L[O(0x1cb)]!==O(0x1d1))['map'](L=>L[O(0x1cf)]+'\x20')[O(0x1d2)]('\x20')||'',i='SELECT\x20'+readableFields(X,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(X[O(0x1c4)])+O(0x1d3))+(o+'\x20'+H[O(0x1cf)][O(0x1d4)](/:uid/g,'\x27'+(q?.['id']??'NULL')+'\x27')+'\x20'+b+'\x20')+('LIMIT\x20$'+(H['values'][O(0x1ca)]+0x1)+'\x20')+('OFFSET\x20$'+(H['values']['length']+0x2)),y=buildSummary(X,query,q,x),[T,D]=await Promise['all']([P['pg'][O(0x1d5)](i,[...H['values'],F,A]),P['pg']['query'](y['sql'],y['values'])['then'](L=>L['rows'][0x0]??{})]),h=T['rows'];return await addDictionaryLookupData(h,X['fields'],P['dictionary']),await addTableLookupData(h,X['fields'],P['pg']),addFileToken(h,X['fields'],P['file']),{'time':Date[O(0x1bf)]()-p,'limit':F,'offset':A,'count':T[O(0x1d6)],'total':D?.['count']??0x0,'summary':D,'rows':h,...query['include']?.['includes'](O(0x1d7))?{'fields':X[O(0x1d7)]}:{}};};}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
type Field = {
|
|
3
|
+
name: string;
|
|
4
|
+
title: string | null | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare function getTableColumns(table: string, deps: ResourceDependencies): Promise<Field[]>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=get-table-columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-table-columns.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/get-table-columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,KAAK,EAAE,CAAC,CAoBlB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(){const p=['not\x20enough\x20params:\x20table','then'];m=function(){return p;};return m();}function C(P,G){P=P-0x134;const j=m();let Z=j[P];return Z;}export async function getTableColumns(P,G){const q=C;if(!P)throw new Error(q(0x134));if(!G?.['pg'])return[];const j=await G['pg']['query']('\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped',[P])[q(0x135)](Z=>Z['rows']||[]);return j;}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import type { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateRelationParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
id: string | number;
|
|
6
7
|
relation: string;
|
|
7
8
|
relationId: string | number;
|
|
8
9
|
data: Record<string, unknown>;
|
|
9
10
|
user?: ResourceUser;
|
|
10
|
-
}
|
|
11
|
+
};
|
|
12
|
+
export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: UpdateRelationParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
13
|
+
export {};
|
|
11
14
|
//# sourceMappingURL=update-relation.d.ts.map
|