@ram_28/kf-ai-sdk 2.0.14 → 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 (157) hide show
  1. package/README.md +10 -9
  2. package/dist/FileField-BWrSHNRq.js +296 -0
  3. package/dist/FileField-eDeuzln8.cjs +1 -0
  4. package/dist/api.cjs +1 -1
  5. package/dist/api.mjs +2 -2
  6. package/dist/auth.cjs +1 -1
  7. package/dist/auth.mjs +1 -1
  8. package/dist/bdo/core/BaseBdo.d.ts +1 -1
  9. package/dist/bdo.cjs +1 -1
  10. package/dist/bdo.mjs +230 -474
  11. package/dist/{client-DnO2KKrw.cjs → client-D5k4SYuw.cjs} +1 -1
  12. package/dist/{client-iQTqFDNI.js → client-_ayziI1d.js} +33 -32
  13. package/dist/components/hooks/index.d.ts +9 -3
  14. package/dist/components/hooks/index.d.ts.map +1 -1
  15. package/dist/{workflow/components → components/hooks}/useActivityForm/createActivityItemProxy.d.ts +9 -5
  16. package/dist/components/hooks/useActivityForm/createActivityItemProxy.d.ts.map +1 -0
  17. package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts +23 -0
  18. package/dist/components/hooks/useActivityForm/createActivityResolver.d.ts.map +1 -0
  19. package/dist/components/hooks/useActivityForm/index.d.ts.map +1 -0
  20. package/dist/{workflow/components → components/hooks}/useActivityForm/types.d.ts +12 -8
  21. package/dist/components/hooks/useActivityForm/types.d.ts.map +1 -0
  22. package/dist/{workflow/components → components/hooks}/useActivityForm/useActivityForm.d.ts +2 -2
  23. package/dist/components/hooks/useActivityForm/useActivityForm.d.ts.map +1 -0
  24. package/dist/components/hooks/useActivityTable/index.d.ts +4 -0
  25. package/dist/components/hooks/useActivityTable/index.d.ts.map +1 -0
  26. package/dist/components/hooks/useActivityTable/types.d.ts +36 -0
  27. package/dist/components/hooks/useActivityTable/types.d.ts.map +1 -0
  28. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts +4 -0
  29. package/dist/components/hooks/useActivityTable/useActivityTable.d.ts.map +1 -0
  30. package/dist/components/hooks/useBDOForm/createItemProxy.d.ts.map +1 -0
  31. package/dist/components/hooks/useBDOForm/createResolver.d.ts.map +1 -0
  32. package/dist/components/hooks/useBDOForm/index.d.ts +6 -0
  33. package/dist/components/hooks/useBDOForm/index.d.ts.map +1 -0
  34. package/dist/components/hooks/useBDOForm/shared.d.ts +50 -0
  35. package/dist/components/hooks/useBDOForm/shared.d.ts.map +1 -0
  36. package/dist/components/hooks/{useForm → useBDOForm}/types.d.ts +6 -6
  37. package/dist/components/hooks/useBDOForm/types.d.ts.map +1 -0
  38. package/dist/components/hooks/{useForm/useForm.d.ts → useBDOForm/useBDOForm.d.ts} +4 -4
  39. package/dist/components/hooks/useBDOForm/useBDOForm.d.ts.map +1 -0
  40. package/dist/components/hooks/useBDOTable/index.d.ts +3 -0
  41. package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
  42. package/dist/components/hooks/useBDOTable/types.d.ts +24 -0
  43. package/dist/components/hooks/useBDOTable/types.d.ts.map +1 -0
  44. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts +3 -0
  45. package/dist/components/hooks/useBDOTable/useBDOTable.d.ts.map +1 -0
  46. package/dist/components/hooks/useTable/index.d.ts +2 -2
  47. package/dist/components/hooks/useTable/index.d.ts.map +1 -1
  48. package/dist/components/hooks/useTable/types.d.ts +11 -10
  49. package/dist/components/hooks/useTable/types.d.ts.map +1 -1
  50. package/dist/components/hooks/useTable/useTable.d.ts +1 -1
  51. package/dist/components/hooks/useTable/useTable.d.ts.map +1 -1
  52. package/dist/form.cjs +1 -1
  53. package/dist/form.d.ts +1 -1
  54. package/dist/form.d.ts.map +1 -1
  55. package/dist/form.mjs +279 -344
  56. package/dist/form.types.d.ts +1 -1
  57. package/dist/form.types.d.ts.map +1 -1
  58. package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
  59. package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +1 -1
  60. package/dist/shared-5a7UkED1.js +1180 -0
  61. package/dist/shared-nnmlRVs7.cjs +1 -0
  62. package/dist/table.cjs +1 -1
  63. package/dist/table.d.ts +1 -0
  64. package/dist/table.d.ts.map +1 -1
  65. package/dist/table.mjs +17 -192
  66. package/dist/table.types.d.ts +2 -1
  67. package/dist/table.types.d.ts.map +1 -1
  68. package/dist/types/base-fields.d.ts +4 -4
  69. package/dist/types/base-fields.d.ts.map +1 -1
  70. package/dist/types/constants.d.ts +3 -3
  71. package/dist/useTable-CeRklbdT.cjs +1 -0
  72. package/dist/useTable-DS0-WInw.js +203 -0
  73. package/dist/workflow/Activity.d.ts +19 -7
  74. package/dist/workflow/Activity.d.ts.map +1 -1
  75. package/dist/workflow/client.d.ts +2 -2
  76. package/dist/workflow/client.d.ts.map +1 -1
  77. package/dist/workflow/createFieldFromMeta.d.ts +29 -0
  78. package/dist/workflow/createFieldFromMeta.d.ts.map +1 -0
  79. package/dist/workflow/index.d.ts +1 -2
  80. package/dist/workflow/index.d.ts.map +1 -1
  81. package/dist/workflow/types.d.ts +16 -12
  82. package/dist/workflow/types.d.ts.map +1 -1
  83. package/dist/workflow.cjs +1 -1
  84. package/dist/workflow.d.ts +5 -2
  85. package/dist/workflow.d.ts.map +1 -1
  86. package/dist/workflow.mjs +687 -352
  87. package/dist/workflow.types.d.ts +1 -0
  88. package/dist/workflow.types.d.ts.map +1 -1
  89. package/docs/bdo.md +1 -1
  90. package/docs/gaps.md +360 -0
  91. package/docs/useActivityForm.md +393 -0
  92. package/docs/useActivityTable.md +418 -0
  93. package/docs/{useForm.md → useBDOForm.md} +24 -24
  94. package/docs/useBDOTable.md +284 -0
  95. package/docs/workflow.md +148 -297
  96. package/package.json +2 -2
  97. package/sdk/bdo/core/BaseBdo.ts +2 -2
  98. package/sdk/bdo/fields/UserField.ts +1 -1
  99. package/sdk/components/hooks/index.ts +28 -5
  100. package/sdk/components/hooks/useActivityForm/createActivityItemProxy.ts +400 -0
  101. package/sdk/components/hooks/useActivityForm/createActivityResolver.ts +87 -0
  102. package/sdk/{workflow/components → components/hooks}/useActivityForm/types.ts +24 -11
  103. package/sdk/components/hooks/useActivityForm/useActivityForm.ts +478 -0
  104. package/sdk/components/hooks/useActivityTable/index.ts +8 -0
  105. package/sdk/components/hooks/useActivityTable/types.ts +47 -0
  106. package/sdk/components/hooks/useActivityTable/useActivityTable.ts +40 -0
  107. package/sdk/components/hooks/{useForm → useBDOForm}/index.ts +4 -3
  108. package/sdk/components/hooks/useBDOForm/shared.ts +250 -0
  109. package/sdk/components/hooks/{useForm → useBDOForm}/types.ts +9 -9
  110. package/sdk/components/hooks/{useForm/useForm.ts → useBDOForm/useBDOForm.ts} +70 -96
  111. package/sdk/components/hooks/useBDOTable/index.ts +2 -0
  112. package/sdk/components/hooks/useBDOTable/types.ts +22 -0
  113. package/sdk/components/hooks/useBDOTable/useBDOTable.ts +16 -0
  114. package/sdk/components/hooks/useTable/index.ts +3 -3
  115. package/sdk/components/hooks/useTable/types.ts +16 -12
  116. package/sdk/components/hooks/useTable/useTable.ts +56 -49
  117. package/sdk/form.ts +2 -2
  118. package/sdk/form.types.ts +4 -4
  119. package/sdk/table.ts +4 -1
  120. package/sdk/table.types.ts +7 -4
  121. package/sdk/types/base-fields.ts +4 -4
  122. package/sdk/types/constants.ts +3 -3
  123. package/sdk/workflow/Activity.ts +36 -12
  124. package/sdk/workflow/client.ts +65 -12
  125. package/sdk/workflow/createFieldFromMeta.ts +110 -0
  126. package/sdk/workflow/index.ts +1 -6
  127. package/sdk/workflow/types.ts +20 -11
  128. package/sdk/workflow.ts +11 -2
  129. package/sdk/workflow.types.ts +7 -0
  130. package/dist/BaseField-B6da88U7.js +0 -40
  131. package/dist/BaseField-Drp0-OxL.cjs +0 -1
  132. package/dist/components/hooks/useForm/createItemProxy.d.ts.map +0 -1
  133. package/dist/components/hooks/useForm/createResolver.d.ts.map +0 -1
  134. package/dist/components/hooks/useForm/index.d.ts +0 -5
  135. package/dist/components/hooks/useForm/index.d.ts.map +0 -1
  136. package/dist/components/hooks/useForm/types.d.ts.map +0 -1
  137. package/dist/components/hooks/useForm/useForm.d.ts.map +0 -1
  138. package/dist/error-handling-CAoD0Kwb.cjs +0 -1
  139. package/dist/error-handling-CrhTtD88.js +0 -14
  140. package/dist/index.esm-Cj63v5ny.js +0 -1014
  141. package/dist/index.esm-DuwT11sx.cjs +0 -1
  142. package/dist/workflow/components/useActivityForm/createActivityItemProxy.d.ts.map +0 -1
  143. package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts +0 -22
  144. package/dist/workflow/components/useActivityForm/createActivityResolver.d.ts.map +0 -1
  145. package/dist/workflow/components/useActivityForm/index.d.ts.map +0 -1
  146. package/dist/workflow/components/useActivityForm/types.d.ts.map +0 -1
  147. package/dist/workflow/components/useActivityForm/useActivityForm.d.ts.map +0 -1
  148. package/docs/useTable.md +0 -369
  149. package/sdk/workflow/components/useActivityForm/createActivityItemProxy.ts +0 -130
  150. package/sdk/workflow/components/useActivityForm/createActivityResolver.ts +0 -61
  151. package/sdk/workflow/components/useActivityForm/useActivityForm.ts +0 -386
  152. /package/dist/{workflow/components → components/hooks}/useActivityForm/index.d.ts +0 -0
  153. /package/dist/components/hooks/{useForm → useBDOForm}/createItemProxy.d.ts +0 -0
  154. /package/dist/components/hooks/{useForm → useBDOForm}/createResolver.d.ts +0 -0
  155. /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
  156. /package/sdk/components/hooks/{useForm → useBDOForm}/createItemProxy.ts +0 -0
  157. /package/sdk/components/hooks/{useForm → useBDOForm}/createResolver.ts +0 -0
