@ram_28/kf-ai-sdk 2.0.20-beta.0 → 2.0.20-beta.2

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/bdo.mjs CHANGED
@@ -1,17 +1,17 @@
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";
1
+ var R = Object.defineProperty;
2
+ var D = (t, e, r) => e in t ? R(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var m = (t, e, r) => D(t, typeof e != "symbol" ? e + "" : e, r);
4
+ import { a as o } from "./client-_ayziI1d.js";
5
+ import { v as E, e as v } from "./attachment-constants-C2UHWxmp.js";
6
+ import { S as F, D as A, U, B as T } from "./FileField-CZjS2uLh.js";
7
+ import { a as Q, b as Z, F as ee, N as te, R as re, c as ae, T as se, T as ne } from "./FileField-CZjS2uLh.js";
8
+ import { d as oe } from "./constants-ConHc1oS.js";
9
9
  class w {
10
- constructor(e, t) {
11
- d(this, "_data");
12
- d(this, "_bdo");
13
- d(this, "_accessorCache", /* @__PURE__ */ new Map());
14
- return this._bdo = e, this._data = { ...t }, new Proxy(this, {
10
+ constructor(e, r) {
11
+ m(this, "_data");
12
+ m(this, "_bdo");
13
+ m(this, "_accessorCache", /* @__PURE__ */ new Map());
14
+ return this._bdo = e, this._data = { ...r }, new Proxy(this, {
15
15
  get(a, s, n) {
16
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);
17
17
  },
@@ -41,17 +41,8 @@ class w {
41
41
  }
42
42
  });
43
43
  }
44
- /**
45
- * Require instanceId or throw.
46
- * TODO: Support create flow via draftInteraction to get temp _id
47
- */
48
44
  _requireInstanceId() {
49
- const e = this._data._id;
50
- if (!e)
51
- throw new Error(
52
- "Cannot perform attachment operation: item has no _id. Save the item first."
53
- );
54
- return e;
45
+ return this._data._id || "draft";
55
46
  }
56
47
  /**
57
48
  * Get or create a field accessor for the given field.
@@ -64,7 +55,7 @@ class w {
64
55
  _id: e,
65
56
  Name: e,
66
57
  Type: "String"
67
- }, n = (a == null ? void 0 : a.readOnly) ?? !1, l = () => {
58
+ }, n = (a == null ? void 0 : a.readOnly) ?? !1, i = () => {
68
59
  if (a) {
69
60
  const h = a.validate(this._data[e]);
70
61
  if (!h.valid)
@@ -75,153 +66,153 @@ class w {
75
66
  this._data[e],
76
67
  this.toJSON()
77
68
  ) : { valid: !0, errors: [] };
78
- }, m = (h) => {
79
- const f = this._data[e];
80
- return f ?? h;
69
+ }, l = (h) => {
70
+ const y = this._data[e];
71
+ return y ?? h;
81
72
  };
82
- let y;
83
- if (n ? y = {
73
+ let f;
74
+ if (n ? f = {
84
75
  label: (a == null ? void 0 : a.label) ?? e,
85
76
  required: (a == null ? void 0 : a.required) ?? !1,
86
77
  readOnly: !0,
87
78
  defaultValue: a == null ? void 0 : a.defaultValue,
88
79
  meta: s,
89
80
  get: () => this._data[e],
90
- getOrDefault: m,
91
- validate: l
92
- } : y = {
81
+ getOrDefault: l,
82
+ validate: i
83
+ } : f = {
93
84
  label: (a == null ? void 0 : a.label) ?? e,
94
85
  required: (a == null ? void 0 : a.required) ?? !1,
95
86
  readOnly: !1,
96
87
  defaultValue: a == null ? void 0 : a.defaultValue,
97
88
  meta: s,
98
89
  get: () => this._data[e],
99
- getOrDefault: m,
90
+ getOrDefault: l,
100
91
  set: (h) => {
101
92
  this._data[e] = h;
102
93
  },
103
- validate: l
94
+ validate: i
104
95
  }, 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];
96
+ const h = this._bdo.getBoId(), y = f;
97
+ s.Type === "Image" ? (y.getDownloadUrl = async (u) => {
98
+ const d = this._requireInstanceId(), _ = this._data[e];
108
99
  if (!(_ != null && _._id))
109
100
  throw new Error(`${e} has no image to download`);
110
- return i(h).getDownloadUrl(
111
- c,
101
+ return o(h).getDownloadUrl(
102
+ d,
112
103
  e,
113
104
  _._id,
114
- o
105
+ u
115
106
  );
116
- }, n || (f.upload = async (o) => {
117
- v(o.name, "Image");
118
- const c = this._requireInstanceId(), _ = {
119
- FileName: o.name,
120
- Size: o.size,
121
- FileExtension: E(o.name)
122
- }, [u] = await i(h).getUploadUrl(
123
- c,
107
+ }, n || (y.upload = async (u) => {
108
+ E(u.name, "Image");
109
+ const d = this._requireInstanceId(), _ = {
110
+ FileName: u.name,
111
+ Size: u.size,
112
+ FileExtension: v(u.name)
113
+ }, [c] = await o(h).getUploadUrl(
114
+ d,
124
115
  e,
125
116
  [_]
126
117
  );
127
- await fetch(u.UploadUrl.URL, {
118
+ await fetch(c.UploadUrl.URL, {
128
119
  method: "PUT",
129
- headers: { "Content-Type": u.ContentType },
130
- body: o
120
+ headers: { "Content-Type": c.ContentType },
121
+ body: u
131
122
  });
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
123
+ const b = {
124
+ _id: c._id,
125
+ _name: c._name,
126
+ FileName: c.FileName,
127
+ FileExtension: c.FileExtension,
128
+ Size: c.Size,
129
+ ContentType: c.ContentType
139
130
  };
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))
131
+ return this._data[e] = b, b;
132
+ }, y.deleteAttachment = async () => {
133
+ const u = this._requireInstanceId(), d = this._data[e];
134
+ if (!(d != null && d._id))
144
135
  throw new Error(`${e} has no image to delete`);
145
- await i(h).deleteAttachment(o, e, c._id), this._data[e] = null;
146
- })) : (f.getDownloadUrl = async (o, c) => {
136
+ await o(h).deleteAttachment(u, e, d._id), this._data[e] = null;
137
+ })) : (y.getDownloadUrl = async (u, d) => {
147
138
  const _ = this._requireInstanceId();
148
- return i(h).getDownloadUrl(
139
+ return o(h).getDownloadUrl(
149
140
  _,
150
141
  e,
151
- o,
152
- c
142
+ u,
143
+ d
153
144
  );
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,
145
+ }, y.getDownloadUrls = async (u) => {
146
+ const d = this._requireInstanceId();
147
+ return o(h).getDownloadUrls(d, e, u);
148
+ }, n || (y.upload = async (u) => {
149
+ for (const p of u)
150
+ E(p.name, "File");
151
+ const d = this._requireInstanceId(), _ = u.map((p) => ({
152
+ FileName: p.name,
153
+ Size: p.size,
154
+ FileExtension: v(p.name)
155
+ })), c = await o(h).getUploadUrl(
156
+ d,
166
157
  e,
167
158
  _
168
- ), p = await Promise.all(
169
- o.map(async (b, N) => (await fetch(u[N].UploadUrl.URL, {
159
+ ), b = await Promise.all(
160
+ u.map(async (p, N) => (await fetch(c[N].UploadUrl.URL, {
170
161
  method: "PUT",
171
- headers: { "Content-Type": u[N].ContentType },
172
- body: b
162
+ headers: { "Content-Type": c[N].ContentType },
163
+ body: p
173
164
  }), {
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
165
+ _id: c[N]._id,
166
+ _name: c[N]._name,
167
+ FileName: c[N].FileName,
168
+ FileExtension: c[N].FileExtension,
169
+ Size: c[N].Size,
170
+ ContentType: c[N].ContentType
180
171
  }))
181
- ), A = this._data[e] ?? [];
172
+ ), S = this._data[e] ?? [];
182
173
  return this._data[e] = [
183
- ...A,
184
- ...p
185
- ], p;
186
- }, f.deleteAttachment = async (o) => {
187
- const c = this._requireInstanceId();
188
- await i(h).deleteAttachment(
189
- c,
174
+ ...S,
175
+ ...b
176
+ ], b;
177
+ }, y.deleteAttachment = async (u) => {
178
+ const d = this._requireInstanceId();
179
+ await o(h).deleteAttachment(
180
+ d,
190
181
  e,
191
- o
182
+ u
192
183
  );
193
184
  const _ = this._data[e] ?? [];
194
185
  this._data[e] = _.filter(
195
- (u) => u._id !== o
186
+ (c) => c._id !== u
196
187
  );
197
188
  }));
198
189
  }
199
- return this._accessorCache.set(e, y), y;
190
+ return this._accessorCache.set(e, f), f;
200
191
  }
201
192
  /**
202
193
  * Validate all fields and return combined results
203
194
  */
204
195
  validate() {
205
- const e = this._bdo.getFields(), t = [], a = this.toJSON();
196
+ const e = this._bdo.getFields(), r = [], a = this.toJSON();
206
197
  for (const [s, n] of Object.entries(e)) {
207
198
  if (n.readOnly) continue;
208
- const l = this._data[s], m = n.validate(l);
209
- if (!m.valid) {
210
- t.push(...m.errors);
199
+ const i = this._data[s], l = n.validate(i);
200
+ if (!l.valid) {
201
+ r.push(...l.errors);
211
202
  continue;
212
203
  }
213
204
  if (this._bdo.hasMetadata()) {
214
- const y = this._bdo.validateFieldExpression(
205
+ const f = this._bdo.validateFieldExpression(
215
206
  s,
216
- l,
207
+ i,
217
208
  a
218
209
  );
219
- y.valid || t.push(...y.errors);
210
+ f.valid || r.push(...f.errors);
220
211
  }
221
212
  }
222
213
  return {
223
- valid: t.length === 0,
224
- errors: t
214
+ valid: r.length === 0,
215
+ errors: r
225
216
  };
226
217
  }
227
218
  /**
@@ -231,7 +222,7 @@ class w {
231
222
  return { ...this._data };
232
223
  }
233
224
  }
234
- const R = {
225
+ const C = {
235
226
  // ============================================================
236
227
  // STRING FUNCTIONS (7)
237
228
  // ============================================================
@@ -239,27 +230,27 @@ const R = {
239
230
  * Concatenate multiple values into a single string
240
231
  * @example CONCAT("Hello", " ", "World") => "Hello World"
241
232
  */
242
- CONCAT: (...r) => r.map((e) => String(e ?? "")).join(""),
233
+ CONCAT: (...t) => t.map((e) => String(e ?? "")).join(""),
243
234
  /**
244
235
  * Convert string to uppercase
245
236
  * @example UPPER("hello") => "HELLO"
246
237
  */
247
- UPPER: (r) => String(r ?? "").toUpperCase(),
238
+ UPPER: (t) => String(t ?? "").toUpperCase(),
248
239
  /**
249
240
  * Convert string to lowercase
250
241
  * @example LOWER("HELLO") => "hello"
251
242
  */
252
- LOWER: (r) => String(r ?? "").toLowerCase(),
243
+ LOWER: (t) => String(t ?? "").toLowerCase(),
253
244
  /**
254
245
  * Remove leading and trailing whitespace
255
246
  * @example TRIM(" hello ") => "hello"
256
247
  */
257
- TRIM: (r) => String(r ?? "").trim(),
248
+ TRIM: (t) => String(t ?? "").trim(),
258
249
  /**
259
250
  * Get the length of a string
260
251
  * @example LENGTH("hello") => 5
261
252
  */
262
- LENGTH: (r) => String(r ?? "").length,
253
+ LENGTH: (t) => String(t ?? "").length,
263
254
  /**
264
255
  * Extract a substring
265
256
  * @param str - Source string
@@ -267,15 +258,15 @@ const R = {
267
258
  * @param len - Optional length of substring
268
259
  * @example SUBSTRING("hello", 1, 3) => "ell"
269
260
  */
270
- SUBSTRING: (r, e, t) => String(r ?? "").substring(
261
+ SUBSTRING: (t, e, r) => String(t ?? "").substring(
271
262
  e,
272
- t !== void 0 ? e + t : void 0
263
+ r !== void 0 ? e + r : void 0
273
264
  ),
274
265
  /**
275
266
  * Replace occurrences of a substring
276
267
  * @example REPLACE("hello", "l", "L") => "heLlo" (first occurrence only)
277
268
  */
278
- REPLACE: (r, e, t) => String(r ?? "").replace(e, t),
269
+ REPLACE: (t, e, r) => String(t ?? "").replace(e, r),
279
270
  // ============================================================
280
271
  // MATH FUNCTIONS (8)
281
272
  // ============================================================
@@ -283,51 +274,51 @@ const R = {
283
274
  * Sum all numeric arguments
284
275
  * @example SUM(1, 2, 3) => 6
285
276
  */
286
- SUM: (...r) => r.reduce((e, t) => e + (Number(t) || 0), 0),
277
+ SUM: (...t) => t.reduce((e, r) => e + (Number(r) || 0), 0),
287
278
  /**
288
279
  * Calculate average of numeric arguments
289
280
  * @example AVG(1, 2, 3) => 2
290
281
  */
291
- AVG: (...r) => {
292
- const e = r.filter((t) => t != null && !isNaN(Number(t)));
293
- return e.length === 0 ? 0 : e.reduce((t, a) => t + Number(a), 0) / e.length;
282
+ AVG: (...t) => {
283
+ const e = t.filter((r) => r != null && !isNaN(Number(r)));
284
+ return e.length === 0 ? 0 : e.reduce((r, a) => r + Number(a), 0) / e.length;
294
285
  },
295
286
  /**
296
287
  * Get minimum value
297
288
  * @example MIN(1, 2, 3) => 1
298
289
  */
299
- MIN: (...r) => {
300
- const e = r.filter((t) => t != null && !isNaN(Number(t))).map((t) => Number(t));
290
+ MIN: (...t) => {
291
+ const e = t.filter((r) => r != null && !isNaN(Number(r))).map((r) => Number(r));
301
292
  return e.length === 0 ? 0 : Math.min(...e);
302
293
  },
303
294
  /**
304
295
  * Get maximum value
305
296
  * @example MAX(1, 2, 3) => 3
306
297
  */
307
- MAX: (...r) => {
308
- const e = r.filter((t) => t != null && !isNaN(Number(t))).map((t) => Number(t));
298
+ MAX: (...t) => {
299
+ const e = t.filter((r) => r != null && !isNaN(Number(r))).map((r) => Number(r));
309
300
  return e.length === 0 ? 0 : Math.max(...e);
310
301
  },
311
302
  /**
312
303
  * Get absolute value
313
304
  * @example ABS(-5) => 5
314
305
  */
315
- ABS: (r) => Math.abs(Number(r) || 0),
306
+ ABS: (t) => Math.abs(Number(t) || 0),
316
307
  /**
317
308
  * Round to nearest integer
318
309
  * @example ROUND(1.5) => 2
319
310
  */
320
- ROUND: (r) => Math.round(Number(r) || 0),
311
+ ROUND: (t) => Math.round(Number(t) || 0),
321
312
  /**
322
313
  * Round down to nearest integer
323
314
  * @example FLOOR(1.9) => 1
324
315
  */
325
- FLOOR: (r) => Math.floor(Number(r) || 0),
316
+ FLOOR: (t) => Math.floor(Number(t) || 0),
326
317
  /**
327
318
  * Round up to nearest integer
328
319
  * @example CEIL(1.1) => 2
329
320
  */
330
- CEIL: (r) => Math.ceil(Number(r) || 0),
321
+ CEIL: (t) => Math.ceil(Number(t) || 0),
331
322
  // ============================================================
332
323
  // DATE FUNCTIONS (6)
333
324
  // ============================================================
@@ -335,51 +326,51 @@ const R = {
335
326
  * Extract year from date
336
327
  * @example YEAR("2024-01-15") => 2024
337
328
  */
338
- YEAR: (r) => {
339
- const e = new Date(r);
329
+ YEAR: (t) => {
330
+ const e = new Date(t);
340
331
  return isNaN(e.getTime()) ? 0 : e.getFullYear();
341
332
  },
342
333
  /**
343
334
  * Extract month from date (1-12)
344
335
  * @example MONTH("2024-01-15") => 1
345
336
  */
346
- MONTH: (r) => {
347
- const e = new Date(r);
337
+ MONTH: (t) => {
338
+ const e = new Date(t);
348
339
  return isNaN(e.getTime()) ? 0 : e.getMonth() + 1;
349
340
  },
350
341
  /**
351
342
  * Extract day of month from date (1-31)
352
343
  * @example DAY("2024-01-15") => 15
353
344
  */
354
- DAY: (r) => {
355
- const e = new Date(r);
345
+ DAY: (t) => {
346
+ const e = new Date(t);
356
347
  return isNaN(e.getTime()) ? 0 : e.getDate();
357
348
  },
358
349
  /**
359
350
  * Calculate difference in days between two dates
360
351
  * @example DATE_DIFF("2024-01-15", "2024-01-10") => 5
361
352
  */
362
- DATE_DIFF: (r, e) => {
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());
353
+ DATE_DIFF: (t, e) => {
354
+ const r = new Date(t), a = new Date(e);
355
+ if (isNaN(r.getTime()) || isNaN(a.getTime())) return 0;
356
+ const s = Math.abs(r.getTime() - a.getTime());
366
357
  return Math.ceil(s / (1e3 * 60 * 60 * 24));
367
358
  },
368
359
  /**
369
360
  * Add days to a date
370
361
  * @example ADD_DAYS("2024-01-15", 5) => Date("2024-01-20")
371
362
  */
372
- ADD_DAYS: (r, e) => {
373
- const t = new Date(r);
374
- return isNaN(t.getTime()) ? /* @__PURE__ */ new Date(NaN) : (t.setDate(t.getDate() + e), t);
363
+ ADD_DAYS: (t, e) => {
364
+ const r = new Date(t);
365
+ return isNaN(r.getTime()) ? /* @__PURE__ */ new Date(NaN) : (r.setDate(r.getDate() + e), r);
375
366
  },
376
367
  /**
377
368
  * Add months to a date
378
369
  * @example ADD_MONTHS("2024-01-15", 2) => Date("2024-03-15")
379
370
  */
380
- ADD_MONTHS: (r, e) => {
381
- const t = new Date(r);
382
- return isNaN(t.getTime()) ? /* @__PURE__ */ new Date(NaN) : (t.setMonth(t.getMonth() + e), t);
371
+ ADD_MONTHS: (t, e) => {
372
+ const r = new Date(t);
373
+ return isNaN(r.getTime()) ? /* @__PURE__ */ new Date(NaN) : (r.setMonth(r.getMonth() + e), r);
383
374
  },
384
375
  // ============================================================
385
376
  // CONDITIONAL FUNCTIONS (1)
@@ -388,7 +379,7 @@ const R = {
388
379
  * Return value based on condition
389
380
  * @example IF(true, "yes", "no") => "yes"
390
381
  */
391
- IF: (r, e, t) => r ? e : t,
382
+ IF: (t, e, r) => t ? e : r,
392
383
  // ============================================================
393
384
  // SYSTEM FUNCTIONS (1)
394
385
  // ============================================================
@@ -396,16 +387,16 @@ const R = {
396
387
  * Generate a UUID v4
397
388
  * @example UUID() => "550e8400-e29b-41d4-a716-446655440000"
398
389
  */
399
- UUID: () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
390
+ UUID: () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (t) => {
400
391
  const e = Math.random() * 16 | 0;
401
- return (r === "x" ? e : e & 3 | 8).toString(16);
392
+ return (t === "x" ? e : e & 3 | 8).toString(16);
402
393
  })
403
394
  };
404
- function C() {
405
- const r = /* @__PURE__ */ new Date();
395
+ function M() {
396
+ const t = /* @__PURE__ */ new Date();
406
397
  return {
407
- NOW: r,
408
- TODAY: new Date(r.getFullYear(), r.getMonth(), r.getDate()),
398
+ NOW: t,
399
+ TODAY: new Date(t.getFullYear(), t.getMonth(), t.getDate()),
409
400
  CURRENT_USER: {
410
401
  // These would come from auth context in real usage
411
402
  // For now, provide empty defaults
@@ -416,50 +407,71 @@ function C() {
416
407
  }
417
408
  };
418
409
  }
419
- function g(r, e) {
420
- var t;
421
- switch (r.Type) {
410
+ function g(t, e) {
411
+ var r;
412
+ switch (t.Type) {
422
413
  case "Literal":
423
- return r.Value;
414
+ return t.Value;
424
415
  case "Identifier":
425
- return e.formValues[r.Name];
416
+ return e.formValues[t.Name];
426
417
  case "SystemIdentifier":
427
- return M(r, e);
418
+ return I(t, e);
428
419
  case "BinaryExpression":
429
- return D(r, e);
420
+ return V(t, e);
430
421
  case "LogicalExpression":
431
- return I(r, e);
422
+ return q(t, e);
432
423
  case "CallExpression":
433
- return B(r, e);
424
+ return j(t, e);
434
425
  case "MemberExpression":
435
- return V(r, e);
426
+ return P(t, e);
436
427
  case "AssignmentExpression":
437
- return ((t = r.Arguments) == null ? void 0 : t.length) === 1 ? g(r.Arguments[0], e) : void 0;
428
+ return ((r = t.Arguments) == null ? void 0 : r.length) === 1 ? g(t.Arguments[0], e) : void 0;
438
429
  default:
439
- throw new Error(`Unsupported expression type: ${r.Type}`);
430
+ throw new Error(`Unsupported expression type: ${t.Type}`);
440
431
  }
441
432
  }
442
- function M(r, e) {
443
- const t = r.Name, a = e.systemValues[t];
444
- return r.Property ? a && typeof a == "object" ? a[r.Property.Name] : void 0 : a;
433
+ function I(t, e) {
434
+ const r = t.Name, a = e.systemValues[r];
435
+ return t.Property ? a && typeof a == "object" ? a[t.Property.Name] : void 0 : a;
436
+ }
437
+ const B = /^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2})?)?$/;
438
+ function O(t) {
439
+ if (t instanceof Date) return t.getTime();
440
+ if (typeof t == "string" && B.test(t)) {
441
+ const e = t.includes("T") || t.includes(" ") ? t.replace(" ", "T") : t + "T00:00:00";
442
+ return new Date(e).getTime();
443
+ }
444
+ return NaN;
445
+ }
446
+ function x(t, e) {
447
+ const r = O(t), a = O(e);
448
+ return !isNaN(r) && !isNaN(a) ? { l: r, r: a } : { l: Number(t), r: Number(e) };
445
449
  }
446
- function D(r, e) {
447
- if (!r.Arguments || r.Arguments.length < 2)
450
+ function V(t, e) {
451
+ if (!t.Arguments || t.Arguments.length < 2)
448
452
  throw new Error("BinaryExpression requires 2 arguments");
449
- const [t, a] = r.Arguments, s = g(t, e), n = g(a, e);
450
- switch (r.Operator) {
453
+ const [r, a] = t.Arguments, s = g(r, e), n = g(a, e);
454
+ switch (t.Operator) {
451
455
  case "==":
452
456
  return s == n;
453
457
  case "!=":
454
458
  return s != n;
455
- case "<":
456
- return Number(s) < Number(n);
457
- case "<=":
458
- return Number(s) <= Number(n);
459
- case ">":
460
- return Number(s) > Number(n);
461
- case ">=":
462
- return Number(s) >= Number(n);
459
+ case "<": {
460
+ const { l: i, r: l } = x(s, n);
461
+ return i < l;
462
+ }
463
+ case "<=": {
464
+ const { l: i, r: l } = x(s, n);
465
+ return i <= l;
466
+ }
467
+ case ">": {
468
+ const { l: i, r: l } = x(s, n);
469
+ return i > l;
470
+ }
471
+ case ">=": {
472
+ const { l: i, r: l } = x(s, n);
473
+ return i >= l;
474
+ }
463
475
  case "+":
464
476
  return Number(s) + Number(n);
465
477
  case "-":
@@ -471,50 +483,50 @@ function D(r, e) {
471
483
  case "%":
472
484
  return Number(s) % Number(n);
473
485
  default:
474
- throw new Error(`Unsupported binary operator: ${r.Operator}`);
486
+ throw new Error(`Unsupported binary operator: ${t.Operator}`);
475
487
  }
476
488
  }
477
- function I(r, e) {
478
- if (!r.Arguments || r.Arguments.length === 0)
489
+ function q(t, e) {
490
+ if (!t.Arguments || t.Arguments.length === 0)
479
491
  throw new Error("LogicalExpression requires at least 1 argument");
480
- const t = r.Arguments;
481
- switch (r.Operator) {
492
+ const r = t.Arguments;
493
+ switch (t.Operator) {
482
494
  case "AND":
483
- return t.every((a) => !!g(a, e));
495
+ return r.every((a) => !!g(a, e));
484
496
  case "OR":
485
- return t.some((a) => !!g(a, e));
497
+ return r.some((a) => !!g(a, e));
486
498
  case "!":
487
- return !g(t[0], e);
499
+ return !g(r[0], e);
488
500
  default:
489
- throw new Error(`Unsupported logical operator: ${r.Operator}`);
501
+ throw new Error(`Unsupported logical operator: ${t.Operator}`);
490
502
  }
491
503
  }
492
- function B(r, e) {
493
- if (!r.Callee)
504
+ function j(t, e) {
505
+ if (!t.Callee)
494
506
  throw new Error("CallExpression requires a Callee");
495
- const t = R[r.Callee];
496
- if (!t)
497
- throw new Error(`Unknown function: ${r.Callee}`);
498
- const a = (r.Arguments ?? []).map((s) => g(s, e));
499
- return t(...a);
507
+ const r = C[t.Callee];
508
+ if (!r)
509
+ throw new Error(`Unknown function: ${t.Callee}`);
510
+ const a = (t.Arguments ?? []).map((s) => g(s, e));
511
+ return r(...a);
500
512
  }
501
- function V(r, e) {
513
+ function P(t, e) {
502
514
  var s, n;
503
- if (!((s = r.Arguments) != null && s.length))
515
+ if (!((s = t.Arguments) != null && s.length))
504
516
  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;
517
+ const r = g(t.Arguments[0], e), a = (n = t.Arguments[0].Property) == null ? void 0 : n.Name;
518
+ return a && r && typeof r == "object" ? r[a] : r;
507
519
  }
508
- class q {
520
+ class L {
509
521
  constructor() {
510
522
  /**
511
523
  * Map of field ID to its validation rules
512
524
  */
513
- d(this, "fieldRules", /* @__PURE__ */ new Map());
525
+ m(this, "fieldRules", /* @__PURE__ */ new Map());
514
526
  /**
515
527
  * The loaded BDO metadata
516
528
  */
517
- d(this, "metadata", null);
529
+ m(this, "metadata", null);
518
530
  }
519
531
  /**
520
532
  * Load metadata and extract field validation rules
@@ -527,20 +539,20 @@ class q {
527
539
  * @param metadata - The BDO metadata from the backend
528
540
  */
529
541
  loadMetadata(e) {
530
- var t, a;
542
+ var r, a;
531
543
  this.metadata = e, this.fieldRules.clear();
532
544
  for (const [s, n] of Object.entries(e.Fields)) {
533
- const l = [];
545
+ const i = [];
534
546
  if (n.Validation && Array.isArray(n.Validation)) {
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);
547
+ for (const l of n.Validation)
548
+ if (typeof l == "object" && l.ExpressionTree)
549
+ i.push(l);
550
+ else if (typeof l == "string") {
551
+ const f = (a = (r = e.Rules) == null ? void 0 : r.Validation) == null ? void 0 : a[l];
552
+ f && i.push(f);
541
553
  }
542
554
  }
543
- l.length > 0 && this.fieldRules.set(s, l);
555
+ i.length > 0 && this.fieldRules.set(s, i);
544
556
  }
545
557
  }
546
558
  /**
@@ -572,25 +584,25 @@ class q {
572
584
  * @param allValues - All form field values (for cross-field validation)
573
585
  * @returns ValidationResult with valid=true if all rules pass
574
586
  */
575
- validateField(e, t, a) {
587
+ validateField(e, r, a) {
576
588
  const s = this.fieldRules.get(e);
577
589
  if (!s || s.length === 0)
578
590
  return { valid: !0, errors: [] };
579
591
  const n = {
580
- formValues: { ...a, [e]: t },
581
- systemValues: C()
592
+ formValues: { ...a, [e]: r },
593
+ systemValues: M()
582
594
  };
583
- for (const l of s)
595
+ for (const i of s)
584
596
  try {
585
- if (!g(l.ExpressionTree, n))
597
+ if (!g(i.ExpressionTree, n))
586
598
  return {
587
599
  valid: !1,
588
- errors: [l.Message || `Validation failed: ${l.Name || l.Id}`]
600
+ errors: [i.Message || `Validation failed: ${i.Name || i.Id}`]
589
601
  };
590
- } catch (m) {
602
+ } catch (l) {
591
603
  console.warn(
592
- `Expression evaluation failed for rule ${l.Id}:`,
593
- m
604
+ `Expression evaluation failed for rule ${i.Id}:`,
605
+ l
594
606
  );
595
607
  }
596
608
  return { valid: !0, errors: [] };
@@ -605,44 +617,44 @@ class q {
605
617
  * @returns ValidationResult with all collected errors
606
618
  */
607
619
  validateAll(e) {
608
- const t = [];
620
+ const r = [];
609
621
  for (const a of this.fieldRules.keys()) {
610
622
  const s = this.validateField(a, e[a], e);
611
- s.valid || t.push(...s.errors);
623
+ s.valid || r.push(...s.errors);
612
624
  }
613
625
  return {
614
- valid: t.length === 0,
615
- errors: t
626
+ valid: r.length === 0,
627
+ errors: r
616
628
  };
617
629
  }
618
630
  }
619
- class z {
631
+ class k {
620
632
  constructor() {
621
633
  // ============================================================
622
634
  // SYSTEM FIELDS (inherited by all BDOs)
623
635
  // ============================================================
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 }));
636
+ m(this, "_id", new F({ _id: "_id", Name: "ID", Type: "String", ReadOnly: !0 }));
637
+ m(this, "_created_at", new A({ _id: "_created_at", Name: "Created At", Type: "DateTime", ReadOnly: !0 }));
638
+ m(this, "_modified_at", new A({ _id: "_modified_at", Name: "Modified At", Type: "DateTime", ReadOnly: !0 }));
639
+ m(this, "_created_by", new U({ _id: "_created_by", Name: "Created By", Type: "User", ReadOnly: !0 }));
640
+ m(this, "_modified_by", new U({ _id: "_modified_by", Name: "Modified By", Type: "User", ReadOnly: !0 }));
641
+ m(this, "_version", new F({ _id: "_version", Name: "Version", Type: "String", ReadOnly: !0 }));
642
+ m(this, "_m_version", new F({ _id: "_m_version", Name: "Metadata Version", Type: "String", ReadOnly: !0 }));
631
643
  /**
632
644
  * Whether fields have been bound to this BDO
633
645
  */
634
- d(this, "_fieldsBound", !1);
646
+ m(this, "_fieldsBound", !1);
635
647
  /**
636
648
  * Cached field map
637
649
  */
638
- d(this, "_fieldsCache", null);
650
+ m(this, "_fieldsCache", null);
639
651
  // ============================================================
640
652
  // EXPRESSION ENGINE (for backend validation rules)
641
653
  // ============================================================
642
654
  /**
643
655
  * Expression engine instance for evaluating backend validation rules
644
656
  */
645
- d(this, "_expressionEngine", new q());
657
+ m(this, "_expressionEngine", new L());
646
658
  }
647
659
  // ============================================================
648
660
  // FIELD DEFINITIONS (auto-discovered)
@@ -662,13 +674,13 @@ class z {
662
674
  if (this._fieldsCache)
663
675
  return this._fieldsCache;
664
676
  const e = {};
665
- for (const t of Object.keys(this)) {
666
- const a = this[t];
667
- a instanceof x && (e[t] = a);
677
+ for (const r of Object.keys(this)) {
678
+ const a = this[r];
679
+ a instanceof T && (e[r] = a);
668
680
  }
669
681
  if (!this._fieldsBound) {
670
- for (const t of Object.values(e))
671
- t._parentBoId = this.meta._id;
682
+ for (const r of Object.values(e))
683
+ r._parentBoId = this.meta._id;
672
684
  this._fieldsBound = !0;
673
685
  }
674
686
  return this._fieldsCache = e, e;
@@ -705,8 +717,8 @@ class z {
705
717
  * @param allValues - All form field values (for cross-field validation)
706
718
  * @returns ValidationResultType from expression evaluation
707
719
  */
708
- validateFieldExpression(e, t, a) {
709
- return this._expressionEngine.hasMetadata() ? this._expressionEngine.validateField(e, t, a) : { valid: !0, errors: [] };
720
+ validateFieldExpression(e, r, a) {
721
+ return this._expressionEngine.hasMetadata() ? this._expressionEngine.validateField(e, r, a) : { valid: !0, errors: [] };
710
722
  }
711
723
  // ============================================================
712
724
  // READ OPERATIONS
@@ -715,14 +727,14 @@ class z {
715
727
  * Get a single record by ID
716
728
  */
717
729
  async get(e) {
718
- const t = await i(this.meta._id).get(e);
719
- return new w(this, t);
730
+ const r = await o(this.meta._id).get(e);
731
+ return new w(this, r);
720
732
  }
721
733
  /**
722
734
  * List records with optional filtering, sorting, and pagination
723
735
  */
724
736
  async list(e) {
725
- return (await i(this.meta._id).list(e)).Data.map(
737
+ return (await o(this.meta._id).list(e)).Data.map(
726
738
  (a) => new w(this, a)
727
739
  );
728
740
  }
@@ -730,7 +742,7 @@ class z {
730
742
  * Get count of records matching the filter criteria
731
743
  */
732
744
  async count(e) {
733
- return (await i(this.meta._id).count(e)).Count;
745
+ return (await o(this.meta._id).count(e)).Count;
734
746
  }
735
747
  // ============================================================
736
748
  // CREATE OPERATIONS
@@ -740,10 +752,10 @@ class z {
740
752
  * Returns an Item with _id from API response + the input data as field accessors
741
753
  */
742
754
  async create(e) {
743
- const t = await i(this.meta._id).create(e);
755
+ const r = await o(this.meta._id).create(e);
744
756
  return new w(
745
757
  this,
746
- { ...e, _id: t._id }
758
+ { ...e, _id: r._id }
747
759
  );
748
760
  }
749
761
  // ============================================================
@@ -752,8 +764,8 @@ class z {
752
764
  /**
753
765
  * Update an existing record
754
766
  */
755
- async update(e, t) {
756
- return i(this.meta._id).update(e, t);
767
+ async update(e, r) {
768
+ return o(this.meta._id).update(e, r);
757
769
  }
758
770
  // ============================================================
759
771
  // DELETE OPERATIONS
@@ -762,7 +774,7 @@ class z {
762
774
  * Delete a record by ID
763
775
  */
764
776
  async delete(e) {
765
- return i(this.meta._id).delete(e);
777
+ return o(this.meta._id).delete(e);
766
778
  }
767
779
  // ============================================================
768
780
  // DRAFT OPERATIONS (for useBDOForm integration)
@@ -771,14 +783,14 @@ class z {
771
783
  * Create a draft - compute fields without persisting
772
784
  */
773
785
  async draft(e) {
774
- return i(this.meta._id).draft(e);
786
+ return o(this.meta._id).draft(e);
775
787
  }
776
788
  /**
777
789
  * Interactive draft - create/update draft without instance ID
778
790
  * Returns computed fields along with a temporary _id
779
791
  */
780
792
  async draftInteraction(e) {
781
- return i(this.meta._id).draftInteraction(e);
793
+ return o(this.meta._id).draftInteraction(e);
782
794
  }
783
795
  /**
784
796
  * Create an Item wrapper for manipulating data with field accessors
@@ -790,14 +802,14 @@ class z {
790
802
  /**
791
803
  * Commit an update draft - finalize changes on an existing record
792
804
  */
793
- async draftUpdate(e, t) {
794
- return i(this.meta._id).draftUpdate(e, t);
805
+ async draftUpdate(e, r) {
806
+ return o(this.meta._id).draftUpdate(e, r);
795
807
  }
796
808
  /**
797
809
  * Patch an existing draft - compute fields during editing
798
810
  */
799
- async draftPatch(e, t) {
800
- return i(this.meta._id).draftPatch(e, t);
811
+ async draftPatch(e, r) {
812
+ return o(this.meta._id).draftPatch(e, r);
801
813
  }
802
814
  // ============================================================
803
815
  // ANALYTICS OPERATIONS
@@ -806,13 +818,13 @@ class z {
806
818
  * Get aggregated metrics grouped by dimensions
807
819
  */
808
820
  async metric(e) {
809
- return i(this.meta._id).metric(e);
821
+ return o(this.meta._id).metric(e);
810
822
  }
811
823
  /**
812
824
  * Get pivot table data
813
825
  */
814
826
  async pivot(e) {
815
- return i(this.meta._id).pivot(e);
827
+ return o(this.meta._id).pivot(e);
816
828
  }
817
829
  // ============================================================
818
830
  // ATTACHMENT OPERATIONS
@@ -820,29 +832,29 @@ class z {
820
832
  /**
821
833
  * Get signed upload URLs for file/image attachments
822
834
  */
823
- async getUploadUrl(e, t, a) {
824
- return i(this.meta._id).getUploadUrl(e, t, a);
835
+ async getUploadUrl(e, r, a) {
836
+ return o(this.meta._id).getUploadUrl(e, r, a);
825
837
  }
826
838
  /**
827
839
  * Get signed download URL for a single attachment
828
840
  */
829
- async getDownloadUrl(e, t, a, s) {
830
- return i(this.meta._id).getDownloadUrl(e, t, a, s);
841
+ async getDownloadUrl(e, r, a, s) {
842
+ return o(this.meta._id).getDownloadUrl(e, r, a, s);
831
843
  }
832
844
  /**
833
845
  * Get signed download URLs for all attachments on a field
834
846
  */
835
- async getDownloadUrls(e, t, a) {
836
- return i(this.meta._id).getDownloadUrls(e, t, a);
847
+ async getDownloadUrls(e, r, a) {
848
+ return o(this.meta._id).getDownloadUrls(e, r, a);
837
849
  }
838
850
  /**
839
851
  * Delete an attachment
840
852
  */
841
- async deleteAttachment(e, t, a) {
842
- return i(this.meta._id).deleteAttachment(e, t, a);
853
+ async deleteAttachment(e, r, a) {
854
+ return o(this.meta._id).deleteAttachment(e, r, a);
843
855
  }
844
856
  }
845
- class J extends x {
857
+ class G extends T {
846
858
  constructor(e) {
847
859
  super(e);
848
860
  }
@@ -857,7 +869,7 @@ class J extends x {
857
869
  } : { valid: !0, errors: [] };
858
870
  }
859
871
  }
860
- class Y extends x {
872
+ class H extends T {
861
873
  constructor(e) {
862
874
  super(e);
863
875
  }
@@ -872,7 +884,7 @@ class Y extends x {
872
884
  } : { valid: !0, errors: [] };
873
885
  }
874
886
  }
875
- class k extends x {
887
+ class K extends T {
876
888
  constructor(e) {
877
889
  super(e);
878
890
  }
@@ -887,21 +899,21 @@ class k extends x {
887
899
  }
888
900
  }
889
901
  export {
890
- J as ArrayField,
891
- z as BaseBdo,
892
- x as BaseField,
893
- K as BooleanField,
894
- W as DateField,
895
- T as DateTimeField,
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
+ G as ArrayField,
903
+ k as BaseBdo,
904
+ T as BaseField,
905
+ Q as BooleanField,
906
+ Z as DateField,
907
+ A as DateTimeField,
908
+ ee as FileField,
909
+ K as ImageField,
910
+ te as NumberField,
911
+ H as ObjectField,
912
+ re as ReferenceField,
913
+ ae as SelectField,
902
914
  F as StringField,
903
- se as SystemField,
904
- te as TextAreaField,
905
- re as TextField,
915
+ oe as SystemField,
916
+ se as TextAreaField,
917
+ ne as TextField,
906
918
  U as UserField
907
919
  };