@stoker-platform/node-client 0.5.10 → 0.5.12

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
@@ -87,19 +87,19 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
87
87
  u?.filter((p) => p.type === "Individual").forEach(() => {
88
88
  d = !0, a.individualEntities?.includes(i.id) || (f = !1);
89
89
  });
90
- let m = !0, O = !1;
90
+ let m = !0, k = !1;
91
91
  if (u?.filter((p) => p.type === "Parent").forEach((p) => {
92
- O = !0;
92
+ k = !0;
93
93
  const T = W(o, p.collectionField);
94
94
  a.parentEntities?.some((C) => i[`${T.name}_Array`].includes(C)) || (m = !1);
95
95
  }), u?.filter((p) => p.type === "Parent_Property").forEach((p) => {
96
- O = !0;
96
+ k = !0;
97
97
  const T = W(o, p.collectionField), C = W(o, p.propertyField);
98
98
  Object.entries(a.parentPropertyEntities || {}).some((v) => {
99
99
  const [Z, x] = v;
100
100
  return Z === i[C.name] && i[`${T.name}_Array`].some((g) => x.includes(g));
101
101
  }) || (m = !1);
102
- }), d && O) {
102
+ }), d && k) {
103
103
  if (!(f || m)) {
104
104
  l = !1;
105
105
  return;
@@ -135,8 +135,8 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
135
135
  return;
136
136
  }
137
137
  Object.entries(x.parentPropertyEntities || {}).some((g) => {
138
- const [k, _] = g;
139
- return k === i[v.name] && i[`${Z.name}_Array`].some((A) => _.includes(A));
138
+ const [O, _] = g;
139
+ return O === i[v.name] && i[`${Z.name}_Array`].some((A) => _.includes(A));
140
140
  }) || (b = !1);
141
141
  }), w && N) {
142
142
  if (!(y || b)) {
@@ -298,11 +298,11 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
298
298
  }
299
299
  }), h?.assignable?.includes(t)))
300
300
  continue;
301
- let O = !1;
301
+ let k = !1;
302
302
  if (h?.restrictions?.forEach((y) => {
303
303
  for (const w of y.roles)
304
304
  if (w.role === t) {
305
- if (O = !0, y.type === "Individual" && !e.collections?.[o.collection]?.individualEntities) {
305
+ if (k = !0, y.type === "Individual" && !e.collections?.[o.collection]?.individualEntities) {
306
306
  r = `Collection ${o.collection} is missing individual entities`, s = !1;
307
307
  return;
308
308
  }
@@ -329,7 +329,7 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
329
329
  }
330
330
  }
331
331
  }
332
- }), O && !e.collections?.[o.collection]?.restrictEntities) {
332
+ }), k && !e.collections?.[o.collection]?.restrictEntities) {
333
333
  r = `Collection ${o.collection} must have restrictEntities set to true`, s = !1;
334
334
  return;
335
335
  }
@@ -341,19 +341,19 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
341
341
  const d = u?.filter((m) => s === m.userRole);
342
342
  return d?.length && !d.some((m) => m.recordRole === r) ? (f = `User ${s} does not have write access to record with role ${r}`, h = !1, h) : n === "update" && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
