@opengis/fcore 0.0.1-beta.8 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +71 -71
  3. package/dist/config.d.ts +1 -0
  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 +0 -3
  9. package/dist/fastify.d.ts.map +1 -1
  10. package/dist/fastify.js +1 -1
  11. package/dist/fcore.d.ts.map +1 -1
  12. package/dist/fcore.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.js +1 -1
  16. package/dist/modules/auth/passwd-cli.js +1 -1
  17. package/dist/modules/auth/permission-cli.js +1 -1
  18. package/dist/modules/auth/route.d.ts.map +1 -1
  19. package/dist/modules/auth/route.js +1 -1
  20. package/dist/modules/auth/schema.js +1 -1
  21. package/dist/modules/auth/services/change-password.js +1 -1
  22. package/dist/modules/auth/services/get-current-user.d.ts +2 -0
  23. package/dist/modules/auth/services/get-current-user.d.ts.map +1 -1
  24. package/dist/modules/auth/services/get-current-user.js +1 -1
  25. package/dist/modules/auth/services/registration.js +1 -1
  26. package/dist/modules/auth/services/verify-two-factor.js +1 -1
  27. package/dist/modules/file/mime.js +1 -1
  28. package/dist/modules/file/route.js +1 -1
  29. package/dist/modules/file/schema.js +1 -1
  30. package/dist/modules/file/services/get-file.js +1 -1
  31. package/dist/modules/file/services/resize-file.js +1 -1
  32. package/dist/modules/file/services/upload-file.d.ts.map +1 -1
  33. package/dist/modules/file/services/upload-file.js +1 -1
  34. package/dist/modules/resource/route.d.ts.map +1 -1
  35. package/dist/modules/resource/route.js +1 -1
  36. package/dist/modules/resource/schema.d.ts +19 -0
  37. package/dist/modules/resource/schema.d.ts.map +1 -1
  38. package/dist/modules/resource/schema.js +1 -1
  39. package/dist/modules/resource/services/add-note.js +1 -1
  40. package/dist/modules/resource/services/add-resource-file.js +1 -1
  41. package/dist/modules/resource/services/create-resource-relation.js +1 -1
  42. package/dist/modules/resource/services/create-resource.js +1 -1
  43. package/dist/modules/resource/services/delete-resource-relation.js +1 -1
  44. package/dist/modules/resource/services/delete-resource.js +1 -1
  45. package/dist/modules/resource/services/export-resource.js +1 -1
  46. package/dist/modules/resource/services/generate-resource-code.d.ts +16 -0
  47. package/dist/modules/resource/services/generate-resource-code.d.ts.map +1 -0
  48. package/dist/modules/resource/services/generate-resource-code.js +1 -0
  49. package/dist/modules/resource/services/get-resource-schema.d.ts +6 -0
  50. package/dist/modules/resource/services/get-resource-schema.d.ts.map +1 -0
  51. package/dist/modules/resource/services/get-resource-schema.js +1 -0
  52. package/dist/modules/resource/services/get-resource.js +1 -1
  53. package/dist/modules/resource/services/list-resource-as-user.d.ts +8 -0
  54. package/dist/modules/resource/services/list-resource-as-user.d.ts.map +1 -0
  55. package/dist/modules/resource/services/list-resource-as-user.js +1 -0
  56. package/dist/modules/resource/services/list-resource-list.d.ts +20 -0
  57. package/dist/modules/resource/services/list-resource-list.d.ts.map +1 -0
  58. package/dist/modules/resource/services/list-resource-list.js +1 -0
  59. package/dist/modules/resource/services/list-resource-relation.js +1 -1
  60. package/dist/modules/resource/services/list-resources.d.ts.map +1 -1
  61. package/dist/modules/resource/services/list-resources.js +1 -1
  62. package/dist/modules/resource/services/search-resource.js +1 -1
  63. package/dist/modules/resource/services/suggest-resource.js +1 -1
  64. package/dist/modules/resource/services/update-resource-relation.js +1 -1
  65. package/dist/modules/resource/services/update-resource.js +1 -1
  66. package/dist/modules/resource/services/upload-resource-file.js +1 -1
  67. package/dist/modules/system/route.d.ts.map +1 -1
  68. package/dist/modules/system/route.js +1 -1
  69. package/dist/modules/system/schema.d.ts +25 -2
  70. package/dist/modules/system/schema.d.ts.map +1 -1
  71. package/dist/modules/system/schema.js +1 -1
  72. package/dist/modules/system/services/check-system.js +1 -1
  73. package/dist/modules/system/services/get-access.d.ts +1 -0
  74. package/dist/modules/system/services/get-access.d.ts.map +1 -1
  75. package/dist/modules/system/services/get-access.js +1 -1
  76. package/dist/modules/system/services/get-api-list.js +1 -1
  77. package/dist/modules/system/services/get-audit-log.d.ts.map +1 -1
  78. package/dist/modules/system/services/get-audit-log.js +1 -1
  79. package/dist/modules/system/services/get-dictionary.js +1 -1
  80. package/dist/modules/system/services/get-resource-access.d.ts +23 -0
  81. package/dist/modules/system/services/get-resource-access.d.ts.map +1 -0
  82. package/dist/modules/system/services/get-resource-access.js +1 -0
  83. package/dist/modules/system/services/get-resource-scopes.d.ts +16 -0
  84. package/dist/modules/system/services/get-resource-scopes.d.ts.map +1 -0
  85. package/dist/modules/system/services/get-resource-scopes.js +1 -0
  86. package/dist/modules/system/services/get-system-log.js +1 -1
  87. package/dist/modules/system/services/get-system-settings.js +1 -1
  88. package/dist/modules/system/services/list-dictionaries.js +1 -1
  89. package/dist/modules/system/services/set-access.d.ts +3 -1
  90. package/dist/modules/system/services/set-access.d.ts.map +1 -1
  91. package/dist/modules/system/services/set-access.js +1 -1
  92. package/dist/modules/system/services/set-resource-access.d.ts +18 -0
  93. package/dist/modules/system/services/set-resource-access.d.ts.map +1 -0
  94. package/dist/modules/system/services/set-resource-access.js +1 -0
  95. package/dist/modules/system/services/set-resource-scopes.d.ts +10 -0
  96. package/dist/modules/system/services/set-resource-scopes.d.ts.map +1 -0
  97. package/dist/modules/system/services/set-resource-scopes.js +1 -0
  98. package/dist/modules/system/services/update-dictionary.js +1 -1
  99. package/dist/modules/system/services/update-system-settings.js +1 -1
  100. package/dist/modules/utils/require-admin.js +1 -1
  101. package/dist/modules/utils/safe-user.js +1 -1
  102. package/dist/modules/utils/unsupported.js +1 -1
  103. package/dist/plugins/audit/audit.js +1 -1
  104. package/dist/plugins/audit/audit.types.d.ts +1 -1
  105. package/dist/plugins/audit/audit.types.d.ts.map +1 -1
  106. package/dist/plugins/audit/services/write-audit.js +1 -1
  107. package/dist/plugins/auth/get-user-permissions.js +1 -1
  108. package/dist/plugins/auth/index.d.ts.map +1 -1
  109. package/dist/plugins/auth/index.js +1 -1
  110. package/dist/plugins/auth/verifyUser.js +1 -1
  111. package/dist/plugins/dictionary.js +1 -1
  112. package/dist/plugins/file.d.ts +7 -3
  113. package/dist/plugins/file.d.ts.map +1 -1
  114. package/dist/plugins/file.js +1 -1
  115. package/dist/plugins/jwt.js +1 -1
  116. package/dist/plugins/logger/index.js +1 -1
  117. package/dist/plugins/logger/transport.js +1 -1
  118. package/dist/plugins/pg.d.ts +4 -2
  119. package/dist/plugins/pg.d.ts.map +1 -1
  120. package/dist/plugins/pg.js +1 -1
  121. package/dist/plugins/redis.d.ts.map +1 -1
  122. package/dist/plugins/redis.js +1 -1
  123. package/dist/plugins/resource/resource.d.ts +1 -1
  124. package/dist/plugins/resource/resource.d.ts.map +1 -1
  125. package/dist/plugins/resource/resource.js +1 -1
  126. package/dist/plugins/resource/resource.registry.d.ts +3 -2
  127. package/dist/plugins/resource/resource.registry.d.ts.map +1 -1
  128. package/dist/plugins/resource/resource.registry.js +1 -1
  129. package/dist/plugins/resource/resource.types.d.ts +71 -17
  130. package/dist/plugins/resource/resource.types.d.ts.map +1 -1
  131. package/dist/plugins/resource/services/add-dictionary-lookup-data.js +1 -1
  132. package/dist/plugins/resource/services/add-file-token.js +1 -1
  133. package/dist/plugins/resource/services/add-table-lookup-data.d.ts.map +1 -1
  134. package/dist/plugins/resource/services/add-table-lookup-data.js +1 -1
  135. package/dist/plugins/resource/services/create-relation.d.ts +5 -2
  136. package/dist/plugins/resource/services/create-relation.d.ts.map +1 -1
  137. package/dist/plugins/resource/services/create-relation.js +1 -1
  138. package/dist/plugins/resource/services/create.d.ts +5 -2
  139. package/dist/plugins/resource/services/create.d.ts.map +1 -1
  140. package/dist/plugins/resource/services/create.js +1 -1
  141. package/dist/plugins/resource/services/delete-relation.d.ts +6 -3
  142. package/dist/plugins/resource/services/delete-relation.d.ts.map +1 -1
  143. package/dist/plugins/resource/services/delete-relation.js +1 -1
  144. package/dist/plugins/resource/services/delete.d.ts +9 -2
  145. package/dist/plugins/resource/services/delete.d.ts.map +1 -1
  146. package/dist/plugins/resource/services/delete.js +1 -1
  147. package/dist/plugins/resource/services/find-one.d.ts.map +1 -1
  148. package/dist/plugins/resource/services/find-one.js +1 -1
  149. package/dist/plugins/resource/services/find-relation.d.ts.map +1 -1
  150. package/dist/plugins/resource/services/find-relation.js +1 -1
  151. package/dist/plugins/resource/services/find.d.ts.map +1 -1
  152. package/dist/plugins/resource/services/find.js +1 -1
  153. package/dist/plugins/resource/services/get-table-columns.d.ts +8 -0
  154. package/dist/plugins/resource/services/get-table-columns.d.ts.map +1 -0
  155. package/dist/plugins/resource/services/get-table-columns.js +1 -0
  156. package/dist/plugins/resource/services/update-relation.d.ts +5 -2
  157. package/dist/plugins/resource/services/update-relation.d.ts.map +1 -1
  158. package/dist/plugins/resource/services/update-relation.js +1 -1
  159. package/dist/plugins/resource/services/update.d.ts +9 -2
  160. package/dist/plugins/resource/services/update.d.ts.map +1 -1
  161. package/dist/plugins/resource/services/update.js +1 -1
  162. package/dist/plugins/resource/utils/auto-index.js +1 -1
  163. package/dist/plugins/resource/utils/fields.js +1 -1
  164. package/dist/plugins/resource/utils/filters.d.ts +2 -1
  165. package/dist/plugins/resource/utils/filters.d.ts.map +1 -1
  166. package/dist/plugins/resource/utils/filters.js +1 -1
  167. package/dist/plugins/resource/utils/permissions.js +1 -1
  168. package/dist/plugins/resource/utils/scope.d.ts +10 -0
  169. package/dist/plugins/resource/utils/scope.d.ts.map +1 -0
  170. package/dist/plugins/resource/utils/scope.js +1 -0
  171. package/dist/plugins/resource/utils/sort.d.ts +1 -1
  172. package/dist/plugins/resource/utils/sort.d.ts.map +1 -1
  173. package/dist/plugins/resource/utils/sort.js +1 -1
  174. package/dist/plugins/resource/utils/sql.d.ts +1 -1
  175. package/dist/plugins/resource/utils/sql.d.ts.map +1 -1
  176. package/dist/plugins/resource/utils/sql.js +1 -1
  177. package/dist/plugins/resource/utils/summary.d.ts +7 -0
  178. package/dist/plugins/resource/utils/summary.d.ts.map +1 -0
  179. package/dist/plugins/resource/utils/summary.js +1 -0
  180. package/dist/shared/getIP.js +1 -1
  181. package/migrations/20260903120000_core_schema.sql +5 -2
  182. package/migrations/20260903130000_move_notes_files_to_admin.sql +17 -17
  183. package/migrations/20260903130001_add_file_fields.sql +5 -0
  184. package/migrations/20260903140000_settings_nulls_not_distinct.sql +18 -18
  185. package/migrations/20260907090000_core_schema.sql +32 -2
  186. package/migrations/20260910170000_core_schema.sql +22 -0
  187. package/migrations/20260929120000_allow_user_only_role_scopes.sql +2 -0
  188. package/migrations/20260929_role_scope.sql +32 -0
  189. package/package.json +93 -93
