@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.
Files changed (248) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.d.ts +2 -10
  4. package/dist/config.d.ts.map +1 -1
  5. package/dist/config.js +1 -1
  6. package/dist/context.js +1 -1
  7. package/dist/errors.js +1 -1
  8. package/dist/fastify.d.ts +2 -5
  9. package/dist/fastify.d.ts.map +1 -1
  10. package/dist/fastify.js +1 -1
  11. package/dist/fcore.js +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/migrations/cli.js +1 -1
  14. package/dist/migrations/runner.js +1 -1
  15. package/dist/modules/auth/adduser-cli.d.ts +3 -0
  16. package/dist/modules/auth/adduser-cli.d.ts.map +1 -0
  17. package/dist/modules/auth/adduser-cli.js +2 -0
  18. package/dist/modules/auth/passwd-cli.d.ts +3 -0
  19. package/dist/modules/auth/passwd-cli.d.ts.map +1 -0
  20. package/dist/modules/auth/passwd-cli.js +2 -0
  21. package/dist/modules/auth/permission-cli.d.ts +3 -0
  22. package/dist/modules/auth/permission-cli.d.ts.map +1 -0
  23. package/dist/modules/auth/permission-cli.js +2 -0
  24. package/dist/modules/auth/route.d.ts.map +1 -1
  25. package/dist/modules/auth/route.js +1 -1
  26. package/dist/modules/auth/schema.d.ts +10 -1
  27. package/dist/modules/auth/schema.d.ts.map +1 -1
  28. package/dist/modules/auth/schema.js +1 -1
  29. package/dist/modules/auth/services/change-password.d.ts +9 -0
  30. package/dist/modules/auth/services/change-password.d.ts.map +1 -0
  31. package/dist/modules/auth/services/change-password.js +1 -0
  32. package/dist/modules/auth/services/get-current-user.d.ts +1 -0
  33. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  34. package/dist/modules/auth/services/get-current-user.js +1 -1
  35. package/dist/modules/auth/services/registration.d.ts +14 -0
  36. package/dist/modules/auth/services/registration.d.ts.map +1 -0
  37. package/dist/modules/auth/services/registration.js +1 -0
  38. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  39. package/dist/modules/file/mime.d.ts +3 -0
  40. package/dist/modules/file/mime.d.ts.map +1 -0
  41. package/dist/modules/file/mime.js +1 -0
  42. package/dist/modules/file/route.d.ts.map +1 -1
  43. package/dist/modules/file/route.js +1 -1
  44. package/dist/modules/file/schema.d.ts +3 -0
  45. package/dist/modules/file/schema.d.ts.map +1 -1
  46. package/dist/modules/file/schema.js +1 -1
  47. package/dist/modules/file/services/get-file.js +1 -1
  48. package/dist/modules/file/services/resize-file.d.ts.map +1 -1
  49. package/dist/modules/file/services/resize-file.js +1 -1
  50. package/dist/modules/file/services/upload-file.d.ts +4 -6
  51. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  52. package/dist/modules/file/services/upload-file.js +1 -1
  53. package/dist/modules/resource/route.d.ts +0 -3
  54. package/dist/modules/resource/route.d.ts.map +1 -1
  55. package/dist/modules/resource/route.js +1 -1
  56. package/dist/modules/resource/schema.d.ts +3 -0
  57. package/dist/modules/resource/schema.d.ts.map +1 -1
  58. package/dist/modules/resource/schema.js +1 -1
  59. package/dist/modules/resource/services/add-note.js +1 -1
  60. package/dist/modules/resource/services/add-resource-file.js +1 -1
  61. package/dist/modules/resource/services/create-resource-relation.d.ts +8 -2
  62. package/dist/modules/resource/services/create-resource-relation.d.ts.map +1 -1
  63. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  64. package/dist/modules/resource/services/create-resource.js +1 -1
  65. package/dist/modules/resource/services/delete-resource-relation.d.ts +8 -1
  66. package/dist/modules/resource/services/delete-resource-relation.d.ts.map +1 -1
  67. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  68. package/dist/modules/resource/services/delete-resource.js +1 -1
  69. package/dist/modules/resource/services/export-resource.d.ts.map +1 -1
  70. package/dist/modules/resource/services/export-resource.js +1 -1
  71. package/dist/modules/resource/services/get-resource.d.ts.map +1 -1
  72. package/dist/modules/resource/services/get-resource.js +1 -1
  73. package/dist/modules/resource/services/list-resource-relation.d.ts +9 -2
  74. package/dist/modules/resource/services/list-resource-relation.d.ts.map +1 -1
  75. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  76. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  77. package/dist/modules/resource/services/list-resources.js +1 -1
  78. package/dist/modules/resource/services/search-resource.d.ts.map +1 -1
  79. package/dist/modules/resource/services/search-resource.js +1 -1
  80. package/dist/modules/resource/services/suggest-resource.d.ts +10 -4
  81. package/dist/modules/resource/services/suggest-resource.d.ts.map +1 -1
  82. package/dist/modules/resource/services/suggest-resource.js +1 -1
  83. package/dist/modules/resource/services/update-resource-relation.d.ts +10 -0
  84. package/dist/modules/resource/services/update-resource-relation.d.ts.map +1 -0
  85. package/dist/modules/resource/services/update-resource-relation.js +1 -0
  86. package/dist/modules/resource/services/update-resource.js +1 -1
  87. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  88. package/dist/modules/system/route.d.ts +2 -1
  89. package/dist/modules/system/route.d.ts.map +1 -1
  90. package/dist/modules/system/route.js +1 -1
  91. package/dist/modules/system/schema.d.ts +23 -1
  92. package/dist/modules/system/schema.d.ts.map +1 -1
  93. package/dist/modules/system/schema.js +1 -1
  94. package/dist/modules/system/services/check-system.d.ts.map +1 -1
  95. package/dist/modules/system/services/check-system.js +1 -1
  96. package/dist/modules/system/services/get-access.d.ts +15 -0
  97. package/dist/modules/system/services/get-access.d.ts.map +1 -0
  98. package/dist/modules/system/services/get-access.js +1 -0
  99. package/dist/modules/system/services/get-api-list.d.ts +4 -1
  100. package/dist/modules/system/services/get-api-list.d.ts.map +1 -1
  101. package/dist/modules/system/services/get-api-list.js +1 -1
  102. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  103. package/dist/modules/system/services/get-audit-log.js +1 -1
  104. package/dist/modules/system/services/get-dictionary.js +1 -1
  105. package/dist/modules/system/services/get-system-log.d.ts +9 -5
  106. package/dist/modules/system/services/get-system-log.d.ts.map +1 -1
  107. package/dist/modules/system/services/get-system-log.js +1 -1
  108. package/dist/modules/system/services/get-system-settings.d.ts.map +1 -1
  109. package/dist/modules/system/services/get-system-settings.js +1 -1
  110. package/dist/modules/system/services/list-dictionaries.js +1 -1
  111. package/dist/modules/system/services/set-access.d.ts +17 -0
  112. package/dist/modules/system/services/set-access.d.ts.map +1 -0
  113. package/dist/modules/system/services/set-access.js +1 -0
  114. package/dist/modules/system/services/update-dictionary.d.ts +13 -0
  115. package/dist/modules/system/services/update-dictionary.d.ts.map +1 -0
  116. package/dist/modules/system/services/update-dictionary.js +1 -0
  117. package/dist/modules/system/services/update-system-settings.d.ts.map +1 -1
  118. package/dist/modules/system/services/update-system-settings.js +1 -1
  119. package/dist/modules/utils/require-admin.js +1 -1
  120. package/dist/modules/utils/safe-user.js +1 -1
  121. package/dist/modules/utils/unsupported.js +1 -1
  122. package/dist/plugins/audit/audit.js +1 -1
  123. package/dist/plugins/audit/audit.types.d.ts +1 -1
  124. package/dist/plugins/audit/audit.types.d.ts.map +1 -1
  125. package/dist/plugins/audit/index.js +1 -1
  126. package/dist/plugins/audit/services/write-audit.js +1 -1
  127. package/dist/plugins/auth/get-user-permissions.d.ts +3 -0
  128. package/dist/plugins/auth/get-user-permissions.d.ts.map +1 -0
  129. package/dist/plugins/auth/get-user-permissions.js +1 -0
  130. package/dist/plugins/auth/index.d.ts +4 -0
  131. package/dist/plugins/auth/index.d.ts.map +1 -1
  132. package/dist/plugins/auth/index.js +1 -1
  133. package/dist/plugins/auth/verifyUser.d.ts +9 -0
  134. package/dist/plugins/auth/verifyUser.d.ts.map +1 -0
  135. package/dist/plugins/auth/verifyUser.js +1 -0
  136. package/dist/plugins/dictionary.d.ts +3 -0
  137. package/dist/plugins/dictionary.d.ts.map +1 -1
  138. package/dist/plugins/dictionary.js +1 -1
  139. package/dist/plugins/file.d.ts +3 -6
  140. package/dist/plugins/file.d.ts.map +1 -1
  141. package/dist/plugins/file.js +1 -1
  142. package/dist/plugins/index.d.ts +2 -0
  143. package/dist/plugins/index.d.ts.map +1 -1
  144. package/dist/plugins/index.js +1 -1
  145. package/dist/plugins/jwt.d.ts +4 -0
  146. package/dist/plugins/jwt.d.ts.map +1 -0
  147. package/dist/plugins/jwt.js +1 -0
  148. package/dist/plugins/logger/index.js +1 -1
  149. package/dist/plugins/logger/transport.js +1 -1
  150. package/dist/plugins/pg.d.ts +4 -2
  151. package/dist/plugins/pg.d.ts.map +1 -1
  152. package/dist/plugins/pg.js +1 -1
  153. package/dist/plugins/redis.js +1 -1
  154. package/dist/plugins/resource/index.js +1 -1
  155. package/dist/plugins/resource/resource.d.ts.map +1 -1
  156. package/dist/plugins/resource/resource.js +1 -1
  157. package/dist/plugins/resource/resource.registry.js +1 -1
  158. package/dist/plugins/resource/resource.types.d.ts +71 -15
  159. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  160. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts +3 -0
  161. package/dist/plugins/resource/services/add-dictionary-lookup-data.d.ts.map +1 -0
  162. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -0
  163. package/dist/plugins/resource/services/add-file-token.d.ts +3 -0
  164. package/dist/plugins/resource/services/add-file-token.d.ts.map +1 -0
  165. package/dist/plugins/resource/services/add-file-token.js +1 -0
  166. package/dist/plugins/resource/services/add-table-lookup-data.d.ts +4 -0
  167. package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -0
  168. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -0
  169. package/dist/plugins/resource/services/create-relation.d.ts +16 -0
  170. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -0
  171. package/dist/plugins/resource/services/create-relation.js +1 -0
  172. package/dist/plugins/resource/services/create.d.ts +5 -2
  173. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  174. package/dist/plugins/resource/services/create.js +1 -1
  175. package/dist/plugins/resource/services/delete-relation.d.ts +18 -0
  176. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -0
  177. package/dist/plugins/resource/services/delete-relation.js +1 -0
  178. package/dist/plugins/resource/services/delete.d.ts +9 -2
  179. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  180. package/dist/plugins/resource/services/delete.js +1 -1
  181. package/dist/plugins/resource/services/find-one.d.ts +3 -2
  182. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  183. package/dist/plugins/resource/services/find-one.js +1 -1
  184. package/dist/plugins/resource/services/find-relation.d.ts +13 -0
  185. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -0
  186. package/dist/plugins/resource/services/find-relation.js +1 -0
  187. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  188. package/dist/plugins/resource/services/find.js +1 -1
  189. package/dist/plugins/resource/services/update-relation.d.ts +14 -0
  190. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -0
  191. package/dist/plugins/resource/services/update-relation.js +1 -0
  192. package/dist/plugins/resource/services/update.d.ts +9 -2
  193. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  194. package/dist/plugins/resource/services/update.js +1 -1
  195. package/dist/plugins/resource/utils/auto-index.d.ts +4 -0
  196. package/dist/plugins/resource/utils/auto-index.d.ts.map +1 -0
  197. package/dist/plugins/resource/utils/auto-index.js +1 -0
  198. package/dist/plugins/resource/utils/fields.d.ts +8 -1
  199. package/dist/plugins/resource/utils/fields.d.ts.map +1 -1
  200. package/dist/plugins/resource/utils/fields.js +1 -1
  201. package/dist/plugins/resource/utils/filters.d.ts +3 -2
  202. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  203. package/dist/plugins/resource/utils/filters.js +1 -1
  204. package/dist/plugins/resource/utils/permissions.d.ts.map +1 -1
  205. package/dist/plugins/resource/utils/permissions.js +1 -1
  206. package/dist/plugins/resource/utils/sort.d.ts +1 -1
  207. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  208. package/dist/plugins/resource/utils/sort.js +1 -1
  209. package/dist/plugins/resource/utils/sql.d.ts +1 -1
  210. package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
  211. package/dist/plugins/resource/utils/sql.js +1 -1
  212. package/dist/shared/getIP.js +1 -1
  213. package/dist/type.d.ts +14 -0
  214. package/dist/type.d.ts.map +1 -1
  215. package/migrations/20260903120000_core_schema.sql +27 -21
  216. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  217. package/migrations/20260903130001_add_file_fields.sql +5 -0
  218. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  219. package/migrations/20260905120000_add_user_foreign_keys.sql +43 -0
  220. package/migrations/20260907090000_core_schema.sql +32 -0
  221. package/package.json +93 -88
  222. package/dist/modules/auth/index.d.ts +0 -9
  223. package/dist/modules/auth/index.d.ts.map +0 -1
  224. package/dist/modules/auth/index.js +0 -1
  225. package/dist/modules/auth/services/login.d.ts +0 -10
  226. package/dist/modules/auth/services/login.d.ts.map +0 -1
  227. package/dist/modules/auth/services/login.js +0 -1
  228. package/dist/modules/auth/services/logout.d.ts +0 -9
  229. package/dist/modules/auth/services/logout.d.ts.map +0 -1
  230. package/dist/modules/auth/services/logout.js +0 -1
  231. package/dist/modules/auth/services/verifyPassword.d.ts +0 -11
  232. package/dist/modules/auth/services/verifyPassword.d.ts.map +0 -1
  233. package/dist/modules/auth/services/verifyPassword.js +0 -1
  234. package/dist/modules/file/index.d.ts +0 -8
  235. package/dist/modules/file/index.d.ts.map +0 -1
  236. package/dist/modules/file/index.js +0 -1
  237. package/dist/modules/resource/index.d.ts +0 -20
  238. package/dist/modules/resource/index.d.ts.map +0 -1
  239. package/dist/modules/resource/index.js +0 -1
  240. package/dist/modules/resource/services/list-children.d.ts +0 -6
  241. package/dist/modules/resource/services/list-children.d.ts.map +0 -1
  242. package/dist/modules/resource/services/list-children.js +0 -1
  243. package/dist/modules/system/index.d.ts +0 -13
  244. package/dist/modules/system/index.d.ts.map +0 -1
  245. package/dist/modules/system/index.js +0 -1
  246. package/dist/modules/utils/get-user-permissions.d.ts +0 -3
  247. package/dist/modules/utils/get-user-permissions.d.ts.map +0 -1
  248. 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
