@ram_28/kf-ai-sdk 2.0.15 → 2.0.17

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