@opengis/fcore 0.0.1-beta.9 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -3
- package/README.md +71 -71
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/context.js +1 -1
- package/dist/errors.js +1 -1
- package/dist/fastify.d.ts +0 -3
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.d.ts.map +1 -1
- package/dist/fcore.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.js +1 -1
- package/dist/modules/auth/passwd-cli.js +1 -1
- package/dist/modules/auth/permission-cli.js +1 -1
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.js +1 -1
- package/dist/modules/auth/services/get-current-user.d.ts +2 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.js +1 -1
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.js +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +19 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.js +1 -1
- package/dist/modules/resource/services/create-resource.js +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
- package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
- package/dist/modules/resource/services/generate-resource-code.js +1 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
- package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
- package/dist/modules/resource/services/get-resource-schema.js +1 -0
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
- package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-as-user.js +1 -0
- package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
- package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
- package/dist/modules/resource/services/list-resource-list.js +1 -0
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.js +1 -1
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts.map +1 -1
- package/dist/modules/system/route.js +1 -1
- package/dist/modules/system/schema.d.ts +25 -2
- package/dist/modules/system/schema.d.ts.map +1 -1
- package/dist/modules/system/schema.js +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +1 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -1
- package/dist/modules/system/services/get-access.js +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-resource-access.d.ts +23 -0
- package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-access.js +1 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
- package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/get-resource-scopes.js +1 -0
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +3 -1
- package/dist/modules/system/services/set-access.d.ts.map +1 -1
- package/dist/modules/system/services/set-access.js +1 -1
- package/dist/modules/system/services/set-resource-access.d.ts +18 -0
- package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-access.js +1 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
- package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
- package/dist/modules/system/services/set-resource-scopes.js +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.js +1 -1
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.js +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +7 -3
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/jwt.js +1 -1
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.d.ts.map +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/resource.d.ts +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.d.ts +3 -2
- package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +66 -14
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
- package/dist/plugins/resource/services/add-file-token.js +1 -1
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
- package/dist/plugins/resource/services/create-relation.d.ts +5 -2
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/create-relation.js +1 -1
- package/dist/plugins/resource/services/create.d.ts +5 -2
- package/dist/plugins/resource/services/create.d.ts.map +1 -1
- package/dist/plugins/resource/services/create.js +1 -1
- package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete-relation.js +1 -1
- package/dist/plugins/resource/services/delete.d.ts +9 -2
- package/dist/plugins/resource/services/delete.d.ts.map +1 -1
- package/dist/plugins/resource/services/delete.js +1 -1
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-relation.js +1 -1
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/get-table-columns.d.ts +8 -0
- package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
- package/dist/plugins/resource/services/get-table-columns.js +1 -0
- package/dist/plugins/resource/services/update-relation.d.ts +5 -2
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
- package/dist/plugins/resource/services/update-relation.js +1 -1
- package/dist/plugins/resource/services/update.d.ts +9 -2
- package/dist/plugins/resource/services/update.d.ts.map +1 -1
- package/dist/plugins/resource/services/update.js +1 -1
- package/dist/plugins/resource/utils/auto-index.js +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +2 -1
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- package/dist/plugins/resource/utils/scope.d.ts +10 -0
- package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
- package/dist/plugins/resource/utils/scope.js +1 -0
- package/dist/plugins/resource/utils/sort.d.ts +1 -1
- package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sort.js +1 -1
- package/dist/plugins/resource/utils/sql.d.ts +1 -1
- package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
- package/dist/plugins/resource/utils/sql.js +1 -1
- package/dist/plugins/resource/utils/summary.d.ts +7 -0
- package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
- package/dist/plugins/resource/utils/summary.js +1 -0
- package/dist/shared/getIP.js +1 -1
- package/migrations/20260903120000_core_schema.sql +5 -2
- package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
- package/migrations/20260903130001_add_file_fields.sql +5 -0
- package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
- package/migrations/20260910170000_core_schema.sql +22 -0
- package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
- package/migrations/20260929_role_scope.sql +32 -0
- package/package.json +93 -93
|
@@ -1 +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
|
-
const
|
|
1
|
+
const j=f;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';function f(p,Z){p=p-0x146;const A=s();let I=A[p];return I;}const ident=/^[a-zA-Z0-9_-]*$/;function validQualified(p){const I=f;return p['split']('.')[I(0x146)]<=0x2&&p[I(0x147)]('.')['every'](Z=>ident[I(0x148)](Z));}export class ResourceRegistry{[j(0x149)]=new Map();['unregister'](p){const D=j;this[D(0x149)][D(0x14a)](p);}['register'](p,Z=![]){const o=j;for(const A of Array['isArray'](p)?p:[p]){this['validate'](A);if(this['resources']['has'](A[o(0x14b)])&&!Z)throw new ConflictError(o(0x14c)+A[o(0x14b)]);this['resources']['set'](A['name'],A);}}['has'](p){const R=j;return this['resources'][R(0x14d)](p);}['get'](p){const B=j,Z=this[B(0x149)][B(0x14e)](p);if(!Z)throw new NotFoundError(B(0x14f)+p);return Z;}['list'](){return[...this['resources']['values']()];}[j(0x150)](p){const H=j;if(p[H(0x151)]!==0x1||!ident['test'](p['name'])||!validQualified(p['table'])||!ident['test'](p['key']))throw new ValidationError(H(0x152)+p['name']);for(const [Z,A]of Object['entries'](p['fields'])){if(!ident[H(0x148)](Z)||!ident['test'](A['column']??Z))throw new ValidationError('Invalid\x20resource\x20field:\x20'+Z);}}}function s(){const e=['length','split','test','resources','delete','name','Resource\x20already\x20registered:\x20','has','get','Resource\x20not\x20registered:\x20','validate','version','Invalid\x20resource\x20contract:\x20'];s=function(){return e;};return s();}
|
|
@@ -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,13 +38,13 @@ 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
|
-
search?: boolean;
|
|
47
|
+
scope?: "all" | "item";
|
|
26
48
|
dictionary?: string;
|
|
27
49
|
lookup?: {
|
|
28
50
|
table: string;
|
|
@@ -37,43 +59,71 @@ export interface ResourceFieldContract {
|
|
|
37
59
|
maximum?: number;
|
|
38
60
|
pattern?: string;
|
|
39
61
|
}
|
|
62
|
+
export type ResourceRelationType = 'one' | 'many';
|
|
40
63
|
export interface ResourceRelationContract {
|
|
64
|
+
type?: ResourceRelationType;
|
|
41
65
|
resource?: string;
|
|
42
66
|
table?: string;
|
|
43
|
-
|
|
44
|
-
|
|
67
|
+
where?: string;
|
|
68
|
+
localKey?: string;
|
|
45
69
|
foreignKey?: string;
|
|
46
|
-
|
|
47
|
-
type?: "one" | "many";
|
|
70
|
+
targetKey?: string;
|
|
48
71
|
fields?: string[];
|
|
72
|
+
junctionTable?: string;
|
|
73
|
+
junctionLocalKey?: string;
|
|
74
|
+
junctionForeignKey?: string;
|
|
75
|
+
junctionTargetKey?: string;
|
|
49
76
|
}
|
|
50
77
|
export interface ResourceContract {
|
|
51
78
|
version: 1;
|
|
52
79
|
name: string;
|
|
53
|
-
module
|
|
80
|
+
module?: string;
|
|
54
81
|
title?: string;
|
|
55
82
|
table: string;
|
|
83
|
+
where?: string;
|
|
56
84
|
key: string;
|
|
85
|
+
display?: string[] | string;
|
|
57
86
|
operations: ResourceOperation[];
|
|
87
|
+
searchable?: string[];
|
|
58
88
|
capabilities?: string[];
|
|
59
89
|
permission?: string;
|
|
60
90
|
fields: Record<string, ResourceFieldContract>;
|
|
61
91
|
relations?: Record<string, ResourceRelationContract>;
|
|
92
|
+
joins?: ResourceJoinContract[];
|
|
62
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[];
|
|
63
109
|
}
|
|
64
110
|
export interface ResourceQuery {
|
|
65
111
|
filter?: Record<string, unknown>;
|
|
66
112
|
include?: string | string[];
|
|
67
113
|
sort?: string[];
|
|
68
114
|
search?: string;
|
|
115
|
+
scope?: string;
|
|
69
116
|
limit?: number;
|
|
70
117
|
offset?: number;
|
|
71
118
|
fields?: string[];
|
|
72
119
|
}
|
|
73
120
|
export interface ResourceListResult<T = Record<string, unknown>> {
|
|
74
121
|
rows: T[];
|
|
122
|
+
summary: Record<string, unknown>;
|
|
75
123
|
limit: number;
|
|
76
124
|
time: number;
|
|
125
|
+
fields?: Record<string, ResourceFieldContract>;
|
|
126
|
+
count: number | null;
|
|
77
127
|
total: number | null;
|
|
78
128
|
offset: number;
|
|
79
129
|
}
|
|
@@ -86,7 +136,8 @@ export interface ResourceDependencies {
|
|
|
86
136
|
file?: FileAdapter;
|
|
87
137
|
}
|
|
88
138
|
export interface ResourcePlugin {
|
|
89
|
-
register(input: ResourceContract | ResourceContract[]): void;
|
|
139
|
+
register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
|
|
140
|
+
unregister(name: string): void;
|
|
90
141
|
has(name: string): boolean;
|
|
91
142
|
get(name: string): ResourceContract;
|
|
92
143
|
list(): ResourceContract[];
|
|
@@ -105,18 +156,18 @@ export interface ResourcePlugin {
|
|
|
105
156
|
name: string;
|
|
106
157
|
data: Record<string, unknown>;
|
|
107
158
|
user?: ResourceUser;
|
|
108
|
-
}): Promise<Record<string, unknown>>;
|
|
159
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
109
160
|
update(params: {
|
|
110
161
|
name: string;
|
|
111
162
|
id: string | number;
|
|
112
163
|
data: Record<string, unknown>;
|
|
113
164
|
user?: ResourceUser;
|
|
114
|
-
}): Promise<Record<string, unknown>>;
|
|
165
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
115
166
|
delete(params: {
|
|
116
167
|
name: string;
|
|
117
168
|
id: string | number;
|
|
118
169
|
user?: ResourceUser;
|
|
119
|
-
}): Promise<boolean>;
|
|
170
|
+
}, ctx?: AppContext): Promise<boolean>;
|
|
120
171
|
findRelation(params: {
|
|
121
172
|
name: string;
|
|
122
173
|
id: string | number;
|
|
@@ -130,7 +181,7 @@ export interface ResourcePlugin {
|
|
|
130
181
|
relation: string;
|
|
131
182
|
data?: Record<string, unknown>;
|
|
132
183
|
user?: ResourceUser;
|
|
133
|
-
}): Promise<any>;
|
|
184
|
+
}, ctx?: AppContext): Promise<any>;
|
|
134
185
|
updateRelation(params: {
|
|
135
186
|
name: string;
|
|
136
187
|
id: string | number;
|
|
@@ -138,15 +189,16 @@ export interface ResourcePlugin {
|
|
|
138
189
|
relationId: string;
|
|
139
190
|
data: Record<string, unknown>;
|
|
140
191
|
user?: ResourceUser;
|
|
141
|
-
}): Promise<Record<string, unknown>>;
|
|
192
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
142
193
|
deleteRelation(params: {
|
|
143
194
|
name: string;
|
|
144
195
|
id: string | number;
|
|
145
196
|
relation: string;
|
|
146
197
|
relationId: string;
|
|
147
198
|
user?: ResourceUser;
|
|
148
|
-
}): Promise<{
|
|
199
|
+
}, ctx?: AppContext): Promise<{
|
|
149
200
|
success: boolean;
|
|
150
201
|
}>;
|
|
151
202
|
}
|
|
203
|
+
export {};
|
|
152
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,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAC3B;IACE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACD;IACE,SAAS,EAAE,eAAe,G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ictionaryIndexesCache['get'](Z)??new Map(),I=dictionaryRevisionsCache[g(0x103)](Z)??new Map();dictionaryIndexesCache['set'](Z,A),dictionaryRevisionsCache[g(0x104)](Z,I);const j=p['filter'](o=>I['get'](o)!==Z[g(0x105)](o));if(j['length']===0x0)return A;const D=await Promise[g(0x106)](j['map'](async o=>{const N=g;if(!Z[N(0x107)](o))return[o,new Map()];const R=await Z[N(0x103)](o),B=new Map();for(const H of R){const e=H['code']??H['id'];if(e==null)continue;B['set'](String(e),{'id':e,'text':H[N(0x108)]??H[N(0x109)],...H['color']!==undefined?{'color':H[N(0x10a)]}:{},...H['icon']!==undefined?{'icon':H[N(0x10b)]}:{}});}return[o,B];}));for(const [o,R]of D){A[g(0x104)](o,R),I[g(0x104)](o,Z['revision'](o));}return A;}function s(){const E=['get','set','revision','all','has','name','text','color','icon','_data'];s=function(){return E;};return s();}function f(p,Z){p=p-0x103;const A=s();let I=A[p];return I;}export async function addDictionaryLookupData(p,Z,A){const h=f;if(!A||p['length']===0x0)return p;const I=Object['entries'](Z)['flatMap'](([D,o])=>{const R=o['dictionary'];return R?[{'field':D,'dictionaryName':R}]:[];});if(I['length']===0x0)return p;const j=await getDictionaryIndexes([...new Set(I['map'](({dictionaryName:D})=>D))],A);for(const D of p){for(const {field:o,dictionaryName:R}of I){const B=D[o];D[o+h(0x10c)]=B==null?null:j[h(0x103)](R)?.[h(0x103)](String(B))??null;}}return p;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export function addFileToken(p,Z,A){const R=f;if(!A||p['length']===0x0)return p;const I=Object['entries'](Z)['filter'](([,j])=>j['type']===R(0x179))['map'](([j])=>j);for(const j of p){for(const D of I){const o=j[D];typeof o===R(0x17a)&&o[R(0x17b)]>0x0&&(j[D]=A['create'](o));}}return p;}function f(p,Z){p=p-0x179;const A=s();let I=A[p];return I;}function s(){const B=['file','string','length'];s=function(){return B;};return s();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(p,Z){p=p-0x199;const A=s();let I=A[p];return I;}import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();export function clearTableLookupCache(p,Z){const K=f,A=tableLookupCache[K(0x199)](Z);if(!A)return;for(const I of A['keys']()){I['startsWith'](p+':')&&A['delete'](I);}}export async function addTableLookupData(p,Z,A){const Q=f;if(!A||p['length']===0x0)return p;const I=tableLookupCache['get'](A)??new Map();tableLookupCache['set'](A,I);const j=Object[Q(0x19a)](Z)['flatMap'](([D,o])=>{const G=Q,{table:R,value:value='id',text:text=G(0x19b)}=o['lookup']??{};return R?[{'field':D,'table':R,'value':value,'text':text}]:[];});for(const D of j){const o=new Map();for(const e of p){const g=e[D['field']];(typeof g===Q(0x19c)||typeof g===Q(0x19d))&&o[Q(0x19e)](String(g),g);}const R=D[Q(0x19f)]+':'+D['value']+':'+D['text'],B=I['get'](R)??new Map();I['set'](R,B);const H=[...o[Q(0x19a)]()]['filter'](([N])=>!B['has'](N))[Q(0x1a0)](([,N])=>N);if(H['length']>0x0){const N=await A[Q(0x1a1)](Q(0x1a2)+qi(D['value'])+Q(0x1a3)+qi(D['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(D['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(D['value'])+'\x20=\x20ANY($1)',[H]);for(const h of N['rows']){B['set'](String(h['id']),h);}for(const E of H){!B[Q(0x1a4)](String(E))&&B['set'](String(E),null);}}for(const a of p){const X=a[D['field']];a[D[Q(0x1a5)]+'_data']=X==null?null:B['get'](String(X))??null;}}return p;}function s(){const V=['get','entries','name','string','number','set','table','map','query','SELECT\x20','\x20AS\x20id,\x20','has','field'];s=function(){return V;};return s();}
|
|
@@ -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,CAyEhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UnsupportedError
|
|
1
|
+
function f(p,Z){p=p-0x1e8;const A=s();let I=A[p];return I;}import{UnsupportedError}from'../../../errors.js';function s(){const K=['get','files','includes','Generic\x20Resource\x20relation\x20\x22','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','rows','foreignKey','table','resource','Relation\x20update\x20is\x20not\x20configured:\x20'];s=function(){return K;};return s();}import{createCreate}from'./create.js';export function createCreateRelation(p,Z){const A=createCreate(p,Z);return async function I({name:j,id:D,relation:o,data:R,user:B},H){const X=f,e=H?.['pg']??p['pg'],g=Z[X(0x1e8)](j);if(['notes',X(0x1e9)][X(0x1ea)](o)&&!g['capabilities']?.[X(0x1ea)](o))throw new UnsupportedError(X(0x1eb)+o+'\x22\x20requires\x20a\x20capabilities\x20\x22'+o+'\x22');if(o==='notes'){const E=await e['query'](X(0x1ec),[j,String(D),R?.['body']]);return E[X(0x1ed)][0x0];}if(o===X(0x1e9)){const a=await e['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*',[j,String(D),R?.['filePath'],R?.['size']??null]);return a[X(0x1ed)][0x0];}const N=g['relations']?.[o];if(!N?.[X(0x1ee)]||!N['resource']&&!N[X(0x1ef)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+o+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!R)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+R);if(!N[X(0x1f0)])throw new UnsupportedError(X(0x1f1)+o);R[N['foreignKey']]=D;const h=await A({'name':N[X(0x1f0)],'data':R??{},'user':B});return h;};}
|
|
@@ -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';import{qi,qt,
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';function f(p,Z){p=p-0x1b4;const A=s();let I=A[p];return I;}import{clearTableLookupCache}from'./add-table-lookup-data.js';function s(){const Q=['created_by','length','map','rows','table','module','name','create','keys'];s=function(){return Q;};return s();}export function createCreate(p,Z){return async function A({name:I,data:j,user:D},o){const K=f,R=Z['get'](I);assertOperation(R,'create',D),validateInputData({'resource':R,'data':j});const B=writableData(R,j);R['fields']['created_at']&&B['push'](['created_at',new Date()]);R['fields'][K(0x1b4)]&&B['push'](['created_by',D?.['id']]);if(!B[K(0x1b5)])throw new ValidationError('No\x20writable\x20fields');const H=B['map'](([a])=>qi(a)),e=B[K(0x1b6)]((a,X)=>'$'+(X+0x1)),g=B[K(0x1b6)](([,a])=>a),N=o?.['pg']??p['pg'],h=await N['query']('INSERT\x20INTO\x20'+qt(R['table'])+'\x20('+H['join'](',\x20')+')\x20'+('VALUES\x20('+e['join'](',\x20')+')\x20')+'RETURNING\x20*',g),E=h[K(0x1b7)][0x0];return clearTableLookupCache(R[K(0x1b8)],N),await(o?.['audit']??p['audit'])?.['write']({'userId':D?.['id'],'module':R[K(0x1b9)],'resource':R[K(0x1ba)],'resourceId':E[R['key']],'action':K(0x1bb),'fields':Object[K(0x1bc)](j)}),E;};}
|
|
@@ -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,CA+CjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function f(p,Z){p=p-0x156;const A=s();let I=A[p];return I;}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';export function createDeleteRelation(p,Z){const A=createRemove(p,Z);return async function I({name:j,id:D,relation:o,relationId:R,user:B},H){const E=f,e=H?.['pg']??p['pg'],g=Z['get'](j);if([E(0x156),'files'][E(0x157)](o)&&!g['capabilities']?.['includes'](o))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+o+'\x22\x20requires\x20a\x20capabilities\x20\x22'+o+'\x22');if(o==='notes')return await e['query'](E(0x158),[R,j,String(D)]),{'success':!![]};if(o==='files')return await e['query'](E(0x159),[R,j,String(D)]),{'success':!![]};const N=g[E(0x15a)]?.[o];if(!N?.['resource']||!N['foreignKey'])throw new UnsupportedError(E(0x15b)+o+'\x22\x20requires\x20a\x20project/provider\x20implementation');const h=await A({'name':N[E(0x15c)],'id':R,'user':B,'where':{'column':N['foreignKey'],'value':D}},H);return{'success':h};};}function s(){const a=['notes','includes','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','relations','Generic\x20Resource\x20relation\x20\x22','resource'];s=function(){return a;};return s();}
|
|
@@ -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
|
-
|
|
1
|
+
function f(p,Z){p=p-0x1d2;const A=s();let I=A[p];return I;}function s(){const E=['delete','column','\x20=\x20$','where','query','DELETE\x20FROM\x20','table','write','name','rowCount'];s=function(){return E;};return s();}import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(p,Z){return async function A({name:I,id:j,user:D,where:o},R){const h=f,B=Z['get'](I);assertOperation(B,h(0x1d2),D);const H=R?.['pg']??p['pg'],e=[j];let g='WHERE\x20'+qi(B['key'])+'\x20=\x20$1';o&&(e['push'](o['value']),g+='\x20AND\x20'+qi(o[h(0x1d3)])+h(0x1d4)+e['length']);B['where']&&(g+='\x20AND\x20('+B[h(0x1d5)]+')');const N=await H[h(0x1d6)](h(0x1d7)+qt(B[h(0x1d8)])+'\x20'+g,e);if((N['rowCount']??0x0)>0x0)clearTableLookupCache(B['table'],H);if((N['rowCount']??0x0)>0x0)await(R?.['audit']??p['audit'])?.[h(0x1d9)]({'module':B['module'],'resource':B[h(0x1da)],'resourceId':j,'action':h(0x1d2)});return(N[h(0x1db)]??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';function
|
|
1
|
+
function f(p,Z){p=p-0x74;const A=s();let I=A[p];return I;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function s(){const K=['get','read','type','query','join','table','rows','fields','all','relations'];s=function(){return K;};return s();}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';export function createFindOne(p,Z){return async function A({name:I,id:j,query:query={},user:D}){const X=f,o=Date['now'](),R=Z[X(0x74)](I);assertOperation(R,X(0x75),D);if(R['fields'][R['key']]?.[X(0x76)]==='integer'&&!Number['isInteger'](Number(j)))throw new ValidationError('Invalid\x20id:\x20'+j+'\x20name:'+I);const B=R['joins']?.['map'](E=>E['sql']+'\x20')['join']('\x20')||'',H=R['where']?'\x20AND\x20('+R['where']+')':'',e=await p['pg'][X(0x77)]('SELECT\x20'+readableFields(R)[X(0x78)](',\x20')+'\x20FROM\x20'+qt(R[X(0x79)])+'\x20t\x20'+B+'\x20WHERE\x20'+qi(R['key'])+'=$1'+H+'\x20LIMIT\x201',[j]),g=e[X(0x7a)][0x0];if(!g)return null;await addDictionaryLookupData([g],R['fields'],p['dictionary']),await addTableLookupData([g],R['fields'],p['pg']),addFileToken([g],R[X(0x7b)],p['file']);const N=(query['include']===X(0x7c)?Object['keys'](R[X(0x7d)]||{}):null)||(Array['isArray'](query['include'])?query['include']:query['include']?.['split'](',')??[]),h=createFindRelation(p,Z);for(const E of N){g[E]=await h({'name':I,'id':j,'relation':E,'query':query,'user':D})['then'](a=>a['rows']??[])['then'](a=>R['relations']?.[E]?.[X(0x76)]==='one'?a[0x0]??null:a);}return g['time']=Date['now']()-o,g;};}
|
|
@@ -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';import{qi,qt}from'../utils/sql.js';function
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function f(p,Z){p=p-0x126;const A=s();let I=A[p];return I;}import{qi,qt}from'../utils/sql.js';function s(){const L=['files','Generic\x20Resource\x20relation\x20\x22','query','rows','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','get','key','keys','filter','fields','\x20WHERE\x20','foreignKey','\x20=\x20(SELECT\x20','localKey','table','\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x20','AND\x20(','where','join','\x20LIMIT\x20$2\x20OFFSET\x20$3','file','now'];s=function(){return L;};return s();}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,Z){return async function A({name:I,id:j,relation:D,query:query={}}){const T=f,o=Date['now'](),R=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),B=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](R)||!Number['isFinite'](B))throw new ValidationError('Invalid\x20pagination');const H=Z['get'](I),e=H['relations']?.[D];if(['notes',T(0x126)]['includes'](D)&&!H['capabilities']?.['includes'](D))throw new UnsupportedError(T(0x127)+D+'\x22\x20requires\x20a\x20capabilities\x20\x22'+D+'\x22');if(D==='notes'){const V=await p['pg'][T(0x128)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[I,String(j)]);return{'total':V['rows']['length'],'time':Date['now']()-o,'rows':V[T(0x129)]};}if(D==='files'){const O=await p['pg'][T(0x128)](T(0x12a),[I,String(j)]);return addFileToken(O['rows'],{'file_path':{'type':'file'}},p['file']),{'total':O['rows']['length'],'time':Date['now']()-o,'rows':O[T(0x129)]};}if(!e?.['resource'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+D+'\x22\x20requires\x20a\x20project/provider\x20implementation');const g=Z[T(0x12b)](e['resource']),N=g?.[T(0x12c)]??'id',h=g?.['table'],E=Object[T(0x12d)](g?.['fields']??{})[T(0x12e)](F=>g?.[T(0x12f)][F]?.['read']&&g?.[T(0x12f)][F]?.['scope']!=='item')['map'](qi)['join'](',\x20'),a=e[T(0x12f)]?.['join'](',\x20')||E||'*';e['foreignKey']&&autoIndex(h,e['foreignKey'],'btree',p['pg']);const X=e['junctionTable']?'JOIN\x20'+qt(e['junctionTable'])+'\x20j\x20ON\x20j.'+qi(e['junctionForeignKey'])+'\x20=\x20t.'+(e['junctionTargetKey']||qi(N))+T(0x130)+qi(e['junctionLocalKey'])+'\x20=\x20$1\x20':'where\x20'+(e[T(0x131)]||qi(N))+T(0x132)+qi(e[T(0x133)]||H['key'])+'\x20FROM\x20'+qt(H[T(0x134)])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(H['key'])+T(0x135)+(e['where']?T(0x136)+e[T(0x137)]+')':''),K=g['joins']?.['map'](F=>F['sql']+'\x20')[T(0x138)]('\x20')||'',Q='SELECT\x20'+a+'\x20FROM\x20'+qt(h)+'\x20t\x20'+K+'\x20'+X+T(0x139),G=await p['pg'][T(0x128)](Q,[j,R,B]);return g&&(await addDictionaryLookupData(G['rows'],g['fields'],p['dictionary']),await addTableLookupData(G['rows'],g['fields'],p['pg']),addFileToken(G['rows'],g['fields'],p[T(0x13a)])),{'limit':R,'offset':B,'total':G[T(0x129)]['length'],'time':Date[T(0x13b)]()-o,'rows':G['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';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';
|
|
1
|
+
function s(){const F=['now','get','read','min','where','sql','\x20WHERE\x20','isFinite','searchable','text','join','scope','default','\x20AND\x20','values','joins','filter','SELECT\x20','length','query','fields','count'];s=function(){return F;};return s();}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';import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';function f(p,Z){p=p-0x11e;const A=s();let I=A[p];return I;}export function createFind(p,Z){return async function A({name:I,query:query={},user:j}){const O=f,D=Date[O(0x11e)](),o=Z[O(0x11f)](I);assertOperation(o,O(0x120),j);const R=Math[O(0x121)](Math['max'](query['limit']??0x14,0x1),0xc8),B=Math['max'](query['offset']??0x0,0x0);buildIndex(o,query['filter'],p['pg']);const H=buildFilters(o,query['filter']);o[O(0x122)]&&(H['sql']+=(H[O(0x123)]?'\x20AND\x20':O(0x124))+('('+o[O(0x122)]+')'));const e=buildSort(o,query['sort']);if(!Number[O(0x125)](R)||!Number['isFinite'](B))throw new ValidationError('Invalid\x20pagination');const g=o[O(0x126)]||Object['keys'](o['fields'])['filter'](V=>o['fields'][V]?.[O(0x126)]);query['search']&&g['length']&&(g['map'](V=>autoIndex(o['table'],V,O(0x127),p['pg'])),H['values']['push'](query['search']['toLowerCase']()+'%'),H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+g?.['map'](V=>'lower('+qt(V)+')\x20LIKE\x20$'+H['values']['length'])[O(0x128)]('\x20OR\x20')+')'));if(query['scope']&&o['scopes']?.[query[O(0x129)]]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query['scope']);const N=query['scope']||(o['scopes']?.['default']?O(0x12a):undefined);N&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+(o['scopes']?.[N]||'true')+')'));const h=await buildUserResourceScopeFilter(o,j,p['pg'],H['values']['length']+0x1);h['sql']&&(H['sql']+=(H['sql']?O(0x12b):'\x20WHERE\x20')+('('+h['sql']+')'),H['values']['push'](...h[O(0x12c)]));const E=o[O(0x12d)]?.[O(0x12e)](V=>V['scope']!=='item')['map'](V=>V[O(0x123)]+'\x20')['join']('\x20')||'',a=O(0x12f)+readableFields(o,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(o['table'])+'\x20t\x20')+(E+'\x20'+H['sql']['replace'](/:uid/g,'\x27'+(j?.['id']??'NULL')+'\x27')+'\x20'+e+'\x20')+('LIMIT\x20$'+(H['values']['length']+0x1)+'\x20')+('OFFSET\x20$'+(H[O(0x12c)][O(0x130)]+0x2)),X=buildSummary(o,query,j,h),[K,Q]=await Promise['all']([p['pg']['query'](a,[...H[O(0x12c)],R,B]),p['pg'][O(0x131)](X[O(0x123)],X['values'])['then'](V=>V['rows'][0x0]??{})]),G=K['rows'];return await addDictionaryLookupData(G,o[O(0x132)],p['dictionary']),await addTableLookupData(G,o['fields'],p['pg']),addFileToken(G,o['fields'],p['file']),{'time':Date['now']()-D,'limit':R,'offset':B,'count':K['rowCount'],'total':Q?.[O(0x133)]??0x0,'summary':Q,'rows':G,...query['include']?.['includes']('fields')?{'fields':o[O(0x132)]}:{}};};}
|
|
@@ -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 s(){const D=['query'];s=function(){return D;};return s();}function f(p,Z){p=p-0x68;const A=s();let I=A[p];return I;}export async function getTableColumns(p,Z){const j=f;if(!p)throw new Error('not\x20enough\x20params:\x20table');if(!Z?.['pg'])return[];const A=await Z['pg'][j(0x68)]('\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])['then'](I=>I['rows']||[]);return A;}
|
|
@@ -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
|
|
@@ -1 +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;
|
|
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;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IACxB,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,CAAC;AAEF,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAI4D,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function s(){const E=['resource','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn','Cannot\x20change\x20relation:\x20','foreignKey'];s=function(){return E;};return s();}function f(p,Z){p=p-0x1df;const A=s();let I=A[p];return I;}import{createUpdate}from'./update.js';export function createUpdateRelation(p,Z){const A=createUpdate(p,Z);return async function I({name:j,id:D,relation:o,relationId:R,data:B,user:H},e){const h=f,g=Z['get'](j),N=g['relations']?.[o];if(!N?.[h(0x1df)]||!N['foreignKey'])throw new UnsupportedError(h(0x1e0)+o);if(Object[h(0x1e1)](B,N['foreignKey'])&&B[N['foreignKey']]!==D)throw new ValidationError(h(0x1e2)+N[h(0x1e3)]);return A({'name':N['resource'],'id':R,'data':B,'user':H,'where':{'column':N['foreignKey'],'value':D}},e);};}
|