@opengis/fcore 0.0.1-beta.9 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/config.d.ts +1 -0
  2. package/dist/config.d.ts.map +1 -1
  3. package/dist/config.js +1 -1
  4. package/dist/context.js +1 -1
  5. package/dist/errors.js +1 -1
  6. package/dist/fastify.d.ts +0 -3
  7. package/dist/fastify.d.ts.map +1 -1
  8. package/dist/fastify.js +1 -1
  9. package/dist/fcore.d.ts.map +1 -1
  10. package/dist/fcore.js +1 -1
  11. package/dist/migrations/cli.js +1 -1
  12. package/dist/migrations/runner.js +1 -1
  13. package/dist/modules/auth/adduser-cli.js +1 -1
  14. package/dist/modules/auth/passwd-cli.js +1 -1
  15. package/dist/modules/auth/permission-cli.js +1 -1
  16. package/dist/modules/auth/route.d.ts.map +1 -1
  17. package/dist/modules/auth/route.js +1 -1
  18. package/dist/modules/auth/schema.js +1 -1
  19. package/dist/modules/auth/services/change-password.js +1 -1
  20. package/dist/modules/auth/services/get-current-user.d.ts +2 -0
  21. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  22. package/dist/modules/auth/services/get-current-user.js +1 -1
  23. package/dist/modules/auth/services/registration.js +1 -1
  24. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  25. package/dist/modules/file/mime.js +1 -1
  26. package/dist/modules/file/route.js +1 -1
  27. package/dist/modules/file/schema.js +1 -1
  28. package/dist/modules/file/services/get-file.js +1 -1
  29. package/dist/modules/file/services/resize-file.js +1 -1
  30. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  31. package/dist/modules/file/services/upload-file.js +1 -1
  32. package/dist/modules/resource/route.d.ts.map +1 -1
  33. package/dist/modules/resource/route.js +1 -1
  34. package/dist/modules/resource/schema.d.ts +19 -0
  35. package/dist/modules/resource/schema.d.ts.map +1 -1
  36. package/dist/modules/resource/schema.js +1 -1
  37. package/dist/modules/resource/services/add-note.js +1 -1
  38. package/dist/modules/resource/services/add-resource-file.js +1 -1
  39. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  40. package/dist/modules/resource/services/create-resource.js +1 -1
  41. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  42. package/dist/modules/resource/services/delete-resource.js +1 -1
  43. package/dist/modules/resource/services/export-resource.js +1 -1
  44. package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
  45. package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
  46. package/dist/modules/resource/services/generate-resource-code.js +1 -0
  47. package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
  48. package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
  49. package/dist/modules/resource/services/get-resource-schema.js +1 -0
  50. package/dist/modules/resource/services/get-resource.js +1 -1
  51. package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
  52. package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
  53. package/dist/modules/resource/services/list-resource-as-user.js +1 -0
  54. package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
  55. package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
  56. package/dist/modules/resource/services/list-resource-list.js +1 -0
  57. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  58. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  59. package/dist/modules/resource/services/list-resources.js +1 -1
  60. package/dist/modules/resource/services/search-resource.js +1 -1
  61. package/dist/modules/resource/services/suggest-resource.js +1 -1
  62. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  63. package/dist/modules/resource/services/update-resource.js +1 -1
  64. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  65. package/dist/modules/system/route.d.ts.map +1 -1
  66. package/dist/modules/system/route.js +1 -1
  67. package/dist/modules/system/schema.d.ts +25 -2
  68. package/dist/modules/system/schema.d.ts.map +1 -1
  69. package/dist/modules/system/schema.js +1 -1
  70. package/dist/modules/system/services/check-system.js +1 -1
  71. package/dist/modules/system/services/get-access.d.ts +1 -0
  72. package/dist/modules/system/services/get-access.d.ts.map +1 -1
  73. package/dist/modules/system/services/get-access.js +1 -1
  74. package/dist/modules/system/services/get-api-list.js +1 -1
  75. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  76. package/dist/modules/system/services/get-audit-log.js +1 -1
  77. package/dist/modules/system/services/get-dictionary.js +1 -1
  78. package/dist/modules/system/services/get-resource-access.d.ts +23 -0
  79. package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
  80. package/dist/modules/system/services/get-resource-access.js +1 -0
  81. package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
  82. package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
  83. package/dist/modules/system/services/get-resource-scopes.js +1 -0
  84. package/dist/modules/system/services/get-system-log.js +1 -1
  85. package/dist/modules/system/services/get-system-settings.js +1 -1
  86. package/dist/modules/system/services/list-dictionaries.js +1 -1
  87. package/dist/modules/system/services/set-access.d.ts +3 -1
  88. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  89. package/dist/modules/system/services/set-access.js +1 -1
  90. package/dist/modules/system/services/set-resource-access.d.ts +18 -0
  91. package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
  92. package/dist/modules/system/services/set-resource-access.js +1 -0
  93. package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
  94. package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
  95. package/dist/modules/system/services/set-resource-scopes.js +1 -0
  96. package/dist/modules/system/services/update-dictionary.js +1 -1
  97. package/dist/modules/system/services/update-system-settings.js +1 -1
  98. package/dist/modules/utils/require-admin.js +1 -1
  99. package/dist/modules/utils/safe-user.js +1 -1
  100. package/dist/modules/utils/unsupported.js +1 -1
  101. package/dist/plugins/audit/audit.js +1 -1
  102. package/dist/plugins/audit/audit.types.d.ts +1 -1
  103. package/dist/plugins/audit/audit.types.d.ts.map +1 -1
  104. package/dist/plugins/audit/services/write-audit.js +1 -1
  105. package/dist/plugins/auth/get-user-permissions.js +1 -1
  106. package/dist/plugins/auth/index.d.ts.map +1 -1
  107. package/dist/plugins/auth/index.js +1 -1
  108. package/dist/plugins/auth/verifyUser.js +1 -1
  109. package/dist/plugins/dictionary.js +1 -1
  110. package/dist/plugins/file.d.ts +7 -3
  111. package/dist/plugins/file.d.ts.map +1 -1
  112. package/dist/plugins/file.js +1 -1
  113. package/dist/plugins/jwt.js +1 -1
  114. package/dist/plugins/logger/index.js +1 -1
  115. package/dist/plugins/logger/transport.js +1 -1
  116. package/dist/plugins/pg.d.ts +4 -2
  117. package/dist/plugins/pg.d.ts.map +1 -1
  118. package/dist/plugins/pg.js +1 -1
  119. package/dist/plugins/redis.d.ts.map +1 -1
  120. package/dist/plugins/redis.js +1 -1
  121. package/dist/plugins/resource/resource.d.ts +1 -1
  122. package/dist/plugins/resource/resource.d.ts.map +1 -1
  123. package/dist/plugins/resource/resource.js +1 -1
  124. package/dist/plugins/resource/resource.registry.d.ts +3 -2
  125. package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
  126. package/dist/plugins/resource/resource.registry.js +1 -1
  127. package/dist/plugins/resource/resource.types.d.ts +66 -14
  128. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  129. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  130. package/dist/plugins/resource/services/add-file-token.js +1 -1
  131. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  132. package/dist/plugins/resource/services/create-relation.d.ts +5 -2
  133. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  134. package/dist/plugins/resource/services/create-relation.js +1 -1
  135. package/dist/plugins/resource/services/create.d.ts +5 -2
  136. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  137. package/dist/plugins/resource/services/create.js +1 -1
  138. package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
  139. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  140. package/dist/plugins/resource/services/delete-relation.js +1 -1
  141. package/dist/plugins/resource/services/delete.d.ts +9 -2
  142. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  143. package/dist/plugins/resource/services/delete.js +1 -1
  144. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  145. package/dist/plugins/resource/services/find-one.js +1 -1
  146. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  147. package/dist/plugins/resource/services/find-relation.js +1 -1
  148. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  149. package/dist/plugins/resource/services/find.js +1 -1
  150. package/dist/plugins/resource/services/get-table-columns.d.ts +8 -0
  151. package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
  152. package/dist/plugins/resource/services/get-table-columns.js +1 -0
  153. package/dist/plugins/resource/services/update-relation.d.ts +5 -2
  154. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
  155. package/dist/plugins/resource/services/update-relation.js +1 -1
  156. package/dist/plugins/resource/services/update.d.ts +9 -2
  157. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  158. package/dist/plugins/resource/services/update.js +1 -1
  159. package/dist/plugins/resource/utils/auto-index.js +1 -1
  160. package/dist/plugins/resource/utils/fields.js +1 -1
  161. package/dist/plugins/resource/utils/filters.d.ts +2 -1
  162. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  163. package/dist/plugins/resource/utils/filters.js +1 -1
  164. package/dist/plugins/resource/utils/permissions.js +1 -1
  165. package/dist/plugins/resource/utils/scope.d.ts +10 -0
  166. package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
  167. package/dist/plugins/resource/utils/scope.js +1 -0
  168. package/dist/plugins/resource/utils/sort.d.ts +1 -1
  169. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  170. package/dist/plugins/resource/utils/sort.js +1 -1
  171. package/dist/plugins/resource/utils/sql.d.ts +1 -1
  172. package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
  173. package/dist/plugins/resource/utils/sql.js +1 -1
  174. package/dist/plugins/resource/utils/summary.d.ts +7 -0
  175. package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
  176. package/dist/plugins/resource/utils/summary.js +1 -0
  177. package/dist/shared/getIP.js +1 -1
  178. package/migrations/20260903120000_core_schema.sql +5 -2
  179. package/migrations/20260903130001_add_file_fields.sql +5 -0
  180. package/migrations/20260910170000_core_schema.sql +22 -0
  181. package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
  182. package/migrations/20260929_role_scope.sql +32 -0
  183. package/package.json +2 -2