@@ -1 +1 @@
1
- {"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IAEjE,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,QAOpD;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,WAEf;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,oBAKf;IAED,IAAI,uBAEH;IAED,OAAO,CAAC,QAAQ;CAQnB"}
1
+ {"version":3,"file":"resource.registry.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.registry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuC;IACjE,UAAU,CAAC,IAAI,EAAE,MAAM,QAEtB;IACD,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,EAAE,EAAE,SAAS,UAAQ,QAUvE;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,WAEf;IAED,GAAG,CAAC,IAAI,EAAE,MAAM,oBAIf;IAED,IAAI,uBAEH;IAED,OAAO,CAAC,QAAQ;CAajB"}
@@ -1 +1 @@
1
- const p=A;import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function A(z,j){z=z-0x193;const c=U();let p=c[z];return p;}function validQualified(z){return z['split']('.')['length']<=0x2&&z['split']('.')['every'](j=>ident['test'](j));}export class ResourceRegistry{['resources']=new Map();[p(0x193)](z){const M=p;for(const j of Array[M(0x194)](z)?z:[z]){this[M(0x195)](j);if(this['resources'][M(0x196)](j['name']))throw new ConflictError('Resource\x20already\x20registered:\x20'+j['name']);this['resources']['set'](j['name'],j);}}['has'](z){const H=p;return this['resources'][H(0x196)](z);}['get'](z){const j=this['resources']['get'](z);if(!j)throw new NotFoundError('Resource\x20not\x20registered:\x20'+z);return j;}['list'](){const i=p;return[...this[i(0x197)]['values']()];}['validate'](z){const b=p;if(z['version']!==0x1||!ident[b(0x198)](z['name'])||!validQualified(z['table'])||!ident['test'](z['key']))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+z['name']);for(const [j,c]of Object['entries'](z[b(0x199)])){if(!ident[b(0x198)](j)||!ident[b(0x198)](c['column']??j))throw new ValidationError(b(0x19a)+j);}}}function U(){const n=['register','isArray','validate','has','resources','test','fields','Invalid\x20resource\x20field:\x20'];U=function(){return n;};return U();}
1
+ import{ValidationError,ConflictError,NotFoundError}from'../../errors.js';const ident=/^[a-zA-Z0-9_-]*$/;function C(P,G){P=P-0x10f;const j=m();let Z=j[P];return Z;}function validQualified(P){const Z=C;return P[Z(0x10f)]('.')['length']<=0x2&&P['split']('.')['every'](G=>ident['test'](G));}export class ResourceRegistry{['resources']=new Map();['unregister'](P){const q=C;this[q(0x110)]['delete'](P);}['register'](P,G=![]){const p=C;for(const j of Array['isArray'](P)?P:[P]){this[p(0x111)](j);if(this['resources'][p(0x112)](j['name'])&&!G)throw new ConflictError('Resource\x20already\x20registered:\x20'+j[p(0x113)]);this['resources'][p(0x114)](j[p(0x113)],j);}}['has'](P){return this['resources']['has'](P);}['get'](P){const G=this['resources']['get'](P);if(!G)throw new NotFoundError('Resource\x20not\x20registered:\x20'+P);return G;}['list'](){return[...this['resources']['values']()];}['validate'](P){const X=C;if(P['version']!==0x1||!ident[X(0x115)](P[X(0x113)])||!validQualified(P['table'])||!ident['test'](P[X(0x116)]))throw new ValidationError('Invalid\x20resource\x20contract:\x20'+P[X(0x113)]);for(const [G,j]of Object[X(0x117)](P[X(0x118)])){if(!ident['test'](G)||!ident['test'](j['column']??G))throw new ValidationError(X(0x119)+G);}}}function m(){const F=['split','resources','validate','has','name','set','test','key','entries','fields','Invalid\x20resource\x20field:\x20'];m=function(){return F;};return m();}
@@ -7,7 +7,29 @@ import type { AuditPlugin } from "../audit/index.js";
7
7
  import type { DictionaryPlugin } from "../dictionary.js";