343
343
  o.User_ID && d?.length && !d.some((m) => m.recordRole === a) ? (f = `User ${s} does not have write access to record with role ${r}`, h = !1, h) : (u?.forEach((m) => {
344
- s === m.userRole && m.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((O) => {
345
- const y = i.collections?.[O], w = l?.collections?.[O];
344
+ s === m.userRole && m.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((k) => {
345
+ const y = i.collections?.[k], w = l?.collections?.[k];
346
346
  if (!(n === "update" && ze(y, w)) && y) {
347
- const b = m.collections.some((N) => N.collection === O);
347
+ const b = m.collections.some((N) => N.collection === k);
348
348
  if (b) {
349
349
  if (b) {
350
- const N = m.collections.find((T) => T.collection === O);
350
+ const N = m.collections.find((T) => T.collection === k);
351
351
  if (!(y.operations.every((T) => N.operations.includes(T)) || n === "update" && ze(y.operations, w?.operations))) {
352
- f = `User ${s} does not have write access to all included operations for collection ${O}`, h = !1;
352
+ f = `User ${s} does not have write access to all included operations for collection ${k}`, h = !1;
353
353
  return;
354
354
  }
355
355
  if (!N.auth && y.auth && !(n === "update" && ze(y.auth, w?.auth))) {
356
- f = `User ${s} does not have write access to auth for collection ${O}`, h = !1;
356
+ f = `User ${s} does not have write access to auth for collection ${k}`, h = !1;
357
357
  return;
358
358
  }
359
359
  const p = {
@@ -364,16 +364,16 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
364
364
  if (Object.keys(p).forEach((T) => {
365
365
  const C = p[T];
366
366
  if (N.attributeRestrictions?.includes(C) && !(y[T]?.active || n === "update" && ze(y[T], w?.[T]))) {
367
- f = `User ${s} does not have write access to attribute restriction ${T} for collection ${O}`, h = !1;
367
+ f = `User ${s} does not have write access to attribute restriction ${T} for collection ${k}`, h = !1;
368
368
  return;
369
369
  }
370
370
  }), N.restrictEntities && !y.restrictEntities && !(n === "update" && ze(y.restrictEntities, w?.restrictEntities))) {
371
- f = `User ${s} does not have write access to restrictEntities for collection ${O}`, h = !1;
371
+ f = `User ${s} does not have write access to restrictEntities for collection ${k}`, h = !1;
372
372
  return;
373
373
  }
374
374
  }
375
375
  } else {
376
- f = `User ${s} does not have write access to collection ${O}`, h = !1;
376
+ f = `User ${s} does not have write access to collection ${k}`, h = !1;
377
377
  return;
378
378
  }
379
379
  }
@@ -450,18 +450,18 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
450
450
  }, or = (n, e, t, s, r, i, o, a, l, c) => {
451
451
  const { labels: u, fields: h } = s, f = o?.collections?.[u.collection], d = { ...e, ...n };
452
452
  nt(d);
453
- let m = !0, O = "";
453
+ let m = !0, k = "";
454
454
  if (i && !f)
455
455
  throw new Error("PERMISSION_DENIED");
456
- i && !Te("Update", f) && (m = !1, O = "Authenticated user does not have Update access to this collection"), i && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
456
+ i && !Te("Update", f) && (m = !1, k = "Authenticated user does not have Update access to this collection"), i && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
457
457
  (!it("Update", s, r, i, o, e) || // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
458
- !it("Update", s, r, i, o, d)) && (m = !1, O = "Authenticated user does not have Update access to this document"), a && (i && !jn(f) && (m = !1, O = "Authenticated user does not have Auth access for this collection"), Vs("update", d, t, s, r, i, o, l, c, e, a) || (O = "Authenticated user does not have sufficient write access for this record", m = !1));
458
+ !it("Update", s, r, i, o, d)) && (m = !1, k = "Authenticated user does not have Update access to this document"), a && (i && !jn(f) && (m = !1, k = "Authenticated user does not have Auth access for this collection"), Vs("update", d, t, s, r, i, o, l, c, e, a) || (k = "Authenticated user does not have sufficient write access for this record", m = !1));
459
459
  for (const y of h) {
460
460
  const w = n[y.name];
461
- y.access && !Zn(y, o) && w !== void 0 && (O = `Authenticated user does not have access to field ${y.name}`, m = !1), w !== void 0 && !ai(y, o) && (O = `Authenticated user does not have Update access to field ${y.name}`, m = !1);
461
+ y.access && !Zn(y, o) && w !== void 0 && (k = `Authenticated user does not have access to field ${y.name}`, m = !1), w !== void 0 && !ai(y, o) && (k = `Authenticated user does not have Update access to field ${y.name}`, m = !1);
462
462
  }
463
463
  if (!m)
464
- throw O && console.error(`PERMISSION_DENIED: ${O}`), new Error("PERMISSION_DENIED");
464
+ throw k && console.error(`PERMISSION_DENIED: ${k}`), new Error("PERMISSION_DENIED");
465
465
  }, Qo = (n, e, t, s, r, i) => {
466
466
  const { labels: o } = t, a = i.collections?.[o.collection];
467
467
  let l = !0;
@@ -5368,8 +5368,8 @@ class _e {
5368
5368
  const d = r(f);
5369
5369
  if (d) {
5370
5370
  const m = h.isNegativeDuration && d !== h.largestUnit ? s : 1;
5371
- let O;
5372
- return this.opts.signMode === "negativeLargestOnly" && d !== h.largestUnit ? O = "never" : this.opts.signMode === "all" ? O = "always" : O = "auto", this.num(u.get(d) * m, f.length, O);
5371
+ let k;
5372
+ return this.opts.signMode === "negativeLargestOnly" && d !== h.largestUnit ? k = "never" : this.opts.signMode === "all" ? k = "always" : k = "auto", this.num(u.get(d) * m, f.length, k);
5373
5373
  } else
5374
5374
  return f;
5375
5375
  }, o = _e.parseFormat(t), a = o.reduce(
@@ -6994,7 +6994,7 @@ function _c(n) {
6994
6994
  return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
6995
6995
  }
6996
6996
  function Ec(n, e) {
6997
- const t = Ce(e), s = Ce(e, "{2}"), r = Ce(e, "{3}"), i = Ce(e, "{4}"), o = Ce(e, "{6}"), a = Ce(e, "{1,2}"), l = Ce(e, "{1,3}"), c = Ce(e, "{1,6}"), u = Ce(e, "{1,9}"), h = Ce(e, "{2,4}"), f = Ce(e, "{4,6}"), d = (y) => ({ regex: RegExp(_c(y.val)), deser: ([w]) => w, literal: !0 }), O = ((y) => {
6997
+ const t = Ce(e), s = Ce(e, "{2}"), r = Ce(e, "{3}"), i = Ce(e, "{4}"), o = Ce(e, "{6}"), a = Ce(e, "{1,2}"), l = Ce(e, "{1,3}"), c = Ce(e, "{1,6}"), u = Ce(e, "{1,9}"), h = Ce(e, "{2,4}"), f = Ce(e, "{4,6}"), d = (y) => ({ regex: RegExp(_c(y.val)), deser: ([w]) => w, literal: !0 }), k = ((y) => {
6998
6998
  if (n.literal)
6999
6999
  return d(y);
7000
7000
  switch (y.val) {
@@ -7117,7 +7117,7 @@ function Ec(n, e) {
7117
7117
  })(n) || {
7118
7118
  invalidReason: yc
7119
7119
  };
7120
- return O.token = n, O;
7120
+ return k.token = n, k;
7121
7121
  }
7122
7122
  const vc = {
7123
7123
  year: {
@@ -7723,18 +7723,18 @@ class V {
7723
7723
  );
7724
7724
  if (f && u)
7725
7725
  throw new St("Can't mix ordinal dates with month/day");
7726
- const O = m || i.weekday && !d;
7726
+ const k = m || i.weekday && !d;
7727
7727
  let y, w, b = pn(l, c);
7728
- O ? (y = Dc, w = xc, b = Pn(b, o, a)) : u ? (y = Ac, w = Ic, b = as(b)) : (y = En, w = vo);
7728
+ k ? (y = Dc, w = xc, b = Pn(b, o, a)) : u ? (y = Ac, w = Ic, b = as(b)) : (y = En, w = vo);
7729
7729
  let N = !1;
7730
7730
  for (const g of y) {
7731
- const k = i[g];
7732
- H(k) ? N ? i[g] = w[g] : i[g] = b[g] : N = !0;
7731
+ const O = i[g];
7732
+ H(O) ? N ? i[g] = w[g] : i[g] = b[g] : N = !0;
7733
7733
  }
7734
- const p = O ? ll(i, o, a) : u ? cl(i) : Bi(i), T = p || Hi(i);
7734
+ const p = k ? ll(i, o, a) : u ? cl(i) : Bi(i), T = p || Hi(i);
7735
7735
  if (T)
7736
7736
  return V.invalid(T);
7737
- const C = O ? Ir(i, o, a) : u ? Dr(i) : i, [v, Z] = _n(C, c, s), x = new V({
7737
+ const C = k ? Ir(i, o, a) : u ? Dr(i) : i, [v, Z] = _n(C, c, s), x = new V({
7738
7738
  ts: v,
7739
7739
  zone: s,
7740
7740
  o: Z,
@@ -9242,7 +9242,7 @@ const $c = (n, e) => {
9242
9242
  for (const a of s.fields)
9243
9243
  await Jr(a.custom?.preValidate, r);
9244
9244
  return Ma(n, t, i).parse(e), e;
9245
- }, Qs = (n, e, t, s, r, i, o, a, l, c, u, h, f, d, m, O, y, w, b, N, p) => {
9245
+ }, Qs = (n, e, t, s, r, i, o, a, l, c, u, h, f, d, m, k, y, w, b, N, p) => {
9246
9246
  const { fields: T } = o;
9247
9247
  T.filter((g) => "unique" in g && g.unique).forEach((g) => {
9248
9248
  n !== "delete" && (typeof r[g.name] == "string" || typeof r[g.name] == "number") && (e.set(d(g, r[g.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||")), {
@@ -9251,39 +9251,39 @@ const $c = (n, e) => {
9251
9251
  }), p && p.size++);
9252
9252
  }), T.forEach((g) => {
9253
9253
  if (ct(g, o, i)) {
9254
- const k = dn(g, o, i), _ = {};
9255
- r[g.name] !== void 0 && (_[g.name] = r[g.name], K(g) && (_[`${g.name}_Array`] = r[`${g.name}_Array`])), k.forEach((A) => {
9254
+ const O = dn(g, o, i), _ = {};
9255
+ r[g.name] !== void 0 && (_[g.name] = r[g.name], K(g) && (_[`${g.name}_Array`] = r[`${g.name}_Array`])), O.forEach((A) => {
9256
9256
  r[A.name] !== void 0 && (K(A) ? _[`${A.name}_Array`] = r[`${A.name}_Array`] : _[A.name] = r[A.name]);
9257
9257
  }), Object.keys(_).length > 0 && (n === "create" && (_.Collection_Path = t, _.Collection_Path_String = t.join("/"), e.set(f(g), _)), n === "update" && e.update(f(g), _), n === "delete" && e.delete(f(g)), p && p.size++);
9258
9258
  }
9259
9259
  });
9260
9260
  const C = l[o.labels.collection];
9261
9261
  for (const g of C) {
9262
- const k = ia(g, o), _ = { ...r };
9263
- k.forEach((A) => {
9262
+ const O = ia(g, o), _ = { ...r };
9263
+ O.forEach((A) => {
9264
9264
  delete _[A.name], delete _[`${A.name}_Array`], delete _[`${A.name}_Single`], delete _[`${A.name}_Lowercase`];
9265
9265
  }), Object.keys(_).length > 0 && (n === "create" && (_.Collection_Path ||= t, _.Collection_Path_String = t.join("/"), e.set(m(g.key), _)), n === "update" && e.update(m(g.key), _), n === "delete" && e.delete(m(g.key)), p && p.size++);
9266
9266
  }
9267
- const v = (g, k) => {
9267
+ const v = (g, O) => {
9268
9268
  let _ = 1;
9269
- ct(k, g, i) && _++, g.fields.forEach((E) => {
9270
- ct(E, g, i) && JSON.parse(es(dn(E, g, i))).includes(k.name) && _++;
9269
+ ct(O, g, i) && _++, g.fields.forEach((E) => {
9270
+ ct(E, g, i) && JSON.parse(es(dn(E, g, i))).includes(O.name) && _++;
9271
9271
  });
9272
9272
  const A = l[g.labels.collection];
9273
9273
  for (const E of A)
9274
- E.fields.some((D) => D.name === k.name) && K(k) && _++;
9274
+ E.fields.some((D) => D.name === O.name) && K(O) && _++;
9275
9275
  return _;
9276
- }, Z = (g, k, _, A, E) => {
9276
+ }, Z = (g, O, _, A, E) => {
9277
9277
  const D = {};
9278
- D[`${_.name}.${s}`] = h(), D[`${_.name}_Array`] = u(s), D[`${_.name}_Single`] = h(), e.update(O(E, A), D), ct(_, k, i) && e.update(y(g, _.name, A), {
9278
+ D[`${_.name}.${s}`] = h(), D[`${_.name}_Array`] = u(s), D[`${_.name}_Single`] = h(), e.update(k(E, A), D), ct(_, O, i) && e.update(y(g, _.name, A), {
9279
9279
  [`${_.name}.${s}`]: h(),
9280
9280
  [`${_.name}_Array`]: u(s)
9281
- }), k.fields.forEach((F) => {
9282
- ct(F, k, i) && JSON.parse(es(dn(F, k, i))).includes(_.name) && e.update(y(g, F.name, A), {
9281
+ }), O.fields.forEach((F) => {
9282
+ ct(F, O, i) && JSON.parse(es(dn(F, O, i))).includes(_.name) && e.update(y(g, F.name, A), {
9283
9283
  [`${_.name}_Array`]: u(s)
9284
9284
  });
9285
9285
  });
9286
- const R = l[k.labels.collection];
9286
+ const R = l[O.labels.collection];
9287
9287
  for (const F of R)
9288
9288
  F.fields.some((M) => M.name === _.name) && K(_) && e.update(w(g, F.key, A), D);
9289
9289
  };
@@ -9294,7 +9294,7 @@ const $c = (n, e) => {
9294
9294
  for (const g of x) {
9295
9295
  if (!p)
9296
9296
  throw new Error("VALIDATION_ERROR: batchSize is required");
9297
- const k = i.collections[g.collection], _ = W(k.fields, g.twoWay), A = ft(k, k.fields), E = Array.from(A).map((D) => D.name);
9297
+ const O = i.collections[g.collection], _ = W(O.fields, g.twoWay), A = ft(O, O.fields), E = Array.from(A).map((D) => D.name);
9298
9298
  if (!_)
9299
9299
  throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
9300
9300
  if (K(_)) {
@@ -9324,24 +9324,24 @@ const $c = (n, e) => {
9324
9324
  ...M
9325
9325
  });
9326
9326
  const j = Sn(r);
9327
- e.update(O(R.Collection_Path, D), {
9327
+ e.update(k(R.Collection_Path, D), {
9328
9328
  ...P,
9329
9329
  ...j
9330
- }), p.size++, ct(_, k, i) && (e.update(y(g, _.name, D), {
9330
+ }), p.size++, ct(_, O, i) && (e.update(y(g, _.name, D), {
9331
9331
  [`${_.name}.${s}`]: {
9332
9332
  Collection_Path: t,
9333
9333
  ...M
9334
9334
  },
9335
9335
  [`${_.name}_Array`]: c(s)
9336
- }), p.size++), k.fields.forEach((S) => {
9337
- if (ct(S, k, i)) {
9338
- const q = JSON.parse(es(dn(S, k, i))), B = {};
9336
+ }), p.size++), O.fields.forEach((S) => {
9337
+ if (ct(S, O, i)) {
9338
+ const q = JSON.parse(es(dn(S, O, i))), B = {};
9339
9339
  q.includes(_.name) && (B[`${g.twoWay}_Array`] = c(s)), Object.keys(j).forEach((re) => {
9340
9340
  q.includes(re) && (B[re] = j[re]);
9341
9341
  }), Object.keys(B).length > 0 && (e.update(y(g, S.name, D), B), p.size++);
9342
9342
  }
9343
9343
  });
9344
- const Q = l[k.labels.collection];
9344
+ const Q = l[O.labels.collection];
9345
9345
  for (const S of Q)
9346
9346
  if (S.fields.some((q) => q.name === _.name)) {
9347
9347
  const q = { ...P };
@@ -9353,30 +9353,30 @@ const $c = (n, e) => {
9353
9353
  } else
9354
9354
  throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9355
9355
  }
9356
- p && p.size > 500 && console.error(new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, roles, dependencies on the collection, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks."));
9356
+ p && p.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${p.size} operations in the Firestore transaction has exceeded the recommended limit of 500. This is likely due to a large number of two way updates, roles, dependencies on the collection, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
9357
9357
  for (const g of x) {
9358
9358
  if (!p)
9359
9359
  throw new Error("VALIDATION_ERROR: batchSize is required");
9360
- const k = i.collections[g.collection], _ = W(k.fields, g.twoWay);
9360
+ const O = i.collections[g.collection], _ = W(O.fields, g.twoWay);
9361
9361
  if (!_)
9362
9362
  throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
9363
9363
  if (K(_)) {
9364
9364
  if (n === "update" && b && !(r[g.name] && Me(r[g.name])) && r[`${g.name}_Array`] && b[`${g.name}_Array`]?.length > 0)
9365
9365
  for (const [A, E] of Object.entries(b[g.name]))
9366
- !r[`${g.name}_Array`].includes(A) && !N?.get(g.name)?.includes(A) && (p.size += v(k, _), p.size <= 500 && Z(g, k, _, A, E.Collection_Path));
9366
+ !r[`${g.name}_Array`].includes(A) && !N?.get(g.name)?.includes(A) && (p.size += v(O, _), p.size <= 500 && Z(g, O, _, A, E.Collection_Path));
9367
9367
  } else
9368
9368
  throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9369
9369
  }
9370
9370
  for (const g of x) {
9371
9371
  if (!p)
9372
9372
  throw new Error("VALIDATION_ERROR: batchSize is required");
9373
- const k = i.collections[g.collection], _ = W(k.fields, g.twoWay);
9373
+ const O = i.collections[g.collection], _ = W(O.fields, g.twoWay);
9374
9374
  if (!_)
9375
9375
  throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
9376
9376
  if (K(_)) {
9377
9377
  if (n === "update" && b && r[g.name] && Me(r[g.name]) && b[`${g.name}_Array`]?.length > 0)
9378
9378
  for (const [A, E] of Object.entries(b[g.name]))
9379
- N?.get(g.name)?.includes(A) || (p.size += v(k, _), p.size <= 500 && Z(g, k, _, A, E.Collection_Path));
9379
+ N?.get(g.name)?.includes(A) || (p.size += v(O, _), p.size <= 500 && Z(g, O, _, A, E.Collection_Path));
9380
9380
  } else
9381
9381
  throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9382
9382
  }
@@ -9568,7 +9568,7 @@ const Tt = {
9568
9568
  const d = r.collections?.[l.collection];
9569
9569
  if (!r.Role)
9570
9570
  throw new Error("PERMISSION_DENIED");
9571
- const m = d && Te("Read", d), O = ui(a, t, r), y = li(a, r), w = Ls(a, r), b = ci(a, t, r), N = (E = []) => {
9571
+ const m = d && Te("Read", d), k = ui(a, t, r), y = li(a, r), w = Ls(a, r), b = ci(a, t, r), N = (E = []) => {
9572
9572
  const D = [], R = pi(r.Role, a, t);
9573
9573
  if (!R)
9574
9574
  throw new Error("PERMISSION_DENIED");
@@ -9577,8 +9577,8 @@ const Tt = {
9577
9577
  E.forEach((M) => {
9578
9578
  F = F.where(...M);
9579
9579
  }), D.push(F);
9580
- } else if (O)
9581
- for (const F of O) {
9580
+ } else if (k)
9581
+ for (const F of k) {
9582
9582
  let M = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${F.field}`).where("Collection_Path_String", "==", e.join("/"));
9583
9583
  E.forEach((P) => {
9584
9584
  M = M.where(...P);
@@ -9666,7 +9666,7 @@ const Tt = {
9666
9666
  }
9667
9667
  }
9668
9668
  });
9669
- const k = [];
9669
+ const O = [];
9670
9670
  w.filter((E) => E.type === "Parent").forEach((E) => {
9671
9671
  if ("collectionField" in E) {
9672
9672
  const D = W(c, E.collectionField);
@@ -9680,7 +9680,7 @@ const Tt = {
9680
9680
  }
9681
9681
  if (!E.singleQuery)
9682
9682
  F.forEach((P) => {
9683
- k.push(...N(x.concat([[`${D.name}_Array`, "array-contains-any", P]])));
9683
+ O.push(...N(x.concat([[`${D.name}_Array`, "array-contains-any", P]])));
9684
9684
  });
9685
9685
  else {
9686
9686
  if (R && R.length > M)
@@ -9707,7 +9707,7 @@ const Tt = {
9707
9707
  }
9708
9708
  if (!R.singleQuery)
9709
9709
  Q.forEach((q) => {
9710
- k.push(...N(x.concat([
9710
+ O.push(...N(x.concat([
9711
9711
  [`${M.name}_Array`, "array-contains-any", q]
9712
9712
  ])));
9713
9713
  });
@@ -9725,7 +9725,7 @@ const Tt = {
9725
9725
  }
9726
9726
  });
9727
9727
  const _ = [];
9728
- k.length === 0 && (w.filter((E) => E.type === "Parent_Property").forEach((E) => {
9728
+ O.length === 0 && (w.filter((E) => E.type === "Parent_Property").forEach((E) => {
9729
9729
  if ("collectionField" in E && "propertyField" in E) {
9730
9730
  const D = W(c, E.collectionField), R = W(c, E.propertyField);
9731
9731
  if ("collection" in D) {
@@ -9778,7 +9778,7 @@ const Tt = {
9778
9778
  }
9779
9779
  }
9780
9780
  }));
9781
- const A = [...g, ...k, ..._];
9781
+ const A = [...g, ...O, ..._];
9782
9782
  return !w.length && !b.length ? N(x) : A;
9783
9783
  } else
9784
9784
  throw new Error("PERMISSION_DENIED");
@@ -9798,8 +9798,8 @@ const Tt = {
9798
9798
  if (h)
9799
9799
  d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${m.key}`).doc(t));
9800
9800
  else if (f)
9801
- for (const O of f)
9802
- d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${O.field}`).doc(t));
9801
+ for (const k of f)
9802
+ d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${k.field}`).doc(t));
9803
9803
  return d;
9804
9804
  } else
9805
9805
  return [c.doc(t)];
@@ -9810,7 +9810,7 @@ const Tt = {
9810
9810
  throw new Error(`SCHEMA_ERROR: Collection ${m} not found in subcollections of ${u}`);
9811
9811
  }) : s.collections = h;
9812
9812
  const f = s.depth - 1, d = s.collections.map(async (m) => {
9813
- const O = await Io([...t, m], s.constraints, {
9813
+ const k = await Io([...t, m], s.constraints, {
9814
9814
  user: a,
9815
9815
  pagination: s.limit,
9816
9816
  providedTransaction: l,
@@ -9818,7 +9818,7 @@ const Tt = {
9818
9818
  }).catch((y) => {
9819
9819
  throw y.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${m} for document at ${t.join("/")}`), y;
9820
9820
  });
9821
- e[m] = O.docs, i && await Promise.all(
9821
+ e[m] = k.docs, i && await Promise.all(
9822
9822
  // eslint-disable-next-line security/detect-object-injection
9823
9823
  e[m].map((y) => Xs(n, y, [...t, m, y.id], i, r, void 0, a, l, c))
9824
9824
  ), f > 0 && await Promise.all(
@@ -9837,18 +9837,18 @@ const Tt = {
9837
9837
  if (!d)
9838
9838
  continue;
9839
9839
  const m = Object.keys(d);
9840
- for (const O of m) {
9841
- const y = d[O], w = at(y.Collection_Path, O, {
9840
+ for (const k of m) {
9841
+ const y = d[k], w = at(y.Collection_Path, k, {
9842
9842
  user: o,
9843
9843
  providedTransaction: a,
9844
9844
  noEmbeddingFields: l
9845
9845
  }).then((b) => {
9846
- if (d[O] = b, u > 0)
9846
+ if (d[k] = b, u > 0)
9847
9847
  return Xs(
9848
9848
  n,
9849
9849
  // eslint-disable-next-line security/detect-object-injection
9850
- d[O],
9851
- [...y.Collection_Path, O],
9850
+ d[k],
9851
+ [...y.Collection_Path, k],
9852
9852
  { depth: u },
9853
9853
  r,
9854
9854
  i,
@@ -9858,7 +9858,7 @@ const Tt = {
9858
9858
  );
9859
9859
  }).catch((b) => {
9860
9860
  if (b.message.includes("NOT_FOUND") || b.code === "permission-denied")
9861
- delete d[O];
9861
+ delete d[k];
9862
9862
  else
9863
9863
  throw b;
9864
9864
  });
@@ -9889,7 +9889,7 @@ const Tt = {
9889
9889
  if (h.data().active)
9890
9890
  throw new Error("MAINTENANCE_MODE");
9891
9891
  const m = f;
9892
- let O;
9892
+ let k;
9893
9893
  const y = Ut(), w = n.at(-1);
9894
9894
  if (!w)
9895
9895
  throw new Error("EMPTY_PATH");
@@ -9900,12 +9900,12 @@ const Tt = {
9900
9900
  if (t?.user) {
9901
9901
  if (!u?.exists)
9902
9902
  throw new Error("PERMISSION_DENIED");
9903
- if (O = u.data(), !O.Role)
9903
+ if (k = u.data(), !k.Role)
9904
9904
  throw new Error("USER_ERROR");
9905
- if (!O.Enabled)
9905
+ if (!k.Enabled)
9906
9906
  throw new Error("PERMISSION_DENIED");
9907
9907
  }
9908
- let v = Vc(s, n, m, t?.user, O);
9908
+ let v = Vc(s, n, m, t?.user, k);
9909
9909
  if (v.length === 0)
9910
9910
  return { cursor: {}, pages: 0, docs: [] };
9911
9911
  if (e && (v = v.map((A) => (e.forEach(([E, D, R]) => {
@@ -9918,7 +9918,7 @@ const Tt = {
9918
9918
  throw new Error("INPUT_ERROR: startAfter and endBefore cannot be provided together");
9919
9919
  const A = t.pagination.startAfter || t.pagination.endBefore;
9920
9920
  if (t?.user) {
9921
- const E = ta(O.Role, p, m);
9921
+ const E = ta(k.Role, p, m);
9922
9922
  if (A && E !== !0)
9923
9923
  throw new Error("INPUT_ERROR: Pagination is not allowed when using " + E);
9924
9924
  }
@@ -9926,7 +9926,7 @@ const Tt = {
9926
9926
  }
9927
9927
  const Z = {};
9928
9928
  await ae("preOperation", y, C, ["read", void 0, void 0, Z]), await ae("preRead", y, C, [Z, v, !0, !1]), a = /* @__PURE__ */ new Map();
9929
- const k = v.map(async (A) => await c.get(A)), _ = await Promise.all(k);
9929
+ const O = v.map(async (A) => await c.get(A)), _ = await Promise.all(O);
9930
9930
  for (const A of _) {
9931
9931
  for (const E of A.docs) {
9932
9932
  a.has(E.id) || a.set(E.id, {});
@@ -9987,8 +9987,8 @@ const Tt = {
9987
9987
  }
9988
9988
  t?.noEmbeddingFields && P.type === "Embedding" && delete M[P.name];
9989
9989
  }
9990
- if (t?.user && O?.Role) {
9991
- const M = O.Role;
9990
+ if (t?.user && k?.Role) {
9991
+ const M = k.Role;
9992
9992
  if (!(C.custom?.serverAccess?.read !== void 0 ? await ie(C.custom.serverAccess.read, [M, A]) : !0)) {
9993
9993
  a.delete(A.id);
9994
9994
  continue;
@@ -10001,7 +10001,7 @@ const Tt = {
10001
10001
  const R = ["read", A, A.id, Z];
10002
10002
  await ae("postOperation", y, C, R), await ae("postRead", y, C, [Z, v, A, !1]);
10003
10003
  }
10004
- t?.user && await Xo(Array.from(a.values()), p, m, t.user, O);
10004
+ t?.user && await Xo(Array.from(a.values()), p, m, t.user, k);
10005
10005
  };
10006
10006
  return t?.providedTransaction ? await l(t.providedTransaction) : await r.runTransaction(async (c) => {
10007
10007
  await l(c);
@@ -10038,8 +10038,8 @@ const Tt = {
10038
10038
  const d = t[f.name];
10039
10039
  if (!d)
10040
10040
  continue;
10041
- for (const [m, O] of Object.entries(d)) {
10042
- const y = at(O.Collection_Path, m, {
10041
+ for (const [m, k] of Object.entries(d)) {
10042
+ const y = at(k.Collection_Path, m, {
10043
10043
  user: o,
10044
10044
  providedTransaction: e,
10045
10045
  noComputedFields: a,
@@ -10051,7 +10051,7 @@ const Tt = {
10051
10051
  e,
10052
10052
  // eslint-disable-next-line security/detect-object-injection
10053
10053
  d[m],
10054
- [...O.Collection_Path, m],
10054
+ [...k.Collection_Path, m],
10055
10055
  r,
10056
10056
  { depth: u },
10057
10057
  o,
@@ -10087,13 +10087,13 @@ const Tt = {
10087
10087
  throw new Error("MAINTENANCE_MODE");
10088
10088
  const f = u;
10089
10089
  let d;
10090
- const m = Ut(), O = n.at(-1);
10091
- if (!O)
10090
+ const m = Ut(), k = n.at(-1);
10091
+ if (!k)
10092
10092
  throw new Error("EMPTY_PATH");
10093
- const y = Object.keys(f.collections).includes(O), w = m.disabledCollections?.includes(O);
10093
+ const y = Object.keys(f.collections).includes(k), w = m.disabledCollections?.includes(k);
10094
10094
  if (!y || w)
10095
10095
  throw new Error("COLLECTION_NOT_FOUND");
10096
- const b = f.collections[O], { labels: N } = b, p = Je(N.collection, f);
10096
+ const b = f.collections[k], { labels: N } = b, p = Je(N.collection, f);
10097
10097
  let T;
10098
10098
  if (t?.user) {
10099
10099
  if (!l?.exists)
@@ -10112,8 +10112,8 @@ const Tt = {
10112
10112
  throw new Error("PERMISSION_DENIED");
10113
10113
  const v = {};
10114
10114
  await ae("preOperation", m, p, ["read", void 0, e, v]), await ae("preRead", m, p, [v, C, !1, !1]), i = {};
10115
- const g = C.map((R) => a.get(R)), k = await Promise.all(g);
10116
- for (const R of k)
10115
+ const g = C.map((R) => a.get(R)), O = await Promise.all(g);
10116
+ for (const R of O)
10117
10117
  if (R.exists) {
10118
10118
  const F = R.data();
10119
10119
  i.id ||= R.id, i = { ...i, ...F }, delete i.Collection_Path_String;
@@ -10125,7 +10125,7 @@ const Tt = {
10125
10125
  const F = b.fields.find((M) => M.name === R);
10126
10126
  if (F)
10127
10127
  return F;
10128
- throw new Error(`SCHEMA_ERROR: Field ${R} not found in collection ${O}`);
10128
+ throw new Error(`SCHEMA_ERROR: Field ${R} not found in collection ${k}`);
10129
10129
  }
10130
10130
  return R;
10131
10131
  })), _.push(Ao(s, a, i, A, f, t.relations, t.user, t.noComputedFields, t.noEmbeddingFields))), await Promise.all(_), !t?.noComputedFields) {
@@ -10165,8 +10165,8 @@ const Tt = {
10165
10165
  if (!Ks(m))
10166
10166
  f.push(`${d.name} "${s[d.name]}" is invalid`);
10167
10167
  else {
10168
- const O = await l.collection("tenants").doc(e).collection("system_unique").doc(u).collection(`Unique-${u}-${d.name}`).doc(m).get();
10169
- O.exists && !(n === "update" && O.data().id === t) && f.push(`${d.name} "${s[d.name]}" already exists`);
10168
+ const k = await l.collection("tenants").doc(e).collection("system_unique").doc(u).collection(`Unique-${u}-${d.name}`).doc(m).get();
10169
+ k.exists && !(n === "update" && k.data().id === t) && f.push(`${d.name} "${s[d.name]}" already exists`);
10170
10170
  }
10171
10171
  }
10172
10172
  })), f.length > 0)
@@ -10192,8 +10192,8 @@ const Tt = {
10192
10192
  }
10193
10193
  const m = ye(t);
10194
10194
  nt(m), n !== "delete" && (d.data.data = ye(m)), n === "update" && (d.data.originalRecord = ye(l)), n !== "delete" && ["started", "written"].includes(e) && (delete d.data.data.Saved_At, delete d.data.data.Last_Save_At), e === "failed" && (d.data.error = JSON.stringify(a));
10195
- const O = De(u, r, s), y = t.Last_Write_At;
10196
- await O.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${y.valueOf()}`).set(d);
10195
+ const k = De(u, r, s), y = t.Last_Write_At;
10196
+ await k.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${y.valueOf()}`).set(d);
10197
10197
  }, un = async (n) => {
10198
10198
  const e = Ye(), t = gt(), s = ue(), r = [];
10199
10199
  if (await Promise.all([
@@ -10224,11 +10224,11 @@ ${i}`);
10224
10224
  n = h;
10225
10225
  else
10226
10226
  throw new Error("Admin email not set");
10227
- const f = hs(n), d = Pc(e), m = t ? Kr(t) : void 0, O = s ? Kr(s) : void 0, y = r ? hs(r) : void 0, w = i ? hs(i) : void 0, b = o ? Un(o) : void 0, N = l ? Un(l) : void 0, p = Array.isArray(f) ? f : [f];
10227
+ const f = hs(n), d = Pc(e), m = t ? Kr(t) : void 0, k = s ? Kr(s) : void 0, y = r ? hs(r) : void 0, w = i ? hs(i) : void 0, b = o ? Un(o) : void 0, N = l ? Un(l) : void 0, p = Array.isArray(f) ? f : [f];
10228
10228
  if (p.length === 0 || p.length === 1 && !p[0])
10229
10229
  throw new Error("No valid email addresses provided");
10230
10230
  const T = { to: f, message: { subject: d } };
10231
- if (m && (T.message.text = m), O && (T.message.html = O), y) {
10231
+ if (m && (T.message.text = m), k && (T.message.html = k), y) {
10232
10232
  const C = Array.isArray(y) ? y : [y];
10233
10233
  C.length > 0 && C[0] && (T.cc = y);
10234
10234
  }
@@ -10292,7 +10292,7 @@ ${i}`);
10292
10292
  d = d.replace("apiKey=&", `apiKey=${m.apiKey}&`);
10293
10293
  }
10294
10294
  if (d) {
10295
- const m = `https://${a.app.options.projectId}.firebaseapp.com/__/auth/action${d}`, O = await ie(t.appName), y = t?.mail?.emailVerification && t.mail.emailVerification(m, O);
10295
+ const m = `https://${a.app.options.projectId}.firebaseapp.com/__/auth/action${d}`, k = await ie(t.appName), y = t?.mail?.emailVerification && t.mail.emailVerification(m, k);
10296
10296
  try {
10297
10297
  await $o(r.Email, y?.subject || "Please verify your email address", void 0, y?.html || `Please verify your email address by clicking the link:
10298
10298
  </br>
@@ -10362,8 +10362,8 @@ ${i}`);
10362
10362
  const d = await r.get(f.doc(u));
10363
10363
  if (!d.exists)
10364
10364
  throw new Error(`VALIDATION_ERROR: Record ${u} not found in collection ${t.collection}`);
10365
- const m = d.data(), O = W(a, t.enforceHierarchy.field), y = t.enforceHierarchy;
10366
- if (!m[y.recordLinkField] || !s[O.name] || !Object.keys(s[O.name]).every((w) => Object.keys(m[y.recordLinkField]).includes(w)))
10365
+ const m = d.data(), k = W(a, t.enforceHierarchy.field), y = t.enforceHierarchy;
10366
+ if (!m[y.recordLinkField] || !s[k.name] || !Object.keys(s[k.name]).every((w) => Object.keys(m[y.recordLinkField]).includes(w)))
10367
10367
  throw new Error("VALIDATION_ERROR: Invalid relation hierarchy");
10368
10368
  }, gn = async (n, e, t) => {
10369
10369
  delete e[n.name][t], e[`${n.name}_Array`] = e[`${n.name}_Array`]?.filter((s) => s !== t), delete e[`${n.name}_Single`];
@@ -10375,7 +10375,7 @@ ${i}`);
10375
10375
  K(l) && l.twoWay && l.collection === t && ((n === "Create" || !i?.[l.name]?.[e]) && r[l.name]?.[e] && o.push(l), n === "Update" && i?.[l.name]?.[e] && !r[l.name]?.[e] && a.push(l));
10376
10376
  return { addedFields: o, removedFields: a };
10377
10377
  }, Po = async (n, e, t, s, r, i, o, a, l, c, u, h) => {
10378
- const { fields: f } = i, d = ue(), m = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
10378
+ const { fields: f } = i, d = ue(), m = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
10379
10379
  for (const w of f)
10380
10380
  K(w) && ["OneToOne", "OneToMany"].includes(w.type) && w.enforceHierarchy && s[w.name] && (n === "Create" || n === "Update" && !ze(h?.[w.name], s[w.name])) && await ei(e, i, w, s, a, l);
10381
10381
  for (const w of f)
@@ -10391,26 +10391,26 @@ ${i}`);
10391
10391
  if (g)
10392
10392
  x = g;
10393
10393
  else {
10394
- l.size++, l && l.size > 500 && console.error(new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks."));
10394
+ l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
10395
10395
  const _ = De(d, Z.Collection_Path, e), A = await a.get(_.doc(v));
10396
10396
  if (!A.exists) {
10397
10397
  gn(w, r, v);
10398
10398
  continue;
10399
10399
  }
10400
10400
  const E = A.data();
10401
- O.set(w.collection, {
10402
- ...O.get(w.collection) || {},
10401
+ k.set(w.collection, {
10402
+ ...k.get(w.collection) || {},
10403
10403
  [v]: E
10404
10404
  }), x = ye({ ...E, ...Sn(s) });
10405
10405
  }
10406
- const k = {
10406
+ const O = {
10407
10407
  ...x[N.name],
10408
10408
  [t]: {
10409
10409
  Collection_Path: s.Collection_Path,
10410
10410
  ...Uc(i, s, N)
10411
10411
  }
10412
10412
  };
10413
- x[N.name] = k, x[`${N.name}_Array`] ||= [], x[`${N.name}_Array`].push(t), p.size === 1 && (x[`${N.name}_Single`] = k), y.set(w.collection, {
10413
+ x[N.name] = O, x[`${N.name}_Array`] ||= [], x[`${N.name}_Array`].push(t), p.size === 1 && (x[`${N.name}_Single`] = O), y.set(w.collection, {
10414
10414
  ...y.get(w.collection) || {},
10415
10415
  [v]: x
10416
10416
  });
@@ -10427,19 +10427,19 @@ ${i}`);
10427
10427
  if (g)
10428
10428
  x = g;
10429
10429
  else {
10430
- l.size++, l && l.size > 500 && console.error(new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks."));
10431
- const k = De(d, Z.Collection_Path, e), _ = await a.get(k.doc(v));
10430
+ l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
10431
+ const O = De(d, Z.Collection_Path, e), _ = await a.get(O.doc(v));
10432
10432
  if (!_.exists) {
10433
10433
  m.set(w.name, [...m.get(w.name) || [], v]);
10434
10434
  continue;
10435
10435
  }
10436
10436
  const A = _.data();
10437
- O.set(w.collection, {
10438
- ...O.get(w.collection) || {},
10437
+ k.set(w.collection, {
10438
+ ...k.get(w.collection) || {},
10439
10439
  [v]: A
10440
10440
  }), x = ye({ ...A, ...Sn(s) });
10441
10441
  }
10442
- x[N.name][t] && delete x[N.name][t], Array.isArray(x[`${N.name}_Array`]) && (x[`${N.name}_Array`] = x[`${N.name}_Array`].filter((k) => k !== t)), p.size === 1 && delete x[`${N.name}_Single`], y.set(w.collection, {
10442
+ x[N.name][t] && delete x[N.name][t], Array.isArray(x[`${N.name}_Array`]) && (x[`${N.name}_Array`] = x[`${N.name}_Array`].filter((O) => O !== t)), p.size === 1 && delete x[`${N.name}_Single`], y.set(w.collection, {
10443
10443
  ...y.get(w.collection) || {},
10444
10444
  [v]: x
10445
10445
  });
@@ -10460,7 +10460,7 @@ ${i}`);
10460
10460
  }
10461
10461
  }
10462
10462
  for (const x of Z) {
10463
- const g = W(N.fields, x.twoWay), k = ft(N, [g]);
10463
+ const g = W(N.fields, x.twoWay), O = ft(N, [g]);
10464
10464
  if (!rr(N, g, u)) {
10465
10465
  ys(
10466
10466
  x,
@@ -10468,7 +10468,7 @@ ${i}`);
10468
10468
  // eslint-disable-next-line security/detect-object-injection
10469
10469
  h?.[x.name]?.[T],
10470
10470
  T,
10471
- k.size === 1
10471
+ O.size === 1
10472
10472
  );
10473
10473
  continue;
10474
10474
  }
@@ -10480,19 +10480,19 @@ ${i}`);
10480
10480
  c,
10481
10481
  u,
10482
10482
  // eslint-disable-next-line security/detect-object-injection
10483
- O.get(w)?.[T]
10483
+ k.get(w)?.[T]
10484
10484
  )) {
10485
10485
  for (const x of v)
10486
10486
  gn(x, r, T);
10487
10487
  for (const x of Z) {
10488
- const g = W(N.fields, x.twoWay), k = ft(N, [g]);
10488
+ const g = W(N.fields, x.twoWay), O = ft(N, [g]);
10489
10489
  ys(
10490
10490
  x,
10491
10491
  r,
10492
10492
  // eslint-disable-next-line security/detect-object-injection
10493
10493
  h?.[x.name]?.[T],
10494
10494
  T,
10495
- k.size === 1
10495
+ O.size === 1
10496
10496
  );
10497
10497
  }
10498
10498
  }
@@ -10500,14 +10500,14 @@ ${i}`);
10500
10500
  for (const x of v)
10501
10501
  gn(x, r, T);
10502
10502
  for (const x of Z) {
10503
- const g = W(N.fields, x.twoWay), k = ft(N, [g]);
10503
+ const g = W(N.fields, x.twoWay), O = ft(N, [g]);
10504
10504
  ys(
10505
10505
  x,
10506
10506
  r,
10507
10507
  // eslint-disable-next-line security/detect-object-injection
10508
10508
  h?.[x.name]?.[T],
10509
10509
  T,
10510
- k.size === 1
10510
+ O.size === 1
10511
10511
  );
10512
10512
  }
10513
10513
  }
@@ -10580,7 +10580,7 @@ ${i}`);
10580
10580
  if (s.collections?.[a]?.restrictEntities || s?.collections?.[a]?.recordOwner?.active || s?.collections?.[a]?.recordUser?.active || s?.collections?.[a]?.recordProperty?.active) {
10581
10581
  const f = i?.collections?.[a], d = [];
10582
10582
  if (l.individualEntities) {
10583
- const m = l.individualEntities, O = f?.individualEntities || [], y = i ? m.filter((w) => !O.includes(w)) : m;
10583
+ const m = l.individualEntities, k = f?.individualEntities || [], y = i ? m.filter((w) => !k.includes(w)) : m;
10584
10584
  for (const w of y) {
10585
10585
  if (o && o.size++, o && o.size > 500)
10586
10586
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks or entity restrictions (in permissions when dealing with user collections).");
@@ -10594,7 +10594,7 @@ ${i}`);
10594
10594
  const m = c.entityRestrictions?.restrictions?.find((p) => p.type === "Parent" && p.roles.some((T) => T.role === e.Role));
10595
10595
  if (!m)
10596
10596
  throw new Error("PERMISSION_DENIED");
10597
- const O = W(u.fields, m.collectionField), y = r.collections[O.collection], w = l.parentEntities, b = f?.parentEntities || [], N = i ? w.filter((p) => !b.includes(p)) : w;
10597
+ const k = W(u.fields, m.collectionField), y = r.collections[k.collection], w = l.parentEntities, b = f?.parentEntities || [], N = i ? w.filter((p) => !b.includes(p)) : w;
10598
10598
  for (const p of N) {
10599
10599
  if (o && o.size++, o && o.size > 500)
10600
10600
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks or entity restrictions (in permissions when dealing with user collections).");
@@ -10608,7 +10608,7 @@ ${i}`);
10608
10608
  const m = c.entityRestrictions?.restrictions?.find((N) => N.type === "Parent_Property" && N.roles.some((p) => p.role === e.Role));
10609
10609
  if (!m)
10610
10610
  throw new Error("PERMISSION_DENIED");
10611
- const O = W(u.fields, m.collectionField), y = r.collections[O.collection], w = l.parentPropertyEntities, b = f?.parentPropertyEntities || {};
10611
+ const k = W(u.fields, m.collectionField), y = r.collections[k.collection], w = l.parentPropertyEntities, b = f?.parentPropertyEntities || {};
10612
10612
  for (const [N, p] of Object.entries(w)) {
10613
10613
  const T = b[N] || [], C = i ? p.filter((v) => !T.includes(v)) : p;
10614
10614
  for (const v of C) {
@@ -10632,23 +10632,25 @@ ${i}`);
10632
10632
  const u = n.at(-1), h = Object.keys(c.collections).includes(u), f = l.disabledCollections?.includes(u);
10633
10633
  if (!h || f)
10634
10634
  throw new Error("COLLECTION_NOT_FOUND");
10635
- const d = c.collections[u], { labels: m, fields: O, enableWriteLog: y, softDelete: w } = d, b = Je(m.collection, c), N = await ie(l.appName), p = ue(), T = gt(), v = (s ? await T.getUser(s) : void 0)?.customClaims?.role;
10635
+ const d = c.collections[u], { labels: m, fields: k, enableWriteLog: y, softDelete: w } = d, b = Je(m.collection, c), N = await ie(l.appName), p = ue(), T = gt(), v = (s ? await T.getUser(s) : void 0)?.customClaims?.role;
10636
10636
  let Z;
10637
10637
  s && await er(n, d);
10638
10638
  const x = De(p, n, a), g = o || x.doc().id;
10639
10639
  i = i || {}, i.collection = m.collection, e.id = g, Fo(e), tr(e);
10640
- const k = Ws("create", n, e, c, N, "Online", s || "System", lt.now(), me.serverTimestamp()), _ = ye(k);
10641
- w && (k[w.archivedField] = !1), Ve(e), y && await Mt("create", "started", k, a, n, g, d), await ae("preOperation", l, b, ["create", k, g, i]), await ae("preWrite", l, b, ["create", k, g, i]), Tn(d, k, c), Rn(d, k), await oa(k, d, b, v), Ve(k);
10640
+ const O = Ws("create", n, e, c, N, "Online", s || "System", lt.now(), me.serverTimestamp());
10641
+ r?.createdAt && (O.Created_At = r.createdAt), r?.createdBy && (O.Created_By = r.createdBy);
10642
+ const _ = ye(O);
10643
+ w && (O[w.archivedField] = !1), Ve(e), y && await Mt("create", "started", O, a, n, g, d), await ae("preOperation", l, b, ["create", O, g, i]), await ae("preWrite", l, b, ["create", O, g, i]), Tn(d, O, c), Rn(d, O), await oa(O, d, b, v), Ve(O);
10642
10644
  try {
10643
10645
  if (d.auth && t && !t.password)
10644
10646
  throw new Error("Password is required");
10645
- await Co("create", a, g, k, d, c), await sn("create", k, d, b, ["create", k, i], c);
10647
+ await Co("create", a, g, O, d, c), await sn("create", O, d, b, ["create", O, i], c);
10646
10648
  } catch (P) {
10647
10649
  throw new Error(`VALIDATION_ERROR: ${P.message}`);
10648
10650
  }
10649
- Ve(k), e.id = g, w && (k[w.archivedField] = !1), Tn(d, k, c), Rn(d, k);
10651
+ Ve(O), e.id = g, w && (O[w.archivedField] = !1), Tn(d, O, c), Rn(d, O);
10650
10652
  try {
10651
- Lo("create", k, _), Vo("create", d, k), await sn("create", k, d, b, ["create", k, i], c);
10653
+ Lo("create", O, _), Vo("create", d, O), await sn("create", O, d, b, ["create", O, i], c);
10652
10654
  } catch (P) {
10653
10655
  throw new Error(`VALIDATION_ERROR: ${P.message}`);
10654
10656
  }
@@ -10656,17 +10658,17 @@ ${i}`);
10656
10658
  const P = v;
10657
10659
  if (!P)
10658
10660
  throw new Error("USER_ERROR");
10659
- if (!(b.custom?.serverAccess?.create !== void 0 ? await ie(b.custom.serverAccess.create, [P, k]) : !0))
10661
+ if (!(b.custom?.serverAccess?.create !== void 0 ? await ie(b.custom.serverAccess.create, [P, O]) : !0))
10660
10662
  throw new Error("PERMISSION_DENIED");
10661
10663
  for (const Q of d.fields) {
10662
- if (!(Q.name in k))
10664
+ if (!(Q.name in O))
10663
10665
  continue;
10664
10666
  const S = Ie(Q, b);
10665
- if (S?.custom?.serverAccess?.create !== void 0 && !await ie(S.custom.serverAccess.create, [P, k]))
10667
+ if (S?.custom?.serverAccess?.create !== void 0 && !await ie(S.custom.serverAccess.create, [P, O]))
10666
10668
  throw new Error("PERMISSION_DENIED");
10667
10669
  }
10668
10670
  }
10669
- t && (t.permissions ||= {}, t.permissions.Role ||= k.Role, t.permissions.Enabled ||= k.Enabled);
10671
+ t && (t.permissions ||= {}, t.permissions.Role ||= O.Role, t.permissions.Enabled ||= O.Enabled);
10670
10672
  const D = async (P, j) => {
10671
10673
  const [Q, S, q, B] = await Promise.all([
10672
10674
  P.get(p.collection("system_deployment").doc("latest_deploy")),
@@ -10677,7 +10679,7 @@ ${i}`);
10677
10679
  if (j && (j.size += 3), !Q.exists)
10678
10680
  throw new Error("VERSION_ERROR");
10679
10681
  const re = Q.data();
10680
- if (re.force && k.Last_Write_At.valueOf() < re.time.valueOf())
10682
+ if (re.force && O.Last_Write_At.valueOf() < re.time.valueOf())
10681
10683
  throw new Error("VERSION_ERROR");
10682
10684
  if (!S.exists)
10683
10685
  throw new Error("MAINTENANCE_MODE");
@@ -10691,14 +10693,14 @@ ${i}`);
10691
10693
  if (!Z.Enabled)
10692
10694
  throw new Error("PERMISSION_DENIED");
10693
10695
  }
10694
- const pe = O.filter((oe) => "unique" in oe && oe.unique).map(async (oe) => {
10696
+ const pe = k.filter((oe) => "unique" in oe && oe.unique).map(async (oe) => {
10695
10697
  if (!s || !oe.access || oe.access.includes(Z.Role)) {
10696
10698
  if (!e[oe.name])
10697
10699
  return;
10698
10700
  const Le = Ie(oe, b);
10699
10701
  if (!(s && Le?.custom?.serverAccess?.read !== void 0 ? await ie(Le.custom.serverAccess.read, [
10700
10702
  Z?.Role,
10701
- k
10703
+ O
10702
10704
  ]) : !0))
10703
10705
  throw new Error("PERMISSION_DENIED");
10704
10706
  const Jn = e[oe.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
@@ -10706,12 +10708,12 @@ ${i}`);
10706
10708
  if (j && j.size++, j && j.size > 500)
10707
10709
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks.");
10708
10710
  if ((await P.get(p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${oe.name}`).doc(Jn)))?.exists)
10709
- throw new Error(`VALIDATION_ERROR: ${oe.name} "${k[oe.name]}" already exists`);
10711
+ throw new Error(`VALIDATION_ERROR: ${oe.name} "${O[oe.name]}" already exists`);
10710
10712
  } else
10711
- throw new Error(`VALIDATION_ERROR: ${oe.name} "${k[oe.name]}" is invalid`);
10713
+ throw new Error(`VALIDATION_ERROR: ${oe.name} "${O[oe.name]}" is invalid`);
10712
10714
  }
10713
10715
  });
10714
- await Promise.all(pe), ir(k, g, d, c, s, Z, t?.permissions), t?.permissions && s && Z && await Uo(P, t.permissions, s, Z, c), ir(k, g, d, c, s, Z, t?.permissions);
10716
+ await Promise.all(pe), ir(O, g, d, c, s, Z, t?.permissions), t?.permissions && s && Z && await Uo(P, t.permissions, s, Z, c), ir(O, g, d, c, s, Z, t?.permissions);
10715
10717
  };
10716
10718
  if (d.auth && t) {
10717
10719
  await p.runTransaction(async (j) => {
@@ -10722,29 +10724,29 @@ ${i}`);
10722
10724
  g,
10723
10725
  l,
10724
10726
  m.collection,
10725
- k,
10727
+ O,
10726
10728
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10727
10729
  t.permissions,
10728
10730
  t.password
10729
10731
  );
10730
- k.User_ID = P;
10732
+ O.User_ID = P;
10731
10733
  }
10732
10734
  try {
10733
10735
  const P = { size: 1 };
10734
10736
  await p.runTransaction(async (j) => {
10735
- await D(j, P), r?.noTwoWay || await Po("Create", a, g, k, k, d, c, j, P, s, Z);
10737
+ await D(j, P), r?.noTwoWay || await Po("Create", a, g, O, O, d, c, j, P, s, Z);
10736
10738
  const Q = Us(c);
10737
- Qs("create", j, n, g, k, c, d, r, Q, me.arrayUnion, me.arrayRemove, me.delete, (S) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${S.name}`).doc(g), (S, q) => p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${S.name}`).doc(q), (S) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${S}`).doc(g), (S, q) => De(p, S, a).doc(q), (S, q, B) => p.collection("tenants").doc(a).collection("system_fields").doc(S.collection).collection(`${S.collection}-${q}`).doc(B), (S, q, B) => p.collection("tenants").doc(a).collection("system_fields").doc(S.collection).collection(`${S.collection}-${q.replaceAll(" ", "-")}`).doc(B), void 0, void 0, P), j.set(x.doc(g), k);
10739
+ Qs("create", j, n, g, O, c, d, r, Q, me.arrayUnion, me.arrayRemove, me.delete, (S) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${S.name}`).doc(g), (S, q) => p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${S.name}`).doc(q), (S) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${S}`).doc(g), (S, q) => De(p, S, a).doc(q), (S, q, B) => p.collection("tenants").doc(a).collection("system_fields").doc(S.collection).collection(`${S.collection}-${q}`).doc(B), (S, q, B) => p.collection("tenants").doc(a).collection("system_fields").doc(S.collection).collection(`${S.collection}-${q.replaceAll(" ", "-")}`).doc(B), void 0, void 0, P), j.set(x.doc(g), O);
10738
10740
  }, { maxAttempts: 10 });
10739
10741
  } catch (P) {
10740
- const Q = await ae("postWriteError", l, b, ["create", k, g, i, P]);
10742
+ const Q = await ae("postWriteError", l, b, ["create", O, g, i, P]);
10741
10743
  if (y && (await new Promise((S) => {
10742
10744
  setTimeout(S, 250);
10743
- }), await Mt("create", Q?.resolved ? "success" : "failed", k, a, n, g, d, Q?.resolved ? void 0 : P)), !Q?.resolved)
10744
- throw d.auth && t && await un(k), P;
10745
+ }), await Mt("create", Q?.resolved ? "success" : "failed", O, a, n, g, d, Q?.resolved ? void 0 : P)), !Q?.resolved)
10746
+ throw d.auth && t && await un(O), P;
10745
10747
  }
10746
- const R = ["create", k, g, i], F = [...R];
10747
- return await ae("postWrite", l, b, R), await ae("postOperation", l, b, F), { id: g, ...k };
10748
+ const R = ["create", O, g, i], F = [...R];
10749
+ return await ae("postWrite", l, b, R), await ae("postOperation", l, b, F), { id: g, ...O };
10748
10750
  }, Qt = async (n, e, t, s) => {
10749
10751
  const r = Ye(), i = gt(), o = ue(), a = e.customClaims || {};
10750
10752
  let l = !1;
@@ -10781,14 +10783,14 @@ ${i}`);
10781
10783
  throw new Error(`ROLLBACK_FAILED: ${s}`);
10782
10784
  }, zc = async (n, e, t, s, r, i, o, a, l, c, u) => {
10783
10785
  const h = gt(), f = ue(), d = a?.customClaims || {}, m = "USER_ERROR";
10784
- let O = "";
10786
+ let k = "";
10785
10787
  if (n === "create") {
10786
10788
  if (!u)
10787
10789
  throw new Error("VALIDATION_ERROR: Password is required");
10788
10790
  if (!l)
10789
10791
  throw new Error("VALIDATION_ERROR: Permissions are required");
10790
10792
  try {
10791
- O = await Mo(e, t, s, r, i, l, u);
10793
+ k = await Mo(e, t, s, r, i, l, u);
10792
10794
  } catch (y) {
10793
10795
  throw new Error(y.message);
10794
10796
  }
@@ -10851,8 +10853,8 @@ ${i}`);
10851
10853
  } catch (y) {
10852
10854
  throw new Error(y.message);
10853
10855
  }
10854
- if (O)
10855
- return O;
10856
+ if (k)
10857
+ return k;
10856
10858
  }, qc = async (n, e, t) => {
10857
10859
  const s = Ye(), r = ue(), i = [e];
10858
10860
  t && t.trim() !== "" && i.push(t), i.sort();
@@ -10882,7 +10884,7 @@ ${i}`);
10882
10884
  const u = n.at(-1), h = Object.keys(c.collections).includes(u), f = l.disabledCollections?.includes(u);
10883
10885
  if (!h || f)
10884
10886
  throw new Error("COLLECTION_NOT_FOUND");
10885
- const d = c.collections[u], { labels: m, fields: O, enableWriteLog: y } = d, w = Je(m.collection, c), b = await ie(l.appName), N = gt(), p = ue();
10887
+ const d = c.collections[u], { labels: m, fields: k, enableWriteLog: y } = d, w = Je(m.collection, c), b = await ie(l.appName), N = gt(), p = ue();
10886
10888
  let T;
10887
10889
  r && await er(n, d);
10888
10890
  const C = De(p, n, a);
@@ -10892,7 +10894,7 @@ ${i}`);
10892
10894
  noComputedFields: !0,
10893
10895
  noEmbeddingFields: !0
10894
10896
  });
10895
- for (const S of O)
10897
+ for (const S of k)
10896
10898
  S.type === "Computed" && delete t[S.name];
10897
10899
  if (c = {
10898
10900
  ...c,
@@ -10909,10 +10911,10 @@ ${i}`);
10909
10911
  throw new Error("VALIDATION_ERROR: User operations are only permitted for auth collections");
10910
10912
  if (s?.operation === "delete" && s.permissions)
10911
10913
  throw new Error("VALIDATION_ERROR: Permissions are not allowed for delete operations");
10912
- const Z = d.auth && s?.operation === "create", x = d.auth && s?.operation === "delete", g = d.auth && !Z && !x && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), k = (S) => S.User_ID && (d.auth && !Z && !x && s?.operation === "update" || t.Role && t.Role !== S.Role || t.Enabled !== void 0 && t.Enabled !== S.Enabled || t.Name && t.Name !== S.Name || t.Email && t.Email !== S.Email || t.Photo_URL && t.Photo_URL !== S.Photo_URL);
10914
+ const Z = d.auth && s?.operation === "create", x = d.auth && s?.operation === "delete", g = d.auth && !Z && !x && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), O = (S) => S.User_ID && (d.auth && !Z && !x && s?.operation === "update" || t.Role && t.Role !== S.Role || t.Enabled !== void 0 && t.Enabled !== S.Enabled || t.Name && t.Name !== S.Name || t.Email && t.Email !== S.Email || t.Photo_URL && t.Photo_URL !== S.Photo_URL);
10913
10915
  delete t.id, Fo(t), tr(t);
10914
10916
  const _ = Ws("update", n, t, c, b, "Online", r || "System", lt.now(), me.serverTimestamp()), A = ye(_);
10915
- for (const S of O)
10917
+ for (const S of k)
10916
10918
  !K(S) && Me(_[S.name]) && S.nullable && (_[S.name] = null);
10917
10919
  Ve(_), Ve(v), y && await Mt("update", "started", _, a, n, e, d, void 0, v);
10918
10920
  const E = [
@@ -10935,7 +10937,7 @@ ${i}`);
10935
10937
  throw new Error(`VALIDATION_ERROR: ${S.message}`);
10936
10938
  }
10937
10939
  Ve(_), delete t.id, Tn(d, _, c), Rn(d, _);
10938
- for (const S of O)
10940
+ for (const S of k)
10939
10941
  !K(S) && Me(_[S.name]) && S.nullable && (_[S.name] = null);
10940
10942
  try {
10941
10943
  const S = { ...v, ..._ };
@@ -10978,7 +10980,7 @@ ${i}`);
10978
10980
  }
10979
10981
  if (B && (B.size += No(a, n, e, c, T).length), Z && v.User_ID || x && !v.User_ID)
10980
10982
  throw new Error("USER_ERROR");
10981
- if (k(v)) {
10983
+ if (O(v)) {
10982
10984
  const de = await S.get(p.collection("tenants").doc(a).collection("system_user_permissions").doc(v.User_ID));
10983
10985
  if (B && B.size++, !de?.exists)
10984
10986
  throw new Error("PERMISSION_DENIED");
@@ -10989,7 +10991,7 @@ ${i}`);
10989
10991
  throw new Error("VALIDATION_ERROR: Enabled field is required");
10990
10992
  }
10991
10993
  }
10992
- const nr = O.filter((de) => "unique" in de && de.unique).map(async (de) => {
10994
+ const nr = k.filter((de) => "unique" in de && de.unique).map(async (de) => {
10993
10995
  if (!r || !de.access || de.access.includes(T.Role)) {
10994
10996
  if (_[de.name] === void 0 || Me(_[de.name]))
10995
10997
  return;
@@ -11024,15 +11026,15 @@ ${i}`);
11024
11026
  throw new Error("PERMISSION_DENIED");
11025
11027
  }
11026
11028
  }
11027
- or(_, v, e, d, c, r, T, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, R), s?.permissions && r && T && await Uo(S, s.permissions, r, T, c, R, B), or(_, v, e, d, c, r, T, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, R), q && (Z || k(v) || x) && await qc(S, e, v.User_ID);
11029
+ or(_, v, e, d, c, r, T, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, R), s?.permissions && r && T && await Uo(S, s.permissions, r, T, c, R, B), or(_, v, e, d, c, r, T, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, R), q && (Z || O(v) || x) && await qc(S, e, v.User_ID);
11028
11030
  };
11029
11031
  (Z || g || x) && await p.runTransaction(async (S) => {
11030
11032
  await F(S, !0);
11031
11033
  }, { maxAttempts: 10 });
11032
11034
  try {
11033
11035
  let S;
11034
- if (Z || k(v) || x) {
11035
- if (k(v)) {
11036
+ if (Z || O(v) || x) {
11037
+ if (O(v)) {
11036
11038
  S = await N.getUser(v.User_ID);
11037
11039
  const re = S.customClaims;
11038
11040
  if (!(re && re.role && re.collection && re.doc))
@@ -11067,13 +11069,13 @@ ${i}`);
11067
11069
  if (y && (await new Promise((Qe) => {
11068
11070
  setTimeout(Qe, 250);
11069
11071
  }), await Mt("update", re?.resolved ? "success" : "failed", _, a, n, e, d, re?.resolved ? void 0 : q, v)), !re?.resolved)
11070
- throw Z && await un(v), k(v) && await Qt(v.User_ID, S, R, "USER_ERROR"), x && await p.collection("tenants").doc(a).collection(m.collection).doc(e).update({ User_ID: me.delete() }), q;
11072
+ throw Z && await un(v), O(v) && await Qt(v.User_ID, S, R, "USER_ERROR"), x && await p.collection("tenants").doc(a).collection(m.collection).doc(e).update({ User_ID: me.delete() }), q;
11071
11073
  }
11072
- (Z || k(v) || x) && await Qr(ti, [e, v.User_ID]).catch(() => {
11074
+ (Z || O(v) || x) && await Qr(ti, [e, v.User_ID]).catch(() => {
11073
11075
  throw new Error("USER_ERROR");
11074
11076
  });
11075
11077
  } catch (S) {
11076
- throw (Z || k(v) || x) && await Qr(ti, [e, v.User_ID]).catch(() => {
11078
+ throw (Z || O(v) || x) && await Qr(ti, [e, v.User_ID]).catch(() => {
11077
11079
  throw new Error("USER_ERROR");
11078
11080
  }), S;
11079
11081
  }
@@ -11089,9 +11091,9 @@ ${i}`);
11089
11091
  const l = n.at(-1), c = Object.keys(a.collections).includes(l), u = o.disabledCollections?.includes(l);
11090
11092
  if (!c || u)
11091
11093
  throw new Error("COLLECTION_NOT_FOUND");
11092
- const h = a.collections[l], { labels: f, auth: d, enableWriteLog: m, softDelete: O } = h, y = Je(f.collection, a), w = await ie(o.appName);
11093
- if (O && !d && !s?.force)
11094
- return await Bc(n, e, { [O.archivedField]: !0, [O.timestampField]: me.serverTimestamp() }, void 0, t);
11094
+ const h = a.collections[l], { labels: f, auth: d, enableWriteLog: m, softDelete: k } = h, y = Je(f.collection, a), w = await ie(o.appName);
11095
+ if (k && !d && !s?.force)
11096
+ return await Bc(n, e, { [k.archivedField]: !0, [k.timestampField]: me.serverTimestamp() }, void 0, t);
11095
11097
  const b = ue();
11096
11098
  let N;
11097
11099
  t && await er(n, h);
@@ -11145,8 +11147,8 @@ ${i}`);
11145
11147
  }), await Mt("delete", R?.resolved ? "success" : "failed", C, i, n, e, h, R?.resolved ? void 0 : E)), !R?.resolved)
11146
11148
  throw h.auth && C.User_ID && await b.collection("tenants").doc(i).collection(f.collection).doc(e).update({ User_ID: me.delete() }), E;
11147
11149
  }
11148
- const k = ["delete", C, e, r], _ = [...k];
11149
- return await ae("postWrite", o, y, k), await ae("postOperation", o, y, _), { id: e, ...C };
11150
+ const O = ["delete", C, e, r], _ = [...O];
11151
+ return await ae("postWrite", o, y, O), await ae("postOperation", o, y, _), { id: e, ...C };
11150
11152
  }, wu = async (n, e) => {
11151
11153
  const t = ue(), s = To(), r = process.env.ADMIN_SMS;
11152
11154
  if (s === "development")