@ram_28/kf-ai-sdk 2.0.14 → 2.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- 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/core/BaseBdo.d.ts +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.mjs +230 -474
- 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 +12 -8
- 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/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/index.d.ts +3 -0
- package/dist/components/hooks/useBDOTable/index.d.ts.map +1 -0
- package/dist/components/hooks/useBDOTable/types.d.ts +24 -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/form.cjs +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.d.ts.map +1 -1
- package/dist/form.mjs +279 -344
- package/dist/form.types.d.ts +1 -1
- package/dist/form.types.d.ts.map +1 -1
- package/dist/{metadata-DpfI3zRN.js → metadata-Cc1mBcLS.js} +1 -1
- package/dist/{metadata-DgLSJkF5.cjs → metadata-DWXQPDav.cjs} +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.d.ts +1 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.mjs +17 -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/types/constants.d.ts +3 -3
- package/dist/useTable-CeRklbdT.cjs +1 -0
- package/dist/useTable-DS0-WInw.js +203 -0
- package/dist/workflow/Activity.d.ts +19 -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/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 +16 -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 +687 -352
- package/dist/workflow.types.d.ts +1 -0
- package/dist/workflow.types.d.ts.map +1 -1
- package/docs/bdo.md +1 -1
- package/docs/gaps.md +360 -0
- package/docs/useActivityForm.md +393 -0
- package/docs/useActivityTable.md +418 -0
- package/docs/{useForm.md → useBDOForm.md} +24 -24
- package/docs/useBDOTable.md +284 -0
- package/docs/workflow.md +148 -297
- package/package.json +2 -2
- package/sdk/bdo/core/BaseBdo.ts +2 -2
- 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 +24 -11
- package/sdk/components/hooks/useActivityForm/useActivityForm.ts +478 -0
- package/sdk/components/hooks/useActivityTable/index.ts +8 -0
- package/sdk/components/hooks/useActivityTable/types.ts +47 -0
- package/sdk/components/hooks/useActivityTable/useActivityTable.ts +40 -0
- 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/index.ts +2 -0
- package/sdk/components/hooks/useBDOTable/types.ts +22 -0
- package/sdk/components/hooks/useBDOTable/useBDOTable.ts +16 -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/form.ts +2 -2
- package/sdk/form.types.ts +4 -4
- package/sdk/table.ts +4 -1
- package/sdk/table.types.ts +7 -4
- package/sdk/types/base-fields.ts +4 -4
- package/sdk/types/constants.ts +3 -3
- package/sdk/workflow/Activity.ts +36 -12
- package/sdk/workflow/client.ts +65 -12
- package/sdk/workflow/createFieldFromMeta.ts +110 -0
- package/sdk/workflow/index.ts +1 -6
- package/sdk/workflow/types.ts +20 -11
- 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/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/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/dist/components/hooks/{useForm → useBDOForm}/createItemProxy.d.ts +0 -0
- /package/dist/components/hooks/{useForm → useBDOForm}/createResolver.d.ts +0 -0
- /package/sdk/{workflow/components → components/hooks}/useActivityForm/index.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createItemProxy.ts +0 -0
- /package/sdk/components/hooks/{useForm → useBDOForm}/createResolver.ts +0 -0
package/dist/bdo.mjs
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { a as i } from "./client-
|
|
5
|
-
import { v
|
|
6
|
-
import { B as
|
|
7
|
-
import {
|
|
1
|
+
var O = Object.defineProperty;
|
|
2
|
+
var S = (r, e, t) => e in r ? O(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var d = (r, e, t) => S(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { a as i } from "./client-_ayziI1d.js";
|
|
5
|
+
import { v, e as E } from "./attachment-constants-C2UHWxmp.js";
|
|
6
|
+
import { S as F, D as T, U, B as x } from "./FileField-BWrSHNRq.js";
|
|
7
|
+
import { a as K, b as W, F as X, N as Q, R as Z, c as ee, T as te, T as re } from "./FileField-BWrSHNRq.js";
|
|
8
|
+
import { d as se } from "./constants-ConHc1oS.js";
|
|
8
9
|
class w {
|
|
9
10
|
constructor(e, t) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
d(this, "_data");
|
|
12
|
+
d(this, "_bdo");
|
|
13
|
+
d(this, "_accessorCache", /* @__PURE__ */ new Map());
|
|
13
14
|
return this._bdo = e, this._data = { ...t }, new Proxy(this, {
|
|
14
|
-
get(
|
|
15
|
-
return
|
|
15
|
+
get(a, s, n) {
|
|
16
|
+
return s === "validate" || s === "toJSON" || s === "_bdo" || s === "_data" || s === "_accessorCache" || s === "_getAccessor" || s === "_requireInstanceId" || typeof s == "symbol" ? Reflect.get(a, s, n) : s === "_id" ? a._data._id : a._getAccessor(s);
|
|
16
17
|
},
|
|
17
|
-
set(
|
|
18
|
-
return
|
|
18
|
+
set(a, s, n) {
|
|
19
|
+
return s === "_bdo" || s === "_data" || s === "_accessorCache" || s === "validate" || s === "toJSON" ? !1 : typeof s == "symbol" ? Reflect.set(a, s, n) : (a._data[s] = n, !0);
|
|
19
20
|
},
|
|
20
|
-
has(
|
|
21
|
-
return
|
|
21
|
+
has(a, s) {
|
|
22
|
+
return s === "validate" || s === "toJSON" ? !0 : s in a._data || s in a._bdo.getFields();
|
|
22
23
|
},
|
|
23
|
-
ownKeys(
|
|
24
|
-
return [...Object.keys(
|
|
24
|
+
ownKeys(a) {
|
|
25
|
+
return [...Object.keys(a._bdo.getFields()), "validate", "toJSON"];
|
|
25
26
|
},
|
|
26
|
-
getOwnPropertyDescriptor(
|
|
27
|
-
if (
|
|
27
|
+
getOwnPropertyDescriptor(a, s) {
|
|
28
|
+
if (s === "validate" || s === "toJSON")
|
|
28
29
|
return {
|
|
29
30
|
configurable: !0,
|
|
30
31
|
enumerable: !1,
|
|
31
|
-
value: s
|
|
32
|
+
value: a[s]
|
|
32
33
|
};
|
|
33
|
-
const n =
|
|
34
|
-
if (
|
|
34
|
+
const n = a._bdo.getFields();
|
|
35
|
+
if (s in n || s in a._data)
|
|
35
36
|
return {
|
|
36
37
|
configurable: !0,
|
|
37
38
|
enumerable: !0,
|
|
38
|
-
get: () =>
|
|
39
|
+
get: () => a._getAccessor(s)
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
});
|
|
@@ -59,163 +60,163 @@ class w {
|
|
|
59
60
|
_getAccessor(e) {
|
|
60
61
|
if (this._accessorCache.has(e))
|
|
61
62
|
return this._accessorCache.get(e);
|
|
62
|
-
const
|
|
63
|
+
const a = this._bdo.getFields()[e], s = (a == null ? void 0 : a.meta) ?? {
|
|
63
64
|
_id: e,
|
|
64
65
|
Name: e,
|
|
65
66
|
Type: "String"
|
|
66
|
-
}, n = (
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
return
|
|
67
|
+
}, n = (a == null ? void 0 : a.readOnly) ?? !1, l = () => {
|
|
68
|
+
if (a) {
|
|
69
|
+
const h = a.validate(this._data[e]);
|
|
70
|
+
if (!h.valid)
|
|
71
|
+
return h;
|
|
71
72
|
}
|
|
72
73
|
return this._bdo.hasMetadata() ? this._bdo.validateFieldExpression(
|
|
73
74
|
e,
|
|
74
75
|
this._data[e],
|
|
75
76
|
this.toJSON()
|
|
76
77
|
) : { valid: !0, errors: [] };
|
|
77
|
-
},
|
|
78
|
-
const
|
|
79
|
-
return
|
|
78
|
+
}, m = (h) => {
|
|
79
|
+
const f = this._data[e];
|
|
80
|
+
return f ?? h;
|
|
80
81
|
};
|
|
81
|
-
let
|
|
82
|
-
if (n ?
|
|
83
|
-
label: (
|
|
84
|
-
required: (
|
|
82
|
+
let y;
|
|
83
|
+
if (n ? y = {
|
|
84
|
+
label: (a == null ? void 0 : a.label) ?? e,
|
|
85
|
+
required: (a == null ? void 0 : a.required) ?? !1,
|
|
85
86
|
readOnly: !0,
|
|
86
|
-
defaultValue:
|
|
87
|
-
meta:
|
|
87
|
+
defaultValue: a == null ? void 0 : a.defaultValue,
|
|
88
|
+
meta: s,
|
|
88
89
|
get: () => this._data[e],
|
|
89
|
-
getOrDefault:
|
|
90
|
-
validate:
|
|
91
|
-
} :
|
|
92
|
-
label: (
|
|
93
|
-
required: (
|
|
90
|
+
getOrDefault: m,
|
|
91
|
+
validate: l
|
|
92
|
+
} : y = {
|
|
93
|
+
label: (a == null ? void 0 : a.label) ?? e,
|
|
94
|
+
required: (a == null ? void 0 : a.required) ?? !1,
|
|
94
95
|
readOnly: !1,
|
|
95
|
-
defaultValue:
|
|
96
|
-
meta:
|
|
96
|
+
defaultValue: a == null ? void 0 : a.defaultValue,
|
|
97
|
+
meta: s,
|
|
97
98
|
get: () => this._data[e],
|
|
98
|
-
getOrDefault:
|
|
99
|
-
set: (
|
|
100
|
-
this._data[e] =
|
|
99
|
+
getOrDefault: m,
|
|
100
|
+
set: (h) => {
|
|
101
|
+
this._data[e] = h;
|
|
101
102
|
},
|
|
102
|
-
validate:
|
|
103
|
-
},
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
const
|
|
103
|
+
validate: l
|
|
104
|
+
}, s.Type === "Image" || s.Type === "File") {
|
|
105
|
+
const h = this._bdo.getBoId(), f = y;
|
|
106
|
+
s.Type === "Image" ? (f.getDownloadUrl = async (o) => {
|
|
107
|
+
const c = this._requireInstanceId(), _ = this._data[e];
|
|
107
108
|
if (!(_ != null && _._id))
|
|
108
109
|
throw new Error(`${e} has no image to download`);
|
|
109
|
-
return i(
|
|
110
|
-
|
|
110
|
+
return i(h).getDownloadUrl(
|
|
111
|
+
c,
|
|
111
112
|
e,
|
|
112
113
|
_._id,
|
|
113
114
|
o
|
|
114
115
|
);
|
|
115
|
-
}, n || (
|
|
116
|
-
|
|
117
|
-
const
|
|
116
|
+
}, n || (f.upload = async (o) => {
|
|
117
|
+
v(o.name, "Image");
|
|
118
|
+
const c = this._requireInstanceId(), _ = {
|
|
118
119
|
FileName: o.name,
|
|
119
120
|
Size: o.size,
|
|
120
121
|
FileExtension: E(o.name)
|
|
121
|
-
}, [
|
|
122
|
-
|
|
122
|
+
}, [u] = await i(h).getUploadUrl(
|
|
123
|
+
c,
|
|
123
124
|
e,
|
|
124
125
|
[_]
|
|
125
126
|
);
|
|
126
|
-
await fetch(
|
|
127
|
+
await fetch(u.UploadUrl.URL, {
|
|
127
128
|
method: "PUT",
|
|
128
|
-
headers: { "Content-Type":
|
|
129
|
+
headers: { "Content-Type": u.ContentType },
|
|
129
130
|
body: o
|
|
130
131
|
});
|
|
131
|
-
const
|
|
132
|
-
_id:
|
|
133
|
-
_name:
|
|
134
|
-
FileName:
|
|
135
|
-
FileExtension:
|
|
136
|
-
Size:
|
|
137
|
-
ContentType:
|
|
132
|
+
const p = {
|
|
133
|
+
_id: u._id,
|
|
134
|
+
_name: u._name,
|
|
135
|
+
FileName: u.FileName,
|
|
136
|
+
FileExtension: u.FileExtension,
|
|
137
|
+
Size: u.Size,
|
|
138
|
+
ContentType: u.ContentType
|
|
138
139
|
};
|
|
139
|
-
return this._data[e] =
|
|
140
|
-
},
|
|
141
|
-
const o = this._requireInstanceId(),
|
|
142
|
-
if (!(
|
|
140
|
+
return this._data[e] = p, p;
|
|
141
|
+
}, f.deleteAttachment = async () => {
|
|
142
|
+
const o = this._requireInstanceId(), c = this._data[e];
|
|
143
|
+
if (!(c != null && c._id))
|
|
143
144
|
throw new Error(`${e} has no image to delete`);
|
|
144
|
-
await i(
|
|
145
|
-
})) : (
|
|
145
|
+
await i(h).deleteAttachment(o, e, c._id), this._data[e] = null;
|
|
146
|
+
})) : (f.getDownloadUrl = async (o, c) => {
|
|
146
147
|
const _ = this._requireInstanceId();
|
|
147
|
-
return i(
|
|
148
|
+
return i(h).getDownloadUrl(
|
|
148
149
|
_,
|
|
149
150
|
e,
|
|
150
151
|
o,
|
|
151
|
-
|
|
152
|
+
c
|
|
152
153
|
);
|
|
153
|
-
},
|
|
154
|
-
const
|
|
155
|
-
return i(
|
|
156
|
-
}, n || (
|
|
157
|
-
for (const
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
FileName:
|
|
161
|
-
Size:
|
|
162
|
-
FileExtension: E(
|
|
163
|
-
})),
|
|
164
|
-
|
|
154
|
+
}, f.getDownloadUrls = async (o) => {
|
|
155
|
+
const c = this._requireInstanceId();
|
|
156
|
+
return i(h).getDownloadUrls(c, e, o);
|
|
157
|
+
}, n || (f.upload = async (o) => {
|
|
158
|
+
for (const b of o)
|
|
159
|
+
v(b.name, "File");
|
|
160
|
+
const c = this._requireInstanceId(), _ = o.map((b) => ({
|
|
161
|
+
FileName: b.name,
|
|
162
|
+
Size: b.size,
|
|
163
|
+
FileExtension: E(b.name)
|
|
164
|
+
})), u = await i(h).getUploadUrl(
|
|
165
|
+
c,
|
|
165
166
|
e,
|
|
166
167
|
_
|
|
167
|
-
),
|
|
168
|
-
o.map(async (
|
|
168
|
+
), p = await Promise.all(
|
|
169
|
+
o.map(async (b, N) => (await fetch(u[N].UploadUrl.URL, {
|
|
169
170
|
method: "PUT",
|
|
170
|
-
headers: { "Content-Type":
|
|
171
|
-
body:
|
|
171
|
+
headers: { "Content-Type": u[N].ContentType },
|
|
172
|
+
body: b
|
|
172
173
|
}), {
|
|
173
|
-
_id:
|
|
174
|
-
_name:
|
|
175
|
-
FileName:
|
|
176
|
-
FileExtension:
|
|
177
|
-
Size:
|
|
178
|
-
ContentType:
|
|
174
|
+
_id: u[N]._id,
|
|
175
|
+
_name: u[N]._name,
|
|
176
|
+
FileName: u[N].FileName,
|
|
177
|
+
FileExtension: u[N].FileExtension,
|
|
178
|
+
Size: u[N].Size,
|
|
179
|
+
ContentType: u[N].ContentType
|
|
179
180
|
}))
|
|
180
181
|
), A = this._data[e] ?? [];
|
|
181
182
|
return this._data[e] = [
|
|
182
183
|
...A,
|
|
183
|
-
...
|
|
184
|
-
],
|
|
185
|
-
},
|
|
186
|
-
const
|
|
187
|
-
await i(
|
|
188
|
-
|
|
184
|
+
...p
|
|
185
|
+
], p;
|
|
186
|
+
}, f.deleteAttachment = async (o) => {
|
|
187
|
+
const c = this._requireInstanceId();
|
|
188
|
+
await i(h).deleteAttachment(
|
|
189
|
+
c,
|
|
189
190
|
e,
|
|
190
191
|
o
|
|
191
192
|
);
|
|
192
193
|
const _ = this._data[e] ?? [];
|
|
193
194
|
this._data[e] = _.filter(
|
|
194
|
-
(
|
|
195
|
+
(u) => u._id !== o
|
|
195
196
|
);
|
|
196
197
|
}));
|
|
197
198
|
}
|
|
198
|
-
return this._accessorCache.set(e,
|
|
199
|
+
return this._accessorCache.set(e, y), y;
|
|
199
200
|
}
|
|
200
201
|
/**
|
|
201
202
|
* Validate all fields and return combined results
|
|
202
203
|
*/
|
|
203
204
|
validate() {
|
|
204
|
-
const e = this._bdo.getFields(), t = [],
|
|
205
|
-
for (const [
|
|
205
|
+
const e = this._bdo.getFields(), t = [], a = this.toJSON();
|
|
206
|
+
for (const [s, n] of Object.entries(e)) {
|
|
206
207
|
if (n.readOnly) continue;
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
-
t.push(...
|
|
208
|
+
const l = this._data[s], m = n.validate(l);
|
|
209
|
+
if (!m.valid) {
|
|
210
|
+
t.push(...m.errors);
|
|
210
211
|
continue;
|
|
211
212
|
}
|
|
212
213
|
if (this._bdo.hasMetadata()) {
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
const y = this._bdo.validateFieldExpression(
|
|
215
|
+
s,
|
|
216
|
+
l,
|
|
217
|
+
a
|
|
217
218
|
);
|
|
218
|
-
|
|
219
|
+
y.valid || t.push(...y.errors);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
return {
|
|
@@ -230,82 +231,7 @@ class w {
|
|
|
230
231
|
return { ...this._data };
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
|
|
234
|
-
constructor(e) {
|
|
235
|
-
super(e);
|
|
236
|
-
}
|
|
237
|
-
/** String-specific: max length constraint */
|
|
238
|
-
get length() {
|
|
239
|
-
var e;
|
|
240
|
-
return (e = this._meta.Constraint) == null ? void 0 : e.Length;
|
|
241
|
-
}
|
|
242
|
-
validate(e) {
|
|
243
|
-
return e != null && typeof e != "string" ? {
|
|
244
|
-
valid: !1,
|
|
245
|
-
errors: [`${this.label} must be a string`]
|
|
246
|
-
} : { valid: !0, errors: [] };
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
class T extends f {
|
|
250
|
-
constructor(e) {
|
|
251
|
-
super(e);
|
|
252
|
-
}
|
|
253
|
-
/** DateTime-specific: precision */
|
|
254
|
-
get precision() {
|
|
255
|
-
var e;
|
|
256
|
-
return ((e = this._meta.Constraint) == null ? void 0 : e.Precision) ?? "Second";
|
|
257
|
-
}
|
|
258
|
-
validate(e) {
|
|
259
|
-
if (e == null || e === "")
|
|
260
|
-
return { valid: !0, errors: [] };
|
|
261
|
-
if (typeof e != "string")
|
|
262
|
-
return {
|
|
263
|
-
valid: !1,
|
|
264
|
-
errors: [`${this.label} must be a valid date string`]
|
|
265
|
-
};
|
|
266
|
-
const t = new Date(e);
|
|
267
|
-
return isNaN(t.getTime()) ? {
|
|
268
|
-
valid: !1,
|
|
269
|
-
errors: [`${this.label} is not a valid date`]
|
|
270
|
-
} : { valid: !0, errors: [] };
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
class O extends f {
|
|
274
|
-
constructor(e) {
|
|
275
|
-
super(e);
|
|
276
|
-
}
|
|
277
|
-
/** Business entity ID for user lookup */
|
|
278
|
-
get businessEntity() {
|
|
279
|
-
var e;
|
|
280
|
-
return (e = this._meta.View) == null ? void 0 : e.BusinessEntity;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* Fetch user records from the backend via the fetchField API.
|
|
284
|
-
* Requires the field to be bound to a parent BDO.
|
|
285
|
-
*/
|
|
286
|
-
async fetchOptions(e) {
|
|
287
|
-
if (!this._parentBoId)
|
|
288
|
-
throw new Error(
|
|
289
|
-
`Field ${this.id} not bound to a BDO. Cannot fetch options.`
|
|
290
|
-
);
|
|
291
|
-
return i(this._parentBoId).fetchField(e, this.id);
|
|
292
|
-
}
|
|
293
|
-
validate(e) {
|
|
294
|
-
if (e == null)
|
|
295
|
-
return { valid: !0, errors: [] };
|
|
296
|
-
if (typeof e != "object")
|
|
297
|
-
return {
|
|
298
|
-
valid: !1,
|
|
299
|
-
errors: [`${this.label} must be a valid user object`]
|
|
300
|
-
};
|
|
301
|
-
const t = e;
|
|
302
|
-
return !("_id" in t) || typeof t._id != "string" ? {
|
|
303
|
-
valid: !1,
|
|
304
|
-
errors: [`${this.label} must have a valid _id`]
|
|
305
|
-
} : { valid: !0, errors: [] };
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const S = {
|
|
234
|
+
const R = {
|
|
309
235
|
// ============================================================
|
|
310
236
|
// STRING FUNCTIONS (7)
|
|
311
237
|
// ============================================================
|
|
@@ -364,7 +290,7 @@ const S = {
|
|
|
364
290
|
*/
|
|
365
291
|
AVG: (...r) => {
|
|
366
292
|
const e = r.filter((t) => t != null && !isNaN(Number(t)));
|
|
367
|
-
return e.length === 0 ? 0 : e.reduce((t,
|
|
293
|
+
return e.length === 0 ? 0 : e.reduce((t, a) => t + Number(a), 0) / e.length;
|
|
368
294
|
},
|
|
369
295
|
/**
|
|
370
296
|
* Get minimum value
|
|
@@ -434,10 +360,10 @@ const S = {
|
|
|
434
360
|
* @example DATE_DIFF("2024-01-15", "2024-01-10") => 5
|
|
435
361
|
*/
|
|
436
362
|
DATE_DIFF: (r, e) => {
|
|
437
|
-
const t = new Date(r),
|
|
438
|
-
if (isNaN(t.getTime()) || isNaN(
|
|
439
|
-
const
|
|
440
|
-
return Math.ceil(
|
|
363
|
+
const t = new Date(r), a = new Date(e);
|
|
364
|
+
if (isNaN(t.getTime()) || isNaN(a.getTime())) return 0;
|
|
365
|
+
const s = Math.abs(t.getTime() - a.getTime());
|
|
366
|
+
return Math.ceil(s / (1e3 * 60 * 60 * 24));
|
|
441
367
|
},
|
|
442
368
|
/**
|
|
443
369
|
* Add days to a date
|
|
@@ -475,7 +401,7 @@ const S = {
|
|
|
475
401
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
476
402
|
})
|
|
477
403
|
};
|
|
478
|
-
function
|
|
404
|
+
function C() {
|
|
479
405
|
const r = /* @__PURE__ */ new Date();
|
|
480
406
|
return {
|
|
481
407
|
NOW: r,
|
|
@@ -490,7 +416,7 @@ function D() {
|
|
|
490
416
|
}
|
|
491
417
|
};
|
|
492
418
|
}
|
|
493
|
-
function
|
|
419
|
+
function g(r, e) {
|
|
494
420
|
var t;
|
|
495
421
|
switch (r.Type) {
|
|
496
422
|
case "Literal":
|
|
@@ -500,50 +426,50 @@ function b(r, e) {
|
|
|
500
426
|
case "SystemIdentifier":
|
|
501
427
|
return M(r, e);
|
|
502
428
|
case "BinaryExpression":
|
|
503
|
-
return
|
|
429
|
+
return D(r, e);
|
|
504
430
|
case "LogicalExpression":
|
|
505
431
|
return I(r, e);
|
|
506
432
|
case "CallExpression":
|
|
507
|
-
return $(r, e);
|
|
508
|
-
case "MemberExpression":
|
|
509
433
|
return B(r, e);
|
|
434
|
+
case "MemberExpression":
|
|
435
|
+
return V(r, e);
|
|
510
436
|
case "AssignmentExpression":
|
|
511
|
-
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ?
|
|
437
|
+
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? g(r.Arguments[0], e) : void 0;
|
|
512
438
|
default:
|
|
513
439
|
throw new Error(`Unsupported expression type: ${r.Type}`);
|
|
514
440
|
}
|
|
515
441
|
}
|
|
516
442
|
function M(r, e) {
|
|
517
|
-
const t = r.Name,
|
|
518
|
-
return r.Property ?
|
|
443
|
+
const t = r.Name, a = e.systemValues[t];
|
|
444
|
+
return r.Property ? a && typeof a == "object" ? a[r.Property.Name] : void 0 : a;
|
|
519
445
|
}
|
|
520
|
-
function
|
|
446
|
+
function D(r, e) {
|
|
521
447
|
if (!r.Arguments || r.Arguments.length < 2)
|
|
522
448
|
throw new Error("BinaryExpression requires 2 arguments");
|
|
523
|
-
const [t,
|
|
449
|
+
const [t, a] = r.Arguments, s = g(t, e), n = g(a, e);
|
|
524
450
|
switch (r.Operator) {
|
|
525
451
|
case "==":
|
|
526
|
-
return
|
|
452
|
+
return s == n;
|
|
527
453
|
case "!=":
|
|
528
|
-
return
|
|
454
|
+
return s != n;
|
|
529
455
|
case "<":
|
|
530
|
-
return Number(
|
|
456
|
+
return Number(s) < Number(n);
|
|
531
457
|
case "<=":
|
|
532
|
-
return Number(
|
|
458
|
+
return Number(s) <= Number(n);
|
|
533
459
|
case ">":
|
|
534
|
-
return Number(
|
|
460
|
+
return Number(s) > Number(n);
|
|
535
461
|
case ">=":
|
|
536
|
-
return Number(
|
|
462
|
+
return Number(s) >= Number(n);
|
|
537
463
|
case "+":
|
|
538
|
-
return Number(
|
|
464
|
+
return Number(s) + Number(n);
|
|
539
465
|
case "-":
|
|
540
|
-
return Number(
|
|
466
|
+
return Number(s) - Number(n);
|
|
541
467
|
case "*":
|
|
542
|
-
return Number(
|
|
468
|
+
return Number(s) * Number(n);
|
|
543
469
|
case "/":
|
|
544
|
-
return Number(n) !== 0 ? Number(
|
|
470
|
+
return Number(n) !== 0 ? Number(s) / Number(n) : 0;
|
|
545
471
|
case "%":
|
|
546
|
-
return Number(
|
|
472
|
+
return Number(s) % Number(n);
|
|
547
473
|
default:
|
|
548
474
|
throw new Error(`Unsupported binary operator: ${r.Operator}`);
|
|
549
475
|
}
|
|
@@ -554,41 +480,41 @@ function I(r, e) {
|
|
|
554
480
|
const t = r.Arguments;
|
|
555
481
|
switch (r.Operator) {
|
|
556
482
|
case "AND":
|
|
557
|
-
return t.every((
|
|
483
|
+
return t.every((a) => !!g(a, e));
|
|
558
484
|
case "OR":
|
|
559
|
-
return t.some((
|
|
485
|
+
return t.some((a) => !!g(a, e));
|
|
560
486
|
case "!":
|
|
561
|
-
return !
|
|
487
|
+
return !g(t[0], e);
|
|
562
488
|
default:
|
|
563
489
|
throw new Error(`Unsupported logical operator: ${r.Operator}`);
|
|
564
490
|
}
|
|
565
491
|
}
|
|
566
|
-
function
|
|
492
|
+
function B(r, e) {
|
|
567
493
|
if (!r.Callee)
|
|
568
494
|
throw new Error("CallExpression requires a Callee");
|
|
569
|
-
const t =
|
|
495
|
+
const t = R[r.Callee];
|
|
570
496
|
if (!t)
|
|
571
497
|
throw new Error(`Unknown function: ${r.Callee}`);
|
|
572
|
-
const
|
|
573
|
-
return t(...
|
|
498
|
+
const a = (r.Arguments ?? []).map((s) => g(s, e));
|
|
499
|
+
return t(...a);
|
|
574
500
|
}
|
|
575
|
-
function
|
|
576
|
-
var
|
|
577
|
-
if (!((
|
|
501
|
+
function V(r, e) {
|
|
502
|
+
var s, n;
|
|
503
|
+
if (!((s = r.Arguments) != null && s.length))
|
|
578
504
|
return;
|
|
579
|
-
const t =
|
|
580
|
-
return
|
|
505
|
+
const t = g(r.Arguments[0], e), a = (n = r.Arguments[0].Property) == null ? void 0 : n.Name;
|
|
506
|
+
return a && t && typeof t == "object" ? t[a] : t;
|
|
581
507
|
}
|
|
582
|
-
class
|
|
508
|
+
class q {
|
|
583
509
|
constructor() {
|
|
584
510
|
/**
|
|
585
511
|
* Map of field ID to its validation rules
|
|
586
512
|
*/
|
|
587
|
-
|
|
513
|
+
d(this, "fieldRules", /* @__PURE__ */ new Map());
|
|
588
514
|
/**
|
|
589
515
|
* The loaded BDO metadata
|
|
590
516
|
*/
|
|
591
|
-
|
|
517
|
+
d(this, "metadata", null);
|
|
592
518
|
}
|
|
593
519
|
/**
|
|
594
520
|
* Load metadata and extract field validation rules
|
|
@@ -601,20 +527,20 @@ class V {
|
|
|
601
527
|
* @param metadata - The BDO metadata from the backend
|
|
602
528
|
*/
|
|
603
529
|
loadMetadata(e) {
|
|
604
|
-
var t,
|
|
530
|
+
var t, a;
|
|
605
531
|
this.metadata = e, this.fieldRules.clear();
|
|
606
|
-
for (const [
|
|
607
|
-
const
|
|
532
|
+
for (const [s, n] of Object.entries(e.Fields)) {
|
|
533
|
+
const l = [];
|
|
608
534
|
if (n.Validation && Array.isArray(n.Validation)) {
|
|
609
|
-
for (const
|
|
610
|
-
if (typeof
|
|
611
|
-
|
|
612
|
-
else if (typeof
|
|
613
|
-
const
|
|
614
|
-
|
|
535
|
+
for (const m of n.Validation)
|
|
536
|
+
if (typeof m == "object" && m.ExpressionTree)
|
|
537
|
+
l.push(m);
|
|
538
|
+
else if (typeof m == "string") {
|
|
539
|
+
const y = (a = (t = e.Rules) == null ? void 0 : t.Validation) == null ? void 0 : a[m];
|
|
540
|
+
y && l.push(y);
|
|
615
541
|
}
|
|
616
542
|
}
|
|
617
|
-
|
|
543
|
+
l.length > 0 && this.fieldRules.set(s, l);
|
|
618
544
|
}
|
|
619
545
|
}
|
|
620
546
|
/**
|
|
@@ -646,25 +572,25 @@ class V {
|
|
|
646
572
|
* @param allValues - All form field values (for cross-field validation)
|
|
647
573
|
* @returns ValidationResult with valid=true if all rules pass
|
|
648
574
|
*/
|
|
649
|
-
validateField(e, t,
|
|
650
|
-
const
|
|
651
|
-
if (!
|
|
575
|
+
validateField(e, t, a) {
|
|
576
|
+
const s = this.fieldRules.get(e);
|
|
577
|
+
if (!s || s.length === 0)
|
|
652
578
|
return { valid: !0, errors: [] };
|
|
653
579
|
const n = {
|
|
654
|
-
formValues: { ...
|
|
655
|
-
systemValues:
|
|
580
|
+
formValues: { ...a, [e]: t },
|
|
581
|
+
systemValues: C()
|
|
656
582
|
};
|
|
657
|
-
for (const
|
|
583
|
+
for (const l of s)
|
|
658
584
|
try {
|
|
659
|
-
if (!
|
|
585
|
+
if (!g(l.ExpressionTree, n))
|
|
660
586
|
return {
|
|
661
587
|
valid: !1,
|
|
662
|
-
errors: [
|
|
588
|
+
errors: [l.Message || `Validation failed: ${l.Name || l.Id}`]
|
|
663
589
|
};
|
|
664
|
-
} catch (
|
|
590
|
+
} catch (m) {
|
|
665
591
|
console.warn(
|
|
666
|
-
`Expression evaluation failed for rule ${
|
|
667
|
-
|
|
592
|
+
`Expression evaluation failed for rule ${l.Id}:`,
|
|
593
|
+
m
|
|
668
594
|
);
|
|
669
595
|
}
|
|
670
596
|
return { valid: !0, errors: [] };
|
|
@@ -680,9 +606,9 @@ class V {
|
|
|
680
606
|
*/
|
|
681
607
|
validateAll(e) {
|
|
682
608
|
const t = [];
|
|
683
|
-
for (const
|
|
684
|
-
const
|
|
685
|
-
|
|
609
|
+
for (const a of this.fieldRules.keys()) {
|
|
610
|
+
const s = this.validateField(a, e[a], e);
|
|
611
|
+
s.valid || t.push(...s.errors);
|
|
686
612
|
}
|
|
687
613
|
return {
|
|
688
614
|
valid: t.length === 0,
|
|
@@ -690,33 +616,33 @@ class V {
|
|
|
690
616
|
};
|
|
691
617
|
}
|
|
692
618
|
}
|
|
693
|
-
class
|
|
619
|
+
class z {
|
|
694
620
|
constructor() {
|
|
695
621
|
// ============================================================
|
|
696
622
|
// SYSTEM FIELDS (inherited by all BDOs)
|
|
697
623
|
// ============================================================
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
624
|
+
d(this, "_id", new F({ _id: "_id", Name: "ID", Type: "String", ReadOnly: !0 }));
|
|
625
|
+
d(this, "_created_at", new T({ _id: "_created_at", Name: "Created At", Type: "DateTime", ReadOnly: !0 }));
|
|
626
|
+
d(this, "_modified_at", new T({ _id: "_modified_at", Name: "Modified At", Type: "DateTime", ReadOnly: !0 }));
|
|
627
|
+
d(this, "_created_by", new U({ _id: "_created_by", Name: "Created By", Type: "User", ReadOnly: !0 }));
|
|
628
|
+
d(this, "_modified_by", new U({ _id: "_modified_by", Name: "Modified By", Type: "User", ReadOnly: !0 }));
|
|
629
|
+
d(this, "_version", new F({ _id: "_version", Name: "Version", Type: "String", ReadOnly: !0 }));
|
|
630
|
+
d(this, "_m_version", new F({ _id: "_m_version", Name: "Metadata Version", Type: "String", ReadOnly: !0 }));
|
|
705
631
|
/**
|
|
706
632
|
* Whether fields have been bound to this BDO
|
|
707
633
|
*/
|
|
708
|
-
|
|
634
|
+
d(this, "_fieldsBound", !1);
|
|
709
635
|
/**
|
|
710
636
|
* Cached field map
|
|
711
637
|
*/
|
|
712
|
-
|
|
638
|
+
d(this, "_fieldsCache", null);
|
|
713
639
|
// ============================================================
|
|
714
640
|
// EXPRESSION ENGINE (for backend validation rules)
|
|
715
641
|
// ============================================================
|
|
716
642
|
/**
|
|
717
643
|
* Expression engine instance for evaluating backend validation rules
|
|
718
644
|
*/
|
|
719
|
-
|
|
645
|
+
d(this, "_expressionEngine", new q());
|
|
720
646
|
}
|
|
721
647
|
// ============================================================
|
|
722
648
|
// FIELD DEFINITIONS (auto-discovered)
|
|
@@ -737,8 +663,8 @@ class Y {
|
|
|
737
663
|
return this._fieldsCache;
|
|
738
664
|
const e = {};
|
|
739
665
|
for (const t of Object.keys(this)) {
|
|
740
|
-
const
|
|
741
|
-
|
|
666
|
+
const a = this[t];
|
|
667
|
+
a instanceof x && (e[t] = a);
|
|
742
668
|
}
|
|
743
669
|
if (!this._fieldsBound) {
|
|
744
670
|
for (const t of Object.values(e))
|
|
@@ -750,7 +676,7 @@ class Y {
|
|
|
750
676
|
/**
|
|
751
677
|
* Load backend metadata for expression-based validation
|
|
752
678
|
*
|
|
753
|
-
* Called by
|
|
679
|
+
* Called by useBDOForm after fetching schema from the backend.
|
|
754
680
|
* This enables expression-based validation rules to be used
|
|
755
681
|
* in addition to type validation.
|
|
756
682
|
*
|
|
@@ -779,8 +705,8 @@ class Y {
|
|
|
779
705
|
* @param allValues - All form field values (for cross-field validation)
|
|
780
706
|
* @returns ValidationResultType from expression evaluation
|
|
781
707
|
*/
|
|
782
|
-
validateFieldExpression(e, t,
|
|
783
|
-
return this._expressionEngine.hasMetadata() ? this._expressionEngine.validateField(e, t,
|
|
708
|
+
validateFieldExpression(e, t, a) {
|
|
709
|
+
return this._expressionEngine.hasMetadata() ? this._expressionEngine.validateField(e, t, a) : { valid: !0, errors: [] };
|
|
784
710
|
}
|
|
785
711
|
// ============================================================
|
|
786
712
|
// READ OPERATIONS
|
|
@@ -797,7 +723,7 @@ class Y {
|
|
|
797
723
|
*/
|
|
798
724
|
async list(e) {
|
|
799
725
|
return (await i(this.meta._id).list(e)).Data.map(
|
|
800
|
-
(
|
|
726
|
+
(a) => new w(this, a)
|
|
801
727
|
);
|
|
802
728
|
}
|
|
803
729
|
/**
|
|
@@ -839,7 +765,7 @@ class Y {
|
|
|
839
765
|
return i(this.meta._id).delete(e);
|
|
840
766
|
}
|
|
841
767
|
// ============================================================
|
|
842
|
-
// DRAFT OPERATIONS (for
|
|
768
|
+
// DRAFT OPERATIONS (for useBDOForm integration)
|
|
843
769
|
// ============================================================
|
|
844
770
|
/**
|
|
845
771
|
* Create a draft - compute fields without persisting
|
|
@@ -894,162 +820,29 @@ class Y {
|
|
|
894
820
|
/**
|
|
895
821
|
* Get signed upload URLs for file/image attachments
|
|
896
822
|
*/
|
|
897
|
-
async getUploadUrl(e, t,
|
|
898
|
-
return i(this.meta._id).getUploadUrl(e, t,
|
|
823
|
+
async getUploadUrl(e, t, a) {
|
|
824
|
+
return i(this.meta._id).getUploadUrl(e, t, a);
|
|
899
825
|
}
|
|
900
826
|
/**
|
|
901
827
|
* Get signed download URL for a single attachment
|
|
902
828
|
*/
|
|
903
|
-
async getDownloadUrl(e, t,
|
|
904
|
-
return i(this.meta._id).getDownloadUrl(e, t,
|
|
829
|
+
async getDownloadUrl(e, t, a, s) {
|
|
830
|
+
return i(this.meta._id).getDownloadUrl(e, t, a, s);
|
|
905
831
|
}
|
|
906
832
|
/**
|
|
907
833
|
* Get signed download URLs for all attachments on a field
|
|
908
834
|
*/
|
|
909
|
-
async getDownloadUrls(e, t,
|
|
910
|
-
return i(this.meta._id).getDownloadUrls(e, t,
|
|
835
|
+
async getDownloadUrls(e, t, a) {
|
|
836
|
+
return i(this.meta._id).getDownloadUrls(e, t, a);
|
|
911
837
|
}
|
|
912
838
|
/**
|
|
913
839
|
* Delete an attachment
|
|
914
840
|
*/
|
|
915
|
-
async deleteAttachment(e, t,
|
|
916
|
-
return i(this.meta._id).deleteAttachment(e, t,
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
class z extends f {
|
|
920
|
-
constructor(e) {
|
|
921
|
-
super(e);
|
|
922
|
-
}
|
|
923
|
-
get integerPart() {
|
|
924
|
-
var e;
|
|
925
|
-
return ((e = this._meta.Constraint) == null ? void 0 : e.IntegerPart) ?? 9;
|
|
926
|
-
}
|
|
927
|
-
get fractionPart() {
|
|
928
|
-
var e;
|
|
929
|
-
return (e = this._meta.Constraint) == null ? void 0 : e.FractionPart;
|
|
930
|
-
}
|
|
931
|
-
validate(e) {
|
|
932
|
-
return e == null || e === "" ? { valid: !0, errors: [] } : typeof e != "number" || isNaN(e) ? {
|
|
933
|
-
valid: !1,
|
|
934
|
-
errors: [`${this.label} must be a valid number`]
|
|
935
|
-
} : { valid: !0, errors: [] };
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
class J extends f {
|
|
939
|
-
constructor(e) {
|
|
940
|
-
super(e);
|
|
941
|
-
}
|
|
942
|
-
validate(e) {
|
|
943
|
-
return e != null && typeof e != "boolean" ? {
|
|
944
|
-
valid: !1,
|
|
945
|
-
errors: [`${this.label} must be a boolean`]
|
|
946
|
-
} : { valid: !0, errors: [] };
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
class k extends f {
|
|
950
|
-
constructor(e) {
|
|
951
|
-
super(e);
|
|
952
|
-
}
|
|
953
|
-
validate(e) {
|
|
954
|
-
if (e == null || e === "")
|
|
955
|
-
return { valid: !0, errors: [] };
|
|
956
|
-
if (typeof e != "string")
|
|
957
|
-
return {
|
|
958
|
-
valid: !1,
|
|
959
|
-
errors: [`${this.label} must be a valid date string`]
|
|
960
|
-
};
|
|
961
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(e))
|
|
962
|
-
return {
|
|
963
|
-
valid: !1,
|
|
964
|
-
errors: [`${this.label} must be in YYYY-MM-DD format`]
|
|
965
|
-
};
|
|
966
|
-
const t = /* @__PURE__ */ new Date(e + "T00:00:00");
|
|
967
|
-
return isNaN(t.getTime()) ? {
|
|
968
|
-
valid: !1,
|
|
969
|
-
errors: [`${this.label} is not a valid date`]
|
|
970
|
-
} : { valid: !0, errors: [] };
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
class G extends f {
|
|
974
|
-
constructor(e) {
|
|
975
|
-
super(e);
|
|
976
|
-
}
|
|
977
|
-
/** Static options derived from Constraint.Enum */
|
|
978
|
-
get options() {
|
|
979
|
-
var t;
|
|
980
|
-
return (((t = this._meta.Constraint) == null ? void 0 : t.Enum) ?? []).map((s) => ({ value: s, label: s }));
|
|
981
|
-
}
|
|
982
|
-
validate(e) {
|
|
983
|
-
if (e == null || e === "")
|
|
984
|
-
return { valid: !0, errors: [] };
|
|
985
|
-
if (this.options.length === 0)
|
|
986
|
-
return { valid: !0, errors: [] };
|
|
987
|
-
const t = this.options.map((s) => s.value);
|
|
988
|
-
return t.includes(e) ? { valid: !0, errors: [] } : {
|
|
989
|
-
valid: !1,
|
|
990
|
-
errors: [`${this.label} must be one of: ${t.join(", ")}`]
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
/**
|
|
994
|
-
* Fetch dynamic options from the backend, returned as typed SelectOption[]
|
|
995
|
-
*/
|
|
996
|
-
async fetchOptions(e) {
|
|
997
|
-
if (!this._parentBoId)
|
|
998
|
-
throw new Error(
|
|
999
|
-
`Field ${this.id} not bound to a BDO. Cannot fetch options.`
|
|
1000
|
-
);
|
|
1001
|
-
return (await i(this._parentBoId).fetchField(
|
|
1002
|
-
e,
|
|
1003
|
-
this.id
|
|
1004
|
-
)).map((s) => ({
|
|
1005
|
-
value: s.Value,
|
|
1006
|
-
label: s.Label
|
|
1007
|
-
}));
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
class H extends f {
|
|
1011
|
-
constructor(e) {
|
|
1012
|
-
super(e);
|
|
1013
|
-
}
|
|
1014
|
-
get referenceBdo() {
|
|
1015
|
-
var e, t;
|
|
1016
|
-
return ((t = (e = this._meta.View) == null ? void 0 : e.DataObject) == null ? void 0 : t.Id) ?? "";
|
|
1017
|
-
}
|
|
1018
|
-
get referenceFields() {
|
|
1019
|
-
var e;
|
|
1020
|
-
return ((e = this._meta.View) == null ? void 0 : e.Fields) ?? ["_id"];
|
|
1021
|
-
}
|
|
1022
|
-
get searchFields() {
|
|
1023
|
-
var e;
|
|
1024
|
-
return ((e = this._meta.View) == null ? void 0 : e.Search) ?? [];
|
|
1025
|
-
}
|
|
1026
|
-
validate(e) {
|
|
1027
|
-
if (e == null)
|
|
1028
|
-
return { valid: !0, errors: [] };
|
|
1029
|
-
if (typeof e != "object")
|
|
1030
|
-
return {
|
|
1031
|
-
valid: !1,
|
|
1032
|
-
errors: [`${this.label} must be a valid reference object`]
|
|
1033
|
-
};
|
|
1034
|
-
const t = e;
|
|
1035
|
-
return !("_id" in t) || typeof t._id != "string" ? {
|
|
1036
|
-
valid: !1,
|
|
1037
|
-
errors: [`${this.label} must have a valid _id`]
|
|
1038
|
-
} : { valid: !0, errors: [] };
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Fetch referenced records from the backend via the fetchField API.
|
|
1042
|
-
* Requires the field to be bound to a parent BDO.
|
|
1043
|
-
*/
|
|
1044
|
-
async fetchOptions(e) {
|
|
1045
|
-
if (!this._parentBoId)
|
|
1046
|
-
throw new Error(
|
|
1047
|
-
`Field ${this.id} not bound to a BDO. Cannot fetch options.`
|
|
1048
|
-
);
|
|
1049
|
-
return i(this._parentBoId).fetchField(e, this.id);
|
|
841
|
+
async deleteAttachment(e, t, a) {
|
|
842
|
+
return i(this.meta._id).deleteAttachment(e, t, a);
|
|
1050
843
|
}
|
|
1051
844
|
}
|
|
1052
|
-
class
|
|
845
|
+
class J extends x {
|
|
1053
846
|
constructor(e) {
|
|
1054
847
|
super(e);
|
|
1055
848
|
}
|
|
@@ -1064,7 +857,7 @@ class K extends f {
|
|
|
1064
857
|
} : { valid: !0, errors: [] };
|
|
1065
858
|
}
|
|
1066
859
|
}
|
|
1067
|
-
class
|
|
860
|
+
class Y extends x {
|
|
1068
861
|
constructor(e) {
|
|
1069
862
|
super(e);
|
|
1070
863
|
}
|
|
@@ -1079,44 +872,7 @@ class W extends f {
|
|
|
1079
872
|
} : { valid: !0, errors: [] };
|
|
1080
873
|
}
|
|
1081
874
|
}
|
|
1082
|
-
class
|
|
1083
|
-
constructor(e) {
|
|
1084
|
-
super(e);
|
|
1085
|
-
}
|
|
1086
|
-
/** Text-specific: format */
|
|
1087
|
-
get format() {
|
|
1088
|
-
var e;
|
|
1089
|
-
return ((e = this._meta.Constraint) == null ? void 0 : e.Format) ?? "Plain";
|
|
1090
|
-
}
|
|
1091
|
-
validate(e) {
|
|
1092
|
-
return e != null && typeof e != "string" ? {
|
|
1093
|
-
valid: !1,
|
|
1094
|
-
errors: [`${this.label} must be a string`]
|
|
1095
|
-
} : { valid: !0, errors: [] };
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
class Q extends f {
|
|
1099
|
-
constructor(e) {
|
|
1100
|
-
super(e);
|
|
1101
|
-
}
|
|
1102
|
-
validate(e) {
|
|
1103
|
-
if (e == null)
|
|
1104
|
-
return { valid: !0, errors: [] };
|
|
1105
|
-
if (!Array.isArray(e))
|
|
1106
|
-
return {
|
|
1107
|
-
valid: !1,
|
|
1108
|
-
errors: [`${this.label} must be an array of file objects`]
|
|
1109
|
-
};
|
|
1110
|
-
for (const t of e)
|
|
1111
|
-
if (!t || typeof t != "object" || !t._id)
|
|
1112
|
-
return {
|
|
1113
|
-
valid: !1,
|
|
1114
|
-
errors: [`Each file in ${this.label} must have an _id`]
|
|
1115
|
-
};
|
|
1116
|
-
return { valid: !0, errors: [] };
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
class Z extends f {
|
|
875
|
+
class k extends x {
|
|
1120
876
|
constructor(e) {
|
|
1121
877
|
super(e);
|
|
1122
878
|
}
|
|
@@ -1131,21 +887,21 @@ class Z extends f {
|
|
|
1131
887
|
}
|
|
1132
888
|
}
|
|
1133
889
|
export {
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
890
|
+
J as ArrayField,
|
|
891
|
+
z as BaseBdo,
|
|
892
|
+
x as BaseField,
|
|
893
|
+
K as BooleanField,
|
|
894
|
+
W as DateField,
|
|
1139
895
|
T as DateTimeField,
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
896
|
+
X as FileField,
|
|
897
|
+
k as ImageField,
|
|
898
|
+
Q as NumberField,
|
|
899
|
+
Y as ObjectField,
|
|
900
|
+
Z as ReferenceField,
|
|
901
|
+
ee as SelectField,
|
|
902
|
+
F as StringField,
|
|
903
|
+
se as SystemField,
|
|
904
|
+
te as TextAreaField,
|
|
905
|
+
re as TextField,
|
|
906
|
+
U as UserField
|
|
1151
907
|
};
|