8
8
  import type { FileAdapter } from "../file.js";
9
9
  import { User } from "../../context.js";
10
+ import type { AppContext } from "../../context.js";
11
+ export type ResourceAggregate = "count" | "countDistinct" | "sum" | "avg" | "min" | "max";
12
+ export type ResourceSummaryItem = {
13
+ aggregate: "count";
14
+ where?: string;
15
+ } | {
16
+ aggregate: "countDistinct" | "sum" | "avg" | "min" | "max";
17
+ field: string;
18
+ where?: string;
19
+ } | {
20
+ sql: string;
21
+ };
22
+ interface ResourceScope {
23
+ where?: string;
24
+ fields?: string[];
25
+ sort?: string;
26
+ limit?: number;
27
+ }
10
28
  export type ResourceOperation = "read" | "create" | "update" | "delete";
29
+ export interface ResourceJoinContract {
30
+ scope?: "all" | "item";
31
+ sql: string;
32
+ }
11
33
  export interface ResourceFieldContract {
12
34
  column?: string;
13
35
  type?: "string" | "number" | "integer" | "boolean" | "date" | "json" | "text" | "timestamp" | "uuid" | "file" | "geometry" | "geom";
@@ -16,18 +38,19 @@ export interface ResourceFieldContract {
16
38
  readable?: boolean;
17
39
  writable?: boolean;
18
40
  required?: boolean;
41
+ code_template?: string;
19
42
  nullable?: boolean;
20
43
  filterable?: boolean;
21
44
  searchable?: boolean;
22
45
  sortable?: boolean;
23
46
  filter?: boolean;
24
- sort?: boolean;
25
- search?: boolean;
47
+ scope?: "all" | "item";
48
+ dictionary?: string;
26
49
  lookup?: {
27
- dictionary?: string;
28
- table?: string;
29
- valueField?: string;
30
- textField?: string;
50
+ table: string;
51
+ value: string;
52
+ text: string;
53
+ fields?: string[];
31
54
  };
32
55
  enum?: string[] | number[];
33
56
  minLength?: number;
@@ -36,42 +59,71 @@ export interface ResourceFieldContract {
36
59
  maximum?: number;
37
60
  pattern?: string;
38
61
  }
62
+ export type ResourceRelationType = 'one' | 'many';
39
63
  export interface ResourceRelationContract {
64
+ type?: ResourceRelationType;
40
65
  resource?: string;
41
66
  table?: string;
42
- sourceField?: string;
67
+ where?: string;
68
+ localKey?: string;
43
69
  foreignKey?: string;
44
- targetField?: string;
45
- type?: "one" | "many";
70
+ targetKey?: string;
46
71
  fields?: string[];
72
+ junctionTable?: string;
73
+ junctionLocalKey?: string;
74
+ junctionForeignKey?: string;
75
+ junctionTargetKey?: string;
47
76
  }
48
77
  export interface ResourceContract {
49
78
  version: 1;
50
79
  name: string;
51
- module: string;
80
+ module?: string;
52
81
  title?: string;
53
82
  table: string;
83
+ where?: string;
54
84
  key: string;
85
+ display?: string[] | string;
55
86
  operations: ResourceOperation[];
87
+ searchable?: string[];
56
88
  capabilities?: string[];
57
89
  permission?: string;
58
90
  fields: Record<string, ResourceFieldContract>;
59
91
  relations?: Record<string, ResourceRelationContract>;
92
+ joins?: ResourceJoinContract[];
60
93
  access?: "public" | "user" | "admin";
94
+ summary?: Record<string, ResourceSummaryItem>;
95
+ scopes?: Record<string, string | ResourceScope>;
96
+ }
97
+ export interface ResourceVariableDto {
98
+ key: string;
99
+ path: string;
100
+ title?: string;
101
+ type: "string" | "number" | "boolean" | "object" | "array";
102
+ resource?: string;
103
+ variables?: ResourceVariableDto[];
104
+ }
105
+ export interface ResourceSchemaDto {
106
+ resource: string;
107
+ title?: string;
108
+ variables: ResourceVariableDto[];
61
109
  }
62
110
  export interface ResourceQuery {
63
111
  filter?: Record<string, unknown>;
64
112
  include?: string | string[];
65
113
  sort?: string[];
66
114
  search?: string;
115
+ scope?: string;
67
116
  limit?: number;
68
117
  offset?: number;
69
118
  fields?: string[];
70
119
  }
71
120
  export interface ResourceListResult<T = Record<string, unknown>> {
72
121
  rows: T[];
122
+ summary: Record<string, unknown>;
73
123
  limit: number;
74
124
  time: number;
125
+ fields?: Record<string, ResourceFieldContract>;
126
+ count: number | null;
75
127
  total: number | null;
76
128
  offset: number;
77
129
  }
@@ -84,7 +136,8 @@ export interface ResourceDependencies {
84
136
  file?: FileAdapter;
85
137
  }
86
138
  export interface ResourcePlugin {
87
- register(input: ResourceContract | ResourceContract[]): void;
139
+ register(input: ResourceContract | ResourceContract[], overwrite?: boolean): void;
140
+ unregister(name: string): void;
88
141
  has(name: string): boolean;
89
142
  get(name: string): ResourceContract;
90
143
  list(): ResourceContract[];
@@ -103,18 +156,18 @@ export interface ResourcePlugin {
103
156
  name: string;
104
157
  data: Record<string, unknown>;
105
158
  user?: ResourceUser;
106
- }): Promise<Record<string, unknown>>;
159
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
107
160
  update(params: {
108
161
  name: string;
109
162
  id: string | number;
110
163
  data: Record<string, unknown>;
111
164
  user?: ResourceUser;
112
- }): Promise<Record<string, unknown>>;
165
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
113
166
  delete(params: {
114
167
  name: string;
115
168
  id: string | number;
116
169
  user?: ResourceUser;
117
- }): Promise<boolean>;
170
+ }, ctx?: AppContext): Promise<boolean>;
118
171
  findRelation(params: {
119
172
  name: string;
120
173
  id: string | number;
@@ -128,7 +181,7 @@ export interface ResourcePlugin {
128
181
  relation: string;
129
182
  data?: Record<string, unknown>;
130
183
  user?: ResourceUser;
131
- }): Promise<any>;
184
+ }, ctx?: AppContext): Promise<any>;
132
185
  updateRelation(params: {
133
186
  name: string;
134
187
  id: string | number;
@@ -136,15 +189,16 @@ export interface ResourcePlugin {
136
189
  relationId: string;
137
190
  data: Record<string, unknown>;
138
191
  user?: ResourceUser;
139
- }): Promise<Record<string, unknown>>;
192
+ }, ctx?: AppContext): Promise<Record<string, unknown>>;
140
193
  deleteRelation(params: {
141
194
  name: string;
142
195
  id: string | number;
143
196
  relation: string;
144
197
  relationId: string;
145
198
  user?: ResourceUser;
146
- }): Promise<{
199
+ }, ctx?: AppContext): Promise<{
147
200
  success: boolean;
148
201
  }>;
