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