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