@ram_28/kf-ai-sdk 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/api.mjs +1 -1
  2. package/dist/auth.mjs +1 -1
  3. package/dist/bdo/core/Item.d.ts.map +1 -1
  4. package/dist/bdo/core/types.d.ts +1 -0
  5. package/dist/bdo/core/types.d.ts.map +1 -1
  6. package/dist/bdo.cjs +1 -1
  7. package/dist/bdo.mjs +91 -86
  8. package/dist/components/hooks/useForm/createItemProxy.d.ts.map +1 -1
  9. package/dist/components/hooks/useForm/index.d.ts +1 -1
  10. package/dist/components/hooks/useForm/index.d.ts.map +1 -1
  11. package/dist/components/hooks/useForm/types.d.ts +6 -16
  12. package/dist/components/hooks/useForm/types.d.ts.map +1 -1
  13. package/dist/components/hooks/useForm/useForm.d.ts +0 -1
  14. package/dist/components/hooks/useForm/useForm.d.ts.map +1 -1
  15. package/dist/components/hooks/useTable/types.d.ts +2 -2
  16. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  17. package/dist/{constants-BQrBcCON.js → constants-CYJih7y4.js} +2 -2
  18. package/dist/filter.mjs +1 -1
  19. package/dist/form.cjs +1 -1
  20. package/dist/form.mjs +158 -283
  21. package/dist/form.types.d.ts +1 -1
  22. package/dist/form.types.d.ts.map +1 -1
  23. package/dist/table.cjs +1 -1
  24. package/dist/table.mjs +65 -65
  25. package/dist/types/constants.d.ts +11 -11
  26. package/dist/types/constants.d.ts.map +1 -1
  27. package/dist/utils/api/buildListOptions.d.ts +1 -1
  28. package/dist/utils/api/buildListOptions.d.ts.map +1 -1
  29. package/dist/workflow/Activity.d.ts +14 -5
  30. package/dist/workflow/Activity.d.ts.map +1 -1
  31. package/dist/workflow/ActivityInstance.d.ts +1 -1
  32. package/dist/workflow/ActivityInstance.d.ts.map +1 -1
  33. package/dist/workflow/client.d.ts +14 -4
  34. package/dist/workflow/client.d.ts.map +1 -1
  35. package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +1 -1
  36. package/dist/workflow/types.d.ts +26 -9
  37. package/dist/workflow/types.d.ts.map +1 -1
  38. package/dist/workflow.cjs +1 -1
  39. package/dist/workflow.mjs +296 -240
  40. package/docs/bdo.md +63 -0
  41. package/docs/useAuth.md +27 -0
  42. package/docs/useFilter.md +67 -0
  43. package/docs/useForm.md +59 -0
  44. package/docs/useTable.md +106 -13
  45. package/docs/workflow.md +93 -49
  46. package/package.json +2 -2
  47. package/sdk/bdo/core/Item.ts +8 -0
  48. package/sdk/bdo/core/types.ts +1 -0
  49. package/sdk/components/hooks/useForm/createItemProxy.ts +8 -0
  50. package/sdk/components/hooks/useForm/index.ts +0 -1
  51. package/sdk/components/hooks/useForm/types.ts +7 -18
  52. package/sdk/components/hooks/useForm/useForm.ts +23 -109
  53. package/sdk/components/hooks/useTable/types.ts +2 -2
  54. package/sdk/components/hooks/useTable/useTable.llm.txt +7 -7
  55. package/sdk/components/hooks/useTable/useTable.ts +9 -8
  56. package/sdk/form.types.ts +0 -1
  57. package/sdk/types/constants.ts +11 -11
  58. package/sdk/utils/api/buildListOptions.ts +2 -3
  59. package/sdk/workflow/Activity.ts +31 -10
  60. package/sdk/workflow/ActivityInstance.ts +1 -1
  61. package/sdk/workflow/client.ts +73 -10
  62. package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +4 -0
  63. package/sdk/workflow/types.ts +22 -9
  64. package/dist/components/hooks/useForm/useDraftInteraction.d.ts +0 -26
  65. package/dist/components/hooks/useForm/useDraftInteraction.d.ts.map +0 -1
  66. package/sdk/components/hooks/useForm/useDraftInteraction.ts +0 -251
