@ram_28/kf-ai-sdk 2.0.24 → 2.0.26
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/{FileField-DU4UWo_t.cjs → FileField-Btr_gdGt.cjs} +1 -1
- package/dist/{FileField-CZjS2uLh.js → FileField-DUnwFhXd.js} +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +2 -2
- package/dist/auth/authClient.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +2 -2
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +3 -3
- package/dist/{client-D5k4SYuw.cjs → client-B4tX3hPi.cjs} +1 -1
- package/dist/{client-_ayziI1d.js → client-DxWWVa0D.js} +8 -7
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts +12 -1
- package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -1
- package/dist/components/hooks/useBDOForm/useBDOForm.d.ts.map +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +260 -233
- package/dist/{metadata-DWXQPDav.cjs → metadata-C2JGyvqu.cjs} +1 -1
- package/dist/{metadata-Cc1mBcLS.js → metadata-D-6r1Eul.js} +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +3 -3
- package/docs/examples/fields/complex-fields.md +11 -14
- package/package.json +1 -1
- package/sdk/api/client.ts +9 -9
- package/sdk/auth/authClient.ts +2 -0
- package/sdk/components/hooks/useBDOForm/createItemProxy.ts +34 -5
- package/sdk/components/hooks/useBDOForm/useBDOForm.ts +42 -5
package/dist/form.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { F as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { v as
|
|
4
|
-
import { useQuery as
|
|
5
|
-
import { a as
|
|
6
|
-
import { v as
|
|
7
|
-
import { g as
|
|
8
|
-
function
|
|
9
|
-
const
|
|
1
|
+
import { F as Ve, I as Fe, V as Se } from "./constants-Cyi942Yr.js";
|
|
2
|
+
import { useMemo as x, useEffect as $, useRef as k, useCallback as G } from "react";
|
|
3
|
+
import { v as te, c as ae, a as ne, u as se, b as ie, d as re, e as le, f as H } from "./shared-5a7UkED1.js";
|
|
4
|
+
import { useQuery as Q } from "@tanstack/react-query";
|
|
5
|
+
import { a as f } from "./client-DxWWVa0D.js";
|
|
6
|
+
import { v as W, e as X } from "./attachment-constants-C2UHWxmp.js";
|
|
7
|
+
import { g as oe } from "./metadata-D-6r1Eul.js";
|
|
8
|
+
function ce(U, n, r, L) {
|
|
9
|
+
const N = U.getFields(), F = /* @__PURE__ */ new Map(), J = U.getBoId(), h = () => L === "create" ? "draft" : n.getValues("_id") || "draft";
|
|
10
10
|
return new Proxy({}, {
|
|
11
|
-
get(
|
|
11
|
+
get(B, e) {
|
|
12
12
|
if (typeof e == "symbol")
|
|
13
13
|
return;
|
|
14
14
|
if (e === "_id")
|
|
@@ -17,163 +17,170 @@ function re(v, n) {
|
|
|
17
17
|
return () => n.getValues();
|
|
18
18
|
if (e === "validate")
|
|
19
19
|
return () => n.trigger();
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
22
|
-
const i =
|
|
20
|
+
if (F.has(e))
|
|
21
|
+
return F.get(e);
|
|
22
|
+
const i = N[e], y = (i == null ? void 0 : i.meta) ?? {
|
|
23
23
|
_id: e,
|
|
24
24
|
Name: e,
|
|
25
25
|
Type: "String"
|
|
26
|
-
},
|
|
26
|
+
}, j = (i == null ? void 0 : i.readOnly) ?? !1, E = () => {
|
|
27
27
|
if (!i) return { valid: !0, errors: [] };
|
|
28
|
-
let
|
|
29
|
-
if ("integerPart" in i && typeof
|
|
30
|
-
const a = Number(
|
|
31
|
-
isNaN(a) || (
|
|
28
|
+
let c = n.getValues(e);
|
|
29
|
+
if ("integerPart" in i && typeof c == "string" && c !== "") {
|
|
30
|
+
const a = Number(c);
|
|
31
|
+
isNaN(a) || (c = a, n.setValue(e, a, { shouldDirty: !1 }));
|
|
32
32
|
}
|
|
33
|
-
if (!i.required && (
|
|
33
|
+
if (!i.required && (c == null || c === "" || Array.isArray(c) && c.length === 0))
|
|
34
34
|
return { valid: !0, errors: [] };
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
39
|
-
if (
|
|
40
|
-
const a =
|
|
35
|
+
const s = i.validate(c);
|
|
36
|
+
if (!s.valid) return s;
|
|
37
|
+
const t = te(i, c);
|
|
38
|
+
if (!t.valid) return t;
|
|
39
|
+
if (U.hasMetadata()) {
|
|
40
|
+
const a = U.validateFieldExpression(
|
|
41
41
|
e,
|
|
42
|
-
|
|
42
|
+
c,
|
|
43
43
|
n.getValues()
|
|
44
44
|
);
|
|
45
45
|
if (!a.valid) return a;
|
|
46
46
|
}
|
|
47
47
|
return { valid: !0, errors: [] };
|
|
48
|
-
},
|
|
49
|
-
const
|
|
50
|
-
return
|
|
48
|
+
}, M = (c) => {
|
|
49
|
+
const s = n.getValues(e);
|
|
50
|
+
return s ?? c;
|
|
51
51
|
};
|
|
52
|
-
if (!
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
},
|
|
52
|
+
if (!j) {
|
|
53
|
+
const c = () => {
|
|
54
|
+
const t = n.getValues(e);
|
|
55
|
+
return y.Type === "File" ? t ?? [] : t;
|
|
56
|
+
}, s = {
|
|
57
57
|
label: (i == null ? void 0 : i.label) ?? e,
|
|
58
58
|
required: (i == null ? void 0 : i.required) ?? !1,
|
|
59
59
|
readOnly: !1,
|
|
60
60
|
defaultValue: i == null ? void 0 : i.defaultValue,
|
|
61
|
-
meta:
|
|
62
|
-
get:
|
|
63
|
-
getOrDefault:
|
|
64
|
-
set: (
|
|
65
|
-
|
|
61
|
+
meta: y,
|
|
62
|
+
get: c,
|
|
63
|
+
getOrDefault: M,
|
|
64
|
+
set: (t) => {
|
|
65
|
+
var a, u, l;
|
|
66
|
+
n.setValue(e, t, {
|
|
66
67
|
shouldDirty: !0,
|
|
67
68
|
shouldTouch: !0,
|
|
68
69
|
shouldValidate: !1
|
|
69
70
|
// Let mode control validation timing
|
|
70
|
-
});
|
|
71
|
+
}), (l = (u = (a = r == null ? void 0 : r.syncFieldRef) == null ? void 0 : a.current) == null ? void 0 : u.call(a, e)) == null || l.catch(console.warn);
|
|
71
72
|
},
|
|
72
|
-
validate:
|
|
73
|
+
validate: E
|
|
73
74
|
};
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
if (y.Type === "Image" || y.Type === "File") {
|
|
76
|
+
const t = J;
|
|
77
|
+
y.Type === "Image" ? (s.upload = async (a) => {
|
|
78
|
+
var o, O, S;
|
|
79
|
+
W(a.name, "Image");
|
|
80
|
+
const u = h(), [l] = await f(t).getUploadUrl(u, e, [
|
|
81
|
+
{ FileName: a.name, Size: a.size, FileExtension: X(a.name) }
|
|
80
82
|
]);
|
|
81
|
-
await fetch(
|
|
83
|
+
await fetch(l.UploadUrl.URL, {
|
|
82
84
|
method: "PUT",
|
|
83
|
-
headers: { "Content-Type":
|
|
85
|
+
headers: { "Content-Type": l.ContentType },
|
|
84
86
|
body: a
|
|
85
87
|
});
|
|
86
|
-
const
|
|
87
|
-
_id:
|
|
88
|
-
_name:
|
|
89
|
-
FileName:
|
|
90
|
-
FileExtension:
|
|
91
|
-
Size:
|
|
92
|
-
ContentType:
|
|
88
|
+
const d = {
|
|
89
|
+
_id: l._id,
|
|
90
|
+
_name: l._name,
|
|
91
|
+
FileName: l.FileName,
|
|
92
|
+
FileExtension: l.FileExtension,
|
|
93
|
+
Size: l.Size,
|
|
94
|
+
ContentType: l.ContentType
|
|
93
95
|
};
|
|
94
|
-
return n.setValue(e,
|
|
95
|
-
},
|
|
96
|
-
|
|
96
|
+
return n.setValue(e, d, { shouldDirty: !0 }), (S = (O = (o = r == null ? void 0 : r.persistRef) == null ? void 0 : o.current) == null ? void 0 : O.call(o, e, d)) == null || S.catch(console.warn), d;
|
|
97
|
+
}, s.deleteAttachment = async () => {
|
|
98
|
+
var l, d, o;
|
|
99
|
+
const a = n.getValues(e), u = h();
|
|
97
100
|
if (!(a != null && a._id)) throw new Error(`${e} has no image to delete`);
|
|
98
|
-
await
|
|
99
|
-
},
|
|
100
|
-
const
|
|
101
|
-
if (!(
|
|
102
|
-
return
|
|
103
|
-
}) : (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
101
|
+
await f(t).deleteAttachment(u, e, a._id), n.setValue(e, null, { shouldDirty: !0 }), (o = (d = (l = r == null ? void 0 : r.persistRef) == null ? void 0 : l.current) == null ? void 0 : d.call(l, e, null)) == null || o.catch(console.warn);
|
|
102
|
+
}, s.getDownloadUrl = async (a) => {
|
|
103
|
+
const u = n.getValues(e), l = h();
|
|
104
|
+
if (!(u != null && u._id)) throw new Error(`${e} has no image`);
|
|
105
|
+
return f(t).getDownloadUrl(l, e, u._id, a);
|
|
106
|
+
}) : (s.upload = async (a) => {
|
|
107
|
+
var v, T, z;
|
|
108
|
+
for (const V of a) W(V.name, "File");
|
|
109
|
+
const u = h(), l = a.map((V) => ({
|
|
110
|
+
FileName: V.name,
|
|
111
|
+
Size: V.size,
|
|
112
|
+
FileExtension: X(V.name)
|
|
113
|
+
})), d = await f(t).getUploadUrl(u, e, l), o = await Promise.all(
|
|
114
|
+
a.map(async (V, _) => (await fetch(d[_].UploadUrl.URL, {
|
|
111
115
|
method: "PUT",
|
|
112
|
-
headers: { "Content-Type":
|
|
113
|
-
body:
|
|
116
|
+
headers: { "Content-Type": d[_].ContentType },
|
|
117
|
+
body: V
|
|
114
118
|
}), {
|
|
115
|
-
_id:
|
|
116
|
-
_name:
|
|
117
|
-
FileName:
|
|
118
|
-
FileExtension:
|
|
119
|
-
Size:
|
|
120
|
-
ContentType:
|
|
119
|
+
_id: d[_]._id,
|
|
120
|
+
_name: d[_]._name,
|
|
121
|
+
FileName: d[_].FileName,
|
|
122
|
+
FileExtension: d[_].FileExtension,
|
|
123
|
+
Size: d[_].Size,
|
|
124
|
+
ContentType: d[_].ContentType
|
|
121
125
|
}))
|
|
122
|
-
),
|
|
123
|
-
return n.setValue(e,
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
), S = [...n.getValues(e) ?? [], ...o];
|
|
127
|
+
return n.setValue(e, S, { shouldDirty: !0 }), (z = (T = (v = r == null ? void 0 : r.persistRef) == null ? void 0 : v.current) == null ? void 0 : T.call(v, e, S)) == null || z.catch(console.warn), o;
|
|
128
|
+
}, s.deleteAttachment = async (a) => {
|
|
129
|
+
var o, O, S;
|
|
130
|
+
const u = n.getValues(e) ?? [], l = h();
|
|
131
|
+
await f(t).deleteAttachment(l, e, a);
|
|
132
|
+
const d = u.filter((v) => v._id !== a);
|
|
133
|
+
n.setValue(
|
|
127
134
|
e,
|
|
128
|
-
|
|
135
|
+
d,
|
|
129
136
|
{ shouldDirty: !0 }
|
|
130
|
-
);
|
|
131
|
-
},
|
|
132
|
-
const
|
|
133
|
-
return
|
|
134
|
-
},
|
|
135
|
-
const
|
|
136
|
-
return
|
|
137
|
+
), (S = (O = (o = r == null ? void 0 : r.persistRef) == null ? void 0 : o.current) == null ? void 0 : O.call(o, e, d)) == null || S.catch(console.warn);
|
|
138
|
+
}, s.getDownloadUrl = async (a, u) => {
|
|
139
|
+
const l = h();
|
|
140
|
+
return f(t).getDownloadUrl(l, e, a, u);
|
|
141
|
+
}, s.getDownloadUrls = async (a) => {
|
|
142
|
+
const u = h();
|
|
143
|
+
return f(t).getDownloadUrls(u, e, a);
|
|
137
144
|
});
|
|
138
145
|
}
|
|
139
|
-
return
|
|
146
|
+
return F.set(e, s), s;
|
|
140
147
|
}
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
return
|
|
148
|
+
const m = () => {
|
|
149
|
+
const c = n.getValues(e);
|
|
150
|
+
return y.Type === "File" ? c ?? [] : c;
|
|
144
151
|
}, I = {
|
|
145
152
|
label: (i == null ? void 0 : i.label) ?? e,
|
|
146
153
|
required: (i == null ? void 0 : i.required) ?? !1,
|
|
147
154
|
readOnly: !0,
|
|
148
155
|
defaultValue: i == null ? void 0 : i.defaultValue,
|
|
149
|
-
meta:
|
|
150
|
-
get:
|
|
151
|
-
getOrDefault:
|
|
152
|
-
validate:
|
|
156
|
+
meta: y,
|
|
157
|
+
get: m,
|
|
158
|
+
getOrDefault: M,
|
|
159
|
+
validate: E
|
|
153
160
|
};
|
|
154
|
-
if (
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
if (!(
|
|
159
|
-
return
|
|
160
|
-
} : (I.getDownloadUrl = async (
|
|
161
|
-
const a =
|
|
162
|
-
return
|
|
163
|
-
}, I.getDownloadUrls = async (
|
|
164
|
-
const
|
|
165
|
-
return
|
|
161
|
+
if (y.Type === "Image" || y.Type === "File") {
|
|
162
|
+
const c = J;
|
|
163
|
+
y.Type === "Image" ? I.getDownloadUrl = async (s) => {
|
|
164
|
+
const t = n.getValues(e), a = h();
|
|
165
|
+
if (!(t != null && t._id)) throw new Error(`${e} has no image to download`);
|
|
166
|
+
return f(c).getDownloadUrl(a, e, t._id, s);
|
|
167
|
+
} : (I.getDownloadUrl = async (s, t) => {
|
|
168
|
+
const a = h();
|
|
169
|
+
return f(c).getDownloadUrl(a, e, s, t);
|
|
170
|
+
}, I.getDownloadUrls = async (s) => {
|
|
171
|
+
const t = h();
|
|
172
|
+
return f(c).getDownloadUrls(t, e, s);
|
|
166
173
|
});
|
|
167
174
|
}
|
|
168
|
-
return
|
|
175
|
+
return F.set(e, I), I;
|
|
169
176
|
},
|
|
170
|
-
has(
|
|
171
|
-
return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" ? !0 : e in
|
|
177
|
+
has(B, e) {
|
|
178
|
+
return typeof e == "symbol" ? !1 : e === "_id" || e === "toJSON" || e === "validate" ? !0 : e in N;
|
|
172
179
|
},
|
|
173
|
-
ownKeys(
|
|
174
|
-
return [...Object.keys(
|
|
180
|
+
ownKeys(B) {
|
|
181
|
+
return [...Object.keys(N), "_id", "toJSON", "validate"];
|
|
175
182
|
},
|
|
176
|
-
getOwnPropertyDescriptor(
|
|
183
|
+
getOwnPropertyDescriptor(B, e) {
|
|
177
184
|
if (typeof e != "symbol")
|
|
178
185
|
return {
|
|
179
186
|
configurable: !0,
|
|
@@ -182,155 +189,175 @@ function re(v, n) {
|
|
|
182
189
|
}
|
|
183
190
|
});
|
|
184
191
|
}
|
|
185
|
-
function
|
|
192
|
+
function he(U) {
|
|
186
193
|
const {
|
|
187
194
|
bdo: n,
|
|
188
|
-
recordId:
|
|
189
|
-
operation:
|
|
190
|
-
defaultValues:
|
|
191
|
-
mode:
|
|
192
|
-
enableDraft:
|
|
193
|
-
enableConstraintValidation:
|
|
194
|
-
enableExpressionValidation:
|
|
195
|
-
} =
|
|
196
|
-
() =>
|
|
197
|
-
[n,
|
|
195
|
+
recordId: r,
|
|
196
|
+
operation: L,
|
|
197
|
+
defaultValues: N,
|
|
198
|
+
mode: F = "onBlur",
|
|
199
|
+
enableDraft: J = !1,
|
|
200
|
+
enableConstraintValidation: h,
|
|
201
|
+
enableExpressionValidation: B
|
|
202
|
+
} = U, e = L ?? (r ? "update" : "create"), i = x(
|
|
203
|
+
() => ae(n, { enableConstraintValidation: h }),
|
|
204
|
+
[n, h]
|
|
198
205
|
), {
|
|
199
|
-
data:
|
|
200
|
-
isLoading:
|
|
201
|
-
isFetching:
|
|
202
|
-
error:
|
|
203
|
-
} =
|
|
204
|
-
queryKey: ["form-record", n.meta._id,
|
|
206
|
+
data: y,
|
|
207
|
+
isLoading: j,
|
|
208
|
+
isFetching: E,
|
|
209
|
+
error: M
|
|
210
|
+
} = Q({
|
|
211
|
+
queryKey: ["form-record", n.meta._id, r],
|
|
205
212
|
queryFn: async () => {
|
|
206
|
-
const
|
|
207
|
-
return
|
|
213
|
+
const g = await n.get(r);
|
|
214
|
+
return ne(n.getFields(), g.toJSON());
|
|
208
215
|
},
|
|
209
|
-
enabled:
|
|
216
|
+
enabled: e === "update" && !!r,
|
|
210
217
|
staleTime: 0
|
|
211
218
|
}), {
|
|
212
|
-
data:
|
|
213
|
-
isLoading:
|
|
214
|
-
error:
|
|
215
|
-
} =
|
|
219
|
+
data: m,
|
|
220
|
+
isLoading: I,
|
|
221
|
+
error: c
|
|
222
|
+
} = Q({
|
|
216
223
|
queryKey: ["form-draft", n.meta._id],
|
|
217
|
-
queryFn: async () =>
|
|
218
|
-
enabled:
|
|
224
|
+
queryFn: async () => f(n.meta._id).draftInteraction({}),
|
|
225
|
+
enabled: e === "create",
|
|
219
226
|
staleTime: 1 / 0,
|
|
220
227
|
gcTime: 0,
|
|
221
228
|
retry: 1
|
|
222
|
-
}), { data:
|
|
229
|
+
}), { data: s } = Q({
|
|
223
230
|
queryKey: ["form-schema", n.meta._id],
|
|
224
|
-
queryFn: () =>
|
|
231
|
+
queryFn: () => oe(n.meta._id),
|
|
225
232
|
staleTime: 30 * 60 * 1e3,
|
|
226
233
|
gcTime: 60 * 60 * 1e3,
|
|
227
|
-
enabled:
|
|
234
|
+
enabled: B !== !1
|
|
228
235
|
});
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}, [
|
|
232
|
-
const t =
|
|
233
|
-
mode:
|
|
234
|
-
resolver:
|
|
235
|
-
defaultValues:
|
|
236
|
+
$(() => {
|
|
237
|
+
s != null && s.BDOBlob ? n.loadMetadata(s.BDOBlob) : s != null && s.MetaBlob && n.loadMetadata(s.MetaBlob);
|
|
238
|
+
}, [s, n]);
|
|
239
|
+
const t = se({
|
|
240
|
+
mode: F,
|
|
241
|
+
resolver: i,
|
|
242
|
+
defaultValues: N
|
|
236
243
|
// NOTE: Don't use `values` prop — it continuously syncs and overrides
|
|
237
244
|
// setValue() calls for unregistered fields (Image/File attachments).
|
|
238
245
|
// Instead, we reset once when record arrives (see useEffect below).
|
|
239
|
-
}),
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
246
|
+
}), a = k(null);
|
|
247
|
+
$(() => {
|
|
248
|
+
var g;
|
|
249
|
+
if (e === "update" && y && y !== a.current) {
|
|
250
|
+
const w = a.current !== null && (y == null ? void 0 : y._id) === ((g = a.current) == null ? void 0 : g._id);
|
|
251
|
+
t.reset(y, w ? { keepDirtyValues: !0 } : void 0), a.current = y;
|
|
252
|
+
}
|
|
253
|
+
}, [y, e, t]), $(() => {
|
|
254
|
+
m != null && m._id && t.setValue("_id", m._id);
|
|
255
|
+
}, [m, t]);
|
|
256
|
+
const u = k(null), l = k(null), d = x(
|
|
257
|
+
() => ce(n, t, {
|
|
258
|
+
syncFieldRef: u,
|
|
259
|
+
persistRef: l
|
|
260
|
+
}, e),
|
|
261
|
+
[n, t, e]
|
|
262
|
+
), o = n.getFields(), O = k(!1), S = x(
|
|
263
|
+
() => Object.keys(o).filter((g) => o[g].readOnly),
|
|
264
|
+
[o]
|
|
265
|
+
), v = G(
|
|
266
|
+
async (g, w) => {
|
|
267
|
+
if (e === "create" && (m != null && m._id))
|
|
268
|
+
return f(n.meta._id).draftInteraction({
|
|
269
|
+
_id: m._id,
|
|
270
|
+
[g]: w
|
|
257
271
|
});
|
|
258
|
-
if (
|
|
259
|
-
return
|
|
260
|
-
[
|
|
272
|
+
if (e === "update" && r)
|
|
273
|
+
return f(n.meta._id).update(r, {
|
|
274
|
+
[g]: w
|
|
261
275
|
});
|
|
262
276
|
},
|
|
263
|
-
[
|
|
264
|
-
),
|
|
265
|
-
() =>
|
|
266
|
-
apiFn:
|
|
267
|
-
allFields:
|
|
268
|
-
readonlyFieldNames:
|
|
277
|
+
[e, m, r, n]
|
|
278
|
+
), T = x(
|
|
279
|
+
() => ie({
|
|
280
|
+
apiFn: v,
|
|
281
|
+
allFields: o,
|
|
282
|
+
readonlyFieldNames: S,
|
|
269
283
|
rhf: t,
|
|
270
|
-
isComputingRef:
|
|
284
|
+
isComputingRef: O
|
|
271
285
|
}),
|
|
272
|
-
[
|
|
273
|
-
)
|
|
274
|
-
|
|
286
|
+
[v, o, S, t]
|
|
287
|
+
);
|
|
288
|
+
u.current = T;
|
|
289
|
+
const z = G(
|
|
290
|
+
async (g, w) => {
|
|
291
|
+
try {
|
|
292
|
+
await v(g, w);
|
|
293
|
+
} catch (b) {
|
|
294
|
+
console.error("[useBDOForm] persistValue failed:", b);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
[v, e, r]
|
|
298
|
+
);
|
|
299
|
+
l.current = z;
|
|
300
|
+
const V = F === "onChange" || F === "all", _ = F === "onBlur" || F === "onTouched" || F === "all", Y = x(
|
|
301
|
+
() => re({
|
|
275
302
|
rhf: t,
|
|
276
|
-
allFields:
|
|
277
|
-
syncField:
|
|
278
|
-
syncOnBlur:
|
|
279
|
-
syncOnChange:
|
|
303
|
+
allFields: o,
|
|
304
|
+
syncField: T,
|
|
305
|
+
syncOnBlur: _,
|
|
306
|
+
syncOnChange: V
|
|
280
307
|
}),
|
|
281
|
-
[t,
|
|
282
|
-
),
|
|
283
|
-
() =>
|
|
308
|
+
[t, o, T, _, V]
|
|
309
|
+
), Z = x(
|
|
310
|
+
() => le({
|
|
284
311
|
control: t.control,
|
|
285
|
-
syncField:
|
|
286
|
-
syncOnBlur:
|
|
287
|
-
syncOnChange:
|
|
312
|
+
syncField: T,
|
|
313
|
+
syncOnBlur: _,
|
|
314
|
+
syncOnChange: V
|
|
288
315
|
}),
|
|
289
|
-
[t.control,
|
|
290
|
-
),
|
|
291
|
-
(
|
|
292
|
-
async (
|
|
316
|
+
[t.control, T, _, V]
|
|
317
|
+
), p = G(
|
|
318
|
+
(g, w) => t.handleSubmit(
|
|
319
|
+
async (b, A) => {
|
|
293
320
|
try {
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
for (const [
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
|
|
321
|
+
const R = {}, P = t.getValues();
|
|
322
|
+
if (e === "create")
|
|
323
|
+
for (const [C, D] of Object.entries(o)) {
|
|
324
|
+
if (D.readOnly) continue;
|
|
325
|
+
const q = P[C] !== void 0 ? P[C] : b[C];
|
|
326
|
+
q !== void 0 && (R[C] = H(D, q));
|
|
300
327
|
}
|
|
301
328
|
else {
|
|
302
|
-
const
|
|
303
|
-
for (const [
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
329
|
+
const C = t.formState.dirtyFields;
|
|
330
|
+
for (const [D, q] of Object.entries(o)) {
|
|
331
|
+
if (q.readOnly || !C[D]) continue;
|
|
332
|
+
const ee = P[D] !== void 0 ? P[D] : b[D];
|
|
333
|
+
R[D] = H(q, ee);
|
|
307
334
|
}
|
|
308
335
|
}
|
|
309
|
-
let
|
|
310
|
-
|
|
311
|
-
} catch (
|
|
312
|
-
|
|
336
|
+
let K;
|
|
337
|
+
e === "create" ? (R._id = m == null ? void 0 : m._id, K = await f(n.meta._id).draft(R)) : K = await f(n.meta._id).update(r, R), g == null || g(K, A);
|
|
338
|
+
} catch (R) {
|
|
339
|
+
w == null || w(R, A);
|
|
313
340
|
}
|
|
314
341
|
},
|
|
315
|
-
(
|
|
316
|
-
|
|
342
|
+
(b, A) => {
|
|
343
|
+
w == null || w(b, A);
|
|
317
344
|
}
|
|
318
345
|
),
|
|
319
|
-
[t, n,
|
|
346
|
+
[t, n, e, r, o, m]
|
|
320
347
|
);
|
|
321
348
|
return {
|
|
322
|
-
item:
|
|
349
|
+
item: d,
|
|
323
350
|
bdo: n,
|
|
324
|
-
operation:
|
|
325
|
-
recordId:
|
|
326
|
-
register:
|
|
327
|
-
handleSubmit:
|
|
351
|
+
operation: e,
|
|
352
|
+
recordId: r,
|
|
353
|
+
register: Y,
|
|
354
|
+
handleSubmit: p,
|
|
328
355
|
watch: t.watch,
|
|
329
356
|
setValue: t.setValue,
|
|
330
357
|
getValues: t.getValues,
|
|
331
358
|
reset: t.reset,
|
|
332
359
|
trigger: t.trigger,
|
|
333
|
-
control:
|
|
360
|
+
control: Z,
|
|
334
361
|
formState: t.formState,
|
|
335
362
|
errors: t.formState.errors,
|
|
336
363
|
isDirty: t.formState.isDirty,
|
|
@@ -338,16 +365,16 @@ function fe(v) {
|
|
|
338
365
|
isSubmitting: t.formState.isSubmitting,
|
|
339
366
|
isSubmitSuccessful: t.formState.isSubmitSuccessful,
|
|
340
367
|
dirtyFields: t.formState.dirtyFields,
|
|
341
|
-
isLoading:
|
|
342
|
-
isFetching:
|
|
343
|
-
loadError:
|
|
344
|
-
draftId:
|
|
345
|
-
isCreatingDraft:
|
|
368
|
+
isLoading: j || I,
|
|
369
|
+
isFetching: E,
|
|
370
|
+
loadError: M ?? c,
|
|
371
|
+
draftId: m == null ? void 0 : m._id,
|
|
372
|
+
isCreatingDraft: I
|
|
346
373
|
};
|
|
347
374
|
}
|
|
348
375
|
export {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
376
|
+
Ve as FormOperation,
|
|
377
|
+
Fe as InteractionMode,
|
|
378
|
+
Se as ValidationMode,
|
|
379
|
+
he as useBDOForm
|
|
353
380
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./client-
|
|
1
|
+
"use strict";const o=require("./client-B4tX3hPi.cjs");async function c(e){try{const r=o.getApiBaseUrl(),s=o.getDefaultHeaders(),a=await fetch(`${r}/api/app/meta/bdo/${e}`,{method:"GET",headers:s});if(!a.ok)throw new Error(`Failed to fetch schema for ${e}: ${a.statusText}`);const t=await a.json();if(!t||typeof t!="object")throw new Error(`Invalid BDO schema response for ${e}`);return t}catch(r){throw console.error(`Schema fetch error for ${e}:`,r),new Error(`Failed to load BDO schema: ${r instanceof Error?r.message:"Unknown error"}`)}}async function n(e){try{const r=o.getApiBaseUrl(),s=o.getDefaultHeaders(),a=e!=null&&e.Filter||e!=null&&e.Sort?"POST":"GET",t=await fetch(`${r}/api/app/metadata/list`,{method:a,headers:s,...a==="POST"&&e&&{body:JSON.stringify(e)}});if(!t.ok)throw new Error(`Failed to list metadata: ${t.statusText}`);return await t.json()}catch(r){throw console.error("Metadata list error:",r),new Error(`Failed to list metadata: ${r instanceof Error?r.message:"Unknown error"}`)}}exports.getBdoSchema=c;exports.listMetadata=n;
|