@stoker-platform/node-client 0.5.63 → 0.5.64

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/bundle.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import He from "lodash/isEqual.js";
2
2
  import Zo from "lodash/merge.js";
3
3
  import zo from "lodash/set.js";
4
- import he from "lodash/cloneDeep.js";
4
+ import fe from "lodash/cloneDeep.js";
5
5
  import { getApp as ni, initializeApp as si, applicationDefault as ri } from "firebase-admin/app";
6
- import { getFirestore as ce, Timestamp as ut, FieldValue as fe } from "firebase-admin/firestore";
6
+ import { getFirestore as ce, Timestamp as ut, FieldValue as he } from "firebase-admin/firestore";
7
7
  import { pathToFileURL as ii } from "node:url";
8
8
  import qo from "cross-spawn";
9
9
  import { getDatabase as oi } from "firebase-admin/database";
10
- import { getAuth as _t } from "firebase-admin/auth";
10
+ import { getAuth as Et } from "firebase-admin/auth";
11
11
  const zn = (n) => !!n.auth, Se = (n, e) => {
12
12
  if (e?.operations)
13
13
  return e.operations.includes(n);
@@ -572,7 +572,7 @@ const zn = (n) => !!n.auth, Se = (n, e) => {
572
572
  Zo(Xn, m);
573
573
  }
574
574
  return c;
575
- }, dt = (n, e, t) => {
575
+ }, ft = (n, e, t) => {
576
576
  const s = Object.values(t.collections), { labels: r } = e;
577
577
  let i = !1;
578
578
  for (const o of s) {
@@ -595,7 +595,7 @@ const zn = (n) => !!n.auth, Se = (n, e) => {
595
595
  });
596
596
  });
597
597
  }), r;