@@ -7,7 +7,29 @@ import type { AuditPlugin } from "../audit/index.js";
7
7
  import type { DictionaryPlugin } from "../dictionary.js";
8
8
  import type { FileAdapter } from "../file.js";
9
9
  import { User } from "../../context.js";
10
+ import type { AppContext } from "../../context.js";
11
+ export type ResourceAggregate = "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
12
+ export type ResourceSummaryItem = {
13
+ aggregate: "count";
14
+ where?: string;
15
+ } | {
16
+ aggregate: "countDistinct" | "sum" | "avg" | "min" | "max";
17
+ field: string;
18
+ where?: string;
19
+ } | {
20
+ sql: string;
21
+ };
22
+ interface ResourceScope {
23
+ where?: string;
24
+ fields?: string[];
25
+ sort?: string;
26
+ limit?: number;
27
+ }
10
28
  export type ResourceOperation = "read" | "create" | "update" | "delete";
29
+ export interface ResourceJoinContract {
30
+ scope?: "all" | "item";
31
+ sql: string;
32
+ }
11
33
  export interface ResourceFieldContract {
12
34
  column?: string;
13
35
  type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
@@ -16,13 +38,13 @@ export interface ResourceFieldContract {
16
38
  readable?: boolean;
17
39
  writable?: boolean;
18
40
  required?: boolean;
41
+ code_template?: string;
19
42
  nullable?: boolean;
20
43
  filterable?: boolean;
21
44
  searchable?: boolean;
22
45
  sortable?: boolean;
23
46
  filter?: boolean;
24
- sort?: boolean;
25
- search?: boolean;
47
+ scope?: "all" | "item";
26
48
  dictionary?: string;
27
49
  lookup?: {
28
50
  table: string;
@@ -37,43 +59,71 @@ export interface ResourceFieldContract {
37
59
  maximum?: number;
38
60
  pattern?: string;
39
61
  }
62
+ export type ResourceRelationType = 'one' | 'many';
40
63
  export interface ResourceRelationContract {
64
+ type?: ResourceRelationType;
41
65
  resource?: string;
42
66
  table?: string;
43
- sourceField?: string;
44
- key?: string;
67
+ where?: string;
68
+ localKey?: string;
45
69
  foreignKey?: string;
46
- targetField?: string;
47
- type?: "one" | "many";
70
+ targetKey?: string;
48
71
  fields?: string[];
72
+ junctionTable?: string;
73
+ junctionLocalKey?: string;
74
+ junctionForeignKey?: string;
75
+ junctionTargetKey?: string;
49
76
  }
50
77
  export interface ResourceContract {
51
78
  version: 1;
52
79
  name: string;
53
- module: string;
80
+ module?: string;
54
81
  title?: string;
55
82
  table: string;
83
+ where?: string;
56
84
  key: string;
85
+ display?: string[] | string;
57
86
  operations: ResourceOperation[];
87
+ searchable?: string[];
58
88
  capabilities?: string[];
59
89
  permission?: string;
60
90
  fields: Record<string, ResourceFieldContract>;
61
91
  relations?: Record<string, ResourceRelationContract>;
92
+ joins?: ResourceJoinContract[];
62
93
  access?: "public" | "user" | "admin";
94
+ summary?: Record<string, ResourceSummaryItem>;
95
+ scopes?: Record<string, string | ResourceScope>;
96
+ }
97
+ export interface ResourceVariableDto {
98
+ key: string;
99
+ path: string;
100
+ title?: string;
101
+ type: "string" | "number" | "boolean" | "object" | "array";
102
+ resource?: string;
103
+ variables?: ResourceVariableDto[];
104
+ }
105
+ export interface ResourceSchemaDto {
106
+ resource: string;
107
+ title?: string;
108
+ variables: ResourceVariableDto[];
63
109
  }
64
110
  export interface ResourceQuery {
65
111
  filter?: Record<string, unknown>;
66
112
  include?: string | string[];
67
113
  sort?: string[];
68
114
  search?: string;
115
+ scope?: string;
69
116
  limit?: number;
70
117
  offset?: number;
71
118
  fields?: string[];
72
119
  }
73
120
  export interface ResourceListResult<T = Record<string, unknown>> {
74
121
  rows: T[];
122
+ summary: Record<string, unknown>;
75
123
  limit: number;
76
124
  time: number;
125
+ fields?: Record<string, ResourceFieldContract>;
126
+ count: number | null;
77
127
  total: number | null;
78
128
  offset: number;
79
129
  }
@@ -86,7 +136,8 @@ export interface ResourceDependencies {
86
136
  file?: FileAdapter;
87
137
  }
88
138
  export interface ResourcePlugin {
89
- register(input: ResourceContract | ResourceContract[]): void;
139
+ register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
140
+ unregister(name: string): void;
90
141
  has(name: string): boolean;
91
142
  get(name: string): ResourceContract;
92
143
  list(): ResourceContract[];
@@ -105,18 +156,18 @@ export interface ResourcePlugin {
105
156
  name: string;
106
157
  data: Record<string, unknown>;
107
158
  user?: ResourceUser;
108
- }): Promise<Record<string, unknown>>;
159
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
109
160
  update(params: {
110
161
  name: string;
111
162
  id: string | number;
112
163
  data: Record<string, unknown>;
113
164
  user?: ResourceUser;
114
- }): Promise<Record<string, unknown>>;
165
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
115
166
  delete(params: {
116
167
  name: string;
117
168
  id: string | number;
118
169
  user?: ResourceUser;
119
- }): Promise<boolean>;
170
+ }, ctx?: AppContext): Promise<boolean>;
120
171
  findRelation(params: {
121
172
  name: string;
122
173
  id: string | number;
@@ -130,7 +181,7 @@ export interface ResourcePlugin {
130
181
  relation: string;
131
182
  data?: Record<string, unknown>;
132
183
  user?: ResourceUser;
133
- }): Promise<any>;
184
+ }, ctx?: AppContext): Promise<any>;
134
185
  updateRelation(params: {
135
186
  name: string;
136
187
  id: string | number;
@@ -138,15 +189,16 @@ export interface ResourcePlugin {
138
189
  relationId: string;
139
190
  data: Record<string, unknown>;
140
191
  user?: ResourceUser;
141
- }): Promise<Record<string, unknown>>;
192
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
142
193
  deleteRelation(params: {
143
194
  name: string;
144
195
  id: string | number;
145
196
  relation: string;
146
197
  relationId: string;
147
198
  user?: ResourceUser;
148
- }): Promise<{
199
+ }, ctx?: AppContext): Promise<{
149
200
  success: boolean;
150
201
  }>;
