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