598
- }, es = (n) => JSON.stringify(n.map((e) => e.name)), gt = [
598
+ }, es = (n) => JSON.stringify(n.map((e) => e.name)), wt = [
599
599
  "id",
600
600
  "Collection_Path",
601
601
  "Last_Write_At",
@@ -607,7 +607,7 @@ const zn = (n) => !!n.auth, Se = (n, e) => {
607
607
  "Created_At",
608
608
  "Saved_At",
609
609
  "Created_By"
610
- ], Bn = () => gt.map((n) => {
610
+ ], Bn = () => wt.map((n) => {
611
611
  let e = "", t;
612
612
  switch (n) {
613
613
  case "id":
@@ -703,17 +703,17 @@ const zn = (n) => !!n.auth, Se = (n, e) => {
703
703
  }), r?.filter((c) => (!c.roles || c.roles.includes(e)) && c.field !== "Collection_Path").forEach((c) => {
704
704
  t.push(U(a, c.field));
705
705
  }), i?.range && i.range.fields.forEach((c) => {
706
- gt.includes(c) && t.push(U(a, c));
706
+ wt.includes(c) && t.push(U(a, c));
707
707
  }), o?.forEach((c) => {
708
708
  const d = U(s.concat(a), c.field);
709
- (!c.roles || c.roles.includes(e)) && d && (!d.access || d.access?.includes(e)) && gt.includes(c.field) && t.push(U(a, c.field));
709
+ (!c.roles || c.roles.includes(e)) && d && (!d.access || d.access?.includes(e)) && wt.includes(c.field) && t.push(U(a, c.field));
710
710
  }), hi(n, e).forEach((c) => {
711
- gt.includes(c.name) && t.push(U(a, c.name));
711
+ wt.includes(c.name) && t.push(U(a, c.name));
712
712
  }), [...new Set(t)];
713
713
  }, ia = (n, e, t) => {
714
714
  const s = [], { fields: r, preloadCache: i } = e, o = Bn();
715
715
  i?.range && i.range.fields.forEach((c) => {
716
- gt.includes(c) ? s.push(U(o, c)) : s.push(U(r, c));
716
+ wt.includes(c) ? s.push(U(o, c)) : s.push(U(r, c));
717
717
  });
718
718
  const a = /* @__PURE__ */ new Set(), l = fi(e, t);
719
719
  return Object.entries(l).map(([c, d]) => {
@@ -806,7 +806,7 @@ async function oe(n, e, t, s) {
806
806
  if (n !== "setEmbedding" && (await ts(n, e?.[n], s), n === "postWriteError"))
807
807
  return r;
808
808
  }
809
- const Ws = (n, e, t, s, r, i, o, a, l, c) => (n === "create" && (t.Collection_Path = e, t.Created_At = a, t.Saved_At = l, t.Created_By = o || "System"), t.Last_Write_App = r, t.Last_Write_At = a, t.Last_Save_At = l, t.Last_Write_By = o || "System", t.Last_Write_Connection_Status = i, t.Last_Write_Version = s.version, t), mt = (n, e) => {
809
+ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n === "create" && (t.Collection_Path = e, t.Created_At = a, t.Saved_At = l, t.Created_By = o || "System"), t.Last_Write_App = r, t.Last_Write_At = a, t.Last_Save_At = l, t.Last_Write_By = o || "System", t.Last_Write_Connection_Status = i, t.Last_Write_Version = s.version, t), pt = (n, e) => {
810
810
  const { access: t, queries: s } = n, { serverReadOnly: r } = t, i = /* @__PURE__ */ new Set();
811
811
  if (s)
812
812
  for (const o of s) {
@@ -816,7 +816,7 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n === "create" && (t.Collection_Pa
816
816
  return e.forEach((o) => {
817
817
  X(o) && ["OneToOne", "OneToMany"].includes(o.type) && o.sorting && (typeof o.sorting == "boolean" || !o.sorting.roles?.every((a) => r?.includes(a))) && i.add(o);
818
818
  }), i;
819
- }, Et = (n, e) => {
819
+ }, vt = (n, e) => {
820
820
  const { access: t, recordTitleField: s } = n, { serverReadOnly: r } = t, i = /* @__PURE__ */ new Set();
821
821
  return e.forEach((o) => {
822
822
  (s === o.name || o.sorting && (typeof o.sorting == "boolean" || !o.sorting.roles?.every((a) => r?.includes(a)))) && o.type === "String" && i.add(o);
@@ -831,13 +831,13 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n === "create" && (t.Collection_Pa
831
831
  else if (e[`${i.name}_Array`] = Object.keys(e[i.name]), i.includeFields)
832
832
  for (const o of i.includeFields) {
833
833
  const a = t.collections[i.collection], l = U(a.fields, o);
834
- Et(a, [l]).size === 1 && Object.keys(e[i.name]).forEach((d) => {
834
+ vt(a, [l]).size === 1 && Object.keys(e[i.name]).forEach((d) => {
835
835
  e[i.name][d][o] ? e[i.name][d][`${o}_Lowercase`] = e[i.name][d][o].toLowerCase() : delete e[i.name][d][`${o}_Lowercase`];
836
836
  });
837
837
  }
838
838
  } else
839
839
  delete e[`${i.name}_Array`], delete e[`${i.name}_Single`];
840
- }), mt(n, s).forEach((i) => {
840
+ }), pt(n, s).forEach((i) => {
841
841
  if (e[i.name])
842
842
  if (Re(e[i.name]))
843
843
  e[`${i.name}_Single`] = e[i.name];
@@ -850,14 +850,14 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n === "create" && (t.Collection_Pa
850
850
  }
851
851
  });
852
852
  }, xn = (n, e) => {
853
- Et(n, n.fields).forEach((s) => {
853
+ vt(n, n.fields).forEach((s) => {
854
854
  e[s.name] ? e[`${s.name}_Lowercase`] = e[s.name].toLowerCase() : delete e[`${s.name}_Lowercase`];
855
855
  });
856
856
  }, aa = async (n, e, t, s) => {
857
857
  const { fields: r } = e;
858
858
  for (const i of t.fields) {
859
859
  const o = U(r, i.name);
860
- i.custom?.initialValue !== void 0 && !(s && o.access && !o.access.includes(s)) && (n[i.name] = await ie(i.custom.initialValue, [n]), Et(e, [o]).size === 1 && (n[`${i.name}_Lowercase`] = n[i.name].toLowerCase()));
860
+ i.custom?.initialValue !== void 0 && !(s && o.access && !o.access.includes(s)) && (n[i.name] = await ie(i.custom.initialValue, [n]), vt(e, [o]).size === 1 && (n[`${i.name}_Lowercase`] = n[i.name].toLowerCase()));
861
861
  }
862
862
  for (const i of r)
863
863
  s && i.access && !i.access.includes(s) || ("autoIncrement" in i && i.autoIncrement && !n[i.name] && (n[i.name] = "Pending"), !X(i) && i.nullable && n[i.name] === void 0 && (n[i.name] = null));
@@ -1173,7 +1173,7 @@ class Ee {
1173
1173
  }
1174
1174
  const J = Object.freeze({
1175
1175
  status: "aborted"
1176
- }), Ht = (n) => ({ status: "dirty", value: n }), $e = (n) => ({ status: "valid", value: n }), lr = (n) => n.status === "aborted", cr = (n) => n.status === "dirty", Dt = (n) => n.status === "valid", Nn = (n) => typeof Promise < "u" && n instanceof Promise;
1176
+ }), Ht = (n) => ({ status: "dirty", value: n }), $e = (n) => ({ status: "valid", value: n }), lr = (n) => n.status === "aborted", cr = (n) => n.status === "dirty", At = (n) => n.status === "valid", Nn = (n) => typeof Promise < "u" && n instanceof Promise;
1177
1177
  var W;
1178
1178
  (function(n) {
1179
1179
  n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e?.message;
@@ -1187,7 +1187,7 @@ class Ze {
1187
1187
  }
1188
1188
  }
1189
1189
  const ur = (n, e) => {
1190
- if (Dt(e))
1190
+ if (At(e))
1191
1191
  return { success: !0, data: e.value };
1192
1192
  if (!n.common.issues.length)
1193
1193
  throw new Error("Validation failed but no issues detected.");
@@ -1288,7 +1288,7 @@ class ee {
1288
1288
  if (!this["~standard"].async)
1289
1289
  try {
1290
1290
  const s = this._parseSync({ data: e, path: [], parent: t });
1291
- return Dt(s) ? {
1291
+ return At(s) ? {
1292
1292
  value: s.value
1293
1293
  } : {
1294
1294
  issues: t.common.issues
@@ -1299,7 +1299,7 @@ class ee {
1299
1299
  async: !0
1300
1300
  };
1301
1301
  }
1302
- return this._parseAsync({ data: e, path: [], parent: t }).then((s) => Dt(s) ? {
1302
+ return this._parseAsync({ data: e, path: [], parent: t }).then((s) => At(s) ? {
1303
1303
  value: s.value
1304
1304
  } : {
1305
1305
  issues: t.common.issues
@@ -1340,7 +1340,7 @@ class ee {
1340
1340
  return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof t == "function" ? t(s, r) : t), !1));
1341
1341
  }
1342
1342
  _refinement(e) {
1343
- return new $t({
1343
+ return new Mt({
1344
1344
  schema: this,
1345
1345
  typeName: Y.ZodEffects,
1346
1346
  effect: { type: "refinement", refinement: e }
@@ -1360,7 +1360,7 @@ class ee {
1360
1360
  return ot.create(this, this._def);
1361
1361
  }
1362
1362
  nullable() {
1363
- return Mt.create(this, this._def);
1363
+ return Ft.create(this, this._def);
1364
1364
  }
1365
1365
  nullish() {
1366
1366
  return this.nullable().optional();
@@ -1378,7 +1378,7 @@ class ee {
1378
1378
  return Cn.create(this, e, this._def);
1379
1379
  }
1380
1380
  transform(e) {
1381
- return new $t({
1381
+ return new Mt({
1382
1382
  ...K(this._def),
1383
1383
  schema: this,
1384
1384
  typeName: Y.ZodEffects,
@@ -1853,7 +1853,7 @@ function Aa(n, e) {
1853
1853
  const t = (n.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = t > s ? t : s, i = Number.parseInt(n.toFixed(r).replace(".", "")), o = Number.parseInt(e.toFixed(r).replace(".", ""));
1854
1854
  return i % o / 10 ** r;
1855
1855
  }
1856
- class At extends ee {
1856
+ class Ct extends ee {
1857
1857
  constructor() {
1858
1858
  super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1859
1859
  }
@@ -1911,7 +1911,7 @@ class At extends ee {
1911
1911
  return this.setLimit("max", e, !1, W.toString(t));
1912
1912
  }
1913
1913
  setLimit(e, t, s, r) {
1914
- return new At({
1914
+ return new Ct({
1915
1915
  ...this._def,
1916
1916
  checks: [
1917
1917
  ...this._def.checks,
@@ -1925,7 +1925,7 @@ class At extends ee {
1925
1925
  });
1926
1926
  }
1927
1927
  _addCheck(e) {
1928
- return new At({
1928
+ return new Ct({
1929
1929
  ...this._def,
1930
1930
  checks: [...this._def.checks, e]
1931
1931
  });
@@ -2019,7 +2019,7 @@ class At extends ee {
2019
2019
  return Number.isFinite(t) && Number.isFinite(e);
2020
2020
  }
2021
2021
  }
2022
- At.create = (n) => new At({
2022
+ Ct.create = (n) => new Ct({
2023
2023
  checks: [],
2024
2024
  typeName: Y.ZodNumber,
2025
2025
  coerce: n?.coerce || !1,
@@ -2433,12 +2433,12 @@ We.create = (n, e) => new We({
2433
2433
  typeName: Y.ZodArray,
2434
2434
  ...K(e)
2435
2435
  });
2436
- function St(n) {
2436
+ function Rt(n) {
2437
2437
  if (n instanceof ue) {
2438
2438
  const e = {};
2439
2439
  for (const t in n.shape) {
2440
2440
  const s = n.shape[t];
2441
- e[t] = ot.create(St(s));
2441
+ e[t] = ot.create(Rt(s));
2442
2442
  }
2443
2443
  return new ue({
2444
2444
  ...n._def,
@@ -2446,8 +2446,8 @@ function St(n) {
2446
2446
  });
2447
2447
  } else return n instanceof We ? new We({
2448
2448
  ...n._def,
2449
- type: St(n.element)
2450
- }) : n instanceof ot ? ot.create(St(n.unwrap())) : n instanceof Mt ? Mt.create(St(n.unwrap())) : n instanceof wt ? wt.create(n.items.map((e) => St(e))) : n;
2449
+ type: Rt(n.element)
2450
+ }) : n instanceof ot ? ot.create(Rt(n.unwrap())) : n instanceof Ft ? Ft.create(Rt(n.unwrap())) : n instanceof _t ? _t.create(n.items.map((e) => Rt(e))) : n;
2451
2451
  }
2452
2452
  class ue extends ee {
2453
2453
  constructor() {
@@ -2682,7 +2682,7 @@ class ue extends ee {
2682
2682
  * @deprecated
2683
2683
  */
2684
2684
  deepPartial() {
2685
- return St(this);
2685
+ return Rt(this);
2686
2686
  }
2687
2687
  partial(e) {
2688
2688
  const t = {};
@@ -2873,7 +2873,7 @@ Cn.create = (n, e, t) => new Cn({
2873
2873
  typeName: Y.ZodIntersection,
2874
2874
  ...K(t)
2875
2875
  });
2876
- class wt extends ee {
2876
+ class _t extends ee {
2877
2877
  _parse(e) {
2878
2878
  const { status: t, ctx: s } = this._processInputParams(e);
2879
2879
  if (s.parsedType !== V.array)
@@ -2907,16 +2907,16 @@ class wt extends ee {
2907
2907
  return this._def.items;
2908
2908
  }
2909
2909
  rest(e) {
2910
- return new wt({
2910
+ return new _t({
2911
2911
  ...this._def,
2912
2912
  rest: e
2913
2913
  });
2914
2914
  }
2915
2915
  }
2916
- wt.create = (n, e) => {
2916
+ _t.create = (n, e) => {
2917
2917
  if (!Array.isArray(n))
2918
2918
  throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2919
- return new wt({
2919
+ return new _t({
2920
2920
  items: n,
2921
2921
  typeName: Y.ZodTuple,
2922
2922
  rest: null,
@@ -3112,13 +3112,13 @@ ks.create = (n, e) => new ks({
3112
3112
  ...K(e)
3113
3113
  });
3114
3114
  function wi(n, e) {
3115
- return new Ct({
3115
+ return new $t({
3116
3116
  values: n,
3117
3117
  typeName: Y.ZodEnum,
3118
3118
  ...K(e)
3119
3119
  });
3120
3120
  }
3121
- class Ct extends ee {
3121
+ class $t extends ee {
3122
3122
  _parse(e) {
3123
3123
  if (typeof e.data != "string") {
3124
3124
  const t = this._getOrReturnCtx(e), s = this._def.values;
@@ -3160,19 +3160,19 @@ class Ct extends ee {
3160
3160
  return e;
3161
3161
  }
3162
3162
  extract(e, t = this._def) {
3163
- return Ct.create(e, {
3163
+ return $t.create(e, {
3164
3164
  ...this._def,
3165
3165
  ...t
3166
3166
  });
3167
3167
  }
3168
3168
  exclude(e, t = this._def) {
3169
- return Ct.create(this.options.filter((s) => !e.includes(s)), {
3169
+ return $t.create(this.options.filter((s) => !e.includes(s)), {
3170
3170
  ...this._def,
3171
3171
  ...t
3172
3172
  });
3173
3173
  }
3174
3174
  }
3175
- Ct.create = wi;
3175
+ $t.create = wi;
3176
3176
  class gr extends ee {
3177
3177
  _parse(e) {
3178
3178
  const t = ne.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
@@ -3227,7 +3227,7 @@ Mn.create = (n, e) => new Mn({
3227
3227
  typeName: Y.ZodPromise,
3228
3228
  ...K(e)
3229
3229
  });
3230
- class $t extends ee {
3230
+ class Mt extends ee {
3231
3231
  innerType() {
3232
3232
  return this._def.schema;
3233
3233
  }
@@ -3293,27 +3293,27 @@ class $t extends ee {
3293
3293
  path: s.path,
3294
3294
  parent: s
3295
3295
  });
3296
- if (!Dt(o))
3296
+ if (!At(o))
3297
3297
  return J;
3298
3298
  const a = r.transform(o.value, i);
3299
3299
  if (a instanceof Promise)
3300
3300
  throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
3301
3301
  return { status: t.value, value: a };
3302
3302
  } else
3303
- return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => Dt(o) ? Promise.resolve(r.transform(o.value, i)).then((a) => ({
3303
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => At(o) ? Promise.resolve(r.transform(o.value, i)).then((a) => ({
3304
3304
  status: t.value,
3305
3305
  value: a
3306
3306
  })) : J);
3307
3307
  ne.assertNever(r);
3308
3308
  }
3309
3309
  }
3310
- $t.create = (n, e, t) => new $t({
3310
+ Mt.create = (n, e, t) => new Mt({
3311
3311
  schema: n,
3312
3312
  typeName: Y.ZodEffects,
3313
3313
  effect: e,
3314
3314
  ...K(t)
3315
3315
  });
3316
- $t.createWithPreprocess = (n, e, t) => new $t({
3316
+ Mt.createWithPreprocess = (n, e, t) => new Mt({
3317
3317
  schema: e,
3318
3318
  effect: { type: "preprocess", transform: n },
3319
3319
  typeName: Y.ZodEffects,
@@ -3332,7 +3332,7 @@ ot.create = (n, e) => new ot({
3332
3332
  typeName: Y.ZodOptional,
3333
3333
  ...K(e)
3334
3334
  });
3335
- class Mt extends ee {
3335
+ class Ft extends ee {
3336
3336
  _parse(e) {
3337
3337
  return this._getType(e) === V.null ? $e(null) : this._def.innerType._parse(e);
3338
3338
  }
@@ -3340,7 +3340,7 @@ class Mt extends ee {
3340
3340
  return this._def.innerType;
3341
3341
  }
3342
3342
  }
3343
- Mt.create = (n, e) => new Mt({
3343
+ Ft.create = (n, e) => new Ft({
3344
3344
  innerType: n,
3345
3345
  typeName: Y.ZodNullable,
3346
3346
  ...K(e)
@@ -3480,7 +3480,7 @@ class js extends ee {
3480
3480
  }
3481
3481
  class Ss extends ee {
3482
3482
  _parse(e) {
3483
- const t = this._def.innerType._parse(e), s = (r) => (Dt(r) && (r.value = Object.freeze(r.value)), r);
3483
+ const t = this._def.innerType._parse(e), s = (r) => (At(r) && (r.value = Object.freeze(r.value)), r);
3484
3484
  return Nn(t) ? t.then((r) => s(r)) : s(t);
3485
3485
  }
3486
3486
  unwrap() {
@@ -3496,15 +3496,15 @@ var Y;
3496
3496
  (function(n) {
3497
3497
  n.ZodString = "ZodString", n.ZodNumber = "ZodNumber", n.ZodNaN = "ZodNaN", n.ZodBigInt = "ZodBigInt", n.ZodBoolean = "ZodBoolean", n.ZodDate = "ZodDate", n.ZodSymbol = "ZodSymbol", n.ZodUndefined = "ZodUndefined", n.ZodNull = "ZodNull", n.ZodAny = "ZodAny", n.ZodUnknown = "ZodUnknown", n.ZodNever = "ZodNever", n.ZodVoid = "ZodVoid", n.ZodArray = "ZodArray", n.ZodObject = "ZodObject", n.ZodUnion = "ZodUnion", n.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", n.ZodIntersection = "ZodIntersection", n.ZodTuple = "ZodTuple", n.ZodRecord = "ZodRecord", n.ZodMap = "ZodMap", n.ZodSet = "ZodSet", n.ZodFunction = "ZodFunction", n.ZodLazy = "ZodLazy", n.ZodLiteral = "ZodLiteral", n.ZodEnum = "ZodEnum", n.ZodEffects = "ZodEffects", n.ZodNativeEnum = "ZodNativeEnum", n.ZodOptional = "ZodOptional", n.ZodNullable = "ZodNullable", n.ZodDefault = "ZodDefault", n.ZodCatch = "ZodCatch", n.ZodPromise = "ZodPromise", n.ZodBranded = "ZodBranded", n.ZodPipeline = "ZodPipeline", n.ZodReadonly = "ZodReadonly";
3498
3498
  })(Y || (Y = {}));
3499
- const Te = Ge.create, pt = At.create, Xt = _s.create, ss = Es.create, pe = vs.create;
3499
+ const Te = Ge.create, yt = Ct.create, Xt = _s.create, ss = Es.create, pe = vs.create;
3500
3500
  ct.create;
3501
- const vt = We.create, je = ue.create, ke = An.create;
3501
+ const Ot = We.create, je = ue.create, ke = An.create;
3502
3502
  Cn.create;
3503
- wt.create;
3504
- const on = $n.create, be = ks.create, Fn = Ct.create;
3503
+ _t.create;
3504
+ const on = $n.create, be = ks.create, Fn = $t.create;
3505
3505
  Mn.create;
3506
3506
  ot.create;
3507
- Mt.create;
3507
+ Ft.create;
3508
3508
  const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds !== void 0 || n._seconds !== void 0 && n._nanoseconds !== void 0), {
3509
3509
  message: "Value is not a valid timestamp"
3510
3510
  }), _r = () => pe().refine((n) => n && (n._methodName === "serverTimestamp" || n.constructor.name === "ServerTimestampTransform"), {
@@ -3519,11 +3519,11 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3519
3519
  const a = i.fields.find((c) => c.name === o);
3520
3520
  if (!a)
3521
3521
  throw new Error(`Field ${o} not found in collection ${n.collection}`);
3522
- s[o] = Pn(i, a), Et(i, [a]).size === 1 && (s[`${o}_Lowercase`] = Pn(i, a, !0));
3522
+ s[o] = Pn(i, a), vt(i, [a]).size === 1 && (s[`${o}_Lowercase`] = Pn(i, a, !0));
3523
3523
  });
3524
3524
  }
3525
3525
  const r = {
3526
- Collection_Path: vt(Te()),
3526
+ Collection_Path: Ot(Te()),
3527
3527
  ...s
3528
3528
  };
3529
3529
  return t && (r.id = Te().length(20)), je(r);
@@ -3531,7 +3531,7 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3531
3531
  let t = on(_i(n, e));
3532
3532
  return n.required || (t = t.optional()), t;
3533
3533
  }, Ma = (n) => {
3534
- let e = vt(ke([Te().length(20), Te().length(28)]));
3534
+ let e = Ot(ke([Te().length(20), Te().length(28)]));
3535
3535
  return ["OneToOne", "OneToMany"].includes(n.type) ? e = e.max(1) : (n.min && (e = e.min(n.min)), n.max && (e = e.max(n.max)), n.length && (e = e.length(n.length))), n.required ? e = e.nonempty() : e = e.optional(), e;
3536
3536
  }, Pn = (n, e, t) => {
3537
3537
  const { softDelete: s } = n, r = s?.timestampField;
@@ -3549,7 +3549,7 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3549
3549
  i = Xt();
3550
3550
  break;
3551
3551
  case "Number":
3552
- e.autoIncrement ? i = ke([be("Pending"), pt().int()]) : (i = pt(), e.min && (i = i.min(e.min)), e.max && (i = i.max(e.max)), e.decimal ? i = i.refine((o) => e.decimal ? (o.toString().split(".")[1]?.length || 0) <= e.decimal : !1, {
3552
+ e.autoIncrement ? i = ke([be("Pending"), yt().int()]) : (i = yt(), e.min && (i = i.min(e.min)), e.max && (i = i.max(e.max)), e.decimal ? i = i.refine((o) => e.decimal ? (o.toString().split(".")[1]?.length || 0) <= e.decimal : !1, {
3553
3553
  message: `Value must have ${e.decimal} or fewer decimal places`
3554
3554
  }) : i = i.int(), e.values && (i = i.refine((o) => e.values?.includes(o), {
3555
3555
  message: "Value is not an allowed value"
@@ -3565,7 +3565,7 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3565
3565
  })));
3566
3566
  break;
3567
3567
  case "Array":
3568
- i = vt(pe()), e.length && (i = i.length(e.length)), e.minlength ? i = i.min(e.minlength) : e.required && (i = i.nonempty()), e.maxlength && (i = i.max(e.maxlength)), e.values && (i = i.refine((o) => {
3568
+ i = Ot(pe()), e.length && (i = i.length(e.length)), e.minlength ? i = i.min(e.minlength) : e.required && (i = i.nonempty()), e.maxlength && (i = i.max(e.maxlength)), e.values && (i = i.refine((o) => {
3569
3569
  let a = !0;
3570
3570
  return o.forEach((l) => {
3571
3571
  e.values && !e.values.includes(l) && (a = !1);
@@ -3584,19 +3584,19 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3584
3584
  return !X(e) && e.nullable && (i = i.nullable()), e.required || (i = i.optional()), i;
3585
3585
  }, Fa = (n, e, t) => {
3586
3586
  const s = {
3587
- Collection_Path: vt(Te()),
3587
+ Collection_Path: Ot(Te()),
3588
3588
  Last_Write_App: Te(),
3589
3589
  Last_Write_At: En(),
3590
3590
  Last_Save_At: _r(),
3591
3591
  Last_Write_By: ke([Te().length(28), be("System")]),
3592
3592
  Last_Write_Connection_Status: Fn(["Online", "Offline"]),
3593
- Last_Write_Version: pt().int(),
3593
+ Last_Write_Version: yt().int(),
3594
3594
  id: Te().regex(new RegExp("^[a-zA-Z0-9]+$")).length(20),
3595
3595
  Created_At: En(),
3596
3596
  Created_By: ke([Te().length(28), be("System")])
3597
3597
  };
3598
3598
  n === "create" && (s.Saved_At = _r()), n === "update" && (s.Saved_At = En(), s.Collection_Path = s.Collection_Path.optional(), s.id = s.id.optional(), s.Created_At = s.Created_At.optional(), s.Saved_At = s.Saved_At.optional(), s.Created_By = s.Created_By.optional());
3599
- const r = mt(e, e.fields), i = Array.from(r).map((l) => l.name);
3599
+ const r = pt(e, e.fields), i = Array.from(r).map((l) => l.name);
3600
3600
  e.fields.forEach((l) => {
3601
3601
  X(l) ? (s[l.name] = $a(l, t), s[`${l.name}_Array`] = Ma(l), i.includes(l.name) && (s[`${l.name}_Single`] = _i(l, t, !0), l.required || (s[`${l.name}_Single`] = s[`${l.name}_Single`].optional())), l.length && (s[l.name] = s[l.name].refine((c) => l.length && c && Object.keys(c).length === l.length, {
3602
3602
  message: `Value must contain ${l.length} item(s)`
@@ -3605,39 +3605,39 @@ const En = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
3605
3605
  })), l.max && (s[l.name] = s[l.name].refine((c) => l.max && (!c || Object.keys(c).length <= l.max), {
3606
3606
  message: `Value must contain at most ${l.max} item(s)`
3607
3607
  }))) : l.type !== "Computed" && (s[l.name] = Pn(e, l));
3608
- }), Et(e, e.fields).forEach((l) => {
3608
+ }), vt(e, e.fields).forEach((l) => {
3609
3609
  s[l.name] && (s[`${l.name}_Lowercase`] = Pn(e, l, !0));
3610
3610
  });
3611
3611
  const a = je(s);
3612
3612
  return e.allowSchemalessFields ? a.passthrough() : a.strict();
3613
3613
  };
3614
- class Ot extends Error {
3614
+ class kt extends Error {
3615
3615
  }
3616
- class Pa extends Ot {
3616
+ class Pa extends kt {
3617
3617
  constructor(e) {
3618
3618
  super(`Invalid DateTime: ${e.toMessage()}`);
3619
3619
  }
3620
3620
  }
3621
- class La extends Ot {
3621
+ class La extends kt {
3622
3622
  constructor(e) {
3623
3623
  super(`Invalid Interval: ${e.toMessage()}`);
3624
3624
  }
3625
3625
  }
3626
- class Va extends Ot {
3626
+ class Va extends kt {
3627
3627
  constructor(e) {
3628
3628
  super(`Invalid Duration: ${e.toMessage()}`);
3629
3629
  }
3630
3630
  }
3631
- class Rt extends Ot {
3631
+ class It extends kt {
3632
3632
  }
3633
- class Ei extends Ot {
3633
+ class Ei extends kt {
3634
3634
  constructor(e) {
3635
3635
  super(`Invalid unit ${e}`);
3636
3636
  }
3637
3637
  }
3638
- class ye extends Ot {
3638
+ class ye extends kt {
3639
3639
  }
3640
- class tt extends Ot {
3640
+ class tt extends kt {
3641
3641
  constructor() {
3642
3642
  super("Zone is an abstract class");
3643
3643
  }
@@ -4771,9 +4771,9 @@ function Vn(n, e = 4, t = 1) {
4771
4771
  return l < 1 ? (c = s - 1, l = sn(c, e, t)) : l > sn(s, e, t) ? (c = s + 1, l = 1) : c = s, { weekYear: c, weekNumber: l, weekday: a, ...Qn(n) };
4772
4772
  }
4773
4773
  function Nr(n, e = 4, t = 1) {
4774
- const { weekYear: s, weekNumber: r, weekday: i } = n, o = qs(zs(s, 1, e), t), a = xt(s);
4774
+ const { weekYear: s, weekNumber: r, weekday: i } = n, o = qs(zs(s, 1, e), t), a = Nt(s);
4775
4775
  let l = r * 7 + i - o - 7 + e, c;
4776
- l < 1 ? (c = s - 1, l += xt(c)) : l > a ? (c = s + 1, l -= xt(s)) : c = s;
4776
+ l < 1 ? (c = s - 1, l += Nt(c)) : l > a ? (c = s + 1, l -= Nt(s)) : c = s;
4777
4777
  const { month: d, day: m } = qi(c, l);
4778
4778
  return { year: c, month: d, day: m, ...Qn(n) };
4779
4779
  }
@@ -4788,7 +4788,7 @@ function Dr(n) {
4788
4788
  function Ar(n, e) {
4789
4789
  if (!H(n.localWeekday) || !H(n.localWeekNumber) || !H(n.localWeekYear)) {
4790
4790
  if (!H(n.weekday) || !H(n.weekNumber) || !H(n.weekYear))
4791
- throw new Rt(
4791
+ throw new It(
4792
4792
  "Cannot mix locale-based week fields with ISO-based week fields"
4793
4793
  );
4794
4794
  return H(n.localWeekday) || (n.weekday = n.localWeekday), H(n.localWeekNumber) || (n.weekNumber = n.localWeekNumber), H(n.localWeekYear) || (n.weekYear = n.localWeekYear), delete n.localWeekday, delete n.localWeekNumber, delete n.localWeekYear, {
@@ -4807,7 +4807,7 @@ function cl(n, e = 4, t = 1) {
4807
4807
  return s ? r ? i ? !1 : Ne("weekday", n.weekday) : Ne("week", n.weekNumber) : Ne("weekYear", n.weekYear);
4808
4808
  }
4809
4809
  function ul(n) {
4810
- const e = Gn(n.year), t = De(n.ordinal, 1, xt(n.year));
4810
+ const e = Gn(n.year), t = De(n.ordinal, 1, Nt(n.year));
4811
4811
  return e ? t ? !1 : Ne("ordinal", n.ordinal) : Ne("year", n.year);
4812
4812
  }
4813
4813
  function Bi(n) {
@@ -4860,7 +4860,7 @@ function Cr(n, e, t) {
4860
4860
  function ml(n, e) {
4861
4861
  return e.reduce((t, s) => (t[s] = n[s], t), {});
4862
4862
  }
4863
- function Ft(n, e) {
4863
+ function Pt(n, e) {
4864
4864
  return Object.prototype.hasOwnProperty.call(n, e);
4865
4865
  }
4866
4866
  function Ms(n) {
@@ -4891,7 +4891,7 @@ function st(n) {
4891
4891
  if (!(H(n) || n === null || n === ""))
4892
4892
  return parseInt(n, 10);
4893
4893
  }
4894
- function ft(n) {
4894
+ function ht(n) {
4895
4895
  if (!(H(n) || n === null || n === ""))
4896
4896
  return parseFloat(n);
4897
4897
  }
@@ -4921,7 +4921,7 @@ function Hs(n, e, t = "round") {
4921
4921
  function ln(n) {
4922
4922
  return n % 4 === 0 && (n % 100 !== 0 || n % 400 === 0);
4923
4923
  }
4924
- function xt(n) {
4924
+ function Nt(n) {
4925
4925
  return ln(n) ? 366 : 365;
4926
4926
  }
4927
4927
  function Un(n, e) {
@@ -4945,7 +4945,7 @@ function $r(n, e, t) {
4945
4945
  }
4946
4946
  function sn(n, e = 4, t = 1) {
4947
4947
  const s = $r(n, e, t), r = $r(n + 1, e, t);
4948
- return (xt(n) - s + r) / 7;
4948
+ return (Nt(n) - s + r) / 7;
4949
4949
  }
4950
4950
  function Fs(n) {
4951
4951
  return n > 99 ? n : n > le.twoDigitCutoffYear ? 1900 + n : 2e3 + n;
@@ -4978,7 +4978,7 @@ function Qi(n) {
4978
4978
  function Wn(n, e) {
4979
4979
  const t = {};
4980
4980
  for (const s in n)
4981
- if (Ft(n, s)) {
4981
+ if (Pt(n, s)) {
4982
4982
  const r = n[s];
4983
4983
  if (r == null) continue;
4984
4984
  t[e(s)] = Qi(r);
@@ -5386,11 +5386,11 @@ class ge {
5386
5386
  }
5387
5387
  }
5388
5388
  const io = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
5389
- function Lt(...n) {
5389
+ function Vt(...n) {
5390
5390
  const e = n.reduce((t, s) => t + s.source, "");
5391
5391
  return RegExp(`^${e}$`);
5392
5392
  }
5393
- function Vt(...n) {
5393
+ function Ut(...n) {
5394
5394
  return (e) => n.reduce(
5395
5395
  ([t, s, r], i) => {
5396
5396
  const [o, a, l] = i(e, r);
@@ -5399,7 +5399,7 @@ function Vt(...n) {
5399
5399
  [{}, null, 1]
5400
5400
  ).slice(0, 2);
5401
5401
  }
5402
- function Ut(n, ...e) {
5402
+ function Wt(n, ...e) {
5403
5403
  if (n == null)
5404
5404
  return [null, null];
5405
5405
  for (const [t, s] of e) {
@@ -5421,22 +5421,22 @@ function oo(...n) {
5421
5421
  const ao = /(?:([Zz])|([+-]\d\d)(?::?(\d\d))?)/, Il = `(?:${ao.source}?(?:\\[(${io.source})\\])?)?`, Gs = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/, lo = RegExp(`${Gs.source}${Il}`), Ys = RegExp(`(?:[Tt]${lo.source})?`), xl = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/, Nl = /(\d{4})-?W(\d\d)(?:-?(\d))?/, Dl = /(\d{4})-?(\d{3})/, Al = oo("weekYear", "weekNumber", "weekDay"), Cl = oo("year", "ordinal"), $l = /(\d{4})-(\d\d)-(\d\d)/, co = RegExp(
5422
5422
  `${Gs.source} ?(?:${ao.source}|(${io.source}))?`
5423
5423
  ), Ml = RegExp(`(?: ${co.source})?`);
5424
- function Nt(n, e, t) {
5424
+ function Dt(n, e, t) {
5425
5425
  const s = n[e];
5426
5426
  return H(s) ? t : st(s);
5427
5427
  }
5428
5428
  function Fl(n, e) {
5429
5429
  return [{
5430
- year: Nt(n, e),
5431
- month: Nt(n, e + 1, 1),
5432
- day: Nt(n, e + 2, 1)
5430
+ year: Dt(n, e),
5431
+ month: Dt(n, e + 1, 1),
5432
+ day: Dt(n, e + 2, 1)
5433
5433
  }, null, e + 3];
5434
5434
  }
5435
- function Wt(n, e) {
5435
+ function jt(n, e) {
5436
5436
  return [{
5437
- hours: Nt(n, e, 0),
5438
- minutes: Nt(n, e + 1, 0),
5439
- seconds: Nt(n, e + 2, 0),
5437
+ hours: Dt(n, e, 0),
5438
+ minutes: Dt(n, e + 1, 0),
5439
+ seconds: Dt(n, e + 2, 0),
5440
5440
  milliseconds: Bs(n[e + 3])
5441
5441
  }, null, e + 4];
5442
5442
  }
@@ -5453,13 +5453,13 @@ function Vl(n) {
5453
5453
  const [e, t, s, r, i, o, a, l, c] = n, d = e[0] === "-", m = l && l[0] === "-", u = (f, g = !1) => f !== void 0 && (g || f && d) ? -f : f;
5454
5454
  return [
5455
5455
  {
5456
- years: u(ft(t)),
5457
- months: u(ft(s)),
5458
- weeks: u(ft(r)),
5459
- days: u(ft(i)),
5460
- hours: u(ft(o)),
5461
- minutes: u(ft(a)),
5462
- seconds: u(ft(l), l === "-0"),
5456
+ years: u(ht(t)),
5457
+ months: u(ht(s)),
5458
+ weeks: u(ht(r)),
5459
+ days: u(ht(i)),
5460
+ hours: u(ht(o)),
5461
+ minutes: u(ht(a)),
5462
+ seconds: u(ht(l), l === "-0"),
5463
5463
  milliseconds: u(Bs(c), m)
5464
5464
  }
5465
5465
  ];
@@ -5516,28 +5516,28 @@ function Hl(n) {
5516
5516
  const [, e, t, s, r, i, o, a] = n;
5517
5517
  return [Js(e, a, t, s, r, i, o), _e.utcInstance];
5518
5518
  }
5519
- const Gl = Lt(xl, Ys), Yl = Lt(Nl, Ys), Jl = Lt(Dl, Ys), Ql = Lt(lo), uo = Vt(
5519
+ const Gl = Vt(xl, Ys), Yl = Vt(Nl, Ys), Jl = Vt(Dl, Ys), Ql = Vt(lo), uo = Ut(
5520
5520
  Fl,
5521
- Wt,
5521
+ jt,
5522
5522
  cn,
5523
5523
  un
5524
- ), Kl = Vt(
5524
+ ), Kl = Ut(
5525
5525
  Al,
5526
- Wt,
5526
+ jt,
5527
5527
  cn,
5528
5528
  un
5529
- ), Xl = Vt(
5529
+ ), Xl = Ut(
5530
5530
  Cl,
5531
- Wt,
5531
+ jt,
5532
5532
  cn,
5533
5533
  un
5534
- ), ec = Vt(
5535
- Wt,
5534
+ ), ec = Ut(
5535
+ jt,
5536
5536
  cn,
5537
5537
  un
5538
5538
  );
5539
5539
  function tc(n) {
5540
- return Ut(
5540
+ return Wt(
5541
5541
  n,
5542
5542
  [Gl, uo],
5543
5543
  [Yl, Kl],
@@ -5546,10 +5546,10 @@ function tc(n) {
5546
5546
  );
5547
5547
  }
5548
5548
  function nc(n) {
5549
- return Ut(Zl(n), [Wl, jl]);
5549
+ return Wt(Zl(n), [Wl, jl]);
5550
5550
  }
5551
5551
  function sc(n) {
5552
- return Ut(
5552
+ return Wt(
5553
5553
  n,
5554
5554
  [zl, Fr],
5555
5555
  [ql, Fr],
@@ -5557,19 +5557,19 @@ function sc(n) {
5557
5557
  );
5558
5558
  }
5559
5559
  function rc(n) {
5560
- return Ut(n, [Ll, Vl]);
5560
+ return Wt(n, [Ll, Vl]);
5561
5561
  }
5562
- const ic = Vt(Wt);
5562
+ const ic = Ut(jt);
5563
5563
  function oc(n) {
5564
- return Ut(n, [Pl, ic]);
5564
+ return Wt(n, [Pl, ic]);
5565
5565
  }
5566
- const ac = Lt($l, Ml), lc = Lt(co), cc = Vt(
5567
- Wt,
5566
+ const ac = Vt($l, Ml), lc = Vt(co), cc = Ut(
5567
+ jt,
5568
5568
  cn,
5569
5569
  un
5570
5570
  );
5571
5571
  function uc(n) {
5572
- return Ut(
5572
+ return Wt(
5573
5573
  n,
5574
5574
  [ac, uo],
5575
5575
  [lc, cc]
@@ -5621,7 +5621,7 @@ const Pr = "Invalid Duration", fo = {
5621
5621
  milliseconds: 720 * 60 * 60 * 1e3
5622
5622
  },
5623
5623
  ...fo
5624
- }, xe = 146097 / 400, kt = 146097 / 4800, fc = {
5624
+ }, xe = 146097 / 400, bt = 146097 / 4800, fc = {
5625
5625
  years: {
5626
5626
  quarters: 4,
5627
5627
  months: 12,
@@ -5642,15 +5642,15 @@ const Pr = "Invalid Duration", fo = {
5642
5642
  milliseconds: xe * 24 * 60 * 60 * 1e3 / 4
5643
5643
  },
5644
5644
  months: {
5645
- weeks: kt / 7,
5646
- days: kt,
5647
- hours: kt * 24,
5648
- minutes: kt * 24 * 60,
5649
- seconds: kt * 24 * 60 * 60,
5650
- milliseconds: kt * 24 * 60 * 60 * 1e3
5645
+ weeks: bt / 7,
5646
+ days: bt,
5647
+ hours: bt * 24,
5648
+ minutes: bt * 24 * 60,
5649
+ seconds: bt * 24 * 60 * 60,
5650
+ milliseconds: bt * 24 * 60 * 60 * 1e3
5651
5651
  },
5652
5652
  ...fo
5653
- }, yt = [
5653
+ }, gt = [
5654
5654
  "years",
5655
5655
  "quarters",
5656
5656
  "months",
@@ -5660,7 +5660,7 @@ const Pr = "Invalid Duration", fo = {
5660
5660
  "minutes",
5661
5661
  "seconds",
5662
5662
  "milliseconds"
5663
- ], hc = yt.slice(0).reverse();
5663
+ ], hc = gt.slice(0).reverse();
5664
5664
  function Be(n, e, t = !1) {
5665
5665
  const s = {
5666
5666
  values: t ? e.values : { ...n.values, ...e.values || {} },
@@ -5678,7 +5678,7 @@ function ho(n, e) {
5678
5678
  }
5679
5679
  function Lr(n, e) {
5680
5680
  const t = ho(n, e) < 0 ? -1 : 1;
5681
- yt.reduceRight((s, r) => {
5681
+ gt.reduceRight((s, r) => {
5682
5682
  if (H(e[r]))
5683
5683
  return s;
5684
5684
  if (s) {
@@ -5686,7 +5686,7 @@ function Lr(n, e) {
5686
5686
  e[r] += a * t, e[s] -= a * o * t;
5687
5687
  }
5688
5688
  return r;
5689
- }, null), yt.reduce((s, r) => {
5689
+ }, null), gt.reduce((s, r) => {
5690
5690
  if (H(e[r]))
5691
5691
  return s;
5692
5692
  if (s) {
@@ -5929,7 +5929,7 @@ class te {
5929
5929
  */
5930
5930
  toHuman(e = {}) {
5931
5931
  if (!this.isValid) return Pr;
5932
- const t = e.showZeros !== !1, s = yt.map((r) => {
5932
+ const t = e.showZeros !== !1, s = gt.map((r) => {
5933
5933
  const i = this.values[r];
5934
5934
  return H(i) || i === 0 && !t ? null : this.loc.numberFormatter({ style: "unit", unitDisplay: "long", ...e, unit: r.slice(0, -1) }).format(i);
5935
5935
  }).filter((r) => r);
@@ -6029,8 +6029,8 @@ class te {
6029
6029
  plus(e) {
6030
6030
  if (!this.isValid) return this;
6031
6031
  const t = te.fromDurationLike(e), s = {};
6032
- for (const r of yt)
6033
- (Ft(t.values, r) || Ft(this.values, r)) && (s[r] = t.get(r) + this.get(r));
6032
+ for (const r of gt)
6033
+ (Pt(t.values, r) || Pt(this.values, r)) && (s[r] = t.get(r) + this.get(r));
6034
6034
  return Be(this, { values: s }, !0);
6035
6035
  }
6036
6036
  /**
@@ -6142,7 +6142,7 @@ class te {
6142
6142
  e = e.map((o) => te.normalizeUnit(o));
6143
6143
  const t = {}, s = {}, r = this.toObject();
6144
6144
  let i;
6145
- for (const o of yt)
6145
+ for (const o of gt)
6146
6146
  if (e.indexOf(o) >= 0) {
6147
6147
  i = o;
6148
6148
  let a = 0;
@@ -6292,13 +6292,13 @@ class te {
6292
6292
  function t(s, r) {
6293
6293
  return s === void 0 || s === 0 ? r === void 0 || r === 0 : s === r;
6294
6294
  }
6295
- for (const s of yt)
6295
+ for (const s of gt)
6296
6296
  if (!t(this.values[s], e.values[s]))
6297
6297
  return !1;
6298
6298
  return !0;
6299
6299
  }
6300
6300
  }
6301
- const bt = "Invalid Interval";
6301
+ const Tt = "Invalid Interval";
6302
6302
  function mc(n, e) {
6303
6303
  return !n || !n.isValid ? ae.invalid("missing or invalid start") : !e || !e.isValid ? ae.invalid("missing or invalid end") : e < n ? ae.invalid(
6304
6304
  "end before start",
@@ -6667,7 +6667,7 @@ class ae {
6667
6667
  * @return {string}
6668
6668
  */
6669
6669
  toString() {
6670
- return this.isValid ? `[${this.s.toISO()} – ${this.e.toISO()})` : bt;
6670
+ return this.isValid ? `[${this.s.toISO()} – ${this.e.toISO()})` : Tt;
6671
6671
  }
6672
6672
  /**
6673
6673
  * Returns a string representation of this Interval appropriate for the REPL.
@@ -6695,7 +6695,7 @@ class ae {
6695
6695
  * @return {string}
6696
6696
  */
6697
6697
  toLocaleString(e = Ln, t = {}) {
6698
- return this.isValid ? ge.create(this.s.loc.clone(t), e).formatInterval(this) : bt;
6698
+ return this.isValid ? ge.create(this.s.loc.clone(t), e).formatInterval(this) : Tt;
6699
6699
  }
6700
6700
  /**
6701
6701
  * Returns an ISO 8601-compliant string representation of this Interval.
@@ -6704,7 +6704,7 @@ class ae {
6704
6704
  * @return {string}
6705
6705
  */
6706
6706
  toISO(e) {
6707
- return this.isValid ? `${this.s.toISO(e)}/${this.e.toISO(e)}` : bt;
6707
+ return this.isValid ? `${this.s.toISO(e)}/${this.e.toISO(e)}` : Tt;
6708
6708
  }
6709
6709
  /**
6710
6710
  * Returns an ISO 8601-compliant string representation of date of this Interval.
@@ -6713,7 +6713,7 @@ class ae {
6713
6713
  * @return {string}
6714
6714
  */
6715
6715
  toISODate() {
6716
- return this.isValid ? `${this.s.toISODate()}/${this.e.toISODate()}` : bt;
6716
+ return this.isValid ? `${this.s.toISODate()}/${this.e.toISODate()}` : Tt;
6717
6717
  }
6718
6718
  /**
6719
6719
  * Returns an ISO 8601-compliant string representation of time of this Interval.
@@ -6723,7 +6723,7 @@ class ae {
6723
6723
  * @return {string}
6724
6724
  */
6725
6725
  toISOTime(e) {
6726
- return this.isValid ? `${this.s.toISOTime(e)}/${this.e.toISOTime(e)}` : bt;
6726
+ return this.isValid ? `${this.s.toISOTime(e)}/${this.e.toISOTime(e)}` : Tt;
6727
6727
  }
6728
6728
  /**
6729
6729
  * Returns a string representation of this Interval formatted according to the specified format
@@ -6737,7 +6737,7 @@ class ae {
6737
6737
  * @return {string}
6738
6738
  */
6739
6739
  toFormat(e, { separator: t = " – " } = {}) {
6740
- return this.isValid ? `${this.s.toFormat(e)}${t}${this.e.toFormat(e)}` : bt;
6740
+ return this.isValid ? `${this.s.toFormat(e)}${t}${this.e.toFormat(e)}` : Tt;
6741
6741
  }
6742
6742
  /**
6743
6743
  * Return a Duration representing the time spanned by this interval.
@@ -7190,7 +7190,7 @@ function Tc(n, e, t) {
7190
7190
  const r = {};
7191
7191
  let i = 1;
7192
7192
  for (const o in t)
7193
- if (Ft(t, o)) {
7193
+ if (Pt(t, o)) {
7194
7194
  const a = t[o], l = a.groups ? a.groups + 1 : 1;
7195
7195
  !a.literal && a.token && (r[a.token.val[0]] = a.deser(s.slice(i, i + l))), i += l;
7196
7196
  }
@@ -7261,8 +7261,8 @@ class go {
7261
7261
  explainFromTokens(e) {
7262
7262
  if (this.isValid) {
7263
7263
  const [t, s] = Tc(e, this.regex, this.handlers), [r, i, o] = s ? Sc(s) : [null, null, void 0];
7264
- if (Ft(s, "a") && Ft(s, "H"))
7265
- throw new Rt(
7264
+ if (Pt(s, "a") && Pt(s, "H"))
7265
+ throw new It(
7266
7266
  "Can't include meridiem when specifying 24-hour format"
7267
7267
  );
7268
7268
  return {
@@ -7312,7 +7312,7 @@ function ds(n) {
7312
7312
  n.loc.getStartOfWeek()
7313
7313
  )), n.localWeekData;
7314
7314
  }
7315
- function ht(n, e) {
7315
+ function mt(n, e) {
7316
7316
  const t = {
7317
7317
  ts: n.ts,
7318
7318
  zone: n.zone,
@@ -7368,7 +7368,7 @@ function zr(n, e) {
7368
7368
  let [l, c] = Eo(a, t, n.zone);
7369
7369
  return o !== 0 && (l += o, c = n.zone.offset(l)), { ts: l, o: c };
7370
7370
  }
7371
- function Tt(n, e, t, s, r, i) {
7371
+ function St(n, e, t, s, r, i) {
7372
7372
  const { setZone: o, zone: a } = t;
7373
7373
  if (n && Object.keys(n).length !== 0 || e) {
7374
7374
  const l = e || a, c = L.fromObject(n, {
@@ -7719,11 +7719,11 @@ class L {
7719
7719
  return L.invalid(Yt(s));
7720
7720
  const r = re.fromObject(t), i = Wn(e, Br), { minDaysInFirstWeek: o, startOfWeek: a } = Ar(i, r), l = le.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, d = !H(i.ordinal), m = !H(i.year), u = !H(i.month) || !H(i.day), f = m || u, g = i.weekYear || i.weekNumber;
7721
7721
  if ((f || d) && g)
7722
- throw new Rt(
7722
+ throw new It(
7723
7723
  "Can't mix weekYear/weekNumber units with year/month/day or ordinals"
7724
7724
  );
7725
7725
  if (u && d)
7726
- throw new Rt("Can't mix ordinal dates with month/day");
7726
+ throw new It("Can't mix ordinal dates with month/day");
7727
7727
  const v = g || i.weekday && !f;
7728
7728
  let y, w, R = gn(l, c);
7729
7729
  v ? (y = Ac, w = Nc, R = Vn(R, o, a)) : d ? (y = Cc, w = Dc, R = as(R)) : (y = On, w = vo);
@@ -7765,7 +7765,7 @@ class L {
7765
7765
  */
7766
7766
  static fromISO(e, t = {}) {
7767
7767
  const [s, r] = tc(e);
7768
- return Tt(s, r, t, "ISO 8601", e);
7768
+ return St(s, r, t, "ISO 8601", e);
7769
7769
  }
7770
7770
  /**
7771
7771
  * Create a DateTime from an RFC 2822 string
@@ -7784,7 +7784,7 @@ class L {
7784
7784
  */
7785
7785
  static fromRFC2822(e, t = {}) {
7786
7786
  const [s, r] = nc(e);
7787
- return Tt(s, r, t, "RFC 2822", e);
7787
+ return St(s, r, t, "RFC 2822", e);
7788
7788
  }
7789
7789
  /**
7790
7790
  * Create a DateTime from an HTTP header date
@@ -7804,7 +7804,7 @@ class L {
7804
7804
  */
7805
7805
  static fromHTTP(e, t = {}) {
7806
7806
  const [s, r] = sc(e);
7807
- return Tt(s, r, t, "HTTP", t);
7807
+ return St(s, r, t, "HTTP", t);
7808
7808
  }
7809
7809
  /**
7810
7810
  * Create a DateTime from an input string and format string.
@@ -7828,7 +7828,7 @@ class L {
7828
7828
  numberingSystem: i,
7829
7829
  defaultToEN: !0
7830
7830
  }), [a, l, c, d] = xc(o, e, t);
7831
- return d ? L.invalid(d) : Tt(a, l, s, `format ${t}`, e, c);
7831
+ return d ? L.invalid(d) : St(a, l, s, `format ${t}`, e, c);
7832
7832
  }
7833
7833
  /**
7834
7834
  * @deprecated use fromFormat instead
@@ -7859,7 +7859,7 @@ class L {
7859
7859
  */
7860
7860
  static fromSQL(e, t = {}) {
7861
7861
  const [s, r] = uc(e);
7862
- return Tt(s, r, t, "SQL", e);
7862
+ return St(s, r, t, "SQL", e);
7863
7863
  }
7864
7864
  /**
7865
7865
  * Create an invalid DateTime.
@@ -8206,7 +8206,7 @@ class L {
8206
8206
  if (o === a)
8207
8207
  return [this];
8208
8208
  const l = s - o * t, c = s - a * t, d = gn(l, o), m = gn(c, a);
8209
- return d.hour === m.hour && d.minute === m.minute && d.second === m.second && d.millisecond === m.millisecond ? [ht(this, { ts: l }), ht(this, { ts: c })] : [this];
8209
+ return d.hour === m.hour && d.minute === m.minute && d.second === m.second && d.millisecond === m.millisecond ? [mt(this, { ts: l }), mt(this, { ts: c })] : [this];
8210
8210
  }
8211
8211
  /**
8212
8212
  * Returns true if this DateTime is in a leap year, false otherwise
@@ -8233,7 +8233,7 @@ class L {
8233
8233
  * @type {number}
8234
8234
  */
8235
8235
  get daysInYear() {
8236
- return this.isValid ? xt(this.year) : NaN;
8236
+ return this.isValid ? Nt(this.year) : NaN;
8237
8237
  }
8238
8238
  /**
8239
8239
  * Returns the number of weeks in this DateTime's year
@@ -8310,7 +8310,7 @@ class L {
8310
8310
  const i = e.offset(this.ts), o = this.toObject();
8311
8311
  [r] = vn(o, i, e);
8312
8312
  }
8313
- return ht(this, { ts: r, zone: e });
8313
+ return mt(this, { ts: r, zone: e });
8314
8314
  } else
8315
8315
  return L.invalid(Yt(e));
8316
8316
  }
@@ -8322,7 +8322,7 @@ class L {
8322
8322
  */
8323
8323
  reconfigure({ locale: e, numberingSystem: t, outputCalendar: s } = {}) {
8324
8324
  const r = this.loc.clone({ locale: e, numberingSystem: t, outputCalendar: s });
8325
- return ht(this, { loc: r });
8325
+ return mt(this, { loc: r });
8326
8326
  }
8327
8327
  /**
8328
8328
  * "Set" the locale. Returns a newly-constructed DateTime.
@@ -8350,11 +8350,11 @@ class L {
8350
8350
  if (!this.isValid) return this;
8351
8351
  const t = Wn(e, Br), { minDaysInFirstWeek: s, startOfWeek: r } = Ar(t, this.loc), i = !H(t.weekYear) || !H(t.weekNumber) || !H(t.weekday), o = !H(t.ordinal), a = !H(t.year), l = !H(t.month) || !H(t.day), c = a || l, d = t.weekYear || t.weekNumber;
8352
8352
  if ((c || o) && d)
8353
- throw new Rt(
8353
+ throw new It(
8354
8354
  "Can't mix weekYear/weekNumber units with year/month/day or ordinals"
8355
8355
  );
8356
8356
  if (l && o)
8357
- throw new Rt("Can't mix ordinal dates with month/day");
8357
+ throw new It("Can't mix ordinal dates with month/day");
8358
8358
  let m;
8359
8359
  i ? m = Nr(
8360
8360
  { ...Vn(this.c, s, r), ...t },
@@ -8362,7 +8362,7 @@ class L {
8362
8362
  r
8363
8363
  ) : H(t.ordinal) ? (m = { ...this.toObject(), ...t }, H(t.day) && (m.day = Math.min(Un(m.year, m.month), m.day))) : m = Dr({ ...as(this.c), ...t });
8364
8364
  const [u, f] = vn(m, this.o, this.zone);
8365
- return ht(this, { ts: u, o: f });
8365
+ return mt(this, { ts: u, o: f });
8366
8366
  }
8367
8367
  /**
8368
8368
  * Add a period of time to this DateTime and return the resulting DateTime
@@ -8380,7 +8380,7 @@ class L {
8380
8380
  plus(e) {
8381
8381
  if (!this.isValid) return this;
8382
8382
  const t = te.fromDurationLike(e);
8383
- return ht(this, zr(this, t));
8383
+ return mt(this, zr(this, t));
8384
8384
  }
8385
8385
  /**
8386
8386
  * Subtract a period of time to this DateTime and return the resulting DateTime
@@ -8391,7 +8391,7 @@ class L {
8391
8391
  minus(e) {
8392
8392
  if (!this.isValid) return this;
8393
8393
  const t = te.fromDurationLike(e).negate();
8394
- return ht(this, zr(this, t));
8394
+ return mt(this, zr(this, t));
8395
8395
  }
8396
8396
  /**
8397
8397
  * "Set" this DateTime to the beginning of a unit of time.
@@ -8947,7 +8947,7 @@ class L {
8947
8947
  `fromFormatParser called with a locale of ${o}, but the format parser was created for ${t.locale}`
8948
8948
  );
8949
8949
  const { result: a, zone: l, specificOffset: c, invalidReason: d } = t.explainFromTokens(e);
8950
- return d ? L.invalid(d) : Tt(
8950
+ return d ? L.invalid(d) : St(
8951
8951
  a,
8952
8952
  l,
8953
8953
  s,
@@ -9135,7 +9135,7 @@ const Mc = (n, e) => {
9135
9135
  });
9136
9136
  }
9137
9137
  return je({
9138
- Collection_Path: vt(Te()),
9138
+ Collection_Path: Ot(Te()),
9139
9139
  ...t
9140
9140
  });
9141
9141
  }, Fc = (n, e, t, s) => {
@@ -9172,9 +9172,9 @@ const Mc = (n, e) => {
9172
9172
  s = Xt(), r && (s = s.describe(r.trim()));
9173
9173
  break;
9174
9174
  case "Number":
9175
- n.autoIncrement ? s = ke([ss(), pt().int()], {
9175
+ n.autoIncrement ? s = ke([ss(), yt().int()], {
9176
9176
  message: "Must be a valid number"
9177
- }) : (s = pt({
9177
+ }) : (s = yt({
9178
9178
  message: "Must be a valid number"
9179
9179
  }), n.min && (s = s.min(n.min, `Must be greater than or equal to ${n.min}`)), n.max && (s = s.max(n.max, `Must be less than or equal to ${n.max}`)), n.decimal ? t ? s = s.describe(`${r}Must have ${n.decimal} decimal places`) : s = s.refine((l) => n.decimal ? (l.toString().split(".")[1]?.length || 0) <= n.decimal : !1, {
9180
9180
  message: `Must have ${n.decimal} or fewer decimal places`
@@ -9187,8 +9187,8 @@ const Mc = (n, e) => {
9187
9187
  break;
9188
9188
  case "Timestamp":
9189
9189
  t ? (s = je({
9190
- seconds: pt(),
9191
- nanoseconds: pt()
9190
+ seconds: yt(),
9191
+ nanoseconds: yt()
9192
9192
  }), n.min && n.max ? s = s.describe(`${r}Must be between ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)} and ${L.fromMillis(n.max).toLocaleString(L.DATE_MED)}`) : n.min ? s = s.describe(`${r}Must be greater than or equal to ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)}`) : n.max ? s = s.describe(`${r}Must be less than or equal to ${L.fromMillis(n.max).toLocaleString(L.DATE_MED)}`) : r && (s = s.describe(r.trim()))) : (s = Pc(), n.min && (s = s.refine((l) => l.toMillis() >= n.min, {
9193
9193
  message: `Must be greater than or equal to ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)}`
9194
9194
  })), n.max && (s = s.refine((l) => l.toMillis() <= n.max, {
@@ -9196,7 +9196,7 @@ const Mc = (n, e) => {
9196
9196
  })));
9197
9197
  break;
9198
9198
  case "Array":
9199
- s = vt(pe()), n.length && (s = s.length(n.length, `Must contain ${n.length} item(s)`)), n.minlength ? s = s.min(n.minlength, `Must contain at least ${n.minlength} item(s)`) : n.required && !i && (s = s.nonempty("Must contain at least one item")), n.maxlength && (s = s.max(n.maxlength, `Must contain at most ${n.maxlength} item(s)`)), n.values ? (t || (s = s.refine((l) => {
9199
+ s = Ot(pe()), n.length && (s = s.length(n.length, `Must contain ${n.length} item(s)`)), n.minlength ? s = s.min(n.minlength, `Must contain at least ${n.minlength} item(s)`) : n.required && !i && (s = s.nonempty("Must contain at least one item")), n.maxlength && (s = s.max(n.maxlength, `Must contain at most ${n.maxlength} item(s)`)), n.values ? (t || (s = s.refine((l) => {
9200
9200
  let c = !0;
9201
9201
  return l.forEach((d) => {
9202
9202
  n.values && !n.values.includes(d) && (c = !1);
@@ -9223,7 +9223,7 @@ const Mc = (n, e) => {
9223
9223
  message: `Must contain at most ${c.max} item(s)`
9224
9224
  })))) : a[c.name] = Oo(c, t, s), r && (a[c.name] = a[c.name].optional()));
9225
9225
  }), !s && i && (a.operation = ke([be("create"), be("update"), be("delete")]).optional(), a.password = Te().optional(), a.passwordConfirm = Te().optional(), Object.values(e.collections).forEach((c) => {
9226
- a[`auth-${c.labels.collection}`] = Xt().optional(), a[`operations-${c.labels.collection}`] = vt(ke([be("Read"), be("Create"), be("Update"), be("Delete")])).optional(), a[`restrict-${c.labels.collection}`] = Xt().optional(), c.access.attributeRestrictions?.forEach((d) => {
9226
+ a[`auth-${c.labels.collection}`] = Xt().optional(), a[`operations-${c.labels.collection}`] = Ot(ke([be("Read"), be("Create"), be("Update"), be("Delete")])).optional(), a[`restrict-${c.labels.collection}`] = Xt().optional(), c.access.attributeRestrictions?.forEach((d) => {
9227
9227
  a[`attribute-${c.labels.collection}-${d.type}`] = Xt().optional();
9228
9228
  }), c.access.entityRestrictions?.restrictions?.forEach((d) => {
9229
9229
  if (d.type === "Individual" && (a[`accessible-${c.labels.collection}-${c.labels.collection}`] = je({}).catchall(pe()).optional()), d.type === "Parent" || d.type === "Parent_Property") {
@@ -9253,7 +9253,7 @@ const Mc = (n, e) => {
9253
9253
  Collection_Path: t
9254
9254
  }), I && I.size++);
9255
9255
  }), E.forEach((p) => {
9256
- if (dt(p, o, i)) {
9256
+ if (ft(p, o, i)) {
9257
9257
  const $ = hn(p, o, i), A = {};
9258
9258
  r[p.name] !== void 0 && (A[p.name] = r[p.name], X(p) && (A[`${p.name}_Array`] = r[`${p.name}_Array`])), $.forEach((j) => {
9259
9259
  r[j.name] !== void 0 && (X(j) ? A[`${j.name}_Array`] = r[`${j.name}_Array`] : A[j.name] = r[j.name]);
@@ -9269,8 +9269,8 @@ const Mc = (n, e) => {
9269
9269
  }
9270
9270
  const _ = (p, $) => {
9271
9271
  let A = 1;
9272
- dt($, p, i) && A++, p.fields.forEach((h) => {
9273
- dt(h, p, i) && JSON.parse(es(hn(h, p, i))).includes($.name) && A++;
9272
+ ft($, p, i) && A++, p.fields.forEach((h) => {
9273
+ ft(h, p, i) && JSON.parse(es(hn(h, p, i))).includes($.name) && A++;
9274
9274
  });
9275
9275
  const j = l[p.labels.collection];
9276
9276
  for (const h of j)
@@ -9278,11 +9278,11 @@ const Mc = (n, e) => {
9278
9278
  return A;
9279
9279
  }, z = (p, $, A, j, h) => {
9280
9280
  const S = {};
9281
- S[`${A.name}.${s}`] = m(), S[`${A.name}_Array`] = d(s), S[`${A.name}_Single`] = m(), e.update(v(h, j), S), dt(A, $, i) && e.update(y(p, A.name, j), {
9281
+ S[`${A.name}.${s}`] = m(), S[`${A.name}_Array`] = d(s), S[`${A.name}_Single`] = m(), e.update(v(h, j), S), ft(A, $, i) && e.update(y(p, A.name, j), {
9282
9282
  [`${A.name}.${s}`]: m(),
9283
9283
  [`${A.name}_Array`]: d(s)
9284
9284
  }), $.fields.forEach((T) => {
9285
- dt(T, $, i) && JSON.parse(es(hn(T, $, i))).includes(A.name) && e.update(y(p, T.name, j), {
9285
+ ft(T, $, i) && JSON.parse(es(hn(T, $, i))).includes(A.name) && e.update(y(p, T.name, j), {
9286
9286
  [`${A.name}_Array`]: d(s)
9287
9287
  });
9288
9288
  });
@@ -9297,7 +9297,7 @@ const Mc = (n, e) => {
9297
9297
  for (const p of k) {
9298
9298
  if (!I)
9299
9299
  throw new Error("VALIDATION_ERROR: batchSize is required");
9300
- const $ = i.collections[p.collection], A = U($.fields, p.twoWay), j = mt($, $.fields), h = Array.from(j).map((S) => S.name);
9300
+ const $ = i.collections[p.collection], A = U($.fields, p.twoWay), j = pt($, $.fields), h = Array.from(j).map((S) => S.name);
9301
9301
  if (!A)
9302
9302
  throw new Error(`SCHEMA_ERROR: Field ${p.twoWay} not found in collection ${p.collection}`);
9303
9303
  if (X(A)) {
@@ -9312,7 +9312,7 @@ const Mc = (n, e) => {
9312
9312
  if (T[Z] !== void 0) {
9313
9313
  N[Z] = T[Z];
9314
9314
  const x = U(o.fields, Z);
9315
- Et(o, [x]).size === 1 && (N[`${Z}_Lowercase`] = T[`${Z}_Lowercase`]);
9315
+ vt(o, [x]).size === 1 && (N[`${Z}_Lowercase`] = T[`${Z}_Lowercase`]);
9316
9316
  }
9317
9317
  });
9318
9318
  const q = {
@@ -9331,14 +9331,14 @@ const Mc = (n, e) => {
9331
9331
  e.update(v(b.Collection_Path, S), {
9332
9332
  ...q,
9333
9333
  ...F
9334
- }), I.size++, dt(A, $, i) && (e.update(y(p, A.name, S), {
9334
+ }), I.size++, ft(A, $, i) && (e.update(y(p, A.name, S), {
9335
9335
  [`${A.name}.${s}`]: {
9336
9336
  Collection_Path: t,
9337
9337
  ...N
9338
9338
  },
9339
9339
  [`${A.name}_Array`]: c(s)
9340
9340
  }), I.size++), $.fields.forEach((Z) => {
9341
- if (dt(Z, $, i)) {
9341
+ if (ft(Z, $, i)) {
9342
9342
  const x = JSON.parse(es(hn(Z, $, i))), Q = {};
9343
9343
  x.includes(A.name) && (Q[`${p.twoWay}_Array`] = c(s)), Object.keys(F).forEach((B) => {
9344
9344
  x.includes(B) && (Q[B] = F[B]);
@@ -9445,7 +9445,7 @@ const Mc = (n, e) => {
9445
9445
  return t;
9446
9446
  };
9447
9447
  let ms, ko, bn, bo, Qt, To, Tn, Sn, ps = 0, Xr = !1;
9448
- const It = {
9448
+ const xt = {
9449
9449
  getTenant() {
9450
9450
  if (!bn)
9451
9451
  throw new Error("Tenant not provided");
@@ -9461,13 +9461,13 @@ const It = {
9461
9461
  return bo;
9462
9462
  },
9463
9463
  getGlobalConfigModule() {
9464
- return he(Qt);
9464
+ return fe(Qt);
9465
9465
  },
9466
9466
  getCustomizationFile(n, e) {
9467
9467
  if (!Object.keys(e.collections).includes(n))
9468
9468
  throw new Error("PERMISSION_DENIED");
9469
- const t = sa([n], To, "node", It);
9470
- return he(t?.[n]);
9469
+ const t = sa([n], To, "node", xt);
9470
+ return fe(t?.[n]);
9471
9471
  },
9472
9472
  getVersionInfo() {
9473
9473
  return Tn;
@@ -9478,11 +9478,11 @@ const It = {
9478
9478
  }, uu = async (n, e, t, s, r) => {
9479
9479
  const i = !!Xr;
9480
9480
  if (Xr = !0, e && (bn = e), ko = n, ms && !r)
9481
- return It;
9481
+ return xt;
9482
9482
  if (!process.env.STOKER_FB_WEB_APP_CONFIG)
9483
9483
  throw new Error("STOKER_FB_WEB_APP_CONFIG not set.");
9484
9484
  const o = process.env.STOKER_FB_WEB_APP_CONFIG, a = JSON.parse(o), d = (await import(ii(t).href)).default;
9485
- Qt = d({ sdk: "node", utils: It }), !r && n === "development" && (process.env.FIREBASE_AUTH_EMULATOR_HOST = "127.0.0.1:9099", process.env.FIREBASE_DATABASE_EMULATOR_HOST = "127.0.0.1:9000", process.env.FIRESTORE_EMULATOR_HOST = "127.0.0.1:8080", process.env.FIREBASE_STORAGE_EMULATOR_HOST = "127.0.0.1:9199");
9485
+ Qt = d({ sdk: "node", utils: xt }), !r && n === "development" && (process.env.FIREBASE_AUTH_EMULATOR_HOST = "127.0.0.1:9099", process.env.FIREBASE_DATABASE_EMULATOR_HOST = "127.0.0.1:9000", process.env.FIRESTORE_EMULATOR_HOST = "127.0.0.1:8080", process.env.FIREBASE_STORAGE_EMULATOR_HOST = "127.0.0.1:9199");
9486
9486
  try {
9487
9487
  ms = ni();
9488
9488
  } catch {
@@ -9504,11 +9504,11 @@ const It = {
9504
9504
  console.error(u.message);
9505
9505
  }), await new Promise((u) => {
9506
9506
  const f = () => {
9507
- Sn && Tn ? u(It) : setTimeout(f, 100);
9507
+ Sn && Tn ? u(xt) : setTimeout(f, 100);
9508
9508
  };
9509
9509
  f();
9510
- }), It;
9511
- }, { getTenant: Xe, setTenant: du, getMode: So, getTimezone: Ro, getGlobalConfigModule: jt, getCustomizationFile: et, getVersionInfo: fu, getMaintenanceInfo: hu } = It, mu = async (n, e, t, s) => new Promise((r, i) => {
9510
+ }), xt;
9511
+ }, { getTenant: Xe, setTenant: du, getMode: So, getTimezone: Ro, getGlobalConfigModule: Zt, getCustomizationFile: et, getVersionInfo: fu, getMaintenanceInfo: hu } = xt, mu = async (n, e, t, s) => new Promise((r, i) => {
9512
9512
  const o = qo(n, e, { cwd: t || process.cwd(), env: { ...process.env, ...s } });
9513
9513
  let a = "";
9514
9514
  const l = () => {
@@ -9895,7 +9895,7 @@ const It = {
9895
9895
  throw new Error("MAINTENANCE_MODE");
9896
9896
  const g = u;
9897
9897
  let v;
9898
- const y = jt(), w = n.at(-1);
9898
+ const y = Zt(), w = n.at(-1);
9899
9899
  if (!w)
9900
9900
  throw new Error("EMPTY_PATH");
9901
9901
  const R = Object.keys(g.collections).includes(w), O = y.disabledCollections?.includes(w);
@@ -9957,9 +9957,9 @@ const It = {
9957
9957
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9958
9958
  a.get(h.id),
9959
9959
  b,
9960
- he(e.subcollections),
9960
+ fe(e.subcollections),
9961
9961
  g,
9962
- he(e?.relations),
9962
+ fe(e?.relations),
9963
9963
  void 0,
9964
9964
  e.userId,
9965
9965
  e.transactional ? c : void 0,
@@ -9977,7 +9977,7 @@ const It = {
9977
9977
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9978
9978
  a.get(h.id),
9979
9979
  b,
9980
- he(e.relations),
9980
+ fe(e.relations),
9981
9981
  g,
9982
9982
  void 0,
9983
9983
  e.userId,
@@ -10109,7 +10109,7 @@ const It = {
10109
10109
  throw new Error("MAINTENANCE_MODE");
10110
10110
  const u = d;
10111
10111
  let f;
10112
- const g = jt(), v = n.at(-1);
10112
+ const g = Zt(), v = n.at(-1);
10113
10113
  if (!v)
10114
10114
  throw new Error("EMPTY_PATH");
10115
10115
  const y = Object.keys(u.collections).includes(v), w = g.disabledCollections?.includes(v);
@@ -10193,8 +10193,8 @@ const It = {
10193
10193
  }
10194
10194
  })), u.length > 0)
10195
10195
  throw new Error(u.join(", "));
10196
- }, Pt = async (n, e, t, s, r, i, o, a, l) => {
10197
- const { labels: c } = o, d = ce(), m = jt(), u = await ie(m.firebase?.writeLogTTL), f = {
10196
+ }, Lt = async (n, e, t, s, r, i, o, a, l) => {
10197
+ const { labels: c } = o, d = ce(), m = Zt(), u = await ie(m.firebase?.writeLogTTL), f = {
10198
10198
  operation: n,
10199
10199
  collection: c.collection,
10200
10200
  docId: i,
@@ -10212,12 +10212,12 @@ const It = {
10212
10212
  const w = /* @__PURE__ */ new Date(), R = new Date((/* @__PURE__ */ new Date()).setDate(w.getDate() + u));
10213
10213
  f.TTL = ut.fromDate(R);
10214
10214
  }
10215
- const g = he(t);
10216
- it(g), n !== "delete" && (f.data.data = he(g)), n === "update" && (f.data.originalRecord = he(l)), n !== "delete" && ["started", "written"].includes(e) && (delete f.data.data.Saved_At, delete f.data.data.Last_Save_At), e === "failed" && (f.data.error = JSON.stringify(a));
10215
+ const g = fe(t);
10216
+ it(g), n !== "delete" && (f.data.data = fe(g)), n === "update" && (f.data.originalRecord = fe(l)), n !== "delete" && ["started", "written"].includes(e) && (delete f.data.data.Saved_At, delete f.data.data.Last_Save_At), e === "failed" && (f.data.error = JSON.stringify(a));
10217
10217
  const v = Ce(d, r, s), y = t.Last_Write_At;
10218
10218
  await v.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${y.valueOf()}`).set(f);
10219
10219
  }, dn = async (n) => {
10220
- const e = Xe(), t = _t(), s = ce(), r = [];
10220
+ const e = Xe(), t = Et(), s = ce(), r = [];
10221
10221
  if (await Promise.all([
10222
10222
  (async () => {
10223
10223
  try {
@@ -10272,7 +10272,7 @@ function jc(n) {
10272
10272
  return e;
10273
10273
  }
10274
10274
  const Fo = async (n, e, t, s, r, i, o) => {
10275
- const a = _t(), l = ce(), { labels: c, fields: d } = s, m = "USER_ERROR", u = async (y, w) => {
10275
+ const a = Et(), l = ce(), { labels: c, fields: d } = s, m = "USER_ERROR", u = async (y, w) => {
10276
10276
  try {
10277
10277
  await dn(y);
10278
10278
  } catch {
@@ -10372,7 +10372,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10372
10372
  }, nr = (n) => {
10373
10373
  if (typeof n == "object")
10374
10374
  for (const e in n)
10375
- Object.prototype.hasOwnProperty.call(n, e) && (n[e] === "_DELETE_FIELD" ? n[e] = fe.delete() : nr(n[e]));
10375
+ Object.prototype.hasOwnProperty.call(n, e) && (n[e] === "_DELETE_FIELD" ? n[e] = he.delete() : nr(n[e]));
10376
10376
  }, Zc = (n, e, t) => {
10377
10377
  if (X(t) && t.includeFields) {
10378
10378
  const s = {};
@@ -10380,7 +10380,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10380
10380
  if (e[r] !== void 0) {
10381
10381
  s[r] = e[r];
10382
10382
  const i = U(n.fields, r);
10383
- Et(n, [i]).size === 1 && (s[`${r}_Lowercase`] = e[`${r}_Lowercase`]);
10383
+ vt(n, [i]).size === 1 && (s[`${r}_Lowercase`] = e[`${r}_Lowercase`]);
10384
10384
  }
10385
10385
  }), s;
10386
10386
  }
@@ -10418,7 +10418,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10418
10418
  X(w) && ["OneToOne", "OneToMany"].includes(w.type) && w.enforceHierarchy && s[w.name] && (n === "Create" || n === "Update" && !He(m?.[w.name], s[w.name])) && await ei(e, i, w, s, a, l);
10419
10419
  for (const w of u)
10420
10420
  if (X(w) && w.twoWay) {
10421
- const R = o.collections[w.collection], O = U(R.fields, w.twoWay), I = mt(R, [O]);
10421
+ const R = o.collections[w.collection], O = U(R.fields, w.twoWay), I = pt(R, [O]);
10422
10422
  if (s[w.name]) {
10423
10423
  const E = Object.entries(s[w.name]);
10424
10424
  for (const C of E) {
@@ -10439,7 +10439,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10439
10439
  v.set(w.collection, {
10440
10440
  ...v.get(w.collection) || {},
10441
10441
  [_]: h
10442
- }), k = he({ ...h, ...Rn(s) });
10442
+ }), k = fe({ ...h, ...Rn(s) });
10443
10443
  }
10444
10444
  const $ = {
10445
10445
  ...k[O.name],
@@ -10475,7 +10475,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10475
10475
  v.set(w.collection, {
10476
10476
  ...v.get(w.collection) || {},
10477
10477
  [_]: j
10478
- }), k = he({ ...j, ...Rn(s) });
10478
+ }), k = fe({ ...j, ...Rn(s) });
10479
10479
  }
10480
10480
  k[O.name][t] && delete k[O.name][t], Array.isArray(k[`${O.name}_Array`]) && (k[`${O.name}_Array`] = k[`${O.name}_Array`].filter(($) => $ !== t)), I.size === 1 && delete k[`${O.name}_Single`], y.set(w.collection, {
10481
10481
  ...y.get(w.collection) || {},
@@ -10498,7 +10498,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10498
10498
  }
10499
10499
  }
10500
10500
  for (const k of z) {
10501
- const p = U(O.fields, k.twoWay), $ = mt(O, [p]);
10501
+ const p = U(O.fields, k.twoWay), $ = pt(O, [p]);
10502
10502
  if (!rr(O, p, d)) {
10503
10503
  ys(
10504
10504
  k,
@@ -10523,7 +10523,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10523
10523
  for (const k of _)
10524
10524
  _n(k, r, E);
10525
10525
  for (const k of z) {
10526
- const p = U(O.fields, k.twoWay), $ = mt(O, [p]);
10526
+ const p = U(O.fields, k.twoWay), $ = pt(O, [p]);
10527
10527
  ys(
10528
10528
  k,
10529
10529
  r,
@@ -10538,7 +10538,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10538
10538
  for (const k of _)
10539
10539
  _n(k, r, E);
10540
10540
  for (const k of z) {
10541
- const p = U(O.fields, k.twoWay), $ = mt(O, [p]);
10541
+ const p = U(O.fields, k.twoWay), $ = pt(O, [p]);
10542
10542
  ys(
10543
10543
  k,
10544
10544
  r,
@@ -10563,13 +10563,13 @@ const Fo = async (n, e, t, s, r, i, o) => {
10563
10563
  }
10564
10564
  return g;
10565
10565
  }, Vo = (n, e, t) => {
10566
- n === "create" && gt.forEach((s) => {
10566
+ n === "create" && wt.forEach((s) => {
10567
10567
  if (!He(e[s], t[s]))
10568
10568
  throw new Error(`Updating system fields in hooks is not allowed: ${s}`);
10569
10569
  }), n === "update" && (["id", "Collection_Path", "Created_At", "Saved_At", "Created_By"].forEach((s) => {
10570
10570
  if (s in e)
10571
10571
  throw new Error(`Cannot update system field: ${s}`);
10572
- }), gt.forEach((s) => {
10572
+ }), wt.forEach((s) => {
10573
10573
  if (!["id", "Collection_Path", "Created_At", "Saved_At", "Created_By"].includes(s) && !He(e[s], t[s]))
10574
10574
  throw new Error(`Updating system fields in hooks is not allowed: ${s}`);
10575
10575
  }));
@@ -10580,12 +10580,12 @@ const Fo = async (n, e, t, s, r, i, o) => {
10580
10580
  const i = r?.archivedField, o = r?.timestampField;
10581
10581
  if (t[i] === !0)
10582
10582
  if (n === "create")
10583
- t[o] = fe.serverTimestamp();
10583
+ t[o] = he.serverTimestamp();
10584
10584
  else {
10585
10585
  if (!s)
10586
10586
  throw new Error("Original record is required for update");
10587
10587
  if (!s[i])
10588
- t[o] = fe.serverTimestamp();
10588
+ t[o] = he.serverTimestamp();
10589
10589
  else if (t[o] && t[o]?.valueOf() !== s[o]?.valueOf())
10590
10590
  throw new Error("Soft delete timestamp cannot be changed");
10591
10591
  }
@@ -10665,7 +10665,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10665
10665
  }, wu = async (n, e, t) => {
10666
10666
  const s = t?.userId, r = t?.user;
10667
10667
  let i = t?.context;
10668
- const o = Xe(), a = jt();
10668
+ const o = Xe(), a = Zt();
10669
10669
  if (t?.providedTransaction && s)
10670
10670
  throw new Error("PERMISSION_DENIED");
10671
10671
  if (t?.providedSchema && s)
@@ -10676,15 +10676,15 @@ const Fo = async (n, e, t, s, r, i, o) => {
10676
10676
  const c = n.at(-1), d = Object.keys(l.collections).includes(c), m = a.disabledCollections?.includes(c);
10677
10677
  if (!d || m)
10678
10678
  throw new Error("COLLECTION_NOT_FOUND");
10679
- const u = l.collections[c], { labels: f, fields: g, enableWriteLog: v, softDelete: y } = u, w = et(f.collection, l), R = await ie(a.appName), O = ce(), I = _t(), C = (s ? await I.getUser(s) : void 0)?.customClaims?.role;
10679
+ const u = l.collections[c], { labels: f, fields: g, enableWriteLog: v, softDelete: y } = u, w = et(f.collection, l), R = await ie(a.appName), O = ce(), I = Et(), C = (s ? await I.getUser(s) : void 0)?.customClaims?.role;
10680
10680
  let _;
10681
10681
  s && await tr(n, u);
10682
10682
  const z = Ce(O, n, o), k = t?.id || z.doc().id;
10683
10683
  i = i || {}, i.collection = f.collection, e.id = k, Po(e), nr(e);
10684
- const p = Ws("create", n, e, l, R, "Online", s || "System", ut.now(), fe.serverTimestamp());
10684
+ const p = Ws("create", n, e, l, R, "Online", s || "System", ut.now(), he.serverTimestamp());
10685
10685
  t?.createdAt && (p.Created_At = t.createdAt), t?.createdBy && (p.Created_By = t.createdBy);
10686
- const $ = he(p);
10687
- y && (p[y.archivedField] = !1), Ue(e), v && !t?.providedTransaction && await Pt("create", "started", p, o, n, k, u), await oe("preOperation", a, w, { operation: "create", data: p, recordId: k, context: i }), await oe("preWrite", a, w, { operation: "create", data: p, recordId: k, context: i }), In(u, p, l), xn(u, p), await aa(p, u, w, C), Ue(p);
10686
+ const $ = fe(p);
10687
+ y && (p[y.archivedField] = !1), Ue(e), v && !t?.providedTransaction && await Lt("create", "started", p, o, n, k, u), await oe("preOperation", a, w, { operation: "create", data: p, recordId: k, context: i }), await oe("preWrite", a, w, { operation: "create", data: p, recordId: k, context: i }), In(u, p, l), xn(u, p), await aa(p, u, w, C), Ue(p);
10688
10688
  try {
10689
10689
  if (u.auth && r && !r.password)
10690
10690
  throw new Error("Password is required");
@@ -10785,7 +10785,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10785
10785
  const N = { size: 1 };
10786
10786
  await h(T, N), t?.noTwoWay || await Lo("Create", o, k, p, p, u, l, T, N, s, _);
10787
10787
  const q = Us(l);
10788
- Qs("create", T, n, k, p, l, u, t, q, fe.arrayUnion, fe.arrayRemove, fe.delete, (F) => O.collection("tenants").doc(o).collection("system_fields").doc(f.collection).collection(`${f.collection}-${F.name}`).doc(k), (F, G) => O.collection("tenants").doc(o).collection("system_unique").doc(f.collection).collection(`Unique-${f.collection}-${F.name}`).doc(G), (F) => O.collection("tenants").doc(o).collection("system_fields").doc(f.collection).collection(`${f.collection}-${F}`).doc(k), (F, G) => Ce(O, F, o).doc(G), (F, G, Z) => O.collection("tenants").doc(o).collection("system_fields").doc(F.collection).collection(`${F.collection}-${G}`).doc(Z), (F, G, Z) => O.collection("tenants").doc(o).collection("system_fields").doc(F.collection).collection(`${F.collection}-${G.replaceAll(" ", "-")}`).doc(Z), void 0, void 0, N), T.set(z.doc(k), p);
10788
+ Qs("create", T, n, k, p, l, u, t, q, he.arrayUnion, he.arrayRemove, he.delete, (F) => O.collection("tenants").doc(o).collection("system_fields").doc(f.collection).collection(`${f.collection}-${F.name}`).doc(k), (F, G) => O.collection("tenants").doc(o).collection("system_unique").doc(f.collection).collection(`Unique-${f.collection}-${F.name}`).doc(G), (F) => O.collection("tenants").doc(o).collection("system_fields").doc(f.collection).collection(`${f.collection}-${F}`).doc(k), (F, G) => Ce(O, F, o).doc(G), (F, G, Z) => O.collection("tenants").doc(o).collection("system_fields").doc(F.collection).collection(`${F.collection}-${G}`).doc(Z), (F, G, Z) => O.collection("tenants").doc(o).collection("system_fields").doc(F.collection).collection(`${F.collection}-${G.replaceAll(" ", "-")}`).doc(Z), void 0, void 0, N), T.set(z.doc(k), p);
10789
10789
  } catch (N) {
10790
10790
  if (t?.providedTransaction)
10791
10791
  throw N;
@@ -10799,7 +10799,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10799
10799
  });
10800
10800
  if (v && (await new Promise((G) => {
10801
10801
  setTimeout(G, 250);
10802
- }), await Pt("create", F?.resolved ? "success" : "failed", p, o, n, k, u, F?.resolved ? void 0 : N)), !F?.resolved)
10802
+ }), await Lt("create", F?.resolved ? "success" : "failed", p, o, n, k, u, F?.resolved ? void 0 : N)), !F?.resolved)
10803
10803
  throw u.auth && r && await dn(p), N;
10804
10804
  }
10805
10805
  }
@@ -10812,7 +10812,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10812
10812
  }
10813
10813
  return { id: k, ...p };
10814
10814
  }, Kt = async (n, e, t, s) => {
10815
- const r = Xe(), i = _t(), o = ce(), a = e.customClaims || {};
10815
+ const r = Xe(), i = Et(), o = ce(), a = e.customClaims || {};
10816
10816
  let l = !1;
10817
10817
  try {
10818
10818
  await i.updateUser(n, {
@@ -10846,7 +10846,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10846
10846
  if (l)
10847
10847
  throw new Error(`ROLLBACK_FAILED: ${s}`);
10848
10848
  }, Hc = async (n, e, t, s, r, i, o, a, l, c, d) => {
10849
- const m = _t(), u = ce(), f = {};
10849
+ const m = Et(), u = ce(), f = {};
10850
10850
  for (const y of r.fields)
10851
10851
  y.saveToAuthToken && !er(y.name) && i[y.name] !== void 0 && y.type !== "Timestamp" && y.type !== "Computed" && y.type !== "Embedding" && (Re(i[y.name]) ? f[y.name] = null : f[y.name] = i[y.name]);
10852
10852
  const g = "USER_ERROR";
@@ -10951,9 +10951,9 @@ const Fo = async (n, e, t, s, r, i, o) => {
10951
10951
  }
10952
10952
  await i.commit();
10953
10953
  }, Yc = async (n, e, t, s) => {
10954
- const r = s?.userId, i = s?.user;
10955
- let o = s?.context;
10956
- const a = Xe(), l = jt();
10954
+ const r = s?.userId;
10955
+ let i = s?.user, o = s?.context;
10956
+ const a = Xe(), l = Zt();
10957
10957
  if (s?.providedTransaction && r)
10958
10958
  throw new Error("PERMISSION_DENIED");
10959
10959
  if (s?.providedSchema && r)
@@ -10966,7 +10966,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
10966
10966
  const d = n.at(-1), m = Object.keys(c.collections).includes(d), u = l.disabledCollections?.includes(d);
10967
10967
  if (!m || u)
10968
10968
  throw new Error("COLLECTION_NOT_FOUND");
10969
- const f = c.collections[d], { labels: g, fields: v, enableWriteLog: y } = f, w = et(g.collection, c), R = await ie(l.appName), O = _t(), I = ce();
10969
+ const f = c.collections[d], { labels: g, fields: v, enableWriteLog: y } = f, w = et(g.collection, c), R = await ie(l.appName), O = Et(), I = ce();
10970
10970
  let E;
10971
10971
  r && await tr(n, f);
10972
10972
  const C = Ce(I, n, a);
@@ -11003,16 +11003,16 @@ const Fo = async (n, e, t, s, r, i, o) => {
11003
11003
  (Q) => t[Q.name] !== void 0 && t[Q.name] !== x[Q.name]
11004
11004
  ));
11005
11005
  delete t.id, Po(t), nr(t);
11006
- const h = Ws("update", n, t, c, R, "Online", r || "System", ut.now(), fe.serverTimestamp()), S = he(h);
11006
+ const h = Ws("update", n, t, c, R, "Online", r || "System", ut.now(), he.serverTimestamp()), S = fe(h);
11007
11007
  for (const x of v)
11008
11008
  !X(x) && Re(h[x.name]) && x.nullable && (h[x.name] = null);
11009
- Ue(h), Ue(_), y && !s?.providedTransaction && await Pt("update", "started", h, a, n, e, f, void 0, _);
11009
+ Ue(h), Ue(_), y && !s?.providedTransaction && await Lt("update", "started", h, a, n, e, f, void 0, _);
11010
11010
  const b = {
11011
11011
  operation: "update",
11012
11012
  data: h,
11013
11013
  recordId: e,
11014
11014
  context: o,
11015
- originalRecord: he(_)
11015
+ originalRecord: fe(_)
11016
11016
  };
11017
11017
  await oe("preOperation", l, w, b);
11018
11018
  const T = {
@@ -11020,15 +11020,15 @@ const Fo = async (n, e, t, s, r, i, o) => {
11020
11020
  data: h,
11021
11021
  recordId: e,
11022
11022
  context: o,
11023
- originalRecord: he(_)
11023
+ originalRecord: fe(_)
11024
11024
  };
11025
11025
  await oe("preWrite", l, w, T), In(f, h, c), xn(f, h), Ue(h);
11026
11026
  try {
11027
- if (p && !i.password)
11027
+ if (p && !i?.password)
11028
11028
  throw new Error("Password is required");
11029
11029
  if (!s?.providedTransaction) {
11030
11030
  const x = { ...z, ...h };
11031
- await Co("update", a, e, x, f, c), it(x), await rn("update", x, f, w, { operation: "update", record: h, context: o, originalRecord: he(_) }, c);
11031
+ await Co("update", a, e, x, f, c), it(x), await rn("update", x, f, w, { operation: "update", record: h, context: o, originalRecord: fe(_) }, c);
11032
11032
  }
11033
11033
  } catch (x) {
11034
11034
  throw new Error(`VALIDATION_ERROR: ${x.message}`);
@@ -11038,7 +11038,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11038
11038
  !X(x) && Re(h[x.name]) && x.nullable && (h[x.name] = null);
11039
11039
  try {
11040
11040
  const x = { ...z, ...h };
11041
- it(x), Uo("update", f, h, _), Vo("update", h, S), await rn("update", x, f, w, { operation: "update", record: h, context: o, originalRecord: he(_) }, c);
11041
+ it(x), Uo("update", f, h, _), Vo("update", h, S), await rn("update", x, f, w, { operation: "update", record: h, context: o, originalRecord: fe(_) }, c);
11042
11042
  } catch (x) {
11043
11043
  throw new Error(`VALIDATION_ERROR: ${x.message}`);
11044
11044
  }
@@ -11083,7 +11083,9 @@ const Fo = async (n, e, t, s, r, i, o) => {
11083
11083
  const Oe = await x.get(I.collection("tenants").doc(a).collection("system_user_permissions").doc(_.User_ID));
11084
11084
  if (B && B.size++, !Oe?.exists)
11085
11085
  throw new Error("PERMISSION_DENIED");
11086
- if (N = Oe.data(), i?.permissions) {
11086
+ N = Oe.data();
11087
+ const dt = i?.permissions && Object.keys(i.permissions).length > 0 ? i.permissions : void 0;
11088
+ if (h.Role && h.Role !== _.Role && !dt && (i ||= { operation: "update", permissions: {} }, i.permissions = fe(N), i.permissions.Role = h.Role), i?.permissions) {
11087
11089
  if (i.permissions.Role ||= h.Role || _.Role, i.permissions.Enabled ??= h.Enabled ?? _.Enabled, Re(i.permissions.Role))
11088
11090
  throw new Error("VALIDATION_ERROR: Role field is required");
11089
11091
  if (Re(i.permissions.Enabled))
@@ -11091,7 +11093,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11091
11093
  }
11092
11094
  }
11093
11095
  if (!s?.providedTransaction) {
11094
- const Zt = v.filter((we) => "unique" in we && we.unique).map(async (we) => {
11096
+ const dt = v.filter((we) => "unique" in we && we.unique).map(async (we) => {
11095
11097
  if (!r || !we.access || we.access.includes(E.Role)) {
11096
11098
  if (h[we.name] === void 0 || Re(h[we.name]))
11097
11099
  return;
@@ -11112,17 +11114,17 @@ const Fo = async (n, e, t, s, r, i, o) => {
11112
11114
  throw new Error(`VALIDATION_ERROR: ${we.name} "${h[we.name]}" is invalid`);
11113
11115
  }
11114
11116
  });
11115
- await Promise.all(Zt);
11117
+ await Promise.all(dt);
11116
11118
  }
11117
11119
  if (r && E?.Role) {
11118
- const Oe = E.Role, Zt = { ..._, ...h };
11119
- if (!(w.custom?.serverAccess?.update !== void 0 ? await ie(w.custom.serverAccess.update, [Oe, Zt, _]) : !0))
11120
+ const Oe = E.Role, dt = { ..._, ...h };
11121
+ if (!(w.custom?.serverAccess?.update !== void 0 ? await ie(w.custom.serverAccess.update, [Oe, dt, _]) : !0))
11120
11122
  throw new Error("PERMISSION_DENIED");
11121
11123
  for (const zt of f.fields) {
11122
11124
  const fn = Ae(zt, w);
11123
11125
  if (Object.prototype.hasOwnProperty.call(h, zt.name) && fn?.custom?.serverAccess?.update !== void 0 && !await ie(fn.custom.serverAccess.update, [
11124
11126
  Oe,
11125
- Zt,
11127
+ dt,
11126
11128
  _
11127
11129
  ]))
11128
11130
  throw new Error("PERMISSION_DENIED");
@@ -11142,7 +11144,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11142
11144
  let Ve;
11143
11145
  !s?.noTwoWay && !s?.providedTransaction && (Ve = await Lo("Update", a, e, ve, h, f, c, x, B, r, E, _));
11144
11146
  const ze = Us(c);
11145
- Qs("update", x, n, e, h, c, f, s, ze, fe.arrayUnion, fe.arrayRemove, fe.delete, (me) => I.collection("tenants").doc(a).collection("system_fields").doc(g.collection).collection(`${g.collection}-${me.name}`).doc(e), (me, qe) => I.collection("tenants").doc(a).collection("system_unique").doc(g.collection).collection(`Unique-${g.collection}-${me.name}`).doc(qe), (me) => I.collection("tenants").doc(a).collection("system_fields").doc(g.collection).collection(`${g.collection}-${me}`).doc(e), (me, qe) => Ce(I, me, a).doc(qe), (me, qe, Oe) => I.collection("tenants").doc(a).collection("system_fields").doc(me.collection).collection(`${me.collection}-${qe}`).doc(Oe), (me, qe, Oe) => I.collection("tenants").doc(a).collection("system_fields").doc(me.collection).collection(`${me.collection}-${qe.replaceAll(" ", "-")}`).doc(Oe), _, Ve, B), x.update(C.doc(e), h);
11147
+ Qs("update", x, n, e, h, c, f, s, ze, he.arrayUnion, he.arrayRemove, he.delete, (me) => I.collection("tenants").doc(a).collection("system_fields").doc(g.collection).collection(`${g.collection}-${me.name}`).doc(e), (me, qe) => I.collection("tenants").doc(a).collection("system_unique").doc(g.collection).collection(`Unique-${g.collection}-${me.name}`).doc(qe), (me) => I.collection("tenants").doc(a).collection("system_fields").doc(g.collection).collection(`${g.collection}-${me}`).doc(e), (me, qe) => Ce(I, me, a).doc(qe), (me, qe, Oe) => I.collection("tenants").doc(a).collection("system_fields").doc(me.collection).collection(`${me.collection}-${qe}`).doc(Oe), (me, qe, Oe) => I.collection("tenants").doc(a).collection("system_fields").doc(me.collection).collection(`${me.collection}-${qe.replaceAll(" ", "-")}`).doc(Oe), _, Ve, B), x.update(C.doc(e), h);
11146
11148
  } catch (B) {
11147
11149
  if (s?.providedTransaction)
11148
11150
  throw B;
@@ -11153,12 +11155,12 @@ const Fo = async (n, e, t, s, r, i, o) => {
11153
11155
  recordId: e,
11154
11156
  context: o,
11155
11157
  error: B,
11156
- originalRecord: he(_)
11158
+ originalRecord: fe(_)
11157
11159
  }, Ve = await oe("postWriteError", l, w, ve);
11158
11160
  if (y && (await new Promise((ze) => {
11159
11161
  setTimeout(ze, 250);
11160
- }), await Pt("update", Ve?.resolved ? "success" : "failed", h, a, n, e, f, Ve?.resolved ? void 0 : B, _)), !Ve?.resolved)
11161
- throw p && await dn(_), j(_) && await Kt(_.User_ID, Q, N, "USER_ERROR"), $ && await I.collection("tenants").doc(a).collection(g.collection).doc(e).update({ User_ID: fe.delete() }), B;
11162
+ }), await Lt("update", Ve?.resolved ? "success" : "failed", h, a, n, e, f, Ve?.resolved ? void 0 : B, _)), !Ve?.resolved)
11163
+ throw p && await dn(_), j(_) && await Kt(_.User_ID, Q, N, "USER_ERROR"), $ && await I.collection("tenants").doc(a).collection(g.collection).doc(e).update({ User_ID: he.delete() }), B;
11162
11164
  }
11163
11165
  }
11164
11166
  (p || j(_) || $) && await Qr(ti, [e, _.User_ID]).catch(() => {
@@ -11177,7 +11179,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11177
11179
  const Q = { ..._, ...h };
11178
11180
  it(Q);
11179
11181
  const B = await Hc(i?.operation || "update", a, e, l, f, Q, _, x, i?.permissions, N, i?.password);
11180
- p && (h.User_ID = B), $ && (h.User_ID = fe.delete());
11182
+ p && (h.User_ID = B), $ && (h.User_ID = he.delete());
11181
11183
  }
11182
11184
  s?.providedTransaction ? await F(s.providedTransaction, x) : await I.runTransaction(async (Q) => {
11183
11185
  await F(Q, x);
@@ -11193,7 +11195,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11193
11195
  data: h,
11194
11196
  recordId: e,
11195
11197
  context: o,
11196
- originalRecord: he(_)
11198
+ originalRecord: fe(_)
11197
11199
  }, Q = { ...x };
11198
11200
  await oe("postWrite", l, w, x), await oe("postOperation", l, w, Q);
11199
11201
  }
@@ -11202,7 +11204,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11202
11204
  }, _u = async (n, e, t) => {
11203
11205
  const s = t?.userId;
11204
11206
  let r = t?.context;
11205
- const i = Xe(), o = jt();
11207
+ const i = Xe(), o = Zt();
11206
11208
  let a = await Ke();
11207
11209
  if (n.length === 0)
11208
11210
  throw new Error("EMPTY_PATH");
@@ -11211,16 +11213,16 @@ const Fo = async (n, e, t, s, r, i, o) => {
11211
11213
  throw new Error("COLLECTION_NOT_FOUND");
11212
11214
  const m = a.collections[l], { labels: u, auth: f, enableWriteLog: g, softDelete: v } = m, y = et(u.collection, a), w = await ie(o.appName);
11213
11215
  if (v && !f && !t?.force)
11214
- return await Yc(n, e, { [v.archivedField]: !0, [v.timestampField]: fe.serverTimestamp() }, { userId: s });
11216
+ return await Yc(n, e, { [v.archivedField]: !0, [v.timestampField]: he.serverTimestamp() }, { userId: s });
11215
11217
  const R = ce();
11216
11218
  let O;
11217
11219
  s && await tr(n, m);
11218
11220
  const I = Ce(R, n, i);
11219
11221
  r = r || {}, r.collection = u.collection;
11220
11222
  const E = await Ye(n, e, { userId: s });
11221
- let C = Ws("delete", n, E, a, w, "Online", s || "System", ut.now(), fe.serverTimestamp());
11223
+ let C = Ws("delete", n, E, a, w, "Online", s || "System", ut.now(), he.serverTimestamp());
11222
11224
  const _ = Rn(C);
11223
- Ue(C), g && await Pt("delete", "started", C, i, n, e, m), await oe("preOperation", o, y, { operation: "delete", data: C, recordId: e, context: r }), await oe("preWrite", o, y, { operation: "delete", data: C, recordId: e, context: r }), Ue(C);
11225
+ Ue(C), g && await Lt("delete", "started", C, i, n, e, m), await oe("preOperation", o, y, { operation: "delete", data: C, recordId: e, context: r }), await oe("preWrite", o, y, { operation: "delete", data: C, recordId: e, context: r }), Ue(C);
11224
11226
  const p = async (h) => {
11225
11227
  const [S, b, T, N] = await Promise.all([
11226
11228
  h.get(R.collection("system_deployment").doc("maintenance_mode")),
@@ -11256,7 +11258,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11256
11258
  await R.runTransaction(async (h) => {
11257
11259
  await p(h);
11258
11260
  const S = Us(a);
11259
- Qs("delete", h, n, e, C, a, m, t, S, fe.arrayUnion, fe.arrayRemove, fe.delete, (b) => R.collection("tenants").doc(i).collection("system_fields").doc(u.collection).collection(`${u.collection}-${b.name}`).doc(e), (b, T) => R.collection("tenants").doc(i).collection("system_unique").doc(u.collection).collection(`Unique-${u.collection}-${b.name}`).doc(T), (b) => R.collection("tenants").doc(i).collection("system_fields").doc(u.collection).collection(`${u.collection}-${b}`).doc(e), (b, T) => Ce(R, b, i).doc(T), (b, T, N) => R.collection("tenants").doc(i).collection("system_fields").doc(b.collection).collection(`${b.collection}-${T}`).doc(N), (b, T, N) => R.collection("tenants").doc(i).collection("system_fields").doc(b.collection).collection(`${b.collection}-${T.replaceAll(" ", "-")}`).doc(N)), h.delete(I.doc(e));
11261
+ Qs("delete", h, n, e, C, a, m, t, S, he.arrayUnion, he.arrayRemove, he.delete, (b) => R.collection("tenants").doc(i).collection("system_fields").doc(u.collection).collection(`${u.collection}-${b.name}`).doc(e), (b, T) => R.collection("tenants").doc(i).collection("system_unique").doc(u.collection).collection(`Unique-${u.collection}-${b.name}`).doc(T), (b) => R.collection("tenants").doc(i).collection("system_fields").doc(u.collection).collection(`${u.collection}-${b}`).doc(e), (b, T) => Ce(R, b, i).doc(T), (b, T, N) => R.collection("tenants").doc(i).collection("system_fields").doc(b.collection).collection(`${b.collection}-${T}`).doc(N), (b, T, N) => R.collection("tenants").doc(i).collection("system_fields").doc(b.collection).collection(`${b.collection}-${T.replaceAll(" ", "-")}`).doc(N)), h.delete(I.doc(e));
11260
11262
  }, { maxAttempts: 10 });
11261
11263
  } catch (h) {
11262
11264
  const b = await oe("postWriteError", o, y, {
@@ -11268,8 +11270,8 @@ const Fo = async (n, e, t, s, r, i, o) => {
11268
11270
  });
11269
11271
  if (g && (await new Promise((T) => {
11270
11272
  setTimeout(T, 250);
11271
- }), await Pt("delete", b?.resolved ? "success" : "failed", C, i, n, e, m, b?.resolved ? void 0 : h)), !b?.resolved)
11272
- throw m.auth && C.User_ID && await R.collection("tenants").doc(i).collection(u.collection).doc(e).update({ User_ID: fe.delete() }), h;
11273
+ }), await Lt("delete", b?.resolved ? "success" : "failed", C, i, n, e, m, b?.resolved ? void 0 : h)), !b?.resolved)
11274
+ throw m.auth && C.User_ID && await R.collection("tenants").doc(i).collection(u.collection).doc(e).update({ User_ID: he.delete() }), h;
11273
11275
  }
11274
11276
  const $ = { operation: "delete", data: C, recordId: e, context: r }, A = { ...$ };
11275
11277
  return await oe("postWrite", o, y, $), await oe("postOperation", o, y, A), { id: e, ...C };
@@ -11292,7 +11294,7 @@ const Fo = async (n, e, t, s, r, i, o) => {
11292
11294
  });
11293
11295
  };
11294
11296
  e(n);
11295
- }, Ou = async (n) => await _t().getUser(n), ku = (n) => {
11297
+ }, Ou = async (n) => await Et().getUser(n), ku = (n) => {
11296
11298
  const e = Ro();
11297
11299
  return L.fromJSDate(n).setZone(e);
11298
11300
  }, Qc = (n) => {
@@ -11324,7 +11326,7 @@ export {
11324
11326
  Vc as getCustomizationFiles,
11325
11327
  Io as getDocumentRefs,
11326
11328
  Ce as getFirestorePathRef,
11327
- jt as getGlobalConfigModule,
11329
+ Zt as getGlobalConfigModule,
11328
11330
  cu as getInputSchema,
11329
11331
  hu as getMaintenanceInfo,
11330
11332
  So as getMode,
@@ -11350,5 +11352,5 @@ export {
11350
11352
  Hc as updateUser,
11351
11353
  Lo as validateRelations,
11352
11354
  Uo as validateSoftDelete,
11353
- Pt as writeLog
11355
+ Lt as writeLog
11354
11356
  };