@judo/actions 0.30.1 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
- import { t as ValidationError } from "./types-BsQmyhQI.js";
2
- import { createContext, useCallback, useContext, useMemo } from "react";
3
- import { jsx } from "react/jsx-runtime";
4
- var RelationBehaviourType = {
1
+ import { t as e } from "./types-BRqo2AHD.js";
2
+ import { createContext as t, useCallback as n, useContext as r, useMemo as i } from "react";
3
+ import { jsx as a } from "react/jsx-runtime";
4
+ //#region ../model-api/dist/index.js
5
+ var o = {
5
6
  LIST: "LIST",
6
7
  CREATE: "CREATE",
7
8
  SET: "SET",
@@ -16,1412 +17,1441 @@ var RelationBehaviourType = {
16
17
  DELETE: "DELETE",
17
18
  REFRESH: "REFRESH",
18
19
  EXPORT: "EXPORT"
19
- }, ACTION_HANDLER_FACTORY = Symbol.for("@judo/ACTION_HANDLER_FACTORY");
20
- const useBackActionHandler = ((o) => async (o) => {
21
- if (o.closeDialog) {
22
- o.closeDialog();
20
+ }, s = Symbol.for("@judo/ACTION_HANDLER_FACTORY"), c = ((e) => async (e) => {
21
+ if (e.closeDialog) {
22
+ e.closeDialog();
23
23
  return;
24
24
  }
25
- o.navigation.goBack();
25
+ e.navigation.goBack();
26
26
  });
27
- useBackActionHandler.actionType = "BackActionDefinition";
28
- const useOpenPageActionHandler = ((o) => async (F) => {
29
- let I = o.targetPageDefinition;
30
- if (!I) throw Error("No target page defined for OpenPageAction");
31
- if (!F.navigation) throw Error("Navigation context is undefined");
32
- let L = F;
33
- F.navigation.navigateTo(I, {
34
- transfer: F.transfer,
35
- ...F.isEager && {
27
+ c.actionType = "BackActionDefinition";
28
+ var l = ((e) => async (t) => {
29
+ let n = e.targetPageDefinition;
30
+ if (!n) throw Error("No target page defined for OpenPageAction");
31
+ if (!t.navigation) throw Error("Navigation context is undefined");
32
+ let r = t;
33
+ t.navigation.navigateTo(n, {
34
+ transfer: t.transfer,
35
+ ...t.isEager && {
36
36
  isEager: !0,
37
- parentTransferId: L.parentTransferId,
38
- relationName: L.relationName
37
+ parentTransferId: r.parentTransferId,
38
+ relationName: r.relationName
39
39
  }
40
40
  });
41
41
  });
42
- useOpenPageActionHandler.actionType = "OpenPageActionDefinition";
43
- const useRowOpenPageActionHandler = ((o) => async (F) => {
44
- let I = o.targetPageDefinition;
45
- if (!I) throw Error("No target page defined for RowOpenPageAction");
46
- if (!F.navigation) throw Error("Navigation context is undefined");
47
- let L = F;
48
- F.navigation.navigateTo(I, {
49
- transfer: F.transfer,
50
- ...F.isEager && {
42
+ l.actionType = "OpenPageActionDefinition";
43
+ var u = ((e) => async (t) => {
44
+ let n = e.targetPageDefinition;
45
+ if (!n) throw Error("No target page defined for RowOpenPageAction");
46
+ if (!t.navigation) throw Error("Navigation context is undefined");
47
+ let r = t;
48
+ t.navigation.navigateTo(n, {
49
+ transfer: t.transfer,
50
+ ...t.isEager && {
51
51
  isEager: !0,
52
- parentTransferId: L.parentTransferId,
53
- relationName: L.relationName
52
+ parentTransferId: r.parentTransferId,
53
+ relationName: r.relationName
54
54
  }
55
55
  });
56
56
  });
57
- useRowOpenPageActionHandler.actionType = "RowOpenPageActionDefinition";
58
- const useCancelActionHandler = ((o) => async (o) => {
59
- if (o.closeDialog) {
60
- o.closeDialog();
57
+ u.actionType = "RowOpenPageActionDefinition";
58
+ var d = ((e) => async (e) => {
59
+ if (e.closeDialog) {
60
+ e.closeDialog();
61
61
  return;
62
62
  }
63
- if (o.pageType === "VIEW" && o.isEditMode && o.data && o.transfer?.__identifier) {
64
- o.data.resetTransfer(o.transfer.__identifier);
63
+ if (e.pageType === "VIEW" && e.isEditMode && e.data && e.transfer?.__identifier) {
64
+ e.data.resetTransfer(e.transfer.__identifier);
65
65
  return;
66
66
  }
67
- o.navigation.goBack();
67
+ e.navigation.goBack();
68
68
  });
69
- useCancelActionHandler.actionType = "CancelActionDefinition";
70
- const useOpenFormActionHandler = ((o) => async (F) => {
71
- let I = o.targetPageDefinition;
72
- if (!I) throw Error("No target page defined for OpenFormAction");
73
- F.navigation.openDialog(I, { transfer: F.transfer });
69
+ d.actionType = "CancelActionDefinition";
70
+ //#endregion
71
+ //#region src/handlers/form/form-handlers.ts
72
+ var f = ((e) => async (t) => {
73
+ let n = e.targetPageDefinition;
74
+ if (!n) throw Error("No target page defined for OpenFormAction");
75
+ t.navigation.openDialog(n, { transfer: t.transfer });
74
76
  });
75
- useOpenFormActionHandler.actionType = "OpenFormActionDefinition";
76
- const useOpenCreateFormActionHandler = ((o) => async (F) => {
77
- let I = o.targetPageDefinition;
78
- if (!I) throw Error("No target page defined for OpenCreateFormAction");
79
- let L = o.ownerDataElement, R = F.isEager === !0, z = F.transfer, B = F;
80
- F.navigation.openDialog(I, {
77
+ f.actionType = "OpenFormActionDefinition";
78
+ var p = ((e) => async (t) => {
79
+ let n = e.targetPageDefinition;
80
+ if (!n) throw Error("No target page defined for OpenCreateFormAction");
81
+ let r = e.ownerDataElement, i = t.isEager === !0, a = t.transfer, o = t;
82
+ t.navigation.openDialog(n, {
81
83
  isCreate: !0,
82
- isEager: R,
83
- relation: L,
84
- ownerTransfer: z,
85
- ...R && {
86
- parentTransferId: B.parentTransferId,
87
- relationName: B.relationName,
88
- onSubmitCreate: async (o) => o
84
+ isEager: i,
85
+ relation: r,
86
+ ownerTransfer: a,
87
+ ...i && {
88
+ parentTransferId: o.parentTransferId,
89
+ relationName: o.relationName,
90
+ onSubmitCreate: async (e) => e
89
91
  }
90
- }, B.onDialogClose);
92
+ }, o.onDialogClose);
91
93
  });
92
- useOpenCreateFormActionHandler.actionType = "OpenCreateFormActionDefinition";
93
- const useOpenOperationInputFormActionHandler = ((o) => async (F) => {
94
- let I = o.targetPageDefinition;
95
- if (!I) throw Error("No target page defined for OpenOperationInputFormAction");
96
- F.navigation.openDialog(I, {
97
- transfer: F.transfer,
98
- operation: o.actionDefinition.formFor?.operation,
94
+ p.actionType = "OpenCreateFormActionDefinition";
95
+ var m = ((e) => async (t) => {
96
+ let n = e.targetPageDefinition;
97
+ if (!n) throw Error("No target page defined for OpenOperationInputFormAction");
98
+ t.navigation.openDialog(n, {
99
+ transfer: t.transfer,
100
+ operation: e.actionDefinition.formFor?.operation,
99
101
  isOperationInput: !0
100
102
  });
101
103
  });
102
- useOpenOperationInputFormActionHandler.actionType = "OpenOperationInputFormActionDefinition";
103
- function getRelation$3(o, F) {
104
- if (o.relation) return o.relation;
105
- let I = F.ownerDataElement;
106
- return I && I["@type"] === "RelationType" ? I : null;
104
+ m.actionType = "OpenOperationInputFormActionDefinition";
105
+ //#endregion
106
+ //#region src/handlers/selector/selector-handlers.ts
107
+ function h(e, t) {
108
+ if (e.relation) return e.relation;
109
+ let n = t.ownerDataElement;
110
+ return n && n["@type"] === "RelationType" ? n : null;
107
111
  }
108
- const useOpenSelectorActionHandler = ((o) => async (F) => {
109
- let I = o.targetPageDefinition;
110
- if (!I) throw Error("No target page defined for OpenSelectorAction");
111
- F.navigation?.openDialog(I, {
112
- ownerTransfer: F.transfer,
112
+ var g = ((e) => async (t) => {
113
+ let n = e.targetPageDefinition;
114
+ if (!n) throw Error("No target page defined for OpenSelectorAction");
115
+ t.navigation?.openDialog(n, {
116
+ ownerTransfer: t.transfer,
113
117
  isSelector: !0,
114
118
  selectionMode: "single"
115
- }, F.onDialogClose);
119
+ }, t.onDialogClose);
116
120
  });
117
- useOpenSelectorActionHandler.actionType = "OpenSelectorActionDefinition";
118
- const useOpenAddSelectorActionHandler = ((o) => async (F) => {
119
- let I = o.targetPageDefinition;
120
- if (!I) throw Error("No target page defined for OpenAddSelectorAction");
121
- F.navigation?.openDialog(I, {
122
- ownerTransfer: F.transfer,
121
+ g.actionType = "OpenSelectorActionDefinition";
122
+ var _ = ((e) => async (t) => {
123
+ let n = e.targetPageDefinition;
124
+ if (!n) throw Error("No target page defined for OpenAddSelectorAction");
125
+ t.navigation?.openDialog(n, {
126
+ ownerTransfer: t.transfer,
123
127
  isSelector: !0,
124
128
  selectionMode: "multiple",
125
129
  operation: "add"
126
- }, F.onDialogClose);
130
+ }, t.onDialogClose);
127
131
  });
128
- useOpenAddSelectorActionHandler.actionType = "OpenAddSelectorActionDefinition";
129
- const useOpenSetSelectorActionHandler = ((o) => async (F) => {
130
- let I = o.targetPageDefinition;
131
- if (!I) throw Error("No target page defined for OpenSetSelectorAction");
132
- F.navigation?.openDialog(I, {
133
- ownerTransfer: F.transfer,
132
+ _.actionType = "OpenAddSelectorActionDefinition";
133
+ var v = ((e) => async (t) => {
134
+ let n = e.targetPageDefinition;
135
+ if (!n) throw Error("No target page defined for OpenSetSelectorAction");
136
+ t.navigation?.openDialog(n, {
137
+ ownerTransfer: t.transfer,
134
138
  isSelector: !0,
135
139
  selectionMode: "single",
136
140
  operation: "set"
137
- }, F.onDialogClose);
141
+ }, t.onDialogClose);
138
142
  });
139
- useOpenSetSelectorActionHandler.actionType = "OpenSetSelectorActionDefinition";
140
- const useOpenOperationInputSelectorActionHandler = ((o) => async (F) => {
141
- let I = o.targetPageDefinition;
142
- if (!I) throw Error("No target page defined for OpenOperationInputSelectorAction");
143
- let { refreshPage: L, isEditMode: R } = F;
144
- F.navigation?.openDialog(I, {
145
- ownerTransfer: F.transfer,
143
+ v.actionType = "OpenSetSelectorActionDefinition";
144
+ var y = ((e) => async (t) => {
145
+ let n = e.targetPageDefinition;
146
+ if (!n) throw Error("No target page defined for OpenOperationInputSelectorAction");
147
+ let { refreshPage: r, isEditMode: i } = t;
148
+ t.navigation?.openDialog(n, {
149
+ ownerTransfer: t.transfer,
146
150
  isSelector: !0,
147
151
  isOperationInput: !0
148
- }, (o) => {
149
- o?.type === "submitted" && !R && L?.();
152
+ }, (e) => {
153
+ e?.type === "submitted" && !i && r?.();
150
154
  });
151
155
  });
152
- useOpenOperationInputSelectorActionHandler.actionType = "OpenOperationInputSelectorActionDefinition";
153
- const useSelectorRangeActionHandler = ((o) => async (F) => {
154
- let I = o.actionDefinition.targetType;
155
- if (!I) throw Error("No target type defined for SelectorRangeAction");
156
- let L = F, { onRangeRequest: R, api: z, onRangeResult: B } = L;
157
- if (R) {
158
- R(I);
156
+ y.actionType = "OpenOperationInputSelectorActionDefinition";
157
+ var ee = ((e) => async (t) => {
158
+ let n = e.actionDefinition.targetType;
159
+ if (!n) throw Error("No target type defined for SelectorRangeAction");
160
+ let r = t, { onRangeRequest: i, api: a, onRangeResult: o } = r;
161
+ if (i) {
162
+ i(n);
159
163
  return;
160
164
  }
161
- if (z) {
162
- let F = getRelation$3(L, o);
163
- if (!F) throw Error("Cannot determine relation for selector range");
164
- let I = await z.getRelationRange(F, L.ownerTransfer, L.queryCustomizer);
165
- B?.(I.data);
165
+ if (a) {
166
+ let t = h(r, e);
167
+ if (!t) throw Error("Cannot determine relation for selector range");
168
+ let n = await a.getRelationRange(t, r.ownerTransfer, r.queryCustomizer);
169
+ o?.(n.data);
166
170
  }
167
171
  });
168
- useSelectorRangeActionHandler.actionType = "SelectorRangeActionDefinition";
169
- function isValidationError$1(o) {
170
- return typeof o == "object" && !!o && o.name === "ValidationError";
172
+ ee.actionType = "SelectorRangeActionDefinition";
173
+ //#endregion
174
+ //#region src/handlers/crud/crud-handlers.ts
175
+ function b(e) {
176
+ return typeof e == "object" && !!e && e.name === "ValidationError";
171
177
  }
172
- function resolveTargetClassType(o) {
173
- let F = o.actionDefinition?.targetType;
174
- if (F) return F;
175
- let I = o.eContainer;
176
- if (!I?.dataElement) return;
177
- let L = I.dataElement;
178
- if (L["@type"] === "ClassType" || L["@type"] === "data:ClassType") return L;
179
- if (L["@type"] === "RelationType" || L["@type"] === "data:RelationType" || L.target) return L.target;
178
+ function x(e) {
179
+ let t = e.actionDefinition?.targetType;
180
+ if (t) return t;
181
+ let n = e.eContainer;
182
+ if (!n?.dataElement) return;
183
+ let r = n.dataElement;
184
+ if (r["@type"] === "ClassType" || r["@type"] === "data:ClassType") return r;
185
+ if (r["@type"] === "RelationType" || r["@type"] === "data:RelationType" || r.target) return r.target;
180
186
  }
181
- function isAccessRelationListAction(o, F) {
182
- let I = o.ownerDataElement;
183
- if (!I || I["@type"] !== "RelationType") return !1;
184
- let L = I;
185
- return String(L.isAccess) === "true" && !F?.__identifier && !F?.__signedIdentifier;
187
+ function te(e, t) {
188
+ let n = e.ownerDataElement;
189
+ return !n || n["@type"] !== "RelationType" ? !1 : String(n.isAccess) === "true" && !t?.__identifier && !t?.__signedIdentifier;
186
190
  }
187
- function isEntityRelationListAction(o, F) {
188
- let I = o.ownerDataElement;
189
- if (!I || I["@type"] !== "RelationType") return !1;
190
- let L = I;
191
- return String(L.isAccess) !== "true" && !!F?.__signedIdentifier;
191
+ function ne(e, t) {
192
+ let n = e.ownerDataElement;
193
+ return !n || n["@type"] !== "RelationType" ? !1 : String(n.isAccess) !== "true" && !!t?.__signedIdentifier;
192
194
  }
193
- const useRefreshActionHandler = ((o) => async (F) => {
194
- let I = F.transfer, L = F, { api: R, pageTransferId: z, rowsPerPage: B } = L, V = o.queryCustomizer, H = o.countRecords;
195
- if (isAccessRelationListAction(o, I)) {
196
- let I = o.ownerDataElement, U = z ?? `table::${o["xmi:id"]}`;
197
- F.data?.setTransferLoading(U, !0);
195
+ var S = ((e) => async (t) => {
196
+ let n = t.transfer, r = t, { api: i, pageTransferId: a, rowsPerPage: o } = r, s = e.queryCustomizer, c = e.countRecords;
197
+ if (te(e, n)) {
198
+ let n = e.ownerDataElement, l = a ?? `table::${e["xmi:id"]}`;
199
+ t.data?.setTransferLoading(l, !0);
198
200
  try {
199
- let { onListRelation: o } = L, z;
200
- if (o) z = await o(I);
201
- else if (R) {
202
- let o = {
203
- _seek: { limit: B ?? 10 },
204
- ...V
205
- }, L = await R.listRelation(I, void 0, o, H);
206
- z = L.data;
207
- let W = L.headers.get("x-judo-count"), G = W ? Number.parseInt(W, 10) : void 0, K = { __items: z };
208
- G !== void 0 && !Number.isNaN(G) && (K.__totalCount = G), F.data?.setTransferData(U, K);
201
+ let { onListRelation: e } = r, a;
202
+ if (e) a = await e(n);
203
+ else if (i) {
204
+ let e = await i.listRelation(n, void 0, {
205
+ _seek: { limit: o ?? 10 },
206
+ ...s
207
+ }, c);
208
+ a = e.data;
209
+ let r = e.headers.get("x-judo-count"), u = r ? Number.parseInt(r, 10) : void 0, d = { __items: a };
210
+ u !== void 0 && !Number.isNaN(u) && (d.__totalCount = u), t.data?.setTransferData(l, d);
209
211
  } else throw Error("API not available in context");
210
- } catch (o) {
211
- throw F.data?.setTransferError(U, o), o;
212
+ } catch (e) {
213
+ throw t.data?.setTransferError(l, e), e;
212
214
  } finally {
213
- F.data?.setTransferLoading(U, !1);
215
+ t.data?.setTransferLoading(l, !1);
214
216
  }
215
217
  return;
216
218
  }
217
- if (isEntityRelationListAction(o, I)) {
218
- let L = o.ownerDataElement, U = z ?? `table::${o["xmi:id"]}`;
219
- F.data?.setTransferLoading(U, !0);
219
+ if (ne(e, n)) {
220
+ let r = e.ownerDataElement, l = a ?? `table::${e["xmi:id"]}`;
221
+ t.data?.setTransferLoading(l, !0);
220
222
  try {
221
- if (R) {
222
- let o = {
223
- _seek: { limit: B ?? 10 },
224
- ...V
225
- }, z = await R.listRelation(L, I, o, H), W = z.data, G = z.headers.get("x-judo-count"), K = G ? Number.parseInt(G, 10) : void 0, q = { __items: W };
226
- K !== void 0 && !Number.isNaN(K) && (q.__totalCount = K), F.data?.setTransferData(U, q);
223
+ if (i) {
224
+ let e = await i.listRelation(r, n, {
225
+ _seek: { limit: o ?? 10 },
226
+ ...s
227
+ }, c), a = e.data, u = e.headers.get("x-judo-count"), d = u ? Number.parseInt(u, 10) : void 0, f = { __items: a };
228
+ d !== void 0 && !Number.isNaN(d) && (f.__totalCount = d), t.data?.setTransferData(l, f);
227
229
  } else throw Error("API not available in context");
228
- } catch (o) {
229
- throw F.data?.setTransferError(U, o), o;
230
+ } catch (e) {
231
+ throw t.data?.setTransferError(l, e), e;
230
232
  } finally {
231
- F.data?.setTransferLoading(U, !1);
233
+ t.data?.setTransferLoading(l, !1);
232
234
  }
233
235
  return;
234
236
  }
235
- if (L.isSelector) {
236
- let I = o.ownerDataElement;
237
- if (I && I["@type"] === "RelationType") {
238
- let U = I, W = z ?? `table::${o["xmi:id"]}`;
239
- F.data?.setTransferLoading(W, !0);
237
+ if (r.isSelector) {
238
+ let n = e.ownerDataElement;
239
+ if (n && n["@type"] === "RelationType") {
240
+ let l = n, u = a ?? `table::${e["xmi:id"]}`;
241
+ t.data?.setTransferLoading(u, !0);
240
242
  try {
241
- if (R) {
242
- let o = {
243
- _seek: { limit: B ?? 10 },
244
- ...V
245
- }, I = await R.getRelationRange(U, L.ownerTransfer?.__signedIdentifier ? { __signedIdentifier: L.ownerTransfer.__signedIdentifier } : void 0, o, H), z = I.data, G = I.headers.get("x-judo-count"), K = G ? Number.parseInt(G, 10) : void 0, q = { __items: z };
246
- K !== void 0 && !Number.isNaN(K) && (q.__totalCount = K), F.data?.setTransferData(W, q);
243
+ if (i) {
244
+ let e = await i.getRelationRange(l, r.ownerTransfer?.__signedIdentifier ? { __signedIdentifier: r.ownerTransfer.__signedIdentifier } : void 0, {
245
+ _seek: { limit: o ?? 10 },
246
+ ...s
247
+ }, c), n = e.data, a = e.headers.get("x-judo-count"), d = a ? Number.parseInt(a, 10) : void 0, f = { __items: n };
248
+ d !== void 0 && !Number.isNaN(d) && (f.__totalCount = d), t.data?.setTransferData(u, f);
247
249
  } else throw Error("API not available in context");
248
- } catch (o) {
249
- throw F.data?.setTransferError(W, o), o;
250
+ } catch (e) {
251
+ throw t.data?.setTransferError(u, e), e;
250
252
  } finally {
251
- F.data?.setTransferLoading(W, !1);
253
+ t.data?.setTransferLoading(u, !1);
252
254
  }
253
255
  return;
254
256
  }
255
- if (I && I["@type"] === "OperationType") {
256
- let U = I, W = I.eContainer;
257
- if (!W) throw Error("Cannot determine owning ClassType for operation input selector (OperationType.eContainer is missing)");
258
- let G = z ?? `table::${o["xmi:id"]}`;
259
- F.data?.setTransferLoading(G, !0);
257
+ if (n && n["@type"] === "OperationType") {
258
+ let l = n, u = n.eContainer;
259
+ if (!u) throw Error("Cannot determine owning ClassType for operation input selector (OperationType.eContainer is missing)");
260
+ let d = a ?? `table::${e["xmi:id"]}`;
261
+ t.data?.setTransferLoading(d, !0);
260
262
  try {
261
- if (R) {
262
- let o = {
263
- _seek: { limit: B ?? 10 },
264
- ...V
265
- }, I = await R.getOperationInputRange(W, U, L.ownerTransfer?.__signedIdentifier ? { __signedIdentifier: L.ownerTransfer.__signedIdentifier } : void 0, o, H), z = I.data, K = I.headers.get("x-judo-count"), q = K ? Number.parseInt(K, 10) : void 0, J = { __items: z };
266
- q !== void 0 && !Number.isNaN(q) && (J.__totalCount = q), F.data?.setTransferData(G, J);
263
+ if (i) {
264
+ let e = await i.getOperationInputRange(u, l, r.ownerTransfer?.__signedIdentifier ? { __signedIdentifier: r.ownerTransfer.__signedIdentifier } : void 0, {
265
+ _seek: { limit: o ?? 10 },
266
+ ...s
267
+ }, c), n = e.data, a = e.headers.get("x-judo-count"), f = a ? Number.parseInt(a, 10) : void 0, p = { __items: n };
268
+ f !== void 0 && !Number.isNaN(f) && (p.__totalCount = f), t.data?.setTransferData(d, p);
267
269
  } else throw Error("API not available in context");
268
- } catch (o) {
269
- throw F.data?.setTransferError(G, o), o;
270
+ } catch (e) {
271
+ throw t.data?.setTransferError(d, e), e;
270
272
  } finally {
271
- F.data?.setTransferLoading(G, !1);
273
+ t.data?.setTransferLoading(d, !1);
272
274
  }
273
275
  return;
274
276
  }
275
277
  }
276
- let U = I?.__identifier ?? I?.__signedIdentifier;
277
- if (U) {
278
- if (F.isEager) {
279
- let o = F;
280
- if (o.parentTransferId && o.relationName && F.data) {
281
- let L = F.data.getSnapshot((F) => F.transfers.get(o.parentTransferId)?.data);
282
- if (L) {
283
- let R = L[o.relationName];
284
- if (Array.isArray(R)) {
285
- let o = R.find((o) => {
286
- if (I.__signedIdentifier && o.__signedIdentifier === I.__signedIdentifier || I.__identifier && o.__identifier === I.__identifier) return !0;
287
- let F = o.__tempId, L = I?.__tempId;
288
- return !!(F && L && F === L);
278
+ let l = n?.__identifier ?? n?.__signedIdentifier;
279
+ if (l) {
280
+ if (t.isEager) {
281
+ let e = t;
282
+ if (e.parentTransferId && e.relationName && t.data) {
283
+ let r = t.data.getSnapshot((t) => t.transfers.get(e.parentTransferId)?.data);
284
+ if (r) {
285
+ let i = r[e.relationName];
286
+ if (Array.isArray(i)) {
287
+ let e = i.find((e) => {
288
+ if (n.__signedIdentifier && e.__signedIdentifier === n.__signedIdentifier || n.__identifier && e.__identifier === n.__identifier) return !0;
289
+ let t = e.__tempId, r = n?.__tempId;
290
+ return !!(t && r && t === r);
289
291
  });
290
- if (o) {
291
- F.data.setTransferData(U, o);
292
+ if (e) {
293
+ t.data.setTransferData(l, e);
292
294
  return;
293
295
  }
294
- } else if (R && typeof R == "object") {
295
- F.data.setTransferData(U, R);
296
+ } else if (i && typeof i == "object") {
297
+ t.data.setTransferData(l, i);
296
298
  return;
297
299
  }
298
300
  }
299
301
  }
300
- F.data?.setTransferData(U, I);
302
+ t.data?.setTransferData(l, n);
301
303
  return;
302
304
  }
303
- F.data?.setTransferLoading(U, !0);
305
+ t.data?.setTransferLoading(l, !0);
304
306
  try {
305
- let z = resolveTargetClassType(o);
306
- if (!z) throw Error("No target type for refresh");
307
- let { onRefresh: B } = L, H;
308
- if (B) H = await B(U, z);
309
- else if (R) H = (await R.refresh(z, I, V)).data;
307
+ let a = x(e);
308
+ if (!a) throw Error("No target type for refresh");
309
+ let { onRefresh: o } = r, c;
310
+ if (o) c = await o(l, a);
311
+ else if (i) c = (await i.refresh(a, n, s)).data;
310
312
  else throw Error("API not available in context");
311
- F.data?.setTransferData(U, H);
312
- } catch (o) {
313
- throw F.data?.setTransferError(U, o), o;
313
+ t.data?.setTransferData(l, c);
314
+ } catch (e) {
315
+ throw t.data?.setTransferError(l, e), e;
314
316
  } finally {
315
- F.data?.setTransferLoading(U, !1);
317
+ t.data?.setTransferLoading(l, !1);
316
318
  }
317
319
  }
318
320
  });
319
- useRefreshActionHandler.actionType = "RefreshActionDefinition";
320
- const useCreateActionHandler = ((o) => async (F) => {
321
- let I = F.transfer;
322
- if (!I && F.data) {
323
- let o = F.pageTransferId;
324
- o && (I = F.data.getSnapshot((F) => F.transfers.get(o)?.data));
325
- }
326
- if (!I) throw Error("No transfer data to create");
327
- let { isEager: L, pageType: R, isEditMode: z, isPageAction: V, validation: H, createDialog: U } = F;
328
- if (!L && !V) {
329
- if (R === "FORM") throw Error("Create operation is not allowed on FORM pages. Save the form first.");
330
- if (R === "VIEW" && z) throw Error("Create operation is not allowed while the view has unsaved changes. Save or cancel changes first.");
331
- }
332
- let W = F.pageTransferId ?? I.__identifier ?? "new";
333
- F.data?.setTransferLoading(W, !0), H?.clearErrors();
321
+ S.actionType = "RefreshActionDefinition";
322
+ var re = ((e) => async (t) => {
323
+ let n = t.transfer;
324
+ if (!n && t.data) {
325
+ let e = t.pageTransferId;
326
+ e && (n = t.data.getSnapshot((t) => t.transfers.get(e)?.data));
327
+ }
328
+ if (!n) throw Error("No transfer data to create");
329
+ let { isEager: r, pageType: i, isEditMode: a, isPageAction: s, validation: c, createDialog: l } = t;
330
+ if (!r && !s) {
331
+ if (i === "FORM") throw Error("Create operation is not allowed on FORM pages. Save the form first.");
332
+ if (i === "VIEW" && a) throw Error("Create operation is not allowed while the view has unsaved changes. Save or cancel changes first.");
333
+ }
334
+ let u = t.pageTransferId ?? n.__identifier ?? "new";
335
+ t.data?.setTransferLoading(u, !0), c?.clearErrors();
334
336
  try {
335
- let { onCreate: R, onValidateCreate: z, api: V, relationMetadata: W, ownerTransfer: G, parentTransferId: K } = F, q;
336
- o.ownerDataElement?.["@type"] === "RelationType" && (q = o.ownerDataElement), q ||= U?.relation, !q && W && ("relation" in W && W.relation ? q = W.relation : "name" in W && W.name && (q = W));
337
- let J = q?.target ?? o.actionDefinition.targetType;
338
- if (!J) throw Error("No target type for create");
339
- let Y = U?.ownerTransfer ?? G, X, Z = q?.behaviours?.includes(RelationBehaviourType.VALIDATE_CREATE);
340
- if (L && Z && V) try {
341
- await V.validateCreateRelation(q, Y, I);
342
- } catch (o) {
343
- if (isValidationError$1(o)) {
344
- let F = o.toFieldErrors();
345
- throw H && Object.keys(F).length > 0 && H.setErrors(F), o;
337
+ let { onCreate: i, onValidateCreate: a, api: s, relationMetadata: u, ownerTransfer: d, parentTransferId: f } = t, p;
338
+ e.ownerDataElement?.["@type"] === "RelationType" && (p = e.ownerDataElement), p ||= l?.relation, !p && u && ("relation" in u && u.relation ? p = u.relation : "name" in u && u.name && (p = u));
339
+ let m = p?.target ?? e.actionDefinition.targetType;
340
+ if (!m) throw Error("No target type for create");
341
+ let h = l?.ownerTransfer ?? d, g, _ = p?.behaviours?.includes(o.VALIDATE_CREATE);
342
+ if (r && _ && s) try {
343
+ await s.validateCreateRelation(p, h, n);
344
+ } catch (e) {
345
+ if (b(e)) {
346
+ let t = e.toFieldErrors();
347
+ throw c && Object.keys(t).length > 0 && c.setErrors(t), e;
346
348
  }
347
- throw o;
349
+ throw e;
348
350
  }
349
- else if (L && Z && z && q) {
350
- let o = await z(I, q, Y);
351
- if (o && Object.keys(o).length > 0) throw H?.setErrors(o), Error("Validation failed");
351
+ else if (r && _ && a && p) {
352
+ let e = await a(n, p, h);
353
+ if (e && Object.keys(e).length > 0) throw c?.setErrors(e), Error("Validation failed");
352
354
  }
353
- if (L) {
354
- let o = `temp::${Date.now()}::${Math.random().toString(36).substring(2, 9)}`;
355
- X = {
356
- ...I,
357
- __tempId: o,
355
+ if (r) {
356
+ let e = `temp::${Date.now()}::${Math.random().toString(36).substring(2, 9)}`;
357
+ g = {
358
+ ...n,
359
+ __tempId: e,
358
360
  __isNew: !0
359
361
  };
360
- let L = U?.parentTransferId ?? K, R = U?.relationName;
361
- if (L && F.data) {
362
- let o = F.data.getSnapshot((o) => o.transfers.get(L)?.data);
363
- if (R) {
364
- let I = o?.[R];
365
- Array.isArray(I) ? F.data.updateTransferFields(L, { [R]: [...I, X] }) : F.data.updateTransferFields(L, { [R]: X });
362
+ let r = l?.parentTransferId ?? f, i = l?.relationName;
363
+ if (r && t.data) {
364
+ let e = t.data.getSnapshot((e) => e.transfers.get(r)?.data);
365
+ if (i) {
366
+ let n = e?.[i];
367
+ Array.isArray(n) ? t.data.updateTransferFields(r, { [i]: [...n, g] }) : t.data.updateTransferFields(r, { [i]: g });
366
368
  } else {
367
- let I = [...o?.__items ?? [], X];
368
- F.data.updateTransferFields(L, { __items: I });
369
+ let n = [...e?.__items ?? [], g];
370
+ t.data.updateTransferFields(r, { __items: n });
369
371
  }
370
372
  }
371
- U?.onSubmitCreate && await U.onSubmitCreate(X);
372
- } else if (R) X = await R(I, J);
373
- else if (V && q) try {
374
- X = (await V.createRelation(q, Y, I)).data;
375
- } catch (o) {
376
- if (isValidationError$1(o)) {
377
- let F = o.toFieldErrors();
378
- throw H && Object.keys(F).length > 0 && H.setErrors(F), o;
373
+ l?.onSubmitCreate && await l.onSubmitCreate(g);
374
+ } else if (i) g = await i(n, m);
375
+ else if (s && p) try {
376
+ g = (await s.createRelation(p, h, n)).data;
377
+ } catch (e) {
378
+ if (b(e)) {
379
+ let t = e.toFieldErrors();
380
+ throw c && Object.keys(t).length > 0 && c.setErrors(t), e;
379
381
  }
380
- throw o;
382
+ throw e;
381
383
  }
382
- else if (!R && !V) return;
384
+ else if (!i && !s) return;
383
385
  else throw Error("Create requires relation context. Provide relation in createDialog or relationMetadata in additionalContext.");
384
- F.closeDialog && F.closeDialog({
386
+ t.closeDialog && t.closeDialog({
385
387
  type: "created",
386
- isEager: L ?? !1
388
+ isEager: r ?? !1
387
389
  });
388
- let Q = o.actionDefinition.autoOpenAfterCreate !== !1, $ = o.targetPageDefinition;
389
- Q && $ && F.navigation && !L && F.navigation.replacePage($, { transfer: X });
390
- } catch (o) {
391
- throw isValidationError$1(o) || F.data?.setTransferError(W, o), o;
390
+ let v = e.actionDefinition.autoOpenAfterCreate !== !1, y = e.targetPageDefinition;
391
+ v && y && t.navigation && !r && t.navigation.replacePage(y, { transfer: g });
392
+ } catch (e) {
393
+ throw b(e) || t.data?.setTransferError(u, e), e;
392
394
  } finally {
393
- F.data?.setTransferLoading(W, !1);
395
+ t.data?.setTransferLoading(u, !1);
394
396
  }
395
397
  });
396
- useCreateActionHandler.actionType = "CreateActionDefinition";
397
- const useUpdateActionHandler = ((o) => async (F) => {
398
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier;
399
- if (!L) throw Error("No transfer to update (missing identifier)");
400
- let R = F.pageTransferId ?? L, z;
401
- F.data && (z = F.data.getSnapshot((o) => o.transfers.get(R)?.data)), z ||= I, F.data?.setTransferLoading(R, !0);
398
+ re.actionType = "CreateActionDefinition";
399
+ var ie = ((e) => async (t) => {
400
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier;
401
+ if (!r) throw Error("No transfer to update (missing identifier)");
402
+ let i = t.pageTransferId ?? r, a;
403
+ t.data && (a = t.data.getSnapshot((e) => e.transfers.get(i)?.data)), a ||= n, t.data?.setTransferLoading(i, !0);
402
404
  try {
403
- let { isEager: I } = F, L = F;
404
- if (I) {
405
- let { parentTransferId: o, relationName: I } = L;
406
- if (o && I && F.data) {
407
- let L = F.data.getSnapshot((F) => F.transfers.get(o)?.data);
408
- if (L) {
409
- let R = L[I];
410
- if (Array.isArray(R)) {
411
- let L = R.map((o) => {
412
- let F = o.__tempId, I = z.__tempId;
413
- return F && I && F === I || o.__identifier && o.__identifier === z.__identifier || o.__signedIdentifier && o.__signedIdentifier === z.__signedIdentifier ? { ...z } : o;
405
+ let { isEager: n } = t, r = t;
406
+ if (n) {
407
+ let { parentTransferId: e, relationName: n } = r;
408
+ if (e && n && t.data) {
409
+ let r = t.data.getSnapshot((t) => t.transfers.get(e)?.data);
410
+ if (r) {
411
+ let i = r[n];
412
+ if (Array.isArray(i)) {
413
+ let r = i.map((e) => {
414
+ let t = e.__tempId, n = a.__tempId;
415
+ return t && n && t === n || e.__identifier && e.__identifier === a.__identifier || e.__signedIdentifier && e.__signedIdentifier === a.__signedIdentifier ? { ...a } : e;
414
416
  });
415
- F.data.updateTransferFields(o, { [I]: L });
416
- } else F.data.updateTransferFields(o, { [I]: { ...z } });
417
+ t.data.updateTransferFields(e, { [n]: r });
418
+ } else t.data.updateTransferFields(e, { [n]: { ...a } });
417
419
  }
418
420
  }
419
- F.data?.setTransferData(R, z), F.navigation?.goBack();
421
+ t.data?.setTransferData(i, a), t.navigation?.goBack();
420
422
  return;
421
423
  }
422
- let B = resolveTargetClassType(o);
423
- if (!B) throw Error("No target type for update");
424
- let { onUpdate: V, api: H } = F, U;
425
- if (V) U = await V(z, B);
426
- else if (H) U = (await H.update(B, z)).data, U = (await H.refresh(B, U)).data;
424
+ let o = x(e);
425
+ if (!o) throw Error("No target type for update");
426
+ let { onUpdate: s, api: c } = t, l;
427
+ if (s) l = await s(a, o);
428
+ else if (c) l = (await c.update(o, a)).data, l = (await c.refresh(o, l)).data;
427
429
  else return;
428
- F.data?.setTransferData(R, U);
429
- } catch (o) {
430
- throw F.data?.setTransferError(R, o), o;
430
+ t.data?.setTransferData(i, l);
431
+ } catch (e) {
432
+ throw t.data?.setTransferError(i, e), e;
431
433
  } finally {
432
- F.data?.setTransferLoading(R, !1);
434
+ t.data?.setTransferLoading(i, !1);
433
435
  }
434
436
  });
435
- useUpdateActionHandler.actionType = "UpdateActionDefinition";
436
- const useDeleteActionHandler = ((o) => async (F) => {
437
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier;
438
- if (!L) throw Error("No transfer to delete (missing identifier)");
439
- F.data?.setTransferLoading(L, !0);
437
+ ie.actionType = "UpdateActionDefinition";
438
+ var ae = ((e) => async (t) => {
439
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier;
440
+ if (!r) throw Error("No transfer to delete (missing identifier)");
441
+ t.data?.setTransferLoading(r, !0);
440
442
  try {
441
- let R = resolveTargetClassType(o);
442
- if (!R) throw Error("No target type for delete");
443
- let { onDelete: z, api: B } = F;
444
- if (z) await z(L, R);
445
- else if (B) await B.delete(R, I);
443
+ let i = x(e);
444
+ if (!i) throw Error("No target type for delete");
445
+ let { onDelete: a, api: o } = t;
446
+ if (a) await a(r, i);
447
+ else if (o) await o.delete(i, n);
446
448
  else return;
447
- F.data?.clearTransfer(L), F.navigation?.goBack();
448
- } catch (o) {
449
- throw F.data?.setTransferError(L, o), o;
449
+ t.data?.clearTransfer(r), t.navigation?.goBack();
450
+ } catch (e) {
451
+ throw t.data?.setTransferError(r, e), e;
450
452
  }
451
453
  });
452
- useDeleteActionHandler.actionType = "DeleteActionDefinition";
453
- const useBulkDeleteActionHandler = ((o) => async (F) => {
454
- let I = F.selectedRows;
455
- if (!I || I.length === 0) return;
456
- let L = o.actionDefinition.targetType;
457
- if (!L) throw Error("No target type for bulk delete");
458
- let { onBulkDelete: R, api: z } = F, B = I.map((o) => o.__identifier ?? o.__signedIdentifier).filter(Boolean);
459
- if (R) await R(B, L);
460
- else if (z) {
461
- let o = I.filter((o) => o.__signedIdentifier).map((o) => z.delete(L, o));
462
- await Promise.all(o);
454
+ ae.actionType = "DeleteActionDefinition";
455
+ var oe = ((e) => async (t) => {
456
+ let n = t.selectedRows;
457
+ if (!n || n.length === 0) return;
458
+ let r = e.actionDefinition.targetType;
459
+ if (!r) throw Error("No target type for bulk delete");
460
+ let { onBulkDelete: i, api: a } = t, o = n.map((e) => e.__identifier ?? e.__signedIdentifier).filter(Boolean);
461
+ if (i) await i(o, r);
462
+ else if (a) {
463
+ let e = n.filter((e) => e.__signedIdentifier).map((e) => a.delete(r, e));
464
+ await Promise.all(e);
463
465
  } else return;
464
- for (let o of B) F.data?.clearTransfer(o);
466
+ for (let e of o) t.data?.clearTransfer(e);
465
467
  });
466
- useBulkDeleteActionHandler.actionType = "BulkDeleteActionDefinition";
467
- const useRowDeleteActionHandler = ((o) => async (F) => {
468
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier, { isEager: R, parentTransferId: z, relationName: B } = F;
469
- if (R && z && F.data) {
470
- let o = F.data.getSnapshot((o) => o.transfers.get(z)?.data);
471
- if (B) {
472
- let R = o?.[B];
473
- if (Array.isArray(R)) {
474
- let o = R.filter((o) => (o.__identifier ?? o.__signedIdentifier ?? o.__tempId) !== (L ?? I?.__tempId));
475
- F.data.updateTransferFields(z, { [B]: o });
476
- } else F.data.updateTransferFields(z, { [B]: null });
468
+ oe.actionType = "BulkDeleteActionDefinition";
469
+ var se = ((e) => async (t) => {
470
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier, { isEager: i, parentTransferId: a, relationName: o } = t;
471
+ if (i && a && t.data) {
472
+ let e = t.data.getSnapshot((e) => e.transfers.get(a)?.data);
473
+ if (o) {
474
+ let i = e?.[o];
475
+ if (Array.isArray(i)) {
476
+ let e = i.filter((e) => (e.__identifier ?? e.__signedIdentifier ?? e.__tempId) !== (r ?? n?.__tempId));
477
+ t.data.updateTransferFields(a, { [o]: e });
478
+ } else t.data.updateTransferFields(a, { [o]: null });
477
479
  } else {
478
- let R = (o?.__items ?? []).filter((o) => (o.__identifier ?? o.__signedIdentifier ?? o.__tempId) !== (L ?? I?.__tempId));
479
- F.data.updateTransferFields(z, { __items: R });
480
+ let i = (e?.__items ?? []).filter((e) => (e.__identifier ?? e.__signedIdentifier ?? e.__tempId) !== (r ?? n?.__tempId));
481
+ t.data.updateTransferFields(a, { __items: i });
480
482
  }
481
483
  return;
482
484
  }
483
- if (!L) return;
484
- let V = o.actionDefinition.targetType;
485
- if (!V) throw Error("No target type for row delete");
486
- let { onRowDelete: H, api: U } = F;
487
- if (H) await H(L, V);
488
- else if (U) await U.delete(V, I);
485
+ if (!r) return;
486
+ let s = e.actionDefinition.targetType;
487
+ if (!s) throw Error("No target type for row delete");
488
+ let { onRowDelete: c, api: l } = t;
489
+ if (c) await c(r, s);
490
+ else if (l) await l.delete(s, n);
489
491
  else return;
490
- F.data?.clearTransfer(L);
492
+ t.data?.clearTransfer(r);
491
493
  });
492
- useRowDeleteActionHandler.actionType = "RowDeleteActionDefinition";
493
- const useGetTemplateActionHandler = ((o) => async (F) => {
494
- let I = o.actionDefinition.targetType;
495
- if (!I) throw Error("No target type for get template");
496
- let { onGetTemplate: L, api: R } = F, z;
497
- if (L) z = await L(I);
498
- else if (R) z = (await R.getTemplate(I)).data;
494
+ se.actionType = "RowDeleteActionDefinition";
495
+ var ce = ((e) => async (t) => {
496
+ let n = e.actionDefinition.targetType;
497
+ if (!n) throw Error("No target type for get template");
498
+ let { onGetTemplate: r, api: i } = t, a;
499
+ if (r) a = await r(n);
500
+ else if (i) a = (await i.getTemplate(n)).data;
499
501
  else throw Error("API not available in context");
500
- F.data?.setTransferData(F.pageTransferId ?? "new", z);
502
+ t.data?.setTransferData(t.pageTransferId ?? "new", a);
501
503
  });
502
- useGetTemplateActionHandler.actionType = "GetTemplateActionDefinition";
503
- function getRelation$2(o, F) {
504
- if (o.relation) return o.relation;
505
- let I = F.ownerDataElement;
506
- return I && I["@type"] === "RelationType" ? I : null;
504
+ ce.actionType = "GetTemplateActionDefinition";
505
+ //#endregion
506
+ //#region src/handlers/relation/relation-handlers.ts
507
+ function C(e, t) {
508
+ if (e.relation) return e.relation;
509
+ let n = t.ownerDataElement;
510
+ return n && n["@type"] === "RelationType" ? n : null;
507
511
  }
508
- const useSetActionHandler = ((o) => async (F) => {
509
- let I = F, { ownerTransfer: L, selectedEntity: R, api: z, onSet: B } = I;
510
- if (!L || !R) throw Error("Missing owner or selected transfer for set");
511
- let V = L.__identifier ?? L.__signedIdentifier, H = R.__identifier ?? R.__signedIdentifier;
512
- if (!V || !H) throw Error("Missing transfer identifiers for set");
513
- let U = o.actionDefinition.name ?? "";
514
- if (B) await B(V, U, H);
515
- else if (z) {
516
- let F = getRelation$2(I, o);
517
- if (!F) throw Error("Cannot determine relation for set action");
518
- await z.setRelation(F, L, R);
519
- }
520
- F.closeDialog?.({
512
+ var le = ((e) => async (t) => {
513
+ let n = t, { ownerTransfer: r, selectedEntity: i, api: a, onSet: o } = n;
514
+ if (!r || !i) throw Error("Missing owner or selected transfer for set");
515
+ let s = r.__identifier ?? r.__signedIdentifier, c = i.__identifier ?? i.__signedIdentifier;
516
+ if (!s || !c) throw Error("Missing transfer identifiers for set");
517
+ let l = e.actionDefinition.name ?? "";
518
+ if (o) await o(s, l, c);
519
+ else if (a) {
520
+ let t = C(n, e);
521
+ if (!t) throw Error("Cannot determine relation for set action");
522
+ await a.setRelation(t, r, i);
523
+ }
524
+ t.closeDialog?.({
521
525
  type: "selected",
522
- data: R
526
+ data: i
523
527
  });
524
528
  });
525
- useSetActionHandler.actionType = "SetActionDefinition";
526
- const useUnsetActionHandler = ((o) => async (F) => {
527
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier;
528
- if (!L) return;
529
- let R = o.actionDefinition.name ?? "", z = F, { onUnset: B, api: V } = z;
530
- if (B) await B(L, R);
531
- else if (V) {
532
- let F = getRelation$2(z, o);
533
- if (!F) throw Error("Cannot determine relation for unset action");
534
- await V.unsetRelation(F, I);
529
+ le.actionType = "SetActionDefinition";
530
+ var ue = ((e) => async (t) => {
531
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier;
532
+ if (!r) return;
533
+ let i = e.actionDefinition.name ?? "", a = t, { onUnset: o, api: s } = a;
534
+ if (o) await o(r, i);
535
+ else if (s) {
536
+ let t = C(a, e);
537
+ if (!t) throw Error("Cannot determine relation for unset action");
538
+ await s.unsetRelation(t, n);
535
539
  }
536
540
  });
537
- useUnsetActionHandler.actionType = "UnsetActionDefinition";
538
- const useAddActionHandler = ((o) => async (F) => {
539
- let I = F, { ownerTransfer: L, selectedEntities: R, api: z, onAdd: B } = I;
540
- if (!L || !R?.length) throw Error("Missing transfers for add");
541
- let V = L.__identifier ?? L.__signedIdentifier;
542
- if (!V) throw Error("Missing owner transfer identifier for add");
543
- let H = R.map((o) => o.__identifier ?? o.__signedIdentifier).filter(Boolean), U = o.actionDefinition.name ?? "";
544
- if (B) await B(V, U, H);
545
- else if (z) {
546
- let F = getRelation$2(I, o);
547
- if (!F) throw Error("Cannot determine relation for add action");
548
- await z.addToRelation(F, L, R);
549
- }
550
- F.closeDialog?.({
541
+ ue.actionType = "UnsetActionDefinition";
542
+ var de = ((e) => async (t) => {
543
+ let n = t, { ownerTransfer: r, selectedEntities: i, api: a, onAdd: o } = n;
544
+ if (!r || !i?.length) throw Error("Missing transfers for add");
545
+ let s = r.__identifier ?? r.__signedIdentifier;
546
+ if (!s) throw Error("Missing owner transfer identifier for add");
547
+ let c = i.map((e) => e.__identifier ?? e.__signedIdentifier).filter(Boolean), l = e.actionDefinition.name ?? "";
548
+ if (o) await o(s, l, c);
549
+ else if (a) {
550
+ let t = C(n, e);
551
+ if (!t) throw Error("Cannot determine relation for add action");
552
+ await a.addToRelation(t, r, i);
553
+ }
554
+ t.closeDialog?.({
551
555
  type: "selected",
552
- data: R
556
+ data: i
553
557
  });
554
558
  });
555
- useAddActionHandler.actionType = "AddActionDefinition";
556
- const useRemoveActionHandler = ((o) => async (F) => {
557
- let I = F, L = F, R = F.transfer, z = R?.__identifier ?? R?.__signedIdentifier;
558
- if (L.isEager && L.parentTransferId && F.data) {
559
- let o = L.parentTransferId, I = L.relationName, B = F.data.getSnapshot((F) => F.transfers.get(o)?.data);
560
- if (I) {
561
- let L = (B?.[I] ?? []).filter((o) => (o.__identifier ?? o.__signedIdentifier ?? o.__tempId) !== (z ?? R?.__tempId));
562
- F.data.updateTransferFields(o, { [I]: L });
559
+ de.actionType = "AddActionDefinition";
560
+ var fe = ((e) => async (t) => {
561
+ let n = t, r = t, i = t.transfer, a = i?.__identifier ?? i?.__signedIdentifier;
562
+ if (r.isEager && r.parentTransferId && t.data) {
563
+ let e = r.parentTransferId, n = r.relationName, o = t.data.getSnapshot((t) => t.transfers.get(e)?.data);
564
+ if (n) {
565
+ let r = (o?.[n] ?? []).filter((e) => (e.__identifier ?? e.__signedIdentifier ?? e.__tempId) !== (a ?? i?.__tempId));
566
+ t.data.updateTransferFields(e, { [n]: r });
563
567
  } else {
564
- let I = (B?.__items ?? []).filter((o) => (o.__identifier ?? o.__signedIdentifier ?? o.__tempId) !== (z ?? R?.__tempId));
565
- F.data.updateTransferFields(o, { __items: I });
568
+ let n = (o?.__items ?? []).filter((e) => (e.__identifier ?? e.__signedIdentifier ?? e.__tempId) !== (a ?? i?.__tempId));
569
+ t.data.updateTransferFields(e, { __items: n });
566
570
  }
567
571
  return;
568
572
  }
569
- let { ownerTransfer: B, api: V, onRemove: H } = I, U = B?.__identifier ?? B?.__signedIdentifier;
570
- if (!U || !z) return;
571
- let W = o.actionDefinition.name ?? "";
572
- if (H) await H(U, W, [z]);
573
- else if (V) {
574
- let F = getRelation$2(I, o);
575
- if (!F) throw Error("Cannot determine relation for remove action");
576
- await V.removeFromRelation(F, B, [R]);
573
+ let { ownerTransfer: o, api: s, onRemove: c } = n, l = o?.__identifier ?? o?.__signedIdentifier;
574
+ if (!l || !a) return;
575
+ let u = e.actionDefinition.name ?? "";
576
+ if (c) await c(l, u, [a]);
577
+ else if (s) {
578
+ let t = C(n, e);
579
+ if (!t) throw Error("Cannot determine relation for remove action");
580
+ await s.removeFromRelation(t, o, [i]);
577
581
  }
578
582
  });
579
- useRemoveActionHandler.actionType = "RemoveActionDefinition";
580
- const useBulkRemoveActionHandler = ((o) => async (F) => {
581
- let I = F, L = F, R = F.selectedRows;
582
- if (!R?.length) return;
583
- if (L.isEager && L.parentTransferId && F.data) {
584
- let o = L.parentTransferId, I = L.relationName, z = new Set(R.map((o) => o.__identifier ?? o.__signedIdentifier ?? o.__tempId).filter(Boolean)), B = F.data.getSnapshot((F) => F.transfers.get(o)?.data);
585
- if (I) {
586
- let L = (B?.[I] ?? []).filter((o) => !z.has(o.__identifier ?? o.__signedIdentifier ?? o.__tempId));
587
- F.data.updateTransferFields(o, { [I]: L });
583
+ fe.actionType = "RemoveActionDefinition";
584
+ var pe = ((e) => async (t) => {
585
+ let n = t, r = t, i = t.selectedRows;
586
+ if (!i?.length) return;
587
+ if (r.isEager && r.parentTransferId && t.data) {
588
+ let e = r.parentTransferId, n = r.relationName, a = new Set(i.map((e) => e.__identifier ?? e.__signedIdentifier ?? e.__tempId).filter(Boolean)), o = t.data.getSnapshot((t) => t.transfers.get(e)?.data);
589
+ if (n) {
590
+ let r = (o?.[n] ?? []).filter((e) => !a.has(e.__identifier ?? e.__signedIdentifier ?? e.__tempId));
591
+ t.data.updateTransferFields(e, { [n]: r });
588
592
  } else {
589
- let I = (B?.__items ?? []).filter((o) => !z.has(o.__identifier ?? o.__signedIdentifier ?? o.__tempId));
590
- F.data.updateTransferFields(o, { __items: I });
593
+ let n = (o?.__items ?? []).filter((e) => !a.has(e.__identifier ?? e.__signedIdentifier ?? e.__tempId));
594
+ t.data.updateTransferFields(e, { __items: n });
591
595
  }
592
596
  return;
593
597
  }
594
- let { ownerTransfer: z, api: B, onBulkRemove: V } = I, H = z?.__identifier ?? z?.__signedIdentifier;
595
- if (!H) return;
596
- let U = R.map((o) => o.__identifier ?? o.__signedIdentifier).filter(Boolean), W = o.actionDefinition.name ?? "";
597
- if (V) await V(H, W, U);
598
- else if (B) {
599
- let F = getRelation$2(I, o);
600
- if (!F) throw Error("Cannot determine relation for bulk remove action");
601
- let L = R.filter((o) => o.__signedIdentifier);
602
- await B.removeFromRelation(F, z, L);
598
+ let { ownerTransfer: a, api: o, onBulkRemove: s } = n, c = a?.__identifier ?? a?.__signedIdentifier;
599
+ if (!c) return;
600
+ let l = i.map((e) => e.__identifier ?? e.__signedIdentifier).filter(Boolean), u = e.actionDefinition.name ?? "";
601
+ if (s) await s(c, u, l);
602
+ else if (o) {
603
+ let t = C(n, e);
604
+ if (!t) throw Error("Cannot determine relation for bulk remove action");
605
+ let r = i.filter((e) => e.__signedIdentifier);
606
+ await o.removeFromRelation(t, a, r);
603
607
  }
604
608
  });
605
- useBulkRemoveActionHandler.actionType = "BulkRemoveActionDefinition";
606
- const useClearActionHandler = ((o) => async (F) => {
607
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier;
608
- if (!L) return;
609
- let R = F, { api: z, onClear: B } = R, V = o.actionDefinition.name ?? "";
610
- if (B) await B(L, V);
611
- else if (z) {
612
- let F = getRelation$2(R, o);
613
- if (!F) throw Error("Cannot determine relation for clear action");
614
- await z.unsetRelation(F, I);
609
+ pe.actionType = "BulkRemoveActionDefinition";
610
+ var w = ((e) => async (t) => {
611
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier;
612
+ if (!r) return;
613
+ let i = t, { api: a, onClear: o } = i, s = e.actionDefinition.name ?? "";
614
+ if (o) await o(r, s);
615
+ else if (a) {
616
+ let t = C(i, e);
617
+ if (!t) throw Error("Cannot determine relation for clear action");
618
+ t.isCollection === !1 ? await a.unsetRelation(t, n) : await a.setRelation(t, n, []);
615
619
  }
616
620
  });
617
- useClearActionHandler.actionType = "ClearActionDefinition";
618
- const useRefreshRelationActionHandler = ((o) => async (F) => {
619
- let I = F.transfer, L = I?.__identifier ?? I?.__signedIdentifier;
620
- if (!L) return;
621
- let R = F, { api: z, onRefreshRelation: B } = R, V = o.actionDefinition.name ?? "";
622
- if (B) await B(L, V);
623
- else if (z) {
624
- let F = getRelation$2(R, o);
625
- if (!F) throw Error("Cannot determine relation for refresh action");
626
- F.isCollection === !1 ? await z.getRelation(F, I) : await z.listRelation(F, I);
621
+ w.actionType = "ClearActionDefinition";
622
+ var T = ((e) => async (t) => {
623
+ let n = t.transfer, r = n?.__identifier ?? n?.__signedIdentifier;
624
+ if (!r) return;
625
+ let i = t, { api: a, onRefreshRelation: o } = i, s = e.actionDefinition.name ?? "";
626
+ if (o) await o(r, s);
627
+ else if (a) {
628
+ let t = C(i, e);
629
+ if (!t) throw Error("Cannot determine relation for refresh action");
630
+ t.isCollection === !1 ? await a.getRelation(t, n) : await a.listRelation(t, n);
627
631
  }
628
632
  });
629
- useRefreshRelationActionHandler.actionType = "RefreshRelationActionDefinition";
630
- const useFilterRelationActionHandler = ((o) => async (F) => {
631
- let I = F;
632
- I.onFilterRelation && I.onFilterRelation(o.actionDefinition.name ?? "");
633
+ T.actionType = "RefreshRelationActionDefinition";
634
+ var E = ((e) => async (t) => {
635
+ let n = t;
636
+ n.onFilterRelation && n.onFilterRelation(e.actionDefinition.name ?? "");
633
637
  });
634
- useFilterRelationActionHandler.actionType = "FilterRelationActionDefinition";
635
- function getRelation$1(o) {
636
- return o.relation ?? null;
638
+ E.actionType = "FilterRelationActionDefinition";
639
+ //#endregion
640
+ //#region src/handlers/table/table-handlers.ts
641
+ function me(e) {
642
+ return e.relation ?? null;
637
643
  }
638
- const useFilterActionHandler = ((o) => async (o) => {
639
- o.onFilterRequest?.();
644
+ var D = ((e) => async (e) => {
645
+ e.onFilterRequest?.();
640
646
  });
641
- useFilterActionHandler.actionType = "FilterActionDefinition";
642
- const useExportActionHandler = ((o) => async (F) => {
643
- let I = o.actionDefinition.targetType;
644
- if (!I) throw Error("No target type for export");
645
- let L = F, { onExport: R, api: z } = L;
646
- if (R) {
647
- await R(I);
647
+ D.actionType = "FilterActionDefinition";
648
+ var O = ((e) => async (t) => {
649
+ let n = e.actionDefinition.targetType;
650
+ if (!n) throw Error("No target type for export");
651
+ let r = t, { onExport: i, api: a } = r;
652
+ if (i) {
653
+ await i(n);
648
654
  return;
649
655
  }
650
- if (z) {
651
- let o = getRelation$1(L);
652
- if (!o) throw Error("Cannot determine relation for export action");
653
- let R = (await z.exportRelation(o, F.transfer)).data, B = URL.createObjectURL(R), V = document.createElement("a");
654
- V.href = B, V.download = `export_${I.simpleName ?? I.name}_${Date.now()}.csv`, V.click(), URL.revokeObjectURL(B);
656
+ if (a) {
657
+ let e = me(r);
658
+ if (!e) throw Error("Cannot determine relation for export action");
659
+ let i = (await a.exportRelation(e, t.transfer)).data, o = URL.createObjectURL(i), s = document.createElement("a");
660
+ s.href = o, s.download = `export_${n.simpleName ?? n.name}_${Date.now()}.csv`, s.click(), URL.revokeObjectURL(o);
655
661
  }
656
662
  });
657
- useExportActionHandler.actionType = "ExportActionDefinition";
658
- const useInlineCreateRowActionHandler = ((o) => async (o) => {
659
- o.onInlineCreateRow?.();
663
+ O.actionType = "ExportActionDefinition";
664
+ var k = ((e) => async (e) => {
665
+ e.onInlineCreateRow?.();
660
666
  });
661
- useInlineCreateRowActionHandler.actionType = "InlineCreateRowActionDefinition";
662
- function isValidationError(o) {
663
- return typeof o == "object" && !!o && o.name === "ValidationError";
667
+ k.actionType = "InlineCreateRowActionDefinition";
668
+ //#endregion
669
+ //#region src/handlers/operation/operation-handlers.ts
670
+ function he(e) {
671
+ return typeof e == "object" && !!e && e.name === "ValidationError";
664
672
  }
665
- function hasStatus(o, ...F) {
666
- if (typeof o == "object" && o) {
667
- let I = o.status;
668
- return I !== void 0 && F.includes(I);
673
+ function ge(e, ...t) {
674
+ if (typeof e == "object" && e) {
675
+ let n = e.status;
676
+ return n !== void 0 && t.includes(n);
669
677
  }
670
678
  return !1;
671
679
  }
672
- function handleOperationError(o, F, I, L) {
673
- if (isValidationError(o)) {
674
- let R = o.toFieldErrors();
675
- L && Object.keys(R).length > 0 && L.setErrors(R), I?.error(`Validation failed for ${F}`);
676
- } else if (hasStatus(o, 401, 403)) I?.error(`Access denied: You don't have permission to execute ${F}`);
677
- else if (hasStatus(o, 404)) I?.error(`Resource not found for ${F}`);
680
+ function A(e, t, n, r) {
681
+ if (he(e)) {
682
+ let i = e.toFieldErrors();
683
+ r && Object.keys(i).length > 0 && r.setErrors(i), n?.error(`Validation failed for ${t}`);
684
+ } else if (ge(e, 401, 403)) n?.error(`Access denied: You don't have permission to execute ${t}`);
685
+ else if (ge(e, 404)) n?.error(`Resource not found for ${t}`);
678
686
  else {
679
- let L = o instanceof Error ? o.message : "Unknown error";
680
- I?.error(`Operation ${F} failed: ${L}`);
687
+ let r = e instanceof Error ? e.message : "Unknown error";
688
+ n?.error(`Operation ${t} failed: ${r}`);
681
689
  }
682
690
  }
683
- function openOperationOutputPage(o, F, I, L) {
684
- let R = o.targetPageDefinition;
685
- if (!F || !R) return;
686
- let z = {
687
- transfer: F,
691
+ function j(e, t, n, r) {
692
+ let i = e.targetPageDefinition;
693
+ if (!t || !i) return;
694
+ let a = {
695
+ transfer: t,
688
696
  isOperationOutput: !0,
689
- isMappedOutput: (I.output?.behaviours ?? []).some((o) => [
697
+ isMappedOutput: (n.output?.behaviours ?? []).some((e) => [
690
698
  "UPDATE",
691
699
  "DELETE",
692
700
  "REFRESH"
693
- ].includes(o))
701
+ ].includes(e))
694
702
  };
695
- String(R.openInDialog) === "true" ? L.navigation?.openDialog(R, z) : L.navigation?.navigateTo(R, z);
703
+ String(i.openInDialog) === "true" ? r.navigation?.openDialog(i, a) : r.navigation?.navigateTo(i, a);
696
704
  }
697
- function triggerPageRefresh(o) {
698
- let { refreshPage: F } = o;
699
- F?.();
705
+ function M(e) {
706
+ let { refreshPage: t } = e;
707
+ t?.();
700
708
  }
701
- function toOperationInfo(o) {
709
+ function N(e) {
702
710
  return {
703
- name: o.name,
704
- isStatic: o.operationType === "STATIC",
705
- isMapped: o.operationType === "MAPPED",
706
- hasInput: !!o.input,
707
- inputType: o.input?.target
711
+ name: e.name,
712
+ isStatic: e.operationType === "STATIC",
713
+ isMapped: e.operationType === "MAPPED",
714
+ hasInput: !!e.input,
715
+ inputType: e.input?.target
708
716
  };
709
717
  }
710
- const useCallOperationActionHandler = ((o) => async (F) => {
711
- let I = o.actionDefinition, L = I.operation;
712
- if (!L) throw Error("No operation defined for CallOperationAction");
713
- let { onCallOperation: R, api: z } = F, { notifications: B, validation: V } = F, H = F.transfer;
718
+ var P = ((e) => async (t) => {
719
+ let n = e.actionDefinition, r = n.operation;
720
+ if (!r) throw Error("No operation defined for CallOperationAction");
721
+ let { onCallOperation: i, api: a } = t, { notifications: o, validation: s } = t, c = t.transfer;
714
722
  try {
715
- if (R) {
716
- let I = await R(L, H, H);
717
- B?.success(`${L.name} completed successfully`), openOperationOutputPage(o, I, L, F), triggerPageRefresh(F);
723
+ if (i) {
724
+ let n = await i(r, c, c);
725
+ o?.success(`${r.name} completed successfully`), j(e, n, r, t), M(t);
718
726
  return;
719
727
  }
720
- if (z) {
721
- let R = I.targetType ?? L.eContainer;
722
- if (!R) throw Error("No owner type for operation call");
723
- let V = toOperationInfo(L), U = await z.invokeOperation(R, V, H, H);
724
- B?.success(`${L.name} completed successfully`), openOperationOutputPage(o, U.data, L, F), triggerPageRefresh(F);
728
+ if (a) {
729
+ let i = n.targetType ?? r.eContainer;
730
+ if (!i) throw Error("No owner type for operation call");
731
+ let s = N(r), l = await a.invokeOperation(i, s, c, c);
732
+ o?.success(`${r.name} completed successfully`), j(e, l.data, r, t), M(t);
725
733
  }
726
- } catch (o) {
727
- throw handleOperationError(o, L.name, B, V), o;
734
+ } catch (e) {
735
+ throw A(e, r.name, o, s), e;
728
736
  }
729
737
  });
730
- useCallOperationActionHandler.actionType = "CallOperationActionDefinition";
731
- const useBulkCallOperationActionHandler = ((o) => async (F) => {
732
- let I = o.actionDefinition, L = I.operation;
733
- if (!L) throw Error("No operation defined for BulkCallOperationAction");
734
- let R = F.selectedRows;
735
- if (!R || R.length === 0) return;
736
- let { onBulkCallOperation: z, api: B } = F, { notifications: V, validation: H } = F;
738
+ P.actionType = "CallOperationActionDefinition";
739
+ var F = ((e) => async (t) => {
740
+ let n = e.actionDefinition, r = n.operation;
741
+ if (!r) throw Error("No operation defined for BulkCallOperationAction");
742
+ let i = t.selectedRows;
743
+ if (!i || i.length === 0) return;
744
+ let { onBulkCallOperation: a, api: o } = t, { notifications: s, validation: c } = t;
737
745
  try {
738
- if (z) {
739
- await z(L, R), V?.success(`${L.name} completed on ${R.length} item(s)`), triggerPageRefresh(F);
746
+ if (a) {
747
+ await a(r, i), s?.success(`${r.name} completed on ${i.length} item(s)`), M(t);
740
748
  return;
741
749
  }
742
- if (B) {
743
- let o = I.targetType ?? L.eContainer;
744
- if (!o) throw Error("No owner type for bulk operation call");
745
- let z = toOperationInfo(L), H = R.map((F) => B.invokeOperation(o, z, F, F));
746
- await Promise.all(H), V?.success(`${L.name} completed on ${R.length} item(s)`), triggerPageRefresh(F);
750
+ if (o) {
751
+ let e = n.targetType ?? r.eContainer;
752
+ if (!e) throw Error("No owner type for bulk operation call");
753
+ let a = N(r), c = i.map((t) => o.invokeOperation(e, a, t, t));
754
+ await Promise.all(c), s?.success(`${r.name} completed on ${i.length} item(s)`), M(t);
747
755
  }
748
- } catch (o) {
749
- throw handleOperationError(o, L.name, V, H), o;
756
+ } catch (e) {
757
+ throw A(e, r.name, s, c), e;
750
758
  }
751
759
  });
752
- useBulkCallOperationActionHandler.actionType = "BulkCallOperationActionDefinition";
753
- const useInputFormCallOperationActionHandler = ((o) => async (F) => {
754
- let I = o.actionDefinition, L = I.operation;
755
- if (!L) throw Error("No operation defined for InputFormCallOperationAction");
756
- let R = F, { onInputFormCallOperation: z, api: B, pageTransferId: V } = R, { notifications: H, validation: U } = F, W = F.transfer, G = R.inputData;
757
- if (!G && F.data && V && (G = F.data.getSnapshot((o) => o.transfers.get(V)?.data)), G) try {
758
- if (z) {
759
- let I = await z(L, W, G);
760
- F.closeDialog?.({ type: "submitted" }), H?.success(`${L.name} completed successfully`), openOperationOutputPage(o, I, L, F), triggerPageRefresh(F);
760
+ F.actionType = "BulkCallOperationActionDefinition";
761
+ var I = ((e) => async (t) => {
762
+ let n = e.actionDefinition, r = n.operation;
763
+ if (!r) throw Error("No operation defined for InputFormCallOperationAction");
764
+ let i = t, { onInputFormCallOperation: a, api: o, pageTransferId: s } = i, { notifications: c, validation: l } = t, u = t.transfer, d = i.inputData;
765
+ if (!d && t.data && s && (d = t.data.getSnapshot((e) => e.transfers.get(s)?.data)), d) try {
766
+ if (a) {
767
+ let n = await a(r, u, d);
768
+ t.closeDialog?.({ type: "submitted" }), c?.success(`${r.name} completed successfully`), j(e, n, r, t), M(t);
761
769
  return;
762
770
  }
763
- if (B) {
764
- let R = I.targetType ?? L.eContainer;
765
- if (!R) throw Error("No owner type for input form operation call");
766
- let z = toOperationInfo(L), V = await B.invokeOperation(R, z, W, G);
767
- F.closeDialog?.({ type: "submitted" }), H?.success(`${L.name} completed successfully`), openOperationOutputPage(o, V.data, L, F), triggerPageRefresh(F);
771
+ if (o) {
772
+ let i = n.targetType ?? r.eContainer;
773
+ if (!i) throw Error("No owner type for input form operation call");
774
+ let a = N(r), s = await o.invokeOperation(i, a, u, d);
775
+ t.closeDialog?.({ type: "submitted" }), c?.success(`${r.name} completed successfully`), j(e, s.data, r, t), M(t);
768
776
  }
769
- } catch (o) {
770
- throw handleOperationError(o, L.name, H, U), o;
777
+ } catch (e) {
778
+ throw A(e, r.name, c, l), e;
771
779
  }
772
780
  });
773
- useInputFormCallOperationActionHandler.actionType = "InputFormCallOperationActionDefinition";
774
- const useInputSelectorCallOperationActionHandler = ((o) => async (F) => {
775
- let I = o.actionDefinition, L = I.operation;
776
- if (!L) throw Error("No operation defined for InputSelectorCallOperationAction");
777
- let { onInputSelectorCallOperation: R, api: z, selectedEntity: B, ownerTransfer: V } = F, { notifications: H, validation: U } = F, W = F.transfer ?? V;
778
- if (B) try {
779
- if (R) {
780
- let I = await R(L, W, B);
781
- F.closeDialog?.({ type: "submitted" }), H?.success(`${L.name} completed successfully`), openOperationOutputPage(o, I, L, F), triggerPageRefresh(F);
781
+ I.actionType = "InputFormCallOperationActionDefinition";
782
+ var L = ((e) => async (t) => {
783
+ let n = e.actionDefinition, r = n.operation;
784
+ if (!r) throw Error("No operation defined for InputSelectorCallOperationAction");
785
+ let { onInputSelectorCallOperation: i, api: a, selectedEntity: o, ownerTransfer: s } = t, { notifications: c, validation: l } = t, u = t.transfer ?? s;
786
+ if (o) try {
787
+ if (i) {
788
+ let n = await i(r, u, o);
789
+ t.closeDialog?.({ type: "submitted" }), c?.success(`${r.name} completed successfully`), j(e, n, r, t), M(t);
782
790
  return;
783
791
  }
784
- if (z) {
785
- let R = I.targetType ?? L.eContainer;
786
- if (!R) throw Error("No owner type for input selector operation call");
787
- let V = toOperationInfo(L), U = await z.invokeOperation(R, V, W, B);
788
- F.closeDialog?.({ type: "submitted" }), H?.success(`${L.name} completed successfully`), openOperationOutputPage(o, U.data, L, F), triggerPageRefresh(F);
792
+ if (a) {
793
+ let i = n.targetType ?? r.eContainer;
794
+ if (!i) throw Error("No owner type for input selector operation call");
795
+ let s = N(r), l = await a.invokeOperation(i, s, u, o);
796
+ t.closeDialog?.({ type: "submitted" }), c?.success(`${r.name} completed successfully`), j(e, l.data, r, t), M(t);
789
797
  }
790
- } catch (o) {
791
- throw handleOperationError(o, L.name, H, U), o;
798
+ } catch (e) {
799
+ throw A(e, r.name, c, l), e;
792
800
  }
793
801
  });
794
- useInputSelectorCallOperationActionHandler.actionType = "InputSelectorCallOperationActionDefinition";
795
- const useParameterlessCallOperationActionHandler = ((o) => async (F) => {
796
- let I = o.actionDefinition, L = I.operation;
797
- if (!L) throw Error("No operation defined for ParameterlessCallOperationAction");
798
- let { onParameterlessCallOperation: R, api: z } = F, { notifications: B, validation: V } = F, H = F.transfer;
802
+ L.actionType = "InputSelectorCallOperationActionDefinition";
803
+ var R = ((e) => async (t) => {
804
+ let n = e.actionDefinition, r = n.operation;
805
+ if (!r) throw Error("No operation defined for ParameterlessCallOperationAction");
806
+ let { onParameterlessCallOperation: i, api: a } = t, { notifications: o, validation: s } = t, c = t.transfer;
799
807
  try {
800
- if (R) {
801
- let I = await R(L, H);
802
- B?.success(`${L.name} completed successfully`), openOperationOutputPage(o, I, L, F), triggerPageRefresh(F);
808
+ if (i) {
809
+ let n = await i(r, c);
810
+ o?.success(`${r.name} completed successfully`), j(e, n, r, t), M(t);
803
811
  return;
804
812
  }
805
- if (z) {
806
- let R = I.targetType ?? L.eContainer;
807
- if (!R) throw Error("No owner type for parameterless operation call");
808
- let V = toOperationInfo(L), U = await z.invokeOperation(R, V, H, void 0);
809
- B?.success(`${L.name} completed successfully`), openOperationOutputPage(o, U.data, L, F), triggerPageRefresh(F);
813
+ if (a) {
814
+ let i = n.targetType ?? r.eContainer;
815
+ if (!i) throw Error("No owner type for parameterless operation call");
816
+ let s = N(r), l = await a.invokeOperation(i, s, c, void 0);
817
+ o?.success(`${r.name} completed successfully`), j(e, l.data, r, t), M(t);
810
818
  }
811
- } catch (o) {
812
- throw handleOperationError(o, L.name, B, V), o;
819
+ } catch (e) {
820
+ throw A(e, r.name, o, s), e;
813
821
  }
814
822
  });
815
- useParameterlessCallOperationActionHandler.actionType = "ParameterlessCallOperationActionDefinition";
816
- function getRelation(o, F) {
817
- if (o.relation) return o.relation;
818
- let I = F.ownerDataElement;
819
- return I && I["@type"] === "RelationType" ? I : null;
823
+ R.actionType = "ParameterlessCallOperationActionDefinition";
824
+ //#endregion
825
+ //#region src/handlers/autocomplete/autocomplete-handlers.ts
826
+ function z(e, t) {
827
+ if (e.relation) return e.relation;
828
+ let n = t.ownerDataElement;
829
+ return n && n["@type"] === "RelationType" ? n : null;
820
830
  }
821
- const useAutocompleteRangeActionHandler = ((o) => async (F) => {
822
- let I = o.actionDefinition.targetType;
823
- if (!I) throw Error("No target type for autocomplete range");
824
- let L = F, { onAutocompleteRange: R, api: z, onRangeResult: B } = L, V = L.searchText ?? "";
825
- if (R) {
826
- let o = await R(I, V);
827
- B?.(o);
831
+ var B = ((e) => async (t) => {
832
+ let n = e.actionDefinition.targetType;
833
+ if (!n) throw Error("No target type for autocomplete range");
834
+ let r = t, { onAutocompleteRange: i, api: a, onRangeResult: o } = r, s = r.searchText ?? "";
835
+ if (i) {
836
+ let e = await i(n, s);
837
+ o?.(e);
828
838
  return;
829
839
  }
830
- if (z) {
831
- let F = getRelation(L, o);
832
- if (!F) throw Error("Cannot determine relation for autocomplete range");
833
- let I = await z.getRelationRange(F, L.ownerTransfer, V ? { _filter: { contains: V } } : void 0);
834
- B?.(I.data);
840
+ if (a) {
841
+ let t = z(r, e);
842
+ if (!t) throw Error("Cannot determine relation for autocomplete range");
843
+ let n = await a.getRelationRange(t, r.ownerTransfer, s ? { _filter: { contains: s } } : void 0);
844
+ o?.(n.data);
835
845
  }
836
846
  });
837
- useAutocompleteRangeActionHandler.actionType = "AutocompleteRangeActionDefinition";
838
- const useAutocompleteSetActionHandler = ((o) => async (F) => {
839
- let I = F, { ownerTransfer: L, selectedEntity: R, api: z, onAutocompleteSet: B } = I, V = L?.__identifier ?? L?.__signedIdentifier, H = R?.__identifier ?? R?.__signedIdentifier;
840
- if (!V || !H) return;
841
- let U = o.actionDefinition.name ?? "";
842
- if (B) {
843
- await B(V, U, H);
847
+ B.actionType = "AutocompleteRangeActionDefinition";
848
+ var V = ((e) => async (t) => {
849
+ let n = t, { ownerTransfer: r, selectedEntity: i, api: a, onAutocompleteSet: o } = n, s = r?.__identifier ?? r?.__signedIdentifier, c = i?.__identifier ?? i?.__signedIdentifier;
850
+ if (!s || !c) return;
851
+ let l = e.actionDefinition.name ?? "";
852
+ if (o) {
853
+ await o(s, l, c);
844
854
  return;
845
855
  }
846
- if (z) {
847
- let F = getRelation(I, o);
848
- if (!F) throw Error("Cannot determine relation for autocomplete set");
849
- await z.setRelation(F, L, R);
856
+ if (a) {
857
+ let t = z(n, e);
858
+ if (!t) throw Error("Cannot determine relation for autocomplete set");
859
+ await a.setRelation(t, r, i);
850
860
  }
851
861
  });
852
- useAutocompleteSetActionHandler.actionType = "AutocompleteSetActionDefinition";
853
- const useAutocompleteAddActionHandler = ((o) => async (F) => {
854
- let I = F, { ownerTransfer: L, selectedEntities: R, api: z, onAutocompleteAdd: B } = I, V = L?.__identifier ?? L?.__signedIdentifier;
855
- if (!V || !R?.length) return;
856
- let H = R.map((o) => o.__identifier ?? o.__signedIdentifier).filter(Boolean), U = o.actionDefinition.name ?? "";
857
- if (B) {
858
- await B(V, U, H);
862
+ V.actionType = "AutocompleteSetActionDefinition";
863
+ var _e = ((e) => async (t) => {
864
+ let n = t, { ownerTransfer: r, selectedEntities: i, api: a, onAutocompleteAdd: o } = n, s = r?.__identifier ?? r?.__signedIdentifier;
865
+ if (!s || !i?.length) return;
866
+ let c = i.map((e) => e.__identifier ?? e.__signedIdentifier).filter(Boolean), l = e.actionDefinition.name ?? "";
867
+ if (o) {
868
+ await o(s, l, c);
859
869
  return;
860
870
  }
861
- if (z) {
862
- let F = getRelation(I, o);
863
- if (!F) throw Error("Cannot determine relation for autocomplete add");
864
- let B = R.filter((o) => o.__signedIdentifier);
865
- await z.addToRelation(F, L, B);
871
+ if (a) {
872
+ let t = z(n, e);
873
+ if (!t) throw Error("Cannot determine relation for autocomplete add");
874
+ let o = i.filter((e) => e.__signedIdentifier);
875
+ await a.addToRelation(t, r, o);
866
876
  }
867
877
  });
868
- useAutocompleteAddActionHandler.actionType = "AutocompleteAddActionDefinition";
869
- const usePreFetchActionHandler = ((o) => async (F) => {
870
- let I = o.actionDefinition.targetType;
871
- if (!I) throw Error("No target type for pre-fetch");
872
- let L = F;
873
- if (L.onPreFetch) {
874
- let o = await L.onPreFetch(I, F.transfer?.__identifier);
875
- o.__identifier && F.data.setTransferData(o.__identifier, o);
878
+ _e.actionType = "AutocompleteAddActionDefinition";
879
+ //#endregion
880
+ //#region src/handlers/other/other-handlers.ts
881
+ var H = ((e) => async (t) => {
882
+ let n = e.actionDefinition.targetType;
883
+ if (!n) throw Error("No target type for pre-fetch");
884
+ let r = t;
885
+ if (r.onPreFetch) {
886
+ let e = await r.onPreFetch(n, t.transfer?.__identifier);
887
+ e.__identifier && t.data.setTransferData(e.__identifier, e);
876
888
  }
877
889
  });
878
- usePreFetchActionHandler.actionType = "PreFetchActionDefinition";
879
- const useCustomActionHandler = ((o) => async (F) => {
880
- let I = F;
881
- I.onCustomAction && await I.onCustomAction(o, F);
890
+ H.actionType = "PreFetchActionDefinition";
891
+ var ve = ((e) => async (t) => {
892
+ let n = t;
893
+ n.onCustomAction && await n.onCustomAction(e, t);
882
894
  });
883
- useCustomActionHandler.actionType = "CustomActionDefinition";
884
- var ApiContext = createContext(null);
885
- function useApi() {
886
- let o = useContext(ApiContext);
887
- if (!o) throw Error("useApi must be used within ApiProvider");
888
- return o.api;
895
+ ve.actionType = "CustomActionDefinition";
896
+ //#endregion
897
+ //#region src/provider/api-context.tsx
898
+ var ye = t(null);
899
+ function be() {
900
+ let e = r(ye);
901
+ if (!e) throw Error("useApi must be used within ApiProvider");
902
+ return e.api;
889
903
  }
890
- function ApiProvider({ children: o, api: F }) {
891
- return /* @__PURE__ */ jsx(ApiContext.Provider, {
892
- value: { api: F },
893
- children: o
904
+ function xe({ children: e, api: t }) {
905
+ return /* @__PURE__ */ a(ye.Provider, {
906
+ value: { api: t },
907
+ children: e
894
908
  });
895
909
  }
896
- async function executeWithLifecycle(o, F, I, L) {
897
- let R = () => o(I), z = {
898
- ...I,
899
- action: L,
900
- actionDefinition: L.actionDefinition,
901
- page: I.page,
902
- callDefault: R
910
+ //#endregion
911
+ //#region src/lifecycle/execute-with-lifecycle.ts
912
+ async function Se(e, t, n, r) {
913
+ let i = () => e(n), a = {
914
+ ...n,
915
+ action: r,
916
+ actionDefinition: r.actionDefinition,
917
+ page: n.page,
918
+ callDefault: i
903
919
  };
904
- if (!(F.before && await F.before(z) === !1)) try {
905
- let L;
906
- return L = F.execute ? await F.execute(z) : await o(I), F.after && await F.after(z, L), L;
907
- } catch (o) {
908
- if (F.onError && await F.onError(z, o) === !0) return;
909
- throw o;
920
+ if (!(t.before && await t.before(a) === !1)) try {
921
+ let r;
922
+ return r = t.execute ? await t.execute(a) : await e(n), t.after && await t.after(a, r), r;
923
+ } catch (e) {
924
+ if (t.onError && await t.onError(a, e) === !0) return;
925
+ throw e;
910
926
  }
911
927
  }
912
- var BUILTIN_HANDLERS = new Map([
913
- ["BackActionDefinition", useBackActionHandler],
914
- ["OpenPageActionDefinition", useOpenPageActionHandler],
915
- ["RowOpenPageActionDefinition", useRowOpenPageActionHandler],
916
- ["CancelActionDefinition", useCancelActionHandler],
917
- ["OpenFormActionDefinition", useOpenFormActionHandler],
918
- ["OpenCreateFormActionDefinition", useOpenCreateFormActionHandler],
919
- ["OpenOperationInputFormActionDefinition", useOpenOperationInputFormActionHandler],
920
- ["OpenSelectorActionDefinition", useOpenSelectorActionHandler],
921
- ["OpenAddSelectorActionDefinition", useOpenAddSelectorActionHandler],
922
- ["OpenSetSelectorActionDefinition", useOpenSetSelectorActionHandler],
923
- ["OpenOperationInputSelectorActionDefinition", useOpenOperationInputSelectorActionHandler],
924
- ["SelectorRangeActionDefinition", useSelectorRangeActionHandler],
925
- ["RefreshActionDefinition", useRefreshActionHandler],
926
- ["CreateActionDefinition", useCreateActionHandler],
927
- ["UpdateActionDefinition", useUpdateActionHandler],
928
- ["DeleteActionDefinition", useDeleteActionHandler],
929
- ["BulkDeleteActionDefinition", useBulkDeleteActionHandler],
930
- ["RowDeleteActionDefinition", useRowDeleteActionHandler],
931
- ["GetTemplateActionDefinition", useGetTemplateActionHandler],
932
- ["SetActionDefinition", useSetActionHandler],
933
- ["UnsetActionDefinition", useUnsetActionHandler],
934
- ["AddActionDefinition", useAddActionHandler],
935
- ["RemoveActionDefinition", useRemoveActionHandler],
936
- ["BulkRemoveActionDefinition", useBulkRemoveActionHandler],
937
- ["ClearActionDefinition", useClearActionHandler],
938
- ["RefreshRelationActionDefinition", useRefreshRelationActionHandler],
939
- ["FilterRelationActionDefinition", useFilterRelationActionHandler],
940
- ["FilterActionDefinition", useFilterActionHandler],
941
- ["ExportActionDefinition", useExportActionHandler],
942
- ["InlineCreateRowActionDefinition", useInlineCreateRowActionHandler],
943
- ["BulkCallOperationActionDefinition", useBulkCallOperationActionHandler],
944
- ["CallOperationActionDefinition", useCallOperationActionHandler],
945
- ["InputFormCallOperationActionDefinition", useInputFormCallOperationActionHandler],
946
- ["InputSelectorCallOperationActionDefinition", useInputSelectorCallOperationActionHandler],
947
- ["ParameterlessCallOperationActionDefinition", useParameterlessCallOperationActionHandler],
948
- ["AutocompleteAddActionDefinition", useAutocompleteAddActionHandler],
949
- ["AutocompleteRangeActionDefinition", useAutocompleteRangeActionHandler],
950
- ["AutocompleteSetActionDefinition", useAutocompleteSetActionHandler],
951
- ["PreFetchActionDefinition", usePreFetchActionHandler],
952
- ["CustomActionDefinition", useCustomActionHandler]
928
+ //#endregion
929
+ //#region src/registry/action-handler-registry.ts
930
+ var Ce = new Map([
931
+ ["BackActionDefinition", c],
932
+ ["OpenPageActionDefinition", l],
933
+ ["RowOpenPageActionDefinition", u],
934
+ ["CancelActionDefinition", d],
935
+ ["OpenFormActionDefinition", f],
936
+ ["OpenCreateFormActionDefinition", p],
937
+ ["OpenOperationInputFormActionDefinition", m],
938
+ ["OpenSelectorActionDefinition", g],
939
+ ["OpenAddSelectorActionDefinition", _],
940
+ ["OpenSetSelectorActionDefinition", v],
941
+ ["OpenOperationInputSelectorActionDefinition", y],
942
+ ["SelectorRangeActionDefinition", ee],
943
+ ["RefreshActionDefinition", S],
944
+ ["CreateActionDefinition", re],
945
+ ["UpdateActionDefinition", ie],
946
+ ["DeleteActionDefinition", ae],
947
+ ["BulkDeleteActionDefinition", oe],
948
+ ["RowDeleteActionDefinition", se],
949
+ ["GetTemplateActionDefinition", ce],
950
+ ["SetActionDefinition", le],
951
+ ["UnsetActionDefinition", ue],
952
+ ["AddActionDefinition", de],
953
+ ["RemoveActionDefinition", fe],
954
+ ["BulkRemoveActionDefinition", pe],
955
+ ["ClearActionDefinition", w],
956
+ ["RefreshRelationActionDefinition", T],
957
+ ["FilterRelationActionDefinition", E],
958
+ ["FilterActionDefinition", D],
959
+ ["ExportActionDefinition", O],
960
+ ["InlineCreateRowActionDefinition", k],
961
+ ["BulkCallOperationActionDefinition", F],
962
+ ["CallOperationActionDefinition", P],
963
+ ["InputFormCallOperationActionDefinition", I],
964
+ ["InputSelectorCallOperationActionDefinition", L],
965
+ ["ParameterlessCallOperationActionDefinition", R],
966
+ ["AutocompleteAddActionDefinition", _e],
967
+ ["AutocompleteRangeActionDefinition", B],
968
+ ["AutocompleteSetActionDefinition", V],
969
+ ["PreFetchActionDefinition", H],
970
+ ["CustomActionDefinition", ve]
953
971
  ]);
954
- function getActionHandler(o) {
955
- return BUILTIN_HANDLERS.get(o.actionDefinition["@type"]);
972
+ function U(e) {
973
+ return Ce.get(e.actionDefinition["@type"]);
956
974
  }
957
- function hasActionHandler$1(o) {
958
- return getActionHandler(o) !== void 0;
975
+ function we(e) {
976
+ return U(e) !== void 0;
959
977
  }
960
- function useActionDispatcher(o) {
961
- let { navigation: F, data: L, registry: z, api: B, transfer: V, selectedRows: H, closeDialog: U, notifications: W, additionalContext: G, actionOverrides: K } = o, q = useMemo(() => ({
962
- navigation: F,
963
- data: L,
964
- registry: z,
965
- api: B,
966
- transfer: V,
967
- selectedRows: H,
968
- closeDialog: U,
969
- notifications: W,
970
- ...G
978
+ //#endregion
979
+ //#region src/hooks/use-action-dispatcher.ts
980
+ function Te(e) {
981
+ let { navigation: t, data: r, registry: a, api: o, transfer: s, selectedRows: c, closeDialog: l, notifications: u, additionalContext: d, actionOverrides: f } = e, p = i(() => ({
982
+ navigation: t,
983
+ data: r,
984
+ registry: a,
985
+ api: o,
986
+ transfer: s,
987
+ selectedRows: c,
988
+ closeDialog: l,
989
+ notifications: u,
990
+ ...d
971
991
  }), [
972
- F,
973
- L,
974
- z,
975
- B,
976
- V,
977
- H,
978
- U,
979
- W,
980
- G
981
- ]), J = useCallback((o) => hasActionHandler$1(o), []);
992
+ t,
993
+ r,
994
+ a,
995
+ o,
996
+ s,
997
+ c,
998
+ l,
999
+ u,
1000
+ d
1001
+ ]), m = n((e) => we(e), []);
982
1002
  return {
983
- dispatch: useCallback(async (o, F) => {
984
- let I = getActionHandler(o);
985
- if (!I) {
986
- let F = o.actionDefinition["@type"];
987
- throw Error(`No handler for action type: ${F}`);
1003
+ dispatch: n(async (e, t) => {
1004
+ let n = U(e);
1005
+ if (!n) {
1006
+ let t = e.actionDefinition["@type"];
1007
+ throw Error(`No handler for action type: ${t}`);
988
1008
  }
989
- let L = I(o), R = F ? {
990
- ...q,
991
- ...F
992
- } : q, z = o["xmi:id"], B = z ? K?.[z] : void 0;
993
- B && Object.keys(B).length > 0 ? await executeWithLifecycle(L, B, R, o) : await L(R);
994
- }, [q, K]),
995
- canHandle: J
1009
+ let r = n(e), i = t ? {
1010
+ ...p,
1011
+ ...t
1012
+ } : p, a = e["xmi:id"], o = a ? f?.[a] : void 0;
1013
+ o && Object.keys(o).length > 0 ? await Se(r, o, i, e) : await r(i);
1014
+ }, [p, f]),
1015
+ canHandle: m
996
1016
  };
997
1017
  }
998
- function useActionHandler(o) {
999
- return useMemo(() => {
1000
- let F = getActionHandler(o);
1001
- if (!F) {
1002
- let F = o.actionDefinition["@type"];
1003
- throw Error(`No handler for action type: ${F}`);
1018
+ //#endregion
1019
+ //#region src/hooks/use-action-handler.ts
1020
+ function Ee(e) {
1021
+ return i(() => {
1022
+ let t = U(e);
1023
+ if (!t) {
1024
+ let t = e.actionDefinition["@type"];
1025
+ throw Error(`No handler for action type: ${t}`);
1004
1026
  }
1005
- return F(o);
1006
- }, [o]);
1027
+ return t(e);
1028
+ }, [e]);
1007
1029
  }
1008
- function hasActionHandler(o) {
1009
- return hasActionHandler$1(o);
1030
+ function De(e) {
1031
+ return we(e);
1010
1032
  }
1011
- const HEADER_SIGNED_IDENTIFIER = "X-Judo-SignedIdentifier", HEADER_MASK = "X-Judo-Mask", HEADER_MARK_SELECTED_RANGE_ITEMS = "X-Judo-Mark-Selected-Range-Items", HEADER_COUNT_RECORDS = "X-Judo-CountRecords", HEADER_TOKEN = "X-Token", DEFAULT_COMMAND_MASK = "{}", SUFFIX_TEMPLATE = "/~template", SUFFIX_GET = "/~get", SUFFIX_UPDATE = "/~update", SUFFIX_VALIDATE = "/~validate", SUFFIX_DELETE = "/~delete", SUFFIX_LIST = "/~list", SUFFIX_RANGE = "/~range", SUFFIX_CREATE = "/~create", SUFFIX_SET = "/~set", SUFFIX_UNSET = "/~unset", SUFFIX_ADD = "/~add", SUFFIX_REMOVE = "/~remove", SUFFIX_EXPORT = "/~export";
1012
- var SPLITTER = "::", TRANSFER_SKIP_SEGMENT = "_default_transferobjecttypes";
1013
- function restPath(o, F, I, L) {
1014
- let R = `${F}${I ? I.split(SPLITTER).join("/") : ""}${L ?? ""}`;
1015
- return `/${o.packageNameTokens?.length ? `${o.packageNameTokens.join("/")}/` : ""}${(o.simpleName ?? "").split(SPLITTER).filter((o) => !o.includes(TRANSFER_SKIP_SEGMENT)).join("/")}${R}`;
1033
+ //#endregion
1034
+ //#region src/api/constants.ts
1035
+ var W = "X-Judo-SignedIdentifier", Oe = "X-Judo-Mask", ke = "X-Judo-MarkSelectedRangeItems", Ae = "X-Judo-CountRecords", je = "X-Token", Me = "{}", G = "/~template", K = "/~get", Ne = "/~update", q = "/~validate", Pe = "/~delete", Fe = "/~list", Ie = "/~range", Le = "/~create", Re = "/~set", ze = "/~unset", Be = "/~add", Ve = "/~remove", He = "/~export", Ue = "/~upload-token", We = "/~principal", Ge = "/~meta", Ke = "::", qe = "_default_transferobjecttypes";
1036
+ function J(e, t, n, r) {
1037
+ let i = `${t}${n ? n.split(Ke).join("/") : ""}${r ?? ""}`;
1038
+ return `/${e.packageNameTokens?.length ? `${e.packageNameTokens.join("/")}/` : ""}${(e.simpleName ?? "").split(Ke).filter((e) => !e.includes(qe)).join("/")}${i}`;
1016
1039
  }
1017
- function getPathForApp(o, F) {
1018
- if (!o) throw Error("Application context is required for path building. Ensure the API is properly initialized with an Application.");
1019
- let I = F || "";
1020
- return `/${o.modelName}${I.length && !I.startsWith("/") ? `/${I}` : I}`;
1040
+ function Je(e, t) {
1041
+ if (!e) throw Error("Application context is required for path building. Ensure the API is properly initialized with an Application.");
1042
+ let n = t || "";
1043
+ return `/${e.modelName}${n.length && !n.startsWith("/") ? `/${n}` : n}`;
1021
1044
  }
1022
- function rootPathForApp(o) {
1023
- if (!o?.actor) throw Error("Application.actor is required for path building. Ensure the Application has a valid actor ClassType.");
1024
- return `${o.actor.packageNameTokens?.length ? `${o.actor.packageNameTokens.join("/")}/` : ""}${o.actor.simpleName ?? o.actor.name ?? "Actor"}`;
1045
+ function Ye(e) {
1046
+ if (!e?.actor) throw Error("Application.actor is required for path building. Ensure the Application has a valid actor ClassType.");
1047
+ return `${e.actor.packageNameTokens?.length ? `${e.actor.packageNameTokens.join("/")}/` : ""}${e.actor.simpleName ?? e.actor.name ?? "Actor"}`;
1025
1048
  }
1026
- function getPathForActor(o, F = "") {
1027
- return getPathForApp(o, rootPathForApp(o) + (F.length && !F.startsWith("/") ? `/${F}` : F));
1049
+ function Y(e, t = "") {
1050
+ return Je(e, Ye(e) + (t.length && !t.startsWith("/") ? `/${t}` : t));
1028
1051
  }
1029
- function getRelationPath(o, F, I = "/~list") {
1030
- return getPathForActor(F, restPath(o?.eContainer, "/", o.name, I));
1052
+ function X(e, t, n = "/~list") {
1053
+ return Y(t, J(e?.eContainer, "/", e.name, n));
1031
1054
  }
1032
- function getClassPath(o, F, I = "") {
1033
- return getPathForActor(F, restPath(o, "", "", I));
1055
+ function Z(e, t, n = "") {
1056
+ return Y(t, J(e, "", "", n));
1034
1057
  }
1035
- function getMutationRelationPath(o, F, I, L = !1) {
1036
- let R = o?.eContainer;
1037
- return L ? getPathForActor(F, restPath(R, "/", o.name, I)) : getPathForActor(F, restPath(R, "/~update/", o.name, I));
1058
+ function Q(e, t, n, r = !1) {
1059
+ let i = e?.eContainer;
1060
+ return r ? Y(t, J(i, "/", e.name, n)) : Y(t, J(i, "/~update/", e.name, n));
1038
1061
  }
1039
- function getOperationPath(o, F, I, L = "") {
1040
- return getPathForActor(I, restPath(o, "/", F, L));
1062
+ function $(e, t, n, r = "") {
1063
+ return Y(n, J(e, "/", t, r));
1041
1064
  }
1042
- var JudoRestApi = class {
1065
+ //#endregion
1066
+ //#region src/api/judo-rest-api.ts
1067
+ var Xe = class {
1043
1068
  config;
1044
1069
  fetchImpl;
1045
1070
  _defaultHeaders;
1046
- constructor(o) {
1047
- if (!o.application) throw Error("JudoRestApi requires 'application' in config. Ensure the API is created with a valid Application context.");
1048
- if (!o.application.actor) throw Error("JudoRestApi requires 'application.actor' in config. Ensure the Application has a valid actor ClassType.");
1049
- this.config = o, this.fetchImpl = o.fetch ?? globalThis.fetch.bind(globalThis), this._defaultHeaders = { ...o.defaultHeaders };
1071
+ constructor(e) {
1072
+ if (!e.application) throw Error("JudoRestApi requires 'application' in config. Ensure the API is created with a valid Application context.");
1073
+ if (!e.application.actor) throw Error("JudoRestApi requires 'application.actor' in config. Ensure the Application has a valid actor ClassType.");
1074
+ this.config = e, this.fetchImpl = e.fetch ?? globalThis.fetch.bind(globalThis), this._defaultHeaders = { ...e.defaultHeaders };
1050
1075
  }
1051
- setDefaultHeaders(o) {
1052
- this._defaultHeaders = o;
1076
+ setDefaultHeaders(e) {
1077
+ this._defaultHeaders = e;
1053
1078
  }
1054
- getUrl(o) {
1055
- return `${this.config.baseUrl}${o}`;
1079
+ getUrl(e) {
1080
+ return `${this.config.baseUrl}${e}`;
1056
1081
  }
1057
- serializeTransfer(o) {
1058
- return this.config.transferSerializer ? this.config.transferSerializer.serialize(o) : o;
1082
+ serializeTransfer(e) {
1083
+ return this.config.transferSerializer ? this.config.transferSerializer.serialize(e) : e;
1059
1084
  }
1060
- deserializeTransfer(o) {
1061
- return this.config.transferDeserializer ? this.config.transferDeserializer.deserialize(o) : o;
1085
+ deserializeTransfer(e) {
1086
+ return this.config.transferDeserializer ? this.config.transferDeserializer.deserialize(e) : e;
1062
1087
  }
1063
- deserializeArray(o) {
1064
- return Array.isArray(o) ? this.config.transferDeserializer ? o.map((o) => this.config.transferDeserializer.deserialize(o)) : o : [];
1088
+ deserializeArray(e) {
1089
+ return Array.isArray(e) ? this.config.transferDeserializer ? e.map((e) => this.config.transferDeserializer.deserialize(e)) : e : [];
1065
1090
  }
1066
- async request(o, F, I = {}) {
1067
- let L = this.getUrl(F), R = {
1068
- method: o,
1091
+ async request(e, t, n = {}) {
1092
+ let r = this.getUrl(t), i = {
1093
+ method: e,
1069
1094
  headers: {
1070
1095
  "Content-Type": "application/json",
1071
1096
  ...this._defaultHeaders,
1072
- ...I.headers
1097
+ ...n.headers
1073
1098
  },
1074
- body: I.body === void 0 ? void 0 : JSON.stringify(I.body)
1099
+ body: n.body === void 0 ? void 0 : JSON.stringify(n.body)
1075
1100
  };
1076
- this.config.onRequest && (R = await this.config.onRequest(R));
1101
+ this.config.onRequest && (i = await this.config.onRequest(i));
1077
1102
  try {
1078
- let o = await this.fetchImpl(L, R);
1079
- if (this.config.onResponse && (o = await this.config.onResponse(o)), !o.ok) {
1080
- let F = await o.text();
1081
- if (o.status === 400 && F.length > 0) try {
1082
- let o = JSON.parse(F);
1083
- if (Array.isArray(o)) {
1084
- let { ValidationError: F } = await import("./types-CbA9-fcJ.js");
1085
- throw new F(o);
1103
+ let e = await this.fetchImpl(r, i);
1104
+ if (this.config.onResponse && (e = await this.config.onResponse(e)), !e.ok) {
1105
+ let t = await e.text();
1106
+ if (e.status === 400 && t.length > 0) try {
1107
+ let e = JSON.parse(t);
1108
+ if (Array.isArray(e)) {
1109
+ let { ValidationError: t } = await import("./types-BRqo2AHD.js").then((e) => e.n);
1110
+ throw new t(e);
1086
1111
  }
1087
- } catch (o) {
1088
- if (o instanceof Error && o.name === "ValidationError") throw o;
1112
+ } catch (e) {
1113
+ if (e instanceof Error && e.name === "ValidationError") throw e;
1089
1114
  }
1090
- throw Error(`HTTP ${o.status}: ${F}`);
1115
+ throw Error(`HTTP ${e.status}: ${t}`);
1091
1116
  }
1092
- let F;
1093
- if (I.responseType === "blob") F = await o.blob();
1117
+ let t;
1118
+ if (n.responseType === "blob") t = await e.blob();
1094
1119
  else {
1095
- let I = await o.text();
1096
- F = I.length > 0 ? JSON.parse(I) : void 0;
1120
+ let n = await e.text();
1121
+ t = n.length > 0 ? JSON.parse(n) : void 0;
1097
1122
  }
1098
1123
  return {
1099
- data: F,
1100
- status: o.status,
1101
- headers: o.headers
1124
+ data: t,
1125
+ status: e.status,
1126
+ headers: e.headers
1102
1127
  };
1103
- } catch (o) {
1104
- throw this.config.onError && this.config.onError(o), o;
1128
+ } catch (e) {
1129
+ throw this.config.onError && this.config.onError(e), e;
1105
1130
  }
1106
1131
  }
1107
- async getTemplate(o) {
1108
- let F = getClassPath(o, this.config.application, SUFFIX_TEMPLATE), I = await this.request("GET", F);
1132
+ async getTemplate(e) {
1133
+ let t = Z(e, this.config.application, G), n = await this.request("GET", t);
1109
1134
  return {
1110
- ...I,
1111
- data: this.deserializeTransfer(I.data)
1135
+ ...n,
1136
+ data: this.deserializeTransfer(n.data)
1112
1137
  };
1113
1138
  }
1114
- async refresh(o, F, I) {
1115
- let L = getClassPath(o, this.config.application, SUFFIX_GET), R = await this.request("POST", L, {
1116
- body: I ?? {},
1117
- headers: { [HEADER_SIGNED_IDENTIFIER]: F.__signedIdentifier }
1139
+ async refresh(e, t, n) {
1140
+ let r = Z(e, this.config.application, K), i = await this.request("POST", r, {
1141
+ body: n ?? {},
1142
+ headers: { [W]: t.__signedIdentifier }
1118
1143
  });
1119
1144
  return {
1120
- ...R,
1121
- data: this.deserializeTransfer(R.data)
1145
+ ...i,
1146
+ data: this.deserializeTransfer(i.data)
1122
1147
  };
1123
1148
  }
1124
- async update(o, F, I) {
1125
- let L = getClassPath(o, this.config.application, SUFFIX_UPDATE), R = await this.request("POST", L, {
1126
- body: this.serializeTransfer(F),
1149
+ async update(e, t, n) {
1150
+ let r = Z(e, this.config.application, Ne), i = await this.request("POST", r, {
1151
+ body: this.serializeTransfer(t),
1127
1152
  headers: {
1128
- [HEADER_SIGNED_IDENTIFIER]: F.__signedIdentifier,
1129
- [HEADER_MASK]: I ?? "{}"
1153
+ [W]: t.__signedIdentifier,
1154
+ [Oe]: n ?? "{}"
1130
1155
  }
1131
1156
  });
1132
1157
  return {
1133
- ...R,
1134
- data: this.deserializeTransfer(R.data)
1158
+ ...i,
1159
+ data: this.deserializeTransfer(i.data)
1135
1160
  };
1136
1161
  }
1137
- async validateUpdate(o, F) {
1138
- let I = getClassPath(o, this.config.application, SUFFIX_VALIDATE), L = await this.request("POST", I, {
1139
- body: this.serializeTransfer(F),
1140
- headers: { [HEADER_SIGNED_IDENTIFIER]: F.__signedIdentifier }
1162
+ async validateUpdate(e, t) {
1163
+ let n = Z(e, this.config.application, q), r = await this.request("POST", n, {
1164
+ body: this.serializeTransfer(t),
1165
+ headers: { [W]: t.__signedIdentifier }
1141
1166
  });
1142
1167
  return {
1143
- ...L,
1144
- data: this.deserializeTransfer(L.data)
1168
+ ...r,
1169
+ data: this.deserializeTransfer(r.data)
1145
1170
  };
1146
1171
  }
1147
- async delete(o, F) {
1148
- let I = getClassPath(o, this.config.application, SUFFIX_DELETE);
1149
- return this.request("POST", I, { headers: { [HEADER_SIGNED_IDENTIFIER]: F.__signedIdentifier } });
1172
+ async delete(e, t) {
1173
+ let n = Z(e, this.config.application, Pe);
1174
+ return this.request("POST", n, { headers: { [W]: t.__signedIdentifier } });
1150
1175
  }
1151
- async listRelation(o, F, I, L) {
1152
- let R = getRelationPath(o, this.config.application, SUFFIX_LIST), z = {};
1153
- F?.__signedIdentifier && (z[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier), L && (z[HEADER_COUNT_RECORDS] = "true");
1154
- let B = await this.request("POST", R, {
1155
- body: I ?? {},
1156
- headers: z
1176
+ async listRelation(e, t, n, r) {
1177
+ let i = X(e, this.config.application, Fe), a = {};
1178
+ t?.__signedIdentifier && (a[W] = t.__signedIdentifier), r && (a[Ae] = "true");
1179
+ let o = await this.request("POST", i, {
1180
+ body: n ?? {},
1181
+ headers: a
1157
1182
  });
1158
1183
  return {
1159
- ...B,
1160
- data: this.deserializeArray(B.data)
1184
+ ...o,
1185
+ data: this.deserializeArray(o.data)
1161
1186
  };
1162
1187
  }
1163
- async getRelation(o, F, I) {
1164
- let L = getRelationPath(o, this.config.application, SUFFIX_GET), R = await this.request("POST", L, {
1165
- body: I ?? {},
1166
- headers: { [HEADER_SIGNED_IDENTIFIER]: F.__signedIdentifier }
1167
- }), z = R.data === void 0 || R.data === null ? null : this.deserializeTransfer(R.data);
1188
+ async getRelation(e, t, n) {
1189
+ let r = X(e, this.config.application, K), i = await this.request("POST", r, {
1190
+ body: n ?? {},
1191
+ headers: { [W]: t.__signedIdentifier }
1192
+ }), a = i.data === void 0 || i.data === null ? null : this.deserializeTransfer(i.data);
1168
1193
  return {
1169
- ...R,
1170
- data: z
1194
+ ...i,
1195
+ data: a
1171
1196
  };
1172
1197
  }
1173
- async refreshAccessRelation(o, F) {
1174
- let I = getRelationPath(o, this.config.application, SUFFIX_GET), L = await this.request("POST", I, { body: F ?? {} });
1198
+ async refreshAccessRelation(e, t) {
1199
+ let n = X(e, this.config.application, K), r = await this.request("POST", n, { body: t ?? {} });
1175
1200
  return {
1176
- ...L,
1177
- data: this.deserializeTransfer(L.data)
1201
+ ...r,
1202
+ data: this.deserializeTransfer(r.data)
1178
1203
  };
1179
1204
  }
1180
- async getRelationRange(o, F, I, L) {
1181
- let R = getRelationPath(o, this.config.application, SUFFIX_RANGE), z = {
1182
- owner: F ?? {},
1183
- queryCustomizer: I ?? {}
1184
- }, B = { [HEADER_MARK_SELECTED_RANGE_ITEMS]: "true" };
1185
- L && (B[HEADER_COUNT_RECORDS] = "true");
1186
- let V = await this.request("POST", R, {
1187
- body: z,
1188
- headers: B
1205
+ async getRelationRange(e, t, n, r) {
1206
+ let i = X(e, this.config.application, Ie), a = {
1207
+ owner: t ?? {},
1208
+ queryCustomizer: n ?? {}
1209
+ }, o = { [ke]: "true" };
1210
+ r && (o[Ae] = "true");
1211
+ let s = await this.request("POST", i, {
1212
+ body: a,
1213
+ headers: o
1189
1214
  });
1190
1215
  return {
1191
- ...V,
1192
- data: this.deserializeArray(V.data)
1216
+ ...s,
1217
+ data: this.deserializeArray(s.data)
1193
1218
  };
1194
1219
  }
1195
- async getRelationTemplate(o) {
1196
- let F = getClassPath(o.target, this.config.application, SUFFIX_TEMPLATE), I = await this.request("GET", F);
1220
+ async getRelationTemplate(e) {
1221
+ let t = Z(e.target, this.config.application, G), n = await this.request("GET", t);
1197
1222
  return {
1198
- ...I,
1199
- data: this.deserializeTransfer(I.data)
1223
+ ...n,
1224
+ data: this.deserializeTransfer(n.data)
1200
1225
  };
1201
1226
  }
1202
- async createRelation(o, F, I, L) {
1203
- let R = o.isAccess, z = R ? getRelationPath(o, this.config.application, SUFFIX_CREATE) : getMutationRelationPath(o, this.config.application, SUFFIX_CREATE), B = { [HEADER_MASK]: L ?? "{}" };
1204
- !R && F?.__signedIdentifier && (B[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier);
1205
- let V = await this.request("POST", z, {
1206
- body: this.serializeTransfer(I),
1207
- headers: B
1227
+ async createRelation(e, t, n, r) {
1228
+ let i = e.isAccess, a = i ? X(e, this.config.application, Le) : Q(e, this.config.application, Le), o = { [Oe]: r ?? "{}" };
1229
+ !i && t?.__signedIdentifier && (o[W] = t.__signedIdentifier);
1230
+ let s = await this.request("POST", a, {
1231
+ body: this.serializeTransfer(n),
1232
+ headers: o
1208
1233
  });
1209
1234
  return {
1210
- ...V,
1211
- data: this.deserializeTransfer(V.data)
1235
+ ...s,
1236
+ data: this.deserializeTransfer(s.data)
1212
1237
  };
1213
1238
  }
1214
- async validateCreateRelation(o, F, I) {
1215
- let L = o.isAccess, R = L ? getRelationPath(o, this.config.application, SUFFIX_VALIDATE) : getMutationRelationPath(o, this.config.application, SUFFIX_VALIDATE), z = {};
1216
- !L && F?.__signedIdentifier && (z[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier);
1217
- let B = await this.request("POST", R, {
1218
- body: this.serializeTransfer(I),
1219
- headers: z
1239
+ async validateCreateRelation(e, t, n) {
1240
+ let r = e.isAccess, i = r ? X(e, this.config.application, q) : Q(e, this.config.application, q), a = {};
1241
+ !r && t?.__signedIdentifier && (a[W] = t.__signedIdentifier);
1242
+ let o = await this.request("POST", i, {
1243
+ body: this.serializeTransfer(n),
1244
+ headers: a
1220
1245
  });
1221
1246
  return {
1222
- ...B,
1223
- data: this.deserializeTransfer(B.data)
1247
+ ...o,
1248
+ data: this.deserializeTransfer(o.data)
1224
1249
  };
1225
1250
  }
1226
- async setRelation(o, F, I) {
1227
- let L = o.isAccess, R = getMutationRelationPath(o, this.config.application, SUFFIX_SET, L), z = {};
1228
- L || (z[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier);
1229
- let B = Array.isArray(I) ? I.map((o) => this.serializeTransfer(o)) : this.serializeTransfer(I);
1230
- return this.request("POST", R, {
1231
- body: B,
1232
- headers: z
1251
+ async setRelation(e, t, n) {
1252
+ let r = e.isAccess, i = Q(e, this.config.application, Re, r), a = {};
1253
+ r || (a[W] = t.__signedIdentifier);
1254
+ let o = Array.isArray(n) ? n.map((e) => this.serializeTransfer(e)) : this.serializeTransfer(n);
1255
+ return this.request("POST", i, {
1256
+ body: o,
1257
+ headers: a
1233
1258
  });
1234
1259
  }
1235
- async unsetRelation(o, F) {
1236
- let I = o.isAccess, L = getMutationRelationPath(o, this.config.application, SUFFIX_UNSET, I), R = {};
1237
- return I || (R[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier), this.request("POST", L, { headers: R });
1260
+ async unsetRelation(e, t) {
1261
+ let n = e.isAccess, r = Q(e, this.config.application, ze, n), i = {};
1262
+ return n || (i[W] = t.__signedIdentifier), this.request("POST", r, { headers: i });
1238
1263
  }
1239
- async addToRelation(o, F, I) {
1240
- let L = o.isAccess, R = getMutationRelationPath(o, this.config.application, SUFFIX_ADD, L), z = {};
1241
- return L || (z[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier), this.request("POST", R, {
1242
- body: I.map((o) => this.serializeTransfer(o)),
1243
- headers: z
1264
+ async addToRelation(e, t, n) {
1265
+ let r = e.isAccess, i = Q(e, this.config.application, Be, r), a = {};
1266
+ return r || (a[W] = t.__signedIdentifier), this.request("POST", i, {
1267
+ body: n.map((e) => this.serializeTransfer(e)),
1268
+ headers: a
1244
1269
  });
1245
1270
  }
1246
- async removeFromRelation(o, F, I) {
1247
- let L = o.isAccess, R = getMutationRelationPath(o, this.config.application, SUFFIX_REMOVE, L), z = {};
1248
- return L || (z[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier), this.request("POST", R, {
1249
- body: I.map((o) => this.serializeTransfer(o)),
1250
- headers: z
1271
+ async removeFromRelation(e, t, n) {
1272
+ let r = e.isAccess, i = Q(e, this.config.application, Ve, r), a = {};
1273
+ return r || (a[W] = t.__signedIdentifier), this.request("POST", i, {
1274
+ body: n.map((e) => this.serializeTransfer(e)),
1275
+ headers: a
1251
1276
  });
1252
1277
  }
1253
- async exportRelation(o, F, I) {
1254
- let L = getRelationPath(o, this.config.application, SUFFIX_EXPORT), R = {};
1255
- return F?.__signedIdentifier && (R[HEADER_SIGNED_IDENTIFIER] = F.__signedIdentifier), this.request("POST", L, {
1256
- body: I ?? {},
1257
- headers: R,
1278
+ async exportRelation(e, t, n) {
1279
+ let r = X(e, this.config.application, He), i = {};
1280
+ return t?.__signedIdentifier && (i[W] = t.__signedIdentifier), this.request("POST", r, {
1281
+ body: n ?? {},
1282
+ headers: i,
1258
1283
  responseType: "blob"
1259
1284
  });
1260
1285
  }
1261
- async invokeOperation(o, F, I, L) {
1262
- let R = getOperationPath(o, F.name, this.config.application), z = {};
1263
- F.isMapped && !F.isStatic && I?.__signedIdentifier && (z[HEADER_SIGNED_IDENTIFIER] = I.__signedIdentifier);
1264
- let B = await this.request("POST", R, {
1265
- body: F.hasInput ? this.serializeTransfer(L) : void 0,
1266
- headers: z
1286
+ async invokeOperation(e, t, n, r) {
1287
+ let i = $(e, t.name, this.config.application), a = {};
1288
+ t.isMapped && !t.isStatic && n?.__signedIdentifier && (a[W] = n.__signedIdentifier);
1289
+ let o = await this.request("POST", i, {
1290
+ body: t.hasInput ? this.serializeTransfer(r) : void 0,
1291
+ headers: a
1267
1292
  });
1268
- return B.data !== void 0 && B.data !== null ? {
1269
- ...B,
1270
- data: this.deserializeTransfer(B.data)
1271
- } : B;
1272
- }
1273
- async validateOperationInput(o, F, I, L) {
1274
- let R = getOperationPath(o, F.name, this.config.application, SUFFIX_VALIDATE), z = {};
1275
- F.isMapped && !F.isStatic && I?.__signedIdentifier && (z[HEADER_SIGNED_IDENTIFIER] = I.__signedIdentifier);
1276
- let B = await this.request("POST", R, {
1277
- body: this.serializeTransfer(L),
1278
- headers: z
1293
+ return o.data !== void 0 && o.data !== null ? {
1294
+ ...o,
1295
+ data: this.deserializeTransfer(o.data)
1296
+ } : o;
1297
+ }
1298
+ async validateOperationInput(e, t, n, r) {
1299
+ let i = $(e, t.name, this.config.application, q), a = {};
1300
+ t.isMapped && !t.isStatic && n?.__signedIdentifier && (a[W] = n.__signedIdentifier);
1301
+ let o = await this.request("POST", i, {
1302
+ body: this.serializeTransfer(r),
1303
+ headers: a
1279
1304
  });
1280
1305
  return {
1281
- ...B,
1282
- data: this.deserializeTransfer(B.data)
1306
+ ...o,
1307
+ data: this.deserializeTransfer(o.data)
1283
1308
  };
1284
1309
  }
1285
- async getOperationInputTemplate(o) {
1286
- if (!o.inputType) throw Error(`Operation ${o.name} has no input type`);
1287
- let F = getClassPath(o.inputType, this.config.application, SUFFIX_TEMPLATE), I = await this.request("GET", F);
1310
+ async getOperationInputTemplate(e) {
1311
+ if (!e.inputType) throw Error(`Operation ${e.name} has no input type`);
1312
+ let t = Z(e.inputType, this.config.application, G), n = await this.request("GET", t);
1288
1313
  return {
1289
- ...I,
1290
- data: this.deserializeTransfer(I.data)
1314
+ ...n,
1315
+ data: this.deserializeTransfer(n.data)
1291
1316
  };
1292
1317
  }
1293
- async getOperationInputRange(o, F, I, L, R) {
1294
- let z = getOperationPath(o, F.name, this.config.application, SUFFIX_RANGE), B = {
1295
- owner: I ?? {},
1296
- queryCustomizer: L ?? {}
1297
- }, V = { [HEADER_MARK_SELECTED_RANGE_ITEMS]: "true" };
1298
- R && (V[HEADER_COUNT_RECORDS] = "true");
1299
- let H = await this.request("POST", z, {
1300
- body: B,
1301
- headers: V
1318
+ async getOperationInputRange(e, t, n, r, i) {
1319
+ let a = $(e, t.name, this.config.application, Ie), o = {
1320
+ owner: n ?? {},
1321
+ queryCustomizer: r ?? {}
1322
+ }, s = { [ke]: "true" };
1323
+ i && (s[Ae] = "true");
1324
+ let c = await this.request("POST", a, {
1325
+ body: o,
1326
+ headers: s
1302
1327
  });
1303
1328
  return {
1304
- ...H,
1305
- data: this.deserializeArray(H.data)
1329
+ ...c,
1330
+ data: this.deserializeArray(c.data)
1306
1331
  };
1307
1332
  }
1308
1333
  async getPrincipal() {
1309
- let o = getPathForActor(this.config.application, "/~principal"), F = await this.request("GET", o);
1334
+ let e = Y(this.config.application, We), t = await this.request("GET", e);
1310
1335
  return {
1311
- ...F,
1312
- data: this.deserializeTransfer(F.data)
1336
+ ...t,
1337
+ data: this.deserializeTransfer(t.data)
1313
1338
  };
1314
1339
  }
1315
1340
  async getMetadata() {
1316
- let o = getPathForActor(this.config.application, "/~meta");
1317
- return this.request("GET", o);
1341
+ let e = Y(this.config.application, Ge);
1342
+ return this.request("GET", e);
1318
1343
  }
1319
- async uploadFile(o, F) {
1320
- let I = (await this.request("POST", `${o}/~upload-token`)).data.token, L = new FormData();
1321
- L.append("file", F);
1322
- let R = `${this.config.baseUrl}/upload`, z = await this.fetchImpl(R, {
1344
+ async uploadFile(e, t) {
1345
+ let n = (await this.request("POST", `${e}${Ue}`)).data.token, r = new FormData();
1346
+ r.append("file", t);
1347
+ let i = `${this.config.baseUrl}/upload`, a = await this.fetchImpl(i, {
1323
1348
  method: "POST",
1324
1349
  headers: {
1325
1350
  ...this._defaultHeaders,
1326
- [HEADER_TOKEN]: I
1351
+ [je]: n
1327
1352
  },
1328
- body: L
1353
+ body: r
1329
1354
  });
1330
- if (!z.ok) throw Error(`Upload failed: HTTP ${z.status}`);
1355
+ if (!a.ok) throw Error(`Upload failed: HTTP ${a.status}`);
1331
1356
  return {
1332
- data: await z.json(),
1333
- status: z.status,
1334
- headers: z.headers
1357
+ data: await a.json(),
1358
+ status: a.status,
1359
+ headers: a.headers
1335
1360
  };
1336
1361
  }
1337
- async downloadFile(o, F = "attachment") {
1338
- let I = `${this.config.baseUrl}/download?disposition=${F}`, L = await this.fetchImpl(I, {
1362
+ async downloadFile(e, t = "attachment") {
1363
+ let n = `${this.config.baseUrl}/download?disposition=${t}`, r = await this.fetchImpl(n, {
1339
1364
  method: "GET",
1340
1365
  headers: {
1341
1366
  ...this._defaultHeaders,
1342
- [HEADER_TOKEN]: o
1367
+ [je]: e
1343
1368
  }
1344
1369
  });
1345
- if (!L.ok) throw Error(`Download failed: HTTP ${L.status}`);
1370
+ if (!r.ok) throw Error(`Download failed: HTTP ${r.status}`);
1346
1371
  return {
1347
- data: await L.blob(),
1348
- status: L.status,
1349
- headers: L.headers
1372
+ data: await r.blob(),
1373
+ status: r.status,
1374
+ headers: r.headers
1350
1375
  };
1351
1376
  }
1352
- async findInstance(o, F, I) {
1353
- let L = getRelationPath(o, this.config.application, SUFFIX_LIST), R = {
1354
- _identifier: F,
1377
+ async findInstance(e, t, n) {
1378
+ let r = X(e, this.config.application, Fe), i = {
1379
+ _identifier: t,
1355
1380
  _seek: { limit: 1 }
1356
1381
  };
1357
- I && (R._mask = I);
1358
- let z = await this.request("POST", L, { body: R }), B = this.deserializeArray(z.data), V = B.length > 0 ? B[0] : null;
1382
+ n && (i._mask = n);
1383
+ let a = await this.request("POST", r, { body: i }), o = this.deserializeArray(a.data), s = o.length > 0 ? o[0] : null;
1359
1384
  return {
1360
- ...z,
1361
- data: V
1385
+ ...a,
1386
+ data: s
1362
1387
  };
1363
1388
  }
1364
1389
  };
1365
- function createJudoRestApi(o) {
1366
- return new JudoRestApi(o);
1390
+ function Ze(e) {
1391
+ return new Xe(e);
1367
1392
  }
1368
- const BACKEND_PROPERTIES = new Set([
1393
+ //#endregion
1394
+ //#region src/api/transfer-serializer.ts
1395
+ var Qe = new Set([
1369
1396
  "__identifier",
1370
1397
  "__entityType",
1371
1398
  "__deleteable",
1372
1399
  "__updateable",
1373
1400
  "__version"
1374
- ]), FRONTEND_PROPERTIES = new Set([
1401
+ ]), $e = new Set([
1375
1402
  "__isNew",
1376
1403
  "__items",
1377
1404
  "__tempId"
1378
- ]), INTERNAL_PROPERTIES = new Set([...BACKEND_PROPERTIES, ...FRONTEND_PROPERTIES]);
1379
- function isInternalProperty(o) {
1380
- return o === "__signedIdentifier" ? !1 : INTERNAL_PROPERTIES.has(o) ? !0 : o.startsWith("__");
1405
+ ]), et = new Set([...Qe, ...$e]);
1406
+ function tt(e) {
1407
+ return e === "__signedIdentifier" ? !1 : et.has(e) ? !0 : e.startsWith("__");
1381
1408
  }
1382
- function serializeTemporalValue(o, F) {
1383
- switch (F) {
1384
- case "date": return `${o.getFullYear()}-${String(o.getMonth() + 1).padStart(2, "0")}-${String(o.getDate()).padStart(2, "0")}`;
1385
- case "timestamp": return o.toISOString();
1386
- case "time": return `${String(o.getHours()).padStart(2, "0")}:${String(o.getMinutes()).padStart(2, "0")}:${String(o.getSeconds()).padStart(2, "0")}`;
1409
+ function nt(e, t) {
1410
+ switch (t) {
1411
+ case "date": return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
1412
+ case "timestamp": return e.toISOString();
1413
+ case "time": return `${String(e.getHours()).padStart(2, "0")}:${String(e.getMinutes()).padStart(2, "0")}:${String(e.getSeconds()).padStart(2, "0")}`;
1387
1414
  }
1388
1415
  }
1389
- function createModelAwareSerializer(o) {
1390
- return { serialize(F) {
1391
- if (typeof F != "object" || !F) return F;
1392
- if (Array.isArray(F)) return F.map((o) => this.serialize(o));
1393
- let I = F, L = I.__entityType, R = L ? o[L] : void 0, z = {};
1394
- for (let [o, F] of Object.entries(I)) if (!isInternalProperty(o)) if (F instanceof Date) {
1395
- let I = R?.[o];
1396
- z[o] = I ? serializeTemporalValue(F, I) : F.toISOString();
1397
- } else typeof F == "object" && F ? z[o] = this.serialize(F) : z[o] = F;
1398
- return z;
1416
+ function rt(e) {
1417
+ return { serialize(t) {
1418
+ if (typeof t != "object" || !t) return t;
1419
+ if (Array.isArray(t)) return t.map((e) => this.serialize(e));
1420
+ let n = t, r = n.__entityType, i = r ? e[r] : void 0, a = {};
1421
+ for (let [e, t] of Object.entries(n)) if (!tt(e)) if (t instanceof Date) {
1422
+ let n = i?.[e];
1423
+ a[e] = n ? nt(t, n) : t.toISOString();
1424
+ } else typeof t == "object" && t ? a[e] = this.serialize(t) : a[e] = t;
1425
+ return a;
1399
1426
  } };
1400
1427
  }
1401
- function parseLocalDate(o) {
1402
- let F = o.split("-");
1403
- if (F.length !== 3) return /* @__PURE__ */ new Date(NaN);
1404
- let [I, L, R] = F.map(Number);
1405
- return new Date(I, L - 1, R);
1428
+ //#endregion
1429
+ //#region src/api/transfer-deserializer.ts
1430
+ function it(e) {
1431
+ let t = e.split("-");
1432
+ if (t.length !== 3) return /* @__PURE__ */ new Date(NaN);
1433
+ let [n, r, i] = t.map(Number);
1434
+ return new Date(n, r - 1, i);
1406
1435
  }
1407
- function deserializeTemporalValue(o, F) {
1408
- switch (F) {
1409
- case "date": return parseLocalDate(o);
1410
- case "timestamp": return new Date(o);
1411
- case "time": return o;
1436
+ function at(e, t) {
1437
+ switch (t) {
1438
+ case "date": return it(e);
1439
+ case "timestamp": return new Date(e);
1440
+ case "time": return e;
1412
1441
  }
1413
1442
  }
1414
- function createModelAwareDeserializer(o) {
1415
- return { deserialize(F) {
1416
- if (typeof F != "object" || !F) return F;
1417
- if (Array.isArray(F)) return F.map((o) => this.deserialize(o));
1418
- let I = F, L = I.__entityType, R = L ? o[L] : void 0, z = { ...I };
1419
- for (let [o, F] of Object.entries(z)) typeof F == "object" && F && (z[o] = this.deserialize(F));
1420
- if (R) for (let [o, F] of Object.entries(R)) {
1421
- let I = z[o];
1422
- typeof I == "string" && (z[o] = deserializeTemporalValue(I, F));
1443
+ function ot(e) {
1444
+ return { deserialize(t) {
1445
+ if (typeof t != "object" || !t) return t;
1446
+ if (Array.isArray(t)) return t.map((e) => this.deserialize(e));
1447
+ let n = t, r = n.__entityType, i = r ? e[r] : void 0, a = { ...n };
1448
+ for (let [e, t] of Object.entries(a)) typeof t == "object" && t && (a[e] = this.deserialize(t));
1449
+ if (i) for (let [e, t] of Object.entries(i)) {
1450
+ let n = a[e];
1451
+ typeof n == "string" && (a[e] = at(n, t));
1423
1452
  }
1424
- return z;
1453
+ return a;
1425
1454
  } };
1426
1455
  }
1427
- export { ACTION_HANDLER_FACTORY, ApiProvider, DEFAULT_COMMAND_MASK, HEADER_MARK_SELECTED_RANGE_ITEMS, HEADER_MASK, HEADER_SIGNED_IDENTIFIER, HEADER_TOKEN, JudoRestApi, SUFFIX_ADD, SUFFIX_CREATE, SUFFIX_DELETE, SUFFIX_EXPORT, SUFFIX_GET, SUFFIX_LIST, SUFFIX_RANGE, SUFFIX_REMOVE, SUFFIX_SET, SUFFIX_TEMPLATE, SUFFIX_UNSET, SUFFIX_UPDATE, SUFFIX_VALIDATE, ValidationError, createJudoRestApi, createModelAwareDeserializer, createModelAwareSerializer, deserializeTemporalValue, executeWithLifecycle, getActionHandler, getClassPath, getMutationRelationPath, getOperationPath, getPathForActor, getRelationPath, hasActionHandler, hasActionHandler$1 as hasActionHandlerRegistry, parseLocalDate, serializeTemporalValue, useActionDispatcher, useActionHandler, useAddActionHandler, useApi, useAutocompleteAddActionHandler, useAutocompleteRangeActionHandler, useAutocompleteSetActionHandler, useBackActionHandler, useBulkCallOperationActionHandler, useBulkDeleteActionHandler, useBulkRemoveActionHandler, useCallOperationActionHandler, useCancelActionHandler, useClearActionHandler, useCreateActionHandler, useCustomActionHandler, useDeleteActionHandler, useExportActionHandler, useFilterActionHandler, useFilterRelationActionHandler, useGetTemplateActionHandler, useInlineCreateRowActionHandler, useInputFormCallOperationActionHandler, useInputSelectorCallOperationActionHandler, useOpenAddSelectorActionHandler, useOpenCreateFormActionHandler, useOpenFormActionHandler, useOpenOperationInputFormActionHandler, useOpenOperationInputSelectorActionHandler, useOpenPageActionHandler, useOpenSelectorActionHandler, useOpenSetSelectorActionHandler, useParameterlessCallOperationActionHandler, usePreFetchActionHandler, useRefreshActionHandler, useRefreshRelationActionHandler, useRemoveActionHandler, useRowDeleteActionHandler, useRowOpenPageActionHandler, useSelectorRangeActionHandler, useSetActionHandler, useUnsetActionHandler, useUpdateActionHandler };
1456
+ //#endregion
1457
+ export { s as ACTION_HANDLER_FACTORY, xe as ApiProvider, Me as DEFAULT_COMMAND_MASK, ke as HEADER_MARK_SELECTED_RANGE_ITEMS, Oe as HEADER_MASK, W as HEADER_SIGNED_IDENTIFIER, je as HEADER_TOKEN, Xe as JudoRestApi, Be as SUFFIX_ADD, Le as SUFFIX_CREATE, Pe as SUFFIX_DELETE, He as SUFFIX_EXPORT, K as SUFFIX_GET, Fe as SUFFIX_LIST, Ie as SUFFIX_RANGE, Ve as SUFFIX_REMOVE, Re as SUFFIX_SET, G as SUFFIX_TEMPLATE, ze as SUFFIX_UNSET, Ne as SUFFIX_UPDATE, q as SUFFIX_VALIDATE, e as ValidationError, Ze as createJudoRestApi, ot as createModelAwareDeserializer, rt as createModelAwareSerializer, at as deserializeTemporalValue, Se as executeWithLifecycle, U as getActionHandler, Z as getClassPath, Q as getMutationRelationPath, $ as getOperationPath, Y as getPathForActor, X as getRelationPath, De as hasActionHandler, we as hasActionHandlerRegistry, it as parseLocalDate, nt as serializeTemporalValue, Te as useActionDispatcher, Ee as useActionHandler, de as useAddActionHandler, be as useApi, _e as useAutocompleteAddActionHandler, B as useAutocompleteRangeActionHandler, V as useAutocompleteSetActionHandler, c as useBackActionHandler, F as useBulkCallOperationActionHandler, oe as useBulkDeleteActionHandler, pe as useBulkRemoveActionHandler, P as useCallOperationActionHandler, d as useCancelActionHandler, w as useClearActionHandler, re as useCreateActionHandler, ve as useCustomActionHandler, ae as useDeleteActionHandler, O as useExportActionHandler, D as useFilterActionHandler, E as useFilterRelationActionHandler, ce as useGetTemplateActionHandler, k as useInlineCreateRowActionHandler, I as useInputFormCallOperationActionHandler, L as useInputSelectorCallOperationActionHandler, _ as useOpenAddSelectorActionHandler, p as useOpenCreateFormActionHandler, f as useOpenFormActionHandler, m as useOpenOperationInputFormActionHandler, y as useOpenOperationInputSelectorActionHandler, l as useOpenPageActionHandler, g as useOpenSelectorActionHandler, v as useOpenSetSelectorActionHandler, R as useParameterlessCallOperationActionHandler, H as usePreFetchActionHandler, S as useRefreshActionHandler, T as useRefreshRelationActionHandler, fe as useRemoveActionHandler, se as useRowDeleteActionHandler, u as useRowOpenPageActionHandler, ee as useSelectorRangeActionHandler, le as useSetActionHandler, ue as useUnsetActionHandler, ie as useUpdateActionHandler };