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