@ram_28/kf-ai-sdk 2.0.15 → 2.0.16

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 (83) hide show
  1. package/README.md +8 -8
  2. package/dist/bdo/core/BaseBdo.d.ts +1 -1
  3. package/dist/bdo.mjs +2 -2
  4. package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts +1 -1
  5. package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -1
  6. package/dist/components/hooks/useActivityForm/types.d.ts +2 -2
  7. package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -1
  8. package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -1
  9. package/dist/components/hooks/useActivityTable/types.d.ts +4 -4
  10. package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -1
  11. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +1 -1
  12. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -1
  13. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -0
  14. package/dist/components/hooks/useBDOForm/createResolver.d.ts.map +1 -0
  15. package/dist/components/hooks/useBDOForm/index.d.ts +6 -0
  16. package/dist/components/hooks/useBDOForm/index.d.ts.map +1 -0
  17. package/dist/components/hooks/useBDOForm/shared.d.ts +50 -0
  18. package/dist/components/hooks/useBDOForm/shared.d.ts.map +1 -0
  19. package/dist/components/hooks/{useForm → useBDOForm}/types.d.ts +6 -6
  20. package/dist/components/hooks/useBDOForm/types.d.ts.map +1 -0
  21. package/dist/components/hooks/{useForm/useForm.d.ts → useBDOForm/useBDOForm.d.ts} +4 -4
  22. package/dist/components/hooks/useBDOForm/useBDOForm.d.ts.map +1 -0
  23. package/dist/components/hooks/useBDOTable/types.d.ts +1 -3
  24. package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -1
  25. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -1
  26. package/dist/form.cjs +1 -1
  27. package/dist/form.d.ts +1 -1
  28. package/dist/form.d.ts.map +1 -1
  29. package/dist/form.mjs +250 -253
  30. package/dist/form.types.d.ts +1 -1
  31. package/dist/form.types.d.ts.map +1 -1
  32. package/dist/shared-5a7UkED1.js +1180 -0
  33. package/dist/shared-nnmlRVs7.cjs +1 -0
  34. package/dist/table.cjs +1 -1
  35. package/dist/table.mjs +12 -11
  36. package/dist/types/constants.d.ts +3 -3
  37. package/dist/workflow/Activity.d.ts +15 -3
  38. package/dist/workflow/Activity.d.ts.map +1 -1
  39. package/dist/workflow/client.d.ts +2 -2
  40. package/dist/workflow/client.d.ts.map +1 -1
  41. package/dist/workflow/types.d.ts +7 -3
  42. package/dist/workflow/types.d.ts.map +1 -1
  43. package/dist/workflow.cjs +1 -1
  44. package/dist/workflow.mjs +503 -546
  45. package/docs/bdo.md +1 -1
  46. package/docs/gaps.md +14 -64
  47. package/docs/useActivityForm.md +393 -0
  48. package/docs/useActivityTable.md +42 -105
  49. package/docs/{useForm.md → useBDOForm.md} +24 -24
  50. package/docs/useBDOTable.md +6 -39
  51. package/docs/workflow.md +43 -301
  52. package/package.json +2 -2
  53. package/sdk/bdo/core/BaseBdo.ts +2 -2
  54. package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +1 -1
  55. package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +1 -1
  56. package/sdk/components/hooks/useActivityForm/types.ts +4 -4
  57. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +44 -194
  58. package/sdk/components/hooks/useActivityTable/types.ts +4 -2
  59. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +8 -39
  60. package/sdk/components/hooks/{useForm → useBDOForm}/index.ts +4 -3
  61. package/sdk/components/hooks/useBDOForm/shared.ts +250 -0
  62. package/sdk/components/hooks/{useForm → useBDOForm}/types.ts +9 -9
  63. package/sdk/components/hooks/{useForm/useForm.ts → useBDOForm/useBDOForm.ts} +70 -96
  64. package/sdk/components/hooks/useBDOTable/types.ts +1 -3
  65. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +3 -2
  66. package/sdk/form.ts +2 -2
  67. package/sdk/form.types.ts +4 -4
  68. package/sdk/types/constants.ts +3 -3
  69. package/sdk/workflow/Activity.ts +29 -6
  70. package/sdk/workflow/client.ts +65 -25
  71. package/sdk/workflow/types.ts +10 -2
  72. package/dist/components/hooks/useForm/createItemProxy.d.ts.map +0 -1
  73. package/dist/components/hooks/useForm/createResolver.d.ts.map +0 -1
  74. package/dist/components/hooks/useForm/index.d.ts +0 -5
  75. package/dist/components/hooks/useForm/index.d.ts.map +0 -1
  76. package/dist/components/hooks/useForm/types.d.ts.map +0 -1
  77. package/dist/components/hooks/useForm/useForm.d.ts.map +0 -1
  78. package/dist/createResolver-AIgUwoS6.cjs +0 -1
  79. package/dist/createResolver-ZHXQ7QMa.js +0 -1078
  80. /package/dist/components/hooks/{useForm → useBDOForm}/createItemProxy.d.ts +0 -0
  81. /package/dist/components/hooks/{useForm → useBDOForm}/createResolver.d.ts +0 -0
  82. /package/sdk/components/hooks/{useForm → useBDOForm}/createItemProxy.ts +0 -0
  83. /package/sdk/components/hooks/{useForm → useBDOForm}/createResolver.ts +0 -0
