@stoker-platform/node-client 0.5.44 → 0.5.46
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.cjs +6 -6
- package/dist/bundle.js +334 -327
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -45,7 +45,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
45
45
|
const c = t.collections?.[l.collection], h = e.collections[l.collection].access.entityRestrictions;
|
|
46
46
|
if (!h)
|
|
47
47
|
throw new Error("PERMISSION_DENIED");
|
|
48
|
-
const d = h.restrictions?.find((f) => f.type === o.type && f.roles.some((
|
|
48
|
+
const d = h.restrictions?.find((f) => f.type === o.type && f.roles.some((p) => p.role === t.Role));
|
|
49
49
|
if (!d)
|
|
50
50
|
throw new Error("PERMISSION_DENIED");
|
|
51
51
|
d.roles.forEach((f) => {
|
|
@@ -83,23 +83,23 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
83
83
|
const C = W(a, v.propertyField), _ = v.roles.find((Z) => Z.role === r.Role);
|
|
84
84
|
C.type === "Array" ? _.values?.some((Z) => i[C.name].includes(Z)) || (c = !1) : _.values?.includes(i[C.name]) || (c = !1);
|
|
85
85
|
});
|
|
86
|
-
let f = !0,
|
|
86
|
+
let f = !0, p = !1;
|
|
87
87
|
h?.filter((v) => v.type === "Individual").forEach(() => {
|
|
88
|
-
|
|
88
|
+
p = !0, l?.individualEntities?.includes(i.id) || (f = !1);
|
|
89
89
|
});
|
|
90
|
-
let O = !0,
|
|
90
|
+
let O = !0, y = !1;
|
|
91
91
|
if (h?.filter((v) => v.type === "Parent").forEach((v) => {
|
|
92
|
-
|
|
92
|
+
y = !0;
|
|
93
93
|
const C = W(a, v.collectionField);
|
|
94
94
|
l?.parentEntities?.some((_) => i[`${C.name}_Array`].includes(_)) || (O = !1);
|
|
95
95
|
}), h?.filter((v) => v.type === "Parent_Property").forEach((v) => {
|
|
96
|
-
|
|
96
|
+
y = !0;
|
|
97
97
|
const C = W(a, v.collectionField), _ = W(a, v.propertyField);
|
|
98
98
|
Object.entries(l?.parentPropertyEntities || {}).some((Z) => {
|
|
99
99
|
const [k, m] = Z;
|
|
100
100
|
return k === i[_.name] && i[`${C.name}_Array`].some((M) => m.includes(M));
|
|
101
101
|
}) || (O = !1);
|
|
102
|
-
}),
|
|
102
|
+
}), p && y) {
|
|
103
103
|
if (!(f || O)) {
|
|
104
104
|
c = !1;
|
|
105
105
|
return;
|
|
@@ -257,41 +257,41 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
257
257
|
}
|
|
258
258
|
});
|
|
259
259
|
for (const i of Object.values(n.collections)) {
|
|
260
|
-
const { labels: o, access: a, fields: l } = i, { operations: c, attributeRestrictions: u, entityRestrictions: h } = a, d = c.assignable, f = e.collections?.[o.collection],
|
|
261
|
-
if (d !== !0 && !(typeof d == "object" && d.includes(t)) ?
|
|
262
|
-
const g =
|
|
263
|
-
if (
|
|
264
|
-
const N = !!a.operations[
|
|
260
|
+
const { labels: o, access: a, fields: l } = i, { operations: c, attributeRestrictions: u, entityRestrictions: h } = a, d = c.assignable, f = e.collections?.[o.collection], p = ["read", "create", "update", "delete"];
|
|
261
|
+
if (d !== !0 && !(typeof d == "object" && d.includes(t)) ? p.forEach((y) => {
|
|
262
|
+
const g = y.charAt(0).toUpperCase() + y.slice(1);
|
|
263
|
+
if (y !== "assignable") {
|
|
264
|
+
const N = !!a.operations[y]?.includes(t), b = !!f?.operations.includes(g);
|
|
265
265
|
if (!N && b) {
|
|
266
|
-
r = `Collection ${o.collection} has excess ${
|
|
266
|
+
r = `Collection ${o.collection} has excess ${y} operation for role ${t}`, s = !1;
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
269
|
if (N && !b) {
|
|
270
|
-
r = `Collection ${o.collection} has missing ${
|
|
270
|
+
r = `Collection ${o.collection} has missing ${y} operation for role ${t}`, s = !1;
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
-
}) :
|
|
275
|
-
const g =
|
|
276
|
-
if (
|
|
277
|
-
const N = !!a.operations[
|
|
274
|
+
}) : p.forEach((y) => {
|
|
275
|
+
const g = y.charAt(0).toUpperCase() + y.slice(1);
|
|
276
|
+
if (y !== "assignable") {
|
|
277
|
+
const N = !!a.operations[y]?.includes(t), b = !!f?.operations.includes(g);
|
|
278
278
|
if (!N && b) {
|
|
279
|
-
r = `Collection ${o.collection} has excess ${
|
|
279
|
+
r = `Collection ${o.collection} has excess ${y} operation for role ${t}`, s = !1;
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
}), !u && !h || (u?.forEach((
|
|
284
|
-
for (const g of
|
|
283
|
+
}), !u && !h || (u?.forEach((y) => {
|
|
284
|
+
for (const g of y.roles)
|
|
285
285
|
if (g.role === t && !g.assignable) {
|
|
286
|
-
if (
|
|
286
|
+
if (y.type === "Record_Owner" && !e.collections?.[o.collection]?.recordOwner?.active) {
|
|
287
287
|
r = `Collection ${o.collection} is missing Record_Owner restriction for role ${t}`, s = !1;
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
-
if (
|
|
290
|
+
if (y.type === "Record_User" && !e.collections?.[o.collection]?.recordUser?.active) {
|
|
291
291
|
r = `Collection ${o.collection} is missing Record_User restriction for role ${t}`, s = !1;
|
|
292
292
|
return;
|
|
293
293
|
}
|
|
294
|
-
if (
|
|
294
|
+
if (y.type === "Record_Property" && !e.collections?.[o.collection]?.recordProperty?.active) {
|
|
295
295
|
r = `Collection ${o.collection} is missing Record_Property restriction for role ${t}`, s = !1;
|
|
296
296
|
return;
|
|
297
297
|
}
|
|
@@ -299,15 +299,15 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
299
299
|
}), h?.assignable?.includes(t)))
|
|
300
300
|
continue;
|
|
301
301
|
let O = !1;
|
|
302
|
-
if (h?.restrictions?.forEach((
|
|
303
|
-
for (const g of
|
|
302
|
+
if (h?.restrictions?.forEach((y) => {
|
|
303
|
+
for (const g of y.roles)
|
|
304
304
|
if (g.role === t) {
|
|
305
|
-
if (O = !0,
|
|
305
|
+
if (O = !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
|
}
|
|
309
|
-
if (
|
|
310
|
-
const N = W(l,
|
|
309
|
+
if (y.type === "Parent") {
|
|
310
|
+
const N = W(l, y.collectionField);
|
|
311
311
|
if (!K(N)) {
|
|
312
312
|
s = !1;
|
|
313
313
|
return;
|
|
@@ -317,8 +317,8 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
|
-
if (
|
|
321
|
-
const N = W(l,
|
|
320
|
+
if (y.type === "Parent_Property") {
|
|
321
|
+
const N = W(l, y.collectionField);
|
|
322
322
|
if (!K(N)) {
|
|
323
323
|
s = !1;
|
|
324
324
|
return;
|
|
@@ -338,21 +338,21 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
338
338
|
}, Bo = (n, e, t, s, r, i, o, a, l) => {
|
|
339
339
|
const { access: c } = e, { permissionWriteRestrictions: u } = c;
|
|
340
340
|
let h = !0, d = "";
|
|
341
|
-
const f = u?.filter((
|
|
342
|
-
return f?.length && !f.some((
|
|
343
|
-
o.User_ID && f?.length && !f.some((
|
|
344
|
-
s ===
|
|
345
|
-
const
|
|
346
|
-
if (!(n === "update" && qe(
|
|
347
|
-
const N =
|
|
341
|
+
const f = u?.filter((p) => s === p.userRole);
|
|
342
|
+
return f?.length && !f.some((p) => p.recordRole === r) ? (d = `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
|
+
o.User_ID && f?.length && !f.some((p) => p.recordRole === a) ? (d = `User ${s} does not have write access to record with role ${r}`, h = !1, h) : (u?.forEach((p) => {
|
|
344
|
+
s === p.userRole && p.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((O) => {
|
|
345
|
+
const y = i.collections?.[O], g = l?.collections?.[O];
|
|
346
|
+
if (!(n === "update" && qe(y, g)) && y) {
|
|
347
|
+
const N = p.collections.some((b) => b.collection === O);
|
|
348
348
|
if (N) {
|
|
349
349
|
if (N) {
|
|
350
|
-
const b =
|
|
351
|
-
if (!(
|
|
350
|
+
const b = p.collections.find((v) => v.collection === O);
|
|
351
|
+
if (!(y.operations.every((v) => b.operations.includes(v)) || n === "update" && qe(y.operations, g?.operations))) {
|
|
352
352
|
d = `User ${s} does not have write access to all included operations for collection ${O}`, h = !1;
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
if (!b.auth &&
|
|
355
|
+
if (!b.auth && y.auth && !(n === "update" && qe(y.auth, g?.auth))) {
|
|
356
356
|
d = `User ${s} does not have write access to auth for collection ${O}`, h = !1;
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
@@ -363,11 +363,11 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
363
363
|
};
|
|
364
364
|
if (Object.keys(x).forEach((v) => {
|
|
365
365
|
const C = x[v];
|
|
366
|
-
if (b.attributeRestrictions?.includes(C) && !(
|
|
366
|
+
if (b.attributeRestrictions?.includes(C) && !(y[v]?.active || n === "update" && qe(y[v], g?.[v]))) {
|
|
367
367
|
d = `User ${s} does not have write access to attribute restriction ${v} for collection ${O}`, h = !1;
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
}), b.restrictEntities && !
|
|
370
|
+
}), b.restrictEntities && !y.restrictEntities && !(n === "update" && qe(y.restrictEntities, g?.restrictEntities))) {
|
|
371
371
|
d = `User ${s} does not have write access to restrictEntities for collection ${O}`, h = !1;
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
@@ -450,18 +450,18 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
450
450
|
}, sr = (n, e, t, s, r, i, o, a, l, c) => {
|
|
451
451
|
const { labels: u, fields: h } = s, d = o?.collections?.[u.collection], f = { ...e, ...n };
|
|
452
452
|
nt(f);
|
|
453
|
-
let
|
|
453
|
+
let p = !0, O = "";
|
|
454
454
|
if (i && !d)
|
|
455
455
|
throw new Error("PERMISSION_DENIED");
|
|
456
|
-
i && !Se("Update", d) && (
|
|
456
|
+
i && !Se("Update", d) && (p = !1, O = "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, f)) && (
|
|
459
|
-
!Se("Delete", d) && (
|
|
460
|
-
for (const
|
|
461
|
-
const g = n[
|
|
462
|
-
|
|
458
|
+
!it("Update", s, r, i, o, f)) && (p = !1, O = "Authenticated user does not have Update access to this document"), i && s.softDelete && f[s.softDelete.archivedField] !== e[s.softDelete.archivedField] && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
459
|
+
!Se("Delete", d) && (p = !1, O = "Authenticated user does not have Delete or Restore access to this document"), a && (i && !jn(d) && (p = !1, O = "Authenticated user does not have Auth access for this collection"), Ps("update", f, t, s, r, i, o, l, c, e, a) || (O = "Authenticated user does not have sufficient write access for this record", p = !1));
|
|
460
|
+
for (const y of h) {
|
|
461
|
+
const g = n[y.name];
|
|
462
|
+
y.access && !Zn(y, o) && g !== void 0 && (O = `Authenticated user does not have access to field ${y.name}`, p = !1), g !== void 0 && !ri(y, o) && (O = `Authenticated user does not have Update access to field ${y.name}`, p = !1);
|
|
463
463
|
}
|
|
464
|
-
if (!
|
|
464
|
+
if (!p)
|
|
465
465
|
throw O && console.error(`PERMISSION_DENIED: ${O}`), new Error("PERMISSION_DENIED");
|
|
466
466
|
}, Go = (n, e, t, s, r, i) => {
|
|
467
467
|
const { labels: o } = t, a = i.collections?.[o.collection];
|
|
@@ -581,7 +581,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
581
581
|
for (const l of a)
|
|
582
582
|
if (K(l) && l.collection === r.collection && l.dependencyFields)
|
|
583
583
|
for (const c of l.dependencyFields)
|
|
584
|
-
c.field
|
|
584
|
+
c.field === n.name && (i = !0);
|
|
585
585
|
}
|
|
586
586
|
return i;
|
|
587
587
|
}, ci = (n, e) => {
|
|
@@ -596,7 +596,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
596
596
|
});
|
|
597
597
|
});
|
|
598
598
|
}), r;
|
|
599
|
-
}, Kn = (n) => JSON.stringify(n.map((e) => e.name)),
|
|
599
|
+
}, Kn = (n) => JSON.stringify(n.map((e) => e.name)), pt = [
|
|
600
600
|
"id",
|
|
601
601
|
"Collection_Path",
|
|
602
602
|
"Last_Write_At",
|
|
@@ -608,7 +608,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
608
608
|
"Created_At",
|
|
609
609
|
"Saved_At",
|
|
610
610
|
"Created_By"
|
|
611
|
-
], zn = () =>
|
|
611
|
+
], zn = () => pt.map((n) => {
|
|
612
612
|
let e = "", t;
|
|
613
613
|
switch (n) {
|
|
614
614
|
case "id":
|
|
@@ -704,17 +704,17 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
704
704
|
}), r?.filter((c) => (!c.roles || c.roles.includes(e)) && c.field !== "Collection_Path").forEach((c) => {
|
|
705
705
|
t.push(W(a, c.field));
|
|
706
706
|
}), i?.range && i.range.fields.forEach((c) => {
|
|
707
|
-
|
|
707
|
+
pt.includes(c) && t.push(W(a, c));
|
|
708
708
|
}), o?.forEach((c) => {
|
|
709
709
|
const u = W(s.concat(a), c.field);
|
|
710
|
-
(!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) &&
|
|
710
|
+
(!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(W(a, c.field));
|
|
711
711
|
}), ui(n, e).forEach((c) => {
|
|
712
|
-
|
|
712
|
+
pt.includes(c.name) && t.push(W(a, c.name));
|
|
713
713
|
}), [...new Set(t)];
|
|
714
714
|
}, ta = (n, e, t) => {
|
|
715
715
|
const s = [], { fields: r, preloadCache: i } = e, o = zn();
|
|
716
716
|
i?.range && i.range.fields.forEach((c) => {
|
|
717
|
-
|
|
717
|
+
pt.includes(c) ? s.push(W(o, c)) : s.push(W(r, c));
|
|
718
718
|
});
|
|
719
719
|
const a = /* @__PURE__ */ new Set(), l = ci(e, t);
|
|
720
720
|
return Object.entries(l).map(([c, u]) => {
|
|
@@ -794,7 +794,7 @@ const jn = (n) => !!n.auth, Se = (n, e) => {
|
|
|
794
794
|
Last_Save_At: n.Last_Save_At
|
|
795
795
|
}), Xn = async (n, e, t) => {
|
|
796
796
|
if (e) {
|
|
797
|
-
const s = await ie(e, t);
|
|
797
|
+
const s = await ie(e, [t]);
|
|
798
798
|
if (s === !1)
|
|
799
799
|
throw new Error(`CANCELLED: Operation cancelled by ${n}`);
|
|
800
800
|
return s;
|
|
@@ -807,7 +807,7 @@ async function oe(n, e, t, s) {
|
|
|
807
807
|
if (n !== "setEmbedding" && (await Xn(n, e?.[n], s), n === "postWriteError"))
|
|
808
808
|
return r;
|
|
809
809
|
}
|
|
810
|
-
const Vs = (n, e, t, s, r, i, o, a, l, c) => (n
|
|
810
|
+
const Vs = (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), ft = (n, e) => {
|
|
811
811
|
const { access: t, queries: s } = n, { serverReadOnly: r } = t, i = /* @__PURE__ */ new Set();
|
|
812
812
|
if (s)
|
|
813
813
|
for (const o of s) {
|
|
@@ -1032,7 +1032,7 @@ class He extends Error {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
}
|
|
1034
1034
|
He.create = (n) => new He(n);
|
|
1035
|
-
const
|
|
1035
|
+
const ys = (n, e) => {
|
|
1036
1036
|
let t;
|
|
1037
1037
|
switch (n.code) {
|
|
1038
1038
|
case D.invalid_type:
|
|
@@ -1088,7 +1088,7 @@ const ps = (n, e) => {
|
|
|
1088
1088
|
}
|
|
1089
1089
|
return { message: t };
|
|
1090
1090
|
};
|
|
1091
|
-
let ra =
|
|
1091
|
+
let ra = ys;
|
|
1092
1092
|
function ia() {
|
|
1093
1093
|
return ra;
|
|
1094
1094
|
}
|
|
@@ -1125,7 +1125,7 @@ function F(n, e) {
|
|
|
1125
1125
|
// then schema-bound map if available
|
|
1126
1126
|
t,
|
|
1127
1127
|
// then global override map
|
|
1128
|
-
t ===
|
|
1128
|
+
t === ys ? void 0 : ys
|
|
1129
1129
|
// then global default map
|
|
1130
1130
|
].filter((r) => !!r)
|
|
1131
1131
|
});
|
|
@@ -1431,9 +1431,9 @@ class X {
|
|
|
1431
1431
|
return this.safeParse(null).success;
|
|
1432
1432
|
}
|
|
1433
1433
|
}
|
|
1434
|
-
const aa = /^c[^\s-]{8,}$/i, la = /^[0-9a-z]+$/, ca = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ua = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, da = /^[a-z0-9_-]{21}$/i, fa = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ha = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, ma = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,
|
|
1434
|
+
const aa = /^c[^\s-]{8,}$/i, la = /^[0-9a-z]+$/, ca = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ua = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, da = /^[a-z0-9_-]{21}$/i, fa = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ha = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, ma = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, pa = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1435
1435
|
let es;
|
|
1436
|
-
const
|
|
1436
|
+
const ya = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, ga = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, wa = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, _a = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Ea = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, va = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, hi = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Oa = new RegExp(`^${hi}$`);
|
|
1437
1437
|
function mi(n) {
|
|
1438
1438
|
let e = "[0-5]\\d";
|
|
1439
1439
|
n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
@@ -1449,7 +1449,7 @@ function ba(n) {
|
|
|
1449
1449
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
1450
1450
|
}
|
|
1451
1451
|
function Sa(n, e) {
|
|
1452
|
-
return !!((e === "v4" || !e) &&
|
|
1452
|
+
return !!((e === "v4" || !e) && ya.test(n) || (e === "v6" || !e) && wa.test(n));
|
|
1453
1453
|
}
|
|
1454
1454
|
function Ta(n, e) {
|
|
1455
1455
|
if (!fa.test(n))
|
|
@@ -1522,7 +1522,7 @@ class Be extends X {
|
|
|
1522
1522
|
message: i.message
|
|
1523
1523
|
}), s.dirty());
|
|
1524
1524
|
else if (i.kind === "emoji")
|
|
1525
|
-
es || (es = new RegExp(
|
|
1525
|
+
es || (es = new RegExp(pa, "u")), es.test(e.data) || (r = this._getOrReturnCtx(e, r), F(r, {
|
|
1526
1526
|
validation: "emoji",
|
|
1527
1527
|
code: D.invalid_string,
|
|
1528
1528
|
message: i.message
|
|
@@ -2448,7 +2448,7 @@ function bt(n) {
|
|
|
2448
2448
|
} else return n instanceof Ue ? new Ue({
|
|
2449
2449
|
...n._def,
|
|
2450
2450
|
type: bt(n.element)
|
|
2451
|
-
}) : n instanceof st ? st.create(bt(n.unwrap())) : n instanceof Ct ? Ct.create(bt(n.unwrap())) : n instanceof
|
|
2451
|
+
}) : n instanceof st ? st.create(bt(n.unwrap())) : n instanceof Ct ? Ct.create(bt(n.unwrap())) : n instanceof yt ? yt.create(n.items.map((e) => bt(e))) : n;
|
|
2452
2452
|
}
|
|
2453
2453
|
class ue extends X {
|
|
2454
2454
|
constructor() {
|
|
@@ -2713,7 +2713,7 @@ class ue extends X {
|
|
|
2713
2713
|
});
|
|
2714
2714
|
}
|
|
2715
2715
|
keyof() {
|
|
2716
|
-
return
|
|
2716
|
+
return pi(ne.objectKeys(this.shape));
|
|
2717
2717
|
}
|
|
2718
2718
|
}
|
|
2719
2719
|
ue.create = (n, e) => new ue({
|
|
@@ -2874,7 +2874,7 @@ Dn.create = (n, e, t) => new Dn({
|
|
|
2874
2874
|
typeName: G.ZodIntersection,
|
|
2875
2875
|
...J(t)
|
|
2876
2876
|
});
|
|
2877
|
-
class
|
|
2877
|
+
class yt extends X {
|
|
2878
2878
|
_parse(e) {
|
|
2879
2879
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2880
2880
|
if (s.parsedType !== U.array)
|
|
@@ -2908,16 +2908,16 @@ class pt extends X {
|
|
|
2908
2908
|
return this._def.items;
|
|
2909
2909
|
}
|
|
2910
2910
|
rest(e) {
|
|
2911
|
-
return new
|
|
2911
|
+
return new yt({
|
|
2912
2912
|
...this._def,
|
|
2913
2913
|
rest: e
|
|
2914
2914
|
});
|
|
2915
2915
|
}
|
|
2916
2916
|
}
|
|
2917
|
-
|
|
2917
|
+
yt.create = (n, e) => {
|
|
2918
2918
|
if (!Array.isArray(n))
|
|
2919
2919
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2920
|
-
return new
|
|
2920
|
+
return new yt({
|
|
2921
2921
|
items: n,
|
|
2922
2922
|
typeName: G.ZodTuple,
|
|
2923
2923
|
rest: null,
|
|
@@ -3112,7 +3112,7 @@ vs.create = (n, e) => new vs({
|
|
|
3112
3112
|
typeName: G.ZodLiteral,
|
|
3113
3113
|
...J(e)
|
|
3114
3114
|
});
|
|
3115
|
-
function
|
|
3115
|
+
function pi(n, e) {
|
|
3116
3116
|
return new Dt({
|
|
3117
3117
|
values: n,
|
|
3118
3118
|
typeName: G.ZodEnum,
|
|
@@ -3173,7 +3173,7 @@ class Dt extends X {
|
|
|
3173
3173
|
});
|
|
3174
3174
|
}
|
|
3175
3175
|
}
|
|
3176
|
-
Dt.create =
|
|
3176
|
+
Dt.create = pi;
|
|
3177
3177
|
class mr extends X {
|
|
3178
3178
|
_parse(e) {
|
|
3179
3179
|
const t = ne.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
@@ -3409,7 +3409,7 @@ ks.create = (n, e) => new ks({
|
|
|
3409
3409
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3410
3410
|
...J(e)
|
|
3411
3411
|
});
|
|
3412
|
-
class
|
|
3412
|
+
class pr extends X {
|
|
3413
3413
|
_parse(e) {
|
|
3414
3414
|
if (this._getType(e) !== U.nan) {
|
|
3415
3415
|
const s = this._getOrReturnCtx(e);
|
|
@@ -3422,7 +3422,7 @@ class yr extends X {
|
|
|
3422
3422
|
return { status: "valid", value: e.data };
|
|
3423
3423
|
}
|
|
3424
3424
|
}
|
|
3425
|
-
|
|
3425
|
+
pr.create = (n) => new pr({
|
|
3426
3426
|
typeName: G.ZodNaN,
|
|
3427
3427
|
...J(n)
|
|
3428
3428
|
});
|
|
@@ -3497,25 +3497,25 @@ var G;
|
|
|
3497
3497
|
(function(n) {
|
|
3498
3498
|
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";
|
|
3499
3499
|
})(G || (G = {}));
|
|
3500
|
-
const be = Be.create, ht = Nt.create, Qt = gs.create, ts = ws.create,
|
|
3500
|
+
const be = Be.create, ht = Nt.create, Qt = gs.create, ts = ws.create, pe = _s.create;
|
|
3501
3501
|
ot.create;
|
|
3502
3502
|
const _t = Ue.create, We = ue.create, Oe = Nn.create;
|
|
3503
3503
|
Dn.create;
|
|
3504
|
-
|
|
3504
|
+
yt.create;
|
|
3505
3505
|
const sn = An.create, ke = vs.create, $n = Dt.create;
|
|
3506
3506
|
Cn.create;
|
|
3507
3507
|
st.create;
|
|
3508
3508
|
Ct.create;
|
|
3509
|
-
const wn = () =>
|
|
3509
|
+
const wn = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds !== void 0 || n._seconds !== void 0 && n._nanoseconds !== void 0), {
|
|
3510
3510
|
message: "Value is not a valid timestamp"
|
|
3511
|
-
}),
|
|
3511
|
+
}), yr = () => pe().refine((n) => n && (n._methodName === "serverTimestamp" || n.constructor.name === "ServerTimestampTransform"), {
|
|
3512
3512
|
message: "Value is not a valid server timestamp"
|
|
3513
|
-
}),
|
|
3513
|
+
}), yi = (n, e, t) => {
|
|
3514
3514
|
const s = {};
|
|
3515
3515
|
if (n.includeFields) {
|
|
3516
3516
|
const i = e.collections[n.collection];
|
|
3517
3517
|
if (!i)
|
|
3518
|
-
return sn(
|
|
3518
|
+
return sn(pe());
|
|
3519
3519
|
n.includeFields.forEach((o) => {
|
|
3520
3520
|
const a = i.fields.find((c) => c.name === o);
|
|
3521
3521
|
if (!a)
|
|
@@ -3529,7 +3529,7 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3529
3529
|
};
|
|
3530
3530
|
return t && (r.id = be().length(20)), We(r);
|
|
3531
3531
|
}, Na = (n, e) => {
|
|
3532
|
-
let t = sn(
|
|
3532
|
+
let t = sn(yi(n, e));
|
|
3533
3533
|
return n.required || (t = t.optional()), t;
|
|
3534
3534
|
}, Da = (n) => {
|
|
3535
3535
|
let e = _t(Oe([be().length(20), be().length(28)]));
|
|
@@ -3557,7 +3557,7 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3557
3557
|
})));
|
|
3558
3558
|
break;
|
|
3559
3559
|
case "Timestamp":
|
|
3560
|
-
e.name === r ? i =
|
|
3560
|
+
e.name === r ? i = pe().refine((o) => o && (o._methodName === "serverTimestamp" || o.constructor.name === "ServerTimestampTransform" || o.seconds !== void 0 && o.nanoseconds !== void 0 || o._seconds !== void 0 && o._nanoseconds !== void 0), {
|
|
3561
3561
|
message: "Value is not a valid timestamp"
|
|
3562
3562
|
}) : (i = wn(), e.min && (i = i.refine((o) => o.toMillis() >= e.min, {
|
|
3563
3563
|
message: `Value is less than the minimum allowed value of ${e.min}`
|
|
@@ -3566,7 +3566,7 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3566
3566
|
})));
|
|
3567
3567
|
break;
|
|
3568
3568
|
case "Array":
|
|
3569
|
-
i = _t(
|
|
3569
|
+
i = _t(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) => {
|
|
3570
3570
|
let a = !0;
|
|
3571
3571
|
return o.forEach((l) => {
|
|
3572
3572
|
e.values && !e.values.includes(l) && (a = !1);
|
|
@@ -3574,12 +3574,12 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3574
3574
|
}, { message: "Value is not an allowed value" }));
|
|
3575
3575
|
break;
|
|
3576
3576
|
case "Map":
|
|
3577
|
-
i = sn(
|
|
3577
|
+
i = sn(pe()), e.required && (i = i.refine((o) => o && typeof o == "object" && Object.keys(o).length > 0, {
|
|
3578
3578
|
message: "Value must have at least one object property"
|
|
3579
3579
|
}));
|
|
3580
3580
|
break;
|
|
3581
3581
|
case "Embedding":
|
|
3582
|
-
i =
|
|
3582
|
+
i = pe();
|
|
3583
3583
|
break;
|
|
3584
3584
|
}
|
|
3585
3585
|
return !K(e) && e.nullable && (i = i.nullable()), e.required || (i = i.optional()), i;
|
|
@@ -3588,7 +3588,7 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3588
3588
|
Collection_Path: _t(be()),
|
|
3589
3589
|
Last_Write_App: be(),
|
|
3590
3590
|
Last_Write_At: wn(),
|
|
3591
|
-
Last_Save_At:
|
|
3591
|
+
Last_Save_At: yr(),
|
|
3592
3592
|
Last_Write_By: Oe([be().length(28), ke("System")]),
|
|
3593
3593
|
Last_Write_Connection_Status: $n(["Online", "Offline"]),
|
|
3594
3594
|
Last_Write_Version: ht().int(),
|
|
@@ -3596,10 +3596,10 @@ const wn = () => ye().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds
|
|
|
3596
3596
|
Created_At: wn(),
|
|
3597
3597
|
Created_By: Oe([be().length(28), ke("System")])
|
|
3598
3598
|
};
|
|
3599
|
-
n === "create" && (s.Saved_At =
|
|
3599
|
+
n === "create" && (s.Saved_At = yr()), n === "update" && (s.Saved_At = wn(), 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());
|
|
3600
3600
|
const r = ft(e, e.fields), i = Array.from(r).map((l) => l.name);
|
|
3601
3601
|
e.fields.forEach((l) => {
|
|
3602
|
-
K(l) ? (s[l.name] = Na(l, t), s[`${l.name}_Array`] = Da(l), i.includes(l.name) && (s[`${l.name}_Single`] =
|
|
3602
|
+
K(l) ? (s[l.name] = Na(l, t), s[`${l.name}_Array`] = Da(l), i.includes(l.name) && (s[`${l.name}_Single`] = yi(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, {
|
|
3603
3603
|
message: `Value must contain ${l.length} item(s)`
|
|
3604
3604
|
})), l.min && (s[l.name] = s[l.name].refine((c) => l.min && c && Object.keys(c).length >= l.min, {
|
|
3605
3605
|
message: `Value must contain at least ${l.min} item(s)`
|
|
@@ -3636,7 +3636,7 @@ class gi extends Et {
|
|
|
3636
3636
|
super(`Invalid unit ${e}`);
|
|
3637
3637
|
}
|
|
3638
3638
|
}
|
|
3639
|
-
class
|
|
3639
|
+
class ye extends Et {
|
|
3640
3640
|
}
|
|
3641
3641
|
class Ke extends Et {
|
|
3642
3642
|
constructor() {
|
|
@@ -4050,8 +4050,8 @@ class Ge extends rn {
|
|
|
4050
4050
|
millisecond: 0
|
|
4051
4051
|
});
|
|
4052
4052
|
let f = +t;
|
|
4053
|
-
const
|
|
4054
|
-
return f -=
|
|
4053
|
+
const p = f % 1e3;
|
|
4054
|
+
return f -= p >= 0 ? p : 1e3 + p, (d - f) / (60 * 1e3);
|
|
4055
4055
|
}
|
|
4056
4056
|
/**
|
|
4057
4057
|
* Return whether this Zone is equal to another zone
|
|
@@ -4868,9 +4868,9 @@ function Cs(n) {
|
|
|
4868
4868
|
if (n == null)
|
|
4869
4869
|
return null;
|
|
4870
4870
|
if (typeof n != "object")
|
|
4871
|
-
throw new
|
|
4871
|
+
throw new ye("Week settings must be an object");
|
|
4872
4872
|
if (!Ne(n.firstDay, 1, 7) || !Ne(n.minimalDays, 1, 7) || !Array.isArray(n.weekend) || n.weekend.some((e) => !Ne(e, 1, 7)))
|
|
4873
|
-
throw new
|
|
4873
|
+
throw new ye("Invalid week settings");
|
|
4874
4874
|
return {
|
|
4875
4875
|
firstDay: n.firstDay,
|
|
4876
4876
|
minimalDays: n.minimalDays,
|
|
@@ -4973,7 +4973,7 @@ function Gn(n, e) {
|
|
|
4973
4973
|
function Gi(n) {
|
|
4974
4974
|
const e = Number(n);
|
|
4975
4975
|
if (typeof n == "boolean" || n === "" || !Number.isFinite(e))
|
|
4976
|
-
throw new
|
|
4976
|
+
throw new ye(`Invalid unit value ${n}`);
|
|
4977
4977
|
return e;
|
|
4978
4978
|
}
|
|
4979
4979
|
function Vn(n, e) {
|
|
@@ -5068,15 +5068,15 @@ function Xi(n) {
|
|
|
5068
5068
|
return null;
|
|
5069
5069
|
}
|
|
5070
5070
|
}
|
|
5071
|
-
const eo = ["AM", "PM"],
|
|
5071
|
+
const eo = ["AM", "PM"], pl = ["Before Christ", "Anno Domini"], yl = ["BC", "AD"], gl = ["B", "A"];
|
|
5072
5072
|
function to(n) {
|
|
5073
5073
|
switch (n) {
|
|
5074
5074
|
case "narrow":
|
|
5075
5075
|
return [...gl];
|
|
5076
5076
|
case "short":
|
|
5077
|
-
return [...pl];
|
|
5078
|
-
case "long":
|
|
5079
5077
|
return [...yl];
|
|
5078
|
+
case "long":
|
|
5079
|
+
return [...pl];
|
|
5080
5080
|
default:
|
|
5081
5081
|
return null;
|
|
5082
5082
|
}
|
|
@@ -5193,12 +5193,12 @@ class ge {
|
|
|
5193
5193
|
return t > 0 && (r.padTo = t), s && (r.signDisplay = s), this.loc.numberFormatter(r).format(e);
|
|
5194
5194
|
}
|
|
5195
5195
|
formatDateTimeFromString(e, t) {
|
|
5196
|
-
const s = this.loc.listingMode() === "en", r = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory", i = (f,
|
|
5197
|
-
|
|
5196
|
+
const s = this.loc.listingMode() === "en", r = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory", i = (f, p) => this.loc.extract(e, f, p), o = (f) => e.isOffsetFixed && e.offset === 0 && f.allowZ ? "Z" : e.isValid ? e.zone.formatOffset(e.ts, f.format) : "", a = () => s ? wl(e) : i({ hour: "numeric", hourCycle: "h12" }, "dayperiod"), l = (f, p) => s ? El(e, f) : i(p ? { month: f } : { month: f, day: "numeric" }, "month"), c = (f, p) => s ? _l(e, f) : i(
|
|
5197
|
+
p ? { weekday: f } : { weekday: f, month: "long", day: "numeric" },
|
|
5198
5198
|
"weekday"
|
|
5199
5199
|
), u = (f) => {
|
|
5200
|
-
const
|
|
5201
|
-
return
|
|
5200
|
+
const p = ge.macroTokenToFormatOpts(f);
|
|
5201
|
+
return p ? this.formatWithSystemDefault(e, p) : f;
|
|
5202
5202
|
}, h = (f) => s ? vl(e, f) : i({ era: f }, "era"), d = (f) => {
|
|
5203
5203
|
switch (f) {
|
|
5204
5204
|
// ms
|
|
@@ -5369,9 +5369,9 @@ class ge {
|
|
|
5369
5369
|
}, i = (u, h) => (d) => {
|
|
5370
5370
|
const f = r(d);
|
|
5371
5371
|
if (f) {
|
|
5372
|
-
const
|
|
5372
|
+
const p = h.isNegativeDuration && f !== h.largestUnit ? s : 1;
|
|
5373
5373
|
let O;
|
|
5374
|
-
return this.opts.signMode === "negativeLargestOnly" && f !== h.largestUnit ? O = "never" : this.opts.signMode === "all" ? O = "always" : O = "auto", this.num(u.get(f) *
|
|
5374
|
+
return this.opts.signMode === "negativeLargestOnly" && f !== h.largestUnit ? O = "never" : this.opts.signMode === "all" ? O = "always" : O = "auto", this.num(u.get(f) * p, d.length, O);
|
|
5375
5375
|
} else
|
|
5376
5376
|
return d;
|
|
5377
5377
|
}, o = ge.parseFormat(t), a = o.reduce(
|
|
@@ -5451,7 +5451,7 @@ function ln(n, e) {
|
|
|
5451
5451
|
}
|
|
5452
5452
|
const Cl = RegExp(`^T?${Bs.source}$`), $l = /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;
|
|
5453
5453
|
function Ml(n) {
|
|
5454
|
-
const [e, t, s, r, i, o, a, l, c] = n, u = e[0] === "-", h = l && l[0] === "-", d = (f,
|
|
5454
|
+
const [e, t, s, r, i, o, a, l, c] = n, u = e[0] === "-", h = l && l[0] === "-", d = (f, p = !1) => f !== void 0 && (p || f && u) ? -f : f;
|
|
5455
5455
|
return [
|
|
5456
5456
|
{
|
|
5457
5457
|
years: d(ut(t)),
|
|
@@ -5746,7 +5746,7 @@ class te {
|
|
|
5746
5746
|
*/
|
|
5747
5747
|
static fromObject(e, t = {}) {
|
|
5748
5748
|
if (e == null || typeof e != "object")
|
|
5749
|
-
throw new
|
|
5749
|
+
throw new ye(
|
|
5750
5750
|
`Duration.fromObject: argument expected to be an object, got ${e === null ? "null" : typeof e}`
|
|
5751
5751
|
);
|
|
5752
5752
|
return new te({
|
|
@@ -5773,7 +5773,7 @@ class te {
|
|
|
5773
5773
|
return e;
|
|
5774
5774
|
if (typeof e == "object")
|
|
5775
5775
|
return te.fromObject(e);
|
|
5776
|
-
throw new
|
|
5776
|
+
throw new ye(
|
|
5777
5777
|
`Unknown duration argument ${e} of type ${typeof e}`
|
|
5778
5778
|
);
|
|
5779
5779
|
}
|
|
@@ -5823,7 +5823,7 @@ class te {
|
|
|
5823
5823
|
*/
|
|
5824
5824
|
static invalid(e, t = null) {
|
|
5825
5825
|
if (!e)
|
|
5826
|
-
throw new
|
|
5826
|
+
throw new ye("need to specify a reason the Duration is invalid");
|
|
5827
5827
|
const s = e instanceof Pe ? e : new Pe(e, t);
|
|
5828
5828
|
if (le.throwOnInvalid)
|
|
5829
5829
|
throw new Ma(s);
|
|
@@ -6321,7 +6321,7 @@ class ae {
|
|
|
6321
6321
|
*/
|
|
6322
6322
|
static invalid(e, t = null) {
|
|
6323
6323
|
if (!e)
|
|
6324
|
-
throw new
|
|
6324
|
+
throw new ye("need to specify a reason the Interval is invalid");
|
|
6325
6325
|
const s = e instanceof Pe ? e : new Pe(e, t);
|
|
6326
6326
|
if (le.throwOnInvalid)
|
|
6327
6327
|
throw new $a(s);
|
|
@@ -6974,7 +6974,7 @@ function se(n, e = (t) => t) {
|
|
|
6974
6974
|
return { regex: n, deser: ([t]) => e(sl(t)) };
|
|
6975
6975
|
}
|
|
6976
6976
|
const mc = " ", uo = `[ ${mc}]`, fo = new RegExp(uo, "g");
|
|
6977
|
-
function
|
|
6977
|
+
function pc(n) {
|
|
6978
6978
|
return n.replace(/\./g, "\\.?").replace(fo, uo);
|
|
6979
6979
|
}
|
|
6980
6980
|
function Lr(n) {
|
|
@@ -6982,7 +6982,7 @@ function Lr(n) {
|
|
|
6982
6982
|
}
|
|
6983
6983
|
function Me(n, e) {
|
|
6984
6984
|
return n === null ? null : {
|
|
6985
|
-
regex: RegExp(n.map(
|
|
6985
|
+
regex: RegExp(n.map(pc).join("|")),
|
|
6986
6986
|
deser: ([t]) => n.findIndex((s) => Lr(t) === Lr(s)) + e
|
|
6987
6987
|
};
|
|
6988
6988
|
}
|
|
@@ -6992,14 +6992,14 @@ function Vr(n, e) {
|
|
|
6992
6992
|
function mn(n) {
|
|
6993
6993
|
return { regex: n, deser: ([e]) => e };
|
|
6994
6994
|
}
|
|
6995
|
-
function
|
|
6995
|
+
function yc(n) {
|
|
6996
6996
|
return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
6997
6997
|
}
|
|
6998
6998
|
function gc(n, e) {
|
|
6999
|
-
const t = $e(e), s = $e(e, "{2}"), r = $e(e, "{3}"), i = $e(e, "{4}"), o = $e(e, "{6}"), a = $e(e, "{1,2}"), l = $e(e, "{1,3}"), c = $e(e, "{1,6}"), u = $e(e, "{1,9}"), h = $e(e, "{2,4}"), d = $e(e, "{4,6}"), f = (
|
|
6999
|
+
const t = $e(e), s = $e(e, "{2}"), r = $e(e, "{3}"), i = $e(e, "{4}"), o = $e(e, "{6}"), a = $e(e, "{1,2}"), l = $e(e, "{1,3}"), c = $e(e, "{1,6}"), u = $e(e, "{1,9}"), h = $e(e, "{2,4}"), d = $e(e, "{4,6}"), f = (y) => ({ regex: RegExp(yc(y.val)), deser: ([g]) => g, literal: !0 }), O = ((y) => {
|
|
7000
7000
|
if (n.literal)
|
|
7001
|
-
return f(
|
|
7002
|
-
switch (
|
|
7001
|
+
return f(y);
|
|
7002
|
+
switch (y.val) {
|
|
7003
7003
|
// era
|
|
7004
7004
|
case "G":
|
|
7005
7005
|
return Me(e.eras("short"), 0);
|
|
@@ -7114,7 +7114,7 @@ function gc(n, e) {
|
|
|
7114
7114
|
case " ":
|
|
7115
7115
|
return mn(/[^\S\n\r]/);
|
|
7116
7116
|
default:
|
|
7117
|
-
return f(
|
|
7117
|
+
return f(y);
|
|
7118
7118
|
}
|
|
7119
7119
|
})(n) || {
|
|
7120
7120
|
invalidReason: hc
|
|
@@ -7246,7 +7246,7 @@ function kc() {
|
|
|
7246
7246
|
function bc(n, e) {
|
|
7247
7247
|
if (n.literal)
|
|
7248
7248
|
return n;
|
|
7249
|
-
const t = ge.macroTokenToFormatOpts(n.val), s =
|
|
7249
|
+
const t = ge.macroTokenToFormatOpts(n.val), s = yo(t, e);
|
|
7250
7250
|
return s == null || s.includes(void 0) ? n : s;
|
|
7251
7251
|
}
|
|
7252
7252
|
function ho(n, e) {
|
|
@@ -7286,14 +7286,14 @@ class mo {
|
|
|
7286
7286
|
return this.disqualifyingUnit ? this.disqualifyingUnit.invalidReason : null;
|
|
7287
7287
|
}
|
|
7288
7288
|
}
|
|
7289
|
-
function
|
|
7289
|
+
function po(n, e, t) {
|
|
7290
7290
|
return new mo(n, t).explainFromTokens(e);
|
|
7291
7291
|
}
|
|
7292
7292
|
function Sc(n, e, t) {
|
|
7293
|
-
const { result: s, zone: r, specificOffset: i, invalidReason: o } =
|
|
7293
|
+
const { result: s, zone: r, specificOffset: i, invalidReason: o } = po(n, e, t);
|
|
7294
7294
|
return [s, r, i, o];
|
|
7295
7295
|
}
|
|
7296
|
-
function
|
|
7296
|
+
function yo(n, e) {
|
|
7297
7297
|
if (!n)
|
|
7298
7298
|
return null;
|
|
7299
7299
|
const s = ge.create(e, n).dtFormatter(kc()), r = s.formatToParts(), i = s.resolvedOptions();
|
|
@@ -7333,7 +7333,7 @@ function go(n, e, t) {
|
|
|
7333
7333
|
const i = t.offset(s);
|
|
7334
7334
|
return r === i ? [s, r] : [n - Math.min(r, i) * 60 * 1e3, Math.max(r, i)];
|
|
7335
7335
|
}
|
|
7336
|
-
function
|
|
7336
|
+
function pn(n, e) {
|
|
7337
7337
|
n += e * 60 * 1e3;
|
|
7338
7338
|
const t = new Date(n);
|
|
7339
7339
|
return {
|
|
@@ -7383,7 +7383,7 @@ function kt(n, e, t, s, r, i) {
|
|
|
7383
7383
|
new Pe("unparsable", `the input "${r}" can't be parsed as ${s}`)
|
|
7384
7384
|
);
|
|
7385
7385
|
}
|
|
7386
|
-
function
|
|
7386
|
+
function yn(n, e, t = !0) {
|
|
7387
7387
|
return n.isValid ? ge.create(re.create("en-US"), {
|
|
7388
7388
|
allowZ: t,
|
|
7389
7389
|
forceSimple: !0
|
|
@@ -7551,7 +7551,7 @@ class V {
|
|
|
7551
7551
|
[r, i] = [e.old.c, e.old.o];
|
|
7552
7552
|
else {
|
|
7553
7553
|
const a = rt(e.o) && !e.old ? e.o : t.offset(this.ts);
|
|
7554
|
-
r =
|
|
7554
|
+
r = pn(this.ts, a), s = Number.isNaN(r.year) ? new Pe("invalid input") : null, r = s ? null : r, i = s ? null : a;
|
|
7555
7555
|
}
|
|
7556
7556
|
this._zone = t, this.loc = e.loc || re.create(), this.invalid = s, this.weekData = null, this.localWeekData = null, this.c = r, this.o = i, this.isLuxonDateTime = !0;
|
|
7557
7557
|
}
|
|
@@ -7656,7 +7656,7 @@ class V {
|
|
|
7656
7656
|
zone: tt(t.zone, le.defaultZone),
|
|
7657
7657
|
loc: re.fromObject(t)
|
|
7658
7658
|
});
|
|
7659
|
-
throw new
|
|
7659
|
+
throw new ye(
|
|
7660
7660
|
`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`
|
|
7661
7661
|
);
|
|
7662
7662
|
}
|
|
@@ -7678,7 +7678,7 @@ class V {
|
|
|
7678
7678
|
zone: tt(t.zone, le.defaultZone),
|
|
7679
7679
|
loc: re.fromObject(t)
|
|
7680
7680
|
});
|
|
7681
|
-
throw new
|
|
7681
|
+
throw new ye("fromSeconds requires a numerical input");
|
|
7682
7682
|
}
|
|
7683
7683
|
/**
|
|
7684
7684
|
* Create a DateTime from a JavaScript object with keys like 'year' and 'hour' with reasonable defaults.
|
|
@@ -7718,18 +7718,18 @@ class V {
|
|
|
7718
7718
|
const s = tt(t.zone, le.defaultZone);
|
|
7719
7719
|
if (!s.isValid)
|
|
7720
7720
|
return V.invalid(Ht(s));
|
|
7721
|
-
const r = re.fromObject(t), i = Vn(e, Zr), { minDaysInFirstWeek: o, startOfWeek: a } = xr(i, r), l = le.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, u = !H(i.ordinal), h = !H(i.year), d = !H(i.month) || !H(i.day), f = h || d,
|
|
7722
|
-
if ((f || u) &&
|
|
7721
|
+
const r = re.fromObject(t), i = Vn(e, Zr), { minDaysInFirstWeek: o, startOfWeek: a } = xr(i, r), l = le.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, u = !H(i.ordinal), h = !H(i.year), d = !H(i.month) || !H(i.day), f = h || d, p = i.weekYear || i.weekNumber;
|
|
7722
|
+
if ((f || u) && p)
|
|
7723
7723
|
throw new St(
|
|
7724
7724
|
"Can't mix weekYear/weekNumber units with year/month/day or ordinals"
|
|
7725
7725
|
);
|
|
7726
7726
|
if (d && u)
|
|
7727
7727
|
throw new St("Can't mix ordinal dates with month/day");
|
|
7728
|
-
const O =
|
|
7729
|
-
let
|
|
7730
|
-
O ? (
|
|
7728
|
+
const O = p || i.weekday && !f;
|
|
7729
|
+
let y, g, N = pn(l, c);
|
|
7730
|
+
O ? (y = Ic, g = Tc, N = Pn(N, o, a)) : u ? (y = xc, g = Rc, N = is(N)) : (y = En, g = wo);
|
|
7731
7731
|
let b = !1;
|
|
7732
|
-
for (const m of
|
|
7732
|
+
for (const m of y) {
|
|
7733
7733
|
const M = i[m];
|
|
7734
7734
|
H(M) ? b ? i[m] = g[m] : i[m] = N[m] : b = !0;
|
|
7735
7735
|
}
|
|
@@ -7823,7 +7823,7 @@ class V {
|
|
|
7823
7823
|
*/
|
|
7824
7824
|
static fromFormat(e, t, s = {}) {
|
|
7825
7825
|
if (H(e) || H(t))
|
|
7826
|
-
throw new
|
|
7826
|
+
throw new ye("fromFormat requires an input string and a format");
|
|
7827
7827
|
const { locale: r = null, numberingSystem: i = null } = s, o = re.fromOpts({
|
|
7828
7828
|
locale: r,
|
|
7829
7829
|
numberingSystem: i,
|
|
@@ -7870,7 +7870,7 @@ class V {
|
|
|
7870
7870
|
*/
|
|
7871
7871
|
static invalid(e, t = null) {
|
|
7872
7872
|
if (!e)
|
|
7873
|
-
throw new
|
|
7873
|
+
throw new ye("need to specify a reason the DateTime is invalid");
|
|
7874
7874
|
const s = e instanceof Pe ? e : new Pe(e, t);
|
|
7875
7875
|
if (le.throwOnInvalid)
|
|
7876
7876
|
throw new Ca(s);
|
|
@@ -7891,7 +7891,7 @@ class V {
|
|
|
7891
7891
|
* @returns {string}
|
|
7892
7892
|
*/
|
|
7893
7893
|
static parseFormatForOpts(e, t = {}) {
|
|
7894
|
-
const s =
|
|
7894
|
+
const s = yo(e, re.fromObject(t));
|
|
7895
7895
|
return s ? s.map((r) => r ? r.val : null).join("") : null;
|
|
7896
7896
|
}
|
|
7897
7897
|
/**
|
|
@@ -8206,7 +8206,7 @@ class V {
|
|
|
8206
8206
|
const e = 864e5, t = 6e4, s = Hn(this.c), r = this.zone.offset(s - e), i = this.zone.offset(s + e), o = this.zone.offset(s - r * t), a = this.zone.offset(s - i * t);
|
|
8207
8207
|
if (o === a)
|
|
8208
8208
|
return [this];
|
|
8209
|
-
const l = s - o * t, c = s - a * t, u =
|
|
8209
|
+
const l = s - o * t, c = s - a * t, u = pn(l, o), h = pn(c, a);
|
|
8210
8210
|
return u.hour === h.hour && u.minute === h.minute && u.second === h.second && u.millisecond === h.millisecond ? [dt(this, { ts: l }), dt(this, { ts: c })] : [this];
|
|
8211
8211
|
}
|
|
8212
8212
|
/**
|
|
@@ -8571,7 +8571,7 @@ class V {
|
|
|
8571
8571
|
* @return {string}
|
|
8572
8572
|
*/
|
|
8573
8573
|
toISOWeekDate() {
|
|
8574
|
-
return
|
|
8574
|
+
return yn(this, "kkkk-'W'WW-c");
|
|
8575
8575
|
}
|
|
8576
8576
|
/**
|
|
8577
8577
|
* Returns an ISO 8601-compliant string representation of this DateTime's time component
|
|
@@ -8616,7 +8616,7 @@ class V {
|
|
|
8616
8616
|
* @return {string}
|
|
8617
8617
|
*/
|
|
8618
8618
|
toRFC2822() {
|
|
8619
|
-
return
|
|
8619
|
+
return yn(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", !1);
|
|
8620
8620
|
}
|
|
8621
8621
|
/**
|
|
8622
8622
|
* Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT.
|
|
@@ -8627,7 +8627,7 @@ class V {
|
|
|
8627
8627
|
* @return {string}
|
|
8628
8628
|
*/
|
|
8629
8629
|
toHTTP() {
|
|
8630
|
-
return
|
|
8630
|
+
return yn(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
|
|
8631
8631
|
}
|
|
8632
8632
|
/**
|
|
8633
8633
|
* Returns a string representation of this DateTime appropriate for use in SQL Date
|
|
@@ -8651,7 +8651,7 @@ class V {
|
|
|
8651
8651
|
*/
|
|
8652
8652
|
toSQLTime({ includeOffset: e = !0, includeZone: t = !1, includeOffsetSpace: s = !0 } = {}) {
|
|
8653
8653
|
let r = "HH:mm:ss.SSS";
|
|
8654
|
-
return (t || e) && (s && (r += " "), t ? r += "z" : e && (r += "ZZ")),
|
|
8654
|
+
return (t || e) && (s && (r += " "), t ? r += "z" : e && (r += "ZZ")), yn(this, r, !0);
|
|
8655
8655
|
}
|
|
8656
8656
|
/**
|
|
8657
8657
|
* Returns a string representation of this DateTime appropriate for use in SQL DateTime
|
|
@@ -8868,7 +8868,7 @@ class V {
|
|
|
8868
8868
|
*/
|
|
8869
8869
|
static min(...e) {
|
|
8870
8870
|
if (!e.every(V.isDateTime))
|
|
8871
|
-
throw new
|
|
8871
|
+
throw new ye("min requires all arguments be DateTimes");
|
|
8872
8872
|
return Nr(e, (t) => t.valueOf(), Math.min);
|
|
8873
8873
|
}
|
|
8874
8874
|
/**
|
|
@@ -8878,7 +8878,7 @@ class V {
|
|
|
8878
8878
|
*/
|
|
8879
8879
|
static max(...e) {
|
|
8880
8880
|
if (!e.every(V.isDateTime))
|
|
8881
|
-
throw new
|
|
8881
|
+
throw new ye("max requires all arguments be DateTimes");
|
|
8882
8882
|
return Nr(e, (t) => t.valueOf(), Math.max);
|
|
8883
8883
|
}
|
|
8884
8884
|
// MISC
|
|
@@ -8895,7 +8895,7 @@ class V {
|
|
|
8895
8895
|
numberingSystem: i,
|
|
8896
8896
|
defaultToEN: !0
|
|
8897
8897
|
});
|
|
8898
|
-
return
|
|
8898
|
+
return po(o, e, t);
|
|
8899
8899
|
}
|
|
8900
8900
|
/**
|
|
8901
8901
|
* @deprecated use fromFormatExplain instead
|
|
@@ -8935,7 +8935,7 @@ class V {
|
|
|
8935
8935
|
*/
|
|
8936
8936
|
static fromFormatParser(e, t, s = {}) {
|
|
8937
8937
|
if (H(e) || H(t))
|
|
8938
|
-
throw new
|
|
8938
|
+
throw new ye(
|
|
8939
8939
|
"fromFormatParser requires an input string and a format parser"
|
|
8940
8940
|
);
|
|
8941
8941
|
const { locale: r = null, numberingSystem: i = null } = s, o = re.fromOpts({
|
|
@@ -8944,7 +8944,7 @@ class V {
|
|
|
8944
8944
|
defaultToEN: !0
|
|
8945
8945
|
});
|
|
8946
8946
|
if (!o.equals(t.locale))
|
|
8947
|
-
throw new
|
|
8947
|
+
throw new ye(
|
|
8948
8948
|
`fromFormatParser called with a locale of ${o}, but the format parser was created for ${t.locale}`
|
|
8949
8949
|
);
|
|
8950
8950
|
const { result: a, zone: l, specificOffset: c, invalidReason: u } = t.explainFromTokens(e);
|
|
@@ -9120,7 +9120,7 @@ function Zt(n) {
|
|
|
9120
9120
|
return V.fromJSDate(n);
|
|
9121
9121
|
if (n && typeof n == "object")
|
|
9122
9122
|
return V.fromObject(n);
|
|
9123
|
-
throw new
|
|
9123
|
+
throw new ye(
|
|
9124
9124
|
`Unknown datetime argument: ${n}, of type ${typeof n}`
|
|
9125
9125
|
);
|
|
9126
9126
|
}
|
|
@@ -9129,10 +9129,10 @@ const Dc = (n, e) => {
|
|
|
9129
9129
|
if (n.includeFields) {
|
|
9130
9130
|
const s = e.collections[n.collection];
|
|
9131
9131
|
if (!s)
|
|
9132
|
-
return sn(
|
|
9132
|
+
return sn(pe());
|
|
9133
9133
|
n.includeFields.forEach((r) => {
|
|
9134
9134
|
const i = s.fields.find((o) => o.name === r);
|
|
9135
|
-
i ? t[r] = _o(i)?.nullable() : t[r] =
|
|
9135
|
+
i ? t[r] = _o(i)?.nullable() : t[r] = pe();
|
|
9136
9136
|
});
|
|
9137
9137
|
}
|
|
9138
9138
|
return We({
|
|
@@ -9146,7 +9146,7 @@ const Dc = (n, e) => {
|
|
|
9146
9146
|
i = zt(o.admin?.skipFormRequiredValidation);
|
|
9147
9147
|
}
|
|
9148
9148
|
return (!n.required || i) && (r = r.optional()), r;
|
|
9149
|
-
}, Cc = () =>
|
|
9149
|
+
}, Cc = () => pe().refine((n) => n && (n.seconds !== void 0 && n.nanoseconds !== void 0 || n._seconds !== void 0 && n._nanoseconds !== void 0), {
|
|
9150
9150
|
message: "Must be a valid date"
|
|
9151
9151
|
}), _o = (n, e, t) => {
|
|
9152
9152
|
let s;
|
|
@@ -9197,7 +9197,7 @@ const Dc = (n, e) => {
|
|
|
9197
9197
|
})));
|
|
9198
9198
|
break;
|
|
9199
9199
|
case "Array":
|
|
9200
|
-
s = _t(
|
|
9200
|
+
s = _t(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) => {
|
|
9201
9201
|
let c = !0;
|
|
9202
9202
|
return l.forEach((u) => {
|
|
9203
9203
|
n.values && !n.values.includes(u) && (c = !1);
|
|
@@ -9205,12 +9205,12 @@ const Dc = (n, e) => {
|
|
|
9205
9205
|
}, { message: `Must only contain the following values: ${n.values.join(", ")}` })), s = s.describe(`${r}Must only contain the following values: ${n.values.join(", ")}`)) : r && (s = s.describe(r.trim())), n.nullable && (s = s.nullable());
|
|
9206
9206
|
break;
|
|
9207
9207
|
case "Map":
|
|
9208
|
-
n.required && !i ? t ? s = We({}).catchall(
|
|
9208
|
+
n.required && !i ? t ? s = We({}).catchall(pe()).describe(`${r}Must be an object. Must contain at least one object property.`) : s = sn(pe()).refine((l) => l && typeof l == "object" && Object.keys(l).length > 0, {
|
|
9209
9209
|
message: "Must not be an empty value"
|
|
9210
|
-
}) : s = We({}).catchall(
|
|
9210
|
+
}) : s = We({}).catchall(pe()).describe(`${r}Must be an object`);
|
|
9211
9211
|
break;
|
|
9212
9212
|
case "Computed":
|
|
9213
|
-
s =
|
|
9213
|
+
s = pe();
|
|
9214
9214
|
}
|
|
9215
9215
|
return (!n.required || i || o) && (s = s.optional()), s;
|
|
9216
9216
|
}, su = (n, e, t, s, r) => {
|
|
@@ -9227,9 +9227,9 @@ const Dc = (n, e) => {
|
|
|
9227
9227
|
a[`auth-${c.labels.collection}`] = Qt().optional(), a[`operations-${c.labels.collection}`] = _t(Oe([ke("Read"), ke("Create"), ke("Update"), ke("Delete")])).optional(), a[`restrict-${c.labels.collection}`] = Qt().optional(), c.access.attributeRestrictions?.forEach((u) => {
|
|
9228
9228
|
a[`attribute-${c.labels.collection}-${u.type}`] = Qt().optional();
|
|
9229
9229
|
}), c.access.entityRestrictions?.restrictions?.forEach((u) => {
|
|
9230
|
-
if (u.type === "Individual" && (a[`accessible-${c.labels.collection}-${c.labels.collection}`] = We({}).catchall(
|
|
9230
|
+
if (u.type === "Individual" && (a[`accessible-${c.labels.collection}-${c.labels.collection}`] = We({}).catchall(pe()).optional()), u.type === "Parent" || u.type === "Parent_Property") {
|
|
9231
9231
|
const h = W(c.fields, u.collectionField);
|
|
9232
|
-
a[`accessible-${c.labels.collection}-${h.collection}`] = We({}).catchall(
|
|
9232
|
+
a[`accessible-${c.labels.collection}-${h.collection}`] = We({}).catchall(pe()).optional();
|
|
9233
9233
|
}
|
|
9234
9234
|
});
|
|
9235
9235
|
}));
|
|
@@ -9237,7 +9237,7 @@ const Dc = (n, e) => {
|
|
|
9237
9237
|
return n.allowSchemalessFields ? l.passthrough() : l.strict();
|
|
9238
9238
|
}, Hr = async (n, e) => {
|
|
9239
9239
|
if (n) {
|
|
9240
|
-
const t = await ie(n, e);
|
|
9240
|
+
const t = await ie(n, [e]);
|
|
9241
9241
|
if (!t.valid)
|
|
9242
9242
|
throw new Error(t.message);
|
|
9243
9243
|
}
|
|
@@ -9246,7 +9246,7 @@ const Dc = (n, e) => {
|
|
|
9246
9246
|
for (const a of s.fields)
|
|
9247
9247
|
await Hr(a.custom?.preValidate, r);
|
|
9248
9248
|
return Aa(n, t, i).parse(e), e;
|
|
9249
|
-
}, Ys = (n, e, t, s, r, i, o, a, l, c, u, h, d, f,
|
|
9249
|
+
}, Ys = (n, e, t, s, r, i, o, a, l, c, u, h, d, f, p, O, y, g, N, b, x) => {
|
|
9250
9250
|
const { fields: v } = o;
|
|
9251
9251
|
v.filter((m) => "unique" in m && m.unique).forEach((m) => {
|
|
9252
9252
|
n !== "delete" && (typeof r[m.name] == "string" || typeof r[m.name] == "number") && (e.set(f(m, r[m.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||")), {
|
|
@@ -9266,7 +9266,7 @@ const Dc = (n, e) => {
|
|
|
9266
9266
|
const M = na(m, o), E = { ...r };
|
|
9267
9267
|
M.forEach((B) => {
|
|
9268
9268
|
delete E[B.name], delete E[`${B.name}_Array`], delete E[`${B.name}_Single`], delete E[`${B.name}_Lowercase`];
|
|
9269
|
-
}), Object.keys(E).length > 0 && (n === "create" && (E.Collection_Path ||= t, E.Collection_Path_String = t.join("/"), e.set(
|
|
9269
|
+
}), Object.keys(E).length > 0 && (n === "create" && (E.Collection_Path ||= t, E.Collection_Path_String = t.join("/"), e.set(p(m.key), E)), n === "update" && e.update(p(m.key), E), n === "delete" && e.delete(p(m.key)), x && x.size++);
|
|
9270
9270
|
}
|
|
9271
9271
|
const _ = (m, M) => {
|
|
9272
9272
|
let E = 1;
|
|
@@ -9279,11 +9279,11 @@ const Dc = (n, e) => {
|
|
|
9279
9279
|
return E;
|
|
9280
9280
|
}, Z = (m, M, E, B, w) => {
|
|
9281
9281
|
const I = {};
|
|
9282
|
-
I[`${E.name}.${s}`] = h(), I[`${E.name}_Array`] = u(s), I[`${E.name}_Single`] = h(), e.update(O(w, B), I), ct(E, M, i) && e.update(
|
|
9282
|
+
I[`${E.name}.${s}`] = h(), I[`${E.name}_Array`] = u(s), I[`${E.name}_Single`] = h(), e.update(O(w, B), I), ct(E, M, i) && e.update(y(m, E.name, B), {
|
|
9283
9283
|
[`${E.name}.${s}`]: h(),
|
|
9284
9284
|
[`${E.name}_Array`]: u(s)
|
|
9285
9285
|
}), M.fields.forEach((R) => {
|
|
9286
|
-
ct(R, M, i) && JSON.parse(Kn(dn(R, M, i))).includes(E.name) && e.update(
|
|
9286
|
+
ct(R, M, i) && JSON.parse(Kn(dn(R, M, i))).includes(E.name) && e.update(y(m, R.name, B), {
|
|
9287
9287
|
[`${E.name}_Array`]: u(s)
|
|
9288
9288
|
});
|
|
9289
9289
|
});
|
|
@@ -9332,7 +9332,7 @@ const Dc = (n, e) => {
|
|
|
9332
9332
|
e.update(O(S.Collection_Path, I), {
|
|
9333
9333
|
...q,
|
|
9334
9334
|
...P
|
|
9335
|
-
}), x.size++, ct(E, M, i) && (e.update(
|
|
9335
|
+
}), x.size++, ct(E, M, i) && (e.update(y(m, E.name, I), {
|
|
9336
9336
|
[`${E.name}.${s}`]: {
|
|
9337
9337
|
Collection_Path: t,
|
|
9338
9338
|
...A
|
|
@@ -9343,7 +9343,7 @@ const Dc = (n, e) => {
|
|
|
9343
9343
|
const z = JSON.parse(Kn(dn(L, M, i))), Q = {};
|
|
9344
9344
|
z.includes(E.name) && (Q[`${m.twoWay}_Array`] = c(s)), Object.keys(P).forEach((ee) => {
|
|
9345
9345
|
z.includes(ee) && (Q[ee] = P[ee]);
|
|
9346
|
-
}), Object.keys(Q).length > 0 && (e.update(
|
|
9346
|
+
}), Object.keys(Q).length > 0 && (e.update(y(m, L.name, I), Q), x.size++);
|
|
9347
9347
|
}
|
|
9348
9348
|
});
|
|
9349
9349
|
const T = l[M.labels.collection];
|
|
@@ -9573,11 +9573,11 @@ const Tt = {
|
|
|
9573
9573
|
const f = r.collections?.[l.collection];
|
|
9574
9574
|
if (!r.Role)
|
|
9575
9575
|
throw new Error("PERMISSION_DENIED");
|
|
9576
|
-
const
|
|
9576
|
+
const p = f && Se("Read", f), O = ai(a, t, r), y = ii(a, r), g = Fs(a, r), N = oi(a, t, r), b = (w = []) => {
|
|
9577
9577
|
const I = [], S = fi(r.Role, a, t);
|
|
9578
9578
|
if (!S)
|
|
9579
9579
|
throw new Error("PERMISSION_DENIED");
|
|
9580
|
-
if (
|
|
9580
|
+
if (p) {
|
|
9581
9581
|
let R = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${S.key}`).where("Collection_Path_String", "==", e.join("/"));
|
|
9582
9582
|
w.forEach((A) => {
|
|
9583
9583
|
R = R.where(...A);
|
|
@@ -9590,7 +9590,7 @@ const Tt = {
|
|
|
9590
9590
|
}), I.push(A);
|
|
9591
9591
|
}
|
|
9592
9592
|
return I;
|
|
9593
|
-
}, x =
|
|
9593
|
+
}, x = y.filter((w) => "operations" in w && w.operations ? w.operations.includes("Read") : !0);
|
|
9594
9594
|
if (x.length === 0 && g.length === 0 && N.length === 0)
|
|
9595
9595
|
return b();
|
|
9596
9596
|
let v = 0;
|
|
@@ -9797,11 +9797,11 @@ const Tt = {
|
|
|
9797
9797
|
const u = r.collections?.[l.collection];
|
|
9798
9798
|
if (!r.Role)
|
|
9799
9799
|
throw new Error("PERMISSION_DENIED");
|
|
9800
|
-
const h = u && Se("Read", u), d = ai(a, s, r), f = [],
|
|
9801
|
-
if (!
|
|
9800
|
+
const h = u && Se("Read", u), d = ai(a, s, r), f = [], p = fi(r.Role, a, s);
|
|
9801
|
+
if (!p)
|
|
9802
9802
|
throw new Error("PERMISSION_DENIED");
|
|
9803
9803
|
if (h)
|
|
9804
|
-
f.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${
|
|
9804
|
+
f.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${p.key}`).doc(t));
|
|
9805
9805
|
else if (d)
|
|
9806
9806
|
for (const O of d)
|
|
9807
9807
|
f.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${O.field}`).doc(t));
|
|
@@ -9809,27 +9809,27 @@ const Tt = {
|
|
|
9809
9809
|
} else
|
|
9810
9810
|
return [c.doc(t)];
|
|
9811
9811
|
}, To = async (n, e, t, s, r, i, o, a, l, c) => {
|
|
9812
|
-
const u = t.at(-2), h = li(r.collections[u], r).map((
|
|
9813
|
-
s.collections ? s.collections.forEach((
|
|
9814
|
-
if (!h.includes(
|
|
9815
|
-
throw new Error(`SCHEMA_ERROR: Collection ${
|
|
9812
|
+
const u = t.at(-2), h = li(r.collections[u], r).map((p) => p.labels.collection);
|
|
9813
|
+
s.collections ? s.collections.forEach((p) => {
|
|
9814
|
+
if (!h.includes(p))
|
|
9815
|
+
throw new Error(`SCHEMA_ERROR: Collection ${p} not found in subcollections of ${u}`);
|
|
9816
9816
|
}) : s.collections = h;
|
|
9817
|
-
const d = s.depth - 1, f = s.collections.map(async (
|
|
9818
|
-
const O = await Ro([...t,
|
|
9817
|
+
const d = s.depth - 1, f = s.collections.map(async (p) => {
|
|
9818
|
+
const O = await Ro([...t, p], {
|
|
9819
9819
|
constraints: s.constraints,
|
|
9820
9820
|
userId: a,
|
|
9821
9821
|
pagination: s.limit,
|
|
9822
9822
|
providedTransaction: l,
|
|
9823
9823
|
noEmbeddingFields: c
|
|
9824
|
-
}).catch((
|
|
9825
|
-
throw
|
|
9824
|
+
}).catch((y) => {
|
|
9825
|
+
throw y.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${p} for document at ${t.join("/")}`), y;
|
|
9826
9826
|
});
|
|
9827
|
-
e[
|
|
9827
|
+
e[p] = O.docs, i && await Promise.all(
|
|
9828
9828
|
// eslint-disable-next-line security/detect-object-injection
|
|
9829
|
-
e[
|
|
9829
|
+
e[p].map((y) => Qs(n, y, [...t, p, y.id], i, r, void 0, a, l, c))
|
|
9830
9830
|
), d > 0 && await Promise.all(
|
|
9831
9831
|
// eslint-disable-next-line security/detect-object-injection
|
|
9832
|
-
e[
|
|
9832
|
+
e[p].map((y) => To(n, y, [...t, p, y.id], { depth: d }, r, i, o, a, l, c))
|
|
9833
9833
|
);
|
|
9834
9834
|
});
|
|
9835
9835
|
await Promise.all(f);
|
|
@@ -9842,9 +9842,9 @@ const Tt = {
|
|
|
9842
9842
|
const f = e[d.name];
|
|
9843
9843
|
if (!f)
|
|
9844
9844
|
continue;
|
|
9845
|
-
const
|
|
9846
|
-
for (const O of
|
|
9847
|
-
const
|
|
9845
|
+
const p = Object.keys(f);
|
|
9846
|
+
for (const O of p) {
|
|
9847
|
+
const y = f[O], g = at(y.Collection_Path, O, {
|
|
9848
9848
|
userId: o,
|
|
9849
9849
|
providedTransaction: a,
|
|
9850
9850
|
noEmbeddingFields: l
|
|
@@ -9854,7 +9854,7 @@ const Tt = {
|
|
|
9854
9854
|
n,
|
|
9855
9855
|
// eslint-disable-next-line security/detect-object-injection
|
|
9856
9856
|
f[O],
|
|
9857
|
-
[...
|
|
9857
|
+
[...y.Collection_Path, O],
|
|
9858
9858
|
{ depth: u },
|
|
9859
9859
|
r,
|
|
9860
9860
|
i,
|
|
@@ -9894,15 +9894,15 @@ const Tt = {
|
|
|
9894
9894
|
throw new Error("MAINTENANCE_MODE");
|
|
9895
9895
|
if (h.data().active)
|
|
9896
9896
|
throw new Error("MAINTENANCE_MODE");
|
|
9897
|
-
const
|
|
9897
|
+
const p = d;
|
|
9898
9898
|
let O;
|
|
9899
|
-
const
|
|
9899
|
+
const y = Ut(), g = n.at(-1);
|
|
9900
9900
|
if (!g)
|
|
9901
9901
|
throw new Error("EMPTY_PATH");
|
|
9902
|
-
const N = Object.keys(
|
|
9902
|
+
const N = Object.keys(p.collections).includes(g), b = y.disabledCollections?.includes(g);
|
|
9903
9903
|
if (!N || b)
|
|
9904
9904
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
9905
|
-
const x =
|
|
9905
|
+
const x = p.collections[g], { labels: v } = x, C = Qe(v.collection, p);
|
|
9906
9906
|
if (e?.userId) {
|
|
9907
9907
|
if (!u?.exists)
|
|
9908
9908
|
throw new Error("PERMISSION_DENIED");
|
|
@@ -9911,7 +9911,7 @@ const Tt = {
|
|
|
9911
9911
|
if (!O.Enabled)
|
|
9912
9912
|
throw new Error("PERMISSION_DENIED");
|
|
9913
9913
|
}
|
|
9914
|
-
let _ = Fc(s, n,
|
|
9914
|
+
let _ = Fc(s, n, p, e?.userId, O);
|
|
9915
9915
|
if (_.length === 0)
|
|
9916
9916
|
return { cursor: {}, pages: 0, docs: [] };
|
|
9917
9917
|
if (t && (_ = _.map((w) => (t.forEach(([I, S, R]) => {
|
|
@@ -9924,14 +9924,14 @@ const Tt = {
|
|
|
9924
9924
|
throw new Error("INPUT_ERROR: startAfter and endBefore cannot be provided together");
|
|
9925
9925
|
const w = e.pagination.startAfter || e.pagination.endBefore;
|
|
9926
9926
|
if (e?.userId) {
|
|
9927
|
-
const I = Ko(O.Role, x,
|
|
9927
|
+
const I = Ko(O.Role, x, p);
|
|
9928
9928
|
if (w && I !== !0)
|
|
9929
9929
|
throw new Error("INPUT_ERROR: Pagination is not allowed when using " + I);
|
|
9930
9930
|
}
|
|
9931
9931
|
e.pagination.orderByField && e.pagination.orderByDirection ? !e.pagination.startAfter && !e.pagination.endBefore ? _ = _.map((I) => I.orderBy(e.pagination.orderByField, e.pagination.orderByDirection).limit(e.pagination.number)) : e.pagination.startAfter ? _ = _.map((I, S) => I.orderBy(e.pagination.orderByField, e.pagination.orderByDirection).startAfter(o.last.get(S)).limit(e.pagination.number)) : _ = _.map((I, S) => I.orderBy(e.pagination.orderByField, e.pagination.orderByDirection).endBefore(o.first.get(S)).limitToLast(e.pagination.number)) : !e.pagination.startAfter && !e.pagination.endBefore ? _ = _.map((I) => I.limit(e.pagination.number)) : e.pagination.startAfter ? _ = _.map((I, S) => I.startAfter(o.last.get(S)).limit(e.pagination.number)) : _ = _.map((I, S) => I.endBefore(o.first.get(S)).limitToLast(e.pagination.number));
|
|
9932
9932
|
}
|
|
9933
9933
|
const Z = {};
|
|
9934
|
-
await oe("preOperation",
|
|
9934
|
+
await oe("preOperation", y, C, { operation: "read", context: Z }), await oe("preRead", y, C, { context: Z, refs: _, multiple: !0, listener: !1 }), a = /* @__PURE__ */ new Map();
|
|
9935
9935
|
const M = _.map(async (w) => await c.get(w)), E = await Promise.all(M);
|
|
9936
9936
|
for (const w of E) {
|
|
9937
9937
|
for (const I of w.docs) {
|
|
@@ -9959,7 +9959,7 @@ const Tt = {
|
|
|
9959
9959
|
a.get(w.id),
|
|
9960
9960
|
S,
|
|
9961
9961
|
me(e.subcollections),
|
|
9962
|
-
|
|
9962
|
+
p,
|
|
9963
9963
|
me(e?.relations),
|
|
9964
9964
|
void 0,
|
|
9965
9965
|
e.userId,
|
|
@@ -9979,7 +9979,7 @@ const Tt = {
|
|
|
9979
9979
|
a.get(w.id),
|
|
9980
9980
|
S,
|
|
9981
9981
|
me(e.relations),
|
|
9982
|
-
|
|
9982
|
+
p,
|
|
9983
9983
|
void 0,
|
|
9984
9984
|
e.userId,
|
|
9985
9985
|
e.transactional ? c : void 0,
|
|
@@ -10008,13 +10008,13 @@ const Tt = {
|
|
|
10008
10008
|
(!z || !ee) && (K(L) ? (delete a.get(w.id)[L.name], delete a.get(w.id)[`${L.name}_Array`], delete a.get(w.id)[`${L.name}_Single`]) : delete a.get(w.id)[L.name]);
|
|
10009
10009
|
}
|
|
10010
10010
|
}
|
|
10011
|
-
const A =
|
|
10012
|
-
await oe("postOperation",
|
|
10011
|
+
const A = { operation: "read", data: w, docId: w.id, context: Z };
|
|
10012
|
+
await oe("postOperation", y, C, A), await oe("postRead", y, C, { context: Z, refs: _, doc: w, listener: !1 });
|
|
10013
10013
|
}
|
|
10014
10014
|
e?.userId && await Jo(
|
|
10015
10015
|
Array.from(a.values()),
|
|
10016
10016
|
x,
|
|
10017
|
-
|
|
10017
|
+
p,
|
|
10018
10018
|
e.userId,
|
|
10019
10019
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
10020
10020
|
O
|
|
@@ -10036,13 +10036,13 @@ const Tt = {
|
|
|
10036
10036
|
relations: o,
|
|
10037
10037
|
pagination: r.limit,
|
|
10038
10038
|
providedTransaction: e
|
|
10039
|
-
}).catch((
|
|
10040
|
-
throw
|
|
10039
|
+
}).catch((p) => {
|
|
10040
|
+
throw p.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${d} for document at ${s.join("/")}`), p;
|
|
10041
10041
|
});
|
|
10042
10042
|
t[d] = f.docs, u > 0 && await Promise.all(
|
|
10043
10043
|
// eslint-disable-next-line security/detect-object-injection
|
|
10044
|
-
t[d].map(async (
|
|
10045
|
-
await Io(n, e,
|
|
10044
|
+
t[d].map(async (p) => {
|
|
10045
|
+
await Io(n, e, p, [...s, d, p.id], { depth: u }, i, o, a);
|
|
10046
10046
|
})
|
|
10047
10047
|
);
|
|
10048
10048
|
});
|
|
@@ -10056,20 +10056,20 @@ const Tt = {
|
|
|
10056
10056
|
const f = t[d.name];
|
|
10057
10057
|
if (!f)
|
|
10058
10058
|
continue;
|
|
10059
|
-
for (const [
|
|
10060
|
-
const
|
|
10059
|
+
for (const [p, O] of Object.entries(f)) {
|
|
10060
|
+
const y = at(O.Collection_Path, p, {
|
|
10061
10061
|
userId: o,
|
|
10062
10062
|
providedTransaction: e,
|
|
10063
10063
|
noComputedFields: a,
|
|
10064
10064
|
noEmbeddingFields: l
|
|
10065
10065
|
}).then((g) => {
|
|
10066
|
-
if (f[
|
|
10066
|
+
if (f[p] = g, u > 0)
|
|
10067
10067
|
return xo(
|
|
10068
10068
|
n,
|
|
10069
10069
|
e,
|
|
10070
10070
|
// eslint-disable-next-line security/detect-object-injection
|
|
10071
|
-
f[
|
|
10072
|
-
[...O.Collection_Path,
|
|
10071
|
+
f[p],
|
|
10072
|
+
[...O.Collection_Path, p],
|
|
10073
10073
|
r,
|
|
10074
10074
|
{ depth: u },
|
|
10075
10075
|
o,
|
|
@@ -10078,11 +10078,11 @@ const Tt = {
|
|
|
10078
10078
|
);
|
|
10079
10079
|
}).catch((g) => {
|
|
10080
10080
|
if (g.message.includes("NOT_FOUND") || g.code === "permission-denied")
|
|
10081
|
-
delete f[
|
|
10081
|
+
delete f[p];
|
|
10082
10082
|
else
|
|
10083
10083
|
throw g;
|
|
10084
10084
|
});
|
|
10085
|
-
h.push(
|
|
10085
|
+
h.push(y);
|
|
10086
10086
|
}
|
|
10087
10087
|
}
|
|
10088
10088
|
await Promise.all(h);
|
|
@@ -10105,11 +10105,11 @@ const Tt = {
|
|
|
10105
10105
|
throw new Error("MAINTENANCE_MODE");
|
|
10106
10106
|
const d = u;
|
|
10107
10107
|
let f;
|
|
10108
|
-
const
|
|
10108
|
+
const p = Ut(), O = n.at(-1);
|
|
10109
10109
|
if (!O)
|
|
10110
10110
|
throw new Error("EMPTY_PATH");
|
|
10111
|
-
const
|
|
10112
|
-
if (!
|
|
10111
|
+
const y = Object.keys(d.collections).includes(O), g = p.disabledCollections?.includes(O);
|
|
10112
|
+
if (!y || g)
|
|
10113
10113
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10114
10114
|
const N = d.collections[O], { labels: b } = N, x = Qe(b.collection, d);
|
|
10115
10115
|
let v;
|
|
@@ -10129,7 +10129,7 @@ const Tt = {
|
|
|
10129
10129
|
if (C.length === 0)
|
|
10130
10130
|
throw new Error("PERMISSION_DENIED");
|
|
10131
10131
|
const _ = {};
|
|
10132
|
-
await oe("preOperation",
|
|
10132
|
+
await oe("preOperation", p, x, { operation: "read", docId: e, context: _ }), await oe("preRead", p, x, { context: _, refs: C, multiple: !1, listener: !1 }), i = {};
|
|
10133
10133
|
const m = C.map((S) => a.get(S)), M = await Promise.all(m);
|
|
10134
10134
|
for (const S of M)
|
|
10135
10135
|
if (S.exists) {
|
|
@@ -10167,7 +10167,7 @@ const Tt = {
|
|
|
10167
10167
|
(!q || !T) && (K(A) ? (delete i[A.name], delete i[`${A.name}_Array`], delete i[`${A.name}_Single`]) : delete i[A.name]);
|
|
10168
10168
|
}
|
|
10169
10169
|
}
|
|
10170
|
-
await oe("postOperation",
|
|
10170
|
+
await oe("postOperation", p, x, { operation: "read", data: i, docId: e, context: _ }), await oe("postRead", p, x, { context: _, refs: C, doc: i, listener: !1 }), t?.userId && await Yo(i, N, d, t.userId, f);
|
|
10171
10171
|
};
|
|
10172
10172
|
return t?.providedTransaction ? await o(t.providedTransaction) : await r.runTransaction(async (a) => {
|
|
10173
10173
|
await o(a);
|
|
@@ -10179,11 +10179,11 @@ const Tt = {
|
|
|
10179
10179
|
if (s[f.name] === void 0 || Fe(s[f.name]))
|
|
10180
10180
|
return;
|
|
10181
10181
|
De(f, c);
|
|
10182
|
-
const
|
|
10183
|
-
if (!Js(
|
|
10182
|
+
const p = s[f.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
|
|
10183
|
+
if (!Js(p))
|
|
10184
10184
|
d.push(`${f.name} "${s[f.name]}" is invalid`);
|
|
10185
10185
|
else {
|
|
10186
|
-
const O = await l.collection("tenants").doc(e).collection("system_unique").doc(u).collection(`Unique-${u}-${f.name}`).doc(
|
|
10186
|
+
const O = await l.collection("tenants").doc(e).collection("system_unique").doc(u).collection(`Unique-${u}-${f.name}`).doc(p).get();
|
|
10187
10187
|
O.exists && !(n === "update" && O.data().id === t) && d.push(`${f.name} "${s[f.name]}" already exists`);
|
|
10188
10188
|
}
|
|
10189
10189
|
}
|
|
@@ -10208,10 +10208,10 @@ const Tt = {
|
|
|
10208
10208
|
const g = /* @__PURE__ */ new Date(), N = new Date((/* @__PURE__ */ new Date()).setDate(g.getDate() + d));
|
|
10209
10209
|
f.TTL = lt.fromDate(N);
|
|
10210
10210
|
}
|
|
10211
|
-
const
|
|
10212
|
-
nt(
|
|
10213
|
-
const O = Ae(u, r, s),
|
|
10214
|
-
await O.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${
|
|
10211
|
+
const p = me(t);
|
|
10212
|
+
nt(p), n !== "delete" && (f.data.data = me(p)), n === "update" && (f.data.originalRecord = me(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));
|
|
10213
|
+
const O = Ae(u, r, s), y = t.Last_Write_At;
|
|
10214
|
+
await O.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${y.valueOf()}`).set(f);
|
|
10215
10215
|
}, cn = async (n) => {
|
|
10216
10216
|
const e = Je(), t = gt(), s = ce(), r = [];
|
|
10217
10217
|
if (await Promise.all([
|
|
@@ -10242,13 +10242,13 @@ ${i}`);
|
|
|
10242
10242
|
n = h;
|
|
10243
10243
|
else
|
|
10244
10244
|
throw new Error("Admin email not set");
|
|
10245
|
-
const d = ds(n), f = $c(e),
|
|
10245
|
+
const d = ds(n), f = $c(e), p = t ? Yr(t) : void 0, O = s ? Yr(s) : void 0, y = r ? ds(r) : void 0, g = i ? ds(i) : void 0, N = o ? Un(o) : void 0, b = l ? Un(l) : void 0, x = Array.isArray(d) ? d : [d];
|
|
10246
10246
|
if (x.length === 0 || x.length === 1 && !x[0])
|
|
10247
10247
|
throw new Error("No valid email addresses provided");
|
|
10248
10248
|
const v = { to: d, message: { subject: f } };
|
|
10249
|
-
if (
|
|
10250
|
-
const C = Array.isArray(
|
|
10251
|
-
C.length > 0 && C[0] && (v.cc =
|
|
10249
|
+
if (p && (v.message.text = p), O && (v.message.html = O), y) {
|
|
10250
|
+
const C = Array.isArray(y) ? y : [y];
|
|
10251
|
+
C.length > 0 && C[0] && (v.cc = y);
|
|
10252
10252
|
}
|
|
10253
10253
|
if (g) {
|
|
10254
10254
|
const C = Array.isArray(g) ? g : [g];
|
|
@@ -10256,11 +10256,11 @@ ${i}`);
|
|
|
10256
10256
|
}
|
|
10257
10257
|
N && (v.replyTo = N), a && (v.message.attachments = a), b && (v.from = b), await c.collection("system_mail").add(v);
|
|
10258
10258
|
}, Ao = async (n, e, t, s, r, i, o) => {
|
|
10259
|
-
const a = gt(), l = ce(), c = "USER_ERROR", u = async (f,
|
|
10259
|
+
const a = gt(), l = ce(), c = "USER_ERROR", u = async (f, p) => {
|
|
10260
10260
|
try {
|
|
10261
10261
|
await cn(f);
|
|
10262
10262
|
} catch {
|
|
10263
|
-
throw new Error(`ROLLBACK_FAILED: ${
|
|
10263
|
+
throw new Error(`ROLLBACK_FAILED: ${p}`);
|
|
10264
10264
|
}
|
|
10265
10265
|
};
|
|
10266
10266
|
let h;
|
|
@@ -10306,16 +10306,16 @@ ${i}`);
|
|
|
10306
10306
|
throw await u(r, c), new Error(c);
|
|
10307
10307
|
}
|
|
10308
10308
|
if (f.includes("apiKey=&")) {
|
|
10309
|
-
const
|
|
10310
|
-
f = f.replace("apiKey=&", `apiKey=${
|
|
10309
|
+
const p = JSON.parse(process.env.STOKER_FB_WEB_APP_CONFIG);
|
|
10310
|
+
f = f.replace("apiKey=&", `apiKey=${p.apiKey}&`);
|
|
10311
10311
|
}
|
|
10312
10312
|
if (f) {
|
|
10313
|
-
const
|
|
10313
|
+
const p = `https://${a.app.options.projectId}.firebaseapp.com/__/auth/action${f}`, O = await ie(t.appName), y = t?.mail?.emailVerification && t.mail.emailVerification(p, O);
|
|
10314
10314
|
try {
|
|
10315
|
-
await Do(r.Email,
|
|
10315
|
+
await Do(r.Email, y?.subject || "Please verify your email address", void 0, y?.html || `Please verify your email address by clicking the link:
|
|
10316
10316
|
</br>
|
|
10317
10317
|
</br>
|
|
10318
|
-
<a href="${
|
|
10318
|
+
<a href="${p}">${p}</a>`);
|
|
10319
10319
|
} catch {
|
|
10320
10320
|
throw await u(r, c), new Error(c);
|
|
10321
10321
|
}
|
|
@@ -10380,8 +10380,8 @@ ${i}`);
|
|
|
10380
10380
|
const f = await r.get(d.doc(u));
|
|
10381
10381
|
if (!f.exists)
|
|
10382
10382
|
throw new Error(`VALIDATION_ERROR: Record ${u} not found in collection ${t.collection}`);
|
|
10383
|
-
const
|
|
10384
|
-
if (!y
|
|
10383
|
+
const p = f.data(), O = W(a, t.enforceHierarchy.field), y = t.enforceHierarchy;
|
|
10384
|
+
if (!p[y.recordLinkField] || !s[O.name] || !Object.keys(s[O.name]).every((g) => Object.keys(p[y.recordLinkField]).includes(g)))
|
|
10385
10385
|
throw new Error("VALIDATION_ERROR: Invalid relation hierarchy");
|
|
10386
10386
|
}, gn = async (n, e, t) => {
|
|
10387
10387
|
delete e[n.name][t], e[`${n.name}_Array`] = e[`${n.name}_Array`]?.filter((s) => s !== t), delete e[`${n.name}_Single`];
|
|
@@ -10393,7 +10393,7 @@ ${i}`);
|
|
|
10393
10393
|
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));
|
|
10394
10394
|
return { addedFields: o, removedFields: a };
|
|
10395
10395
|
}, $o = async (n, e, t, s, r, i, o, a, l, c, u, h) => {
|
|
10396
|
-
const { fields: d } = i, f = ce(),
|
|
10396
|
+
const { fields: d } = i, f = ce(), p = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
|
|
10397
10397
|
for (const g of d)
|
|
10398
10398
|
K(g) && ["OneToOne", "OneToMany"].includes(g.type) && g.enforceHierarchy && s[g.name] && (n === "Create" || n === "Update" && !qe(h?.[g.name], s[g.name])) && await Qr(e, i, g, s, a, l);
|
|
10399
10399
|
for (const g of d)
|
|
@@ -10405,7 +10405,7 @@ ${i}`);
|
|
|
10405
10405
|
const [_, Z] = C;
|
|
10406
10406
|
if (n === "Create" || !h?.[g.name]?.[_]) {
|
|
10407
10407
|
let k;
|
|
10408
|
-
const m =
|
|
10408
|
+
const m = y.get(g.collection)?.[_];
|
|
10409
10409
|
if (m)
|
|
10410
10410
|
k = m;
|
|
10411
10411
|
else {
|
|
@@ -10428,8 +10428,8 @@ ${i}`);
|
|
|
10428
10428
|
...Pc(i, s, b)
|
|
10429
10429
|
}
|
|
10430
10430
|
};
|
|
10431
|
-
k[b.name] = M, k[`${b.name}_Array`] ||= [], k[`${b.name}_Array`].push(t), x.size === 1 && (k[`${b.name}_Single`] = { id: t, ...M }),
|
|
10432
|
-
...
|
|
10431
|
+
k[b.name] = M, k[`${b.name}_Array`] ||= [], k[`${b.name}_Array`].push(t), x.size === 1 && (k[`${b.name}_Single`] = { id: t, ...M }), y.set(g.collection, {
|
|
10432
|
+
...y.get(g.collection) || {},
|
|
10433
10433
|
[_]: k
|
|
10434
10434
|
});
|
|
10435
10435
|
}
|
|
@@ -10441,14 +10441,14 @@ ${i}`);
|
|
|
10441
10441
|
const [_, Z] = C;
|
|
10442
10442
|
if (!s[g.name]?.[_]) {
|
|
10443
10443
|
let k;
|
|
10444
|
-
const m =
|
|
10444
|
+
const m = y.get(g.collection)?.[_];
|
|
10445
10445
|
if (m)
|
|
10446
10446
|
k = m;
|
|
10447
10447
|
else {
|
|
10448
10448
|
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.`));
|
|
10449
10449
|
const M = Ae(f, Z.Collection_Path, e), E = await a.get(M.doc(_));
|
|
10450
10450
|
if (!E.exists) {
|
|
10451
|
-
|
|
10451
|
+
p.set(g.name, [...p.get(g.name) || [], _]);
|
|
10452
10452
|
continue;
|
|
10453
10453
|
}
|
|
10454
10454
|
const B = E.data();
|
|
@@ -10457,15 +10457,15 @@ ${i}`);
|
|
|
10457
10457
|
[_]: B
|
|
10458
10458
|
}), k = me({ ...B, ...Sn(s) });
|
|
10459
10459
|
}
|
|
10460
|
-
k[b.name][t] && delete k[b.name][t], Array.isArray(k[`${b.name}_Array`]) && (k[`${b.name}_Array`] = k[`${b.name}_Array`].filter((M) => M !== t)), x.size === 1 && delete k[`${b.name}_Single`],
|
|
10461
|
-
...
|
|
10460
|
+
k[b.name][t] && delete k[b.name][t], Array.isArray(k[`${b.name}_Array`]) && (k[`${b.name}_Array`] = k[`${b.name}_Array`].filter((M) => M !== t)), x.size === 1 && delete k[`${b.name}_Single`], y.set(g.collection, {
|
|
10461
|
+
...y.get(g.collection) || {},
|
|
10462
10462
|
[_]: k
|
|
10463
10463
|
});
|
|
10464
10464
|
}
|
|
10465
10465
|
}
|
|
10466
10466
|
}
|
|
10467
10467
|
}
|
|
10468
|
-
for (const [g, N] of
|
|
10468
|
+
for (const [g, N] of y.entries()) {
|
|
10469
10469
|
const b = o.collections[g], x = Qe(g, o);
|
|
10470
10470
|
for (const [v, C] of Object.entries(N)) {
|
|
10471
10471
|
const { addedFields: _, removedFields: Z } = Lc(n, v, g, i, s, h);
|
|
@@ -10531,7 +10531,7 @@ ${i}`);
|
|
|
10531
10531
|
}
|
|
10532
10532
|
}
|
|
10533
10533
|
try {
|
|
10534
|
-
await nn("update", C, b, x,
|
|
10534
|
+
await nn("update", C, b, x, { operation: "update", record: C, context: {}, originalRecord: C }, o);
|
|
10535
10535
|
} catch (k) {
|
|
10536
10536
|
throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${v} in ${g}: ${k.message}`);
|
|
10537
10537
|
}
|
|
@@ -10541,15 +10541,15 @@ ${i}`);
|
|
|
10541
10541
|
}
|
|
10542
10542
|
}
|
|
10543
10543
|
}
|
|
10544
|
-
return
|
|
10544
|
+
return p;
|
|
10545
10545
|
}, Mo = (n, e, t) => {
|
|
10546
|
-
n === "create" &&
|
|
10546
|
+
n === "create" && pt.forEach((s) => {
|
|
10547
10547
|
if (!qe(e[s], t[s]))
|
|
10548
10548
|
throw new Error(`Updating system fields in hooks is not allowed: ${s}`);
|
|
10549
10549
|
}), n === "update" && (["id", "Collection_Path", "Created_At", "Saved_At", "Created_By"].forEach((s) => {
|
|
10550
10550
|
if (s in e)
|
|
10551
10551
|
throw new Error(`Cannot update system field: ${s}`);
|
|
10552
|
-
}),
|
|
10552
|
+
}), pt.forEach((s) => {
|
|
10553
10553
|
if (!["id", "Collection_Path", "Created_At", "Saved_At", "Created_By"].includes(s) && !qe(e[s], t[s]))
|
|
10554
10554
|
throw new Error(`Updating system fields in hooks is not allowed: ${s}`);
|
|
10555
10555
|
}));
|
|
@@ -10569,7 +10569,7 @@ ${i}`);
|
|
|
10569
10569
|
else if (t[o] && t[o]?.valueOf() !== s[o]?.valueOf())
|
|
10570
10570
|
throw new Error("Soft delete timestamp cannot be changed");
|
|
10571
10571
|
}
|
|
10572
|
-
},
|
|
10572
|
+
}, ps = async (n, e, t, s, r) => {
|
|
10573
10573
|
if (!Se("Read", r.collections?.[e.labels.collection]))
|
|
10574
10574
|
return !1;
|
|
10575
10575
|
try {
|
|
@@ -10598,42 +10598,42 @@ ${i}`);
|
|
|
10598
10598
|
if (s.collections?.[a]?.restrictEntities || s?.collections?.[a]?.recordOwner?.active || s?.collections?.[a]?.recordUser?.active || s?.collections?.[a]?.recordProperty?.active) {
|
|
10599
10599
|
const d = i?.collections?.[a], f = [];
|
|
10600
10600
|
if (l.individualEntities) {
|
|
10601
|
-
const
|
|
10602
|
-
for (const g of
|
|
10601
|
+
const p = l.individualEntities, O = d?.individualEntities || [], y = i ? p.filter((g) => !O.includes(g)) : p;
|
|
10602
|
+
for (const g of y) {
|
|
10603
10603
|
if (o && o.size++, o && o.size > 500)
|
|
10604
10604
|
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).");
|
|
10605
10605
|
f.push(async () => {
|
|
10606
|
-
if (!await
|
|
10606
|
+
if (!await ps(n, u, g, t, s))
|
|
10607
10607
|
throw new Error("PERMISSION_DENIED");
|
|
10608
10608
|
});
|
|
10609
10609
|
}
|
|
10610
10610
|
}
|
|
10611
10611
|
if (l.parentEntities) {
|
|
10612
|
-
const
|
|
10613
|
-
if (!
|
|
10612
|
+
const p = c.entityRestrictions?.restrictions?.find((x) => x.type === "Parent" && x.roles.some((v) => v.role === e.Role));
|
|
10613
|
+
if (!p)
|
|
10614
10614
|
throw new Error("PERMISSION_DENIED");
|
|
10615
|
-
const O = W(u.fields,
|
|
10615
|
+
const O = W(u.fields, p.collectionField), y = r.collections[O.collection], g = l.parentEntities, N = d?.parentEntities || [], b = i ? g.filter((x) => !N.includes(x)) : g;
|
|
10616
10616
|
for (const x of b) {
|
|
10617
10617
|
if (o && o.size++, o && o.size > 500)
|
|
10618
10618
|
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).");
|
|
10619
10619
|
f.push(async () => {
|
|
10620
|
-
if (!await
|
|
10620
|
+
if (!await ps(n, y, x, t, s))
|
|
10621
10621
|
throw new Error("PERMISSION_DENIED");
|
|
10622
10622
|
});
|
|
10623
10623
|
}
|
|
10624
10624
|
}
|
|
10625
10625
|
if (l.parentPropertyEntities) {
|
|
10626
|
-
const
|
|
10627
|
-
if (!
|
|
10626
|
+
const p = c.entityRestrictions?.restrictions?.find((b) => b.type === "Parent_Property" && b.roles.some((x) => x.role === e.Role));
|
|
10627
|
+
if (!p)
|
|
10628
10628
|
throw new Error("PERMISSION_DENIED");
|
|
10629
|
-
const O = W(u.fields,
|
|
10629
|
+
const O = W(u.fields, p.collectionField), y = r.collections[O.collection], g = l.parentPropertyEntities, N = d?.parentPropertyEntities || {};
|
|
10630
10630
|
for (const [b, x] of Object.entries(g)) {
|
|
10631
10631
|
const v = N[b] || [], C = i ? x.filter((_) => !v.includes(_)) : x;
|
|
10632
10632
|
for (const _ of C) {
|
|
10633
10633
|
if (o && o.size++, o && o.size > 500)
|
|
10634
10634
|
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).");
|
|
10635
10635
|
f.push(async () => {
|
|
10636
|
-
if (!await
|
|
10636
|
+
if (!await ps(n, y, _, t, s))
|
|
10637
10637
|
throw new Error("PERMISSION_DENIED");
|
|
10638
10638
|
});
|
|
10639
10639
|
}
|
|
@@ -10656,7 +10656,7 @@ ${i}`);
|
|
|
10656
10656
|
const c = n.at(-1), u = Object.keys(l.collections).includes(c), h = a.disabledCollections?.includes(c);
|
|
10657
10657
|
if (!u || h)
|
|
10658
10658
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10659
|
-
const d = l.collections[c], { labels: f, fields:
|
|
10659
|
+
const d = l.collections[c], { labels: f, fields: p, enableWriteLog: O, softDelete: y } = d, g = Qe(f.collection, l), N = await ie(a.appName), b = ce(), x = gt(), C = (s ? await x.getUser(s) : void 0)?.customClaims?.role;
|
|
10660
10660
|
let _;
|
|
10661
10661
|
s && await Ks(n, d);
|
|
10662
10662
|
const Z = Ae(b, n, o), k = t?.id || Z.doc().id;
|
|
@@ -10664,17 +10664,17 @@ ${i}`);
|
|
|
10664
10664
|
const m = Vs("create", n, e, l, N, "Online", s || "System", lt.now(), fe.serverTimestamp());
|
|
10665
10665
|
t?.createdAt && (m.Created_At = t.createdAt), t?.createdBy && (m.Created_By = t.createdBy);
|
|
10666
10666
|
const M = me(m);
|
|
10667
|
-
|
|
10667
|
+
y && (m[y.archivedField] = !1), Ve(e), O && !t?.providedTransaction && await Mt("create", "started", m, o, n, k, d), await oe("preOperation", a, g, { operation: "create", data: m, docId: k, context: i }), await oe("preWrite", a, g, { operation: "create", data: m, docId: k, context: i }), Tn(d, m, l), Rn(d, m), await sa(m, d, g, C), Ve(m);
|
|
10668
10668
|
try {
|
|
10669
10669
|
if (d.auth && r && !r.password)
|
|
10670
10670
|
throw new Error("Password is required");
|
|
10671
|
-
t?.providedTransaction || (await No("create", o, k, m, d, l), await nn("create", m, d, g,
|
|
10671
|
+
t?.providedTransaction || (await No("create", o, k, m, d, l), await nn("create", m, d, g, { operation: "create", record: m, context: i }, l));
|
|
10672
10672
|
} catch (R) {
|
|
10673
10673
|
throw new Error(`VALIDATION_ERROR: ${R.message}`);
|
|
10674
10674
|
}
|
|
10675
|
-
Ve(m), e.id = k,
|
|
10675
|
+
Ve(m), e.id = k, y && (m[y.archivedField] = !1), Tn(d, m, l), Rn(d, m);
|
|
10676
10676
|
try {
|
|
10677
|
-
Mo("create", m, M), Fo("create", d, m), await nn("create", m, d, g,
|
|
10677
|
+
Mo("create", m, M), Fo("create", d, m), await nn("create", m, d, g, { operation: "create", record: m, context: i }, l);
|
|
10678
10678
|
} catch (R) {
|
|
10679
10679
|
throw new Error(`VALIDATION_ERROR: ${R.message}`);
|
|
10680
10680
|
}
|
|
@@ -10720,7 +10720,7 @@ ${i}`);
|
|
|
10720
10720
|
throw new Error("PERMISSION_DENIED");
|
|
10721
10721
|
}
|
|
10722
10722
|
if (!t?.providedTransaction) {
|
|
10723
|
-
const Q =
|
|
10723
|
+
const Q = p.filter((ee) => "unique" in ee && ee.unique).map(async (ee) => {
|
|
10724
10724
|
if (!s || !ee.access || ee.access.includes(_.Role)) {
|
|
10725
10725
|
if (!e[ee.name])
|
|
10726
10726
|
return;
|
|
@@ -10770,7 +10770,13 @@ ${i}`);
|
|
|
10770
10770
|
if (t?.providedTransaction)
|
|
10771
10771
|
throw A;
|
|
10772
10772
|
{
|
|
10773
|
-
const P = await oe("postWriteError", a, g,
|
|
10773
|
+
const P = await oe("postWriteError", a, g, {
|
|
10774
|
+
operation: "create",
|
|
10775
|
+
data: m,
|
|
10776
|
+
docId: k,
|
|
10777
|
+
context: i,
|
|
10778
|
+
error: A
|
|
10779
|
+
});
|
|
10774
10780
|
if (O && (await new Promise((T) => {
|
|
10775
10781
|
setTimeout(T, 250);
|
|
10776
10782
|
}), await Mt("create", P?.resolved ? "success" : "failed", m, o, n, k, d, P?.resolved ? void 0 : A)), !P?.resolved)
|
|
@@ -10781,7 +10787,7 @@ ${i}`);
|
|
|
10781
10787
|
if (t?.providedTransaction ? await I(t.providedTransaction) : await b.runTransaction(async (R) => {
|
|
10782
10788
|
await I(R);
|
|
10783
10789
|
}, { maxAttempts: 10 }), !t?.providedTransaction) {
|
|
10784
|
-
const R =
|
|
10790
|
+
const R = { operation: "create", data: m, docId: k, context: i }, A = { ...R };
|
|
10785
10791
|
await oe("postWrite", a, g, R), await oe("postOperation", a, g, A);
|
|
10786
10792
|
}
|
|
10787
10793
|
return { id: k, ...m };
|
|
@@ -10820,7 +10826,7 @@ ${i}`);
|
|
|
10820
10826
|
if (l)
|
|
10821
10827
|
throw new Error(`ROLLBACK_FAILED: ${s}`);
|
|
10822
10828
|
}, Wc = async (n, e, t, s, r, i, o, a, l, c, u) => {
|
|
10823
|
-
const h = gt(), d = ce(), f = a?.customClaims || {},
|
|
10829
|
+
const h = gt(), d = ce(), f = a?.customClaims || {}, p = "USER_ERROR";
|
|
10824
10830
|
let O = "";
|
|
10825
10831
|
if (n === "create") {
|
|
10826
10832
|
if (!u)
|
|
@@ -10829,18 +10835,18 @@ ${i}`);
|
|
|
10829
10835
|
throw new Error("VALIDATION_ERROR: Permissions are required");
|
|
10830
10836
|
try {
|
|
10831
10837
|
O = await Ao(e, t, s, r, i, l, u);
|
|
10832
|
-
} catch (
|
|
10833
|
-
throw new Error(
|
|
10838
|
+
} catch (y) {
|
|
10839
|
+
throw new Error(y.message);
|
|
10834
10840
|
}
|
|
10835
10841
|
} else if (n === "update") {
|
|
10836
10842
|
if (!c || !a)
|
|
10837
10843
|
throw new Error("USER_ERROR");
|
|
10838
|
-
const
|
|
10839
|
-
if (o.Name !== i.Name && (
|
|
10844
|
+
const y = {};
|
|
10845
|
+
if (o.Name !== i.Name && (y.displayName = i.Name), o.Email !== i.Email && (y.email = i.Email, y.emailVerified = !1), o.Photo_URL !== i.Photo_URL && (y.photoURL = i.Photo_URL ? i.Photo_URL : void 0), o.Enabled !== i.Enabled && (y.disabled = !i.Enabled), u && (y.password = u), Object.keys(y).length)
|
|
10840
10846
|
try {
|
|
10841
|
-
await h.updateUser(o.User_ID,
|
|
10847
|
+
await h.updateUser(o.User_ID, y), y.disabled === !0 && await h.revokeRefreshTokens(o.User_ID);
|
|
10842
10848
|
} catch {
|
|
10843
|
-
throw await Jt(o.User_ID, a, c,
|
|
10849
|
+
throw await Jt(o.User_ID, a, c, p), new Error(p);
|
|
10844
10850
|
}
|
|
10845
10851
|
if (i.Role && i.Role !== o.Role)
|
|
10846
10852
|
try {
|
|
@@ -10849,7 +10855,7 @@ ${i}`);
|
|
|
10849
10855
|
role: i.Role
|
|
10850
10856
|
}), await h.revokeRefreshTokens(o.User_ID);
|
|
10851
10857
|
} catch {
|
|
10852
|
-
throw await Jt(o.User_ID, a, c,
|
|
10858
|
+
throw await Jt(o.User_ID, a, c, p), new Error(p);
|
|
10853
10859
|
}
|
|
10854
10860
|
try {
|
|
10855
10861
|
await d.collection("tenants").doc(e).collection("system_user_permissions").doc(o.User_ID).set({
|
|
@@ -10860,7 +10866,7 @@ ${i}`);
|
|
|
10860
10866
|
Enabled: i.Enabled ?? o.Enabled ?? !1
|
|
10861
10867
|
});
|
|
10862
10868
|
} catch {
|
|
10863
|
-
throw await Jt(o.User_ID, a, c,
|
|
10869
|
+
throw await Jt(o.User_ID, a, c, p), new Error(p);
|
|
10864
10870
|
}
|
|
10865
10871
|
if (o.Email !== i.Email) {
|
|
10866
10872
|
const g = s.auth.enableMultiFactorAuth;
|
|
@@ -10880,7 +10886,7 @@ ${i}`);
|
|
|
10880
10886
|
</br>
|
|
10881
10887
|
<a href="${b}">${b}</a>`);
|
|
10882
10888
|
} catch {
|
|
10883
|
-
throw await Jt(o.User_ID, a, c,
|
|
10889
|
+
throw await Jt(o.User_ID, a, c, p), new Error(p);
|
|
10884
10890
|
}
|
|
10885
10891
|
}
|
|
10886
10892
|
}
|
|
@@ -10888,8 +10894,8 @@ ${i}`);
|
|
|
10888
10894
|
} else if (n === "delete")
|
|
10889
10895
|
try {
|
|
10890
10896
|
await cn(o);
|
|
10891
|
-
} catch (
|
|
10892
|
-
throw new Error(
|
|
10897
|
+
} catch (y) {
|
|
10898
|
+
throw new Error(y.message);
|
|
10893
10899
|
}
|
|
10894
10900
|
if (O)
|
|
10895
10901
|
return O;
|
|
@@ -10930,11 +10936,11 @@ ${i}`);
|
|
|
10930
10936
|
const u = n.at(-1), h = Object.keys(c.collections).includes(u), d = l.disabledCollections?.includes(u);
|
|
10931
10937
|
if (!h || d)
|
|
10932
10938
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10933
|
-
const f = c.collections[u], { labels:
|
|
10939
|
+
const f = c.collections[u], { labels: p, fields: O, enableWriteLog: y } = f, g = Qe(p.collection, c), N = await ie(l.appName), b = gt(), x = ce();
|
|
10934
10940
|
let v;
|
|
10935
10941
|
r && await Ks(n, f);
|
|
10936
10942
|
const C = Ae(x, n, a);
|
|
10937
|
-
o = o || {}, o.collection =
|
|
10943
|
+
o = o || {}, o.collection = p.collection;
|
|
10938
10944
|
let _ = s?.originalRecord || await at(n, e, {
|
|
10939
10945
|
userId: r,
|
|
10940
10946
|
noComputedFields: !0,
|
|
@@ -10962,24 +10968,29 @@ ${i}`);
|
|
|
10962
10968
|
const E = Vs("update", n, t, c, N, "Online", r || "System", lt.now(), fe.serverTimestamp()), B = me(E);
|
|
10963
10969
|
for (const T of O)
|
|
10964
10970
|
!K(T) && Fe(E[T.name]) && T.nullable && (E[T.name] = null);
|
|
10965
|
-
Ve(E), Ve(_),
|
|
10966
|
-
const w =
|
|
10967
|
-
"update",
|
|
10968
|
-
E,
|
|
10969
|
-
e,
|
|
10970
|
-
o,
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
];
|
|
10971
|
+
Ve(E), Ve(_), y && !s?.providedTransaction && await Mt("update", "started", E, a, n, e, f, void 0, _);
|
|
10972
|
+
const w = {
|
|
10973
|
+
operation: "update",
|
|
10974
|
+
data: E,
|
|
10975
|
+
docId: e,
|
|
10976
|
+
context: o,
|
|
10977
|
+
originalRecord: me(_)
|
|
10978
|
+
};
|
|
10974
10979
|
await oe("preOperation", l, g, w);
|
|
10975
|
-
const I =
|
|
10980
|
+
const I = {
|
|
10981
|
+
operation: "update",
|
|
10982
|
+
data: E,
|
|
10983
|
+
docId: e,
|
|
10984
|
+
context: o,
|
|
10985
|
+
originalRecord: me(_)
|
|
10986
|
+
};
|
|
10976
10987
|
await oe("preWrite", l, g, I), Tn(f, E, c), Rn(f, E), Ve(E);
|
|
10977
10988
|
try {
|
|
10978
10989
|
if (Z && !i.password)
|
|
10979
10990
|
throw new Error("Password is required");
|
|
10980
10991
|
if (!s?.providedTransaction) {
|
|
10981
10992
|
const T = { ..._, ...E };
|
|
10982
|
-
await No("update", a, e, T, f, c), nt(T), await nn("update", T, f, g,
|
|
10993
|
+
await No("update", a, e, T, f, c), nt(T), await nn("update", T, f, g, { operation: "update", record: E, context: o, originalRecord: me(_) }, c);
|
|
10983
10994
|
}
|
|
10984
10995
|
} catch (T) {
|
|
10985
10996
|
throw new Error(`VALIDATION_ERROR: ${T.message}`);
|
|
@@ -10989,7 +11000,7 @@ ${i}`);
|
|
|
10989
11000
|
!K(T) && Fe(E[T.name]) && T.nullable && (E[T.name] = null);
|
|
10990
11001
|
try {
|
|
10991
11002
|
const T = { ..._, ...E };
|
|
10992
|
-
nt(T), Fo("update", f, E, _), Mo("update", E, B), await nn("update", T, f, g,
|
|
11003
|
+
nt(T), Fo("update", f, E, _), Mo("update", E, B), await nn("update", T, f, g, { operation: "update", record: E, context: o, originalRecord: _ }, c);
|
|
10993
11004
|
} catch (T) {
|
|
10994
11005
|
throw new Error(`VALIDATION_ERROR: ${T.message}`);
|
|
10995
11006
|
}
|
|
@@ -11056,7 +11067,7 @@ ${i}`);
|
|
|
11056
11067
|
if (Js(Jn)) {
|
|
11057
11068
|
if (z && z.size++, z && z.size > 500)
|
|
11058
11069
|
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.");
|
|
11059
|
-
const er = await T.get(x.collection("tenants").doc(a).collection("system_unique").doc(
|
|
11070
|
+
const er = await T.get(x.collection("tenants").doc(a).collection("system_unique").doc(p.collection).collection(`Unique-${p.collection}-${_e.name}`).doc(Jn));
|
|
11060
11071
|
if (er.exists && er.data().id !== e)
|
|
11061
11072
|
throw new Error(`VALIDATION_ERROR: ${_e.name} "${E[_e.name]}" already exists`);
|
|
11062
11073
|
} else
|
|
@@ -11093,26 +11104,23 @@ ${i}`);
|
|
|
11093
11104
|
let ee;
|
|
11094
11105
|
!s?.noTwoWay && !s?.providedTransaction && (ee = await $o("Update", a, e, Q, E, f, c, T, z, r, v, _));
|
|
11095
11106
|
const Ze = Ls(c);
|
|
11096
|
-
Ys("update", T, n, e, E, c, f, s, Ze, fe.arrayUnion, fe.arrayRemove, fe.delete, (he) => x.collection("tenants").doc(a).collection("system_fields").doc(
|
|
11107
|
+
Ys("update", T, n, e, E, c, f, s, Ze, fe.arrayUnion, fe.arrayRemove, fe.delete, (he) => x.collection("tenants").doc(a).collection("system_fields").doc(p.collection).collection(`${p.collection}-${he.name}`).doc(e), (he, Re) => x.collection("tenants").doc(a).collection("system_unique").doc(p.collection).collection(`Unique-${p.collection}-${he.name}`).doc(Re), (he) => x.collection("tenants").doc(a).collection("system_fields").doc(p.collection).collection(`${p.collection}-${he}`).doc(e), (he, Re) => Ae(x, he, a).doc(Re), (he, Re, we) => x.collection("tenants").doc(a).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Re}`).doc(we), (he, Re, we) => x.collection("tenants").doc(a).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Re.replaceAll(" ", "-")}`).doc(we), _, ee, z), T.update(C.doc(e), E);
|
|
11097
11108
|
} catch (z) {
|
|
11098
11109
|
if (s?.providedTransaction)
|
|
11099
11110
|
throw z;
|
|
11100
11111
|
{
|
|
11101
|
-
const Q =
|
|
11102
|
-
"update",
|
|
11103
|
-
E,
|
|
11104
|
-
e,
|
|
11105
|
-
o,
|
|
11106
|
-
z,
|
|
11107
|
-
|
|
11108
|
-
|
|
11109
|
-
|
|
11110
|
-
me(_)
|
|
11111
|
-
], ee = await oe("postWriteError", l, g, Q);
|
|
11112
|
-
if (p && (await new Promise((Ze) => {
|
|
11112
|
+
const Q = {
|
|
11113
|
+
operation: "update",
|
|
11114
|
+
data: E,
|
|
11115
|
+
docId: e,
|
|
11116
|
+
context: o,
|
|
11117
|
+
error: z,
|
|
11118
|
+
originalRecord: me(_)
|
|
11119
|
+
}, ee = await oe("postWriteError", l, g, Q);
|
|
11120
|
+
if (y && (await new Promise((Ze) => {
|
|
11113
11121
|
setTimeout(Ze, 250);
|
|
11114
11122
|
}), await Mt("update", ee?.resolved ? "success" : "failed", E, a, n, e, f, ee?.resolved ? void 0 : z, _)), !ee?.resolved)
|
|
11115
|
-
throw Z && await cn(_), M(_) && await Jt(_.User_ID, L, S, "USER_ERROR"), k && await x.collection("tenants").doc(a).collection(
|
|
11123
|
+
throw Z && await cn(_), M(_) && await Jt(_.User_ID, L, S, "USER_ERROR"), k && await x.collection("tenants").doc(a).collection(p.collection).doc(e).update({ User_ID: fe.delete() }), z;
|
|
11116
11124
|
}
|
|
11117
11125
|
}
|
|
11118
11126
|
(Z || M(_) || k) && await Gr(Kr, [e, _.User_ID]).catch(() => {
|
|
@@ -11130,7 +11138,7 @@ ${i}`);
|
|
|
11130
11138
|
}
|
|
11131
11139
|
const L = { ..._, ...E };
|
|
11132
11140
|
nt(L);
|
|
11133
|
-
const z = await Wc(i?.operation || "update", a, e, l,
|
|
11141
|
+
const z = await Wc(i?.operation || "update", a, e, l, p.collection, L, _, T, i?.permissions, S, i?.password);
|
|
11134
11142
|
Z && (E.User_ID = z), k && (E.User_ID = fe.delete());
|
|
11135
11143
|
}
|
|
11136
11144
|
s?.providedTransaction ? await A(s.providedTransaction, T) : await x.runTransaction(async (L) => {
|
|
@@ -11142,14 +11150,13 @@ ${i}`);
|
|
|
11142
11150
|
}), T;
|
|
11143
11151
|
}
|
|
11144
11152
|
if (!s?.providedTransaction) {
|
|
11145
|
-
const T =
|
|
11146
|
-
"update",
|
|
11147
|
-
E,
|
|
11148
|
-
e,
|
|
11149
|
-
o,
|
|
11150
|
-
|
|
11151
|
-
|
|
11152
|
-
], L = [...T];
|
|
11153
|
+
const T = {
|
|
11154
|
+
operation: "update",
|
|
11155
|
+
data: E,
|
|
11156
|
+
docId: e,
|
|
11157
|
+
context: o,
|
|
11158
|
+
originalRecord: me(_)
|
|
11159
|
+
}, L = { ...T };
|
|
11153
11160
|
await oe("postWrite", l, g, T), await oe("postOperation", l, g, L);
|
|
11154
11161
|
}
|
|
11155
11162
|
const q = { ..._, ...E };
|
|
@@ -11164,7 +11171,7 @@ ${i}`);
|
|
|
11164
11171
|
const l = n.at(-1), c = Object.keys(a.collections).includes(l), u = o.disabledCollections?.includes(l);
|
|
11165
11172
|
if (!c || u)
|
|
11166
11173
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
11167
|
-
const h = a.collections[l], { labels: d, auth: f, enableWriteLog:
|
|
11174
|
+
const h = a.collections[l], { labels: d, auth: f, enableWriteLog: p, softDelete: O } = h, y = Qe(d.collection, a), g = await ie(o.appName);
|
|
11168
11175
|
if (O && !f && !t?.force)
|
|
11169
11176
|
return await Zc(n, e, { [O.archivedField]: !0, [O.timestampField]: fe.serverTimestamp() }, { userId: s });
|
|
11170
11177
|
const N = ce();
|
|
@@ -11175,11 +11182,11 @@ ${i}`);
|
|
|
11175
11182
|
const v = await at(n, e, { userId: s });
|
|
11176
11183
|
let C = Vs("delete", n, v, a, g, "Online", s || "System", lt.now(), fe.serverTimestamp());
|
|
11177
11184
|
const _ = Sn(C);
|
|
11178
|
-
Ve(C),
|
|
11185
|
+
Ve(C), p && await Mt("delete", "started", C, i, n, e, h), await oe("preOperation", o, y, { operation: "delete", data: C, docId: e, context: r }), await oe("preWrite", o, y, { operation: "delete", data: C, docId: e, context: r }), Ve(C);
|
|
11179
11186
|
const m = async (w) => {
|
|
11180
11187
|
const [I, S, R, A] = await Promise.all([
|
|
11181
11188
|
w.get(N.collection("system_deployment").doc("maintenance_mode")),
|
|
11182
|
-
at(
|
|
11189
|
+
at(n, e, { userId: s, providedTransaction: w }),
|
|
11183
11190
|
s ? w.get(N.collection("tenants").doc(i).collection("system_user_permissions").doc(s)) : Promise.resolve({}),
|
|
11184
11191
|
Ye()
|
|
11185
11192
|
]);
|
|
@@ -11200,7 +11207,7 @@ ${i}`);
|
|
|
11200
11207
|
}
|
|
11201
11208
|
if (s && b?.Role) {
|
|
11202
11209
|
const P = b.Role;
|
|
11203
|
-
if (!(
|
|
11210
|
+
if (!(y.custom?.serverAccess?.delete !== void 0 ? await ie(y.custom.serverAccess.delete, [P, C]) : !0))
|
|
11204
11211
|
throw new Error("PERMISSION_DENIED");
|
|
11205
11212
|
}
|
|
11206
11213
|
};
|
|
@@ -11214,14 +11221,14 @@ ${i}`);
|
|
|
11214
11221
|
Ys("delete", w, n, e, C, a, h, t, I, fe.arrayUnion, fe.arrayRemove, fe.delete, (S) => N.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S.name}`).doc(e), (S, R) => N.collection("tenants").doc(i).collection("system_unique").doc(d.collection).collection(`Unique-${d.collection}-${S.name}`).doc(R), (S) => N.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S}`).doc(e), (S, R) => Ae(N, S, i).doc(R), (S, R, A) => N.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${R}`).doc(A), (S, R, A) => N.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${R.replaceAll(" ", "-")}`).doc(A)), w.delete(x.doc(e));
|
|
11215
11222
|
}, { maxAttempts: 10 });
|
|
11216
11223
|
} catch (w) {
|
|
11217
|
-
const S = await oe("postWriteError", o,
|
|
11218
|
-
if (
|
|
11224
|
+
const S = await oe("postWriteError", o, y, { operation: "delete", data: C, docId: e, context: r, error: w });
|
|
11225
|
+
if (p && (await new Promise((R) => {
|
|
11219
11226
|
setTimeout(R, 250);
|
|
11220
11227
|
}), await Mt("delete", S?.resolved ? "success" : "failed", C, i, n, e, h, S?.resolved ? void 0 : w)), !S?.resolved)
|
|
11221
11228
|
throw h.auth && C.User_ID && await N.collection("tenants").doc(i).collection(d.collection).doc(e).update({ User_ID: fe.delete() }), w;
|
|
11222
11229
|
}
|
|
11223
|
-
const M =
|
|
11224
|
-
return await oe("postWrite", o,
|
|
11230
|
+
const M = { operation: "delete", data: C, docId: e, context: r }, E = { ...M };
|
|
11231
|
+
return await oe("postWrite", o, y, M), await oe("postOperation", o, y, E), { id: e, ...C };
|
|
11225
11232
|
}, mu = async (n, e) => {
|
|
11226
11233
|
const t = ce(), s = ko(), r = process.env.ADMIN_SMS;
|
|
11227
11234
|
if (s === "development")
|
|
@@ -11231,7 +11238,7 @@ ${i}`);
|
|
|
11231
11238
|
throw new Error("Admin phone not set");
|
|
11232
11239
|
const i = { to: n, body: e };
|
|
11233
11240
|
await t.collection("system_messages").add(i);
|
|
11234
|
-
}, zc = (n) => n !== null && typeof n == "object",
|
|
11241
|
+
}, zc = (n) => n !== null && typeof n == "object", pu = (n) => {
|
|
11235
11242
|
const e = (t) => {
|
|
11236
11243
|
Object.entries(t).forEach(([s, r]) => {
|
|
11237
11244
|
r instanceof lt ? t[s] = {
|
|
@@ -11241,7 +11248,7 @@ ${i}`);
|
|
|
11241
11248
|
});
|
|
11242
11249
|
};
|
|
11243
11250
|
e(n);
|
|
11244
|
-
},
|
|
11251
|
+
}, yu = async (n) => await gt().getUser(n), gu = (n) => {
|
|
11245
11252
|
const e = bo();
|
|
11246
11253
|
return V.fromJSDate(n).setZone(e);
|
|
11247
11254
|
}, qc = (n) => {
|
|
@@ -11281,7 +11288,7 @@ export {
|
|
|
11281
11288
|
Ro as getSome,
|
|
11282
11289
|
Je as getTenant,
|
|
11283
11290
|
bo as getTimezone,
|
|
11284
|
-
|
|
11291
|
+
yu as getUser,
|
|
11285
11292
|
ou as getVersionInfo,
|
|
11286
11293
|
Aa as getZodSchema,
|
|
11287
11294
|
cu as initializeFirebase,
|
|
@@ -11292,7 +11299,7 @@ export {
|
|
|
11292
11299
|
lu as runChildProcess,
|
|
11293
11300
|
Do as sendMail,
|
|
11294
11301
|
mu as sendMessage,
|
|
11295
|
-
|
|
11302
|
+
pu as serializeTimestamps,
|
|
11296
11303
|
iu as setTenant,
|
|
11297
11304
|
ie as tryPromise,
|
|
11298
11305
|
Zc as updateRecord,
|