@opengis/fcore 0.0.1-beta.2 → 0.0.1-beta.20
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 +2 -10
- 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 +2 -5
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +1 -1
- package/dist/fcore.js +1 -1
- package/dist/index.js +1 -1
- package/dist/migrations/cli.js +1 -1
- package/dist/migrations/runner.js +1 -1
- package/dist/modules/auth/adduser-cli.d.ts +3 -0
- package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
- package/dist/modules/auth/adduser-cli.js +2 -0
- package/dist/modules/auth/passwd-cli.d.ts +3 -0
- package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
- package/dist/modules/auth/passwd-cli.js +2 -0
- package/dist/modules/auth/permission-cli.d.ts +3 -0
- package/dist/modules/auth/permission-cli.d.ts.map +1 -0
- package/dist/modules/auth/permission-cli.js +2 -0
- package/dist/modules/auth/route.d.ts.map +1 -1
- package/dist/modules/auth/route.js +1 -1
- package/dist/modules/auth/schema.d.ts +10 -1
- package/dist/modules/auth/schema.d.ts.map +1 -1
- package/dist/modules/auth/schema.js +1 -1
- package/dist/modules/auth/services/change-password.d.ts +9 -0
- package/dist/modules/auth/services/change-password.d.ts.map +1 -0
- package/dist/modules/auth/services/change-password.js +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts +1 -0
- package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
- package/dist/modules/auth/services/get-current-user.js +1 -1
- package/dist/modules/auth/services/registration.d.ts +14 -0
- package/dist/modules/auth/services/registration.d.ts.map +1 -0
- package/dist/modules/auth/services/registration.js +1 -0
- package/dist/modules/auth/services/verify-two-factor.js +1 -1
- package/dist/modules/file/mime.d.ts +3 -0
- package/dist/modules/file/mime.d.ts.map +1 -0
- package/dist/modules/file/mime.js +1 -0
- package/dist/modules/file/route.d.ts.map +1 -1
- package/dist/modules/file/route.js +1 -1
- package/dist/modules/file/schema.d.ts +3 -0
- package/dist/modules/file/schema.d.ts.map +1 -1
- package/dist/modules/file/schema.js +1 -1
- package/dist/modules/file/services/get-file.js +1 -1
- package/dist/modules/file/services/resize-file.d.ts.map +1 -1
- package/dist/modules/file/services/resize-file.js +1 -1
- package/dist/modules/file/services/upload-file.d.ts +4 -6
- package/dist/modules/file/services/upload-file.d.ts.map +1 -1
- package/dist/modules/file/services/upload-file.js +1 -1
- package/dist/modules/resource/route.d.ts +0 -3
- package/dist/modules/resource/route.d.ts.map +1 -1
- package/dist/modules/resource/route.js +1 -1
- package/dist/modules/resource/schema.d.ts +3 -0
- package/dist/modules/resource/schema.d.ts.map +1 -1
- package/dist/modules/resource/schema.js +1 -1
- package/dist/modules/resource/services/add-note.js +1 -1
- package/dist/modules/resource/services/add-resource-file.js +1 -1
- package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
- package/dist/modules/resource/services/create-resource-relation.d.ts.map +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.d.ts +8 -1
- package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/delete-resource-relation.js +1 -1
- package/dist/modules/resource/services/delete-resource.js +1 -1
- package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/export-resource.js +1 -1
- package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/get-resource.js +1 -1
- package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
- package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resource-relation.js +1 -1
- package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
- package/dist/modules/resource/services/list-resources.js +1 -1
- package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/search-resource.js +1 -1
- package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
- package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
- package/dist/modules/resource/services/suggest-resource.js +1 -1
- package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
- package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
- package/dist/modules/resource/services/update-resource-relation.js +1 -0
- package/dist/modules/resource/services/update-resource.js +1 -1
- package/dist/modules/resource/services/upload-resource-file.js +1 -1
- package/dist/modules/system/route.d.ts +2 -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 +23 -1
- 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.d.ts.map +1 -1
- package/dist/modules/system/services/check-system.js +1 -1
- package/dist/modules/system/services/get-access.d.ts +15 -0
- package/dist/modules/system/services/get-access.d.ts.map +1 -0
- package/dist/modules/system/services/get-access.js +1 -0
- package/dist/modules/system/services/get-api-list.d.ts +4 -1
- package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
- package/dist/modules/system/services/get-api-list.js +1 -1
- package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-audit-log.js +1 -1
- package/dist/modules/system/services/get-dictionary.js +1 -1
- package/dist/modules/system/services/get-system-log.d.ts +9 -5
- package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-log.js +1 -1
- package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/get-system-settings.js +1 -1
- package/dist/modules/system/services/list-dictionaries.js +1 -1
- package/dist/modules/system/services/set-access.d.ts +17 -0
- package/dist/modules/system/services/set-access.d.ts.map +1 -0
- package/dist/modules/system/services/set-access.js +1 -0
- package/dist/modules/system/services/update-dictionary.d.ts +13 -0
- package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
- package/dist/modules/system/services/update-dictionary.js +1 -0
- package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
- package/dist/modules/system/services/update-system-settings.js +1 -1
- package/dist/modules/utils/require-admin.js +1 -1
- package/dist/modules/utils/safe-user.js +1 -1
- package/dist/modules/utils/unsupported.js +1 -1
- package/dist/plugins/audit/audit.js +1 -1
- package/dist/plugins/audit/audit.types.d.ts +1 -1
- package/dist/plugins/audit/audit.types.d.ts.map +1 -1
- package/dist/plugins/audit/index.js +1 -1
- package/dist/plugins/audit/services/write-audit.js +1 -1
- package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
- package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
- package/dist/plugins/auth/get-user-permissions.js +1 -0
- package/dist/plugins/auth/index.d.ts +4 -0
- package/dist/plugins/auth/index.d.ts.map +1 -1
- package/dist/plugins/auth/index.js +1 -1
- package/dist/plugins/auth/verifyUser.d.ts +9 -0
- package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
- package/dist/plugins/auth/verifyUser.js +1 -0
- package/dist/plugins/dictionary.d.ts +3 -0
- package/dist/plugins/dictionary.d.ts.map +1 -1
- package/dist/plugins/dictionary.js +1 -1
- package/dist/plugins/file.d.ts +3 -6
- package/dist/plugins/file.d.ts.map +1 -1
- package/dist/plugins/file.js +1 -1
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/jwt.d.ts +4 -0
- package/dist/plugins/jwt.d.ts.map +1 -0
- package/dist/plugins/jwt.js +1 -0
- package/dist/plugins/logger/index.js +1 -1
- package/dist/plugins/logger/transport.js +1 -1
- package/dist/plugins/pg.d.ts +4 -2
- package/dist/plugins/pg.d.ts.map +1 -1
- package/dist/plugins/pg.js +1 -1
- package/dist/plugins/redis.js +1 -1
- package/dist/plugins/resource/index.js +1 -1
- package/dist/plugins/resource/resource.d.ts.map +1 -1
- package/dist/plugins/resource/resource.js +1 -1
- package/dist/plugins/resource/resource.registry.js +1 -1
- package/dist/plugins/resource/resource.types.d.ts +71 -15
- package/dist/plugins/resource/resource.types.d.ts.map +1 -1
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
- package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
- package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-file-token.js +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
- package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
- package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
- package/dist/plugins/resource/services/create-relation.d.ts +16 -0
- package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/create-relation.js +1 -0
- 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 +18 -0
- package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/delete-relation.js +1 -0
- 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 +3 -2
- package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
- package/dist/plugins/resource/services/find-one.js +1 -1
- package/dist/plugins/resource/services/find-relation.d.ts +13 -0
- package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/find-relation.js +1 -0
- package/dist/plugins/resource/services/find.d.ts.map +1 -1
- package/dist/plugins/resource/services/find.js +1 -1
- package/dist/plugins/resource/services/update-relation.d.ts +14 -0
- package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
- package/dist/plugins/resource/services/update-relation.js +1 -0
- package/dist/plugins/resource/services/update.d.ts +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.d.ts +4 -0
- package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
- package/dist/plugins/resource/utils/auto-index.js +1 -0
- package/dist/plugins/resource/utils/fields.d.ts +8 -1
- package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
- package/dist/plugins/resource/utils/fields.js +1 -1
- package/dist/plugins/resource/utils/filters.d.ts +3 -2
- package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
- package/dist/plugins/resource/utils/filters.js +1 -1
- package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
- package/dist/plugins/resource/utils/permissions.js +1 -1
- 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/shared/getIP.js +1 -1
- package/dist/type.d.ts +14 -0
- package/dist/type.d.ts.map +1 -1
- package/migrations/20260903120000_core_schema.sql +27 -21
- 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/20260905120000_add_user_foreign_keys.sql +43 -0
- package/migrations/20260907090000_core_schema.sql +32 -0
- package/package.json +93 -88
- package/dist/modules/auth/index.d.ts +0 -9
- package/dist/modules/auth/index.d.ts.map +0 -1
- package/dist/modules/auth/index.js +0 -1
- package/dist/modules/auth/services/login.d.ts +0 -10
- package/dist/modules/auth/services/login.d.ts.map +0 -1
- package/dist/modules/auth/services/login.js +0 -1
- package/dist/modules/auth/services/logout.d.ts +0 -9
- package/dist/modules/auth/services/logout.d.ts.map +0 -1
- package/dist/modules/auth/services/logout.js +0 -1
- package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
- package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
- package/dist/modules/auth/services/verifyPassword.js +0 -1
- package/dist/modules/file/index.d.ts +0 -8
- package/dist/modules/file/index.d.ts.map +0 -1
- package/dist/modules/file/index.js +0 -1
- package/dist/modules/resource/index.d.ts +0 -20
- package/dist/modules/resource/index.d.ts.map +0 -1
- package/dist/modules/resource/index.js +0 -1
- package/dist/modules/resource/services/list-children.d.ts +0 -6
- package/dist/modules/resource/services/list-children.d.ts.map +0 -1
- package/dist/modules/resource/services/list-children.js +0 -1
- package/dist/modules/system/index.d.ts +0 -13
- package/dist/modules/system/index.d.ts.map +0 -1
- package/dist/modules/system/index.js +0 -1
- package/dist/modules/utils/get-user-permissions.d.ts +0 -3
- package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
- package/dist/modules/utils/get-user-permissions.js +0 -1
|
@@ -4,11 +4,18 @@
|
|
|
4
4
|
import type { DatabaseAdapter } from "../pg.js";
|
|
5
5
|
import type { AppLogger } from "../logger/index.js";
|
|
6
6
|
import type { AuditPlugin } from "../audit/index.js";
|
|
7
|
+
import type { DictionaryPlugin } from "../dictionary.js";
|
|
8
|
+
import type { FileAdapter } from "../file.js";
|
|
7
9
|
import { User } from "../../context.js";
|
|
10
|
+
import type { AppContext } from "../../context.js";
|
|
8
11
|
export type ResourceOperation = "read" | "create" | "update" | "delete";
|
|
12
|
+
export interface ResourceJoinContract {
|
|
13
|
+
scope?: "all" | "item";
|
|
14
|
+
sql: string;
|
|
15
|
+
}
|
|
9
16
|
export interface ResourceFieldContract {
|
|
10
17
|
column?: string;
|
|
11
|
-
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid";
|
|
18
|
+
type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
|
|
12
19
|
read?: boolean;
|
|
13
20
|
write?: boolean;
|
|
14
21
|
readable?: boolean;
|
|
@@ -19,39 +26,52 @@ export interface ResourceFieldContract {
|
|
|
19
26
|
searchable?: boolean;
|
|
20
27
|
sortable?: boolean;
|
|
21
28
|
filter?: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
scope?: "all" | "item";
|
|
30
|
+
dictionary?: string;
|
|
24
31
|
lookup?: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
table: string;
|
|
33
|
+
value: string;
|
|
34
|
+
text: string;
|
|
35
|
+
fields?: string[];
|
|
29
36
|
};
|
|
37
|
+
enum?: string[] | number[];
|
|
38
|
+
minLength?: number;
|
|
39
|
+
maxLength?: number;
|
|
40
|
+
minimum?: number;
|
|
41
|
+
maximum?: number;
|
|
42
|
+
pattern?: string;
|
|
30
43
|
}
|
|
31
44
|
export interface ResourceRelationContract {
|
|
32
45
|
resource?: string;
|
|
33
46
|
table?: string;
|
|
34
|
-
|
|
47
|
+
where?: string;
|
|
48
|
+
localKey?: string;
|
|
35
49
|
foreignKey?: string;
|
|
36
|
-
|
|
50
|
+
fields?: string[];
|
|
51
|
+
junctionTable?: string;
|
|
52
|
+
junctionLocalKey?: string;
|
|
53
|
+
junctionForeignKey?: string;
|
|
37
54
|
}
|
|
38
55
|
export interface ResourceContract {
|
|
39
56
|
version: 1;
|
|
40
57
|
name: string;
|
|
41
|
-
module
|
|
58
|
+
module?: string;
|
|
42
59
|
title?: string;
|
|
43
60
|
table: string;
|
|
61
|
+
where?: string;
|
|
44
62
|
key: string;
|
|
45
63
|
operations: ResourceOperation[];
|
|
64
|
+
searchable?: string[];
|
|
46
65
|
capabilities?: string[];
|
|
47
66
|
permission?: string;
|
|
48
67
|
fields: Record<string, ResourceFieldContract>;
|
|
49
68
|
relations?: Record<string, ResourceRelationContract>;
|
|
50
|
-
|
|
69
|
+
joins?: ResourceJoinContract[];
|
|
51
70
|
access?: "public" | "user" | "admin";
|
|
52
71
|
}
|
|
53
72
|
export interface ResourceQuery {
|
|
54
73
|
filter?: Record<string, unknown>;
|
|
74
|
+
include?: string | string[];
|
|
55
75
|
sort?: string[];
|
|
56
76
|
search?: string;
|
|
57
77
|
limit?: number;
|
|
@@ -61,13 +81,17 @@ export interface ResourceQuery {
|
|
|
61
81
|
export interface ResourceListResult<T = Record<string, unknown>> {
|
|
62
82
|
rows: T[];
|
|
63
83
|
limit: number;
|
|
84
|
+
time: number;
|
|
85
|
+
total: number | null;
|
|
64
86
|
offset: number;
|
|
65
87
|
}
|
|
66
88
|
export type ResourceUser = User;
|
|
67
89
|
export interface ResourceDependencies {
|
|
68
|
-
pg: DatabaseAdapter
|
|
90
|
+
pg: DatabaseAdapter;
|
|
69
91
|
logger?: AppLogger;
|
|
70
92
|
audit?: AuditPlugin;
|
|
93
|
+
dictionary?: DictionaryPlugin;
|
|
94
|
+
file?: FileAdapter;
|
|
71
95
|
}
|
|
72
96
|
export interface ResourcePlugin {
|
|
73
97
|
register(input: ResourceContract | ResourceContract[]): void;
|
|
@@ -82,23 +106,55 @@ export interface ResourcePlugin {
|
|
|
82
106
|
findOne(params: {
|
|
83
107
|
name: string;
|
|
84
108
|
id: string | number;
|
|
109
|
+
query?: ResourceQuery;
|
|
85
110
|
user?: ResourceUser;
|
|
86
111
|
}): Promise<Record<string, unknown> | null>;
|
|
87
112
|
create(params: {
|
|
88
113
|
name: string;
|
|
89
114
|
data: Record<string, unknown>;
|
|
90
115
|
user?: ResourceUser;
|
|
91
|
-
}): Promise<Record<string, unknown>>;
|
|
116
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
92
117
|
update(params: {
|
|
93
118
|
name: string;
|
|
94
119
|
id: string | number;
|
|
95
120
|
data: Record<string, unknown>;
|
|
96
121
|
user?: ResourceUser;
|
|
97
|
-
}): Promise<Record<string, unknown>>;
|
|
122
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
98
123
|
delete(params: {
|
|
99
124
|
name: string;
|
|
100
125
|
id: string | number;
|
|
101
126
|
user?: ResourceUser;
|
|
102
|
-
}): Promise<boolean>;
|
|
127
|
+
}, ctx?: AppContext): Promise<boolean>;
|
|
128
|
+
findRelation(params: {
|
|
129
|
+
name: string;
|
|
130
|
+
id: string | number;
|
|
131
|
+
relation: string;
|
|
132
|
+
query?: ResourceQuery;
|
|
133
|
+
user?: ResourceUser;
|
|
134
|
+
}): Promise<any>;
|
|
135
|
+
createRelation(params: {
|
|
136
|
+
name: string;
|
|
137
|
+
id: string | number;
|
|
138
|
+
relation: string;
|
|
139
|
+
data?: Record<string, unknown>;
|
|
140
|
+
user?: ResourceUser;
|
|
141
|
+
}, ctx?: AppContext): Promise<any>;
|
|
142
|
+
updateRelation(params: {
|
|
143
|
+
name: string;
|
|
144
|
+
id: string | number;
|
|
145
|
+
relation: string;
|
|
146
|
+
relationId: string;
|
|
147
|
+
data: Record<string, unknown>;
|
|
148
|
+
user?: ResourceUser;
|
|
149
|
+
}, ctx?: AppContext): Promise<Record<string, unknown>>;
|
|
150
|
+
deleteRelation(params: {
|
|
151
|
+
name: string;
|
|
152
|
+
id: string | number;
|
|
153
|
+
relation: string;
|
|
154
|
+
relationId: string;
|
|
155
|
+
user?: ResourceUser;
|
|
156
|
+
}, ctx?: AppContext): Promise<{
|
|
157
|
+
success: boolean;
|
|
158
|
+
}>;
|
|
103
159
|
}
|
|
104
160
|
//# 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,K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EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addDictionaryLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], dictionary: ResourceDependencies["dictionary"]): Promise<Record<string, unknown>[]>;
|
|
3
|
+
//# sourceMappingURL=add-dictionary-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-dictionary-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-dictionary-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAsDnF,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAuBpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();function f(){const F=['set','filter','get','length','all','name','color','icon','flatMap','map'];f=function(){return F;};return f();}async function getDictionaryIndexes(I,X){const r=u,o=dictionaryIndexesCache['get'](X)??new Map(),b=dictionaryRevisionsCache['get'](X)??new Map();dictionaryIndexesCache[r(0xaf)](X,o),dictionaryRevisionsCache['set'](X,b);const A=I[r(0xb0)](p=>b[r(0xb1)](p)!==X['revision'](p));if(A[r(0xb2)]===0x0)return o;const t=await Promise[r(0xb3)](A['map'](async p=>{const B=r;if(!X['has'](p))return[p,new Map()];const V=await X['get'](p),O=new Map();for(const P of V){const M=P['code']??P['id'];if(M==null)continue;O[B(0xaf)](String(M),{'id':M,'text':P[B(0xb4)]??P['text'],...P['color']!==undefined?{'color':P[B(0xb5)]}:{},...P['icon']!==undefined?{'icon':P[B(0xb6)]}:{}});}return[p,O];}));for(const [p,V]of t){o['set'](p,V),b['set'](p,X['revision'](p));}return o;}function u(I,X){I=I-0xaf;const o=f();let b=o[I];return b;}export async function addDictionaryLookupData(I,X,o){const s=u;if(!o||I['length']===0x0)return I;const b=Object['entries'](X)[s(0xb7)](([t,p])=>{const V=p['dictionary'];return V?[{'field':t,'dictionaryName':V}]:[];});if(b['length']===0x0)return I;const A=await getDictionaryIndexes([...new Set(b[s(0xb8)](({dictionaryName:t})=>t))],o);for(const t of I){for(const {field:p,dictionaryName:V}of b){const O=t[p];t[p+'_data']=O==null?null:A['get'](V)?.['get'](String(O))??null;}}return I;}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function addFileToken(rows: Record<string, unknown>[], fields: ResourceContract["fields"], file: ResourceDependencies["file"]): Record<string, unknown>[];
|
|
3
|
+
//# sourceMappingURL=add-file-token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-file-token.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-file-token.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,wBAAgB,YAAY,CACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACnC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAiB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function u(I,X){I=I-0x162;const o=f();let b=o[I];return b;}export function addFileToken(I,X,o){const V=u;if(!o||I['length']===0x0)return I;const b=Object['entries'](X)['filter'](([,A])=>A[V(0x162)]==='file')[V(0x163)](([A])=>A);for(const A of I){for(const t of b){const p=A[t];typeof p==='string'&&p['length']>0x0&&(A[t]=o['create'](p));}}return I;}function f(){const O=['type','map'];f=function(){return O;};return f();}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResourceContract, ResourceDependencies } from "../resource.types.js";
|
|
2
|
+
export declare function clearTableLookupCache(table: string, pg: NonNullable<ResourceDependencies["pg"]>): void;
|
|
3
|
+
export declare function addTableLookupData(rows: Record<string, unknown>[], fields: ResourceContract["fields"], pg: ResourceDependencies["pg"]): Promise<Record<string, unknown>[]>;
|
|
4
|
+
//# sourceMappingURL=add-table-lookup-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{qi,qt}from'../utils/sql.js';function u(I,X){I=I-0x19a;const o=f();let b=o[I];return b;}const tableLookupCache=new WeakMap();function f(){const Y=['get','delete','set','lookup','table','map','query','SELECT\x20','text','\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'];f=function(){return Y;};return f();}export function clearTableLookupCache(I,X){const K=u,o=tableLookupCache[K(0x19a)](X);if(!o)return;for(const b of o['keys']()){b['startsWith'](I+':')&&o[K(0x19b)](b);}}export async function addTableLookupData(I,X,o){const y=u;if(!o||I['length']===0x0)return I;const b=tableLookupCache['get'](o)??new Map();tableLookupCache[y(0x19c)](o,b);const A=Object['entries'](X)['flatMap'](([t,p])=>{const c=y,{table:V,value:value='id',text:text='name'}=p[c(0x19d)]??{};return V?[{'field':t,'table':V,'value':value,'text':text}]:[];});for(const t of A){const p=new Map();for(const M of I){const r=M[t['field']];(typeof r==='string'||typeof r==='number')&&p[y(0x19c)](String(r),r);}const V=t[y(0x19e)]+':'+t['value']+':'+t['text'],O=b['get'](V)??new Map();b[y(0x19c)](V,O);const P=[...p['entries']()]['filter'](([B])=>!O['has'](B))[y(0x19f)](([,B])=>B);if(P['length']>0x0){const B=await o[y(0x1a0)](y(0x1a1)+qi(t['value'])+'\x20AS\x20id,\x20'+qi(t[y(0x1a2)])+y(0x1a3)+qt(t['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(t['value'])+'\x20=\x20ANY($1)',[P]);for(const s of B['rows']){O['set'](String(s['id']),s);}for(const F of P){!O['has'](String(F))&&O[y(0x19c)](String(F),null);}}for(const Z of I){const W=Z[t['field']];Z[t['field']+'_data']=W==null?null:O['get'](String(W))??null;}}return I;}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the create relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import { AppContext } from "../../../context.js";
|
|
7
|
+
type CreateRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
data?: Record<string, unknown>;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=create-relation.d.ts.map
|
|
@@ -0,0 +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;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,yCAIgD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,GAAG,CAAC,CA+DhI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createCreate}from'./create.js';export function createCreateRelation(I,X){const o=createCreate(I,X);return async function b({name:A,id:t,relation:p,data:V,user:O},P){const W=u,M=P?.['pg']??I['pg'],r=X['get'](A);if([W(0xa1),'files'][W(0xa2)](p)&&!r['capabilities']?.['includes'](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20capabilities\x20\x22'+p+'\x22');if(p==='notes'){const F=await M['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[A,String(t),V?.['body']]);return F[W(0xa3)][0x0];}if(p==='files'){const Z=await M['query'](W(0xa4),[A,String(t),V?.['filePath'],V?.['size']??null]);return Z['rows'][0x0];}const B=r[W(0xa5)]?.[p];if(!B?.['foreignKey']||!B['resource']&&!B['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');if(!V)throw new UnsupportedError(W(0xa6)+V);if(!B['resource'])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+p);V[B[W(0xa7)]]=t;const s=await o({'name':B['resource'],'data':V??{},'user':O});return s;};}function u(I,X){I=I-0xa1;const o=f();let b=o[I];return b;}function f(){const K=['notes','includes','rows','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*','relations','No\x20data\x20provided\x20for\x20relation:\x20','foreignKey'];f=function(){return K;};return f();}
|
|
@@ -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
|
-
|
|
1
|
+
function u(I,X){I=I-0xb7;const o=f();let b=o[I];return b;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function f(){const y=['create','fields','created_at','created_by','length','RETURNING\x20*','audit','name'];f=function(){return y;};return f();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createCreate(I,X){return async function o({name:b,data:A,user:t},p){const K=u,V=X['get'](b);assertOperation(V,K(0xb7),t),validateInputData({'resource':V,'data':A});const O=writableData(V,A);V[K(0xb8)][K(0xb9)]&&O['push'](['created_at',new Date()]);V['fields'][K(0xba)]&&O['push'](['created_by',t?.['id']]);if(!O[K(0xbb)])throw new ValidationError('No\x20writable\x20fields');const P=O['map'](([Z])=>qi(Z)),M=O['map']((Z,W)=>'$'+(W+0x1)),r=O['map'](([,Z])=>Z),B=p?.['pg']??I['pg'],s=await B['query']('INSERT\x20INTO\x20'+qt(V['table'])+'\x20('+P['join'](',\x20')+')\x20'+('VALUES\x20('+M['join'](',\x20')+')\x20')+K(0xbc),r),F=s['rows'][0x0];return clearTableLookupCache(V['table'],B),await(p?.['audit']??I[K(0xbd)])?.['write']({'userId':t?.['id'],'module':V['module'],'resource':V[K(0xbe)],'resourceId':F[V['key']],'action':'create','fields':Object['keys'](A)}),F;};}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the delete relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
import type { AppContext } from "../../../context.js";
|
|
7
|
+
type DeleteRelationParams = {
|
|
8
|
+
name: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
relation: string;
|
|
11
|
+
relationId: string | number;
|
|
12
|
+
user?: ResourceUser;
|
|
13
|
+
};
|
|
14
|
+
export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user, }: DeleteRelationParams, ctx?: AppContext) => Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=delete-relation.d.ts.map
|
|
@@ -0,0 +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;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,+CAIsD,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAqCvJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function u(I,X){I=I-0xf3;const o=f();let b=o[I];return b;}export function createDeleteRelation(I,X){const o=createRemove(I,X);return async function b({name:A,id:t,relation:p,relationId:V,user:O},P){const F=u,M=P?.['pg']??I['pg'],r=X['get'](A);if(['notes','files']['includes'](p)&&!r['capabilities']?.[F(0xf3)](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20capabilities\x20\x22'+p+'\x22');if(p==='notes')return await M[F(0xf4)]('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[V,A,String(t)]),{'success':!![]};if(p===F(0xf5))return await M['query'](F(0xf6),[V,A,String(t)]),{'success':!![]};const B=r['relations']?.[p];if(!B?.[F(0xf7)]||!B['foreignKey'])throw new UnsupportedError(F(0xf8)+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');const s=await o({'name':B['resource'],'id':V,'user':O,'where':{'column':B['foreignKey'],'value':t}},P);return{'success':s};};}function f(){const Z=['includes','query','files','DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','resource','Generic\x20Resource\x20relation\x20\x22'];f=function(){return Z;};return f();}
|
|
@@ -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;AAEhE,
|
|
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
|
+
import{assertOperation}from'../utils/permissions.js';function f(){const F=['WHERE\x20','\x20=\x20$1','\x20AND\x20','audit','name','rowCount'];f=function(){return F;};return f();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function u(I,X){I=I-0x71;const o=f();let b=o[I];return b;}export function createRemove(I,X){return async function o({name:b,id:A,user:t,where:p},V){const s=u,O=X['get'](b);assertOperation(O,'delete',t);const P=V?.['pg']??I['pg'],M=[A];let r=s(0x71)+qi(O['key'])+s(0x72);p&&(M['push'](p['value']),r+=s(0x73)+qi(p['column'])+'\x20=\x20$'+M['length']);O['where']&&(r+='\x20AND\x20('+O['where']+')');const B=await P['query']('DELETE\x20FROM\x20'+qt(O['table'])+'\x20'+r,M);if((B['rowCount']??0x0)>0x0)clearTableLookupCache(O['table'],P);if((B['rowCount']??0x0)>0x0)await(V?.[s(0x74)]??I['audit'])?.['write']({'module':O['module'],'resource':O[s(0x75)],'resourceId':A,'action':'delete'});return(B[s(0x76)]??0x0)>0x0;};}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Implements the find one operation of the generic Resource CRUD engine.
|
|
3
3
|
*/
|
|
4
|
-
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
5
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
-
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
|
|
6
|
+
export declare function createFindOne(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, query, user, }: {
|
|
7
7
|
name: string;
|
|
8
8
|
id: string | number;
|
|
9
|
+
query?: ResourceQuery;
|
|
9
10
|
user?: ResourceUser;
|
|
10
11
|
}) => Promise<Record<string, unknown> | null>;
|
|
11
12
|
//# sourceMappingURL=find-one.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAuDF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function u(I,X){I=I-0xce;const o=f();let b=o[I];return b;}import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';function f(){const D=['get','key','dictionary','fields','join','\x20WHERE\x20','\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','query','file'];f=function(){return D;};return f();}export function createFindOne(I,X){return async function o({name:b,id:A,query:query={},user:t}){const q=u,p=Date['now'](),V=X[q(0xce)](b);assertOperation(V,'read',t);if(V['fields'][V[q(0xcf)]]?.['type']==='integer'&&!Number['isInteger'](Number(A)))throw new ValidationError('Invalid\x20id:\x20'+A+'\x20name:'+b);const O=V['joins']?.['map'](s=>s['sql']+'\x20')['join']('\x20')||'',P=V['where']?'\x20AND\x20('+V['where']+')':'',M=await I['pg']['query']('SELECT\x20'+readableFields(V)['join'](',\x20')+'\x20FROM\x20'+qt(V['table'])+'\x20t\x20'+O+'\x20WHERE\x20'+qi(V[q(0xcf)])+'=$1'+P+'\x20LIMIT\x201',[A]),r=M['rows'][0x0];if(!r)return null;await addDictionaryLookupData([r],V['fields'],I[q(0xd0)]),await addTableLookupData([r],V[q(0xd1)],I['pg']),addFileToken([r],V[q(0xd1)],I['file']);const B=Array['isArray'](query['include'])?query['include']:query['include']?.['split'](',')??[];for(const s of B){const F=V['relations']?.[s];if(!F?.['foreignKey']||!F['resource']&&!F['table'])throw new ValidationError('Unknown\x20relation:\x20'+s);const Z=F['resource']?X['get'](F['resource']):undefined,W=F['table']??Z['table'],K=Z?.['key']??'id',y=Z?readableFields(Z)[q(0xd2)](',\x20'):'*',c='SELECT\x20'+y+'\x20FROM\x20'+qt(W)+q(0xd3)+qi(K)+q(0xd4)+qi(F['foreignKey'])+'\x20FROM\x20'+qt(V['table'])+q(0xd5)+qi(V[q(0xcf)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',Y=(await I['pg'][q(0xd6)](c,[A]))['rows'];Z&&(await addDictionaryLookupData(Y,Z['fields'],I['dictionary']),await addTableLookupData(Y,Z['fields'],I['pg']),addFileToken(Y,Z['fields'],I[q(0xd7)])),r[s]=Y;}return r['time']=Date['now']()-p,r;};}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Implements the find relation operation of the generic Resource CRUD engine.
|
|
3
|
+
*/
|
|
4
|
+
import type { ResourceDependencies, ResourceQuery, ResourceUser } from "../resource.types.js";
|
|
5
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
6
|
+
export declare function createFindRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, query, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
id: string | number;
|
|
9
|
+
relation: string;
|
|
10
|
+
query?: ResourceQuery;
|
|
11
|
+
user?: ResourceUser;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
//# sourceMappingURL=find-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,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,CAuGjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{UnsupportedError,ValidationError}from'../../../errors.js';function u(I,X){I=I-0x117;const o=f();let b=o[I];return b;}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function f(){const m=['now','min','max','get','relations','notes','query','rows','file','junctionTable','junctionLocalKey','localKey','resource','table','key','scope','fields','joins','map','sql','where','SELECT\x20','\x20j\x20ON\x20j.','\x0a\x20\x20\x20\x20\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','foreignKey','\x20=\x20$1','\x20FROM\x20','\x20=\x20(select\x20','\x20=\x20$1\x20limit\x201)','\x20LIMIT\x20$2\x20OFFSET\x20$3'];f=function(){return m;};return f();}import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(I,X){return async function o({name:b,id:A,relation:t,query:query={}}){const N=u,p=Date[N(0x117)](),V=Math[N(0x118)](Math['max'](query['limit']??0x14,0x1),0xc8),O=Math[N(0x119)](query['offset']??0x0,0x0);if(!Number['isFinite'](V)||!Number['isFinite'](O))throw new ValidationError('Invalid\x20pagination');const P=X[N(0x11a)](b),M=P[N(0x11b)]?.[t];if(['notes','files']['includes'](t)&&!P['capabilities']?.['includes'](t))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+t+'\x22\x20requires\x20a\x20capabilities\x20\x22'+t+'\x22');if(t===N(0x11c)){const q=await I['pg'][N(0x11d)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[b,String(A)]);return{'total':q[N(0x11e)]['length'],'time':Date['now']()-p,'rows':q['rows']};}if(t==='files'){const D=await I['pg'][N(0x11d)]('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[b,String(A)]);return addFileToken(D[N(0x11e)],{'file_path':{'type':'file'}},I[N(0x11f)]),{'total':D['rows']['length'],'time':Date['now']()-p,'rows':D['rows']};}const r=!!(M?.[N(0x120)]&&M[N(0x121)]&&M['junctionForeignKey']);if(!M||!r&&!M['foreignKey']&&!M[N(0x122)]||!M[N(0x123)]&&!M['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+t+'\x22\x20requires\x20a\x20project/provider\x20implementation');const B=M['resource']?X[N(0x11a)](M['resource']):undefined,s=M[N(0x124)]??B['table'],F=B?.[N(0x125)]??'id',Z=!r&&Object['keys'](B?.['fields']??{})['filter'](d=>B?.['fields'][d]?.['read']&&B?.['fields'][d]?.[N(0x126)]!=='item')['map'](qi)['join'](',\x20'),W=M[N(0x127)]?.['join'](',\x20')||Z||'*';M['foreignKey']&&autoIndex(s,M['foreignKey'],'btree',I['pg']);const K=B?.[N(0x128)]?.['filter'](d=>d['scope']!=='item')[N(0x129)](d=>d[N(0x12a)]+'\x20')['join']('\x20')||'',y=M[N(0x12b)]?'\x20AND\x20('+M[N(0x12b)]+')':'',c=(r?N(0x12c)+W+'\x20FROM\x20'+qt(s)+'\x20t\x20'+K+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20JOIN\x20'+qt(M['junctionTable'])+N(0x12d)+qi(M['junctionForeignKey'])+'\x20=\x20t.'+qi(F)+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20j.'+qi(M['junctionLocalKey'])+'\x20=\x20$1'+y+N(0x12e):'')||(M['foreignKey']?'SELECT\x20'+W+'\x20FROM\x20'+qt(s)+'\x20t\x20'+K+'\x20WHERE\x20t.'+qi(M[N(0x12f)])+N(0x130)+y+'\x20LIMIT\x20$2\x20OFFSET\x20$3':'SELECT\x20'+W+N(0x131)+qt(s)+'\x20t\x20'+K+'\x20WHERE\x20t.'+qi(M['foreignKey']||F)+N(0x132)+qi(M[N(0x122)])+N(0x131)+qt(P[N(0x124)])+'\x20where\x20'+qi(P['key'])+N(0x133)+y+N(0x134)),Y=await I['pg']['query'](c,[A,V,O]);return B&&(await addDictionaryLookupData(Y['rows'],B['fields'],I['dictionary']),await addTableLookupData(Y['rows'],B[N(0x127)],I['pg']),addFileToken(Y[N(0x11e)],B['fields'],I['file'])),{'limit':V,'offset':O,'total':Y['rows']['length'],'time':Date['now']()-p,'rows':Y[N(0x11e)]??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;AAMhE,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,CAmDhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';function f(){const y=['read','min','limit','\x20AND\x20','sort','filter','fields','values','push','search','map','join','SELECT\x20','FROM\x20','\x20t\x20','LIMIT\x20$','dictionary'];f=function(){return y;};return f();}import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function u(I,X){I=I-0x1dc;const o=f();let b=o[I];return b;}import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFind(I,X){return async function o({name:b,query:query={},user:A}){const K=u,t=Date['now'](),p=X['get'](b);assertOperation(p,K(0x1dc),A);const V=Math[K(0x1dd)](Math['max'](query[K(0x1de)]??0x14,0x1),0xc8),O=Math['max'](query['offset']??0x0,0x0),P=buildFilters(p,query['filter'],0x1,I['pg']);p['where']&&(P['sql']+=(P['sql']?K(0x1df):'\x20WHERE\x20')+('('+p['where']+')'));const M=buildSort(p,query[K(0x1e0)]);if(!Number['isFinite'](V)||!Number['isFinite'](O))throw new ValidationError('Invalid\x20pagination');const r=p['searchable']||Object['keys'](p['fields'])[K(0x1e1)](W=>p[K(0x1e2)][W]?.['searchable']);query['search']&&r['length']&&(r['map'](W=>autoIndex(p['table'],W,'text',I['pg'])),P[K(0x1e3)][K(0x1e4)](query[K(0x1e5)]['toLowerCase']()+'%'),P['sql']+=(P['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+r?.[K(0x1e6)](W=>'lower('+qt(W)+')\x20LIKE\x20$'+P['values']['length'])[K(0x1e7)]('\x20OR\x20')+')'));const B=p['joins']?.[K(0x1e1)](W=>W['scope']!=='item')['map'](W=>W['sql']+'\x20')['join']('\x20')||'',s=K(0x1e8)+readableFields(p,'all')['join'](',\x20')+'\x20'+(K(0x1e9)+qt(p['table'])+K(0x1ea))+(B+'\x20'+P['sql']+'\x20'+M+'\x20')+(K(0x1eb)+(P[K(0x1e3)]['length']+0x1)+'\x20')+('OFFSET\x20$'+(P['values']['length']+0x2)),F=await I['pg']['query'](s,[...P['values'],V,O]),Z=F['rows'];return await addDictionaryLookupData(Z,p['fields'],I[K(0x1ec)]),await addTableLookupData(Z,p[K(0x1e2)],I['pg']),addFileToken(Z,p['fields'],I['file']),{'limit':V,'offset':O,'total':F['rowCount'],'time':Date['now']()-t,'rows':Z};};}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
|
+
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
+
import type { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateRelationParams = {
|
|
5
|
+
name: string;
|
|
6
|
+
id: string | number;
|
|
7
|
+
relation: string;
|
|
8
|
+
relationId: string | number;
|
|
9
|
+
data: Record<string, unknown>;
|
|
10
|
+
user?: ResourceUser;
|
|
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 {};
|
|
14
|
+
//# sourceMappingURL=update-relation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function u(I,X){I=I-0x17d;const o=f();let b=o[I];return b;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function f(){const F=['relations','foreignKey'];f=function(){return F;};return f();}export function createUpdateRelation(I,X){const o=createUpdate(I,X);return async function b({name:A,id:t,relation:p,relationId:V,data:O,user:P},M){const s=u,r=X['get'](A),B=r[s(0x17d)]?.[p];if(!B?.['resource']||!B[s(0x17e)])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+p);if(Object['hasOwn'](O,B['foreignKey'])&&O[B[s(0x17e)]]!==t)throw new ValidationError('Cannot\x20change\x20relation:\x20'+B['foreignKey']);return o({'name':B['resource'],'id':V,'data':O,'user':P,'where':{'column':B['foreignKey'],'value':t}},M);};}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
|
|
2
2
|
import type { ResourceRegistry } from "../resource.registry.js";
|
|
3
|
-
|
|
3
|
+
import { AppContext } from "../../../context.js";
|
|
4
|
+
type UpdateParams = {
|
|
4
5
|
name: string;
|
|
5
6
|
id: string | number;
|
|
6
7
|
data: Record<string, unknown>;
|
|
7
8
|
user?: ResourceUser;
|
|
8
|
-
|
|
9
|
+
where?: {
|
|
10
|
+
column: string;
|
|
11
|
+
value: string | number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, where, }: UpdateParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
|
|
15
|
+
export {};
|
|
9
16
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,sCAEqC,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2DjI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function f(){const Y=['get','length','No\x20writable\x20fields','fields','updated_at','push','map','WHERE\x20','\x20=\x20$','\x20AND\x20','where','RETURNING\x20','audit'];f=function(){return Y;};return f();}import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,writableData}from'../utils/sql.js';function u(I,X){I=I-0x164;const o=f();let b=o[I];return b;}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createUpdate(I,X){return async function o({name:b,id:A,data:t,user:p,where:V},O){const c=u,P=X[c(0x164)](b);assertOperation(P,'update',p);const M=writableData(P,t);if(!M[c(0x165)])throw new ValidationError(c(0x166));const r=O?.['pg']??I['pg'];validateInputData({'resource':P,'data':t,'update':!![]});P[c(0x167)][c(0x168)]&&M[c(0x169)](['updated_at',new Date()]);P['fields']['updated_by']&&M[c(0x169)](['updated_by',p?.['id']]);delete t['user_type'];const B=M[c(0x16a)](([K],y)=>qi(K)+'\x20=\x20$'+(y+0x1)),s=[...M['map'](([,K])=>K),A];let F=c(0x16b)+qi(P['key'])+c(0x16c)+s['length'];V&&(s['push'](V['value']),F+=c(0x16d)+qi(V['column'])+c(0x16c)+s['length']);P[c(0x16e)]&&(F+='\x20AND\x20('+P['where']+')');const Z=await r['query']('UPDATE\x20'+qt(P['table'])+'\x20'+('SET\x20'+B['join'](',\x20')+'\x20')+(F+'\x20')+(c(0x16f)+Object['keys'](t)['map'](qi)['join'](',\x20')),s),W=Z['rows'][0x0];if(!W)throw new NotFoundError(b+':'+A);return clearTableLookupCache(P['table'],r),await(O?.[c(0x170)]??I['audit'])?.['write']({'userId':p?.['id'],'module':P['module'],'resource':P['name'],'resourceId':A,'action':'update','fields':Object['keys'](t)}),W;};}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DatabaseAdapter } from "../../pg.js";
|
|
2
|
+
export type AutoIndexType = "text" | "btree" | "gist";
|
|
3
|
+
export declare function autoIndex(table: string, column: string, type: AutoIndexType | undefined, pg: DatabaseAdapter): void;
|
|
4
|
+
//# sourceMappingURL=auto-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/utils/auto-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AAItD,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,aAAa,YAAU,EAC7B,EAAE,EAAE,eAAe,GACpB,IAAI,CAWN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const O=u;import{qi,qt}from'./sql.js';function u(I,X){I=I-0x98;const o=f();let b=o[I];return b;}const requestedIndexes=new WeakMap();export function autoIndex(I,X,o=O(0x98),b){const P=O,A=requestedIndexes['get'](b)??new Set();requestedIndexes[P(0x99)](b,A);const t=I+':'+X+':'+o;if(A['has'](t))return;A['add'](t),void ensureIndex(I,X,o,b)['catch'](()=>{A['delete'](t);});}function f(){const r=['btree','set','split','query'];f=function(){return r;};return f();}async function ensureIndex(I,X,o,b){const M=O,A=I[M(0x9a)]('.'),t=A['length']===0x2?A[0x0]:'public',p=(I+'_'+X+'_'+o+'_idx')['replace'](/[^A-Za-z0-9_]/g,'_'),V=await b[M(0x9b)]('SELECT\x201\x20FROM\x20pg_indexes\x20WHERE\x20schemaname\x20=\x20$1\x20AND\x20indexname\x20=\x20$2',[t,p]);if(V['rowCount'])return;if(o==='text'){await b['query']('CREATE\x20EXTENSION\x20IF\x20NOT\x20EXISTS\x20pg_trgm'),await b[M(0x9b)]('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(p+'_l')+'\x20ON\x20'+qt(I)+'\x20USING\x20btree\x20(lower('+qi(X)+')\x20text_pattern_ops)'),await b['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(p)+'\x20ON\x20'+qt(I)+'\x20USING\x20gin\x20(lower('+qi(X)+')\x20gin_trgm_ops)');return;}await b['query']('CREATE\x20INDEX\x20IF\x20NOT\x20EXISTS\x20'+qi(p)+'\x20ON\x20'+qt(I)+'\x20USING\x20'+o+'\x20('+qi(X)+')');}
|