package/dist/workflow.mjs CHANGED
@@ -1,17 +1,17 @@
1
- var ie = Object.defineProperty;
2
- var oe = (i, t, e) => t in i ? ie(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var I = (i, t, e) => oe(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { c as P, g as j, d as ce } from "./client-_ayziI1d.js";
5
- import { B as le, c as ue, S as Z, F as de, U as fe, R as ye, T as he, D as ge, b as me, a as we, N as _e } from "./FileField-BWrSHNRq.js";
6
- import { useState as G, useRef as H, useMemo as p, useEffect as Te, useCallback as B } from "react";
7
- import { v as Fe, u as ve } from "./createResolver-ZHXQ7QMa.js";
8
- import { useQuery as be } from "@tanstack/react-query";
9
- import { v as Y, e as Q } from "./attachment-constants-C2UHWxmp.js";
10
- import { t as K, u as Se } from "./useTable-DS0-WInw.js";
11
- import { g as $e } from "./metadata-Cc1mBcLS.js";
12
- class Ve {
1
+ var oe = Object.defineProperty;
2
+ var ce = (o, t, e) => t in o ? oe(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var N = (o, t, e) => ce(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import { c as S, g as $, d as le } from "./client-_ayziI1d.js";
5
+ import { B as ue, c as de, S as Q, F as ye, U as fe, R as he, T as ge, D as me, b as _e, a as we, N as Fe } from "./FileField-BWrSHNRq.js";
6
+ import { useState as z, useRef as W, useMemo as P, useEffect as Te, useCallback as G } from "react";
7
+ import { v as ve, u as Oe, b as be, d as Se, e as $e, f as X, a as Ce } from "./shared-5a7UkED1.js";
8
+ import { useQuery as pe } from "@tanstack/react-query";
9
+ import { v as Y, e as Z } from "./attachment-constants-C2UHWxmp.js";
10
+ import { t as K, u as Pe } from "./useTable-DS0-WInw.js";
11
+ import { g as Ve } from "./metadata-Cc1mBcLS.js";
12
+ class xe {
13
13
  constructor(t) {
14
- I(this, "bp_id");
14
+ N(this, "bp_id");
15
15
  this.bp_id = t;
16
16
  }
17
17
  /**
@@ -19,10 +19,10 @@ class Ve {
19
19
  */
20
20
  async start() {
21
21
  const t = await fetch(
22
- `${P()}/api/app/process/${this.bp_id}/start`,
22
+ `${S()}/api/app/process/${this.bp_id}/start`,
23
23
  {
24
24
  method: "POST",
25
- headers: j()
25
+ headers: $()
26
26
  }
27
27
  );
28
28
  if (!t.ok)
@@ -37,10 +37,10 @@ class Ve {
37
37
  */
38
38
  async progress(t) {
39
39
  const e = await fetch(
40
- `${P()}/api/app/process/${this.bp_id}/${t}/progress`,
40
+ `${S()}/api/app/process/${this.bp_id}/${t}/progress`,
41
41
  {
42
42
  method: "GET",
43
- headers: j()
43
+ headers: $()
44
44
  }
45
45
  );
46
46
  if (!e.ok)
@@ -55,123 +55,147 @@ class Ve {
55
55
  const e = `/api/app/process/${this.bp_id}/${t}`;
56
56
  return {
57
57
  // ── List-level ────────────────────────────────────────────
58
- // TODO: Backend currently only supports GET for list/metric endpoints.
59
- // Once backend is updated to accept POST with Filter/Sort/Page body,
60
- // switch back to POST so useTable features (search, sort, pagination) work.
61
- //
62
- // POST version (waiting for backend):
63
- // async inProgressList(options?: ListOptionsType) {
64
- // return fetch(url + "/inprogress/list", {
65
- // method: "POST", headers: getDefaultHeaders(),
66
- // body: options ? JSON.stringify(options) : undefined,
67
- // });
68
- // }
69
- // (same pattern for completedList, inProgressMetric, completedMetric)
70
58
  async inProgressList(a) {
71
- const s = await fetch(`${P()}${e}/inprogress/list`, {
72
- method: "GET",
73
- headers: j()
59
+ const n = await fetch(`${S()}${e}/inprogress/list`, {
60
+ method: "POST",
61
+ headers: $(),
62
+ body: a ? JSON.stringify(a) : void 0
74
63
  });
75
- if (!s.ok)
76
- throw new Error(`Failed to list in-progress activities: ${s.statusText}`);
77
- return s.json();
64
+ if (!n.ok)
65
+ throw new Error(`Failed to list in-progress activities: ${n.statusText}`);
66
+ return n.json();
78
67
  },
79
68
  async completedList(a) {
80
- const s = await fetch(`${P()}${e}/completed/list`, {
81
- method: "GET",
82
- headers: j()
69
+ const n = await fetch(`${S()}${e}/completed/list`, {
70
+ method: "POST",
71
+ headers: $(),
72
+ body: a ? JSON.stringify(a) : void 0
73
+ });
74
+ if (!n.ok)
75
+ throw new Error(`Failed to list completed activities: ${n.statusText}`);
76
+ return n.json();
77
+ },
78
+ async inProgressCount(a) {
79
+ var m, s;
80
+ const n = {
81
+ Type: "Metric",
82
+ GroupBy: [],
83
+ Metric: [{ Field: "_id", Type: "Count" }],
84
+ ...(a == null ? void 0 : a.Filter) && { Filter: a.Filter }
85
+ }, i = await fetch(`${S()}${e}/inprogress/metric`, {
86
+ method: "POST",
87
+ headers: $(),
88
+ body: JSON.stringify(n)
83
89
  });
84
- if (!s.ok)
85
- throw new Error(`Failed to list completed activities: ${s.statusText}`);
86
- return s.json();
90
+ if (!i.ok)
91
+ throw new Error(`Failed to get in-progress count: ${i.statusText}`);
92
+ return { Count: ((s = (m = (await i.json()).Data) == null ? void 0 : m[0]) == null ? void 0 : s.count__id) ?? 0 };
93
+ },
94
+ async completedCount(a) {
95
+ var m, s;
96
+ const n = {
97
+ Type: "Metric",
98
+ GroupBy: [],
99
+ Metric: [{ Field: "_id", Type: "Count" }],
100
+ ...(a == null ? void 0 : a.Filter) && { Filter: a.Filter }
101
+ }, i = await fetch(`${S()}${e}/completed/metric`, {
102
+ method: "POST",
103
+ headers: $(),
104
+ body: JSON.stringify(n)
105
+ });
106
+ if (!i.ok)
107
+ throw new Error(`Failed to get completed count: ${i.statusText}`);
108
+ return { Count: ((s = (m = (await i.json()).Data) == null ? void 0 : m[0]) == null ? void 0 : s.count__id) ?? 0 };
87
109
  },
88
110
  async inProgressMetric(a) {
89
- const s = await fetch(`${P()}${e}/inprogress/metric`, {
90
- method: "GET",
91
- headers: j()
111
+ const n = { Type: "Metric", ...a }, i = await fetch(`${S()}${e}/inprogress/metric`, {
112
+ method: "POST",
113
+ headers: $(),
114
+ body: JSON.stringify(n)
92
115
  });
93
- if (!s.ok)
94
- throw new Error(`Failed to get in-progress activity count: ${s.statusText}`);
95
- return s.json();
116
+ if (!i.ok)
117
+ throw new Error(`Failed to get in-progress metrics: ${i.statusText}`);
118
+ return i.json();
96
119
  },
97
120
  async completedMetric(a) {
98
- const s = await fetch(`${P()}${e}/completed/metric`, {
99
- method: "GET",
100
- headers: j()
121
+ const n = { Type: "Metric", ...a }, i = await fetch(`${S()}${e}/completed/metric`, {
122
+ method: "POST",
123
+ headers: $(),
124
+ body: JSON.stringify(n)
101
125
  });
102
- if (!s.ok)
103
- throw new Error(`Failed to get completed activity count: ${s.statusText}`);
104
- return s.json();
126
+ if (!i.ok)
127
+ throw new Error(`Failed to get completed metrics: ${i.statusText}`);
128
+ return i.json();
105
129
  },
106
130
  // ── Instance-level ────────────────────────────────────────
107
131
  async read(a) {
108
- const s = await fetch(`${P()}${e}/${a}/read`, {
132
+ const n = await fetch(`${S()}${e}/${a}/read`, {
109
133
  method: "GET",
110
- headers: j()
134
+ headers: $()
111
135
  });
112
- if (!s.ok)
113
- throw new Error(`Failed to read activity: ${s.statusText}`);
114
- return (await s.json()).Data;
136
+ if (!n.ok)
137
+ throw new Error(`Failed to read activity: ${n.statusText}`);
138
+ return (await n.json()).Data;
115
139
  },
116
- async update(a, s) {
117
- const o = await fetch(`${P()}${e}/${a}/update`, {
140
+ async update(a, n) {
141
+ const i = await fetch(`${S()}${e}/${a}/update`, {
118
142
  method: "POST",
119
- headers: j(),
120
- body: JSON.stringify(s)
143
+ headers: $(),
144
+ body: JSON.stringify(n)
121
145
  });
122
- if (!o.ok)
123
- throw new Error(`Failed to update activity: ${o.statusText}`);
124
- return o.json();
146
+ if (!i.ok)
147
+ throw new Error(`Failed to update activity: ${i.statusText}`);
148
+ return i.json();
125
149
  },
126
- async draftStart(a, s) {
127
- const o = await fetch(`${P()}${e}/${a}/draft`, {
150
+ async draftStart(a, n) {
151
+ const i = await fetch(`${S()}${e}/${a}/draft`, {
128
152
  method: "PATCH",
129
- headers: j(),
130
- body: JSON.stringify(s)
153
+ headers: $(),
154
+ body: JSON.stringify(n)
131
155
  });
132
- if (!o.ok)
133
- throw new Error(`Failed to start draft: ${o.statusText}`);
134
- return o.json();
156
+ if (!i.ok)
157
+ throw new Error(`Failed to start draft: ${i.statusText}`);
158
+ return i.json();
135
159
  },
136
- async draftEnd(a, s) {
137
- const o = await fetch(`${P()}${e}/${a}/draft`, {
160
+ async draftEnd(a, n) {
161
+ const i = await fetch(`${S()}${e}/${a}/draft`, {
138
162
  method: "POST",
139
- headers: j(),
140
- body: JSON.stringify(s)
163
+ headers: $(),
164
+ body: JSON.stringify(n)
141
165
  });
142
- if (!o.ok)
143
- throw new Error(`Failed to end draft: ${o.statusText}`);
144
- return o.json();
166
+ if (!i.ok)
167
+ throw new Error(`Failed to end draft: ${i.statusText}`);
168
+ return i.json();
145
169
  },
146
170
  async complete(a) {
147
- const s = await fetch(`${P()}${e}/${a}/done`, {
171
+ const n = await fetch(`${S()}${e}/${a}/done`, {
148
172
  method: "POST",
149
- headers: j()
173
+ headers: $()
150
174
  });
151
- if (!s.ok)
152
- throw new Error(`Failed to complete activity: ${s.statusText}`);
153
- return s.json();
175
+ if (!n.ok)
176
+ throw new Error(`Failed to complete activity: ${n.statusText}`);
177
+ return n.json();
154
178
  },
155
179
  async progress(a) {
156
- const s = await fetch(`${P()}${e}/${a}/progress`, {
180
+ const n = await fetch(`${S()}${e}/${a}/progress`, {
157
181
  method: "GET",
158
- headers: j()
182
+ headers: $()
159
183
  });
160
- if (!s.ok)
161
- throw new Error(`Failed to get activity progress: ${s.statusText}`);
162
- return s.json();
184
+ if (!n.ok)
185
+ throw new Error(`Failed to get activity progress: ${n.statusText}`);
186
+ return n.json();
163
187
  }
164
188
  };
165
189
  }
166
190
  }
167
- class Ce {
168
- constructor(t, e, a, s) {
169
- I(this, "_id");
170
- I(this, "_data");
171
- I(this, "_ops");
172
- I(this, "_fields");
173
- I(this, "_accessorCache", /* @__PURE__ */ new Map());
174
- this._ops = t, this._id = e, this._data = { ...a }, this._fields = s;
191
+ class ke {
192
+ constructor(t, e, a, n) {
193
+ N(this, "_id");
194
+ N(this, "_data");
195
+ N(this, "_ops");
196
+ N(this, "_fields");
197
+ N(this, "_accessorCache", /* @__PURE__ */ new Map());
198
+ this._ops = t, this._id = e, this._data = { ...a }, this._fields = n;
175
199
  }
176
200
  // ============================================================
177
201
  // BDO ITEM METHODS
@@ -188,8 +212,8 @@ class Ce {
188
212
  validate() {
189
213
  const t = [];
190
214
  for (const [e, a] of Object.entries(this._fields)) {
191
- const s = this._data[e], o = a.validate(s);
192
- o.valid || t.push(...o.errors);
215
+ const n = this._data[e], i = a.validate(n);
216
+ i.valid || t.push(...i.errors);
193
217
  }
194
218
  return {
195
219
  valid: t.length === 0,
@@ -234,16 +258,16 @@ class Ce {
234
258
  _id: t,
235
259
  Name: t,
236
260
  Type: "String"
237
- }, s = (e == null ? void 0 : e.readOnly) ?? !1, o = () => e ? e.validate(this._data[t]) : { valid: !0, errors: [] };
261
+ }, n = (e == null ? void 0 : e.readOnly) ?? !1, i = () => e ? e.validate(this._data[t]) : { valid: !0, errors: [] };
238
262
  let r;
239
- return s ? r = {
263
+ return n ? r = {
240
264
  label: (e == null ? void 0 : e.label) ?? t,
241
265
  required: (e == null ? void 0 : e.required) ?? !1,
242
266
  readOnly: !0,
243
267
  defaultValue: e == null ? void 0 : e.defaultValue,
244
268
  meta: a,
245
269
  get: () => this._data[t],
246
- validate: o
270
+ validate: i
247
271
  } : r = {
248
272
  label: (e == null ? void 0 : e.label) ?? t,
249
273
  required: (e == null ? void 0 : e.required) ?? !1,
@@ -251,30 +275,30 @@ class Ce {
251
275
  defaultValue: e == null ? void 0 : e.defaultValue,
252
276
  meta: a,
253
277
  get: () => this._data[t],
254
- set: (w) => {
255
- this._data[t] = w;
278
+ set: (y) => {
279
+ this._data[t] = y;
256
280
  },
257
- validate: o
281
+ validate: i
258
282
  }, this._accessorCache.set(t, r), r;
259
283
  }
260
284
  }
261
- function De(i, t, e, a) {
262
- const s = new Ce(
263
- i,
285
+ function Ne(o, t, e, a) {
286
+ const n = new ke(
287
+ o,
264
288
  t,
265
289
  e,
266
290
  a
267
291
  );
268
- return new Proxy(s, {
269
- get(o, r, w) {
270
- 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(o, r, w) : r === "_id" ? o._id : o._getAccessor(r);
292
+ return new Proxy(n, {
293
+ get(i, r, y) {
294
+ 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(i, r, y) : r === "_id" ? i._id : i._getAccessor(r);
271
295
  },
272
- has(o, r) {
273
- return typeof r == "symbol" ? !1 : r === "validate" || r === "toJSON" || r === "update" || r === "save" || r === "complete" || r === "progress" || r === "_id" ? !0 : r in o._fields;
296
+ has(i, r) {
297
+ return typeof r == "symbol" ? !1 : r === "validate" || r === "toJSON" || r === "update" || r === "save" || r === "complete" || r === "progress" || r === "_id" ? !0 : r in i._fields;
274
298
  },
275
- ownKeys(o) {
299
+ ownKeys(i) {
276
300
  return [
277
- ...Object.keys(o._fields),
301
+ ...Object.keys(i._fields),
278
302
  "_id",
279
303
  "validate",
280
304
  "toJSON",
@@ -284,7 +308,7 @@ function De(i, t, e, a) {
284
308
  "progress"
285
309
  ];
286
310
  },
287
- getOwnPropertyDescriptor(o, r) {
311
+ getOwnPropertyDescriptor(i, r) {
288
312
  if (typeof r != "symbol")
289
313
  return {
290
314
  configurable: !0,
@@ -293,12 +317,12 @@ function De(i, t, e, a) {
293
317
  }
294
318
  });
295
319
  }
296
- class Je {
320
+ class Ge {
297
321
  constructor() {
298
322
  // ============================================================
299
323
  // FIELD DISCOVERY (internal)
300
324
  // ============================================================
301
- I(this, "_fieldsCache", null);
325
+ N(this, "_fieldsCache", null);
302
326
  }
303
327
  // ============================================================
304
328
  // ACTIVITY OPERATIONS (internal)
@@ -308,7 +332,7 @@ class Je {
308
332
  * @internal
309
333
  */
310
334
  _ops() {
311
- return new Ve(this.meta.businessProcessId).activity(this.meta.activityId);
335
+ return new xe(this.meta.businessProcessId).activity(this.meta.activityId);
312
336
  }
313
337
  /**
314
338
  * Discover BaseField instances from subclass properties.
@@ -319,7 +343,7 @@ class Je {
319
343
  const t = {};
320
344
  for (const e of Object.keys(this)) {
321
345
  const a = this[e];
322
- a instanceof le && (t[e] = a);
346
+ a instanceof ue && (t[e] = a);
323
347
  }
324
348
  return this._fieldsCache = t, t;
325
349
  }
@@ -342,14 +366,30 @@ class Je {
342
366
  }
343
367
  /**
344
368
  * Get count of in-progress activity instances.
369
+ * Returns a number (same as BDO count()).
345
370
  */
346
- async inProgressMetrics(t) {
347
- return this._ops().inProgressMetric(t);
371
+ async inProgressCount(t) {
372
+ return (await this._ops().inProgressCount(t)).Count;
348
373
  }
349
374
  /**
350
375
  * Get count of completed activity instances.
376
+ * Returns a number (same as BDO count()).
377
+ */
378
+ async completedCount(t) {
379
+ return (await this._ops().completedCount(t)).Count;
380
+ }
381
+ /**
382
+ * Get aggregated metrics for in-progress activity instances.
383
+ * Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
384
+ */
385
+ async inProgressMetric(t) {
386
+ return this._ops().inProgressMetric(t);
387
+ }
388
+ /**
389
+ * Get aggregated metrics for completed activity instances.
390
+ * Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
351
391
  */
352
- async completedMetrics(t) {
392
+ async completedMetric(t) {
353
393
  return this._ops().completedMetric(t);
354
394
  }
355
395
  /**
@@ -359,12 +399,12 @@ class Je {
359
399
  * @returns ActivityInstance with typed field accessors
360
400
  */
361
401
  async getInstance(t) {
362
- const e = this._ops(), a = await e.read(t), s = this._discoverFields();
363
- return De(
402
+ const e = this._ops(), a = await e.read(t), n = this._discoverFields();
403
+ return Ne(
364
404
  e,
365
405
  t,
366
406
  a,
367
- s
407
+ n
368
408
  );
369
409
  }
370
410
  // ============================================================
@@ -385,81 +425,81 @@ class Je {
385
425
  return this._ops();
386
426
  }
387
427
  }
388
- function X(i, t) {
389
- var s;
390
- const e = { _id: i, ...t }, a = t.Type;
391
- if (a === "String" && ((s = t.Constraint) != null && s.Enum))
392
- return new ue(e);
428
+ function ee(o, t) {
429
+ var n;
430
+ const e = { _id: o, ...t }, a = t.Type;
431
+ if (a === "String" && ((n = t.Constraint) != null && n.Enum))
432
+ return new de(e);
393
433
  switch (a) {
394
434
  case "String":
395
- return new Z(e);
435
+ return new Q(e);
396
436
  case "Number":
397
- return new _e(e);
437
+ return new Fe(e);
398
438
  case "Boolean":
399
439
  return new we(e);
400
440
  case "Date":
401
- return new me(e);
441
+ return new _e(e);
402
442
  case "DateTime":
403
- return new ge(e);
443
+ return new me(e);
404
444
  case "Text":
405
- return new he(e);
445
+ return new ge(e);
406
446
  case "Reference":
407
- return new ye(e);
447
+ return new he(e);
408
448
  case "User":
409
449
  return new fe(e);
410
450
  case "File":
411
- return new de(e);
451
+ return new ye(e);
412
452
  default:
413
- return new Z(e);
453
+ return new Q(e);
414
454
  }
415
455
  }
416
- function Oe(i) {
456
+ function je(o) {
417
457
  const t = {};
418
- for (const [e, a] of Object.entries(i))
419
- t[e] = X(e, a);
458
+ for (const [e, a] of Object.entries(o))
459
+ t[e] = ee(e, a);
420
460
  return t;
421
461
  }
422
- function ke(i, t, e) {
423
- var o;
462
+ function De(o, t, e) {
463
+ var i;
424
464
  const a = t == null ? void 0 : t.BDOBlob;
425
465
  if (!(a != null && a.Activity)) return null;
426
- const s = i == null ? void 0 : i.Id;
466
+ const n = o == null ? void 0 : o.Id;
427
467
  for (const r of a.Activity)
428
- if (r.Id !== s && (o = r.Input) != null && o[e])
468
+ if (r.Id !== n && (i = r.Input) != null && i[e])
429
469
  return r.Input[e];
430
470
  return null;
431
471
  }
432
- function Pe(i) {
472
+ function Ue(o) {
433
473
  return async (t, e, a) => {
434
- const s = {}, o = "_getFields" in i ? i._getFields() : i, r = (a == null ? void 0 : a.names) ?? Object.keys(o);
435
- for (const w of r) {
436
- const D = o[w];
437
- if (!D || D.readOnly) continue;
438
- let n = t[w];
439
- typeof n == "string" && D.meta.Type === "Number" && (n = n === "" ? void 0 : Number(n));
440
- const c = D.validate(n);
441
- if (!c.valid && c.errors.length > 0) {
442
- s[w] = {
474
+ const n = {}, i = "_getFields" in o ? o._getFields() : o, r = (a == null ? void 0 : a.names) ?? Object.keys(i);
475
+ for (const y of r) {
476
+ const m = i[y];
477
+ if (!m || m.readOnly) continue;
478
+ let s = t[y];
479
+ typeof s == "string" && m.meta.Type === "Number" && (s = s === "" ? void 0 : Number(s));
480
+ const l = m.validate(s);
481
+ if (!l.valid && l.errors.length > 0) {
482
+ n[y] = {
443
483
  type: "validate",
444
- message: c.errors[0] || `${w} is invalid`
484
+ message: l.errors[0] || `${y} is invalid`
445
485
  };
446
486
  continue;
447
487
  }
448
- const T = Fe(
449
- D,
450
- n
488
+ const w = ve(
489
+ m,
490
+ s
451
491
  );
452
- !T.valid && T.errors.length > 0 && (s[w] = {
492
+ !w.valid && w.errors.length > 0 && (n[y] = {
453
493
  type: "constraint",
454
- message: T.errors[0]
494
+ message: w.errors[0]
455
495
  });
456
496
  }
457
- return Object.keys(s).length === 0 ? { values: t, errors: {} } : { values: {}, errors: s };
497
+ return Object.keys(n).length === 0 ? { values: t, errors: {} } : { values: {}, errors: n };
458
498
  };
459
499
  }
460
- function je(i, t, e) {
461
- const a = i._getFields(), s = /* @__PURE__ */ new Map(), o = `/api/app/process/${i.meta.businessProcessId}/${i.meta.activityId}`, r = ce(o);
462
- function w() {
500
+ function Ie(o, t, e) {
501
+ const a = o._getFields(), n = /* @__PURE__ */ new Map(), i = `/api/app/process/${o.meta.businessProcessId}/${o.meta.activityId}`, r = le(i);
502
+ function y() {
463
503
  if (!e)
464
504
  throw new Error(
465
505
  "Cannot perform attachment operation: no activity instance ID"
@@ -469,275 +509,256 @@ function je(i, t, e) {
469
509
  return new Proxy(
470
510
  {},
471
511
  {
472
- get(D, n) {
473
- if (typeof n == "symbol")
512
+ get(m, s) {
513
+ if (typeof s == "symbol")
474
514
  return;
475
- if (n === "_id")
515
+ if (s === "_id")
476
516
  return e;
477
- if (n === "toJSON")
517
+ if (s === "toJSON")
478
518
  return () => t.getValues();
479
- if (n === "validate")
519
+ if (s === "validate")
480
520
  return () => t.trigger();
481
- if (s.has(n))
482
- return s.get(n);
483
- const c = a[n], T = (c == null ? void 0 : c.meta) ?? {
484
- _id: n,
485
- Name: n,
521
+ if (n.has(s))
522
+ return n.get(s);
523
+ const l = a[s], w = (l == null ? void 0 : l.meta) ?? {
524
+ _id: s,
525
+ Name: s,
486
526
  Type: "String"
487
- }, L = (c == null ? void 0 : c.readOnly) ?? !1, M = () => c ? c.validate(
488
- t.getValues(n)
489
- ) : { valid: !0, errors: [] }, E = (O) => {
490
- const y = t.getValues(n);
491
- return y ?? O;
527
+ }, B = (l == null ? void 0 : l.readOnly) ?? !1, R = () => l ? l.validate(
528
+ t.getValues(s)
529
+ ) : { valid: !0, errors: [] }, A = (b) => {
530
+ const d = t.getValues(s);
531
+ return d ?? b;
492
532
  };
493
- if (!L) {
494
- const O = () => {
495
- const l = t.getValues(n);
496
- return T.Type === "File" ? l ?? [] : l;
497
- }, y = {
498
- label: (c == null ? void 0 : c.label) ?? n,
499
- required: (c == null ? void 0 : c.required) ?? !1,
533
+ if (!B) {
534
+ const b = () => {
535
+ const c = t.getValues(s);
536
+ return w.Type === "File" ? c ?? [] : c;
537
+ }, d = {
538
+ label: (l == null ? void 0 : l.label) ?? s,
539
+ required: (l == null ? void 0 : l.required) ?? !1,
500
540
  readOnly: !1,
501
- defaultValue: c == null ? void 0 : c.defaultValue,
502
- meta: T,
503
- get: O,
504
- getOrDefault: E,
505
- set: (l) => {
506
- t.setValue(n, l, {
541
+ defaultValue: l == null ? void 0 : l.defaultValue,
542
+ meta: w,
543
+ get: b,
544
+ getOrDefault: A,
545
+ set: (c) => {
546
+ t.setValue(s, c, {
507
547
  shouldDirty: !0,
508
548
  shouldTouch: !0,
509
549
  shouldValidate: !1
510
550
  });
511
551
  },
512
- validate: M
552
+ validate: R
513
553
  };
514
- return (T.Type === "Image" || T.Type === "File") && (T.Type === "Image" ? (y.upload = async (l) => {
515
- Y(l.name, "Image");
516
- const _ = w(), [g] = await r.getUploadUrl(
517
- _,
518
- n,
554
+ return (w.Type === "Image" || w.Type === "File") && (w.Type === "Image" ? (d.upload = async (c) => {
555
+ Y(c.name, "Image");
556
+ const h = y(), [f] = await r.getUploadUrl(
557
+ h,
558
+ s,
519
559
  [
520
560
  {
521
- FileName: l.name,
522
- Size: l.size,
523
- FileExtension: Q(l.name)
561
+ FileName: c.name,
562
+ Size: c.size,
563
+ FileExtension: Z(c.name)
524
564
  }
525
565
  ]
526
566
  );
527
- await fetch(g.UploadUrl.URL, {
567
+ await fetch(f.UploadUrl.URL, {
528
568
  method: "PUT",
529
- headers: { "Content-Type": g.ContentType },
530
- body: l
569
+ headers: { "Content-Type": f.ContentType },
570
+ body: c
531
571
  });
532
- const b = {
533
- _id: g._id,
534
- _name: g._name,
535
- FileName: g.FileName,
536
- FileExtension: g.FileExtension,
537
- Size: g.Size,
538
- ContentType: g.ContentType
572
+ const _ = {
573
+ _id: f._id,
574
+ _name: f._name,
575
+ FileName: f.FileName,
576
+ FileExtension: f.FileExtension,
577
+ Size: f.Size,
578
+ ContentType: f.ContentType
539
579
  };
540
- return t.setValue(n, b, {
580
+ return t.setValue(s, _, {
541
581
  shouldDirty: !0
542
- }), b;
543
- }, y.deleteAttachment = async () => {
544
- const l = t.getValues(
545
- n
546
- ), _ = w();
547
- if (!(l != null && l._id))
548
- throw new Error(`${n} has no image to delete`);
549
- await r.deleteAttachment(_, n, l._id), t.setValue(n, null, {
582
+ }), _;
583
+ }, d.deleteAttachment = async () => {
584
+ const c = t.getValues(
585
+ s
586
+ ), h = y();
587
+ if (!(c != null && c._id))
588
+ throw new Error(`${s} has no image to delete`);
589
+ await r.deleteAttachment(h, s, c._id), t.setValue(s, null, {
550
590
  shouldDirty: !0
551
591
  });
552
- }, y.getDownloadUrl = async (l) => {
553
- const _ = t.getValues(
554
- n
555
- ), g = w();
556
- if (!(_ != null && _._id))
557
- throw new Error(`${n} has no image`);
592
+ }, d.getDownloadUrl = async (c) => {
593
+ const h = t.getValues(
594
+ s
595
+ ), f = y();
596
+ if (!(h != null && h._id))
597
+ throw new Error(`${s} has no image`);
558
598
  return r.getDownloadUrl(
559
- g,
560
- n,
561
- _._id,
562
- l
599
+ f,
600
+ s,
601
+ h._id,
602
+ c
563
603
  );
564
- }) : (y.upload = async (l) => {
565
- for (const V of l)
566
- Y(V.name, "File");
567
- const _ = w(), g = l.map((V) => ({
568
- FileName: V.name,
569
- Size: V.size,
570
- FileExtension: Q(V.name)
571
- })), b = await r.getUploadUrl(
572
- _,
573
- n,
574
- g
575
- ), q = await Promise.all(
576
- l.map(async (V, x) => (await fetch(b[x].UploadUrl.URL, {
604
+ }) : (d.upload = async (c) => {
605
+ for (const O of c)
606
+ Y(O.name, "File");
607
+ const h = y(), f = c.map((O) => ({
608
+ FileName: O.name,
609
+ Size: O.size,
610
+ FileExtension: Z(O.name)
611
+ })), _ = await r.getUploadUrl(
612
+ h,
613
+ s,
614
+ f
615
+ ), M = await Promise.all(
616
+ c.map(async (O, k) => (await fetch(_[k].UploadUrl.URL, {
577
617
  method: "PUT",
578
618
  headers: {
579
- "Content-Type": b[x].ContentType
619
+ "Content-Type": _[k].ContentType
580
620
  },
581
- body: V
621
+ body: O
582
622
  }), {
583
- _id: b[x]._id,
584
- _name: b[x]._name,
585
- FileName: b[x].FileName,
586
- FileExtension: b[x].FileExtension,
587
- Size: b[x].Size,
588
- ContentType: b[x].ContentType
623
+ _id: _[k]._id,
624
+ _name: _[k]._name,
625
+ FileName: _[k].FileName,
626
+ FileExtension: _[k].FileExtension,
627
+ Size: _[k].Size,
628
+ ContentType: _[k].ContentType
589
629
  }))
590
- ), u = t.getValues(n) ?? [];
630
+ ), u = t.getValues(s) ?? [];
591
631
  return t.setValue(
592
- n,
593
- [...u, ...q],
632
+ s,
633
+ [...u, ...M],
594
634
  { shouldDirty: !0 }
595
- ), q;
596
- }, y.deleteAttachment = async (l) => {
597
- const _ = t.getValues(n) ?? [], g = w();
598
- await r.deleteAttachment(g, n, l), t.setValue(
599
- n,
600
- _.filter((b) => b._id !== l),
635
+ ), M;
636
+ }, d.deleteAttachment = async (c) => {
637
+ const h = t.getValues(s) ?? [], f = y();
638
+ await r.deleteAttachment(f, s, c), t.setValue(
639
+ s,
640
+ h.filter((_) => _._id !== c),
601
641
  { shouldDirty: !0 }
602
642
  );
603
- }, y.getDownloadUrl = async (l, _) => {
604
- const g = w();
643
+ }, d.getDownloadUrl = async (c, h) => {
644
+ const f = y();
605
645
  return r.getDownloadUrl(
606
- g,
607
- n,
608
- l,
609
- _
646
+ f,
647
+ s,
648
+ c,
649
+ h
610
650
  );
611
- }, y.getDownloadUrls = async (l) => {
612
- const _ = w();
613
- return r.getDownloadUrls(_, n, l);
614
- })), s.set(n, y), y;
651
+ }, d.getDownloadUrls = async (c) => {
652
+ const h = y();
653
+ return r.getDownloadUrls(h, s, c);
654
+ })), n.set(s, d), d;
615
655
  }
616
- const N = () => {
617
- const O = t.getValues(n);
618
- return T.Type === "File" ? O ?? [] : O;
619
- }, k = {
620
- label: (c == null ? void 0 : c.label) ?? n,
621
- required: (c == null ? void 0 : c.required) ?? !1,
656
+ const D = () => {
657
+ const b = t.getValues(s);
658
+ return w.Type === "File" ? b ?? [] : b;
659
+ }, V = {
660
+ label: (l == null ? void 0 : l.label) ?? s,
661
+ required: (l == null ? void 0 : l.required) ?? !1,
622
662
  readOnly: !0,
623
- defaultValue: c == null ? void 0 : c.defaultValue,
624
- meta: T,
625
- get: N,
626
- getOrDefault: E,
627
- validate: M
663
+ defaultValue: l == null ? void 0 : l.defaultValue,
664
+ meta: w,
665
+ get: D,
666
+ getOrDefault: A,
667
+ validate: R
628
668
  };
629
- return (T.Type === "Image" || T.Type === "File") && (T.Type === "Image" ? k.getDownloadUrl = async (O) => {
630
- const y = t.getValues(
631
- n
632
- ), l = w();
633
- if (!(y != null && y._id))
634
- throw new Error(`${n} has no image to download`);
669
+ return (w.Type === "Image" || w.Type === "File") && (w.Type === "Image" ? V.getDownloadUrl = async (b) => {
670
+ const d = t.getValues(
671
+ s
672
+ ), c = y();
673
+ if (!(d != null && d._id))
674
+ throw new Error(`${s} has no image to download`);
635
675
  return r.getDownloadUrl(
636
- l,
637
- n,
638
- y._id,
639
- O
676
+ c,
677
+ s,
678
+ d._id,
679
+ b
640
680
  );
641
- } : (k.getDownloadUrl = async (O, y) => {
642
- const l = w();
681
+ } : (V.getDownloadUrl = async (b, d) => {
682
+ const c = y();
643
683
  return r.getDownloadUrl(
644
- l,
645
- n,
646
- O,
647
- y
684
+ c,
685
+ s,
686
+ b,
687
+ d
648
688
  );
649
- }, k.getDownloadUrls = async (O) => {
650
- const y = w();
651
- return r.getDownloadUrls(y, n, O);
652
- })), s.set(n, k), k;
689
+ }, V.getDownloadUrls = async (b) => {
690
+ const d = y();
691
+ return r.getDownloadUrls(d, s, b);
692
+ })), n.set(s, V), V;
653
693
  },
654
- has(D, n) {
655
- return typeof n == "symbol" ? !1 : n === "_id" || n === "toJSON" || n === "validate" ? !0 : n in a;
694
+ has(m, s) {
695
+ return typeof s == "symbol" ? !1 : s === "_id" || s === "toJSON" || s === "validate" ? !0 : s in a;
656
696
  },
657
- ownKeys(D) {
697
+ ownKeys(m) {
658
698
  return [...Object.keys(a), "_id", "toJSON", "validate"];
659
699
  },
660
- getOwnPropertyDescriptor(D, n) {
661
- if (typeof n != "symbol")
700
+ getOwnPropertyDescriptor(m, s) {
701
+ if (typeof s != "symbol")
662
702
  return {
663
703
  configurable: !0,
664
- enumerable: n !== "toJSON" && n !== "validate"
704
+ enumerable: s !== "toJSON" && s !== "validate"
665
705
  };
666
706
  }
667
707
  }
668
708
  );
669
709
  }
670
- function W(i, t) {
671
- const e = i.meta.Type;
672
- if (typeof t == "string" && e === "Number")
673
- return t === "" ? void 0 : Number(t);
674
- if (!(typeof t == "string" && t === "" && (e === "Date" || e === "DateTime"))) {
675
- if (typeof t == "string" && t !== "" && e === "DateTime") {
676
- let a = t;
677
- return a.endsWith("Z") && (a = a.slice(0, -1)), ((a.split("T")[1] || "").match(/:/g) || []).length === 1 && (a += ":00"), a + "Z";
678
- }
679
- return t;
680
- }
681
- }
682
- function pe(i, t) {
683
- var a;
684
- const e = { ...t };
685
- for (const [s, o] of Object.entries(e))
686
- typeof o == "string" && ((a = i[s]) == null ? void 0 : a.meta.Type) === "DateTime" && o.endsWith("Z") && (e[s] = o.slice(0, -1));
687
- return e;
688
- }
689
- function ze(i, t) {
710
+ function Ke(o, t) {
690
711
  const {
691
712
  activity_instance_id: e,
692
713
  defaultValues: a = {},
693
- mode: s = "onBlur",
694
- enabled: o = !0
695
- } = t, [r, w] = G(!1), [D, n] = G(null), [c, T] = G(!1), [L, M] = G({}), E = H(!1), N = H(null), { data: k, isLoading: O } = be({
696
- queryKey: ["bp-metadata", i.meta.businessProcessId],
697
- queryFn: () => $e(i.meta.businessProcessId),
714
+ mode: n = "onBlur",
715
+ enabled: i = !0
716
+ } = t, [r, y] = z(!1), [m, s] = z(null), [l, w] = z(!1), [B, R] = z({}), A = W(!1), D = W(null), { data: V, isLoading: b } = pe({
717
+ queryKey: ["bp-metadata", o.meta.businessProcessId],
718
+ queryFn: () => Ve(o.meta.businessProcessId),
698
719
  staleTime: 30 * 60 * 1e3
699
- }), y = p(() => {
700
- const f = k == null ? void 0 : k.BDOBlob;
701
- return f != null && f.Activity ? f.Activity.find(
702
- (d) => d.Id === i.meta.activityId
720
+ }), d = P(() => {
721
+ const g = V == null ? void 0 : V.BDOBlob;
722
+ return g != null && g.Activity ? g.Activity.find(
723
+ (T) => T.Id === o.meta.activityId
703
724
  ) ?? null : null;
704
- }, [k, i.meta.activityId]), l = O, _ = p(() => y != null && y.Input ? Oe(y.Input) : i._getFields(), [y, i]), g = p(
725
+ }, [V, o.meta.activityId]), c = b, h = P(() => d != null && d.Input ? je(d.Input) : o._getFields(), [d, o]), f = P(
705
726
  () => ({
706
- ...L,
727
+ ...B,
707
728
  // readonly fields from other activities
708
- ..._
729
+ ...h
709
730
  // Input fields (editable + readonly)
710
731
  }),
711
- [L, _]
712
- ), b = p(
713
- () => Object.keys(g).filter((f) => g[f].readOnly),
714
- [g]
715
- ), q = p(
716
- () => Pe(_),
717
- [_]
718
- ), u = ve({
719
- mode: s,
732
+ [B, h]
733
+ ), _ = P(
734
+ () => Object.keys(f).filter((g) => f[g].readOnly),
735
+ [f]
736
+ ), M = P(
737
+ () => Ue(h),
738
+ [h]
739
+ ), u = Oe({
740
+ mode: n,
720
741
  defaultValues: a,
721
- resolver: q
722
- }), V = p(() => i._getOps(), [i]), x = p(
723
- () => je(i, u, e),
724
- [i, u, e]
742
+ resolver: M
743
+ }), O = P(() => o._getOps(), [o]), k = P(
744
+ () => Ie(o, u, e),
745
+ [o, u, e]
725
746
  );
726
747
  Te(() => {
727
- if (!o || l) return;
728
- let f = !0;
748
+ if (!i || c) return;
749
+ let g = !0;
729
750
  return (async () => {
730
- w(!0), n(null);
751
+ y(!0), s(null);
731
752
  try {
732
- const m = await V.read(e);
733
- if (!f) return;
734
- if (m && typeof m == "object") {
735
- const v = pe(
736
- _,
737
- m
738
- ), S = { ...a, ...v };
739
- (N.current === null || m !== N.current) && (u.reset(S), N.current = m);
740
- const $ = /* @__PURE__ */ new Set([
753
+ const F = await O.read(e);
754
+ if (!g) return;
755
+ if (F && typeof F == "object") {
756
+ const x = Ce(
757
+ h,
758
+ F
759
+ ), C = { ...a, ...x };
760
+ (D.current === null || F !== D.current) && (u.reset(C), D.current = F);
761
+ const U = /* @__PURE__ */ new Set([
741
762
  "_id",
742
763
  "BPInstanceId",
743
764
  "Status",
@@ -749,239 +770,175 @@ function ze(i, t) {
749
770
  "_modified_by",
750
771
  "_v",
751
772
  "_m_v"
752
- ]), F = {};
753
- for (const C of Object.keys(m))
754
- if (!_[C] && !$.has(C)) {
755
- const h = ke(
756
- y,
757
- k,
758
- C
773
+ ]), j = {};
774
+ for (const p of Object.keys(F))
775
+ if (!h[p] && !U.has(p)) {
776
+ const v = De(
777
+ d,
778
+ V,
779
+ p
759
780
  );
760
- h && (F[C] = X(C, {
761
- ...h,
781
+ v && (j[p] = ee(p, {
782
+ ...v,
762
783
  ReadOnly: !0
763
784
  }));
764
785
  }
765
- Object.keys(F).length > 0 && M(F);
786
+ Object.keys(j).length > 0 && R(j);
766
787
  }
767
- } catch (m) {
768
- if (!f) return;
769
- console.error("Failed to read activity data:", m), n(K(m));
788
+ } catch (F) {
789
+ if (!g) return;
790
+ console.error("Failed to read activity data:", F), s(K(F));
770
791
  } finally {
771
- f && w(!1);
792
+ g && y(!1);
772
793
  }
773
794
  })(), () => {
774
- f = !1;
795
+ g = !1;
775
796
  };
776
- }, [o, l, V, e]);
777
- const U = B(
778
- async (f) => {
779
- if (!E.current) {
780
- E.current = !0;
781
- try {
782
- if (!await u.trigger(f)) return;
783
- const m = u.getValues(f), v = g[f], S = v ? W(v, m) : m, $ = await V.update(e, {
784
- [f]: S
785
- });
786
- if (u.resetField(f, {
787
- defaultValue: m,
788
- keepTouched: !0,
789
- keepError: !0
790
- }), $ && typeof $ == "object") {
791
- const F = $.Data ?? $;
792
- if (F && typeof F == "object") {
793
- const C = new Set(b);
794
- for (const h of Object.keys(F))
795
- C.has(h) && F[h] !== void 0 && u.getValues(h) !== F[h] && u.setValue(
796
- h,
797
- F[h],
798
- { shouldDirty: !1, shouldValidate: !1 }
799
- );
800
- }
801
- }
802
- } catch (d) {
803
- console.warn("syncField failed:", d);
804
- } finally {
805
- E.current = !1;
806
- }
807
- }
808
- },
809
- [V, b, g, u, e]
810
- ), J = s === "onChange" || s === "all", z = s === "onBlur" || s === "onTouched" || s === "all", ee = B(
811
- (f, d) => {
812
- const m = g[f], v = m ? m.readOnly : !1, S = u.register(f, {
813
- ...d,
814
- ...z ? {
815
- onBlur: async ($) => {
816
- var F;
817
- await ((F = d == null ? void 0 : d.onBlur) == null ? void 0 : F.call(d, $)), await U(f);
818
- }
819
- } : {},
820
- ...J ? {
821
- onChange: async ($) => {
822
- var F;
823
- await ((F = d == null ? void 0 : d.onChange) == null ? void 0 : F.call(d, $)), await U(f);
824
- }
825
- } : {},
826
- ...v ? { disabled: !0 } : {}
827
- });
828
- return v ? { ...S, disabled: !0 } : S;
829
- },
830
- [u, g, U, z, J]
831
- ), te = p(
832
- () => new Proxy(u.control, {
833
- get(f, d, m) {
834
- return d === "register" ? (v, S) => {
835
- const $ = f.register(v, S), F = $.onChange, C = $.onBlur;
836
- return {
837
- ...$,
838
- ...J ? {
839
- onChange: async (h) => {
840
- await F(h), await U(v);
841
- }
842
- } : {},
843
- ...z ? {
844
- onBlur: async (h) => {
845
- await C(h), await U(v);
846
- }
847
- } : {}
848
- };
849
- } : Reflect.get(f, d, m);
850
- }
797
+ }, [i, c, O, e]);
798
+ const H = G(
799
+ (g, T) => O.update(e, {
800
+ [g]: T
801
+ }),
802
+ [O, e]
803
+ ), J = P(
804
+ () => be({
805
+ apiFn: H,
806
+ allFields: f,
807
+ readonlyFieldNames: _,
808
+ rhf: u,
809
+ isComputingRef: A
810
+ }),
811
+ [H, f, _, u]
812
+ ), q = n === "onChange" || n === "all", L = n === "onBlur" || n === "onTouched" || n === "all", te = P(
813
+ () => Se({
814
+ rhf: u,
815
+ allFields: f,
816
+ syncField: J,
817
+ syncOnBlur: L,
818
+ syncOnChange: q
819
+ }),
820
+ [u, f, J, L, q]
821
+ ), se = P(
822
+ () => $e({
823
+ control: u.control,
824
+ syncField: J,
825
+ syncOnBlur: L,
826
+ syncOnChange: q
851
827
  }),
852
- [u.control, U, J, z]
853
- ), se = B(
854
- (f, d) => u.handleSubmit(
855
- async (m, v) => {
856
- T(!0);
828
+ [u.control, J, L, q]
829
+ ), ae = G(
830
+ (g, T) => u.handleSubmit(
831
+ async (F, x) => {
832
+ w(!0);
857
833
  try {
858
- const S = {}, $ = new Set(b), F = u.formState.dirtyFields, C = u.getValues();
859
- for (const h of Object.keys(C)) {
860
- if ($.has(h) || !F[h]) continue;
861
- const A = C[h] !== void 0 ? C[h] : m[h], R = g[h];
862
- S[h] = R ? W(R, A) : A;
834
+ const C = {}, U = new Set(_), j = u.formState.dirtyFields, p = u.getValues();
835
+ for (const v of Object.keys(p)) {
836
+ if (U.has(v) || !j[v]) continue;
837
+ const I = p[v] !== void 0 ? p[v] : F[v], E = f[v];
838
+ C[v] = E ? X(E, I) : I;
863
839
  }
864
- Object.keys(S).length > 0 && await V.update(
840
+ Object.keys(C).length > 0 && await O.update(
865
841
  e,
866
- S
867
- ), await (f == null ? void 0 : f(m, v));
868
- } catch (S) {
869
- d == null || d(K(S), v);
842
+ C
843
+ ), await (g == null ? void 0 : g(F, x));
844
+ } catch (C) {
845
+ T == null || T(K(C), x);
870
846
  } finally {
871
- T(!1);
847
+ w(!1);
872
848
  }
873
849
  },
874
- (m, v) => {
875
- d == null || d(m, v);
850
+ (F, x) => {
851
+ T == null || T(F, x);
876
852
  }
877
853
  ),
878
- [u, V, b, g, e]
879
- ), ae = B(
880
- (f, d) => u.handleSubmit(
881
- async (m, v) => {
882
- T(!0);
854
+ [u, O, _, f, e]
855
+ ), ne = G(
856
+ (g, T) => u.handleSubmit(
857
+ async (F, x) => {
858
+ w(!0);
883
859
  try {
884
- const S = {}, $ = new Set(b), F = u.formState.dirtyFields, C = u.getValues();
885
- for (const h of Object.keys(C)) {
886
- if ($.has(h) || !F[h]) continue;
887
- const A = C[h] !== void 0 ? C[h] : m[h], R = g[h];
888
- S[h] = R ? W(R, A) : A;
860
+ const C = {}, U = new Set(_), j = u.formState.dirtyFields, p = u.getValues();
861
+ for (const v of Object.keys(p)) {
862
+ if (U.has(v) || !j[v]) continue;
863
+ const I = p[v] !== void 0 ? p[v] : F[v], E = f[v];
864
+ C[v] = E ? X(E, I) : I;
889
865
  }
890
- Object.keys(S).length > 0 && await V.update(
866
+ Object.keys(C).length > 0 && await O.update(
891
867
  e,
892
- S
893
- ), await V.complete(e), await (f == null ? void 0 : f(m, v));
894
- } catch (S) {
895
- d == null || d(K(S), v);
868
+ C
869
+ ), await O.complete(e), await (g == null ? void 0 : g(F, x));
870
+ } catch (C) {
871
+ T == null || T(K(C), x);
896
872
  } finally {
897
- T(!1);
873
+ w(!1);
898
874
  }
899
875
  },
900
- (m, v) => {
901
- d == null || d(m, v);
876
+ (F, x) => {
877
+ T == null || T(F, x);
902
878
  }
903
879
  ),
904
- [u, V, b, g, e]
905
- ), ne = B(() => {
880
+ [u, O, _, f, e]
881
+ ), re = G(() => {
906
882
  u.clearErrors();
907
- }, [u]), re = !!D;
883
+ }, [u]), ie = !!m;
908
884
  return {
909
885
  // Item proxy
910
- item: x,
886
+ item: k,
911
887
  // Activity reference
912
- activity: i,
888
+ activity: o,
913
889
  // Form methods
914
- register: ee,
915
- handleSubmit: se,
916
- handleComplete: ae,
890
+ register: te,
891
+ handleSubmit: ae,
892
+ handleComplete: ne,
917
893
  watch: u.watch,
918
894
  setValue: u.setValue,
919
895
  getValues: u.getValues,
920
896
  reset: u.reset,
921
897
  trigger: u.trigger,
922
- control: te,
898
+ control: se,
923
899
  // Flattened form state
924
900
  errors: u.formState.errors,
925
901
  isValid: u.formState.isValid,
926
902
  isDirty: u.formState.isDirty,
927
- isSubmitting: u.formState.isSubmitting || c,
903
+ isSubmitting: u.formState.isSubmitting || l,
928
904
  isSubmitSuccessful: u.formState.isSubmitSuccessful,
929
905
  // Loading
930
- isLoading: r || l,
931
- isMetadataLoading: l,
932
- loadError: D,
933
- hasError: re,
906
+ isLoading: r || c,
907
+ isMetadataLoading: c,
908
+ loadError: m,
909
+ hasError: ie,
934
910
  // Metadata
935
- bpMetadata: k ?? null,
911
+ bpMetadata: V ?? null,
936
912
  // Operations
937
- clearErrors: ne
913
+ clearErrors: re
938
914
  };
939
915
  }
940
- const xe = /* @__PURE__ */ new Set([
941
- "_id",
942
- "BPInstanceId",
943
- "Status",
944
- "AssignedTo",
945
- "CompletedAt"
946
- ]);
947
- function Ie(i) {
948
- const t = {}, e = {};
949
- for (const [a, s] of Object.entries(i))
950
- xe.has(a) ? t[a] = s : e[a] = s;
951
- return t.ADO = e, t;
952
- }
953
- function Ge(i, t) {
954
- const { status: e, ...a } = t, { businessProcessId: s, activityId: o } = i.meta, r = p(() => i._getOps(), [i]), w = p(() => {
955
- const n = e === "inprogress" ? (c) => r.inProgressList(c) : (c) => r.completedList(c);
956
- return async (c) => {
957
- const T = await n(c);
958
- return {
959
- ...T,
960
- Data: T.Data.map(Ie)
961
- };
962
- };
963
- }, [r, e]), D = p(
964
- () => e === "inprogress" ? (n) => r.inProgressMetric(n) : (n) => r.completedMetric(n),
916
+ function He(o) {
917
+ const { activity: t, status: e, ...a } = o, { businessProcessId: n, activityId: i } = t.meta, r = P(() => t._getOps(), [t]), y = P(
918
+ () => e === "inprogress" ? (s) => r.inProgressList(s) : (s) => r.completedList(s),
919
+ [r, e]
920
+ ), m = P(
921
+ () => e === "inprogress" ? (s) => r.inProgressCount(s) : (s) => r.completedCount(s),
965
922
  [r, e]
966
923
  );
967
- return Se({
968
- queryKey: ["activity-table", s, o, e],
969
- listFn: w,
970
- countFn: D,
924
+ return Pe({
925
+ queryKey: ["activity-table", n, i, e],
926
+ listFn: y,
927
+ countFn: m,
971
928
  ...a
972
929
  });
973
930
  }
974
- const Ke = {
931
+ const Qe = {
975
932
  InProgress: "inprogress",
976
933
  Completed: "completed"
977
934
  };
978
935
  export {
979
- Je as Activity,
980
- Ce as ActivityInstance,
981
- Ke as ActivityTableStatus,
982
- Ve as Workflow,
983
- Oe as buildFieldsFromInput,
984
- X as createFieldFromMeta,
985
- ze as useActivityForm,
986
- Ge as useActivityTable
936
+ Ge as Activity,
937
+ ke as ActivityInstance,
938
+ Qe as ActivityTableStatus,
939
+ xe as Workflow,
940
+ je as buildFieldsFromInput,
941
+ ee as createFieldFromMeta,
942
+ Ke as useActivityForm,
943
+ He as useActivityTable
987
944
  };