@ram_28/kf-ai-sdk 2.0.10 → 2.0.12

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/workflow.mjs CHANGED
@@ -1,14 +1,15 @@
1
- var G = Object.defineProperty;
2
- var H = (o, e, t) => e in o ? G(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var b = (o, e, t) => H(o, typeof e != "symbol" ? e + "" : e, t);
4
- import { c as y, g } from "./client-CMERmrC-.js";
5
- import { B as K } from "./BaseField-B6da88U7.js";
6
- import { useState as k, useRef as A, useMemo as p, useEffect as U, useCallback as j } from "react";
1
+ var K = Object.defineProperty;
2
+ var H = (o, e, t) => e in o ? K(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var p = (o, e, t) => H(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { c as g, g as m } from "./client-CMERmrC-.js";
5
+ import { B as Q } from "./BaseField-B6da88U7.js";
6
+ import { useState as L, useRef as A, useMemo as P, useEffect as U, useCallback as C } from "react";
7
7
  import { u as W } from "./index.esm-Cj63v5ny.js";
8
- import { t as C } from "./error-handling-CrhTtD88.js";
8
+ import { t as x } from "./error-handling-CrhTtD88.js";
9
+ import { useQuery as M } from "@tanstack/react-query";
9
10
  class z {
10
11
  constructor(e) {
11
- b(this, "bp_id");
12
+ p(this, "bp_id");
12
13
  this.bp_id = e;
13
14
  }
14
15
  /**
@@ -16,10 +17,10 @@ class z {
16
17
  */
17
18
  async start() {
18
19
  const e = await fetch(
19
- `${y()}/api/app/process/${this.bp_id}/start`,
20
+ `${g()}/api/app/process/${this.bp_id}/start`,
20
21
  {
21
22
  method: "POST",
22
- headers: g()
23
+ headers: m()
23
24
  }
24
25
  );
25
26
  if (!e.ok)
@@ -34,10 +35,10 @@ class z {
34
35
  */
35
36
  async progress(e) {
36
37
  const t = await fetch(
37
- `${y()}/api/app/process/${this.bp_id}/${e}/progress`,
38
+ `${g()}/api/app/process/${this.bp_id}/${e}/progress`,
38
39
  {
39
40
  method: "GET",
40
- headers: g()
41
+ headers: m()
41
42
  }
42
43
  );
43
44
  if (!t.ok)
@@ -53,94 +54,94 @@ class z {
53
54
  return {
54
55
  // ── List-level ────────────────────────────────────────────
55
56
  async inProgressList() {
56
- const r = await fetch(`${y()}${t}/inprogress/list`, {
57
+ const a = await fetch(`${g()}${t}/inprogress/list`, {
57
58
  method: "GET",
58
- headers: g()
59
+ headers: m()
59
60
  });
60
- if (!r.ok)
61
- throw new Error(`Failed to list in-progress activities: ${r.statusText}`);
62
- return r.json();
61
+ if (!a.ok)
62
+ throw new Error(`Failed to list in-progress activities: ${a.statusText}`);
63
+ return a.json();
63
64
  },
64
65
  async completedList() {
65
- const r = await fetch(`${y()}${t}/completed/list`, {
66
+ const a = await fetch(`${g()}${t}/completed/list`, {
66
67
  method: "GET",
67
- headers: g()
68
+ headers: m()
68
69
  });
69
- if (!r.ok)
70
- throw new Error(`Failed to list completed activities: ${r.statusText}`);
71
- return r.json();
70
+ if (!a.ok)
71
+ throw new Error(`Failed to list completed activities: ${a.statusText}`);
72
+ return a.json();
72
73
  },
73
74
  async inProgressMetric() {
74
- const r = await fetch(`${y()}${t}/inprogress/metric`, {
75
+ const a = await fetch(`${g()}${t}/inprogress/metric`, {
75
76
  method: "GET",
76
- headers: g()
77
+ headers: m()
77
78
  });
78
- if (!r.ok)
79
- throw new Error(`Failed to get in-progress activity metrics: ${r.statusText}`);
80
- return r.json();
79
+ if (!a.ok)
80
+ throw new Error(`Failed to get in-progress activity metrics: ${a.statusText}`);
81
+ return a.json();
81
82
  },
82
83
  async completedMetric() {
83
- const r = await fetch(`${y()}${t}/completed/metric`, {
84
+ const a = await fetch(`${g()}${t}/completed/metric`, {
84
85
  method: "GET",
85
- headers: g()
86
+ headers: m()
86
87
  });
87
- if (!r.ok)
88
- throw new Error(`Failed to get completed activity metrics: ${r.statusText}`);
89
- return r.json();
88
+ if (!a.ok)
89
+ throw new Error(`Failed to get completed activity metrics: ${a.statusText}`);
90
+ return a.json();
90
91
  },
91
92
  // ── Instance-level ────────────────────────────────────────
92
- async read(r) {
93
- const s = await fetch(`${y()}${t}/${r}/read`, {
93
+ async read(a) {
94
+ const s = await fetch(`${g()}${t}/${a}/read`, {
94
95
  method: "GET",
95
- headers: g()
96
+ headers: m()
96
97
  });
97
98
  if (!s.ok)
98
99
  throw new Error(`Failed to read activity: ${s.statusText}`);
99
100
  return (await s.json()).Data;
100
101
  },
101
- async update(r, s) {
102
- const a = await fetch(`${y()}${t}/${r}/update`, {
102
+ async update(a, s) {
103
+ const r = await fetch(`${g()}${t}/${a}/update`, {
103
104
  method: "POST",
104
- headers: g(),
105
+ headers: m(),
105
106
  body: JSON.stringify(s)
106
107
  });
107
- if (!a.ok)
108
- throw new Error(`Failed to update activity: ${a.statusText}`);
109
- return a.json();
108
+ if (!r.ok)
109
+ throw new Error(`Failed to update activity: ${r.statusText}`);
110
+ return r.json();
110
111
  },
111
- async draftStart(r, s) {
112
- const a = await fetch(`${y()}${t}/${r}/draft`, {
112
+ async draftStart(a, s) {
113
+ const r = await fetch(`${g()}${t}/${a}/draft`, {
113
114
  method: "PATCH",
114
- headers: g(),
115
+ headers: m(),
115
116
  body: JSON.stringify(s)
116
117
  });
117
- if (!a.ok)
118
- throw new Error(`Failed to start draft: ${a.statusText}`);
119
- return a.json();
118
+ if (!r.ok)
119
+ throw new Error(`Failed to start draft: ${r.statusText}`);
120
+ return r.json();
120
121
  },
121
- async draftEnd(r, s) {
122
- const a = await fetch(`${y()}${t}/${r}/draft`, {
122
+ async draftEnd(a, s) {
123
+ const r = await fetch(`${g()}${t}/${a}/draft`, {
123
124
  method: "POST",
124
- headers: g(),
125
+ headers: m(),
125
126
  body: JSON.stringify(s)
126
127
  });
127
- if (!a.ok)
128
- throw new Error(`Failed to end draft: ${a.statusText}`);
129
- return a.json();
128
+ if (!r.ok)
129
+ throw new Error(`Failed to end draft: ${r.statusText}`);
130
+ return r.json();
130
131
  },
131
- async complete(r) {
132
- const s = await fetch(`${y()}${t}/${r}/done`, {
132
+ async complete(a) {
133
+ const s = await fetch(`${g()}${t}/${a}/done`, {
133
134
  method: "POST",
134
- headers: g()
135
+ headers: m()
135
136
  });
136
137
  if (!s.ok)
137
138
  throw new Error(`Failed to complete activity: ${s.statusText}`);
138
139
  return s.json();
139
140
  },
140
- async progress(r) {
141
- const s = await fetch(`${y()}${t}/${r}/progress`, {
141
+ async progress(a) {
142
+ const s = await fetch(`${g()}${t}/${a}/progress`, {
142
143
  method: "GET",
143
- headers: g()
144
+ headers: m()
144
145
  });
145
146
  if (!s.ok)
146
147
  throw new Error(`Failed to get activity progress: ${s.statusText}`);
@@ -149,14 +150,14 @@ class z {
149
150
  };
150
151
  }
151
152
  }
152
- class Q {
153
- constructor(e, t, r, s) {
154
- b(this, "_id");
155
- b(this, "_data");
156
- b(this, "_ops");
157
- b(this, "_fields");
158
- b(this, "_accessorCache", /* @__PURE__ */ new Map());
159
- this._ops = e, this._id = t, this._data = { ...r }, this._fields = s;
153
+ class X {
154
+ constructor(e, t, a, s) {
155
+ p(this, "_id");
156
+ p(this, "_data");
157
+ p(this, "_ops");
158
+ p(this, "_fields");
159
+ p(this, "_accessorCache", /* @__PURE__ */ new Map());
160
+ this._ops = e, this._id = t, this._data = { ...a }, this._fields = s;
160
161
  }
161
162
  // ============================================================
162
163
  // BDO ITEM METHODS
@@ -172,9 +173,9 @@ class Q {
172
173
  */
173
174
  validate() {
174
175
  const e = [];
175
- for (const [t, r] of Object.entries(this._fields)) {
176
- const s = this._data[t], a = r.validate(s);
177
- a.valid || e.push(...a.errors);
176
+ for (const [t, a] of Object.entries(this._fields)) {
177
+ const s = this._data[t], r = a.validate(s);
178
+ r.valid || e.push(...r.errors);
178
179
  }
179
180
  return {
180
181
  valid: e.length === 0,
@@ -215,51 +216,51 @@ class Q {
215
216
  _getAccessor(e) {
216
217
  if (this._accessorCache.has(e))
217
218
  return this._accessorCache.get(e);
218
- const t = this._fields[e], r = (t == null ? void 0 : t.meta) ?? {
219
+ const t = this._fields[e], a = (t == null ? void 0 : t.meta) ?? {
219
220
  _id: e,
220
221
  Name: e,
221
222
  Type: "String"
222
- }, s = (t == null ? void 0 : t.readOnly) ?? !1, a = () => t ? t.validate(this._data[e]) : { valid: !0, errors: [] };
223
+ }, s = (t == null ? void 0 : t.readOnly) ?? !1, r = () => t ? t.validate(this._data[e]) : { valid: !0, errors: [] };
223
224
  let i;
224
225
  return s ? i = {
225
226
  label: (t == null ? void 0 : t.label) ?? e,
226
227
  required: (t == null ? void 0 : t.required) ?? !1,
227
228
  readOnly: !0,
228
229
  defaultValue: t == null ? void 0 : t.defaultValue,
229
- meta: r,
230
+ meta: a,
230
231
  get: () => this._data[e],
231
- validate: a
232
+ validate: r
232
233
  } : i = {
233
234
  label: (t == null ? void 0 : t.label) ?? e,
234
235
  required: (t == null ? void 0 : t.required) ?? !1,
235
236
  readOnly: !1,
236
237
  defaultValue: t == null ? void 0 : t.defaultValue,
237
- meta: r,
238
+ meta: a,
238
239
  get: () => this._data[e],
239
- set: (f) => {
240
- this._data[e] = f;
240
+ set: (d) => {
241
+ this._data[e] = d;
241
242
  },
242
- validate: a
243
+ validate: r
243
244
  }, this._accessorCache.set(e, i), i;
244
245
  }
245
246
  }
246
- function X(o, e, t, r) {
247
- const s = new Q(
247
+ function Y(o, e, t, a) {
248
+ const s = new X(
248
249
  o,
249
250
  e,
250
251
  t,
251
- r
252
+ a
252
253
  );
253
254
  return new Proxy(s, {
254
- get(a, i, f) {
255
- return i === "validate" || i === "toJSON" || i === "update" || i === "save" || i === "complete" || i === "progress" || i === "_ops" || i === "_data" || i === "_fields" || i === "_accessorCache" || i === "_getAccessor" || typeof i == "symbol" ? Reflect.get(a, i, f) : i === "_id" ? a._id : a._getAccessor(i);
255
+ get(r, i, d) {
256
+ return i === "validate" || i === "toJSON" || i === "update" || i === "save" || i === "complete" || i === "progress" || i === "_ops" || i === "_data" || i === "_fields" || i === "_accessorCache" || i === "_getAccessor" || typeof i == "symbol" ? Reflect.get(r, i, d) : i === "_id" ? r._id : r._getAccessor(i);
256
257
  },
257
- has(a, i) {
258
- return typeof i == "symbol" ? !1 : i === "validate" || i === "toJSON" || i === "update" || i === "save" || i === "complete" || i === "progress" || i === "_id" ? !0 : i in a._fields;
258
+ has(r, i) {
259
+ return typeof i == "symbol" ? !1 : i === "validate" || i === "toJSON" || i === "update" || i === "save" || i === "complete" || i === "progress" || i === "_id" ? !0 : i in r._fields;
259
260
  },
260
- ownKeys(a) {
261
+ ownKeys(r) {
261
262
  return [
262
- ...Object.keys(a._fields),
263
+ ...Object.keys(r._fields),
263
264
  "_id",
264
265
  "validate",
265
266
  "toJSON",
@@ -269,7 +270,7 @@ function X(o, e, t, r) {
269
270
  "progress"
270
271
  ];
271
272
  },
272
- getOwnPropertyDescriptor(a, i) {
273
+ getOwnPropertyDescriptor(r, i) {
273
274
  if (typeof i != "symbol")
274
275
  return {
275
276
  configurable: !0,
@@ -278,12 +279,12 @@ function X(o, e, t, r) {
278
279
  }
279
280
  });
280
281
  }
281
- class ot {
282
+ class ut {
282
283
  constructor() {
283
284
  // ============================================================
284
285
  // FIELD DISCOVERY (internal)
285
286
  // ============================================================
286
- b(this, "_fieldsCache", null);
287
+ p(this, "_fieldsCache", null);
287
288
  }
288
289
  // ============================================================
289
290
  // ACTIVITY OPERATIONS (internal)
@@ -303,8 +304,8 @@ class ot {
303
304
  if (this._fieldsCache) return this._fieldsCache;
304
305
  const e = {};
305
306
  for (const t of Object.keys(this)) {
306
- const r = this[t];
307
- r instanceof K && (e[t] = r);
307
+ const a = this[t];
308
+ a instanceof Q && (e[t] = a);
308
309
  }
309
310
  return this._fieldsCache = e, e;
310
311
  }
@@ -344,11 +345,11 @@ class ot {
344
345
  * @returns ActivityInstance with typed field accessors
345
346
  */
346
347
  async getInstance(e) {
347
- const t = this._ops(), r = await t.read(e), s = this._discoverFields();
348
- return X(
348
+ const t = this._ops(), a = await t.read(e), s = this._discoverFields();
349
+ return Y(
349
350
  t,
350
351
  e,
351
- r,
352
+ a,
352
353
  s
353
354
  );
354
355
  }
@@ -370,72 +371,72 @@ class ot {
370
371
  return this._ops();
371
372
  }
372
373
  }
373
- function Y(o) {
374
- return async (e, t, r) => {
375
- const s = {}, a = o._getFields(), i = (r == null ? void 0 : r.names) ?? Object.keys(a);
376
- for (const f of i) {
377
- const w = a[f];
378
- if (!w || w.readOnly) continue;
379
- const S = e[f], $ = w.validate(S);
380
- !$.valid && $.errors.length > 0 && (s[f] = {
374
+ function Z(o) {
375
+ return async (e, t, a) => {
376
+ const s = {}, r = o._getFields(), i = (a == null ? void 0 : a.names) ?? Object.keys(r);
377
+ for (const d of i) {
378
+ const _ = r[d];
379
+ if (!_ || _.readOnly) continue;
380
+ const V = e[d], w = _.validate(V);
381
+ !w.valid && w.errors.length > 0 && (s[d] = {
381
382
  type: "validate",
382
- message: $.errors[0] || `${f} is invalid`
383
+ message: w.errors[0] || `${d} is invalid`
383
384
  });
384
385
  }
385
386
  return Object.keys(s).length === 0 ? { values: e, errors: {} } : { values: {}, errors: s };
386
387
  };
387
388
  }
388
- function Z(o, e) {
389
+ function tt(o, e) {
389
390
  const t = o._getFields();
390
391
  return new Proxy(
391
392
  {},
392
393
  {
393
- get(r, s) {
394
+ get(a, s) {
394
395
  if (typeof s == "symbol")
395
396
  return;
396
397
  if (s === "toJSON")
397
398
  return () => e.getValues();
398
399
  if (s === "validate")
399
400
  return () => e.trigger();
400
- const a = t[s], i = (a == null ? void 0 : a.meta) ?? {
401
+ const r = t[s], i = (r == null ? void 0 : r.meta) ?? {
401
402
  _id: s,
402
403
  Name: s,
403
404
  Type: "String"
404
- }, f = (a == null ? void 0 : a.readOnly) ?? !1, w = () => a ? a.validate(e.getValues(s)) : { valid: !0, errors: [] };
405
- return f ? {
406
- label: (a == null ? void 0 : a.label) ?? s,
407
- required: (a == null ? void 0 : a.required) ?? !1,
405
+ }, d = (r == null ? void 0 : r.readOnly) ?? !1, _ = () => r ? r.validate(e.getValues(s)) : { valid: !0, errors: [] };
406
+ return d ? {
407
+ label: (r == null ? void 0 : r.label) ?? s,
408
+ required: (r == null ? void 0 : r.required) ?? !1,
408
409
  readOnly: !0,
409
- defaultValue: a == null ? void 0 : a.defaultValue,
410
+ defaultValue: r == null ? void 0 : r.defaultValue,
410
411
  meta: i,
411
412
  get: () => e.getValues(s),
412
- getOrDefault: ($) => e.getValues(s) ?? $,
413
- validate: w
413
+ getOrDefault: (w) => e.getValues(s) ?? w,
414
+ validate: _
414
415
  } : {
415
- label: (a == null ? void 0 : a.label) ?? s,
416
- required: (a == null ? void 0 : a.required) ?? !1,
416
+ label: (r == null ? void 0 : r.label) ?? s,
417
+ required: (r == null ? void 0 : r.required) ?? !1,
417
418
  readOnly: !1,
418
- defaultValue: a == null ? void 0 : a.defaultValue,
419
+ defaultValue: r == null ? void 0 : r.defaultValue,
419
420
  meta: i,
420
421
  get: () => e.getValues(s),
421
- getOrDefault: (O) => e.getValues(s) ?? O,
422
- set: (O) => {
423
- e.setValue(s, O, {
422
+ getOrDefault: (v) => e.getValues(s) ?? v,
423
+ set: (v) => {
424
+ e.setValue(s, v, {
424
425
  shouldDirty: !0,
425
426
  shouldTouch: !0,
426
427
  shouldValidate: !1
427
428
  });
428
429
  },
429
- validate: w
430
+ validate: _
430
431
  };
431
432
  },
432
- has(r, s) {
433
+ has(a, s) {
433
434
  return typeof s == "symbol" ? !1 : s === "toJSON" || s === "validate" ? !0 : s in t;
434
435
  },
435
- ownKeys(r) {
436
+ ownKeys(a) {
436
437
  return [...Object.keys(t), "toJSON", "validate"];
437
438
  },
438
- getOwnPropertyDescriptor(r, s) {
439
+ getOwnPropertyDescriptor(a, s) {
439
440
  if (typeof s != "symbol")
440
441
  return {
441
442
  configurable: !0,
@@ -445,66 +446,66 @@ function Z(o, e) {
445
446
  }
446
447
  );
447
448
  }
448
- function ct(o, e) {
449
+ function dt(o, e) {
449
450
  const {
450
451
  activity_instance_id: t,
451
- defaultValues: r = {},
452
+ defaultValues: a = {},
452
453
  mode: s = "onBlur",
453
- enabled: a = !0
454
- } = e, [i, f] = k(!1), [w, S] = k(null), [$, O] = k(!1), x = A(!1), N = A(null), T = p(
454
+ enabled: r = !0
455
+ } = e, [i, d] = L(!1), [_, V] = L(null), [w, v] = L(!1), T = A(!1), E = A(null), j = P(
455
456
  () => o._getFields(),
456
457
  [o]
457
- ), V = p(
458
- () => Object.keys(T).filter(
459
- (u) => T[u].readOnly
458
+ ), S = P(
459
+ () => Object.keys(j).filter(
460
+ (u) => j[u].readOnly
460
461
  ),
461
- [T]
462
- ), B = p(
463
- () => Y(o),
462
+ [j]
463
+ ), N = P(
464
+ () => Z(o),
464
465
  [o]
465
466
  ), n = W({
466
467
  mode: s,
467
- defaultValues: r,
468
- resolver: B
469
- }), F = p(
470
- () => Z(o, n),
468
+ defaultValues: a,
469
+ resolver: N
470
+ }), k = P(
471
+ () => tt(o, n),
471
472
  [o, n]
472
- ), v = p(
473
+ ), $ = P(
473
474
  () => o._getOps(),
474
475
  [o]
475
476
  );
476
477
  U(() => {
477
- if (!a) return;
478
+ if (!r) return;
478
479
  let u = !0;
479
480
  return (async () => {
480
- f(!0), S(null);
481
+ d(!0), V(null);
481
482
  try {
482
- const l = await v.read(t);
483
+ const l = await $.read(t);
483
484
  if (!u) return;
484
- l && typeof l == "object" && n.reset({ ...r, ...l });
485
+ l && typeof l == "object" && n.reset({ ...a, ...l });
485
486
  } catch (l) {
486
487
  if (!u) return;
487
- console.error("Failed to read activity data:", l), S(C(l));
488
+ console.error("Failed to read activity data:", l), V(x(l));
488
489
  } finally {
489
- u && f(!1);
490
+ u && d(!1);
490
491
  }
491
492
  })(), () => {
492
493
  u = !1;
493
494
  };
494
- }, [a, v, t]);
495
- const E = j(
495
+ }, [r, $, t]);
496
+ const f = C(
496
497
  async (u) => {
497
- V.length !== 0 && (x.current || (N.current && clearTimeout(N.current), N.current = setTimeout(async () => {
498
- if (!x.current) {
499
- x.current = !0;
498
+ S.length !== 0 && (T.current || (E.current && clearTimeout(E.current), E.current = setTimeout(async () => {
499
+ if (!T.current) {
500
+ T.current = !0;
500
501
  try {
501
- const c = n.getValues(), l = {}, d = new Set(V);
502
- Object.keys(c).forEach((m) => {
503
- d.has(m) || (l[m] = c[m]);
502
+ const c = n.getValues(), l = {}, h = new Set(S);
503
+ Object.keys(c).forEach((b) => {
504
+ h.has(b) || (l[b] = c[b]);
504
505
  });
505
- const h = await v.draftStart(t, l);
506
- h && typeof h == "object" && Object.entries(h).forEach(([m, _]) => {
507
- d.has(m) && n.getValues(m) !== _ && n.setValue(m, _, {
506
+ const y = await $.draftStart(t, l);
507
+ y && typeof y == "object" && Object.entries(y).forEach(([b, O]) => {
508
+ h.has(b) && n.getValues(b) !== O && n.setValue(b, O, {
508
509
  shouldDirty: !1,
509
510
  shouldValidate: !1
510
511
  });
@@ -512,75 +513,75 @@ function ct(o, e) {
512
513
  } catch (c) {
513
514
  console.warn("Draft computation failed:", c);
514
515
  } finally {
515
- x.current = !1;
516
+ T.current = !1;
516
517
  }
517
518
  }
518
519
  }, 300)));
519
520
  },
520
- [v, V, n]
521
- ), R = j(
521
+ [$, S, n]
522
+ ), D = C(
522
523
  (u, c) => {
523
- const l = T[u], d = l ? l.readOnly : !1, h = c == null ? void 0 : c.onBlur, m = async (J) => {
524
- h && await h(J);
525
- let P = !0;
526
- s === "onBlur" || s === "onTouched" || s === "all" ? P = await n.trigger(u) : P = !n.getFieldState(u, n.formState).error, P && await E(u);
527
- }, _ = n.register(u, {
524
+ const l = j[u], h = l ? l.readOnly : !1, y = c == null ? void 0 : c.onBlur, b = async (q) => {
525
+ y && await y(q);
526
+ let F = !0;
527
+ s === "onBlur" || s === "onTouched" || s === "all" ? F = await n.trigger(u) : F = !n.getFieldState(u, n.formState).error, F && await f(u);
528
+ }, O = n.register(u, {
528
529
  ...c,
529
- onBlur: m,
530
- ...d ? { disabled: !0 } : {}
530
+ onBlur: b,
531
+ ...h ? { disabled: !0 } : {}
531
532
  });
532
- return d ? { ..._, disabled: !0 } : _;
533
+ return h ? { ...O, disabled: !0 } : O;
533
534
  },
534
- [n, T, E, s]
535
- ), D = j(
535
+ [n, j, f, s]
536
+ ), J = C(
536
537
  (u, c) => n.handleSubmit(
537
- async (l, d) => {
538
- O(!0);
538
+ async (l, h) => {
539
+ v(!0);
539
540
  try {
540
- const h = {}, m = new Set(V);
541
- Object.keys(l).forEach((_) => {
542
- !m.has(_) && l[_] !== void 0 && (h[_] = l[_]);
543
- }), await v.update(t, h), await v.draftEnd(t, h), await (u == null ? void 0 : u(l, d));
544
- } catch (h) {
545
- c == null || c(C(h), d);
541
+ const y = {}, b = new Set(S);
542
+ Object.keys(l).forEach((O) => {
543
+ !b.has(O) && l[O] !== void 0 && (y[O] = l[O]);
544
+ }), await $.update(t, y), await $.draftEnd(t, y), await (u == null ? void 0 : u(l, h));
545
+ } catch (y) {
546
+ c == null || c(x(y), h);
546
547
  } finally {
547
- O(!1);
548
+ v(!1);
548
549
  }
549
550
  },
550
- (l, d) => {
551
- c == null || c(l, d);
551
+ (l, h) => {
552
+ c == null || c(l, h);
552
553
  }
553
554
  ),
554
- [n, v, V]
555
- ), L = j(
555
+ [n, $, S]
556
+ ), B = C(
556
557
  (u, c) => n.handleSubmit(
557
- async (l, d) => {
558
- O(!0);
558
+ async (l, h) => {
559
+ v(!0);
559
560
  try {
560
- await v.complete(t), await (u == null ? void 0 : u(l, d));
561
- } catch (h) {
562
- c == null || c(C(h), d);
561
+ await $.complete(t), await (u == null ? void 0 : u(l, h));
562
+ } catch (y) {
563
+ c == null || c(x(y), h);
563
564
  } finally {
564
- O(!1);
565
+ v(!1);
565
566
  }
566
567
  },
567
- (l, d) => {
568
- c == null || c(l, d);
568
+ (l, h) => {
569
+ c == null || c(l, h);
569
570
  }
570
571
  ),
571
- [n, v]
572
- ), M = j(() => {
572
+ [n, $]
573
+ ), G = C(() => {
573
574
  n.clearErrors();
574
- }, [n]), q = !!w;
575
+ }, [n]), I = !!_;
575
576
  return {
576
577
  // Item proxy
577
- item: F,
578
+ item: k,
578
579
  // Activity reference
579
580
  activity: o,
580
581
  // Form methods
581
- register: R,
582
- handleSubmit: D,
583
- handleComplete: L,
582
+ register: D,
583
+ handleSubmit: J,
584
+ handleComplete: B,
584
585
  watch: n.watch,
585
586
  setValue: n.setValue,
586
587
  getValues: n.getValues,
@@ -591,19 +592,88 @@ function ct(o, e) {
591
592
  errors: n.formState.errors,
592
593
  isValid: n.formState.isValid,
593
594
  isDirty: n.formState.isDirty,
594
- isSubmitting: n.formState.isSubmitting || $,
595
+ isSubmitting: n.formState.isSubmitting || w,
595
596
  isSubmitSuccessful: n.formState.isSubmitSuccessful,
596
597
  // Loading
597
598
  isLoading: i,
598
- loadError: w,
599
- hasError: q,
599
+ loadError: _,
600
+ hasError: I,
600
601
  // Operations
601
- clearErrors: M
602
+ clearErrors: G
603
+ };
604
+ }
605
+ const R = {
606
+ InProgress: "inprogress",
607
+ Completed: "completed"
608
+ };
609
+ function ft(o, e) {
610
+ const { status: t, onError: a, onSuccess: s } = e, { businessProcessId: r, activityId: i } = o.meta, {
611
+ data: d,
612
+ isLoading: _,
613
+ isFetching: V,
614
+ error: w,
615
+ refetch: v
616
+ } = M({
617
+ queryKey: ["activity-table", r, i, t],
618
+ queryFn: async () => {
619
+ try {
620
+ const f = t === R.InProgress ? await o.getInProgressList() : await o.getCompletedList();
621
+ return s && s(f.Data), f;
622
+ } catch (f) {
623
+ throw a && a(x(f)), f;
624
+ }
625
+ },
626
+ staleTime: 0,
627
+ gcTime: 30 * 1e3
628
+ }), {
629
+ data: T,
630
+ isLoading: E,
631
+ isFetching: j,
632
+ error: S,
633
+ refetch: N
634
+ } = M({
635
+ queryKey: [
636
+ "activity-table-count",
637
+ r,
638
+ i,
639
+ t
640
+ ],
641
+ queryFn: async () => {
642
+ try {
643
+ return t === R.InProgress ? await o.inProgressMetrics() : await o.completedMetrics();
644
+ } catch (f) {
645
+ throw a && a(x(f)), f;
646
+ }
647
+ },
648
+ staleTime: 0,
649
+ gcTime: 30 * 1e3
650
+ }), n = P(
651
+ () => (d == null ? void 0 : d.Data) || [],
652
+ [d]
653
+ ), k = P(
654
+ () => {
655
+ var f;
656
+ return ((f = T == null ? void 0 : T.Data[0]) == null ? void 0 : f.count__id) ?? 0;
657
+ },
658
+ [T]
659
+ ), $ = C(async () => {
660
+ const [f] = await Promise.all([v(), N()]);
661
+ return f.data || { Data: [] };
662
+ }, [v, N]);
663
+ return {
664
+ rows: n,
665
+ totalItems: k,
666
+ isLoading: _ || E,
667
+ isFetching: V || j,
668
+ error: w ? x(w) : S ? x(S) : null,
669
+ refetch: $
602
670
  };
603
671
  }
604
672
  export {
605
- ot as Activity,
606
- Q as ActivityInstance,
673
+ ut as Activity,
674
+ X as ActivityInstance,
675
+ R as ActivityTableStatus,
607
676
  z as Workflow,
608
- ct as useActivityForm
677
+ dt as useActivityForm,
678
+ ft as useActivityTable
609
679
  };