- sort?: boolean;
23
- search?: boolean;
29
+ scope?: "all" | "item";
30
+ dictionary?: string;
24
31
  lookup?: {
25
- dictionary?: string;
26
- table?: string;
27
- valueField?: string;
28
- textField?: string;
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
- sourceField?: string;
47
+ where?: string;
48
+ localKey?: string;
35
49
  foreignKey?: string;
36
- targetField?: string;
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: string;
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
- children?: Record<string, ResourceRelationContract>;
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 | null;
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,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,qBAAqB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;IACrG,IAAI,CA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AAC,EAAE,aAAa,CAAC;QACtB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjB,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD,cAAc,CAAC,MAAM,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,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
- export declare function createCreate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, data, user, }: {
3
+ import { AppContext } from "../../../context.js";
4
+ type CreateParams = {
4
5
  name: string;
5
6
  data: Record<string, unknown>;
6
7
  user?: ResourceUser;
7
- }) => Promise<Record<string, unknown>>;
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;AAIhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA8CrC"}
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
- (function(_0x1377af,_0x4e374f){const _0x1e5d01=_0xf5af,_0x3e6076=_0x1377af();while(!![]){try{const _0x48e856=-parseInt(_0x1e5d01(0x15b))/0x1+-parseInt(_0x1e5d01(0x165))/0x2+parseInt(_0x1e5d01(0x15c))/0x3*(-parseInt(_0x1e5d01(0x166))/0x4)+parseInt(_0x1e5d01(0x157))/0x5+-parseInt(_0x1e5d01(0x169))/0x6+parseInt(_0x1e5d01(0x17a))/0x7+parseInt(_0x1e5d01(0x158))/0x8;if(_0x48e856===_0x4e374f)break;else _0x3e6076['push'](_0x3e6076['shift']());}catch(_0x397db3){_0x3e6076['push'](_0x3e6076['shift']());}}}(_0x616c,0x2400d));import{ValidationError}from'../../../errors.js';function _0xf5af(_0x4567b1,_0x3050e7){_0x4567b1=_0x4567b1-0x157;const _0x616c8e=_0x616c();let _0xf5af09=_0x616c8e[_0x4567b1];return _0xf5af09;}function _0x616c(){const _0x23d755=['No\x20writable\x20fields','1688472OAIrBg','writable','keys','table','required','empty\x20pg','hvaBl','RETURNING\x20','audit','INSERT\x20INTO\x20','create','VALUES\x20(','key','write','length','ubKxd','eRPkQ','524874CZdDvm','Required\x20field:\x20','Tdkxf','fields','hdiMm','1293495xgEsqL','3272344qDfcYj','GGCTh','rows','104649SpTJSH','17301KqMJUZ','entries','name','get','slZSO','XWHzB','join','module','map','83902yydgBZ','116msNofH','query'];_0x616c=function(){return _0x23d755;};return _0x616c();}import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';export function createCreate(_0x4572e6,_0x29cf4b){const _0x5c7f1f=_0xf5af,_0x1327fa={'slZSO':function(_0x499456,_0x5285e3,_0x341ca2,_0x3cb90e){return _0x499456(_0x5285e3,_0x341ca2,_0x3cb90e);},'hdiMm':function(_0xb46883,_0x54142a){return _0xb46883===_0x54142a;},'ubKxd':function(_0x237f6d,_0x1a015e,_0x810683){return _0x237f6d(_0x1a015e,_0x810683);},'hvaBl':_0x5c7f1f(0x16e),'XWHzB':function(_0x54d03e,_0x45ffef){return _0x54d03e+_0x45ffef;},'GGCTh':function(_0x2d6e20,_0x3443f4){return _0x2d6e20+_0x3443f4;},'eRPkQ':function(_0x1aa97d,_0x286a71){return _0x1aa97d(_0x286a71);},'Tdkxf':function(_0xcdeed0,_0x42b109){return _0xcdeed0(_0x42b109);}};return async function _0x1719dd({name:_0xc87918,data:_0x450e48,user:_0x206139}){const _0xe1cabd=_0x5c7f1f,_0x1e0b2f=_0x29cf4b[_0xe1cabd(0x15f)](_0xc87918);_0x1327fa[_0xe1cabd(0x160)](assertOperation,_0x1e0b2f,_0xe1cabd(0x173),_0x206139);for(const [_0x57fadb,_0x5cce99]of Object[_0xe1cabd(0x15d)](_0x1e0b2f[_0xe1cabd(0x17d)])){if(_0x5cce99[_0xe1cabd(0x16d)]&&_0x5cce99[_0xe1cabd(0x16a)]!==![]&&_0x1327fa[_0xe1cabd(0x17e)](_0x450e48[_0x57fadb],undefined))throw new ValidationError(_0xe1cabd(0x17b)+_0x57fadb);}const _0x514907=_0x1327fa[_0xe1cabd(0x178)](writableData,_0x1e0b2f,_0x450e48);if(!_0x514907[_0xe1cabd(0x177)])throw new ValidationError(_0xe1cabd(0x168));const _0x24ac2b=_0x514907[_0xe1cabd(0x164)](([_0x3410d])=>qi(_0x3410d)),_0x3b884c=_0x514907[_0xe1cabd(0x164)]((_0x42ac21,_0x187e38)=>'$'+(_0x187e38+0x1)),_0x54724d=_0x514907[_0xe1cabd(0x164)](([,_0x3e62b5])=>_0x3e62b5);if(!_0x4572e6['pg'])throw new Error(_0x1327fa[_0xe1cabd(0x16f)]);const _0x4e7c3d=await _0x4572e6['pg'][_0xe1cabd(0x167)](_0x1327fa[_0xe1cabd(0x161)](_0x1327fa[_0xe1cabd(0x159)](_0xe1cabd(0x172)+_0x1327fa[_0xe1cabd(0x179)](qt,_0x1e0b2f[_0xe1cabd(0x16c)])+'\x20('+_0x24ac2b[_0xe1cabd(0x162)](',\x20')+')\x20',_0xe1cabd(0x174)+_0x3b884c[_0xe1cabd(0x162)](',\x20')+')\x20'),_0xe1cabd(0x170)+_0x1327fa[_0xe1cabd(0x17c)](readableFields,_0x1e0b2f)[_0xe1cabd(0x162)](',\x20')),_0x54724d),_0x4efc23=_0x4e7c3d[_0xe1cabd(0x15a)][0x0];return await _0x4572e6[_0xe1cabd(0x171)]?.[_0xe1cabd(0x176)]({'userId':_0x206139?.['id'],'module':_0x1e0b2f[_0xe1cabd(0x163)],'resource':_0x1e0b2f[_0xe1cabd(0x15e)],'resourceId':_0x4efc23[_0x1e0b2f[_0xe1cabd(0x175)]],'action':_0xe1cabd(0x173),'fields':Object[_0xe1cabd(0x16b)](_0x450e48)}),_0x4efc23;};}
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
- export declare function createRemove(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, user, }: {
6
+ import { AppContext } from "../../../context.js";
7
+ type RemoveParams = {
7
8
  name: string;
8
9
  id: string | number;
9
10
  user?: ResourceUser;
10
- }) => Promise<boolean>;
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,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,sBAuBF"}
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
- function _0x360c(_0x31788e,_0x2dfded){_0x31788e=_0x31788e-0x74;const _0x5078bb=_0x5078();let _0x360cdd=_0x5078bb[_0x31788e];return _0x360cdd;}function _0x5078(){const _0x544ecb=['2020370aFRVHz','action','module','key','=$1','name','325969NfFWiu','delete','1203336sYQqgs','resource','resourceId','1852210zmpnXb','\x20WHERE\x20','write','VDSes','40234PMcptm','audit','15HHeuSB','get','query','yKTKt','SZTRe','OUSxV','table','30SMMByg','jRzpB','empty\x20pg','rowCount','1246143PEnJcR','DELETE\x20FROM\x20','18TuNPmZ','11RVZIBE','159612nNMesQ'];_0x5078=function(){return _0x544ecb;};return _0x5078();}(function(_0x5175ce,_0x280e7b){const _0x3d0960=_0x360c,_0x45dcdf=_0x5175ce();while(!![]){try{const _0x133337=-parseInt(_0x3d0960(0x7f))/0x1*(parseInt(_0x3d0960(0x90))/0x2)+parseInt(_0x3d0960(0x7c))/0x3+-parseInt(_0x3d0960(0x80))/0x4*(-parseInt(_0x3d0960(0x92))/0x5)+parseInt(_0x3d0960(0x78))/0x6*(parseInt(_0x3d0960(0x87))/0x7)+-parseInt(_0x3d0960(0x89))/0x8+-parseInt(_0x3d0960(0x7e))/0x9*(parseInt(_0x3d0960(0x8c))/0xa)+parseInt(_0x3d0960(0x81))/0xb;if(_0x133337===_0x280e7b)break;else _0x45dcdf['push'](_0x45dcdf['shift']());}catch(_0x84e3ad){_0x45dcdf['push'](_0x45dcdf['shift']());}}}(_0x5078,0x33229));import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';export function createRemove(_0x453d8e,_0x4e3002){const _0x3779c1=_0x360c,_0x400e31={'SZTRe':function(_0x1f6b1a,_0x30a2c5,_0x9c3db7,_0x10cdad){return _0x1f6b1a(_0x30a2c5,_0x9c3db7,_0x10cdad);},'VDSes':_0x3779c1(0x88),'jRzpB':_0x3779c1(0x7a),'yKTKt':function(_0x59674a,_0x48a7a0){return _0x59674a(_0x48a7a0);},'OUSxV':function(_0x111e8d,_0x5138a2){return _0x111e8d>_0x5138a2;}};return async function _0x16d9dc({name:_0x11989f,id:_0x31b209,user:_0x58379b}){const _0x4de63e=_0x3779c1,_0x481772=_0x4e3002[_0x4de63e(0x93)](_0x11989f);_0x400e31[_0x4de63e(0x75)](assertOperation,_0x481772,_0x400e31[_0x4de63e(0x8f)],_0x58379b);if(!_0x453d8e['pg'])throw new Error(_0x400e31[_0x4de63e(0x79)]);const _0x5b4de0=await _0x453d8e['pg'][_0x4de63e(0x94)](_0x4de63e(0x7d)+_0x400e31[_0x4de63e(0x74)](qt,_0x481772[_0x4de63e(0x77)])+_0x4de63e(0x8d)+_0x400e31[_0x4de63e(0x74)](qi,_0x481772[_0x4de63e(0x84)])+_0x4de63e(0x85),[_0x31b209]),_0x2e7363={};_0x2e7363[_0x4de63e(0x83)]=_0x481772[_0x4de63e(0x83)],_0x2e7363[_0x4de63e(0x8a)]=_0x481772[_0x4de63e(0x86)],_0x2e7363[_0x4de63e(0x8b)]=_0x31b209,_0x2e7363[_0x4de63e(0x82)]=_0x400e31[_0x4de63e(0x8f)];if((_0x5b4de0[_0x4de63e(0x7b)]??0x0)>0x0)await _0x453d8e[_0x4de63e(0x91)]?.[_0x4de63e(0x8e)](_0x2e7363);return _0x400e31[_0x4de63e(0x76)](_0x5b4de0[_0x4de63e(0x7b)]??0x0,0x0);};}
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;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAiBF"}
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 _0x41ca(_0x13c984,_0x2584f){_0x13c984=_0x13c984-0x10e;const _0x1e1a7e=_0x1e1a();let _0x41ca33=_0x1e1a7e[_0x13c984];return _0x41ca33;}function _0x1e1a(){const _0x3376f0=['1916978RrApyb','=$1\x20LIMIT\x201','rows','69772ALMpWK','6135vVsAne','6115604tJntIx','Lckpq','table','99gIoKFh','query','2eibuxK','125284GNCXbG','read','wrkav','SELECT\x20','join','60wPvYXi','3690910ilCMrN','empty\x20pg','upzJM','iHLCB','6352zvhphx','key','\x20WHERE\x20','\x20FROM\x20','get','2154RtcHVz'];_0x1e1a=function(){return _0x3376f0;};return _0x1e1a();}(function(_0x4e8fe5,_0x2fff3d){const _0x524e75=_0x41ca,_0x49f1e7=_0x4e8fe5();while(!![]){try{const _0x15e8a7=-parseInt(_0x524e75(0x112))/0x1*(-parseInt(_0x524e75(0x111))/0x2)+-parseInt(_0x524e75(0x117))/0x3*(-parseInt(_0x524e75(0x125))/0x4)+-parseInt(_0x524e75(0x126))/0x5*(-parseInt(_0x524e75(0x121))/0x6)+parseInt(_0x524e75(0x122))/0x7+-parseInt(_0x524e75(0x11c))/0x8*(parseInt(_0x524e75(0x10f))/0x9)+-parseInt(_0x524e75(0x118))/0xa+-parseInt(_0x524e75(0x127))/0xb;if(_0x15e8a7===_0x2fff3d)break;else _0x49f1e7['push'](_0x49f1e7['shift']());}catch(_0x1664e7){_0x49f1e7['push'](_0x49f1e7['shift']());}}}(_0x1e1a,0x3e2ee));import{assertOperation}from'../utils/permissions.js';import{qt,qi,readableFields}from'../utils/sql.js';export function createFindOne(_0x2c20ba,_0x2c5d91){const _0x55dc72=_0x41ca,_0x3dba14={'upzJM':function(_0x4580f7,_0x158ab2,_0x1039ec,_0x243bae){return _0x4580f7(_0x158ab2,_0x1039ec,_0x243bae);},'Lckpq':_0x55dc72(0x113),'iHLCB':_0x55dc72(0x119),'wrkav':function(_0x4133e6,_0x1d988a){return _0x4133e6(_0x1d988a);}};return async function _0x463d96({name:_0x15666f,id:_0x28198f,user:_0x58779f}){const _0x20e46a=_0x55dc72,_0x401351=_0x2c5d91[_0x20e46a(0x120)](_0x15666f);_0x3dba14[_0x20e46a(0x11a)](assertOperation,_0x401351,_0x3dba14[_0x20e46a(0x128)],_0x58779f);if(!_0x2c20ba['pg'])throw new Error(_0x3dba14[_0x20e46a(0x11b)]);const _0x48699d=await _0x2c20ba['pg'][_0x20e46a(0x110)](_0x20e46a(0x115)+readableFields(_0x401351)[_0x20e46a(0x116)](',\x20')+_0x20e46a(0x11f)+qt(_0x401351[_0x20e46a(0x10e)])+_0x20e46a(0x11e)+_0x3dba14[_0x20e46a(0x114)](qi,_0x401351[_0x20e46a(0x11d)])+_0x20e46a(0x123),[_0x28198f]);return _0x48699d[_0x20e46a(0x124)][0x0]??null;};}
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;AAEhE,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,CAiChC"}
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
- (function(_0x1a8d2a,_0x73e788){const _0x21f8c5=_0xce7b,_0x219871=_0x1a8d2a();while(!![]){try{const _0xbd3ec3=-parseInt(_0x21f8c5(0x1aa))/0x1+-parseInt(_0x21f8c5(0x1b6))/0x2*(-parseInt(_0x21f8c5(0x1a8))/0x3)+-parseInt(_0x21f8c5(0x1bb))/0x4+-parseInt(_0x21f8c5(0x19f))/0x5+parseInt(_0x21f8c5(0x1a2))/0x6+-parseInt(_0x21f8c5(0x1ac))/0x7*(parseInt(_0x21f8c5(0x1ae))/0x8)+parseInt(_0x21f8c5(0x19c))/0x9*(parseInt(_0x21f8c5(0x1b9))/0xa);if(_0xbd3ec3===_0x73e788)break;else _0x219871['push'](_0x219871['shift']());}catch(_0x5baf04){_0x219871['push'](_0x219871['shift']());}}}(_0x24a6,0xc9fbb));import{ValidationError}from'../../../errors.js';function _0x24a6(){const _0x35ed79=['DwiYp','table','min','qQpVZ','706590HyeZwD','PItvc','values','5207885vKxXjA','join','offset','418914jxpjUp','length','sort','query','empty\x20pg','filter','2965629VMMRPJ','FROM\x20','431969pOYbSM','FsyAw','266jrXwJk','get','330800zrHefc','LIMIT\x20$','rows','iytIG','AGEES','OFFSET\x20$','limit','Invalid\x20pagination','2JKDZsA','sql','read','360XPwgCW','SELECT\x20','50212jfrGZB','vhwQy','isFinite','max','HLRlk'];_0x24a6=function(){return _0x35ed79;};return _0x24a6();}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';function _0xce7b(_0x241a1a,_0x5af080){_0x241a1a=_0x241a1a-0x19b;const _0x24a6e4=_0x24a6();let _0xce7b97=_0x24a6e4[_0x241a1a];return _0xce7b97;}export function createFind(_0x21d310,_0x5da74d){const _0x2cf2d6=_0xce7b,_0x25d54f={'DwiYp':function(_0xdd5a66,_0x28a09a,_0x3ca440,_0xa394b1){return _0xdd5a66(_0x28a09a,_0x3ca440,_0xa394b1);},'FsyAw':_0x2cf2d6(0x1b8),'HLRlk':function(_0x3fd2c4,_0x2ec291,_0x2b0b81){return _0x3fd2c4(_0x2ec291,_0x2b0b81);},'vhwQy':_0x2cf2d6(0x1b5),'AGEES':function(_0x190ac9,_0x48ca8c){return _0x190ac9+_0x48ca8c;},'qQpVZ':function(_0x2c7d7e,_0x483f89){return _0x2c7d7e+_0x483f89;},'PItvc':function(_0x2bf0d9,_0x3f8c3d){return _0x2bf0d9(_0x3f8c3d);},'iytIG':function(_0x13e56d,_0x203f09){return _0x13e56d(_0x203f09);}};return async function _0x3aafce({name:_0x3542e5,query:query={},user:_0x47abb2}){const _0x23ab01=_0x2cf2d6,_0x54687f=_0x5da74d[_0x23ab01(0x1ad)](_0x3542e5);_0x25d54f[_0x23ab01(0x1c0)](assertOperation,_0x54687f,_0x25d54f[_0x23ab01(0x1ab)],_0x47abb2);const _0x439219=Math[_0x23ab01(0x1c2)](Math[_0x23ab01(0x1be)](query[_0x23ab01(0x1b4)]??0x14,0x1),0xc8),_0x21713a=Math[_0x23ab01(0x1be)](query[_0x23ab01(0x1a1)]??0x0,0x0),_0x35cd4d=_0x25d54f[_0x23ab01(0x1bf)](buildFilters,_0x54687f,query[_0x23ab01(0x1a7)]),_0x2aae2e=_0x25d54f[_0x23ab01(0x1bf)](buildSort,_0x54687f,query[_0x23ab01(0x1a4)]);if(!Number[_0x23ab01(0x1bd)](_0x439219)||!Number[_0x23ab01(0x1bd)](_0x21713a))throw new ValidationError(_0x25d54f[_0x23ab01(0x1bc)]);const _0x325639=_0x25d54f[_0x23ab01(0x1b2)](_0x25d54f[_0x23ab01(0x19b)](_0x25d54f[_0x23ab01(0x19b)](_0x23ab01(0x1ba)+_0x25d54f[_0x23ab01(0x19d)](readableFields,_0x54687f)[_0x23ab01(0x1a0)](',\x20')+'\x20',_0x23ab01(0x1a9)+_0x25d54f[_0x23ab01(0x1b1)](qt,_0x54687f[_0x23ab01(0x1c1)])),''+_0x35cd4d[_0x23ab01(0x1b7)]+_0x2aae2e+'\x20'),_0x23ab01(0x1af)+(_0x35cd4d[_0x23ab01(0x19e)][_0x23ab01(0x1a3)]+0x1)+'\x20')+(_0x23ab01(0x1b3)+_0x25d54f[_0x23ab01(0x1b2)](_0x35cd4d[_0x23ab01(0x19e)][_0x23ab01(0x1a3)],0x2));if(!_0x21d310['pg'])throw new Error(_0x23ab01(0x1a6));const _0x125d9e=await _0x21d310['pg'][_0x23ab01(0x1a5)](_0x325639,[..._0x35cd4d[_0x23ab01(0x19e)],_0x439219,_0x21713a]),_0x5fbc4f={};return _0x5fbc4f[_0x23ab01(0x1b0)]=_0x125d9e[_0x23ab01(0x1b0)],_0x5fbc4f[_0x23ab01(0x1b4)]=_0x439219,_0x5fbc4f[_0x23ab01(0x1a1)]=_0x21713a,_0x5fbc4f;};}
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
- export declare function createUpdate(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, data, user, }: {
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
- }) => Promise<Record<string, unknown>>;
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;AAEhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,+BAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAyCrC"}
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 _0x4ffc(){const _0x225c4a=['No\x20writable\x20fields','name','map','module','empty\x20pg','68664fIxRqo','WHERE\x20','RETURNING\x20','table','SET\x20','query','write','get','BzEeJ','3940560tQXKHf','20979dbYJbr','KRsZP','rows','9jOFJtk','2469805BmiSZf','keys','8pOUMbG','UPDATE\x20','kdQOd','update','12LTXfJd','kEXTa','audit','\x20=\x20$','key','1469325CvROHo','6733232fRmTPP','length','882UXZETF','WxIkj','5301410NXEbDW','join','nxmEk'];_0x4ffc=function(){return _0x225c4a;};return _0x4ffc();}(function(_0x425d7a,_0x2b5626){const _0x3f66fb=_0x510b,_0xf3ff29=_0x425d7a();while(!![]){try{const _0x722d06=parseInt(_0x3f66fb(0xa1))/0x1*(-parseInt(_0x3f66fb(0x91))/0x2)+parseInt(_0x3f66fb(0x84))/0x3+-parseInt(_0x3f66fb(0x7f))/0x4*(-parseInt(_0x3f66fb(0x9f))/0x5)+parseInt(_0x3f66fb(0x87))/0x6*(-parseInt(_0x3f66fb(0x9b))/0x7)+-parseInt(_0x3f66fb(0x9a))/0x8+parseInt(_0x3f66fb(0x9e))/0x9*(-parseInt(_0x3f66fb(0x89))/0xa)+parseInt(_0x3f66fb(0x85))/0xb;if(_0x722d06===_0x2b5626)break;else _0xf3ff29['push'](_0xf3ff29['shift']());}catch(_0x384c6f){_0xf3ff29['push'](_0xf3ff29['shift']());}}}(_0x4ffc,0xce814));function _0x510b(_0x4af633,_0x35699d){_0x4af633=_0x4af633-0x7c;const _0x4ffc3e=_0x4ffc();let _0x510b4f=_0x4ffc3e[_0x4af633];return _0x510b4f;}import{NotFoundError,ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';export function createUpdate(_0x50e3cb,_0x1fb9d3){const _0x579ea1=_0x510b,_0x50289e={'KRsZP':function(_0x453650,_0xdcb4ad,_0x5c72f3,_0x261627){return _0x453650(_0xdcb4ad,_0x5c72f3,_0x261627);},'kdQOd':_0x579ea1(0x7e),'BzEeJ':_0x579ea1(0x8c),'nxmEk':function(_0x35a8d7,_0x5b2932){return _0x35a8d7+_0x5b2932;},'kEXTa':function(_0x59044d,_0x1f4257){return _0x59044d(_0x1f4257);},'WxIkj':function(_0xc853b5,_0x5e4606){return _0xc853b5(_0x5e4606);}};return async function _0x46560a({name:_0x5267b5,id:_0x33fdb4,data:_0x3cb378,user:_0x3563e2}){const _0x5ad279=_0x579ea1,_0x13464d=_0x1fb9d3[_0x5ad279(0x98)](_0x5267b5);_0x50289e[_0x5ad279(0x9c)](assertOperation,_0x13464d,_0x50289e[_0x5ad279(0x7d)],_0x3563e2);const _0x163e21=writableData(_0x13464d,_0x3cb378);if(!_0x163e21[_0x5ad279(0x86)])throw new ValidationError(_0x50289e[_0x5ad279(0x99)]);if(!_0x50e3cb['pg'])throw new Error(_0x5ad279(0x90));const _0x3be3dc=_0x163e21[_0x5ad279(0x8e)](([_0x50b322],_0x215daf)=>qi(_0x50b322)+_0x5ad279(0x82)+(_0x215daf+0x1)),_0x4eb997=[..._0x163e21[_0x5ad279(0x8e)](([,_0x499ee2])=>_0x499ee2),_0x33fdb4],_0x657a63=await _0x50e3cb['pg'][_0x5ad279(0x96)](_0x50289e[_0x5ad279(0x8b)](_0x50289e[_0x5ad279(0x8b)](_0x5ad279(0x7c)+qt(_0x13464d[_0x5ad279(0x94)])+'\x20'+(_0x5ad279(0x95)+_0x3be3dc[_0x5ad279(0x8a)](',\x20')+'\x20'),_0x5ad279(0x92)+_0x50289e[_0x5ad279(0x80)](qi,_0x13464d[_0x5ad279(0x83)])+_0x5ad279(0x82)+_0x50289e[_0x5ad279(0x8b)](_0x163e21[_0x5ad279(0x86)],0x1)+'\x20'),_0x5ad279(0x93)+_0x50289e[_0x5ad279(0x88)](readableFields,_0x13464d)[_0x5ad279(0x8a)](',\x20')),_0x4eb997),_0x51bae4=_0x657a63[_0x5ad279(0x9d)][0x0];if(!_0x51bae4)throw new NotFoundError(_0x5267b5+':'+_0x33fdb4);return await _0x50e3cb[_0x5ad279(0x81)]?.[_0x5ad279(0x97)]({'userId':_0x3563e2?.['id'],'module':_0x13464d[_0x5ad279(0x8f)],'resource':_0x13464d[_0x5ad279(0x8d)],'resourceId':_0x33fdb4,'action':_0x50289e[_0x5ad279(0x7d)],'fields':Object[_0x5ad279(0xa0)](_0x3cb378)}),_0x51bae4;};}
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)+')');}