package/dist/workflow.mjs CHANGED
@@ -1,134 +1,176 @@
1
- var K = Object.defineProperty;
2
- var p = (c, s, e) => s in c ? K(c, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[s] = e;
3
- var O = (c, s, e) => p(c, typeof s != "symbol" ? s + "" : s, e);
4
- import { c as w, g as v } from "./client-BULEEaCP.js";
5
- import { B as D } from "./BaseField-B6da88U7.js";
6
- import { useState as k, useRef as q, useMemo as j, useEffect as U, useCallback as N } from "react";
1
+ var G = Object.defineProperty;
2
+ var H = (o, e, r) => e in o ? G(o, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[e] = r;
3
+ var $ = (o, e, r) => H(o, typeof e != "symbol" ? e + "" : e, r);
4
+ import { c as y, g } from "./client-BULEEaCP.js";
5
+ import { B as K } from "./BaseField-B6da88U7.js";
6
+ import { useState as k, useRef as q, useMemo as p, useEffect as U, useCallback as j } from "react";
7
7
  import { u as W } from "./index.esm-Cj63v5ny.js";
8
- import { t as B } from "./error-handling-CrhTtD88.js";
8
+ import { t as J } from "./error-handling-CrhTtD88.js";
9
9
  class z {
10
- constructor(s) {
11
- O(this, "bp_id");
12
- this.bp_id = s;
10
+ constructor(e) {
11
+ $(this, "bp_id");
12
+ this.bp_id = e;
13
13
  }
14
14
  /**
15
15
  * Start a new workflow instance
16
16
  */
17
17
  async start() {
18
- const s = await fetch(
19
- `${w()}/api/app/process/${this.bp_id}/start`,
18
+ const e = await fetch(
19
+ `${y()}/api/app/process/${this.bp_id}/start`,
20
20
  {
21
21
  method: "POST",
22
- headers: v()
22
+ headers: g()
23
23
  }
24
24
  );
25
- if (!s.ok)
26
- throw new Error(`Failed to start process: ${s.statusText}`);
27
- return s.json();
25
+ if (!e.ok)
26
+ throw new Error(`Failed to start process: ${e.statusText}`);
27
+ return e.json();
28
+ }
29
+ /**
30
+ * Get global progress across the entire business process.
31
+ * Returns a list of progress entries for each stage/activity.
32
+ */
33
+ async progress() {
34
+ const e = await fetch(
35
+ `${y()}/api/app/process/${this.bp_id}/progress`,
36
+ {
37
+ method: "GET",
38
+ headers: g()
39
+ }
40
+ );
41
+ if (!e.ok)
42
+ throw new Error(`Failed to get process progress: ${e.statusText}`);
43
+ return e.json();
28
44
  }
29
45
  /**
30
46
  * Get all operations for a specific activity
31
47
  * @param activity_id - Activity identifier
32
48
  */
33
- activity(s) {
34
- const e = `/api/app/process/${this.bp_id}/${s}`;
49
+ activity(e) {
50
+ const r = `/api/app/process/${this.bp_id}/${e}`;
35
51
  return {
36
52
  // ── List-level ────────────────────────────────────────────
37
- async list(i) {
38
- const a = {
53
+ async inProgressList(i) {
54
+ const s = {
55
+ Type: "List",
56
+ ...i
57
+ }, t = await fetch(`${y()}${r}/inprogress/list`, {
58
+ method: "POST",
59
+ headers: g(),
60
+ body: JSON.stringify(s)
61
+ });
62
+ if (!t.ok)
63
+ throw new Error(`Failed to list in-progress activities: ${t.statusText}`);
64
+ return t.json();
65
+ },
66
+ async completedList(i) {
67
+ const s = {
39
68
  Type: "List",
40
69
  ...i
41
- }, t = await fetch(`${w()}${e}/list`, {
70
+ }, t = await fetch(`${y()}${r}/completed/list`, {
42
71
  method: "POST",
43
- headers: v(),
44
- body: JSON.stringify(a)
72
+ headers: g(),
73
+ body: JSON.stringify(s)
45
74
  });
46
75
  if (!t.ok)
47
- throw new Error(`Failed to list activities: ${t.statusText}`);
76
+ throw new Error(`Failed to list completed activities: ${t.statusText}`);
48
77
  return t.json();
49
78
  },
50
- async metric(i) {
51
- const a = {
79
+ async inProgressMetric(i) {
80
+ const s = {
52
81
  Type: "Metric",
53
82
  ...i
54
- }, t = await fetch(`${w()}${e}/metric`, {
83
+ }, t = await fetch(`${y()}${r}/inprogress/metric`, {
55
84
  method: "POST",
56
- headers: v(),
57
- body: JSON.stringify(a)
85
+ headers: g(),
86
+ body: JSON.stringify(s)
58
87
  });
59
88
  if (!t.ok)
60
- throw new Error(`Failed to get activity metrics: ${t.statusText}`);
89
+ throw new Error(`Failed to get in-progress activity metrics: ${t.statusText}`);
90
+ return t.json();
91
+ },
92
+ async completedMetric(i) {
93
+ const s = {
94
+ Type: "Metric",
95
+ ...i
96
+ }, t = await fetch(`${y()}${r}/completed/metric`, {
97
+ method: "POST",
98
+ headers: g(),
99
+ body: JSON.stringify(s)
100
+ });
101
+ if (!t.ok)
102
+ throw new Error(`Failed to get completed activity metrics: ${t.statusText}`);
61
103
  return t.json();
62
104
  },
63
105
  // ── Instance-level ────────────────────────────────────────
64
106
  async read(i) {
65
- const a = await fetch(`${w()}${e}/${i}/read`, {
107
+ const s = await fetch(`${y()}${r}/${i}/read`, {
66
108
  method: "GET",
67
- headers: v()
109
+ headers: g()
68
110
  });
69
- if (!a.ok)
70
- throw new Error(`Failed to read activity: ${a.statusText}`);
71
- return (await a.json()).Data;
111
+ if (!s.ok)
112
+ throw new Error(`Failed to read activity: ${s.statusText}`);
113
+ return (await s.json()).Data;
72
114
  },
73
- async update(i, a) {
74
- const t = await fetch(`${w()}${e}/${i}/update`, {
115
+ async update(i, s) {
116
+ const t = await fetch(`${y()}${r}/${i}/update`, {
75
117
  method: "POST",
76
- headers: v(),
77
- body: JSON.stringify(a)
118
+ headers: g(),
119
+ body: JSON.stringify(s)
78
120
  });
79
121
  if (!t.ok)
80
122
  throw new Error(`Failed to update activity: ${t.statusText}`);
81
123
  return t.json();
82
124
  },
83
- async draftStart(i, a) {
84
- const t = await fetch(`${w()}${e}/${i}/draft`, {
125
+ async draftStart(i, s) {
126
+ const t = await fetch(`${y()}${r}/${i}/draft`, {
85
127
  method: "PATCH",
86
- headers: v(),
87
- body: JSON.stringify(a)
128
+ headers: g(),
129
+ body: JSON.stringify(s)
88
130
  });
89
131
  if (!t.ok)
90
132
  throw new Error(`Failed to start draft: ${t.statusText}`);
91
133
  return t.json();
92
134
  },
93
- async draftEnd(i, a) {
94
- const t = await fetch(`${w()}${e}/${i}/draft`, {
135
+ async draftEnd(i, s) {
136
+ const t = await fetch(`${y()}${r}/${i}/draft`, {
95
137
  method: "POST",
96
- headers: v(),
97
- body: JSON.stringify(a)
138
+ headers: g(),
139
+ body: JSON.stringify(s)
98
140
  });
99
141
  if (!t.ok)
100
142
  throw new Error(`Failed to end draft: ${t.statusText}`);
101
143
  return t.json();
102
144
  },
103
145
  async complete(i) {
104
- const a = await fetch(`${w()}${e}/${i}/done`, {
146
+ const s = await fetch(`${y()}${r}/${i}/done`, {
105
147
  method: "POST",
106
- headers: v()
148
+ headers: g()
107
149
  });
108
- if (!a.ok)
109
- throw new Error(`Failed to complete activity: ${a.statusText}`);
110
- return a.json();
150
+ if (!s.ok)
151
+ throw new Error(`Failed to complete activity: ${s.statusText}`);
152
+ return s.json();
111
153
  },
112
154
  async progress(i) {
113
- const a = await fetch(`${w()}${e}/${i}/progress`, {
155
+ const s = await fetch(`${y()}${r}/${i}/progress`, {
114
156
  method: "GET",
115
- headers: v()
157
+ headers: g()
116
158
  });
117
- if (!a.ok)
118
- throw new Error(`Failed to get activity progress: ${a.statusText}`);
119
- return a.json();
159
+ if (!s.ok)
160
+ throw new Error(`Failed to get activity progress: ${s.statusText}`);
161
+ return s.json();
120
162
  }
121
163
  };
122
164
  }
123
165
  }
124
166
  class Q {
125
- constructor(s, e, i, a) {
126
- O(this, "_id");
127
- O(this, "_data");
128
- O(this, "_ops");
129
- O(this, "_fields");
130
- O(this, "_accessorCache", /* @__PURE__ */ new Map());
131
- this._ops = s, this._id = e, this._data = { ...i }, this._fields = a;
167
+ constructor(e, r, i, s) {
168
+ $(this, "_id");
169
+ $(this, "_data");
170
+ $(this, "_ops");
171
+ $(this, "_fields");
172
+ $(this, "_accessorCache", /* @__PURE__ */ new Map());
173
+ this._ops = e, this._id = r, this._data = { ...i }, this._fields = s;
132
174
  }
133
175
  // ============================================================
134
176
  // BDO ITEM METHODS
@@ -143,14 +185,14 @@ class Q {
143
185
  * Validate all fields and return combined results
144
186
  */
145
187
  validate() {
146
- const s = [];
147
- for (const [e, i] of Object.entries(this._fields)) {
148
- const a = this._data[e], t = i.validate(a);
149
- t.valid || s.push(...t.errors);
188
+ const e = [];
189
+ for (const [r, i] of Object.entries(this._fields)) {
190
+ const s = this._data[r], t = i.validate(s);
191
+ t.valid || e.push(...t.errors);
150
192
  }
151
193
  return {
152
- valid: s.length === 0,
153
- errors: s
194
+ valid: e.length === 0,
195
+ errors: e
154
196
  };
155
197
  }
156
198
  // ============================================================
@@ -159,14 +201,14 @@ class Q {
159
201
  /**
160
202
  * Regular update — calls ActivityOperations.update()
161
203
  */
162
- async update(s) {
163
- return this._ops.update(this._id, s);
204
+ async update(e) {
205
+ return this._ops.update(this._id, e);
164
206
  }
165
207
  /**
166
208
  * Commit draft — calls ActivityOperations.draftEnd()
167
209
  */
168
- async save(s) {
169
- return this._ops.draftEnd(this._id, s);
210
+ async save(e) {
211
+ return this._ops.draftEnd(this._id, e);
170
212
  }
171
213
  /**
172
214
  * Complete the activity — calls ActivityOperations.complete()
@@ -184,50 +226,50 @@ class Q {
184
226
  // FIELD ACCESSOR (internal)
185
227
  // ============================================================
186
228
  /** @internal */
187
- _getAccessor(s) {
188
- if (this._accessorCache.has(s))
189
- return this._accessorCache.get(s);
190
- const e = this._fields[s], i = (e == null ? void 0 : e.meta) ?? {
191
- _id: s,
192
- Name: s,
229
+ _getAccessor(e) {
230
+ if (this._accessorCache.has(e))
231
+ return this._accessorCache.get(e);
232
+ const r = this._fields[e], i = (r == null ? void 0 : r.meta) ?? {
233
+ _id: e,
234
+ Name: e,
193
235
  Type: "String"
194
- }, a = (e == null ? void 0 : e.readOnly) ?? !1, t = () => e ? e.validate(this._data[s]) : { valid: !0, errors: [] };
195
- let r;
196
- return a ? r = {
197
- label: (e == null ? void 0 : e.label) ?? s,
198
- required: (e == null ? void 0 : e.required) ?? !1,
236
+ }, s = (r == null ? void 0 : r.readOnly) ?? !1, t = () => r ? r.validate(this._data[e]) : { valid: !0, errors: [] };
237
+ let a;
238
+ return s ? a = {
239
+ label: (r == null ? void 0 : r.label) ?? e,
240
+ required: (r == null ? void 0 : r.required) ?? !1,
199
241
  readOnly: !0,
200
- defaultValue: e == null ? void 0 : e.defaultValue,
242
+ defaultValue: r == null ? void 0 : r.defaultValue,
201
243
  meta: i,
202
- get: () => this._data[s],
244
+ get: () => this._data[e],
203
245
  validate: t
204
- } : r = {
205
- label: (e == null ? void 0 : e.label) ?? s,
206
- required: (e == null ? void 0 : e.required) ?? !1,
246
+ } : a = {
247
+ label: (r == null ? void 0 : r.label) ?? e,
248
+ required: (r == null ? void 0 : r.required) ?? !1,
207
249
  readOnly: !1,
208
- defaultValue: e == null ? void 0 : e.defaultValue,
250
+ defaultValue: r == null ? void 0 : r.defaultValue,
209
251
  meta: i,
210
- get: () => this._data[s],
252
+ get: () => this._data[e],
211
253
  set: (f) => {
212
- this._data[s] = f;
254
+ this._data[e] = f;
213
255
  },
214
256
  validate: t
215
- }, this._accessorCache.set(s, r), r;
257
+ }, this._accessorCache.set(e, a), a;
216
258
  }
217
259
  }
218
- function X(c, s, e, i) {
219
- const a = new Q(
220
- c,
221
- s,
260
+ function X(o, e, r, i) {
261
+ const s = new Q(
262
+ o,
222
263
  e,
264
+ r,
223
265
  i
224
266
  );
225
- return new Proxy(a, {
226
- get(t, r, f) {
227
- return r === "validate" || r === "toJSON" || r === "update" || r === "save" || r === "complete" || r === "progress" || r === "_ops" || r === "_data" || r === "_fields" || r === "_accessorCache" || r === "_getAccessor" || typeof r == "symbol" ? Reflect.get(t, r, f) : r === "_id" ? t._id : t._getAccessor(r);
267
+ return new Proxy(s, {
268
+ get(t, a, f) {
269
+ return a === "validate" || a === "toJSON" || a === "update" || a === "save" || a === "complete" || a === "progress" || a === "_ops" || a === "_data" || a === "_fields" || a === "_accessorCache" || a === "_getAccessor" || typeof a == "symbol" ? Reflect.get(t, a, f) : a === "_id" ? t._id : t._getAccessor(a);
228
270
  },
229
- has(t, r) {
230
- return typeof r == "symbol" ? !1 : r === "validate" || r === "toJSON" || r === "update" || r === "save" || r === "complete" || r === "progress" || r === "_id" ? !0 : r in t._fields;
271
+ has(t, a) {
272
+ return typeof a == "symbol" ? !1 : a === "validate" || a === "toJSON" || a === "update" || a === "save" || a === "complete" || a === "progress" || a === "_id" ? !0 : a in t._fields;
231
273
  },
232
274
  ownKeys(t) {
233
275
  return [
@@ -241,21 +283,21 @@ function X(c, s, e, i) {
241
283
  "progress"
242
284
  ];
243
285
  },
244
- getOwnPropertyDescriptor(t, r) {
245
- if (typeof r != "symbol")
286
+ getOwnPropertyDescriptor(t, a) {
287
+ if (typeof a != "symbol")
246
288
  return {
247
289
  configurable: !0,
248
- enumerable: r !== "validate" && r !== "toJSON" && r !== "update" && r !== "save" && r !== "complete" && r !== "progress"
290
+ enumerable: a !== "validate" && a !== "toJSON" && a !== "update" && a !== "save" && a !== "complete" && a !== "progress"
249
291
  };
250
292
  }
251
293
  });
252
294
  }
253
- class ct {
295
+ class ot {
254
296
  constructor() {
255
297
  // ============================================================
256
298
  // FIELD DISCOVERY (internal)
257
299
  // ============================================================
258
- O(this, "_fieldsCache", null);
300
+ $(this, "_fieldsCache", null);
259
301
  }
260
302
  // ============================================================
261
303
  // ACTIVITY OPERATIONS (internal)
@@ -273,27 +315,39 @@ class ct {
273
315
  */
274
316
  _discoverFields() {
275
317
  if (this._fieldsCache) return this._fieldsCache;
276
- const s = {};
277
- for (const e of Object.keys(this)) {
278
- const i = this[e];
279
- i instanceof D && (s[e] = i);
318
+ const e = {};
319
+ for (const r of Object.keys(this)) {
320
+ const i = this[r];
321
+ i instanceof K && (e[r] = i);
280
322
  }
281
- return this._fieldsCache = s, s;
323
+ return this._fieldsCache = e, e;
282
324
  }
283
325
  // ============================================================
284
326
  // PUBLIC METHODS
285
327
  // ============================================================
286
328
  /**
287
- * List activity instances with optional filtering/pagination.
329
+ * List in-progress activity instances with optional filtering/pagination.
330
+ */
331
+ async getInProgressList(e) {
332
+ return this._ops().inProgressList(e);
333
+ }
334
+ /**
335
+ * List completed activity instances with optional filtering/pagination.
336
+ */
337
+ async getCompletedList(e) {
338
+ return this._ops().completedList(e);
339
+ }
340
+ /**
341
+ * Get aggregated metrics for in-progress activity instances.
288
342
  */
289
- async getInstanceList(s) {
290
- return this._ops().list(s);
343
+ async inProgressMetrics(e) {
344
+ return this._ops().inProgressMetric(e);
291
345
  }
292
346
  /**
293
- * Get aggregated metrics for activity instances.
347
+ * Get aggregated metrics for completed activity instances.
294
348
  */
295
- async instanceMetrics(s) {
296
- return this._ops().metric(s);
349
+ async completedMetrics(e) {
350
+ return this._ops().completedMetric(e);
297
351
  }
298
352
  /**
299
353
  * Get a typed ActivityInstance with field accessors and persistence methods.
@@ -301,13 +355,13 @@ class ct {
301
355
  * @param instanceId - The activity instance identifier
302
356
  * @returns ActivityInstance with typed field accessors
303
357
  */
304
- async getInstance(s) {
305
- const e = this._ops(), i = await e.read(s), a = this._discoverFields();
358
+ async getInstance(e) {
359
+ const r = this._ops(), i = await r.read(e), s = this._discoverFields();
306
360
  return X(
361
+ r,
307
362
  e,
308
- s,
309
363
  i,
310
- a
364
+ s
311
365
  );
312
366
  }
313
367
  // ============================================================
@@ -328,215 +382,217 @@ class ct {
328
382
  return this._ops();
329
383
  }
330
384
  }
331
- function Y(c) {
332
- return async (s, e, i) => {
333
- const a = {}, t = c._getFields(), r = (i == null ? void 0 : i.names) ?? Object.keys(t);
334
- for (const f of r) {
335
- const m = t[f];
336
- if (!m || m.readOnly) continue;
337
- const $ = s[f], S = m.validate($);
338
- !S.valid && S.errors.length > 0 && (a[f] = {
385
+ function Y(o) {
386
+ return async (e, r, i) => {
387
+ const s = {}, t = o._getFields(), a = (i == null ? void 0 : i.names) ?? Object.keys(t);
388
+ for (const f of a) {
389
+ const w = t[f];
390
+ if (!w || w.readOnly) continue;
391
+ const b = e[f], v = w.validate(b);
392
+ !v.valid && v.errors.length > 0 && (s[f] = {
339
393
  type: "validate",
340
- message: S.errors[0] || `${f} is invalid`
394
+ message: v.errors[0] || `${f} is invalid`
341
395
  });
342
396
  }
343
- return Object.keys(a).length === 0 ? { values: s, errors: {} } : { values: {}, errors: a };
397
+ return Object.keys(s).length === 0 ? { values: e, errors: {} } : { values: {}, errors: s };
344
398
  };
345
399
  }
346
- function Z(c, s) {
347
- const e = c._getFields();
400
+ function Z(o, e) {
401
+ const r = o._getFields();
348
402
  return new Proxy(
349
403
  {},
350
404
  {
351
- get(i, a) {
352
- if (typeof a == "symbol")
405
+ get(i, s) {
406
+ if (typeof s == "symbol")
353
407
  return;
354
- if (a === "toJSON")
355
- return () => s.getValues();
356
- if (a === "validate")
357
- return () => s.trigger();
358
- const t = e[a], r = (t == null ? void 0 : t.meta) ?? {
359
- _id: a,
360
- Name: a,
408
+ if (s === "toJSON")
409
+ return () => e.getValues();
410
+ if (s === "validate")
411
+ return () => e.trigger();
412
+ const t = r[s], a = (t == null ? void 0 : t.meta) ?? {
413
+ _id: s,
414
+ Name: s,
361
415
  Type: "String"
362
- }, f = (t == null ? void 0 : t.readOnly) ?? !1, m = () => t ? t.validate(s.getValues(a)) : { valid: !0, errors: [] };
416
+ }, f = (t == null ? void 0 : t.readOnly) ?? !1, w = () => t ? t.validate(e.getValues(s)) : { valid: !0, errors: [] };
363
417
  return f ? {
364
- label: (t == null ? void 0 : t.label) ?? a,
418
+ label: (t == null ? void 0 : t.label) ?? s,
365
419
  required: (t == null ? void 0 : t.required) ?? !1,
366
420
  readOnly: !0,
367
421
  defaultValue: t == null ? void 0 : t.defaultValue,
368
- meta: r,
369
- get: () => s.getValues(a),
370
- validate: m
422
+ meta: a,
423
+ get: () => e.getValues(s),
424
+ getOrDefault: (v) => e.getValues(s) ?? v,
425
+ validate: w
371
426
  } : {
372
- label: (t == null ? void 0 : t.label) ?? a,
427
+ label: (t == null ? void 0 : t.label) ?? s,
373
428
  required: (t == null ? void 0 : t.required) ?? !1,
374
429
  readOnly: !1,
375
430
  defaultValue: t == null ? void 0 : t.defaultValue,
376
- meta: r,
377
- get: () => s.getValues(a),
378
- set: (b) => {
379
- s.setValue(a, b, {
431
+ meta: a,
432
+ get: () => e.getValues(s),
433
+ getOrDefault: (S) => e.getValues(s) ?? S,
434
+ set: (S) => {
435
+ e.setValue(s, S, {
380
436
  shouldDirty: !0,
381
437
  shouldTouch: !0,
382
438
  shouldValidate: !1
383
439
  });
384
440
  },
385
- validate: m
441
+ validate: w
386
442
  };
387
443
  },
388
- has(i, a) {
389
- return typeof a == "symbol" ? !1 : a === "toJSON" || a === "validate" ? !0 : a in e;
444
+ has(i, s) {
445
+ return typeof s == "symbol" ? !1 : s === "toJSON" || s === "validate" ? !0 : s in r;
390
446
  },
391
447
  ownKeys(i) {
392
- return [...Object.keys(e), "toJSON", "validate"];
448
+ return [...Object.keys(r), "toJSON", "validate"];
393
449
  },
394
- getOwnPropertyDescriptor(i, a) {
395
- if (typeof a != "symbol")
450
+ getOwnPropertyDescriptor(i, s) {
451
+ if (typeof s != "symbol")
396
452
  return {
397
453
  configurable: !0,
398
- enumerable: a !== "toJSON" && a !== "validate"
454
+ enumerable: s !== "toJSON" && s !== "validate"
399
455
  };
400
456
  }
401
457
  }
402
458
  );
403
459
  }
404
- function ot(c, s) {
460
+ function ct(o, e) {
405
461
  const {
406
- activity_instance_id: e,
462
+ activity_instance_id: r,
407
463
  defaultValues: i = {},
408
- mode: a = "onBlur",
464
+ mode: s = "onBlur",
409
465
  enabled: t = !0
410
- } = s, [r, f] = k(!1), [m, $] = k(null), [S, b] = k(!1), x = q(!1), C = q(null), T = j(
411
- () => c._getFields(),
412
- [c]
413
- ), V = j(
466
+ } = e, [a, f] = k(!1), [w, b] = k(null), [v, S] = k(!1), N = q(!1), P = q(null), T = p(
467
+ () => o._getFields(),
468
+ [o]
469
+ ), V = p(
414
470
  () => Object.keys(T).filter(
415
471
  (u) => T[u].readOnly
416
472
  ),
417
473
  [T]
418
- ), R = j(
419
- () => Y(c),
420
- [c]
474
+ ), A = p(
475
+ () => Y(o),
476
+ [o]
421
477
  ), n = W({
422
- mode: a,
478
+ mode: s,
423
479
  defaultValues: i,
424
- resolver: R
425
- }), E = j(
426
- () => Z(c, n),
427
- [c, n]
428
- ), _ = j(
429
- () => c._getOps(),
430
- [c]
480
+ resolver: A
481
+ }), E = p(
482
+ () => Z(o, n),
483
+ [o, n]
484
+ ), O = p(
485
+ () => o._getOps(),
486
+ [o]
431
487
  );
432
488
  U(() => {
433
489
  if (!t) return;
434
490
  let u = !0;
435
491
  return (async () => {
436
- f(!0), $(null);
492
+ f(!0), b(null);
437
493
  try {
438
- const l = await _.read(e);
494
+ const l = await O.read(r);
439
495
  if (!u) return;
440
496
  l && typeof l == "object" && n.reset({ ...i, ...l });
441
497
  } catch (l) {
442
498
  if (!u) return;
443
- console.error("Failed to read activity data:", l), $(B(l));
499
+ console.error("Failed to read activity data:", l), b(J(l));
444
500
  } finally {
445
501
  u && f(!1);
446
502
  }
447
503
  })(), () => {
448
504
  u = !1;
449
505
  };
450
- }, [t, _, e]);
451
- const P = N(
506
+ }, [t, O, r]);
507
+ const B = j(
452
508
  async (u) => {
453
- V.length !== 0 && (x.current || (C.current && clearTimeout(C.current), C.current = setTimeout(async () => {
454
- if (!x.current) {
455
- x.current = !0;
509
+ V.length !== 0 && (N.current || (P.current && clearTimeout(P.current), P.current = setTimeout(async () => {
510
+ if (!N.current) {
511
+ N.current = !0;
456
512
  try {
457
- const o = n.getValues(), l = {}, d = new Set(V);
458
- Object.keys(o).forEach((y) => {
459
- d.has(y) || (l[y] = o[y]);
513
+ const c = n.getValues(), l = {}, d = new Set(V);
514
+ Object.keys(c).forEach((m) => {
515
+ d.has(m) || (l[m] = c[m]);
460
516
  });
461
- const h = await _.draftStart(e, l);
462
- h && typeof h == "object" && Object.entries(h).forEach(([y, g]) => {
463
- d.has(y) && n.getValues(y) !== g && n.setValue(y, g, {
517
+ const h = await O.draftStart(r, l);
518
+ h && typeof h == "object" && Object.entries(h).forEach(([m, _]) => {
519
+ d.has(m) && n.getValues(m) !== _ && n.setValue(m, _, {
464
520
  shouldDirty: !1,
465
521
  shouldValidate: !1
466
522
  });
467
523
  });
468
- } catch (o) {
469
- console.warn("Draft computation failed:", o);
524
+ } catch (c) {
525
+ console.warn("Draft computation failed:", c);
470
526
  } finally {
471
- x.current = !1;
527
+ N.current = !1;
472
528
  }
473
529
  }
474
530
  }, 300)));
475
531
  },
476
- [_, V, n]
477
- ), F = N(
478
- (u, o) => {
479
- const l = T[u], d = l ? l.readOnly : !1, h = o == null ? void 0 : o.onBlur, y = async (A) => {
480
- h && await h(A);
481
- let J = !0;
482
- a === "onBlur" || a === "onTouched" || a === "all" ? J = await n.trigger(u) : J = !n.getFieldState(u, n.formState).error, J && await P(u);
483
- }, g = n.register(u, {
484
- ...o,
485
- onBlur: y,
532
+ [O, V, n]
533
+ ), L = j(
534
+ (u, c) => {
535
+ const l = T[u], d = l ? l.readOnly : !1, h = c == null ? void 0 : c.onBlur, m = async (C) => {
536
+ h && await h(C);
537
+ let x = !0;
538
+ s === "onBlur" || s === "onTouched" || s === "all" ? x = await n.trigger(u) : x = !n.getFieldState(u, n.formState).error, x && await B(u);
539
+ }, _ = n.register(u, {
540
+ ...c,
541
+ onBlur: m,
486
542
  ...d ? { disabled: !0 } : {}
487
543
  });
488
- return d ? { ...g, disabled: !0 } : g;
544
+ return d ? { ..._, disabled: !0 } : _;
489
545
  },
490
- [n, T, P, a]
491
- ), L = N(
492
- (u, o) => n.handleSubmit(
546
+ [n, T, B, s]
547
+ ), M = j(
548
+ (u, c) => n.handleSubmit(
493
549
  async (l, d) => {
494
- b(!0);
550
+ S(!0);
495
551
  try {
496
- const h = {}, y = new Set(V);
497
- Object.keys(l).forEach((g) => {
498
- !y.has(g) && l[g] !== void 0 && (h[g] = l[g]);
499
- }), await _.update(e, h), await _.draftEnd(e, h), await (u == null ? void 0 : u(l, d));
552
+ const h = {}, m = new Set(V);
553
+ Object.keys(l).forEach((_) => {
554
+ !m.has(_) && l[_] !== void 0 && (h[_] = l[_]);
555
+ }), await O.update(r, h), await O.draftEnd(r, h), await (u == null ? void 0 : u(l, d));
500
556
  } catch (h) {
501
- o == null || o(B(h), d);
557
+ c == null || c(J(h), d);
502
558
  } finally {
503
- b(!1);
559
+ S(!1);
504
560
  }
505
561
  },
506
562
  (l, d) => {
507
- o == null || o(l, d);
563
+ c == null || c(l, d);
508
564
  }
509
565
  ),
510
- [n, _, V]
511
- ), M = N(
512
- (u, o) => n.handleSubmit(
566
+ [n, O, V]
567
+ ), F = j(
568
+ (u, c) => n.handleSubmit(
513
569
  async (l, d) => {
514
- b(!0);
570
+ S(!0);
515
571
  try {
516
- await _.complete(e), await (u == null ? void 0 : u(l, d));
572
+ await O.complete(r), await (u == null ? void 0 : u(l, d));
517
573
  } catch (h) {
518
- o == null || o(B(h), d);
574
+ c == null || c(J(h), d);
519
575
  } finally {
520
- b(!1);
576
+ S(!1);
521
577
  }
522
578
  },
523
579
  (l, d) => {
524
- o == null || o(l, d);
580
+ c == null || c(l, d);
525
581
  }
526
582
  ),
527
- [n, _]
528
- ), G = N(() => {
583
+ [n, O]
584
+ ), R = j(() => {
529
585
  n.clearErrors();
530
- }, [n]), H = !!m;
586
+ }, [n]), D = !!w;
531
587
  return {
532
588
  // Item proxy
533
589
  item: E,
534
590
  // Activity reference
535
- activity: c,
591
+ activity: o,
536
592
  // Form methods
537
- register: F,
538
- handleSubmit: L,
539
- handleComplete: M,
593
+ register: L,
594
+ handleSubmit: M,
595
+ handleComplete: F,
540
596
  watch: n.watch,
541
597
  setValue: n.setValue,
542
598
  getValues: n.getValues,
@@ -547,19 +603,19 @@ function ot(c, s) {
547
603
  errors: n.formState.errors,
548
604
  isValid: n.formState.isValid,
549
605
  isDirty: n.formState.isDirty,
550
- isSubmitting: n.formState.isSubmitting || S,
606
+ isSubmitting: n.formState.isSubmitting || v,
551
607
  isSubmitSuccessful: n.formState.isSubmitSuccessful,
552
608
  // Loading
553
- isLoading: r,
554
- loadError: m,
555
- hasError: H,
609
+ isLoading: a,
610
+ loadError: w,
611
+ hasError: D,
556
612
  // Operations
557
- clearErrors: G
613
+ clearErrors: R
558
614
  };
559
615
  }
560
616
  export {
561
- ct as Activity,
617
+ ot as Activity,
562
618
  Q as ActivityInstance,
563
619
  z as Workflow,
564
- ot as useActivityForm
620
+ ct as useActivityForm
565
621
  };