149
202
  }
203
+ export {};
150
204
  //# sourceMappingURL=resource.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;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,K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AC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACnC"}
1
+ {"version":3,"file":"resource.types.d.ts","sourceRoot":"","sources":["../../../src/plugins/resource/resource.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GACzB,OAAO,GACP,eAAe,GACf,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,mBAAmB,GAC3B;IACE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACD;IACE,SAAS,EAAE,eAAe,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACD;IACE,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEN,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACxE,MAAM,WAAW,oBAAoB;IACn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ACZ,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,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,YAAY,CAAC;KACrB,EACD,GAAG,CAAC,EAAE,UAAU,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,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 A(z,j){z=z-0x1b7;const c=U();let p=c[z];return p;}function U(){const o=['set','map','has','get','code','text','color','icon','length'];U=function(){return o;};return U();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(z,j){const q=A,c=dictionaryIndexesCache['get'](j)??new Map(),p=dictionaryRevisionsCache['get'](j)??new Map();dictionaryIndexesCache['set'](j,c),dictionaryRevisionsCache[q(0x1b7)](j,p);const M=z['filter'](i=>p['get'](i)!==j['revision'](i));if(M['length']===0x0)return c;const H=await Promise['all'](M[q(0x1b8)](async i=>{const Z=q;if(!j[Z(0x1b9)](i))return[i,new Map()];const b=await j[Z(0x1ba)](i),n=new Map();for(const v of b){const r=v[Z(0x1bb)]??v['id'];if(r==null)continue;n[Z(0x1b7)](String(r),{'id':r,'text':v['name']??v[Z(0x1bc)],...v[Z(0x1bd)]!==undefined?{'color':v['color']}:{},...v[Z(0x1be)]!==undefined?{'icon':v['icon']}:{}});}return[i,n];}));for(const [i,b]of H){c[q(0x1b7)](i,b),p[q(0x1b7)](i,j['revision'](i));}return c;}export async function addDictionaryLookupData(z,j,c){const e=A;if(!c||z[e(0x1bf)]===0x0)return z;const p=Object['entries'](j)['flatMap'](([H,i])=>{const b=i['lookup']?.['dictionary'];return b?[{'field':H,'dictionaryName':b}]:[];});if(p['length']===0x0)return z;const M=await getDictionaryIndexes([...new Set(p['map'](({dictionaryName:H})=>H))],c);for(const H of z){for(const {field:i,dictionaryName:b}of p){const n=H[i];H[i+'_data']=n==null?null:M['get'](b)?.['get'](String(n))??null;}}return z;}
1
+ function m(){const i=['filter','get','revision','set','text','color','icon','length','flatMap','dictionary','map'];m=function(){return i;};return m();}const dictionaryIndexesCache=new WeakMap(),dictionaryRevisionsCache=new WeakMap();async function getDictionaryIndexes(P,G){const E=C,j=dictionaryIndexesCache['get'](G)??new Map(),Z=dictionaryRevisionsCache['get'](G)??new Map();dictionaryIndexesCache['set'](G,j),dictionaryRevisionsCache['set'](G,Z);const q=P[E(0x1f3)](X=>Z[E(0x1f4)](X)!==G[E(0x1f5)](X));if(q['length']===0x0)return j;const p=await Promise['all'](q['map'](async X=>{const z=E;if(!G['has'](X))return[X,new Map()];const F=await G['get'](X),A=new Map();for(const H of F){const b=H['code']??H['id'];if(b==null)continue;A[z(0x1f6)](String(b),{'id':b,'text':H['name']??H[z(0x1f7)],...H['color']!==undefined?{'color':H[z(0x1f8)]}:{},...H[z(0x1f9)]!==undefined?{'icon':H['icon']}:{}});}return[X,A];}));for(const [X,F]of p){j['set'](X,F),Z[E(0x1f6)](X,G['revision'](X));}return j;}function C(P,G){P=P-0x1f3;const j=m();let Z=j[P];return Z;}export async function addDictionaryLookupData(P,G,j){const x=C;if(!j||P[x(0x1fa)]===0x0)return P;const Z=Object['entries'](G)[x(0x1fb)](([p,X])=>{const o=x,F=X[o(0x1fc)];return F?[{'field':p,'dictionaryName':F}]:[];});if(Z['length']===0x0)return P;const q=await getDictionaryIndexes([...new Set(Z[x(0x1fd)](({dictionaryName:p})=>p))],j);for(const p of P){for(const {field:X,dictionaryName:F}of Z){const A=p[X];p[X+'_data']=A==null?null:q['get'](F)?.[x(0x1f4)](String(A))??null;}}return P;}
@@ -1 +1 @@
1
- function A(z,j){z=z-0x83;const c=U();let p=c[z];return p;}export function addFileToken(z,j,c){const b=A;if(!c||z[b(0x83)]===0x0)return z;const p=Object[b(0x84)](j)[b(0x85)](([,M])=>M[b(0x86)]==='file')['map'](([M])=>M);for(const M of z){for(const H of p){const i=M[H];typeof i==='string'&&i['length']>0x0&&(M[H]=c['create'](i));}}return z;}function U(){const n=['length','entries','filter','type'];U=function(){return n;};return U();}
1
+ function m(){const A=['file','string'];m=function(){return A;};return m();}function C(P,G){P=P-0x155;const j=m();let Z=j[P];return Z;}export function addFileToken(P,G,j){const F=C;if(!j||P['length']===0x0)return P;const Z=Object['entries'](G)['filter'](([,q])=>q['type']===F(0x155))['map'](([q])=>q);for(const q of P){for(const p of Z){const X=q[p];typeof X===F(0x156)&&X['length']>0x0&&(q[p]=j['create'](X));}}return P;}
@@ -1 +1 @@
1
- {"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAenF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
1
+ {"version":3,"file":"add-table-lookup-data.d.ts","sourceRoot":"","sources":["../../../../src/plugins/resource/services/add-table-lookup-data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQnF,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,GAC5C,IAAI,CASN;AAED,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC/B,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,EAAE,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAC/B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CA8DpC"}
@@ -1 +1 @@
1
- import{qi,qt}from'../utils/sql.js';function U(){const B=['entries','name','lookup','set','textField','get','has','query','\x20AS\x20id,\x20','valueField','field'];U=function(){return B;};return U();}function A(z,j){z=z-0x150;const c=U();let p=c[z];return p;}const tableLookupCache=new WeakMap();export function clearTableLookupCache(z,j){const c=tableLookupCache['get'](j);if(!c)return;for(const p of c['keys']()){p['startsWith'](z+':')&&c['delete'](p);}}export async function addTableLookupData(z,j,c){const g=A;if(!c||z['length']===0x0)return z;const p=tableLookupCache['get'](c)??new Map();tableLookupCache['set'](c,p);const M=Object[g(0x150)](j)['flatMap'](([H,i])=>{const y=g,{table:b,valueField:valueField='id',textField:textField=y(0x151)}=i[y(0x152)]??{};return b?[{'field':H,'table':b,'valueField':valueField,'textField':textField}]:[];});for(const H of M){const i=new Map();for(const r of z){const q=r[H['field']];(typeof q==='string'||typeof q==='number')&&i[g(0x153)](String(q),q);}const b=H['table']+':'+H['valueField']+':'+H[g(0x154)],n=p[g(0x155)](b)??new Map();p['set'](b,n);const v=[...i['entries']()]['filter'](([Z])=>!n[g(0x156)](Z))['map'](([,Z])=>Z);if(v['length']>0x0){const Z=await c[g(0x157)]('SELECT\x20'+qi(H['valueField'])+g(0x158)+qi(H['textField'])+'\x20AS\x20text\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20'+qt(H['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(H[g(0x159)])+'\x20=\x20ANY($1)',[v]);for(const e of Z['rows']){n['set'](String(e['id']),e);}for(const o of v){!n['has'](String(o))&&n['set'](String(o),null);}}for(const P of z){const t=P[H[g(0x15a)]];P[H[g(0x15a)]+'_data']=t==null?null:n['get'](String(t))??null;}}return z;}
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
- function U(){const C=['body','files','resource','includes','No\x20writable\x20fields','map','query','rows','UPDATE\x20','foreignKey','key'];U=function(){return C;};return U();}import{UnsupportedError,ValidationError}from'../../../errors.js';import{qi,qt}from'../utils/sql.js';function A(z,j){z=z-0xb6;const c=U();let p=c[z];return p;}import{createCreate}from'./create.js';export function createCreateRelation(z,j){const c=createCreate(z,j);return async function p({name:M,id:H,relation:i,data:b,user:n}){const D=A;if(!z['pg'])throw new Error('empty\x20pg');if(i==='notes'){const e=await z['pg']['query']('INSERT\x20INTO\x20admin.notes(resource,resource_id,body)\x20VALUES\x20($1,$2,$3)\x20RETURNING\x20*',[M,String(H),b?.[D(0xb6)]]);return e['rows'][0x0];}if(i===D(0xb7)){const o=await z['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*',[M,String(H),b?.['filePath'],b?.['size']??null]);return o['rows'][0x0];}const v=j['get'](M),r=v['relations']?.[i];if(!r?.['foreignKey']||!r[D(0xb8)]&&!r['table'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+i+'\x22\x20requires\x20a\x20project/provider\x20implementation');let q,Z;if(r['resource'])q=await c({'name':r[D(0xb8)],'data':b??{},'user':n}),Z=q[j['get'](r['resource'])['key']];else{const P=r['fields'];if(!P?.['length'])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+i+'\x22\x20requires\x20a\x20project/provider\x20implementation');const t=Object['entries'](b??{})['filter'](([s])=>P[D(0xb9)](s));if(!t['length'])throw new ValidationError(D(0xba));const g=t[D(0xbb)](([s])=>qi(s)),y=t['map']((s,R)=>'$'+(R+0x1)),B=t[D(0xbb)](([,s])=>s),Y=await z['pg'][D(0xbc)]('INSERT\x20INTO\x20'+qt(r['table'])+'\x20('+g['join'](',\x20')+')\x20VALUES\x20('+y['join'](',\x20')+')\x20RETURNING\x20*',B);q=Y[D(0xbd)][0x0],Z=q['id'];}return await z['pg'][D(0xbc)](D(0xbe)+qt(v['table'])+'\x20SET\x20'+qi(r[D(0xbf)])+'\x20=\x20$1\x20WHERE\x20'+qi(v[D(0xc0)])+'\x20=\x20$2',[Z,H]),q;};}
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';function U(){const t=['map','empty\x20pg','VALUES\x20(','RETURNING\x20','rows','table','audit','name','create'];U=function(){return t;};return U();}import{validateInputData}from'../utils/fields.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function A(z,j){z=z-0x178;const c=U();let p=c[z];return p;}export function createCreate(z,j){return async function c({name:p,data:M,user:H}){const P=A,i=j['get'](p);assertOperation(i,'create',H),validateInputData({'resource':i,'data':M});const b=writableData(i,M);if(!b['length'])throw new ValidationError('No\x20writable\x20fields');const n=b[P(0x178)](([e])=>qi(e)),v=b['map']((e,o)=>'$'+(o+0x1)),r=b[P(0x178)](([,e])=>e);if(!z['pg'])throw new Error(P(0x179));const q=await z['pg']['query']('INSERT\x20INTO\x20'+qt(i['table'])+'\x20('+n['join'](',\x20')+')\x20'+(P(0x17a)+v['join'](',\x20')+')\x20')+(P(0x17b)+readableFields(i)['join'](',\x20')),r),Z=q[P(0x17c)][0x0];return clearTableLookupCache(i[P(0x17d)],z['pg']),await z[P(0x17e)]?.['write']({'userId':H?.['id'],'module':i['module'],'resource':i[P(0x17f)],'resourceId':Z[i['key']],'action':P(0x180),'fields':Object['keys'](M)}),Z;};}
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
- function A(z,j){z=z-0x78;var c=U();var p=c[z];return p;}import{UnsupportedError}from'../../../errors.js';export function createDeleteRelation(z,j){return async function c({name:p,id:M,relation:H,relationId:i}){var b=A;if(!z['pg'])throw new Error('empty\x20pg');if(H==='notes')return await z['pg'][b(0x78)]('DELETE\x20FROM\x20admin.notes\x20WHERE\x20note_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[i,p,String(M)]),{'success':!![]};if(H===b(0x79))return await z['pg'][b(0x78)]('DELETE\x20FROM\x20admin.files\x20WHERE\x20file_id\x20=\x20$1\x20AND\x20resource\x20=\x20$2\x20AND\x20resource_id\x20=\x20$3',[i,p,String(M)]),{'success':!![]};throw new UnsupportedError(b(0x7a)+H+'\x22\x20requires\x20a\x20project/provider\x20implementation');};}function U(){var n=['query','files','Generic\x20Resource\x20relation\x20\x22'];U=function(){return n;};return U();}
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';function U(){const v=['=$1','delete'];U=function(){return v;};return U();}import{qt,qi}from'../utils/sql.js';import{clearTableLookupCache}from'./add-table-lookup-data.js';function A(z,j){z=z-0x79;const c=U();let p=c[z];return p;}export function createRemove(z,j){return async function c({name:p,id:M,user:H}){const n=A,i=j['get'](p);assertOperation(i,'delete',H);if(!z['pg'])throw new Error('empty\x20pg');const b=await z['pg']['query']('DELETE\x20FROM\x20'+qt(i['table'])+'\x20WHERE\x20'+qi(i['key'])+n(0x79),[M]);if((b['rowCount']??0x0)>0x0)clearTableLookupCache(i['table'],z['pg']);if((b['rowCount']??0x0)>0x0)await z['audit']?.['write']({'module':i['module'],'resource':i['name'],'resourceId':M,'action':n(0x7a)});return(b['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';import{qt,qi,readableFields}from'../utils/sql.js';function A(z,j){z=z-0x1c0;const c=U();let p=c[z];return p;}import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function U(){const Y=['read','query','join','=$1\x20LIMIT\x201','dictionary','file','include','split','relations','table','Unknown\x20relation:\x20','resource','key','SELECT\x20'];U=function(){return Y;};return U();}import{addFileToken}from'./add-file-token.js';export function createFindOne(z,j){return async function c({name:p,id:M,query:query={},user:H}){const B=A,i=Date['now'](),b=j['get'](p);assertOperation(b,B(0x1c0),H);if(!z['pg'])throw new Error('empty\x20pg');const n=await z['pg'][B(0x1c1)]('SELECT\x20'+readableFields(b)[B(0x1c2)](',\x20')+'\x20FROM\x20'+qt(b['table'])+'\x20WHERE\x20'+qi(b['key'])+B(0x1c3),[M]),v=n['rows'][0x0];if(!v)return null;await addDictionaryLookupData([v],b['fields'],z[B(0x1c4)]),await addTableLookupData([v],b['fields'],z['pg']),addFileToken([v],b['fields'],z[B(0x1c5)]);const r=Array['isArray'](query[B(0x1c6)])?query['include']:query[B(0x1c6)]?.[B(0x1c7)](',')??[];for(const q of r){const Z=b[B(0x1c8)]?.[q];if(!Z?.['foreignKey']||!Z['resource']&&!Z[B(0x1c9)])throw new ValidationError(B(0x1ca)+q);const e=Z['resource']?j['get'](Z[B(0x1cb)]):undefined,o=Z['table']??e[B(0x1c9)],P=e?.[B(0x1cc)]??'id',t=e?readableFields(e)['join'](',\x20'):'*',g=B(0x1cd)+t+'\x20FROM\x20'+qt(o)+'\x20WHERE\x20'+qi(P)+'\x20=\x20(\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20'+qi(Z['foreignKey'])+'\x20FROM\x20'+qt(b['table'])+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20'+qi(b[B(0x1cc)])+'\x20=\x20$1\x20LIMIT\x201\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20)',y=(await z['pg']['query'](g,[M]))['rows'];e&&(await addDictionaryLookupData(y,e['fields'],z['dictionary']),await addTableLookupData(y,e['fields'],z['pg']),addFileToken(y,e['fields'],z['file'])),v[q]=y;}return v['time']=Date['now']()-i,v;};}
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';function U(){const Y=['now','query','rows','file','table','resource','key','length','dictionary','fields'];U=function(){return Y;};return U();}import{qi,qt}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function A(z,j){z=z-0x16f;const c=U();let p=c[z];return p;}import{addFileToken}from'./add-file-token.js';export function createFindRelation(z,j){return async function c({name:p,id:M,relation:H,query:query={}}){const B=A,i=Date[B(0x16f)](),b=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),n=Math['max'](query['offset']??0x0,0x0);if(!Number['isFinite'](b)||!Number['isFinite'](n))throw new ValidationError('Invalid\x20pagination');if(H==='notes'){const g=await z['pg'][B(0x170)]('SELECT\x20*\x20FROM\x20admin.notes\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(M)]);return{'total':g[B(0x171)]['length'],'time':Date['now']()-i,'rows':g['rows']};}if(H==='files'){const y=await z['pg']['query']('SELECT\x20*\x20FROM\x20admin.files\x20WHERE\x20resource\x20=\x20$1\x20AND\x20resource_id\x20=\x20$2\x20ORDER\x20BY\x20created_at\x20DESC',[p,String(M)]);return addFileToken(y[B(0x171)],{'file_path':{'type':B(0x172)}},z['file']),{'total':y['rows']['length'],'time':Date['now']()-i,'rows':y['rows']};}const v=j['get'](p),r=v['relations']?.[H];if(!r?.['foreignKey']||!r['resource']&&!r[B(0x173)])throw new UnsupportedError('Generic\x20Resource\x20relation\x20\x22'+H+'\x22\x20requires\x20a\x20project/provider\x20implementation');const q=r['resource']?j['get'](r[B(0x174)]):undefined,Z=r['table']??q['table'],e=q?.[B(0x175)]??'id',o=r['fields']?.[B(0x176)]?r['fields']['map'](qi)['join'](',\x20'):'*',P='SELECT\x20'+o+'\x20FROM\x20'+qt(Z)+'\x20WHERE\x20\x0a\x20\x20\x20\x20'+qi(e)+'\x20=\x20(select\x20'+qi(r['foreignKey'])+'\x20FROM\x20'+qt(v[B(0x173)])+'\x20WHERE\x20'+qi(v['key'])+'\x20=\x20$1\x20LIMIT\x201)\x20\x0a\x20\x20\x20\x20LIMIT\x20$2\x20OFFSET\x20$3',t=await z['pg']['query'](P,[M,b,n]);return q&&(await addDictionaryLookupData(t['rows'],q['fields'],z[B(0x177)]),await addTableLookupData(t['rows'],q['fields'],z['pg']),addFileToken(t['rows'],q[B(0x178)],z['file'])),{'limit':b,'offset':n,'total':t[B(0x171)][B(0x176)],'time':Date['now']()-i,'rows':t['rows']??null};};}
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';function U(){const P=['now','max','offset','filter','length','OFFSET\x20$','query'];U=function(){return P;};return U();}import{qt,readableFields}from'../utils/sql.js';import{addDictionaryLookupData}from'./add-dictionary-lookup-data.js';import{addTableLookupData}from'./add-table-lookup-data.js';function A(z,j){z=z-0x1d4;const c=U();let p=c[z];return p;}import{addFileToken}from'./add-file-token.js';export function createFind(z,j){return async function c({name:p,query:query={},user:M}){const o=A,H=Date[o(0x1d4)](),i=j['get'](p);assertOperation(i,'read',M);const b=Math['min'](Math['max'](query['limit']??0x14,0x1),0xc8),n=Math[o(0x1d5)](query[o(0x1d6)]??0x0,0x0),v=buildFilters(i,query[o(0x1d7)],0x1,z['pg']),r=buildSort(i,query['sort']);if(!Number['isFinite'](b)||!Number['isFinite'](n))throw new ValidationError('Invalid\x20pagination');const q='SELECT\x20'+readableFields(i)['join'](',\x20')+'\x20'+('FROM\x20'+qt(i['table']))+(''+v['sql']+r+'\x20')+('LIMIT\x20$'+(v['values'][o(0x1d8)]+0x1)+'\x20')+(o(0x1d9)+(v['values']['length']+0x2)),Z=await z['pg'][o(0x1da)](q,[...v['values'],b,n]),e=Z['rows'];return await addDictionaryLookupData(e,i['fields'],z['dictionary']),await addTableLookupData(e,i['fields'],z['pg']),addFileToken(e,i['fields'],z['file']),{'limit':b,'offset':n,'total':Z['rowCount'],'time':Date[o(0x1d4)]()-H,'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