package/dist/workflow.mjs CHANGED
@@ -1,30 +1,33 @@
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-iQTqFDNI.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";
7
- import { u as W } from "./index.esm-Cj63v5ny.js";
8
- import { t as C } from "./error-handling-CrhTtD88.js";
9
- class z {
10
- constructor(e) {
11
- b(this, "bp_id");
12
- this.bp_id = e;
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
+ constructor(t) {
14
+ N(this, "bp_id");
15
+ this.bp_id = t;
13
16
  }
14
17
  /**
15
18
  * Start a new workflow instance
16
19
  */
17
20
  async start() {
18
- const e = await fetch(
19
- `${y()}/api/app/process/${this.bp_id}/start`,
21
+ const t = await fetch(
22
+ `${S()}/api/app/process/${this.bp_id}/start`,
20
23
  {
21
24
  method: "POST",
22
- headers: g()
25
+ headers: $()
23
26
  }
24
27
  );
25
- if (!e.ok)
26
- throw new Error(`Failed to start process: ${e.statusText}`);
27
- return (await e.json()).Data;
28
+ if (!t.ok)
29
+ throw new Error(`Failed to start process: ${t.statusText}`);
30
+ return (await t.json()).Data;
28
31
  }
29
32
  /**
30
33
  * Get progress for a specific process instance.
@@ -32,131 +35,167 @@ class z {
32
35
  *
33
36
  * @param instance_id - The business process instance ID (from start().BPInstanceId)
34
37
  */
35
- async progress(e) {
36
- const t = await fetch(
37
- `${y()}/api/app/process/${this.bp_id}/${e}/progress`,
38
+ async progress(t) {
39
+ const e = await fetch(
40
+ `${S()}/api/app/process/${this.bp_id}/${t}/progress`,
38
41
  {
39
42
  method: "GET",
40
- headers: g()
43
+ headers: $()
41
44
  }
42
45
  );
43
- if (!t.ok)
44
- throw new Error(`Failed to get process progress: ${t.statusText}`);
45
- return (await t.json()).Data;
46
+ if (!e.ok)
47
+ throw new Error(`Failed to get process progress: ${e.statusText}`);
48
+ return (await e.json()).Data;
46
49
  }
47
50
  /**
48
51
  * Get all operations for a specific activity
49
52
  * @param activity_id - Activity identifier
50
53
  */
51
- activity(e) {
52
- const t = `/api/app/process/${this.bp_id}/${e}`;
54
+ activity(t) {
55
+ const e = `/api/app/process/${this.bp_id}/${t}`;
53
56
  return {
54
57
  // ── List-level ────────────────────────────────────────────
55
- async inProgressList() {
56
- const r = await fetch(`${y()}${t}/inprogress/list`, {
57
- method: "GET",
58
- headers: g()
58
+ async inProgressList(a) {
59
+ const n = await fetch(`${S()}${e}/inprogress/list`, {
60
+ method: "POST",
61
+ headers: $(),
62
+ body: a ? JSON.stringify(a) : void 0
59
63
  });
60
- if (!r.ok)
61
- throw new Error(`Failed to list in-progress activities: ${r.statusText}`);
62
- return r.json();
64
+ if (!n.ok)
65
+ throw new Error(`Failed to list in-progress activities: ${n.statusText}`);
66
+ return n.json();
63
67
  },
64
- async completedList() {
65
- const r = await fetch(`${y()}${t}/completed/list`, {
66
- method: "GET",
67
- headers: g()
68
+ async completedList(a) {
69
+ const n = await fetch(`${S()}${e}/completed/list`, {
70
+ method: "POST",
71
+ headers: $(),
72
+ body: a ? JSON.stringify(a) : void 0
68
73
  });
69
- if (!r.ok)
70
- throw new Error(`Failed to list completed activities: ${r.statusText}`);
71
- return r.json();
74
+ if (!n.ok)
75
+ throw new Error(`Failed to list completed activities: ${n.statusText}`);
76
+ return n.json();
72
77
  },
73
- async inProgressMetric() {
74
- const r = await fetch(`${y()}${t}/inprogress/metric`, {
75
- method: "GET",
76
- headers: g()
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)
77
89
  });
78
- if (!r.ok)
79
- throw new Error(`Failed to get in-progress activity metrics: ${r.statusText}`);
80
- return r.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 };
81
93
  },
82
- async completedMetric() {
83
- const r = await fetch(`${y()}${t}/completed/metric`, {
84
- method: "GET",
85
- headers: g()
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 };
109
+ },
110
+ async inProgressMetric(a) {
111
+ const n = { Type: "Metric", ...a }, i = await fetch(`${S()}${e}/inprogress/metric`, {
112
+ method: "POST",
113
+ headers: $(),
114
+ body: JSON.stringify(n)
115
+ });
116
+ if (!i.ok)
117
+ throw new Error(`Failed to get in-progress metrics: ${i.statusText}`);
118
+ return i.json();
119
+ },
120
+ async completedMetric(a) {
121
+ const n = { Type: "Metric", ...a }, i = await fetch(`${S()}${e}/completed/metric`, {
122
+ method: "POST",
123
+ headers: $(),
124
+ body: JSON.stringify(n)
86
125
  });
87
- if (!r.ok)
88
- throw new Error(`Failed to get completed activity metrics: ${r.statusText}`);
89
- return r.json();
126
+ if (!i.ok)
127
+ throw new Error(`Failed to get completed metrics: ${i.statusText}`);
128
+ return i.json();
90
129
  },
91
130
  // ── Instance-level ────────────────────────────────────────
92
- async read(r) {
93
- const s = await fetch(`${y()}${t}/${r}/read`, {
131
+ async read(a) {
132
+ const n = await fetch(`${S()}${e}/${a}/read`, {
94
133
  method: "GET",
95
- headers: g()
134
+ headers: $()
96
135
  });
97
- if (!s.ok)
98
- throw new Error(`Failed to read activity: ${s.statusText}`);
99
- 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;
100
139
  },
101
- async update(r, s) {
102
- const a = await fetch(`${y()}${t}/${r}/update`, {
140
+ async update(a, n) {
141
+ const i = await fetch(`${S()}${e}/${a}/update`, {
103
142
  method: "POST",
104
- headers: g(),
105
- body: JSON.stringify(s)
143
+ headers: $(),
144
+ body: JSON.stringify(n)
106
145
  });
107
- if (!a.ok)
108
- throw new Error(`Failed to update activity: ${a.statusText}`);
109
- return a.json();
146
+ if (!i.ok)
147
+ throw new Error(`Failed to update activity: ${i.statusText}`);
148
+ return i.json();
110
149
  },
111
- async draftStart(r, s) {
112
- const a = await fetch(`${y()}${t}/${r}/draft`, {
150
+ async draftStart(a, n) {
151
+ const i = await fetch(`${S()}${e}/${a}/draft`, {
113
152
  method: "PATCH",
114
- headers: g(),
115
- body: JSON.stringify(s)
153
+ headers: $(),
154
+ body: JSON.stringify(n)
116
155
  });
117
- if (!a.ok)
118
- throw new Error(`Failed to start draft: ${a.statusText}`);
119
- return a.json();
156
+ if (!i.ok)
157
+ throw new Error(`Failed to start draft: ${i.statusText}`);
158
+ return i.json();
120
159
  },
121
- async draftEnd(r, s) {
122
- const a = await fetch(`${y()}${t}/${r}/draft`, {
160
+ async draftEnd(a, n) {
161
+ const i = await fetch(`${S()}${e}/${a}/draft`, {
123
162
  method: "POST",
124
- headers: g(),
125
- body: JSON.stringify(s)
163
+ headers: $(),
164
+ body: JSON.stringify(n)
126
165
  });
127
- if (!a.ok)
128
- throw new Error(`Failed to end draft: ${a.statusText}`);
129
- return a.json();
166
+ if (!i.ok)
167
+ throw new Error(`Failed to end draft: ${i.statusText}`);
168
+ return i.json();
130
169
  },
131
- async complete(r) {
132
- const s = await fetch(`${y()}${t}/${r}/done`, {
170
+ async complete(a) {
171
+ const n = await fetch(`${S()}${e}/${a}/done`, {
133
172
  method: "POST",
134
- headers: g()
173
+ headers: $()
135
174
  });
136
- if (!s.ok)
137
- throw new Error(`Failed to complete activity: ${s.statusText}`);
138
- return s.json();
175
+ if (!n.ok)
176
+ throw new Error(`Failed to complete activity: ${n.statusText}`);
177
+ return n.json();
139
178
  },
140
- async progress(r) {
141
- const s = await fetch(`${y()}${t}/${r}/progress`, {
179
+ async progress(a) {
180
+ const n = await fetch(`${S()}${e}/${a}/progress`, {
142
181
  method: "GET",
143
- headers: g()
182
+ headers: $()
144
183
  });
145
- if (!s.ok)
146
- throw new Error(`Failed to get activity progress: ${s.statusText}`);
147
- return s.json();
184
+ if (!n.ok)
185
+ throw new Error(`Failed to get activity progress: ${n.statusText}`);
186
+ return n.json();
148
187
  }
149
188
  };
150
189
  }
151
190
  }
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;
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;
160
199
  }
161
200
  // ============================================================
162
201
  // BDO ITEM METHODS
@@ -171,14 +210,14 @@ class Q {
171
210
  * Validate all fields and return combined results
172
211
  */
173
212
  validate() {
174
- 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);
213
+ const t = [];
214
+ for (const [e, a] of Object.entries(this._fields)) {
215
+ const n = this._data[e], i = a.validate(n);
216
+ i.valid || t.push(...i.errors);
178
217
  }
179
218
  return {
180
- valid: e.length === 0,
181
- errors: e
219
+ valid: t.length === 0,
220
+ errors: t
182
221
  };
183
222
  }
184
223
  // ============================================================
@@ -187,14 +226,14 @@ class Q {
187
226
  /**
188
227
  * Regular update — calls ActivityOperations.update()
189
228
  */
190
- async update(e) {
191
- return this._ops.update(this._id, e);
229
+ async update(t) {
230
+ return this._ops.update(this._id, t);
192
231
  }
193
232
  /**
194
233
  * Commit draft — calls ActivityOperations.draftEnd()
195
234
  */
196
- async save(e) {
197
- return this._ops.draftEnd(this._id, e);
235
+ async save(t) {
236
+ return this._ops.draftEnd(this._id, t);
198
237
  }
199
238
  /**
200
239
  * Complete the activity — calls ActivityOperations.complete()
@@ -212,54 +251,54 @@ class Q {
212
251
  // FIELD ACCESSOR (internal)
213
252
  // ============================================================
214
253
  /** @internal */
215
- _getAccessor(e) {
216
- if (this._accessorCache.has(e))
217
- return this._accessorCache.get(e);
218
- const t = this._fields[e], r = (t == null ? void 0 : t.meta) ?? {
219
- _id: e,
220
- Name: e,
254
+ _getAccessor(t) {
255
+ if (this._accessorCache.has(t))
256
+ return this._accessorCache.get(t);
257
+ const e = this._fields[t], a = (e == null ? void 0 : e.meta) ?? {
258
+ _id: t,
259
+ Name: t,
221
260
  Type: "String"
222
- }, s = (t == null ? void 0 : t.readOnly) ?? !1, a = () => t ? t.validate(this._data[e]) : { valid: !0, errors: [] };
223
- let i;
224
- return s ? i = {
225
- label: (t == null ? void 0 : t.label) ?? e,
226
- required: (t == null ? void 0 : t.required) ?? !1,
261
+ }, n = (e == null ? void 0 : e.readOnly) ?? !1, i = () => e ? e.validate(this._data[t]) : { valid: !0, errors: [] };
262
+ let r;
263
+ return n ? r = {
264
+ label: (e == null ? void 0 : e.label) ?? t,
265
+ required: (e == null ? void 0 : e.required) ?? !1,
227
266
  readOnly: !0,
228
- defaultValue: t == null ? void 0 : t.defaultValue,
229
- meta: r,
230
- get: () => this._data[e],
231
- validate: a
232
- } : i = {
233
- label: (t == null ? void 0 : t.label) ?? e,
234
- required: (t == null ? void 0 : t.required) ?? !1,
267
+ defaultValue: e == null ? void 0 : e.defaultValue,
268
+ meta: a,
269
+ get: () => this._data[t],
270
+ validate: i
271
+ } : r = {
272
+ label: (e == null ? void 0 : e.label) ?? t,
273
+ required: (e == null ? void 0 : e.required) ?? !1,
235
274
  readOnly: !1,
236
- defaultValue: t == null ? void 0 : t.defaultValue,
237
- meta: r,
238
- get: () => this._data[e],
239
- set: (f) => {
240
- this._data[e] = f;
275
+ defaultValue: e == null ? void 0 : e.defaultValue,
276
+ meta: a,
277
+ get: () => this._data[t],
278
+ set: (y) => {
279
+ this._data[t] = y;
241
280
  },
242
- validate: a
243
- }, this._accessorCache.set(e, i), i;
281
+ validate: i
282
+ }, this._accessorCache.set(t, r), r;
244
283
  }
245
284
  }
246
- function X(o, e, t, r) {
247
- const s = new Q(
285
+ function Ne(o, t, e, a) {
286
+ const n = new ke(
248
287
  o,
249
- e,
250
288
  t,
251
- r
289
+ e,
290
+ a
252
291
  );
253
- 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);
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);
256
295
  },
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;
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;
259
298
  },
260
- ownKeys(a) {
299
+ ownKeys(i) {
261
300
  return [
262
- ...Object.keys(a._fields),
301
+ ...Object.keys(i._fields),
263
302
  "_id",
264
303
  "validate",
265
304
  "toJSON",
@@ -269,21 +308,21 @@ function X(o, e, t, r) {
269
308
  "progress"
270
309
  ];
271
310
  },
272
- getOwnPropertyDescriptor(a, i) {
273
- if (typeof i != "symbol")
311
+ getOwnPropertyDescriptor(i, r) {
312
+ if (typeof r != "symbol")
274
313
  return {
275
314
  configurable: !0,
276
- enumerable: i !== "validate" && i !== "toJSON" && i !== "update" && i !== "save" && i !== "complete" && i !== "progress"
315
+ enumerable: r !== "validate" && r !== "toJSON" && r !== "update" && r !== "save" && r !== "complete" && r !== "progress"
277
316
  };
278
317
  }
279
318
  });
280
319
  }
281
- class ot {
320
+ class Ge {
282
321
  constructor() {
283
322
  // ============================================================
284
323
  // FIELD DISCOVERY (internal)
285
324
  // ============================================================
286
- b(this, "_fieldsCache", null);
325
+ N(this, "_fieldsCache", null);
287
326
  }
288
327
  // ============================================================
289
328
  // ACTIVITY OPERATIONS (internal)
@@ -293,7 +332,7 @@ class ot {
293
332
  * @internal
294
333
  */
295
334
  _ops() {
296
- return new z(this.meta.businessProcessId).activity(this.meta.activityId);
335
+ return new xe(this.meta.businessProcessId).activity(this.meta.activityId);
297
336
  }
298
337
  /**
299
338
  * Discover BaseField instances from subclass properties.
@@ -301,41 +340,57 @@ class ot {
301
340
  */
302
341
  _discoverFields() {
303
342
  if (this._fieldsCache) return this._fieldsCache;
304
- const e = {};
305
- for (const t of Object.keys(this)) {
306
- const r = this[t];
307
- r instanceof K && (e[t] = r);
343
+ const t = {};
344
+ for (const e of Object.keys(this)) {
345
+ const a = this[e];
346
+ a instanceof ue && (t[e] = a);
308
347
  }
309
- return this._fieldsCache = e, e;
348
+ return this._fieldsCache = t, t;
310
349
  }
311
350
  // ============================================================
312
351
  // PUBLIC METHODS
313
352
  // ============================================================
314
353
  /**
315
354
  * List in-progress activity instances.
316
- * Filtering and pagination are handled server-side.
355
+ * Accepts optional filter/sort/pagination options.
317
356
  */
318
- async getInProgressList() {
319
- return this._ops().inProgressList();
357
+ async getInProgressList(t) {
358
+ return this._ops().inProgressList(t);
320
359
  }
321
360
  /**
322
361
  * List completed activity instances.
323
- * Filtering and pagination are handled server-side.
362
+ * Accepts optional filter/sort/pagination options.
363
+ */
364
+ async getCompletedList(t) {
365
+ return this._ops().completedList(t);
366
+ }
367
+ /**
368
+ * Get count of in-progress activity instances.
369
+ * Returns a number (same as BDO count()).
370
+ */
371
+ async inProgressCount(t) {
372
+ return (await this._ops().inProgressCount(t)).Count;
373
+ }
374
+ /**
375
+ * Get count of completed activity instances.
376
+ * Returns a number (same as BDO count()).
324
377
  */
325
- async getCompletedList() {
326
- return this._ops().completedList();
378
+ async completedCount(t) {
379
+ return (await this._ops().completedCount(t)).Count;
327
380
  }
328
381
  /**
329
382
  * Get aggregated metrics for in-progress activity instances.
383
+ * Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
330
384
  */
331
- async inProgressMetrics() {
332
- return this._ops().inProgressMetric();
385
+ async inProgressMetric(t) {
386
+ return this._ops().inProgressMetric(t);
333
387
  }
334
388
  /**
335
389
  * Get aggregated metrics for completed activity instances.
390
+ * Accepts MetricOptionsType (without Type) for custom aggregations (Sum, Avg, etc.).
336
391
  */
337
- async completedMetrics() {
338
- return this._ops().completedMetric();
392
+ async completedMetric(t) {
393
+ return this._ops().completedMetric(t);
339
394
  }
340
395
  /**
341
396
  * Get a typed ActivityInstance with field accessors and persistence methods.
@@ -343,13 +398,13 @@ class ot {
343
398
  * @param instanceId - The activity instance identifier
344
399
  * @returns ActivityInstance with typed field accessors
345
400
  */
346
- async getInstance(e) {
347
- const t = this._ops(), r = await t.read(e), s = this._discoverFields();
348
- return X(
349
- t,
401
+ async getInstance(t) {
402
+ const e = this._ops(), a = await e.read(t), n = this._discoverFields();
403
+ return Ne(
350
404
  e,
351
- r,
352
- s
405
+ t,
406
+ a,
407
+ n
353
408
  );
354
409
  }
355
410
  // ============================================================
@@ -370,72 +425,279 @@ class ot {
370
425
  return this._ops();
371
426
  }
372
427
  }
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] = {
381
- type: "validate",
382
- message: $.errors[0] || `${f} is invalid`
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);
433
+ switch (a) {
434
+ case "String":
435
+ return new Q(e);
436
+ case "Number":
437
+ return new Fe(e);
438
+ case "Boolean":
439
+ return new we(e);
440
+ case "Date":
441
+ return new _e(e);
442
+ case "DateTime":
443
+ return new me(e);
444
+ case "Text":
445
+ return new ge(e);
446
+ case "Reference":
447
+ return new he(e);
448
+ case "User":
449
+ return new fe(e);
450
+ case "File":
451
+ return new ye(e);
452
+ default:
453
+ return new Q(e);
454
+ }
455
+ }
456
+ function je(o) {
457
+ const t = {};
458
+ for (const [e, a] of Object.entries(o))
459
+ t[e] = ee(e, a);
460
+ return t;
461
+ }
462
+ function De(o, t, e) {
463
+ var i;
464
+ const a = t == null ? void 0 : t.BDOBlob;
465
+ if (!(a != null && a.Activity)) return null;
466
+ const n = o == null ? void 0 : o.Id;
467
+ for (const r of a.Activity)
468
+ if (r.Id !== n && (i = r.Input) != null && i[e])
469
+ return r.Input[e];
470
+ return null;
471
+ }
472
+ function Ue(o) {
473
+ return async (t, e, a) => {
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] = {
483
+ type: "validate",
484
+ message: l.errors[0] || `${y} is invalid`
485
+ };
486
+ continue;
487
+ }
488
+ const w = ve(
489
+ m,
490
+ s
491
+ );
492
+ !w.valid && w.errors.length > 0 && (n[y] = {
493
+ type: "constraint",
494
+ message: w.errors[0]
383
495
  });
384
496
  }
385
- return Object.keys(s).length === 0 ? { values: e, errors: {} } : { values: {}, errors: s };
497
+ return Object.keys(n).length === 0 ? { values: t, errors: {} } : { values: {}, errors: n };
386
498
  };
387
499
  }
388
- function Z(o, e) {
389
- const t = o._getFields();
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() {
503
+ if (!e)
504
+ throw new Error(
505
+ "Cannot perform attachment operation: no activity instance ID"
506
+ );
507
+ return e;
508
+ }
390
509
  return new Proxy(
391
510
  {},
392
511
  {
393
- get(r, s) {
512
+ get(m, s) {
394
513
  if (typeof s == "symbol")
395
514
  return;
515
+ if (s === "_id")
516
+ return e;
396
517
  if (s === "toJSON")
397
- return () => e.getValues();
518
+ return () => t.getValues();
398
519
  if (s === "validate")
399
- return () => e.trigger();
400
- const a = t[s], i = (a == null ? void 0 : a.meta) ?? {
520
+ return () => t.trigger();
521
+ if (n.has(s))
522
+ return n.get(s);
523
+ const l = a[s], w = (l == null ? void 0 : l.meta) ?? {
401
524
  _id: s,
402
525
  Name: s,
403
526
  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,
408
- readOnly: !0,
409
- defaultValue: a == null ? void 0 : a.defaultValue,
410
- meta: i,
411
- get: () => e.getValues(s),
412
- getOrDefault: ($) => e.getValues(s) ?? $,
413
- validate: w
414
- } : {
415
- label: (a == null ? void 0 : a.label) ?? s,
416
- required: (a == null ? void 0 : a.required) ?? !1,
417
- readOnly: !1,
418
- defaultValue: a == null ? void 0 : a.defaultValue,
419
- meta: i,
420
- get: () => e.getValues(s),
421
- getOrDefault: (O) => e.getValues(s) ?? O,
422
- set: (O) => {
423
- e.setValue(s, O, {
424
- shouldDirty: !0,
425
- shouldTouch: !0,
426
- shouldValidate: !1
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;
532
+ };
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,
540
+ readOnly: !1,
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, {
547
+ shouldDirty: !0,
548
+ shouldTouch: !0,
549
+ shouldValidate: !1
550
+ });
551
+ },
552
+ validate: R
553
+ };
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,
559
+ [
560
+ {
561
+ FileName: c.name,
562
+ Size: c.size,
563
+ FileExtension: Z(c.name)
564
+ }
565
+ ]
566
+ );
567
+ await fetch(f.UploadUrl.URL, {
568
+ method: "PUT",
569
+ headers: { "Content-Type": f.ContentType },
570
+ body: c
571
+ });
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
579
+ };
580
+ return t.setValue(s, _, {
581
+ shouldDirty: !0
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, {
590
+ shouldDirty: !0
427
591
  });
428
- },
429
- validate: w
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`);
598
+ return r.getDownloadUrl(
599
+ f,
600
+ s,
601
+ h._id,
602
+ c
603
+ );
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, {
617
+ method: "PUT",
618
+ headers: {
619
+ "Content-Type": _[k].ContentType
620
+ },
621
+ body: O
622
+ }), {
623
+ _id: _[k]._id,
624
+ _name: _[k]._name,
625
+ FileName: _[k].FileName,
626
+ FileExtension: _[k].FileExtension,
627
+ Size: _[k].Size,
628
+ ContentType: _[k].ContentType
629
+ }))
630
+ ), u = t.getValues(s) ?? [];
631
+ return t.setValue(
632
+ s,
633
+ [...u, ...M],
634
+ { shouldDirty: !0 }
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),
641
+ { shouldDirty: !0 }
642
+ );
643
+ }, d.getDownloadUrl = async (c, h) => {
644
+ const f = y();
645
+ return r.getDownloadUrl(
646
+ f,
647
+ s,
648
+ c,
649
+ h
650
+ );
651
+ }, d.getDownloadUrls = async (c) => {
652
+ const h = y();
653
+ return r.getDownloadUrls(h, s, c);
654
+ })), n.set(s, d), d;
655
+ }
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,
662
+ readOnly: !0,
663
+ defaultValue: l == null ? void 0 : l.defaultValue,
664
+ meta: w,
665
+ get: D,
666
+ getOrDefault: A,
667
+ validate: R
430
668
  };
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`);
675
+ return r.getDownloadUrl(
676
+ c,
677
+ s,
678
+ d._id,
679
+ b
680
+ );
681
+ } : (V.getDownloadUrl = async (b, d) => {
682
+ const c = y();
683
+ return r.getDownloadUrl(
684
+ c,
685
+ s,
686
+ b,
687
+ d
688
+ );
689
+ }, V.getDownloadUrls = async (b) => {
690
+ const d = y();
691
+ return r.getDownloadUrls(d, s, b);
692
+ })), n.set(s, V), V;
431
693
  },
432
- has(r, s) {
433
- return typeof s == "symbol" ? !1 : s === "toJSON" || s === "validate" ? !0 : s in t;
694
+ has(m, s) {
695
+ return typeof s == "symbol" ? !1 : s === "_id" || s === "toJSON" || s === "validate" ? !0 : s in a;
434
696
  },
435
- ownKeys(r) {
436
- return [...Object.keys(t), "toJSON", "validate"];
697
+ ownKeys(m) {
698
+ return [...Object.keys(a), "_id", "toJSON", "validate"];
437
699
  },
438
- getOwnPropertyDescriptor(r, s) {
700
+ getOwnPropertyDescriptor(m, s) {
439
701
  if (typeof s != "symbol")
440
702
  return {
441
703
  configurable: !0,
@@ -445,165 +707,238 @@ function Z(o, e) {
445
707
  }
446
708
  );
447
709
  }
448
- function ct(o, e) {
710
+ function Ke(o, t) {
449
711
  const {
450
- activity_instance_id: t,
451
- defaultValues: r = {},
452
- 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(
455
- () => o._getFields(),
456
- [o]
457
- ), V = p(
458
- () => Object.keys(T).filter(
459
- (u) => T[u].readOnly
460
- ),
461
- [T]
462
- ), B = p(
463
- () => Y(o),
464
- [o]
465
- ), n = W({
466
- mode: s,
467
- defaultValues: r,
468
- resolver: B
469
- }), F = p(
470
- () => Z(o, n),
471
- [o, n]
472
- ), v = p(
473
- () => o._getOps(),
474
- [o]
712
+ activity_instance_id: e,
713
+ defaultValues: a = {},
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),
719
+ staleTime: 30 * 60 * 1e3
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
724
+ ) ?? null : null;
725
+ }, [V, o.meta.activityId]), c = b, h = P(() => d != null && d.Input ? je(d.Input) : o._getFields(), [d, o]), f = P(
726
+ () => ({
727
+ ...B,
728
+ // readonly fields from other activities
729
+ ...h
730
+ // Input fields (editable + readonly)
731
+ }),
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,
741
+ defaultValues: a,
742
+ resolver: M
743
+ }), O = P(() => o._getOps(), [o]), k = P(
744
+ () => Ie(o, u, e),
745
+ [o, u, e]
475
746
  );
476
- U(() => {
477
- if (!a) return;
478
- let u = !0;
747
+ Te(() => {
748
+ if (!i || c) return;
749
+ let g = !0;
479
750
  return (async () => {
480
- f(!0), S(null);
751
+ y(!0), s(null);
481
752
  try {
482
- const l = await v.read(t);
483
- if (!u) return;
484
- l && typeof l == "object" && n.reset({ ...r, ...l });
485
- } catch (l) {
486
- if (!u) return;
487
- console.error("Failed to read activity data:", l), S(C(l));
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([
762
+ "_id",
763
+ "BPInstanceId",
764
+ "Status",
765
+ "AssignedTo",
766
+ "CompletedAt",
767
+ "_created_at",
768
+ "_modified_at",
769
+ "_created_by",
770
+ "_modified_by",
771
+ "_v",
772
+ "_m_v"
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
780
+ );
781
+ v && (j[p] = ee(p, {
782
+ ...v,
783
+ ReadOnly: !0
784
+ }));
785
+ }
786
+ Object.keys(j).length > 0 && R(j);
787
+ }
788
+ } catch (F) {
789
+ if (!g) return;
790
+ console.error("Failed to read activity data:", F), s(K(F));
488
791
  } finally {
489
- u && f(!1);
792
+ g && y(!1);
490
793
  }
491
794
  })(), () => {
492
- u = !1;
795
+ g = !1;
493
796
  };
494
- }, [a, v, t]);
495
- const E = j(
496
- 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;
500
- 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]);
504
- });
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, _, {
508
- shouldDirty: !1,
509
- shouldValidate: !1
510
- });
511
- });
512
- } catch (c) {
513
- console.warn("Draft computation failed:", c);
514
- } finally {
515
- x.current = !1;
516
- }
517
- }
518
- }, 300)));
519
- },
520
- [v, V, n]
521
- ), R = j(
522
- (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, {
528
- ...c,
529
- onBlur: m,
530
- ...d ? { disabled: !0 } : {}
531
- });
532
- return d ? { ..._, disabled: !0 } : _;
533
- },
534
- [n, T, E, s]
535
- ), D = j(
536
- (u, c) => n.handleSubmit(
537
- async (l, d) => {
538
- O(!0);
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
827
+ }),
828
+ [u.control, J, L, q]
829
+ ), ae = G(
830
+ (g, T) => u.handleSubmit(
831
+ async (F, x) => {
832
+ w(!0);
539
833
  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);
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;
839
+ }
840
+ Object.keys(C).length > 0 && await O.update(
841
+ e,
842
+ C
843
+ ), await (g == null ? void 0 : g(F, x));
844
+ } catch (C) {
845
+ T == null || T(K(C), x);
546
846
  } finally {
547
- O(!1);
847
+ w(!1);
548
848
  }
549
849
  },
550
- (l, d) => {
551
- c == null || c(l, d);
850
+ (F, x) => {
851
+ T == null || T(F, x);
552
852
  }
553
853
  ),
554
- [n, v, V]
555
- ), L = j(
556
- (u, c) => n.handleSubmit(
557
- async (l, d) => {
558
- O(!0);
854
+ [u, O, _, f, e]
855
+ ), ne = G(
856
+ (g, T) => u.handleSubmit(
857
+ async (F, x) => {
858
+ w(!0);
559
859
  try {
560
- await v.complete(t), await (u == null ? void 0 : u(l, d));
561
- } catch (h) {
562
- c == null || c(C(h), d);
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;
865
+ }
866
+ Object.keys(C).length > 0 && await O.update(
867
+ e,
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);
563
872
  } finally {
564
- O(!1);
873
+ w(!1);
565
874
  }
566
875
  },
567
- (l, d) => {
568
- c == null || c(l, d);
876
+ (F, x) => {
877
+ T == null || T(F, x);
569
878
  }
570
879
  ),
571
- [n, v]
572
- ), M = j(() => {
573
- n.clearErrors();
574
- }, [n]), q = !!w;
880
+ [u, O, _, f, e]
881
+ ), re = G(() => {
882
+ u.clearErrors();
883
+ }, [u]), ie = !!m;
575
884
  return {
576
885
  // Item proxy
577
- item: F,
886
+ item: k,
578
887
  // Activity reference
579
888
  activity: o,
580
889
  // Form methods
581
- register: R,
582
- handleSubmit: D,
583
- handleComplete: L,
584
- watch: n.watch,
585
- setValue: n.setValue,
586
- getValues: n.getValues,
587
- reset: n.reset,
588
- trigger: n.trigger,
589
- control: n.control,
890
+ register: te,
891
+ handleSubmit: ae,
892
+ handleComplete: ne,
893
+ watch: u.watch,
894
+ setValue: u.setValue,
895
+ getValues: u.getValues,
896
+ reset: u.reset,
897
+ trigger: u.trigger,
898
+ control: se,
590
899
  // Flattened form state
591
- errors: n.formState.errors,
592
- isValid: n.formState.isValid,
593
- isDirty: n.formState.isDirty,
594
- isSubmitting: n.formState.isSubmitting || $,
595
- isSubmitSuccessful: n.formState.isSubmitSuccessful,
900
+ errors: u.formState.errors,
901
+ isValid: u.formState.isValid,
902
+ isDirty: u.formState.isDirty,
903
+ isSubmitting: u.formState.isSubmitting || l,
904
+ isSubmitSuccessful: u.formState.isSubmitSuccessful,
596
905
  // Loading
597
- isLoading: i,
598
- loadError: w,
599
- hasError: q,
906
+ isLoading: r || c,
907
+ isMetadataLoading: c,
908
+ loadError: m,
909
+ hasError: ie,
910
+ // Metadata
911
+ bpMetadata: V ?? null,
600
912
  // Operations
601
- clearErrors: M
913
+ clearErrors: re
602
914
  };
603
915
  }
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),
922
+ [r, e]
923
+ );
924
+ return Pe({
925
+ queryKey: ["activity-table", n, i, e],
926
+ listFn: y,
927
+ countFn: m,
928
+ ...a
929
+ });
930
+ }
931
+ const Qe = {
932
+ InProgress: "inprogress",
933
+ Completed: "completed"
934
+ };
604
935
  export {
605
- ot as Activity,
606
- Q as ActivityInstance,
607
- z as Workflow,
608
- ct as useActivityForm
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
609
944
  };