@ram_28/kf-ai-sdk 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +21 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api.cjs +1 -1
- package/dist/api.mjs +3 -3
- package/dist/api.types.d.ts +1 -1
- package/dist/api.types.d.ts.map +1 -1
- package/dist/auth.cjs +1 -1
- package/dist/auth.mjs +2 -2
- package/dist/bdo/core/BaseBdo.d.ts +21 -1
- package/dist/bdo/core/BaseBdo.d.ts.map +1 -1
- package/dist/bdo/core/Item.d.ts +22 -3
- package/dist/bdo/core/Item.d.ts.map +1 -1
- package/dist/bdo/core/types.d.ts +28 -0
- package/dist/bdo/core/types.d.ts.map +1 -1
- package/dist/bdo/fields/FileField.d.ts +2 -2
- package/dist/bdo/fields/FileField.d.ts.map +1 -1
- package/dist/bdo/fields/ImageField.d.ts +18 -0
- package/dist/bdo/fields/ImageField.d.ts.map +1 -0
- package/dist/bdo/fields/attachment-constants.d.ts +9 -0
- package/dist/bdo/fields/attachment-constants.d.ts.map +1 -0
- package/dist/bdo/fields/index.d.ts +1 -0
- package/dist/bdo/fields/index.d.ts.map +1 -1
- package/dist/bdo/index.d.ts +2 -2
- package/dist/bdo/index.d.ts.map +1 -1
- package/dist/bdo.cjs +1 -1
- package/dist/bdo.d.ts +1 -1
- package/dist/bdo.d.ts.map +1 -1
- package/dist/bdo.mjs +381 -157
- package/dist/bdo.types.d.ts +2 -2
- package/dist/bdo.types.d.ts.map +1 -1
- package/dist/client-BnVxSHAm.cjs +1 -0
- package/dist/client-CMERmrC-.js +279 -0
- package/dist/{constants-CYJih7y4.js → constants-ConHc1oS.js} +5 -3
- package/dist/constants-QX2RX-wu.cjs +1 -0
- package/dist/filter.cjs +1 -1
- package/dist/filter.mjs +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.mjs +15 -15
- package/dist/{metadata-BJWukIqS.cjs → metadata-BfJtHz84.cjs} +1 -1
- package/dist/{metadata-CJuFxytC.js → metadata-CwAo6a8e.js} +1 -1
- package/dist/table.cjs +1 -1
- package/dist/table.mjs +2 -2
- package/dist/types/base-fields.d.ts +19 -3
- package/dist/types/base-fields.d.ts.map +1 -1
- package/dist/types/common.d.ts +40 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/constants.d.ts +13 -3
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/workflow.cjs +1 -1
- package/dist/workflow.mjs +1 -1
- package/docs/api.md +1 -1
- package/docs/useFilter.md +279 -6
- package/docs/useForm.md +174 -0
- package/package.json +1 -1
- package/sdk/api/client.ts +145 -0
- package/sdk/api/index.ts +4 -0
- package/sdk/api.types.ts +5 -0
- package/sdk/bdo/core/BaseBdo.ts +60 -0
- package/sdk/bdo/core/Item.ts +231 -3
- package/sdk/bdo/core/types.ts +63 -0
- package/sdk/bdo/fields/FileField.ts +14 -5
- package/sdk/bdo/fields/ImageField.ts +46 -0
- package/sdk/bdo/fields/attachment-constants.ts +72 -0
- package/sdk/bdo/fields/index.ts +1 -0
- package/sdk/bdo/index.ts +6 -0
- package/sdk/bdo.ts +1 -0
- package/sdk/bdo.types.ts +7 -0
- package/sdk/components/hooks/useFilter/useFilter.llm.txt +73 -4
- package/sdk/components/hooks/useForm/createResolver.ts +1 -1
- package/sdk/types/base-fields.ts +21 -3
- package/sdk/types/common.ts +45 -0
- package/sdk/types/constants.ts +13 -3
- package/dist/client-BULEEaCP.js +0 -222
- package/dist/client-DtPpfJc1.cjs +0 -1
- package/dist/constants-D0J69if5.cjs +0 -1
package/dist/bdo.mjs
CHANGED
|
@@ -1,20 +1,79 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { a as
|
|
5
|
-
import { B as
|
|
6
|
-
import { d as
|
|
7
|
-
|
|
1
|
+
var S = Object.defineProperty;
|
|
2
|
+
var U = (r, e, t) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var c = (r, e, t) => U(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { a as i } from "./client-CMERmrC-.js";
|
|
5
|
+
import { B as f } from "./BaseField-B6da88U7.js";
|
|
6
|
+
import { d as se } from "./constants-ConHc1oS.js";
|
|
7
|
+
const C = /* @__PURE__ */ new Set([
|
|
8
|
+
"jpg",
|
|
9
|
+
"jpeg",
|
|
10
|
+
"png",
|
|
11
|
+
"gif",
|
|
12
|
+
"webp",
|
|
13
|
+
"bmp",
|
|
14
|
+
"tiff",
|
|
15
|
+
"tif",
|
|
16
|
+
"heic",
|
|
17
|
+
"heif"
|
|
18
|
+
]), D = /* @__PURE__ */ new Set([
|
|
19
|
+
// Images
|
|
20
|
+
"jpg",
|
|
21
|
+
"jpeg",
|
|
22
|
+
"png",
|
|
23
|
+
"gif",
|
|
24
|
+
"webp",
|
|
25
|
+
"bmp",
|
|
26
|
+
"tiff",
|
|
27
|
+
"tif",
|
|
28
|
+
"heic",
|
|
29
|
+
"heif",
|
|
30
|
+
// Videos
|
|
31
|
+
"mp4",
|
|
32
|
+
"mov",
|
|
33
|
+
"avi",
|
|
34
|
+
"webm",
|
|
35
|
+
"mkv",
|
|
36
|
+
"m4v",
|
|
37
|
+
"wmv",
|
|
38
|
+
"flv",
|
|
39
|
+
// Documents
|
|
40
|
+
"pdf",
|
|
41
|
+
"doc",
|
|
42
|
+
"docx",
|
|
43
|
+
"xls",
|
|
44
|
+
"xlsx",
|
|
45
|
+
"ppt",
|
|
46
|
+
"pptx",
|
|
47
|
+
// Other
|
|
48
|
+
"txt",
|
|
49
|
+
"csv",
|
|
50
|
+
"zip"
|
|
51
|
+
]);
|
|
52
|
+
function E(r) {
|
|
53
|
+
if (!r.includes(".")) return "";
|
|
54
|
+
const e = r.split(".");
|
|
55
|
+
return (e[e.length - 1] ?? "").toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
function F(r, e) {
|
|
58
|
+
const t = E(r), s = e === "Image" ? C : D;
|
|
59
|
+
if (!t || !s.has(t)) {
|
|
60
|
+
const a = [...s].sort().join(", ");
|
|
61
|
+
throw new Error(
|
|
62
|
+
`File "${r}" has unsupported extension "${t || "(none)"}". Supported for ${e} fields: ${a}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
class w {
|
|
8
67
|
constructor(e, t) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
68
|
+
c(this, "_data");
|
|
69
|
+
c(this, "_bdo");
|
|
70
|
+
c(this, "_accessorCache", /* @__PURE__ */ new Map());
|
|
12
71
|
return this._bdo = e, this._data = { ...t }, new Proxy(this, {
|
|
13
|
-
get(s, a,
|
|
14
|
-
return a === "validate" || a === "toJSON" || a === "_bdo" || a === "_data" || a === "_accessorCache" || a === "_getAccessor" || typeof a == "symbol" ? Reflect.get(s, a,
|
|
72
|
+
get(s, a, n) {
|
|
73
|
+
return a === "validate" || a === "toJSON" || a === "_bdo" || a === "_data" || a === "_accessorCache" || a === "_getAccessor" || a === "_requireInstanceId" || typeof a == "symbol" ? Reflect.get(s, a, n) : a === "_id" ? s._data._id : s._getAccessor(a);
|
|
15
74
|
},
|
|
16
|
-
set(s, a,
|
|
17
|
-
return a === "_bdo" || a === "_data" || a === "_accessorCache" || a === "validate" || a === "toJSON" ? !1 : typeof a == "symbol" ? Reflect.set(s, a,
|
|
75
|
+
set(s, a, n) {
|
|
76
|
+
return a === "_bdo" || a === "_data" || a === "_accessorCache" || a === "validate" || a === "toJSON" ? !1 : typeof a == "symbol" ? Reflect.set(s, a, n) : (s._data[a] = n, !0);
|
|
18
77
|
},
|
|
19
78
|
has(s, a) {
|
|
20
79
|
return a === "validate" || a === "toJSON" ? !0 : a in s._data || a in s._bdo.getFields();
|
|
@@ -29,8 +88,8 @@ class h {
|
|
|
29
88
|
enumerable: !1,
|
|
30
89
|
value: s[a]
|
|
31
90
|
};
|
|
32
|
-
const
|
|
33
|
-
if (a in
|
|
91
|
+
const n = s._bdo.getFields();
|
|
92
|
+
if (a in n || a in s._data)
|
|
34
93
|
return {
|
|
35
94
|
configurable: !0,
|
|
36
95
|
enumerable: !0,
|
|
@@ -39,6 +98,18 @@ class h {
|
|
|
39
98
|
}
|
|
40
99
|
});
|
|
41
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Require instanceId or throw.
|
|
103
|
+
* TODO: Support create flow via draftInteraction to get temp _id
|
|
104
|
+
*/
|
|
105
|
+
_requireInstanceId() {
|
|
106
|
+
const e = this._data._id;
|
|
107
|
+
if (!e)
|
|
108
|
+
throw new Error(
|
|
109
|
+
"Cannot perform attachment operation: item has no _id. Save the item first."
|
|
110
|
+
);
|
|
111
|
+
return e;
|
|
112
|
+
}
|
|
42
113
|
/**
|
|
43
114
|
* Get or create a field accessor for the given field.
|
|
44
115
|
* Editable fields get set(), readonly fields do not.
|
|
@@ -50,64 +121,159 @@ class h {
|
|
|
50
121
|
_id: e,
|
|
51
122
|
Name: e,
|
|
52
123
|
Type: "String"
|
|
53
|
-
},
|
|
124
|
+
}, n = (s == null ? void 0 : s.readOnly) ?? !1, u = () => {
|
|
54
125
|
if (s) {
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
return
|
|
126
|
+
const h = s.validate(this._data[e]);
|
|
127
|
+
if (!h.valid)
|
|
128
|
+
return h;
|
|
58
129
|
}
|
|
59
130
|
return this._bdo.hasMetadata() ? this._bdo.validateFieldExpression(
|
|
60
131
|
e,
|
|
61
132
|
this._data[e],
|
|
62
133
|
this.toJSON()
|
|
63
134
|
) : { valid: !0, errors: [] };
|
|
64
|
-
},
|
|
65
|
-
const
|
|
66
|
-
return
|
|
135
|
+
}, m = (h) => {
|
|
136
|
+
const p = this._data[e];
|
|
137
|
+
return p ?? h;
|
|
67
138
|
};
|
|
68
|
-
let
|
|
69
|
-
|
|
139
|
+
let g;
|
|
140
|
+
if (n ? g = {
|
|
70
141
|
label: (s == null ? void 0 : s.label) ?? e,
|
|
71
142
|
required: (s == null ? void 0 : s.required) ?? !1,
|
|
72
143
|
readOnly: !0,
|
|
73
144
|
defaultValue: s == null ? void 0 : s.defaultValue,
|
|
74
145
|
meta: a,
|
|
75
146
|
get: () => this._data[e],
|
|
76
|
-
getOrDefault:
|
|
77
|
-
validate:
|
|
78
|
-
} :
|
|
147
|
+
getOrDefault: m,
|
|
148
|
+
validate: u
|
|
149
|
+
} : g = {
|
|
79
150
|
label: (s == null ? void 0 : s.label) ?? e,
|
|
80
151
|
required: (s == null ? void 0 : s.required) ?? !1,
|
|
81
152
|
readOnly: !1,
|
|
82
153
|
defaultValue: s == null ? void 0 : s.defaultValue,
|
|
83
154
|
meta: a,
|
|
84
155
|
get: () => this._data[e],
|
|
85
|
-
getOrDefault:
|
|
86
|
-
set: (
|
|
87
|
-
this._data[e] =
|
|
156
|
+
getOrDefault: m,
|
|
157
|
+
set: (h) => {
|
|
158
|
+
this._data[e] = h;
|
|
88
159
|
},
|
|
89
|
-
validate:
|
|
90
|
-
},
|
|
160
|
+
validate: u
|
|
161
|
+
}, a.Type === "Image" || a.Type === "File") {
|
|
162
|
+
const h = this._bdo.getBoId(), p = g;
|
|
163
|
+
a.Type === "Image" ? (p.getDownloadUrl = async (o) => {
|
|
164
|
+
const d = this._requireInstanceId(), _ = this._data[e];
|
|
165
|
+
if (!(_ != null && _._id))
|
|
166
|
+
throw new Error(`${e} has no image to download`);
|
|
167
|
+
return i(h).getDownloadUrl(
|
|
168
|
+
d,
|
|
169
|
+
e,
|
|
170
|
+
_._id,
|
|
171
|
+
o
|
|
172
|
+
);
|
|
173
|
+
}, n || (p.upload = async (o) => {
|
|
174
|
+
F(o.name, "Image");
|
|
175
|
+
const d = this._requireInstanceId(), _ = {
|
|
176
|
+
FileName: o.name,
|
|
177
|
+
Size: o.size,
|
|
178
|
+
FileExtension: E(o.name)
|
|
179
|
+
}, [l] = await i(h).getUploadUrl(
|
|
180
|
+
d,
|
|
181
|
+
e,
|
|
182
|
+
[_]
|
|
183
|
+
);
|
|
184
|
+
await fetch(l.UploadUrl.URL, {
|
|
185
|
+
method: "PUT",
|
|
186
|
+
headers: { "Content-Type": l.ContentType },
|
|
187
|
+
body: o
|
|
188
|
+
});
|
|
189
|
+
const v = {
|
|
190
|
+
_id: l._id,
|
|
191
|
+
_name: l._name,
|
|
192
|
+
FileName: l.FileName,
|
|
193
|
+
FileExtension: l.FileExtension,
|
|
194
|
+
Size: l.Size,
|
|
195
|
+
ContentType: l.ContentType
|
|
196
|
+
};
|
|
197
|
+
return this._data[e] = v, v;
|
|
198
|
+
}, p.deleteAttachment = async () => {
|
|
199
|
+
const o = this._requireInstanceId(), d = this._data[e];
|
|
200
|
+
if (!(d != null && d._id))
|
|
201
|
+
throw new Error(`${e} has no image to delete`);
|
|
202
|
+
await i(h).deleteAttachment(o, e, d._id), this._data[e] = null;
|
|
203
|
+
})) : (p.getDownloadUrl = async (o, d) => {
|
|
204
|
+
const _ = this._requireInstanceId();
|
|
205
|
+
return i(h).getDownloadUrl(
|
|
206
|
+
_,
|
|
207
|
+
e,
|
|
208
|
+
o,
|
|
209
|
+
d
|
|
210
|
+
);
|
|
211
|
+
}, p.getDownloadUrls = async (o) => {
|
|
212
|
+
const d = this._requireInstanceId();
|
|
213
|
+
return i(h).getDownloadUrls(d, e, o);
|
|
214
|
+
}, n || (p.upload = async (o) => {
|
|
215
|
+
for (const N of o)
|
|
216
|
+
F(N.name, "File");
|
|
217
|
+
const d = this._requireInstanceId(), _ = o.map((N) => ({
|
|
218
|
+
FileName: N.name,
|
|
219
|
+
Size: N.size,
|
|
220
|
+
FileExtension: E(N.name)
|
|
221
|
+
})), l = await i(h).getUploadUrl(
|
|
222
|
+
d,
|
|
223
|
+
e,
|
|
224
|
+
_
|
|
225
|
+
), v = await Promise.all(
|
|
226
|
+
o.map(async (N, y) => (await fetch(l[y].UploadUrl.URL, {
|
|
227
|
+
method: "PUT",
|
|
228
|
+
headers: { "Content-Type": l[y].ContentType },
|
|
229
|
+
body: N
|
|
230
|
+
}), {
|
|
231
|
+
_id: l[y]._id,
|
|
232
|
+
_name: l[y]._name,
|
|
233
|
+
FileName: l[y].FileName,
|
|
234
|
+
FileExtension: l[y].FileExtension,
|
|
235
|
+
Size: l[y].Size,
|
|
236
|
+
ContentType: l[y].ContentType
|
|
237
|
+
}))
|
|
238
|
+
), O = this._data[e] ?? [];
|
|
239
|
+
return this._data[e] = [
|
|
240
|
+
...O,
|
|
241
|
+
...v
|
|
242
|
+
], v;
|
|
243
|
+
}, p.deleteAttachment = async (o) => {
|
|
244
|
+
const d = this._requireInstanceId();
|
|
245
|
+
await i(h).deleteAttachment(
|
|
246
|
+
d,
|
|
247
|
+
e,
|
|
248
|
+
o
|
|
249
|
+
);
|
|
250
|
+
const _ = this._data[e] ?? [];
|
|
251
|
+
this._data[e] = _.filter(
|
|
252
|
+
(l) => l._id !== o
|
|
253
|
+
);
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
return this._accessorCache.set(e, g), g;
|
|
91
257
|
}
|
|
92
258
|
/**
|
|
93
259
|
* Validate all fields and return combined results
|
|
94
260
|
*/
|
|
95
261
|
validate() {
|
|
96
262
|
const e = this._bdo.getFields(), t = [], s = this.toJSON();
|
|
97
|
-
for (const [a,
|
|
98
|
-
if (
|
|
99
|
-
const
|
|
100
|
-
if (!
|
|
101
|
-
t.push(...
|
|
263
|
+
for (const [a, n] of Object.entries(e)) {
|
|
264
|
+
if (n.readOnly) continue;
|
|
265
|
+
const u = this._data[a], m = n.validate(u);
|
|
266
|
+
if (!m.valid) {
|
|
267
|
+
t.push(...m.errors);
|
|
102
268
|
continue;
|
|
103
269
|
}
|
|
104
270
|
if (this._bdo.hasMetadata()) {
|
|
105
|
-
const
|
|
271
|
+
const g = this._bdo.validateFieldExpression(
|
|
106
272
|
a,
|
|
107
|
-
|
|
273
|
+
u,
|
|
108
274
|
s
|
|
109
275
|
);
|
|
110
|
-
|
|
276
|
+
g.valid || t.push(...g.errors);
|
|
111
277
|
}
|
|
112
278
|
}
|
|
113
279
|
return {
|
|
@@ -122,7 +288,7 @@ class h {
|
|
|
122
288
|
return { ...this._data };
|
|
123
289
|
}
|
|
124
290
|
}
|
|
125
|
-
class
|
|
291
|
+
class x extends f {
|
|
126
292
|
constructor(e) {
|
|
127
293
|
super(e);
|
|
128
294
|
}
|
|
@@ -138,7 +304,7 @@ class b extends d {
|
|
|
138
304
|
} : { valid: !0, errors: [] };
|
|
139
305
|
}
|
|
140
306
|
}
|
|
141
|
-
class
|
|
307
|
+
class T extends f {
|
|
142
308
|
constructor(e) {
|
|
143
309
|
super(e);
|
|
144
310
|
}
|
|
@@ -162,7 +328,7 @@ class g extends d {
|
|
|
162
328
|
} : { valid: !0, errors: [] };
|
|
163
329
|
}
|
|
164
330
|
}
|
|
165
|
-
class
|
|
331
|
+
class A extends f {
|
|
166
332
|
constructor(e) {
|
|
167
333
|
super(e);
|
|
168
334
|
}
|
|
@@ -186,7 +352,7 @@ class y extends d {
|
|
|
186
352
|
} : { valid: !0, errors: [] };
|
|
187
353
|
}
|
|
188
354
|
}
|
|
189
|
-
const
|
|
355
|
+
const M = {
|
|
190
356
|
// ============================================================
|
|
191
357
|
// STRING FUNCTIONS (7)
|
|
192
358
|
// ============================================================
|
|
@@ -356,7 +522,7 @@ const v = {
|
|
|
356
522
|
return (r === "x" ? e : e & 3 | 8).toString(16);
|
|
357
523
|
})
|
|
358
524
|
};
|
|
359
|
-
function
|
|
525
|
+
function R() {
|
|
360
526
|
const r = /* @__PURE__ */ new Date();
|
|
361
527
|
return {
|
|
362
528
|
NOW: r,
|
|
@@ -371,7 +537,7 @@ function x() {
|
|
|
371
537
|
}
|
|
372
538
|
};
|
|
373
539
|
}
|
|
374
|
-
function
|
|
540
|
+
function b(r, e) {
|
|
375
541
|
var t;
|
|
376
542
|
switch (r.Type) {
|
|
377
543
|
case "Literal":
|
|
@@ -379,97 +545,97 @@ function f(r, e) {
|
|
|
379
545
|
case "Identifier":
|
|
380
546
|
return e.formValues[r.Name];
|
|
381
547
|
case "SystemIdentifier":
|
|
382
|
-
return
|
|
548
|
+
return I(r, e);
|
|
383
549
|
case "BinaryExpression":
|
|
384
|
-
return
|
|
550
|
+
return $(r, e);
|
|
385
551
|
case "LogicalExpression":
|
|
386
|
-
return
|
|
552
|
+
return j(r, e);
|
|
387
553
|
case "CallExpression":
|
|
388
|
-
return
|
|
554
|
+
return B(r, e);
|
|
389
555
|
case "MemberExpression":
|
|
390
|
-
return
|
|
556
|
+
return V(r, e);
|
|
391
557
|
case "AssignmentExpression":
|
|
392
|
-
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ?
|
|
558
|
+
return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? b(r.Arguments[0], e) : void 0;
|
|
393
559
|
default:
|
|
394
560
|
throw new Error(`Unsupported expression type: ${r.Type}`);
|
|
395
561
|
}
|
|
396
562
|
}
|
|
397
|
-
function
|
|
563
|
+
function I(r, e) {
|
|
398
564
|
const t = r.Name, s = e.systemValues[t];
|
|
399
565
|
return r.Property ? s && typeof s == "object" ? s[r.Property.Name] : void 0 : s;
|
|
400
566
|
}
|
|
401
|
-
function
|
|
567
|
+
function $(r, e) {
|
|
402
568
|
if (!r.Arguments || r.Arguments.length < 2)
|
|
403
569
|
throw new Error("BinaryExpression requires 2 arguments");
|
|
404
|
-
const [t, s] = r.Arguments, a =
|
|
570
|
+
const [t, s] = r.Arguments, a = b(t, e), n = b(s, e);
|
|
405
571
|
switch (r.Operator) {
|
|
406
572
|
case "==":
|
|
407
|
-
return a ==
|
|
573
|
+
return a == n;
|
|
408
574
|
case "!=":
|
|
409
|
-
return a !=
|
|
575
|
+
return a != n;
|
|
410
576
|
case "<":
|
|
411
|
-
return Number(a) < Number(
|
|
577
|
+
return Number(a) < Number(n);
|
|
412
578
|
case "<=":
|
|
413
|
-
return Number(a) <= Number(
|
|
579
|
+
return Number(a) <= Number(n);
|
|
414
580
|
case ">":
|
|
415
|
-
return Number(a) > Number(
|
|
581
|
+
return Number(a) > Number(n);
|
|
416
582
|
case ">=":
|
|
417
|
-
return Number(a) >= Number(
|
|
583
|
+
return Number(a) >= Number(n);
|
|
418
584
|
case "+":
|
|
419
|
-
return Number(a) + Number(
|
|
585
|
+
return Number(a) + Number(n);
|
|
420
586
|
case "-":
|
|
421
|
-
return Number(a) - Number(
|
|
587
|
+
return Number(a) - Number(n);
|
|
422
588
|
case "*":
|
|
423
|
-
return Number(a) * Number(
|
|
589
|
+
return Number(a) * Number(n);
|
|
424
590
|
case "/":
|
|
425
|
-
return Number(
|
|
591
|
+
return Number(n) !== 0 ? Number(a) / Number(n) : 0;
|
|
426
592
|
case "%":
|
|
427
|
-
return Number(a) % Number(
|
|
593
|
+
return Number(a) % Number(n);
|
|
428
594
|
default:
|
|
429
595
|
throw new Error(`Unsupported binary operator: ${r.Operator}`);
|
|
430
596
|
}
|
|
431
597
|
}
|
|
432
|
-
function
|
|
598
|
+
function j(r, e) {
|
|
433
599
|
if (!r.Arguments || r.Arguments.length === 0)
|
|
434
600
|
throw new Error("LogicalExpression requires at least 1 argument");
|
|
435
601
|
const t = r.Arguments;
|
|
436
602
|
switch (r.Operator) {
|
|
437
603
|
case "AND":
|
|
438
|
-
return t.every((s) => !!
|
|
604
|
+
return t.every((s) => !!b(s, e));
|
|
439
605
|
case "OR":
|
|
440
|
-
return t.some((s) => !!
|
|
606
|
+
return t.some((s) => !!b(s, e));
|
|
441
607
|
case "!":
|
|
442
|
-
return !
|
|
608
|
+
return !b(t[0], e);
|
|
443
609
|
default:
|
|
444
610
|
throw new Error(`Unsupported logical operator: ${r.Operator}`);
|
|
445
611
|
}
|
|
446
612
|
}
|
|
447
|
-
function
|
|
613
|
+
function B(r, e) {
|
|
448
614
|
if (!r.Callee)
|
|
449
615
|
throw new Error("CallExpression requires a Callee");
|
|
450
|
-
const t =
|
|
616
|
+
const t = M[r.Callee];
|
|
451
617
|
if (!t)
|
|
452
618
|
throw new Error(`Unknown function: ${r.Callee}`);
|
|
453
|
-
const s = (r.Arguments ?? []).map((a) =>
|
|
619
|
+
const s = (r.Arguments ?? []).map((a) => b(a, e));
|
|
454
620
|
return t(...s);
|
|
455
621
|
}
|
|
456
|
-
function
|
|
457
|
-
var a,
|
|
622
|
+
function V(r, e) {
|
|
623
|
+
var a, n;
|
|
458
624
|
if (!((a = r.Arguments) != null && a.length))
|
|
459
625
|
return;
|
|
460
|
-
const t =
|
|
626
|
+
const t = b(r.Arguments[0], e), s = (n = r.Arguments[0].Property) == null ? void 0 : n.Name;
|
|
461
627
|
return s && t && typeof t == "object" ? t[s] : t;
|
|
462
628
|
}
|
|
463
|
-
class
|
|
629
|
+
class P {
|
|
464
630
|
constructor() {
|
|
465
631
|
/**
|
|
466
632
|
* Map of field ID to its validation rules
|
|
467
633
|
*/
|
|
468
|
-
|
|
634
|
+
c(this, "fieldRules", /* @__PURE__ */ new Map());
|
|
469
635
|
/**
|
|
470
636
|
* The loaded BDO metadata
|
|
471
637
|
*/
|
|
472
|
-
|
|
638
|
+
c(this, "metadata", null);
|
|
473
639
|
}
|
|
474
640
|
/**
|
|
475
641
|
* Load metadata and extract field validation rules
|
|
@@ -484,18 +650,18 @@ class T {
|
|
|
484
650
|
loadMetadata(e) {
|
|
485
651
|
var t, s;
|
|
486
652
|
this.metadata = e, this.fieldRules.clear();
|
|
487
|
-
for (const [a,
|
|
488
|
-
const
|
|
489
|
-
if (
|
|
490
|
-
for (const
|
|
491
|
-
if (typeof
|
|
492
|
-
|
|
493
|
-
else if (typeof
|
|
494
|
-
const
|
|
495
|
-
|
|
653
|
+
for (const [a, n] of Object.entries(e.Fields)) {
|
|
654
|
+
const u = [];
|
|
655
|
+
if (n.Validation && Array.isArray(n.Validation)) {
|
|
656
|
+
for (const m of n.Validation)
|
|
657
|
+
if (typeof m == "object" && m.ExpressionTree)
|
|
658
|
+
u.push(m);
|
|
659
|
+
else if (typeof m == "string") {
|
|
660
|
+
const g = (s = (t = e.Rules) == null ? void 0 : t.Validation) == null ? void 0 : s[m];
|
|
661
|
+
g && u.push(g);
|
|
496
662
|
}
|
|
497
663
|
}
|
|
498
|
-
|
|
664
|
+
u.length > 0 && this.fieldRules.set(a, u);
|
|
499
665
|
}
|
|
500
666
|
}
|
|
501
667
|
/**
|
|
@@ -531,21 +697,21 @@ class T {
|
|
|
531
697
|
const a = this.fieldRules.get(e);
|
|
532
698
|
if (!a || a.length === 0)
|
|
533
699
|
return { valid: !0, errors: [] };
|
|
534
|
-
const
|
|
700
|
+
const n = {
|
|
535
701
|
formValues: { ...s, [e]: t },
|
|
536
|
-
systemValues:
|
|
702
|
+
systemValues: R()
|
|
537
703
|
};
|
|
538
|
-
for (const
|
|
704
|
+
for (const u of a)
|
|
539
705
|
try {
|
|
540
|
-
if (!
|
|
706
|
+
if (!b(u.ExpressionTree, n))
|
|
541
707
|
return {
|
|
542
708
|
valid: !1,
|
|
543
|
-
errors: [
|
|
709
|
+
errors: [u.Message || `Validation failed: ${u.Name || u.Id}`]
|
|
544
710
|
};
|
|
545
|
-
} catch (
|
|
711
|
+
} catch (m) {
|
|
546
712
|
console.warn(
|
|
547
|
-
`Expression evaluation failed for rule ${
|
|
548
|
-
|
|
713
|
+
`Expression evaluation failed for rule ${u.Id}:`,
|
|
714
|
+
m
|
|
549
715
|
);
|
|
550
716
|
}
|
|
551
717
|
return { valid: !0, errors: [] };
|
|
@@ -571,36 +737,42 @@ class T {
|
|
|
571
737
|
};
|
|
572
738
|
}
|
|
573
739
|
}
|
|
574
|
-
class
|
|
740
|
+
class z {
|
|
575
741
|
constructor() {
|
|
576
742
|
// ============================================================
|
|
577
743
|
// SYSTEM FIELDS (inherited by all BDOs)
|
|
578
744
|
// ============================================================
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
// ============================================================
|
|
587
|
-
// FIELD DEFINITIONS (auto-discovered)
|
|
588
|
-
// ============================================================
|
|
745
|
+
c(this, "_id", new x({ _id: "_id", Name: "ID", Type: "String", ReadOnly: !0 }));
|
|
746
|
+
c(this, "_created_at", new T({ _id: "_created_at", Name: "Created At", Type: "DateTime", ReadOnly: !0 }));
|
|
747
|
+
c(this, "_modified_at", new T({ _id: "_modified_at", Name: "Modified At", Type: "DateTime", ReadOnly: !0 }));
|
|
748
|
+
c(this, "_created_by", new A({ _id: "_created_by", Name: "Created By", Type: "User", ReadOnly: !0 }));
|
|
749
|
+
c(this, "_modified_by", new A({ _id: "_modified_by", Name: "Modified By", Type: "User", ReadOnly: !0 }));
|
|
750
|
+
c(this, "_version", new x({ _id: "_version", Name: "Version", Type: "String", ReadOnly: !0 }));
|
|
751
|
+
c(this, "_m_version", new x({ _id: "_m_version", Name: "Metadata Version", Type: "String", ReadOnly: !0 }));
|
|
589
752
|
/**
|
|
590
753
|
* Whether fields have been bound to this BDO
|
|
591
754
|
*/
|
|
592
|
-
|
|
755
|
+
c(this, "_fieldsBound", !1);
|
|
593
756
|
/**
|
|
594
757
|
* Cached field map
|
|
595
758
|
*/
|
|
596
|
-
|
|
759
|
+
c(this, "_fieldsCache", null);
|
|
597
760
|
// ============================================================
|
|
598
761
|
// EXPRESSION ENGINE (for backend validation rules)
|
|
599
762
|
// ============================================================
|
|
600
763
|
/**
|
|
601
764
|
* Expression engine instance for evaluating backend validation rules
|
|
602
765
|
*/
|
|
603
|
-
|
|
766
|
+
c(this, "_expressionEngine", new P());
|
|
767
|
+
}
|
|
768
|
+
// ============================================================
|
|
769
|
+
// FIELD DEFINITIONS (auto-discovered)
|
|
770
|
+
// ============================================================
|
|
771
|
+
/**
|
|
772
|
+
* Get the Business Object ID for API calls
|
|
773
|
+
*/
|
|
774
|
+
getBoId() {
|
|
775
|
+
return this.meta._id;
|
|
604
776
|
}
|
|
605
777
|
/**
|
|
606
778
|
* Get all field definitions (system + business) with automatic binding.
|
|
@@ -613,7 +785,7 @@ class S {
|
|
|
613
785
|
const e = {};
|
|
614
786
|
for (const t of Object.keys(this)) {
|
|
615
787
|
const s = this[t];
|
|
616
|
-
s instanceof
|
|
788
|
+
s instanceof f && (e[t] = s);
|
|
617
789
|
}
|
|
618
790
|
if (!this._fieldsBound) {
|
|
619
791
|
for (const t of Object.values(e))
|
|
@@ -664,22 +836,22 @@ class S {
|
|
|
664
836
|
* Get a single record by ID
|
|
665
837
|
*/
|
|
666
838
|
async get(e) {
|
|
667
|
-
const t = await
|
|
668
|
-
return new
|
|
839
|
+
const t = await i(this.meta._id).get(e);
|
|
840
|
+
return new w(this, t);
|
|
669
841
|
}
|
|
670
842
|
/**
|
|
671
843
|
* List records with optional filtering, sorting, and pagination
|
|
672
844
|
*/
|
|
673
845
|
async list(e) {
|
|
674
|
-
return (await
|
|
675
|
-
(s) => new
|
|
846
|
+
return (await i(this.meta._id).list(e)).Data.map(
|
|
847
|
+
(s) => new w(this, s)
|
|
676
848
|
);
|
|
677
849
|
}
|
|
678
850
|
/**
|
|
679
851
|
* Get count of records matching the filter criteria
|
|
680
852
|
*/
|
|
681
853
|
async count(e) {
|
|
682
|
-
return (await
|
|
854
|
+
return (await i(this.meta._id).count(e)).Count;
|
|
683
855
|
}
|
|
684
856
|
// ============================================================
|
|
685
857
|
// CREATE OPERATIONS
|
|
@@ -689,8 +861,8 @@ class S {
|
|
|
689
861
|
* Returns an Item with _id from API response + the input data as field accessors
|
|
690
862
|
*/
|
|
691
863
|
async create(e) {
|
|
692
|
-
const t = await
|
|
693
|
-
return new
|
|
864
|
+
const t = await i(this.meta._id).create(e);
|
|
865
|
+
return new w(
|
|
694
866
|
this,
|
|
695
867
|
{ ...e, _id: t._id }
|
|
696
868
|
);
|
|
@@ -702,7 +874,7 @@ class S {
|
|
|
702
874
|
* Update an existing record
|
|
703
875
|
*/
|
|
704
876
|
async update(e, t) {
|
|
705
|
-
return
|
|
877
|
+
return i(this.meta._id).update(e, t);
|
|
706
878
|
}
|
|
707
879
|
// ============================================================
|
|
708
880
|
// DELETE OPERATIONS
|
|
@@ -711,7 +883,7 @@ class S {
|
|
|
711
883
|
* Delete a record by ID
|
|
712
884
|
*/
|
|
713
885
|
async delete(e) {
|
|
714
|
-
return
|
|
886
|
+
return i(this.meta._id).delete(e);
|
|
715
887
|
}
|
|
716
888
|
// ============================================================
|
|
717
889
|
// DRAFT OPERATIONS (for useForm integration)
|
|
@@ -720,33 +892,33 @@ class S {
|
|
|
720
892
|
* Create a draft - compute fields without persisting
|
|
721
893
|
*/
|
|
722
894
|
async draft(e) {
|
|
723
|
-
return
|
|
895
|
+
return i(this.meta._id).draft(e);
|
|
724
896
|
}
|
|
725
897
|
/**
|
|
726
898
|
* Interactive draft - create/update draft without instance ID
|
|
727
899
|
* Returns computed fields along with a temporary _id
|
|
728
900
|
*/
|
|
729
901
|
async draftInteraction(e) {
|
|
730
|
-
return
|
|
902
|
+
return i(this.meta._id).draftInteraction(e);
|
|
731
903
|
}
|
|
732
904
|
/**
|
|
733
905
|
* Create an Item wrapper for manipulating data with field accessors
|
|
734
906
|
* Use this when you need get/set/validate methods on fields
|
|
735
907
|
*/
|
|
736
908
|
createItem(e) {
|
|
737
|
-
return new
|
|
909
|
+
return new w(this, e ?? {});
|
|
738
910
|
}
|
|
739
911
|
/**
|
|
740
912
|
* Commit an update draft - finalize changes on an existing record
|
|
741
913
|
*/
|
|
742
914
|
async draftUpdate(e, t) {
|
|
743
|
-
return
|
|
915
|
+
return i(this.meta._id).draftUpdate(e, t);
|
|
744
916
|
}
|
|
745
917
|
/**
|
|
746
918
|
* Patch an existing draft - compute fields during editing
|
|
747
919
|
*/
|
|
748
920
|
async draftPatch(e, t) {
|
|
749
|
-
return
|
|
921
|
+
return i(this.meta._id).draftPatch(e, t);
|
|
750
922
|
}
|
|
751
923
|
// ============================================================
|
|
752
924
|
// ANALYTICS OPERATIONS
|
|
@@ -755,16 +927,43 @@ class S {
|
|
|
755
927
|
* Get aggregated metrics grouped by dimensions
|
|
756
928
|
*/
|
|
757
929
|
async metric(e) {
|
|
758
|
-
return
|
|
930
|
+
return i(this.meta._id).metric(e);
|
|
759
931
|
}
|
|
760
932
|
/**
|
|
761
933
|
* Get pivot table data
|
|
762
934
|
*/
|
|
763
935
|
async pivot(e) {
|
|
764
|
-
return
|
|
936
|
+
return i(this.meta._id).pivot(e);
|
|
937
|
+
}
|
|
938
|
+
// ============================================================
|
|
939
|
+
// ATTACHMENT OPERATIONS
|
|
940
|
+
// ============================================================
|
|
941
|
+
/**
|
|
942
|
+
* Get signed upload URLs for file/image attachments
|
|
943
|
+
*/
|
|
944
|
+
async getUploadUrl(e, t, s) {
|
|
945
|
+
return i(this.meta._id).getUploadUrl(e, t, s);
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Get signed download URL for a single attachment
|
|
949
|
+
*/
|
|
950
|
+
async getDownloadUrl(e, t, s, a) {
|
|
951
|
+
return i(this.meta._id).getDownloadUrl(e, t, s, a);
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Get signed download URLs for all attachments on a field
|
|
955
|
+
*/
|
|
956
|
+
async getDownloadUrls(e, t, s) {
|
|
957
|
+
return i(this.meta._id).getDownloadUrls(e, t, s);
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Delete an attachment
|
|
961
|
+
*/
|
|
962
|
+
async deleteAttachment(e, t, s) {
|
|
963
|
+
return i(this.meta._id).deleteAttachment(e, t, s);
|
|
765
964
|
}
|
|
766
965
|
}
|
|
767
|
-
class
|
|
966
|
+
class J extends f {
|
|
768
967
|
constructor(e) {
|
|
769
968
|
super(e);
|
|
770
969
|
}
|
|
@@ -783,7 +982,7 @@ class D extends d {
|
|
|
783
982
|
} : { valid: !0, errors: [] };
|
|
784
983
|
}
|
|
785
984
|
}
|
|
786
|
-
class
|
|
985
|
+
class k extends f {
|
|
787
986
|
constructor(e) {
|
|
788
987
|
super(e);
|
|
789
988
|
}
|
|
@@ -794,7 +993,7 @@ class V extends d {
|
|
|
794
993
|
} : { valid: !0, errors: [] };
|
|
795
994
|
}
|
|
796
995
|
}
|
|
797
|
-
class
|
|
996
|
+
class G extends f {
|
|
798
997
|
constructor(e) {
|
|
799
998
|
super(e);
|
|
800
999
|
}
|
|
@@ -818,7 +1017,7 @@ class B extends d {
|
|
|
818
1017
|
} : { valid: !0, errors: [] };
|
|
819
1018
|
}
|
|
820
1019
|
}
|
|
821
|
-
class
|
|
1020
|
+
class H extends f {
|
|
822
1021
|
constructor(e) {
|
|
823
1022
|
super(e);
|
|
824
1023
|
}
|
|
@@ -846,7 +1045,7 @@ class $ extends d {
|
|
|
846
1045
|
throw new Error(
|
|
847
1046
|
`Field ${this.id} not bound to a BDO. Cannot fetch options.`
|
|
848
1047
|
);
|
|
849
|
-
return (await
|
|
1048
|
+
return (await i(this._parentBoId).fetchField(
|
|
850
1049
|
e ?? "new",
|
|
851
1050
|
this.id
|
|
852
1051
|
)).map((s) => ({
|
|
@@ -855,7 +1054,7 @@ class $ extends d {
|
|
|
855
1054
|
}));
|
|
856
1055
|
}
|
|
857
1056
|
}
|
|
858
|
-
class
|
|
1057
|
+
class X extends f {
|
|
859
1058
|
constructor(e) {
|
|
860
1059
|
super(e);
|
|
861
1060
|
}
|
|
@@ -893,10 +1092,10 @@ class j extends d {
|
|
|
893
1092
|
throw new Error(
|
|
894
1093
|
`Field ${this.id} not bound to a BDO. Cannot fetch options.`
|
|
895
1094
|
);
|
|
896
|
-
return
|
|
1095
|
+
return i(this._parentBoId).fetchField(e ?? "new", this.id);
|
|
897
1096
|
}
|
|
898
1097
|
}
|
|
899
|
-
class
|
|
1098
|
+
class K extends f {
|
|
900
1099
|
constructor(e) {
|
|
901
1100
|
super(e);
|
|
902
1101
|
}
|
|
@@ -911,7 +1110,7 @@ class U extends d {
|
|
|
911
1110
|
} : { valid: !0, errors: [] };
|
|
912
1111
|
}
|
|
913
1112
|
}
|
|
914
|
-
class
|
|
1113
|
+
class W extends f {
|
|
915
1114
|
constructor(e) {
|
|
916
1115
|
super(e);
|
|
917
1116
|
}
|
|
@@ -926,7 +1125,7 @@ class P extends d {
|
|
|
926
1125
|
} : { valid: !0, errors: [] };
|
|
927
1126
|
}
|
|
928
1127
|
}
|
|
929
|
-
class
|
|
1128
|
+
class Q extends f {
|
|
930
1129
|
constructor(e) {
|
|
931
1130
|
super(e);
|
|
932
1131
|
}
|
|
@@ -942,32 +1141,57 @@ class I extends d {
|
|
|
942
1141
|
} : { valid: !0, errors: [] };
|
|
943
1142
|
}
|
|
944
1143
|
}
|
|
945
|
-
class
|
|
1144
|
+
class Z extends f {
|
|
1145
|
+
constructor(e) {
|
|
1146
|
+
super(e);
|
|
1147
|
+
}
|
|
1148
|
+
validate(e) {
|
|
1149
|
+
if (e == null)
|
|
1150
|
+
return { valid: !0, errors: [] };
|
|
1151
|
+
if (!Array.isArray(e))
|
|
1152
|
+
return {
|
|
1153
|
+
valid: !1,
|
|
1154
|
+
errors: [`${this.label} must be an array of file objects`]
|
|
1155
|
+
};
|
|
1156
|
+
for (const t of e)
|
|
1157
|
+
if (!t || typeof t != "object" || !t._id)
|
|
1158
|
+
return {
|
|
1159
|
+
valid: !1,
|
|
1160
|
+
errors: [`Each file in ${this.label} must have an _id`]
|
|
1161
|
+
};
|
|
1162
|
+
return { valid: !0, errors: [] };
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
class ee extends f {
|
|
946
1166
|
constructor(e) {
|
|
947
1167
|
super(e);
|
|
948
1168
|
}
|
|
949
1169
|
validate(e) {
|
|
950
1170
|
return e == null ? { valid: !0, errors: [] } : typeof e != "object" || Array.isArray(e) ? {
|
|
951
1171
|
valid: !1,
|
|
952
|
-
errors: [`${this.label} must be a valid
|
|
1172
|
+
errors: [`${this.label} must be a valid image object`]
|
|
1173
|
+
} : !e._id || !e.FileName ? {
|
|
1174
|
+
valid: !1,
|
|
1175
|
+
errors: [`${this.label} must have _id and FileName`]
|
|
953
1176
|
} : { valid: !0, errors: [] };
|
|
954
1177
|
}
|
|
955
1178
|
}
|
|
956
1179
|
export {
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1180
|
+
K as ArrayField,
|
|
1181
|
+
z as BaseBdo,
|
|
1182
|
+
f as BaseField,
|
|
1183
|
+
k as BooleanField,
|
|
1184
|
+
G as DateField,
|
|
1185
|
+
T as DateTimeField,
|
|
1186
|
+
Z as FileField,
|
|
1187
|
+
ee as ImageField,
|
|
1188
|
+
J as NumberField,
|
|
1189
|
+
W as ObjectField,
|
|
1190
|
+
X as ReferenceField,
|
|
1191
|
+
H as SelectField,
|
|
1192
|
+
x as StringField,
|
|
1193
|
+
se as SystemField,
|
|
1194
|
+
Q as TextAreaField,
|
|
1195
|
+
Q as TextField,
|
|
1196
|
+
A as UserField
|
|
973
1197
|
};
|