151
202
  }
203
+ export {};
152
204
  //# sourceMappingURL=resource.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EACH,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,MAAM,GACN,MAAM,GACN,WAAW,GACX,MAAM,GACN,MAAM,GACN,UAAU,GACV,MAAM,CAAC;IACT,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAA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AE,OAAO,CAAC,CAAC,CAAC;IACpC,cAAc,CACZ,MAAM,EAAE;QACN,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,EACD,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAClC"}
@@ -1 +1 @@
1
- function c(J,e){J=J-0xf6;const p=L();let b=p[J];return b;}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(J,e){const w=c,p=dictionaryIndexesCache['get'](e)??new Map(),b=dictionaryRevisionsCache['get'](e)??new Map();dictionaryIndexesCache[w(0xf6)](e,p),dictionaryRevisionsCache[w(0xf6)](e,b);const F=J['filter'](h=>b[w(0xf7)](h)!==e['revision'](h));if(F['length']===0x0)return p;const P=await Promise['all'](F['map'](async h=>{const X=w;if(!e['has'](h))return[h,new Map()];const u=await e['get'](h),H=new Map();for(const D of u){const U=D['code']??D['id'];if(U==null)continue;H['set'](String(U),{'id':U,'text':D['name']??D['text'],...D['color']!==undefined?{'color':D['color']}:{},...D[X(0xf8)]!==undefined?{'icon':D[X(0xf8)]}:{}});}return[h,H];}));for(const [h,u]of P){p[w(0xf6)](h,u),b['set'](h,e['revision'](h));}return p;}export async function addDictionaryLookupData(J,e,p){const E=c;if(!p||J['length']===0x0)return J;const b=Object['entries'](e)['flatMap'](([P,h])=>{const u=h['dictionary'];return u?[{'field':P,'dictionaryName':u}]:[];});if(b[E(0xf9)]===0x0)return J;const F=await getDictionaryIndexes([...new Set(b['map'](({dictionaryName:P})=>P))],p);for(const P of J){for(const {field:h,dictionaryName:u}of b){const H=P[h];P[h+'_data']=H==null?null:F['get'](u)?.[E(0xf7)](String(H))??null;}}return J;}function L(){const Q=['set','get','icon','length'];L=function(){return Q;};return L();}
1
+ function m(){const i=['filter','get','revision','set','text','color','icon','length','flatMap','dictionary','map'];m=function(){return i;};return m();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(P,G){const E=C,j=dictionaryIndexesCache['get'](G)??new Map(),Z=dictionaryRevisionsCache['get'](G)??new Map();dictionaryIndexesCache['set'](G,j),dictionaryRevisionsCache['set'](G,Z);const q=P[E(0x1f3)](X=>Z[E(0x1f4)](X)!==G[E(0x1f5)](X));if(q['length']===0x0)return j;const p=await Promise['all'](q['map'](async X=>{const z=E;if(!G['has'](X))return[X,new Map()];const F=await G['get'](X),A=new Map();for(const H of F){const b=H['code']??H['id'];if(b==null)continue;A[z(0x1f6)](String(b),{'id':b,'text':H['name']??H[z(0x1f7)],...H['color']!==undefined?{'color':H[z(0x1f8)]}:{},...H[z(0x1f9)]!==undefined?{'icon':H['icon']}:{}});}return[X,A];}));for(const [X,F]of p){j['set'](X,F),Z[E(0x1f6)](X,G['revision'](X));}return j;}function C(P,G){P=P-0x1f3;const j=m();let Z=j[P];return Z;}export async function addDictionaryLookupData(P,G,j){const x=C;if(!j||P[x(0x1fa)]===0x0)return P;const Z=Object['entries'](G)[x(0x1fb)](([p,X])=>{const o=x,F=X[o(0x1fc)];return F?[{'field':p,'dictionaryName':F}]:[];});if(Z['length']===0x0)return P;const q=await getDictionaryIndexes([...new Set(Z[x(0x1fd)](({dictionaryName:p})=>p))],j);for(const p of P){for(const {field:X,dictionaryName:F}of Z){const A=p[X];p[X+'_data']=A==null?null:q['get'](F)?.[x(0x1f4)](String(A))??null;}}return P;}
@@ -1 +1 @@
1
- function c(J,e){J=J-0x9c;const p=L();let b=p[J];return b;}export function addFileToken(J,e,p){const u=c;if(!p||J['length']===0x0)return J;const b=Object[u(0x9c)](e)[u(0x9d)](([,F])=>F['type']==='file')['map'](([F])=>F);for(const F of J){for(const P of b){const h=F[P];typeof h==='string'&&h['length']>0x0&&(F[P]=p['create'](h));}}return J;}function L(){const H=['entries','filter'];L=function(){return H;};return L();}
1
+ function m(){const A=['file','string'];m=function(){return A;};return m();}function C(P,G){P=P-0x155;const j=m();let Z=j[P];return Z;}export function addFileToken(P,G,j){const F=C;if(!j||P['length']===0x0)return P;const Z=Object['entries'](G)['filter'](([,q])=>q['type']===F(0x155))['map'](([q])=>q);for(const q of P){for(const p of Z){const X=q[p];typeof X===F(0x156)&&X['length']>0x0&&(q[p]=j['create'](X));}}return P;}
@@ -1 +1 @@
1
- import{qi,qt}from'../utils/sql.js';function c(J,e){J=J-0x6a;const p=L();let b=p[J];return b;}const tableLookupCache=new WeakMap();export function clearTableLookupCache(J,e){const a=c,p=tableLookupCache[a(0x6a)](e);if(!p)return;for(const b of p[a(0x6b)]()){b['startsWith'](J+':')&&p['delete'](b);}}export async function addTableLookupData(J,e,p){const M=c;if(!p||J['length']===0x0)return J;const b=tableLookupCache['get'](p)??new Map();tableLookupCache['set'](p,b);const F=Object['entries'](e)[M(0x6c)](([P,h])=>{const d=M,{table:u,value:value='id',text:text=d(0x6d)}=h[d(0x6e)]??{};return u?[{'field':P,'table':u,'value':value,'text':text}]:[];});for(const P of F){const h=new Map();for(const U of J){const w=U[P[M(0x6f)]];(typeof w===M(0x70)||typeof w==='number')&&h['set'](String(w),w);}const u=P[M(0x71)]+':'+P['value']+':'+P['text'],H=b['get'](u)??new Map();b['set'](u,H);const D=[...h['entries']()]['filter'](([X])=>!H['has'](X))['map'](([,X])=>X);if(D['length']>0x0){const X=await p['query']('SELECT\x20'+qi(P[M(0x72)])+'\x20AS\x20id,\x20'+qi(P['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(P[M(0x71)])+M(0x73)+qi(P['value'])+'\x20=\x20ANY($1)',[D]);for(const E of X[M(0x74)]){H[M(0x75)](String(E['id']),E);}for(const Q of D){!H[M(0x76)](String(Q))&&H[M(0x75)](String(Q),null);}}for(const T of J){const l=T[P['field']];T[P['field']+'_data']=l==null?null:H['get'](String(l))??null;}}return J;}function L(){const A=['get','keys','flatMap','name','lookup','field','string','table','value','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','rows','set','has'];L=function(){return A;};return L();}
1
+ import{qi,qt}from'../utils/sql.js';const tableLookupCache=new WeakMap();function C(P,G){P=P-0xd7;const j=m();let Z=j[P];return Z;}export function clearTableLookupCache(P,G){const T=C,j=tableLookupCache['get'](G);if(!j)return;for(const Z of j['keys']()){Z[T(0xd7)](P+':')&&j['delete'](Z);}}export async function addTableLookupData(P,G,j){const D=C;if(!j||P['length']===0x0)return P;const Z=tableLookupCache[D(0xd8)](j)??new Map();tableLookupCache[D(0xd9)](j,Z);const q=Object['entries'](G)['flatMap'](([p,X])=>{const h=D,{table:F,value:value='id',text:text=h(0xda)}=X[h(0xdb)]??{};return F?[{'field':p,'table':F,'value':value,'text':text}]:[];});for(const p of q){const X=new Map();for(const b of P){const E=b[p['field']];(typeof E===D(0xdc)||typeof E==='number')&&X[D(0xd9)](String(E),E);}const F=p['table']+':'+p['value']+':'+p[D(0xdd)],A=Z[D(0xd8)](F)??new Map();Z[D(0xd9)](F,A);const H=[...X[D(0xde)]()]['filter'](([z])=>!A['has'](z))['map'](([,z])=>z);if(H['length']>0x0){const z=await j['query']('SELECT\x20'+qi(p[D(0xdf)])+'\x20AS\x20id,\x20'+qi(p['text'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(p[D(0xe0)])+D(0xe1)+qi(p['value'])+D(0xe2),[H]);for(const x of z['rows']){A[D(0xd9)](String(x['id']),x);}for(const o of H){!A['has'](String(o))&&A[D(0xd9)](String(o),null);}}for(const i of P){const y=i[p['field']];i[p['field']+D(0xe3)]=y==null?null:A['get'](String(y))??null;}}return P;}function m(){const L=['startsWith','get','set','name','lookup','string','text','entries','value','table','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','\x20=\x20ANY($1)','_data'];m=function(){return L;};return m();}
@@ -3,11 +3,14 @@
3
3
  */
4
4
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
5
  import type { ResourceRegistry } from "../resource.registry.js";
6
- export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user, }: {
6
+ import { AppContext } from "../../../context.js";
7
+ type CreateRelationParams = {
7
8
  name: string;
8
9
  id: string | number;
9
10
  relation: string;
10
11
  data?: Record<string, unknown>;
11
12
  user?: ResourceUser;
12
- }) => Promise<any>;
13
+ };
14
+ export declare function createCreateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, data, user }: CreateRelationParams, ctx?: AppContext) => Promise<any>;
15
+ export {};
13
16
  //# sourceMappingURL=create-relation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAUvB;IACD,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,KAAG,OAAO,CAAC,GAAG,CAAC,CAuEjB"}
1
+ {"version":3,"file":"create-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,wCAKY,oBAAoB,QAClD,UAAU,KACf,OAAO,CAAC,GAAG,CAAC,CAyFhB"}
@@ -1 +1 @@
1
- import{UnsupportedError,ValidationError}from'../../../errors.js';function L(){const R=['query','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','rows','relations','Generic\x20Resource\x20relation\x20\x22','get','resource','entries','length','table',')\x20VALUES\x20(','join','UPDATE\x20','\x20SET\x20','\x20=\x20$1\x20WHERE\x20'];L=function(){return R;};return L();}import{qi,qt}from'../utils/sql.js';function c(J,e){J=J-0x180;const p=L();let b=p[J];return b;}import{createCreate}from'./create.js';export function createCreateRelation(J,e){const p=createCreate(J,e);return async function b({name:F,id:P,relation:h,data:u,user:H}){const z=c;if(!J['pg'])throw new Error('empty\x20pg');if(h==='notes'){const E=await J['pg'][z(0x180)](z(0x181),[F,String(P),u?.['body']]);return E[z(0x182)][0x0];}if(h==='files'){const Q=await J['pg']['query']('INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[F,String(P),u?.['filePath'],u?.['size']??null]);return Q['rows'][0x0];}const D=e['get'](F),U=D[z(0x183)]?.[h];if(!U?.['foreignKey']||!U['resource']&&!U['table'])throw new UnsupportedError(z(0x184)+h+'\x22\x20requires\x20a\x20project/provider\x20implementation');let w,X;if(U['resource'])w=await p({'name':U['resource'],'data':u??{},'user':H}),X=w[e[z(0x185)](U[z(0x186)])['key']];else{const T=U['fields'];if(!T?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+h+'\x22\x20requires\x20a\x20project/provider\x20implementation');const l=Object[z(0x187)](u??{})['filter'](([Y])=>T['includes'](Y));if(!l[z(0x188)])throw new ValidationError('No\x20writable\x20fields');const a=l['map'](([Y])=>qi(Y)),M=l['map']((Y,q)=>'$'+(q+0x1)),d=l['map'](([,Y])=>Y),A=await J['pg']['query']('INSERT\x20INTO\x20'+qt(U[z(0x189)])+'\x20('+a['join'](',\x20')+z(0x18a)+M[z(0x18b)](',\x20')+')\x20RETURNING\x20*',d);w=A['rows'][0x0],X=w['id'];}return await J['pg']['query'](z(0x18c)+qt(D[z(0x189)])+z(0x18d)+qi(U['foreignKey'])+z(0x18e)+qi(D['key'])+'\x20=\x20$2',[X,P]),w;};}
1
+ function m(){const D=['files','includes','\x22\x20requires\x20a\x20capabilities\x20\x22','query','INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*','filePath','rows','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','Relation\x20update\x20is\x20not\x20configured:\x20','resource'];m=function(){return D;};return m();}import{UnsupportedError}from'../../../errors.js';function C(P,G){P=P-0xf5;const j=m();let Z=j[P];return Z;}import{createCreate}from'./create.js';export function createCreateRelation(P,G){const j=createCreate(P,G);return async function Z({name:q,id:p,relation:X,data:F,user:A},H){const T=C,b=H?.['pg']??P['pg'],E=G['get'](q);if(['notes',T(0xf5),'gallery']['includes'](X)&&!E['capabilities']?.[T(0xf6)](X))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+X+T(0xf7)+X+'\x22');if(X==='notes'){const o=await b[T(0xf8)](T(0xf9),[q,String(p),F?.['body']]);return o['rows'][0x0];}if(X==='files'){const i=await b['query']('INSERT\x20INTO\x20admin.files\x20(resource,\x20resource_id,\x20file_path,\x20size)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[q,String(p),F?.[T(0xfa)],F?.['size']??null]);return i['rows'][0x0];}if(X==='gallery'){const y=await b[T(0xf8)]('INSERT\x20INTO\x20admin.gallery\x20(resource,\x20resource_id,\x20file_path,\x20size,\x20mime_type)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20VALUES\x20($1,\x20$2,\x20$3,\x20$4)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20RETURNING\x20*',[q,String(p),F?.['filePath'],F?.['size']??null,F?.['mimeType']??'image/jpeg']);return y[T(0xfb)][0x0];}const z=E['relations']?.[X];if(!z?.['foreignKey']||!z['resource']&&!z['table'])throw new UnsupportedError(T(0xfc)+X+T(0xfd));if(!F)throw new UnsupportedError('No\x20data\x20provided\x20for\x20relation:\x20'+F);if(!z['resource'])throw new UnsupportedError(T(0xfe)+X);F[z['foreignKey']]=p;const x=await j({'name':z[T(0xff)],'data':F??{},'user':A});return x;};}
@@ -1,8 +1,11 @@
1
1
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
2
2
  import type { ResourceRegistry } from "../resource.registry.js";
3
- 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;AAMhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsCrC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/create.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,2BAE0B,YAAY,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA4CtH"}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';import{qi,qt,readableFields,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function c(J,e){J=J-0x1c8;const p=L();let b=p[J];return b;}export function createCreate(J,e){return async function p({name:b,data:F,user:P}){const T=c,h=e[T(0x1c8)](b);assertOperation(h,T(0x1c9),P),validateInputData({'resource':h,'data':F});const u=writableData(h,F);if(!u['length'])throw new ValidationError(T(0x1ca));const H=u['map'](([E])=>qi(E)),D=u[T(0x1cb)]((E,Q)=>'$'+(Q+0x1)),U=u[T(0x1cb)](([,E])=>E);if(!J['pg'])throw new Error('empty\x20pg');const w=await J['pg']['query'](T(0x1cc)+qt(h['table'])+'\x20('+H['join'](',\x20')+')\x20'+(T(0x1cd)+D['join'](',\x20')+')\x20')+(T(0x1ce)+readableFields(h)['join'](',\x20')),U),X=w[T(0x1cf)][0x0];return clearTableLookupCache(h['table'],J['pg']),await J[T(0x1d0)]?.[T(0x1d1)]({'userId':P?.['id'],'module':h['module'],'resource':h['name'],'resourceId':X[h[T(0x1d2)]],'action':'create','fields':Object['keys'](F)}),X;};}function L(){const l=['get','create','No\x20writable\x20fields','map','INSERT\x20INTO\x20','VALUES\x20(','RETURNING\x20','rows','audit','write','key'];L=function(){return l;};return L();}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function m(){const D=['created_at','push','created_by','length','query','join','rows','table','audit','module','keys'];m=function(){return D;};return m();}import{qi,qt,writableData}from'../utils/sql.js';import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function C(P,G){P=P-0x1e0;const j=m();let Z=j[P];return Z;}export function createCreate(P,G){return async function j({name:Z,data:q,user:p},X){const T=C,F=G['get'](Z);assertOperation(F,'create',p),validateInputData({'resource':F,'data':q});const A=writableData(F,q);F['fields']['created_at']&&A['push']([T(0x1e0),new Date()]);F['fields']['created_by']&&A[T(0x1e1)]([T(0x1e2),p?.['id']]);if(!A[T(0x1e3)])throw new ValidationError('No\x20writable\x20fields');const H=A['map'](([i])=>qi(i)),b=A['map']((i,y)=>'$'+(y+0x1)),E=A['map'](([,i])=>i),z=X?.['pg']??P['pg'],x=await z[T(0x1e4)]('INSERT\x20INTO\x20'+qt(F['table'])+'\x20('+H['join'](',\x20')+')\x20'+('VALUES\x20('+b[T(0x1e5)](',\x20')+')\x20')+'RETURNING\x20*',E),o=x[T(0x1e6)][0x0];return clearTableLookupCache(F[T(0x1e7)],z),await(X?.[T(0x1e8)]??P['audit'])?.['write']({'userId':p?.['id'],'module':F[T(0x1e9)],'resource':F['name'],'resourceId':o[F['key']],'action':'create','fields':Object[T(0x1ea)](q)}),o;};}
@@ -3,13 +3,16 @@
3
3
  */
4
4
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
5
  import type { ResourceRegistry } from "../resource.registry.js";
6
- export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, }: {
6
+ import type { AppContext } from "../../../context.js";
7
+ type DeleteRelationParams = {
7
8
  name: string;
8
9
  id: string | number;
9
10
  relation: string;
10
- relationId: string;
11
+ relationId: string | number;
11
12
  user?: ResourceUser;
12
- }) => Promise<{
13
+ };
14
+ export declare function createDeleteRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, user }: DeleteRelationParams, ctx?: AppContext) => Promise<{
13
15
  success: boolean;
14
16
  }>;
17
+ export {};
15
18
  //# sourceMappingURL=delete-relation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAyBlC"}
1
+ {"version":3,"file":"delete-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,CAAC;AACF,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,8CAKkB,oBAAoB,QACxD,UAAU,KACf,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAuDjC"}
@@ -1 +1 @@
1
- import{UnsupportedError}from'../../../errors.js';function c(J,e){J=J-0xf1;var p=L();var b=p[J];return b;}function L(){var H=['notes','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation'];L=function(){return H;};return L();}export function createDeleteRelation(J,e){return async function p({name:b,id:F,relation:P,relationId:h}){var u=c;if(!J['pg'])throw new Error('empty\x20pg');if(P===u(0xf1))return await J['pg']['query'](u(0xf2),[h,b,String(F)]),{'success':!![]};if(P==='files')return await J['pg']['query']('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[h,b,String(F)]),{'success':!![]};throw new UnsupportedError(u(0xf3)+P+u(0xf4));};}
1
+ function m(){const i=['get','notes','includes','query','DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3','foreignKey','Generic\x20Resource\x20relation\x20\x22','\x22\x20requires\x20a\x20project/provider\x20implementation','resource'];m=function(){return i;};return m();}import{UnsupportedError}from'../../../errors.js';import{createRemove}from'./delete.js';function C(P,G){P=P-0x1b1;const j=m();let Z=j[P];return Z;}export function createDeleteRelation(P,G){const j=createRemove(P,G);return async function Z({name:q,id:p,relation:X,relationId:F,user:A},H){const o=C,b=H?.['pg']??P['pg'],E=G[o(0x1b1)](q);if([o(0x1b2),'files','gallery']['includes'](X)&&!E['capabilities']?.[o(0x1b3)](X))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+X+'\x22\x20requires\x20a\x20capabilities\x20\x22'+X+'\x22');if(X==='notes')return await b[o(0x1b4)](o(0x1b5),[F,q,String(p)]),{'success':!![]};if(X==='files')return await b[o(0x1b4)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[F,q,String(p)]),{'success':!![]};if(X==='gallery')return await b['query']('DELETE\x20FROM\x20admin.gallery\x20WHERE\x20id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[F,q,String(p)]),{'success':!![]};const z=E['relations']?.[X];if(!z?.['resource']||!z[o(0x1b6)])throw new UnsupportedError(o(0x1b7)+X+o(0x1b8));const x=await j({'name':z[o(0x1b9)],'id':F,'user':A,'where':{'column':z[o(0x1b6)],'value':p}},H);return{'success':x};};}
@@ -3,9 +3,16 @@
3
3
  */
4
4
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
5
5
  import type { ResourceRegistry } from "../resource.registry.js";
6
- 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;AAGhE,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,yBAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,sBA0BF"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/delete.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpD,CAAC;AACF,wBAAgB,YAAY,CAC1B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAE+B,YAAY,QAAQ,UAAU,sBAoCxF"}
@@ -1 +1 @@
1
- import{assertOperation}from'../utils/permissions.js';import{qt,qi}from'../utils/sql.js';function L(){const D=['delete','empty\x20pg','=$1','audit','name'];L=function(){return D;};return L();}import{clearTableLookupCache}from'./add-table-lookup-data.js';function c(J,e){J=J-0xd3;const p=L();let b=p[J];return b;}export function createRemove(J,e){return async function p({name:b,id:F,user:P}){const H=c,h=e['get'](b);assertOperation(h,H(0xd3),P);if(!J['pg'])throw new Error(H(0xd4));const u=await J['pg']['query']('DELETE\x20FROM\x20'+qt(h['table'])+'\x20WHERE\x20'+qi(h['key'])+H(0xd5),[F]);if((u['rowCount']??0x0)>0x0)clearTableLookupCache(h['table'],J['pg']);if((u['rowCount']??0x0)>0x0)await J[H(0xd6)]?.['write']({'module':h['module'],'resource':h[H(0xd7)],'resourceId':F,'action':'delete'});return(u['rowCount']??0x0)>0x0;};}
1
+ import{assertOperation}from'../utils/permissions.js';function C(P,G){P=P-0x17e;const j=m();let Z=j[P];return Z;}function m(){const o=['WHERE\x20','\x20=\x20$1','\x20=\x20$','length','\x20AND\x20(','DELETE\x20FROM\x20','table','write','module','delete'];m=function(){return o;};return m();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';export function createRemove(P,G){return async function j({name:Z,id:q,user:p,where:X},F){const x=C,A=G['get'](Z);assertOperation(A,'delete',p);const H=F?.['pg']??P['pg'],b=[q];let E=x(0x17e)+qi(A['key'])+x(0x17f);X&&(b['push'](X['value']),E+='\x20AND\x20'+qi(X['column'])+x(0x180)+b[x(0x181)]);A['where']&&(E+=x(0x182)+A['where']+')');const z=await H['query'](x(0x183)+qt(A[x(0x184)])+'\x20'+E,b);if((z['rowCount']??0x0)>0x0)clearTableLookupCache(A[x(0x184)],H);if((z['rowCount']??0x0)>0x0)await(F?.['audit']??P['audit'])?.[x(0x185)]({'module':A[x(0x186)],'resource':A['name'],'resourceId':q,'action':x(0x187)});return(z['rowCount']??0x0)>0x0;};}
@@ -1 +1 @@
1
- {"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAK9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAsDF"}
1
+ {"version":3,"file":"find-one.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-one.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,gCAQvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,6CAkDF"}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function L(){const A=['now','empty\x20pg','\x20FROM\x20','table','fields','isArray','include','resource','get','SELECT\x20','\x20WHERE\x20','\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20','foreignKey','query'];L=function(){return A;};return L();}function c(J,e){J=J-0x67;const p=L();let b=p[J];return b;}import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindOne(J,e){return async function p({name:b,id:F,query:query={},user:P}){const d=c,h=Date[d(0x67)](),u=e['get'](b);assertOperation(u,'read',P);if(!J['pg'])throw new Error(d(0x68));const H=await J['pg']['query']('SELECT\x20'+readableFields(u)['join'](',\x20')+d(0x69)+qt(u[d(0x6a)])+'\x20WHERE\x20'+qi(u['key'])+'=$1\x20LIMIT\x201',[F]),D=H['rows'][0x0];if(!D)return null;await addDictionaryLookupData([D],u['fields'],J['dictionary']),await addTableLookupData([D],u[d(0x6b)],J['pg']),addFileToken([D],u['fields'],J['file']);const U=Array[d(0x6c)](query['include'])?query['include']:query[d(0x6d)]?.['split'](',')??[];for(const w of U){const X=u['relations']?.[w];if(!X?.['foreignKey']||!X[d(0x6e)]&&!X['table'])throw new ValidationError('Unknown\x20relation:\x20'+w);const E=X[d(0x6e)]?e[d(0x6f)](X['resource']):undefined,Q=X['table']??E[d(0x6a)],T=E?.['key']??'id',l=E?readableFields(E)['join'](',\x20'):'*',a=d(0x70)+l+'\x20FROM\x20'+qt(Q)+d(0x71)+qi(T)+d(0x72)+qi(X[d(0x73)])+d(0x69)+qt(u['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(u['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',M=(await J['pg'][d(0x74)](a,[F]))['rows'];E&&(await addDictionaryLookupData(M,E['fields'],J['dictionary']),await addTableLookupData(M,E['fields'],J['pg']),addFileToken(M,E['fields'],J['file'])),D[w]=M;}return D['time']=Date['now']()-h,D;};}
1
+ import{ValidationError}from'../../../errors.js';import{assertOperation}from'../utils/permissions.js';function C(P,G){P=P-0x184;const j=m();let Z=j[P];return Z;}import{qt,qi,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{createFindRelation}from'./find-relation.js';function m(){const T=['now','read','Invalid\x20id:\x20','joins','sql','\x20AND\x20(','SELECT\x20','\x20FROM\x20','\x20WHERE\x20','dictionary','fields','file','keys','isArray','include','split','type'];m=function(){return T;};return m();}export function createFindOne(P,G){return async function j({name:Z,id:q,query:query={},user:p}){const y=C,X=Date[y(0x184)](),F=G['get'](Z);assertOperation(F,y(0x185),p);if(F['fields'][F['key']]?.['type']==='integer'&&!Number['isInteger'](Number(q)))throw new ValidationError(y(0x186)+q+'\x20name:'+Z);const A=F[y(0x187)]?.['map'](o=>o[y(0x188)]+'\x20')['join']('\x20')||'',H=F['where']?y(0x189)+F['where']+')':'',b=await P['pg']['query'](y(0x18a)+readableFields(F)['join'](',\x20')+y(0x18b)+qt(F['table'])+'\x20t\x20'+A+y(0x18c)+qi(F['key'])+'=$1'+H+'\x20LIMIT\x201',[q]),E=b['rows'][0x0];if(!E)return null;await addDictionaryLookupData([E],F['fields'],P[y(0x18d)]),await addTableLookupData([E],F[y(0x18e)],P['pg']),addFileToken([E],F['fields'],P[y(0x18f)]);const z=(query['include']==='all'?Object[y(0x190)](F['relations']||{}):null)||(Array[y(0x191)](query['include'])?query[y(0x192)]:query['include']?.[y(0x193)](',')??[]),x=createFindRelation(P,G);for(const o of z){E[o]=await x({'name':Z,'id':q,'relation':o,'query':query,'user':p})['then'](i=>i['rows']??[])['then'](i=>F['relations']?.[o]?.[y(0x194)]==='one'?i[0x0]??null:i);}return E['time']=Date['now']()-X,E;};}
@@ -1 +1 @@
1
- {"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CAyEjB"}
1
+ {"version":3,"file":"find-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find-relation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,oCAOvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,GAAG,CAAC,CA+GjB"}
@@ -1 +1 @@
1
- import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function c(J,e){J=J-0x12b;const p=L();let b=p[J];return b;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';export function createFindRelation(J,e){return async function p({name:b,id:F,relation:P,query:query={}}){const d=c,h=Date[d(0x12b)](),u=Math['min'](Math['max'](query[d(0x12c)]??0x14,0x1),0xc8),H=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](u)||!Number['isFinite'](H))throw new ValidationError('Invalid\x20pagination');if(P===d(0x12d)){const a=await J['pg'][d(0x12e)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[b,String(F)]);return{'total':a[d(0x12f)]['length'],'time':Date[d(0x12b)]()-h,'rows':a['rows']};}if(P===d(0x130)){const M=await J['pg']['query'](d(0x131),[b,String(F)]);return addFileToken(M[d(0x12f)],{'file_path':{'type':d(0x132)}},J['file']),{'total':M['rows']['length'],'time':Date['now']()-h,'rows':M['rows']};}const D=e['get'](b),U=D[d(0x133)]?.[P];if(!U?.['foreignKey']||!U['resource']&&!U['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+P+'\x22\x20requires\x20a\x20project/provider\x20implementation');const w=U[d(0x134)]?e[d(0x135)](U['resource']):undefined,X=U[d(0x136)]??w['table'],E=w?.['key']??'id',Q=U['fields']?.['length']?U['fields'][d(0x137)](qi)[d(0x138)](',\x20'):'*',T='SELECT\x20'+Q+'\x20FROM\x20'+qt(X)+'\x20WHERE\x20\x0a\x20\x20\x20\x20'+qi(E)+'\x20=\x20(select\x20'+qi(U['foreignKey'])+'\x20FROM\x20'+qt(D['table'])+d(0x139)+qi(D['key'])+d(0x13a),l=await J['pg']['query'](T,[F,u,H]);return w&&(await addDictionaryLookupData(l['rows'],w['fields'],J['dictionary']),await addTableLookupData(l['rows'],w['fields'],J['pg']),addFileToken(l['rows'],w['fields'],J['file'])),{'limit':u,'offset':H,'total':l[d(0x12f)][d(0x13b)],'time':Date['now']()-h,'rows':l[d(0x12f)]??null};};}function L(){const A=['now','limit','notes','query','rows','files','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','file','relations','resource','get','table','map','join','\x20WHERE\x20','\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3','length'];L=function(){return A;};return L();}
1
+ function C(P,G){P=P-0x137;const j=m();let Z=j[P];return Z;}import{UnsupportedError,ValidationError}from'../../../errors.js';function m(){const n=['now','max','isFinite','includes','\x22\x20requires\x20a\x20capabilities\x20\x22','notes','query','rows','files','SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC','resource','get','key','keys','junctionTable','JOIN\x20','junctionForeignKey','\x20=\x20t.','\x20=\x20(SELECT\x20','\x20FROM\x20','table','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20','sql','\x20t\x20','fields'];m=function(){return n;};return m();}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';export function createFindRelation(P,G){return async function j({name:Z,id:q,relation:p,query:query={}}){const a=C,X=Date[a(0x137)](),F=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[a(0x138)](query['offset']??0x0,0x0);if(!Number['isFinite'](F)||!Number[a(0x139)](A))throw new ValidationError('Invalid\x20pagination');const H=G['get'](Z),b=H['relations']?.[p];if(['notes','files'][a(0x13a)](p)&&!H['capabilities']?.['includes'](p))throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+a(0x13b)+p+'\x22');if(p===a(0x13c)){const L=await P['pg'][a(0x13d)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[Z,String(q)]);return{'total':L[a(0x13e)]['length'],'time':Date['now']()-X,'rows':L['rows']};}if(p===a(0x13f)){const O=await P['pg'][a(0x13d)](a(0x140),[Z,String(q)]);return addFileToken(O['rows'],{'file_path':{'type':'file'}},P['file']),{'total':O[a(0x13e)]['length'],'time':Date['now']()-X,'rows':O['rows']};}if(!b?.[a(0x141)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+p+'\x22\x20requires\x20a\x20project/provider\x20implementation');const E=G[a(0x142)](b['resource']),z=E?.[a(0x143)]??'id',x=E?.['table'],o=Object[a(0x144)](E?.['fields']??{})['filter'](N=>E?.['fields'][N]?.['read']&&E?.['fields'][N]?.['scope']!=='item')['map'](qi)['join'](',\x20'),i=b['fields']?.['join'](',\x20')||o||'*';b['foreignKey']&&autoIndex(x,b['foreignKey'],'btree',P['pg']);const y=b[a(0x145)]?a(0x146)+qt(b['junctionTable'])+'\x20j\x20ON\x20j.'+qi(b[a(0x147)])+a(0x148)+(b['junctionTargetKey']||qi(z))+'\x20WHERE\x20'+qi(b['junctionLocalKey'])+'\x20=\x20$1\x20':'where\x20'+(b['foreignKey']||qi(z))+a(0x149)+qi(b['localKey']||H[a(0x143)])+a(0x14a)+qt(H[a(0x14b)])+a(0x14c)+qi(H['key'])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)\x20'+(b['where']?'AND\x20('+b['where']+')':''),T=E['joins']?.['map'](N=>N[a(0x14d)]+'\x20')['join']('\x20')||'',D='SELECT\x20'+i+'\x20FROM\x20'+qt(x)+a(0x14e)+T+'\x20'+y+'\x20LIMIT\x20$2\x20OFFSET\x20$3',h=await P['pg']['query'](D,[q,F,A]);return E&&(await addDictionaryLookupData(h[a(0x13e)],E[a(0x14f)],P['dictionary']),await addTableLookupData(h['rows'],E['fields'],P['pg']),addFileToken(h['rows'],E['fields'],P['file'])),{'limit':F,'offset':A,'total':h['rows']['length'],'time':Date['now']()-X,'rows':h['rows']??null};};}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAsChC"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/find.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,YAAY,EACb,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQhE,wBAAgB,UAAU,CACxB,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,4BAMvB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,kBAAkB,CAAC,CAwFhC"}
@@ -1 +1 @@
1
- import{ValidationError}from'../../../errors.js';import{buildFilters}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';function c(J,e){J=J-0x75;const p=L();let b=p[J];return b;}import{addTableLookupData}from'./add-table-lookup-data.js';function L(){const T=['min','max','filter','sort','isFinite','SELECT\x20','OFFSET\x20$','fields','now'];L=function(){return T;};return L();}import{addFileToken}from'./add-file-token.js';export function createFind(J,e){return async function p({name:b,query:query={},user:F}){const Q=c,P=Date['now'](),h=e['get'](b);assertOperation(h,'read',F);const u=Math[Q(0x75)](Math[Q(0x76)](query['limit']??0x14,0x1),0xc8),H=Math[Q(0x76)](query['offset']??0x0,0x0),D=buildFilters(h,query[Q(0x77)],0x1,J['pg']),U=buildSort(h,query[Q(0x78)]);if(!Number['isFinite'](u)||!Number[Q(0x79)](H))throw new ValidationError('Invalid\x20pagination');const w=Q(0x7a)+readableFields(h)['join'](',\x20')+'\x20'+('FROM\x20'+qt(h['table']))+(''+D['sql']+U+'\x20')+('LIMIT\x20$'+(D['values']['length']+0x1)+'\x20')+(Q(0x7b)+(D['values']['length']+0x2)),X=await J['pg']['query'](w,[...D['values'],u,H]),E=X['rows'];return await addDictionaryLookupData(E,h[Q(0x7c)],J['dictionary']),await addTableLookupData(E,h[Q(0x7c)],J['pg']),addFileToken(E,h['fields'],J['file']),{'limit':u,'offset':H,'total':X['rowCount'],'time':Date[Q(0x7d)]()-P,'rows':E};};}
1
+ import{ValidationError}from'../../../errors.js';import{buildFilters,buildIndex}from'../utils/filters.js';import{assertOperation}from'../utils/permissions.js';import{buildSort}from'../utils/sort.js';import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';import{addFileToken}from'./add-file-token.js';import{autoIndex}from'../utils/auto-index.js';function C(P,G){P=P-0x1bf;const j=m();let Z=j[P];return Z;}function m(){const N=['now','read','min','max','where','table','text','values','push','lower(',')\x20LIKE\x20$','length','scope','scopes','\x20WHERE\x20','true','sql','joins','item','join','\x20t\x20','replace','query','rowCount','fields'];m=function(){return N;};return m();}import{buildSummary}from'../utils/summary.js';import{buildUserResourceScopeFilter}from'../utils/scope.js';export function createFind(P,G){return async function j({name:Z,query:query={},user:q}){const O=C,p=Date[O(0x1bf)](),X=G['get'](Z);assertOperation(X,O(0x1c0),q);const F=Math[O(0x1c1)](Math['max'](query['limit']??0x14,0x1),0xc8),A=Math[O(0x1c2)](query['offset']??0x0,0x0);buildIndex(X,query['filter'],P['pg']);const H=buildFilters(X,query['filter']);X[O(0x1c3)]&&(H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('('+X[O(0x1c3)]+')'));const b=buildSort(X,query['sort']);if(!Number['isFinite'](F)||!Number['isFinite'](A))throw new ValidationError('Invalid\x20pagination');const E=X['searchable']||Object['keys'](X['fields'])['filter'](L=>X['fields'][L]?.['searchable']);query['search']&&E['length']&&(E['map'](L=>autoIndex(X[O(0x1c4)],L,O(0x1c5),P['pg'])),H[O(0x1c6)][O(0x1c7)](query['search']['toLowerCase']()+'%'),H['sql']+=(H['sql']?'\x20AND\x20':'\x20WHERE\x20')+('\x20('+E?.['map'](L=>O(0x1c8)+qt(L)+O(0x1c9)+H[O(0x1c6)][O(0x1ca)])['join']('\x20OR\x20')+')'));if(query[O(0x1cb)]&&X[O(0x1cc)]?.[query[O(0x1cb)]]===undefined)throw new ValidationError('Unknown\x20scope:\x20'+query[O(0x1cb)]);const z=query[O(0x1cb)]||(X[O(0x1cc)]?.['default']?'default':undefined);z&&(H['sql']+=(H['sql']?'\x20AND\x20':O(0x1cd))+('('+(X['scopes']?.[z]||O(0x1ce))+')'));const x=await buildUserResourceScopeFilter(X,q,P['pg'],H['values']['length']+0x1);x['sql']&&(H[O(0x1cf)]+=(H[O(0x1cf)]?'\x20AND\x20':'\x20WHERE\x20')+('('+x['sql']+')'),H[O(0x1c6)][O(0x1c7)](...x[O(0x1c6)]));const o=X[O(0x1d0)]?.['filter'](L=>L[O(0x1cb)]!==O(0x1d1))['map'](L=>L[O(0x1cf)]+'\x20')[O(0x1d2)]('\x20')||'',i='SELECT\x20'+readableFields(X,'all')['join'](',\x20')+'\x20'+('FROM\x20'+qt(X[O(0x1c4)])+O(0x1d3))+(o+'\x20'+H[O(0x1cf)][O(0x1d4)](/:uid/g,'\x27'+(q?.['id']??'NULL')+'\x27')+'\x20'+b+'\x20')+('LIMIT\x20$'+(H['values'][O(0x1ca)]+0x1)+'\x20')+('OFFSET\x20$'+(H['values']['length']+0x2)),y=buildSummary(X,query,q,x),[T,D]=await Promise['all']([P['pg'][O(0x1d5)](i,[...H['values'],F,A]),P['pg']['query'](y['sql'],y['values'])['then'](L=>L['rows'][0x0]??{})]),h=T['rows'];return await addDictionaryLookupData(h,X['fields'],P['dictionary']),await addTableLookupData(h,X['fields'],P['pg']),addFileToken(h,X['fields'],P['file']),{'time':Date[O(0x1bf)]()-p,'limit':F,'offset':A,'count':T[O(0x1d6)],'total':D?.['count']??0x0,'summary':D,'rows':h,...query['include']?.['includes'](O(0x1d7))?{'fields':X[O(0x1d7)]}:{}};};}
@@ -0,0 +1,8 @@
1
+ import type { ResourceDependencies } from "../resource.types.js";
2
+ type Field = {
3
+ name: string;
4
+ title: string | null | undefined;
5
+ };
6
+ export declare function getTableColumns(table: string, deps: ResourceDependencies): Promise<Field[]>;
7
+ export {};
8
+ //# sourceMappingURL=get-table-columns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-table-columns.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/get-table-columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,oBAAoB,GACzB,OAAO,CAAC,KAAK,EAAE,CAAC,CAoBlB"}
@@ -0,0 +1 @@
1
+ function m(){const p=['not\x20enough\x20params:\x20table','then'];m=function(){return p;};return m();}function C(P,G){P=P-0x134;const j=m();let Z=j[P];return Z;}export async function getTableColumns(P,G){const q=C;if(!P)throw new Error(q(0x134));if(!G?.['pg'])return[];const j=await G['pg']['query']('\x0a\x20\x20\x20\x20select\x0a\x20\x20\x20\x20\x20\x20\x20\x20attname\x20as\x20name,\x20pg_catalog.col_description(attrelid,attnum)\x20as\x20title\x0a\x20\x20\x20\x20from\x20pg_catalog.pg_attribute\x20where\x20attrelid=$1::regclass\x20and\x20attnum>0\x20and\x20NOT\x20attisdropped',[P])[q(0x135)](Z=>Z['rows']||[]);return j;}
@@ -1,11 +1,14 @@
1
1
  import type { ResourceDependencies, ResourceUser } from "../resource.types.js";
2
2
  import type { ResourceRegistry } from "../resource.registry.js";
3
- export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: {
3
+ import type { AppContext } from "../../../context.js";
4
+ type UpdateRelationParams = {
4
5
  name: string;
5
6
  id: string | number;
6
7
  relation: string;
7
8
  relationId: string | number;
8
9
  data: Record<string, unknown>;
9
10
  user?: ResourceUser;
10
- }) => Promise<Record<string, unknown>>;
11
+ };
12
+ export declare function createUpdateRelation(deps: ResourceDependencies, registry: ResourceRegistry): ({ name, id, relation, relationId, data, user, }: UpdateRelationParams, ctx?: AppContext) => Promise<Record<string, unknown>>;
13
+ export {};
11
14
  //# sourceMappingURL=update-relation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAWvB;IACC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0BvC"}
1
+ {"version":3,"file":"update-relation.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/update-relation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,oBAAoB,CAChC,IAAI,EAAE,oBAAoB,EAC1B,QAAQ,EAAE,gBAAgB,qDAI4D,oBAAoB,QAAQ,UAAU,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAclK"}
@@ -1 +1 @@
1
- function c(J,e){J=J-0x118;const p=L();let b=p[J];return b;}function L(){const E=['empty\x20pg','resource','foreignKey'];L=function(){return E;};return L();}import{UnsupportedError}from'../../../errors.js';import{createUpdate}from'./update.js';export function createUpdateRelation(J,e){const p=createUpdate(J,e);return async function b({name:F,id:P,relation:h,relationId:u,data:H,user:D}){const X=c;if(!J['pg'])throw new Error(X(0x118));const U=e['get'](F),w=U['relations']?.[h];if(!w?.[X(0x119)]||!w[X(0x11a)])throw new UnsupportedError('Relation\x20update\x20is\x20not\x20configured:\x20'+h);return p({'name':w['resource'],'id':u,'data':H,'user':D});};}
1
+ function C(P,G){P=P-0x96;const j=m();let Z=j[P];return Z;}import{UnsupportedError,ValidationError}from'../../../errors.js';import{createUpdate}from'./update.js';function m(){const o=['relations','resource','foreignKey','Relation\x20update\x20is\x20not\x20configured:\x20','hasOwn'];m=function(){return o;};return m();}export function createUpdateRelation(P,G){const j=createUpdate(P,G);return async function Z({name:q,id:p,relation:X,relationId:F,data:A,user:H},b){const x=C,E=G['get'](q),z=E[x(0x96)]?.[X];if(!z?.[x(0x97)]||!z[x(0x98)])throw new UnsupportedError(x(0x99)+X);if(Object[x(0x9a)](A,z['foreignKey'])&&A[z[x(0x98)]]!==p)throw new ValidationError('Cannot\x20change\x20relation:\x20'+z[x(0x98)]);return j({'name':z['resource'],'id':F,'data':A,'user':H,'where':{'column':z[x(0x98)],'value':p}},b);};}
@@ -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