@stoker-platform/node-client 0.5.11 → 0.5.13
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 +1167 -1161
- package/dist/types/read/getSome.d.ts +1 -0
- package/dist/types/write/addRecord.d.ts +3 -1
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -15,7 +15,7 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
15
15
|
const { labels: s } = n;
|
|
16
16
|
return t.collections && // eslint-disable-next-line security/detect-object-injection
|
|
17
17
|
Te("Update", t.collections[s.collection]) && (!e.access || Zn(e, t)) && ai(e, t) && !(n.auth && !t.collections?.[s.collection].auth && ["Enabled", "Role", "Name", "Email", "Photo_URL"].includes(e.name));
|
|
18
|
-
},
|
|
18
|
+
}, V = (n, e) => n.filter((t) => t.name === e)[0], K = (n) => ["OneToOne", "OneToMany", "ManyToOne", "ManyToMany"].includes(n.type), li = (n, e) => {
|
|
19
19
|
const t = {
|
|
20
20
|
Record_Owner: "recordOwner",
|
|
21
21
|
Record_User: "recordUser",
|
|
@@ -39,7 +39,7 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
39
39
|
return i?.parentFilters?.forEach((o) => {
|
|
40
40
|
if (!o.roles.some((d) => d.role === t.Role))
|
|
41
41
|
return;
|
|
42
|
-
const a = o.collectionField, l =
|
|
42
|
+
const a = o.collectionField, l = V(n.fields, a);
|
|
43
43
|
if (!K(l))
|
|
44
44
|
throw new Error("PERMISSION_DENIED");
|
|
45
45
|
const c = t.collections?.[l.collection], h = e.collections[l.collection].access.entityRestrictions;
|
|
@@ -75,31 +75,31 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
75
75
|
}), c?.filter((p) => p.type === "Record_User").forEach((p) => {
|
|
76
76
|
if ("operations" in p && p.operations && !p.operations.includes(n))
|
|
77
77
|
return;
|
|
78
|
-
const
|
|
79
|
-
i[`${
|
|
78
|
+
const R = V(o, p.collectionField);
|
|
79
|
+
i[`${R.name}_Array`]?.includes(r.Doc_ID) || (l = !1);
|
|
80
80
|
}), c?.filter((p) => p.type === "Record_Property").forEach((p) => {
|
|
81
81
|
if ("operations" in p && p.operations && !p.operations.includes(n))
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const R = V(o, p.propertyField), A = p.roles.find((v) => v.role === r.Role);
|
|
84
|
+
R.type === "Array" ? A.values?.some((v) => i[R.name].includes(v)) || (l = !1) : A.values?.includes(i[R.name]) || (l = !1);
|
|
85
85
|
});
|
|
86
86
|
let f = !0, d = !1;
|
|
87
87
|
u?.filter((p) => p.type === "Individual").forEach(() => {
|
|
88
88
|
d = !0, a.individualEntities?.includes(i.id) || (f = !1);
|
|
89
89
|
});
|
|
90
|
-
let m = !0,
|
|
90
|
+
let m = !0, b = !1;
|
|
91
91
|
if (u?.filter((p) => p.type === "Parent").forEach((p) => {
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
a.parentEntities?.some((
|
|
92
|
+
b = !0;
|
|
93
|
+
const R = V(o, p.collectionField);
|
|
94
|
+
a.parentEntities?.some((A) => i[`${R.name}_Array`].includes(A)) || (m = !1);
|
|
95
95
|
}), u?.filter((p) => p.type === "Parent_Property").forEach((p) => {
|
|
96
|
-
|
|
97
|
-
const
|
|
96
|
+
b = !0;
|
|
97
|
+
const R = V(o, p.collectionField), A = V(o, p.propertyField);
|
|
98
98
|
Object.entries(a.parentPropertyEntities || {}).some((v) => {
|
|
99
|
-
const [
|
|
100
|
-
return
|
|
99
|
+
const [j, I] = v;
|
|
100
|
+
return j === i[A.name] && i[`${R.name}_Array`].some((g) => I.includes(g));
|
|
101
101
|
}) || (m = !1);
|
|
102
|
-
}), d &&
|
|
102
|
+
}), d && b) {
|
|
103
103
|
if (!(f || m)) {
|
|
104
104
|
l = !1;
|
|
105
105
|
return;
|
|
@@ -108,42 +108,42 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
108
108
|
l = !1;
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
let y = !0,
|
|
111
|
+
let y = !0, _ = !1;
|
|
112
112
|
h?.filter((p) => p.parentFilter.type === "Individual").forEach((p) => {
|
|
113
|
-
|
|
114
|
-
const { parentFilter:
|
|
113
|
+
_ = !0;
|
|
114
|
+
const { parentFilter: R } = p, A = V(o, R.collectionField), v = r.collections?.[A.collection];
|
|
115
115
|
if (!v) {
|
|
116
116
|
l = !1;
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
v.individualEntities?.some((
|
|
119
|
+
v.individualEntities?.some((j) => i[`${A.name}_Array`].includes(j)) || (y = !1);
|
|
120
120
|
});
|
|
121
|
-
let
|
|
121
|
+
let S = !0, x = !1;
|
|
122
122
|
if (h?.filter((p) => p.parentFilter.type === "Parent").forEach((p) => {
|
|
123
|
-
|
|
124
|
-
const { parentFilter:
|
|
125
|
-
if (!
|
|
123
|
+
x = !0;
|
|
124
|
+
const { parentFilter: R } = p, A = V(o, R.collectionField), v = V(o, R.parentCollectionField), j = r.collections?.[A.collection];
|
|
125
|
+
if (!j) {
|
|
126
126
|
l = !1;
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
j.parentEntities?.some((I) => i[`${v.name}_Array`].includes(I)) || (S = !1);
|
|
130
130
|
}), h?.filter((p) => p.parentFilter.type === "Parent_Property").forEach((p) => {
|
|
131
|
-
|
|
132
|
-
const { parentFilter:
|
|
133
|
-
if (!
|
|
131
|
+
x = !0;
|
|
132
|
+
const { parentFilter: R } = p, A = V(o, R.collectionField), v = V(o, R.parentPropertyField), j = V(o, R.parentCollectionField), I = r.collections?.[A.collection];
|
|
133
|
+
if (!I) {
|
|
134
134
|
l = !1;
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
Object.entries(
|
|
138
|
-
const [k,
|
|
139
|
-
return k === i[v.name] && i[`${
|
|
140
|
-
}) || (
|
|
141
|
-
}),
|
|
142
|
-
if (!(y ||
|
|
137
|
+
Object.entries(I.parentPropertyEntities || {}).some((g) => {
|
|
138
|
+
const [k, E] = g;
|
|
139
|
+
return k === i[v.name] && i[`${j.name}_Array`].some((B) => E.includes(B));
|
|
140
|
+
}) || (S = !1);
|
|
141
|
+
}), _ && x) {
|
|
142
|
+
if (!(y || S)) {
|
|
143
143
|
l = !1;
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
} else if (!y || !
|
|
146
|
+
} else if (!y || !S) {
|
|
147
147
|
l = !1;
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
@@ -259,30 +259,30 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
259
259
|
for (const i of Object.values(n.collections)) {
|
|
260
260
|
const { labels: o, access: a, fields: l } = i, { operations: c, attributeRestrictions: u, entityRestrictions: h } = a, f = c.assignable, d = e.collections?.[o.collection], m = ["read", "create", "update", "delete"];
|
|
261
261
|
if (f !== !0 && !(typeof f == "object" && f.includes(t)) ? m.forEach((y) => {
|
|
262
|
-
const
|
|
262
|
+
const _ = y.charAt(0).toUpperCase() + y.slice(1);
|
|
263
263
|
if (y !== "assignable") {
|
|
264
|
-
const
|
|
265
|
-
if (!
|
|
264
|
+
const S = !!a.operations[y]?.includes(t), x = !!d?.operations.includes(_);
|
|
265
|
+
if (!S && x) {
|
|
266
266
|
r = `Collection ${o.collection} has excess ${y} operation for role ${t}`, s = !1;
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
|
-
if (
|
|
269
|
+
if (S && !x) {
|
|
270
270
|
r = `Collection ${o.collection} has missing ${y} operation for role ${t}`, s = !1;
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
}) : m.forEach((y) => {
|
|
275
|
-
const
|
|
275
|
+
const _ = y.charAt(0).toUpperCase() + y.slice(1);
|
|
276
276
|
if (y !== "assignable") {
|
|
277
|
-
const
|
|
278
|
-
if (!
|
|
277
|
+
const S = !!a.operations[y]?.includes(t), x = !!d?.operations.includes(_);
|
|
278
|
+
if (!S && x) {
|
|
279
279
|
r = `Collection ${o.collection} has excess ${y} operation for role ${t}`, s = !1;
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}), !u && !h || (u?.forEach((y) => {
|
|
284
|
-
for (const
|
|
285
|
-
if (
|
|
284
|
+
for (const _ of y.roles)
|
|
285
|
+
if (_.role === t && !_.assignable) {
|
|
286
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;
|
|
@@ -298,17 +298,17 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
298
298
|
}
|
|
299
299
|
}), h?.assignable?.includes(t)))
|
|
300
300
|
continue;
|
|
301
|
-
let
|
|
301
|
+
let b = !1;
|
|
302
302
|
if (h?.restrictions?.forEach((y) => {
|
|
303
|
-
for (const
|
|
304
|
-
if (
|
|
305
|
-
if (
|
|
303
|
+
for (const _ of y.roles)
|
|
304
|
+
if (_.role === t) {
|
|
305
|
+
if (b = !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
309
|
if (y.type === "Parent") {
|
|
310
|
-
const
|
|
311
|
-
if (!K(
|
|
310
|
+
const S = V(l, y.collectionField);
|
|
311
|
+
if (!K(S)) {
|
|
312
312
|
s = !1;
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
@@ -318,18 +318,18 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
if (y.type === "Parent_Property") {
|
|
321
|
-
const
|
|
322
|
-
if (!K(
|
|
321
|
+
const S = V(l, y.collectionField);
|
|
322
|
+
if (!K(S)) {
|
|
323
323
|
s = !1;
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
|
-
if (!e.collections?.[o.collection]?.parentPropertyEntities?.[
|
|
326
|
+
if (!e.collections?.[o.collection]?.parentPropertyEntities?.[S.collection]) {
|
|
327
327
|
r = `Collection ${o.collection} is missing parent property entities`, s = !1;
|
|
328
328
|
return;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
}),
|
|
332
|
+
}), b && !e.collections?.[o.collection]?.restrictEntities) {
|
|
333
333
|
r = `Collection ${o.collection} must have restrictEntities set to true`, s = !1;
|
|
334
334
|
return;
|
|
335
335
|
}
|
|
@@ -341,19 +341,19 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
341
341
|
const d = u?.filter((m) => s === m.userRole);
|
|
342
342
|
return d?.length && !d.some((m) => m.recordRole === r) ? (f = `User ${s} does not have write access to record with role ${r}`, h = !1, h) : n === "update" && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
343
343
|
o.User_ID && d?.length && !d.some((m) => m.recordRole === a) ? (f = `User ${s} does not have write access to record with role ${r}`, h = !1, h) : (u?.forEach((m) => {
|
|
344
|
-
s === m.userRole && m.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((
|
|
345
|
-
const y = i.collections?.[
|
|
346
|
-
if (!(n === "update" && ze(y,
|
|
347
|
-
const
|
|
348
|
-
if (
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
if (!(y.operations.every((
|
|
352
|
-
f = `User ${s} does not have write access to all included operations for collection ${
|
|
344
|
+
s === m.userRole && m.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((b) => {
|
|
345
|
+
const y = i.collections?.[b], _ = l?.collections?.[b];
|
|
346
|
+
if (!(n === "update" && ze(y, _)) && y) {
|
|
347
|
+
const S = m.collections.some((x) => x.collection === b);
|
|
348
|
+
if (S) {
|
|
349
|
+
if (S) {
|
|
350
|
+
const x = m.collections.find((R) => R.collection === b);
|
|
351
|
+
if (!(y.operations.every((R) => x.operations.includes(R)) || n === "update" && ze(y.operations, _?.operations))) {
|
|
352
|
+
f = `User ${s} does not have write access to all included operations for collection ${b}`, h = !1;
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
if (!
|
|
356
|
-
f = `User ${s} does not have write access to auth for collection ${
|
|
355
|
+
if (!x.auth && y.auth && !(n === "update" && ze(y.auth, _?.auth))) {
|
|
356
|
+
f = `User ${s} does not have write access to auth for collection ${b}`, h = !1;
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
const p = {
|
|
@@ -361,19 +361,19 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
361
361
|
recordUser: "Record_User",
|
|
362
362
|
recordProperty: "Record_Property"
|
|
363
363
|
};
|
|
364
|
-
if (Object.keys(p).forEach((
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
f = `User ${s} does not have write access to attribute restriction ${
|
|
364
|
+
if (Object.keys(p).forEach((R) => {
|
|
365
|
+
const A = p[R];
|
|
366
|
+
if (x.attributeRestrictions?.includes(A) && !(y[R]?.active || n === "update" && ze(y[R], _?.[R]))) {
|
|
367
|
+
f = `User ${s} does not have write access to attribute restriction ${R} for collection ${b}`, h = !1;
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
}),
|
|
371
|
-
f = `User ${s} does not have write access to restrictEntities for collection ${
|
|
370
|
+
}), x.restrictEntities && !y.restrictEntities && !(n === "update" && ze(y.restrictEntities, _?.restrictEntities))) {
|
|
371
|
+
f = `User ${s} does not have write access to restrictEntities for collection ${b}`, h = !1;
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
} else {
|
|
376
|
-
f = `User ${s} does not have write access to collection ${
|
|
376
|
+
f = `User ${s} does not have write access to collection ${b}`, h = !1;
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
379
|
}
|
|
@@ -450,18 +450,18 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
450
450
|
}, or = (n, e, t, s, r, i, o, a, l, c) => {
|
|
451
451
|
const { labels: u, fields: h } = s, f = o?.collections?.[u.collection], d = { ...e, ...n };
|
|
452
452
|
nt(d);
|
|
453
|
-
let m = !0,
|
|
453
|
+
let m = !0, b = "";
|
|
454
454
|
if (i && !f)
|
|
455
455
|
throw new Error("PERMISSION_DENIED");
|
|
456
|
-
i && !Te("Update", f) && (m = !1,
|
|
456
|
+
i && !Te("Update", f) && (m = !1, b = "Authenticated user does not have Update access to this collection"), i && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
457
457
|
(!it("Update", s, r, i, o, e) || // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
458
|
-
!it("Update", s, r, i, o, d)) && (m = !1,
|
|
458
|
+
!it("Update", s, r, i, o, d)) && (m = !1, b = "Authenticated user does not have Update access to this document"), a && (i && !jn(f) && (m = !1, b = "Authenticated user does not have Auth access for this collection"), Vs("update", d, t, s, r, i, o, l, c, e, a) || (b = "Authenticated user does not have sufficient write access for this record", m = !1));
|
|
459
459
|
for (const y of h) {
|
|
460
|
-
const
|
|
461
|
-
y.access && !Zn(y, o) &&
|
|
460
|
+
const _ = n[y.name];
|
|
461
|
+
y.access && !Zn(y, o) && _ !== void 0 && (b = `Authenticated user does not have access to field ${y.name}`, m = !1), _ !== void 0 && !ai(y, o) && (b = `Authenticated user does not have Update access to field ${y.name}`, m = !1);
|
|
462
462
|
}
|
|
463
463
|
if (!m)
|
|
464
|
-
throw
|
|
464
|
+
throw b && console.error(`PERMISSION_DENIED: ${b}`), new Error("PERMISSION_DENIED");
|
|
465
465
|
}, Qo = (n, e, t, s, r, i) => {
|
|
466
466
|
const { labels: o } = t, a = i.collections?.[o.collection];
|
|
467
467
|
let l = !0;
|
|
@@ -504,7 +504,7 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
504
504
|
for (const i of r.parentFilters) {
|
|
505
505
|
if (!i.roles.some((c) => c.role === n))
|
|
506
506
|
continue;
|
|
507
|
-
const o =
|
|
507
|
+
const o = V(e.fields, i.collectionField);
|
|
508
508
|
if (!K(o))
|
|
509
509
|
throw new Error("PERMISSION_DENIED");
|
|
510
510
|
const l = t.collections[o.collection].access.entityRestrictions?.restrictions?.find((c) => c.type === i.type && c.roles.some((u) => u.role === n));
|
|
@@ -656,39 +656,39 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
656
656
|
if (l.roles.some((c) => c.role === e))
|
|
657
657
|
switch (l.type) {
|
|
658
658
|
case "Record_Owner":
|
|
659
|
-
t.push(
|
|
659
|
+
t.push(V(a, "Created_By"));
|
|
660
660
|
break;
|
|
661
661
|
case "Record_User":
|
|
662
|
-
t.push(
|
|
662
|
+
t.push(V(r, l.collectionField));
|
|
663
663
|
break;
|
|
664
664
|
case "Record_Property":
|
|
665
|
-
t.push(
|
|
665
|
+
t.push(V(r, l.propertyField));
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
668
|
}), o && (o.restrictions?.forEach((l) => {
|
|
669
669
|
if (l.roles.some((c) => c.role === e))
|
|
670
670
|
switch (l.type) {
|
|
671
671
|
case "Individual":
|
|
672
|
-
t.push(
|
|
672
|
+
t.push(V(a, "id"));
|
|
673
673
|
break;
|
|
674
674
|
case "Parent":
|
|
675
|
-
t.push(
|
|
675
|
+
t.push(V(r, l.collectionField));
|
|
676
676
|
break;
|
|
677
677
|
case "Parent_Property":
|
|
678
|
-
t.push(
|
|
678
|
+
t.push(V(r, l.collectionField)), t.push(V(r, l.propertyField));
|
|
679
679
|
break;
|
|
680
680
|
}
|
|
681
681
|
}), o.parentFilters && o.parentFilters.forEach((l) => {
|
|
682
682
|
if (l.roles.some((c) => c.role === e))
|
|
683
683
|
switch (l.type) {
|
|
684
684
|
case "Individual":
|
|
685
|
-
t.push(
|
|
685
|
+
t.push(V(r, l.collectionField));
|
|
686
686
|
break;
|
|
687
687
|
case "Parent":
|
|
688
|
-
t.push(
|
|
688
|
+
t.push(V(r, l.parentCollectionField));
|
|
689
689
|
break;
|
|
690
690
|
case "Parent_Property":
|
|
691
|
-
t.push(
|
|
691
|
+
t.push(V(r, l.parentCollectionField)), t.push(V(r, l.parentPropertyField));
|
|
692
692
|
break;
|
|
693
693
|
}
|
|
694
694
|
})), [...new Set(t)];
|
|
@@ -701,19 +701,19 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
701
701
|
}), s.forEach((c) => {
|
|
702
702
|
(!c.access || c.access.includes(e)) && t.push(c);
|
|
703
703
|
}), r?.filter((c) => (!c.roles || c.roles.includes(e)) && c.field !== "Collection_Path").forEach((c) => {
|
|
704
|
-
t.push(
|
|
704
|
+
t.push(V(a, c.field));
|
|
705
705
|
}), i?.range && i.range.fields.forEach((c) => {
|
|
706
|
-
pt.includes(c) && t.push(
|
|
706
|
+
pt.includes(c) && t.push(V(a, c));
|
|
707
707
|
}), o?.forEach((c) => {
|
|
708
|
-
const u =
|
|
709
|
-
(!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(
|
|
708
|
+
const u = V(s.concat(a), c.field);
|
|
709
|
+
(!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(V(a, c.field));
|
|
710
710
|
}), hi(n, e).forEach((c) => {
|
|
711
|
-
pt.includes(c.name) && t.push(
|
|
711
|
+
pt.includes(c.name) && t.push(V(a, c.name));
|
|
712
712
|
}), [...new Set(t)];
|
|
713
713
|
}, ra = (n, e, t) => {
|
|
714
714
|
const s = [], { fields: r, preloadCache: i } = e, o = zn();
|
|
715
715
|
i?.range && i.range.fields.forEach((c) => {
|
|
716
|
-
pt.includes(c) ? s.push(
|
|
716
|
+
pt.includes(c) ? s.push(V(o, c)) : s.push(V(r, c));
|
|
717
717
|
});
|
|
718
718
|
const a = /* @__PURE__ */ new Set(), l = fi(e, t);
|
|
719
719
|
return Object.entries(l).map(([c, u]) => {
|
|
@@ -746,9 +746,9 @@ const jn = (n) => !!n.auth, Te = (n, e) => {
|
|
|
746
746
|
});
|
|
747
747
|
});
|
|
748
748
|
}), o.forEach((l) => {
|
|
749
|
-
s.push(
|
|
749
|
+
s.push(V(r, l));
|
|
750
750
|
}), i) {
|
|
751
|
-
const l =
|
|
751
|
+
const l = V(r, i.archivedField);
|
|
752
752
|
l && s.push(l);
|
|
753
753
|
}
|
|
754
754
|
return s.push(...ra(n, e, t)), [...new Set(s)];
|
|
@@ -810,7 +810,7 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n == "create" && (t.Collection_Pat
|
|
|
810
810
|
const { access: t, queries: s } = n, { serverReadOnly: r } = t, i = /* @__PURE__ */ new Set();
|
|
811
811
|
if (s)
|
|
812
812
|
for (const o of s) {
|
|
813
|
-
const a =
|
|
813
|
+
const a = V(e, o.field);
|
|
814
814
|
e.find((l) => l.name === o.field) && K(a) && ["OneToOne", "OneToMany"].includes(a.type) && i.add(a);
|
|
815
815
|
}
|
|
816
816
|
return e.forEach((o) => {
|
|
@@ -830,7 +830,7 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n == "create" && (t.Collection_Pat
|
|
|
830
830
|
e[`${i.name}_Array`] = e[i.name];
|
|
831
831
|
else if (e[`${i.name}_Array`] = Object.keys(e[i.name]), i.includeFields)
|
|
832
832
|
for (const o of i.includeFields) {
|
|
833
|
-
const a = t.collections[i.collection], l =
|
|
833
|
+
const a = t.collections[i.collection], l = V(a.fields, o);
|
|
834
834
|
wt(a, [l]).size === 1 && Object.keys(e[i.name]).forEach((u) => {
|
|
835
835
|
e[i.name][u][o] ? e[i.name][u][`${o}_Lowercase`] = e[i.name][u][o].toLowerCase() : delete e[i.name][u][`${o}_Lowercase`];
|
|
836
836
|
});
|
|
@@ -856,7 +856,7 @@ const Ws = (n, e, t, s, r, i, o, a, l, c) => (n == "create" && (t.Collection_Pat
|
|
|
856
856
|
}, oa = async (n, e, t, s) => {
|
|
857
857
|
const { fields: r } = e;
|
|
858
858
|
for (const i of t.fields) {
|
|
859
|
-
const o =
|
|
859
|
+
const o = V(r, i.name);
|
|
860
860
|
i.custom?.initialValue && !(s && o.access && !o.access.includes(s)) && (n[i.name] = await ie(i.custom.initialValue, [n]), wt(e, [o]).size === 1 && (n[`${i.name}_Lowercase`] = n[i.name].toLowerCase()));
|
|
861
861
|
}
|
|
862
862
|
for (const i of r)
|
|
@@ -907,7 +907,7 @@ var ar;
|
|
|
907
907
|
// second overwrites first
|
|
908
908
|
});
|
|
909
909
|
})(ar || (ar = {}));
|
|
910
|
-
const
|
|
910
|
+
const L = te.arrayToEnum([
|
|
911
911
|
"string",
|
|
912
912
|
"nan",
|
|
913
913
|
"number",
|
|
@@ -931,25 +931,25 @@ const U = te.arrayToEnum([
|
|
|
931
931
|
]), Xe = (n) => {
|
|
932
932
|
switch (typeof n) {
|
|
933
933
|
case "undefined":
|
|
934
|
-
return
|
|
934
|
+
return L.undefined;
|
|
935
935
|
case "string":
|
|
936
|
-
return
|
|
936
|
+
return L.string;
|
|
937
937
|
case "number":
|
|
938
|
-
return Number.isNaN(n) ?
|
|
938
|
+
return Number.isNaN(n) ? L.nan : L.number;
|
|
939
939
|
case "boolean":
|
|
940
|
-
return
|
|
940
|
+
return L.boolean;
|
|
941
941
|
case "function":
|
|
942
|
-
return
|
|
942
|
+
return L.function;
|
|
943
943
|
case "bigint":
|
|
944
|
-
return
|
|
944
|
+
return L.bigint;
|
|
945
945
|
case "symbol":
|
|
946
|
-
return
|
|
946
|
+
return L.symbol;
|
|
947
947
|
case "object":
|
|
948
|
-
return Array.isArray(n) ?
|
|
948
|
+
return Array.isArray(n) ? L.array : n === null ? L.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? L.promise : typeof Map < "u" && n instanceof Map ? L.map : typeof Set < "u" && n instanceof Set ? L.set : typeof Date < "u" && n instanceof Date ? L.date : L.object;
|
|
949
949
|
default:
|
|
950
|
-
return
|
|
950
|
+
return L.unknown;
|
|
951
951
|
}
|
|
952
|
-
},
|
|
952
|
+
}, D = te.arrayToEnum([
|
|
953
953
|
"invalid_type",
|
|
954
954
|
"invalid_literal",
|
|
955
955
|
"custom",
|
|
@@ -1034,52 +1034,52 @@ Be.create = (n) => new Be(n);
|
|
|
1034
1034
|
const ws = (n, e) => {
|
|
1035
1035
|
let t;
|
|
1036
1036
|
switch (n.code) {
|
|
1037
|
-
case
|
|
1038
|
-
n.received ===
|
|
1037
|
+
case D.invalid_type:
|
|
1038
|
+
n.received === L.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
1039
1039
|
break;
|
|
1040
|
-
case
|
|
1040
|
+
case D.invalid_literal:
|
|
1041
1041
|
t = `Invalid literal value, expected ${JSON.stringify(n.expected, te.jsonStringifyReplacer)}`;
|
|
1042
1042
|
break;
|
|
1043
|
-
case
|
|
1043
|
+
case D.unrecognized_keys:
|
|
1044
1044
|
t = `Unrecognized key(s) in object: ${te.joinValues(n.keys, ", ")}`;
|
|
1045
1045
|
break;
|
|
1046
|
-
case
|
|
1046
|
+
case D.invalid_union:
|
|
1047
1047
|
t = "Invalid input";
|
|
1048
1048
|
break;
|
|
1049
|
-
case
|
|
1049
|
+
case D.invalid_union_discriminator:
|
|
1050
1050
|
t = `Invalid discriminator value. Expected ${te.joinValues(n.options)}`;
|
|
1051
1051
|
break;
|
|
1052
|
-
case
|
|
1052
|
+
case D.invalid_enum_value:
|
|
1053
1053
|
t = `Invalid enum value. Expected ${te.joinValues(n.options)}, received '${n.received}'`;
|
|
1054
1054
|
break;
|
|
1055
|
-
case
|
|
1055
|
+
case D.invalid_arguments:
|
|
1056
1056
|
t = "Invalid function arguments";
|
|
1057
1057
|
break;
|
|
1058
|
-
case
|
|
1058
|
+
case D.invalid_return_type:
|
|
1059
1059
|
t = "Invalid function return type";
|
|
1060
1060
|
break;
|
|
1061
|
-
case
|
|
1061
|
+
case D.invalid_date:
|
|
1062
1062
|
t = "Invalid date";
|
|
1063
1063
|
break;
|
|
1064
|
-
case
|
|
1064
|
+
case D.invalid_string:
|
|
1065
1065
|
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : te.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
1066
1066
|
break;
|
|
1067
|
-
case
|
|
1067
|
+
case D.too_small:
|
|
1068
1068
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "bigint" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
1069
1069
|
break;
|
|
1070
|
-
case
|
|
1070
|
+
case D.too_big:
|
|
1071
1071
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "less than"} ${n.maximum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at most" : "under"} ${n.maximum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "bigint" ? t = `BigInt must be ${n.exact ? "exactly" : n.inclusive ? "less than or equal to" : "less than"} ${n.maximum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly" : n.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(n.maximum))}` : t = "Invalid input";
|
|
1072
1072
|
break;
|
|
1073
|
-
case
|
|
1073
|
+
case D.custom:
|
|
1074
1074
|
t = "Invalid input";
|
|
1075
1075
|
break;
|
|
1076
|
-
case
|
|
1076
|
+
case D.invalid_intersection_types:
|
|
1077
1077
|
t = "Intersection results could not be merged";
|
|
1078
1078
|
break;
|
|
1079
|
-
case
|
|
1079
|
+
case D.not_multiple_of:
|
|
1080
1080
|
t = `Number must be a multiple of ${n.multipleOf}`;
|
|
1081
1081
|
break;
|
|
1082
|
-
case
|
|
1082
|
+
case D.not_finite:
|
|
1083
1083
|
t = "Number must be finite";
|
|
1084
1084
|
break;
|
|
1085
1085
|
default:
|
|
@@ -1112,7 +1112,7 @@ const ca = (n) => {
|
|
|
1112
1112
|
message: a
|
|
1113
1113
|
};
|
|
1114
1114
|
};
|
|
1115
|
-
function
|
|
1115
|
+
function M(n, e) {
|
|
1116
1116
|
const t = la(), s = ca({
|
|
1117
1117
|
issueData: e,
|
|
1118
1118
|
data: n.data,
|
|
@@ -1174,10 +1174,10 @@ class ve {
|
|
|
1174
1174
|
const Y = Object.freeze({
|
|
1175
1175
|
status: "aborted"
|
|
1176
1176
|
}), Bt = (n) => ({ status: "dirty", value: n }), Ae = (n) => ({ status: "valid", value: n }), lr = (n) => n.status === "aborted", cr = (n) => n.status === "dirty", xt = (n) => n.status === "valid", Nn = (n) => typeof Promise < "u" && n instanceof Promise;
|
|
1177
|
-
var
|
|
1177
|
+
var Z;
|
|
1178
1178
|
(function(n) {
|
|
1179
1179
|
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
1180
|
-
})(
|
|
1180
|
+
})(Z || (Z = {}));
|
|
1181
1181
|
class je {
|
|
1182
1182
|
constructor(e, t, s, r) {
|
|
1183
1183
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = r;
|
|
@@ -1201,7 +1201,7 @@ const ur = (n, e) => {
|
|
|
1201
1201
|
}
|
|
1202
1202
|
};
|
|
1203
1203
|
};
|
|
1204
|
-
function
|
|
1204
|
+
function Q(n) {
|
|
1205
1205
|
if (!n)
|
|
1206
1206
|
return {};
|
|
1207
1207
|
const { errorMap: e, invalid_type_error: t, required_error: s, description: r } = n;
|
|
@@ -1330,7 +1330,7 @@ class X {
|
|
|
1330
1330
|
const s = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
|
|
1331
1331
|
return this._refinement((r, i) => {
|
|
1332
1332
|
const o = e(r), a = () => i.addIssue({
|
|
1333
|
-
code:
|
|
1333
|
+
code: D.custom,
|
|
1334
1334
|
...s(r)
|
|
1335
1335
|
});
|
|
1336
1336
|
return typeof Promise < "u" && o instanceof Promise ? o.then((l) => l ? !0 : (a(), !1)) : o ? !0 : (a(), !1);
|
|
@@ -1379,7 +1379,7 @@ class X {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
transform(e) {
|
|
1381
1381
|
return new At({
|
|
1382
|
-
...
|
|
1382
|
+
...Q(this._def),
|
|
1383
1383
|
schema: this,
|
|
1384
1384
|
typeName: G.ZodEffects,
|
|
1385
1385
|
effect: { type: "transform", transform: e }
|
|
@@ -1388,7 +1388,7 @@ class X {
|
|
|
1388
1388
|
default(e) {
|
|
1389
1389
|
const t = typeof e == "function" ? e : () => e;
|
|
1390
1390
|
return new bs({
|
|
1391
|
-
...
|
|
1391
|
+
...Q(this._def),
|
|
1392
1392
|
innerType: this,
|
|
1393
1393
|
defaultValue: t,
|
|
1394
1394
|
typeName: G.ZodDefault
|
|
@@ -1398,13 +1398,13 @@ class X {
|
|
|
1398
1398
|
return new Aa({
|
|
1399
1399
|
typeName: G.ZodBranded,
|
|
1400
1400
|
type: this,
|
|
1401
|
-
...
|
|
1401
|
+
...Q(this._def)
|
|
1402
1402
|
});
|
|
1403
1403
|
}
|
|
1404
1404
|
catch(e) {
|
|
1405
1405
|
const t = typeof e == "function" ? e : () => e;
|
|
1406
1406
|
return new Ss({
|
|
1407
|
-
...
|
|
1407
|
+
...Q(this._def),
|
|
1408
1408
|
innerType: this,
|
|
1409
1409
|
catchValue: t,
|
|
1410
1410
|
typeName: G.ZodCatch
|
|
@@ -1468,11 +1468,11 @@ function Ia(n, e) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
class qe extends X {
|
|
1470
1470
|
_parse(e) {
|
|
1471
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !==
|
|
1471
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== L.string) {
|
|
1472
1472
|
const i = this._getOrReturnCtx(e);
|
|
1473
|
-
return
|
|
1474
|
-
code:
|
|
1475
|
-
expected:
|
|
1473
|
+
return M(i, {
|
|
1474
|
+
code: D.invalid_type,
|
|
1475
|
+
expected: L.string,
|
|
1476
1476
|
received: i.parsedType
|
|
1477
1477
|
}), Y;
|
|
1478
1478
|
}
|
|
@@ -1480,8 +1480,8 @@ class qe extends X {
|
|
|
1480
1480
|
let r;
|
|
1481
1481
|
for (const i of this._def.checks)
|
|
1482
1482
|
if (i.kind === "min")
|
|
1483
|
-
e.data.length < i.value && (r = this._getOrReturnCtx(e, r),
|
|
1484
|
-
code:
|
|
1483
|
+
e.data.length < i.value && (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1484
|
+
code: D.too_small,
|
|
1485
1485
|
minimum: i.value,
|
|
1486
1486
|
type: "string",
|
|
1487
1487
|
inclusive: !0,
|
|
@@ -1489,8 +1489,8 @@ class qe extends X {
|
|
|
1489
1489
|
message: i.message
|
|
1490
1490
|
}), s.dirty());
|
|
1491
1491
|
else if (i.kind === "max")
|
|
1492
|
-
e.data.length > i.value && (r = this._getOrReturnCtx(e, r),
|
|
1493
|
-
code:
|
|
1492
|
+
e.data.length > i.value && (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1493
|
+
code: D.too_big,
|
|
1494
1494
|
maximum: i.value,
|
|
1495
1495
|
type: "string",
|
|
1496
1496
|
inclusive: !0,
|
|
@@ -1499,15 +1499,15 @@ class qe extends X {
|
|
|
1499
1499
|
}), s.dirty());
|
|
1500
1500
|
else if (i.kind === "length") {
|
|
1501
1501
|
const o = e.data.length > i.value, a = e.data.length < i.value;
|
|
1502
|
-
(o || a) && (r = this._getOrReturnCtx(e, r), o ?
|
|
1503
|
-
code:
|
|
1502
|
+
(o || a) && (r = this._getOrReturnCtx(e, r), o ? M(r, {
|
|
1503
|
+
code: D.too_big,
|
|
1504
1504
|
maximum: i.value,
|
|
1505
1505
|
type: "string",
|
|
1506
1506
|
inclusive: !0,
|
|
1507
1507
|
exact: !0,
|
|
1508
1508
|
message: i.message
|
|
1509
|
-
}) : a &&
|
|
1510
|
-
code:
|
|
1509
|
+
}) : a && M(r, {
|
|
1510
|
+
code: D.too_small,
|
|
1511
1511
|
minimum: i.value,
|
|
1512
1512
|
type: "string",
|
|
1513
1513
|
inclusive: !0,
|
|
@@ -1515,108 +1515,108 @@ class qe extends X {
|
|
|
1515
1515
|
message: i.message
|
|
1516
1516
|
}), s.dirty());
|
|
1517
1517
|
} else if (i.kind === "email")
|
|
1518
|
-
ga.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1518
|
+
ga.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1519
1519
|
validation: "email",
|
|
1520
|
-
code:
|
|
1520
|
+
code: D.invalid_string,
|
|
1521
1521
|
message: i.message
|
|
1522
1522
|
}), s.dirty());
|
|
1523
1523
|
else if (i.kind === "emoji")
|
|
1524
|
-
ns || (ns = new RegExp(wa, "u")), ns.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1524
|
+
ns || (ns = new RegExp(wa, "u")), ns.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1525
1525
|
validation: "emoji",
|
|
1526
|
-
code:
|
|
1526
|
+
code: D.invalid_string,
|
|
1527
1527
|
message: i.message
|
|
1528
1528
|
}), s.dirty());
|
|
1529
1529
|
else if (i.kind === "uuid")
|
|
1530
|
-
ha.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1530
|
+
ha.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1531
1531
|
validation: "uuid",
|
|
1532
|
-
code:
|
|
1532
|
+
code: D.invalid_string,
|
|
1533
1533
|
message: i.message
|
|
1534
1534
|
}), s.dirty());
|
|
1535
1535
|
else if (i.kind === "nanoid")
|
|
1536
|
-
ma.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1536
|
+
ma.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1537
1537
|
validation: "nanoid",
|
|
1538
|
-
code:
|
|
1538
|
+
code: D.invalid_string,
|
|
1539
1539
|
message: i.message
|
|
1540
1540
|
}), s.dirty());
|
|
1541
1541
|
else if (i.kind === "cuid")
|
|
1542
|
-
ua.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1542
|
+
ua.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1543
1543
|
validation: "cuid",
|
|
1544
|
-
code:
|
|
1544
|
+
code: D.invalid_string,
|
|
1545
1545
|
message: i.message
|
|
1546
1546
|
}), s.dirty());
|
|
1547
1547
|
else if (i.kind === "cuid2")
|
|
1548
|
-
da.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1548
|
+
da.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1549
1549
|
validation: "cuid2",
|
|
1550
|
-
code:
|
|
1550
|
+
code: D.invalid_string,
|
|
1551
1551
|
message: i.message
|
|
1552
1552
|
}), s.dirty());
|
|
1553
1553
|
else if (i.kind === "ulid")
|
|
1554
|
-
fa.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1554
|
+
fa.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1555
1555
|
validation: "ulid",
|
|
1556
|
-
code:
|
|
1556
|
+
code: D.invalid_string,
|
|
1557
1557
|
message: i.message
|
|
1558
1558
|
}), s.dirty());
|
|
1559
1559
|
else if (i.kind === "url")
|
|
1560
1560
|
try {
|
|
1561
1561
|
new URL(e.data);
|
|
1562
1562
|
} catch {
|
|
1563
|
-
r = this._getOrReturnCtx(e, r),
|
|
1563
|
+
r = this._getOrReturnCtx(e, r), M(r, {
|
|
1564
1564
|
validation: "url",
|
|
1565
|
-
code:
|
|
1565
|
+
code: D.invalid_string,
|
|
1566
1566
|
message: i.message
|
|
1567
1567
|
}), s.dirty();
|
|
1568
1568
|
}
|
|
1569
|
-
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1569
|
+
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1570
1570
|
validation: "regex",
|
|
1571
|
-
code:
|
|
1571
|
+
code: D.invalid_string,
|
|
1572
1572
|
message: i.message
|
|
1573
|
-
}), s.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (r = this._getOrReturnCtx(e, r),
|
|
1574
|
-
code:
|
|
1573
|
+
}), s.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1574
|
+
code: D.invalid_string,
|
|
1575
1575
|
validation: { includes: i.value, position: i.position },
|
|
1576
1576
|
message: i.message
|
|
1577
|
-
}), s.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (r = this._getOrReturnCtx(e, r),
|
|
1578
|
-
code:
|
|
1577
|
+
}), s.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1578
|
+
code: D.invalid_string,
|
|
1579
1579
|
validation: { startsWith: i.value },
|
|
1580
1580
|
message: i.message
|
|
1581
|
-
}), s.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (r = this._getOrReturnCtx(e, r),
|
|
1582
|
-
code:
|
|
1581
|
+
}), s.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1582
|
+
code: D.invalid_string,
|
|
1583
1583
|
validation: { endsWith: i.value },
|
|
1584
1584
|
message: i.message
|
|
1585
|
-
}), s.dirty()) : i.kind === "datetime" ? Ra(i).test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1586
|
-
code:
|
|
1585
|
+
}), s.dirty()) : i.kind === "datetime" ? Ra(i).test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1586
|
+
code: D.invalid_string,
|
|
1587
1587
|
validation: "datetime",
|
|
1588
1588
|
message: i.message
|
|
1589
|
-
}), s.dirty()) : i.kind === "date" ? Sa.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1590
|
-
code:
|
|
1589
|
+
}), s.dirty()) : i.kind === "date" ? Sa.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1590
|
+
code: D.invalid_string,
|
|
1591
1591
|
validation: "date",
|
|
1592
1592
|
message: i.message
|
|
1593
|
-
}), s.dirty()) : i.kind === "time" ? Ta(i).test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1594
|
-
code:
|
|
1593
|
+
}), s.dirty()) : i.kind === "time" ? Ta(i).test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1594
|
+
code: D.invalid_string,
|
|
1595
1595
|
validation: "time",
|
|
1596
1596
|
message: i.message
|
|
1597
|
-
}), s.dirty()) : i.kind === "duration" ? ya.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1597
|
+
}), s.dirty()) : i.kind === "duration" ? ya.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1598
1598
|
validation: "duration",
|
|
1599
|
-
code:
|
|
1599
|
+
code: D.invalid_string,
|
|
1600
1600
|
message: i.message
|
|
1601
|
-
}), s.dirty()) : i.kind === "ip" ? Na(e.data, i.version) || (r = this._getOrReturnCtx(e, r),
|
|
1601
|
+
}), s.dirty()) : i.kind === "ip" ? Na(e.data, i.version) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1602
1602
|
validation: "ip",
|
|
1603
|
-
code:
|
|
1603
|
+
code: D.invalid_string,
|
|
1604
1604
|
message: i.message
|
|
1605
|
-
}), s.dirty()) : i.kind === "jwt" ? xa(e.data, i.alg) || (r = this._getOrReturnCtx(e, r),
|
|
1605
|
+
}), s.dirty()) : i.kind === "jwt" ? xa(e.data, i.alg) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1606
1606
|
validation: "jwt",
|
|
1607
|
-
code:
|
|
1607
|
+
code: D.invalid_string,
|
|
1608
1608
|
message: i.message
|
|
1609
|
-
}), s.dirty()) : i.kind === "cidr" ? Ia(e.data, i.version) || (r = this._getOrReturnCtx(e, r),
|
|
1609
|
+
}), s.dirty()) : i.kind === "cidr" ? Ia(e.data, i.version) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1610
1610
|
validation: "cidr",
|
|
1611
|
-
code:
|
|
1611
|
+
code: D.invalid_string,
|
|
1612
1612
|
message: i.message
|
|
1613
|
-
}), s.dirty()) : i.kind === "base64" ? ka.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1613
|
+
}), s.dirty()) : i.kind === "base64" ? ka.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1614
1614
|
validation: "base64",
|
|
1615
|
-
code:
|
|
1615
|
+
code: D.invalid_string,
|
|
1616
1616
|
message: i.message
|
|
1617
|
-
}), s.dirty()) : i.kind === "base64url" ? ba.test(e.data) || (r = this._getOrReturnCtx(e, r),
|
|
1617
|
+
}), s.dirty()) : i.kind === "base64url" ? ba.test(e.data) || (r = this._getOrReturnCtx(e, r), M(r, {
|
|
1618
1618
|
validation: "base64url",
|
|
1619
|
-
code:
|
|
1619
|
+
code: D.invalid_string,
|
|
1620
1620
|
message: i.message
|
|
1621
1621
|
}), s.dirty()) : te.assertNever(i);
|
|
1622
1622
|
return { status: s.value, value: e.data };
|
|
@@ -1624,8 +1624,8 @@ class qe extends X {
|
|
|
1624
1624
|
_regex(e, t, s) {
|
|
1625
1625
|
return this.refinement((r) => e.test(r), {
|
|
1626
1626
|
validation: t,
|
|
1627
|
-
code:
|
|
1628
|
-
...
|
|
1627
|
+
code: D.invalid_string,
|
|
1628
|
+
...Z.errToObj(s)
|
|
1629
1629
|
});
|
|
1630
1630
|
}
|
|
1631
1631
|
_addCheck(e) {
|
|
@@ -1635,46 +1635,46 @@ class qe extends X {
|
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
1637
|
email(e) {
|
|
1638
|
-
return this._addCheck({ kind: "email", ...
|
|
1638
|
+
return this._addCheck({ kind: "email", ...Z.errToObj(e) });
|
|
1639
1639
|
}
|
|
1640
1640
|
url(e) {
|
|
1641
|
-
return this._addCheck({ kind: "url", ...
|
|
1641
|
+
return this._addCheck({ kind: "url", ...Z.errToObj(e) });
|
|
1642
1642
|
}
|
|
1643
1643
|
emoji(e) {
|
|
1644
|
-
return this._addCheck({ kind: "emoji", ...
|
|
1644
|
+
return this._addCheck({ kind: "emoji", ...Z.errToObj(e) });
|
|
1645
1645
|
}
|
|
1646
1646
|
uuid(e) {
|
|
1647
|
-
return this._addCheck({ kind: "uuid", ...
|
|
1647
|
+
return this._addCheck({ kind: "uuid", ...Z.errToObj(e) });
|
|
1648
1648
|
}
|
|
1649
1649
|
nanoid(e) {
|
|
1650
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
1650
|
+
return this._addCheck({ kind: "nanoid", ...Z.errToObj(e) });
|
|
1651
1651
|
}
|
|
1652
1652
|
cuid(e) {
|
|
1653
|
-
return this._addCheck({ kind: "cuid", ...
|
|
1653
|
+
return this._addCheck({ kind: "cuid", ...Z.errToObj(e) });
|
|
1654
1654
|
}
|
|
1655
1655
|
cuid2(e) {
|
|
1656
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
1656
|
+
return this._addCheck({ kind: "cuid2", ...Z.errToObj(e) });
|
|
1657
1657
|
}
|
|
1658
1658
|
ulid(e) {
|
|
1659
|
-
return this._addCheck({ kind: "ulid", ...
|
|
1659
|
+
return this._addCheck({ kind: "ulid", ...Z.errToObj(e) });
|
|
1660
1660
|
}
|
|
1661
1661
|
base64(e) {
|
|
1662
|
-
return this._addCheck({ kind: "base64", ...
|
|
1662
|
+
return this._addCheck({ kind: "base64", ...Z.errToObj(e) });
|
|
1663
1663
|
}
|
|
1664
1664
|
base64url(e) {
|
|
1665
1665
|
return this._addCheck({
|
|
1666
1666
|
kind: "base64url",
|
|
1667
|
-
...
|
|
1667
|
+
...Z.errToObj(e)
|
|
1668
1668
|
});
|
|
1669
1669
|
}
|
|
1670
1670
|
jwt(e) {
|
|
1671
|
-
return this._addCheck({ kind: "jwt", ...
|
|
1671
|
+
return this._addCheck({ kind: "jwt", ...Z.errToObj(e) });
|
|
1672
1672
|
}
|
|
1673
1673
|
ip(e) {
|
|
1674
|
-
return this._addCheck({ kind: "ip", ...
|
|
1674
|
+
return this._addCheck({ kind: "ip", ...Z.errToObj(e) });
|
|
1675
1675
|
}
|
|
1676
1676
|
cidr(e) {
|
|
1677
|
-
return this._addCheck({ kind: "cidr", ...
|
|
1677
|
+
return this._addCheck({ kind: "cidr", ...Z.errToObj(e) });
|
|
1678
1678
|
}
|
|
1679
1679
|
datetime(e) {
|
|
1680
1680
|
return typeof e == "string" ? this._addCheck({
|
|
@@ -1688,7 +1688,7 @@ class qe extends X {
|
|
|
1688
1688
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1689
1689
|
offset: e?.offset ?? !1,
|
|
1690
1690
|
local: e?.local ?? !1,
|
|
1691
|
-
...
|
|
1691
|
+
...Z.errToObj(e?.message)
|
|
1692
1692
|
});
|
|
1693
1693
|
}
|
|
1694
1694
|
date(e) {
|
|
@@ -1702,17 +1702,17 @@ class qe extends X {
|
|
|
1702
1702
|
}) : this._addCheck({
|
|
1703
1703
|
kind: "time",
|
|
1704
1704
|
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1705
|
-
...
|
|
1705
|
+
...Z.errToObj(e?.message)
|
|
1706
1706
|
});
|
|
1707
1707
|
}
|
|
1708
1708
|
duration(e) {
|
|
1709
|
-
return this._addCheck({ kind: "duration", ...
|
|
1709
|
+
return this._addCheck({ kind: "duration", ...Z.errToObj(e) });
|
|
1710
1710
|
}
|
|
1711
1711
|
regex(e, t) {
|
|
1712
1712
|
return this._addCheck({
|
|
1713
1713
|
kind: "regex",
|
|
1714
1714
|
regex: e,
|
|
1715
|
-
...
|
|
1715
|
+
...Z.errToObj(t)
|
|
1716
1716
|
});
|
|
1717
1717
|
}
|
|
1718
1718
|
includes(e, t) {
|
|
@@ -1720,49 +1720,49 @@ class qe extends X {
|
|
|
1720
1720
|
kind: "includes",
|
|
1721
1721
|
value: e,
|
|
1722
1722
|
position: t?.position,
|
|
1723
|
-
...
|
|
1723
|
+
...Z.errToObj(t?.message)
|
|
1724
1724
|
});
|
|
1725
1725
|
}
|
|
1726
1726
|
startsWith(e, t) {
|
|
1727
1727
|
return this._addCheck({
|
|
1728
1728
|
kind: "startsWith",
|
|
1729
1729
|
value: e,
|
|
1730
|
-
...
|
|
1730
|
+
...Z.errToObj(t)
|
|
1731
1731
|
});
|
|
1732
1732
|
}
|
|
1733
1733
|
endsWith(e, t) {
|
|
1734
1734
|
return this._addCheck({
|
|
1735
1735
|
kind: "endsWith",
|
|
1736
1736
|
value: e,
|
|
1737
|
-
...
|
|
1737
|
+
...Z.errToObj(t)
|
|
1738
1738
|
});
|
|
1739
1739
|
}
|
|
1740
1740
|
min(e, t) {
|
|
1741
1741
|
return this._addCheck({
|
|
1742
1742
|
kind: "min",
|
|
1743
1743
|
value: e,
|
|
1744
|
-
...
|
|
1744
|
+
...Z.errToObj(t)
|
|
1745
1745
|
});
|
|
1746
1746
|
}
|
|
1747
1747
|
max(e, t) {
|
|
1748
1748
|
return this._addCheck({
|
|
1749
1749
|
kind: "max",
|
|
1750
1750
|
value: e,
|
|
1751
|
-
...
|
|
1751
|
+
...Z.errToObj(t)
|
|
1752
1752
|
});
|
|
1753
1753
|
}
|
|
1754
1754
|
length(e, t) {
|
|
1755
1755
|
return this._addCheck({
|
|
1756
1756
|
kind: "length",
|
|
1757
1757
|
value: e,
|
|
1758
|
-
...
|
|
1758
|
+
...Z.errToObj(t)
|
|
1759
1759
|
});
|
|
1760
1760
|
}
|
|
1761
1761
|
/**
|
|
1762
1762
|
* Equivalent to `.min(1)`
|
|
1763
1763
|
*/
|
|
1764
1764
|
nonempty(e) {
|
|
1765
|
-
return this.min(1,
|
|
1765
|
+
return this.min(1, Z.errToObj(e));
|
|
1766
1766
|
}
|
|
1767
1767
|
trim() {
|
|
1768
1768
|
return new qe({
|
|
@@ -1847,7 +1847,7 @@ qe.create = (n) => new qe({
|
|
|
1847
1847
|
checks: [],
|
|
1848
1848
|
typeName: G.ZodString,
|
|
1849
1849
|
coerce: n?.coerce ?? !1,
|
|
1850
|
-
...
|
|
1850
|
+
...Q(n)
|
|
1851
1851
|
});
|
|
1852
1852
|
function Da(n, e) {
|
|
1853
1853
|
const t = (n.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = t > s ? t : s, i = Number.parseInt(n.toFixed(r).replace(".", "")), o = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
@@ -1858,57 +1858,57 @@ class It extends X {
|
|
|
1858
1858
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1859
1859
|
}
|
|
1860
1860
|
_parse(e) {
|
|
1861
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !==
|
|
1861
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== L.number) {
|
|
1862
1862
|
const i = this._getOrReturnCtx(e);
|
|
1863
|
-
return
|
|
1864
|
-
code:
|
|
1865
|
-
expected:
|
|
1863
|
+
return M(i, {
|
|
1864
|
+
code: D.invalid_type,
|
|
1865
|
+
expected: L.number,
|
|
1866
1866
|
received: i.parsedType
|
|
1867
1867
|
}), Y;
|
|
1868
1868
|
}
|
|
1869
1869
|
let s;
|
|
1870
1870
|
const r = new ve();
|
|
1871
1871
|
for (const i of this._def.checks)
|
|
1872
|
-
i.kind === "int" ? te.isInteger(e.data) || (s = this._getOrReturnCtx(e, s),
|
|
1873
|
-
code:
|
|
1872
|
+
i.kind === "int" ? te.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), M(s, {
|
|
1873
|
+
code: D.invalid_type,
|
|
1874
1874
|
expected: "integer",
|
|
1875
1875
|
received: "float",
|
|
1876
1876
|
message: i.message
|
|
1877
|
-
}), r.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s),
|
|
1878
|
-
code:
|
|
1877
|
+
}), r.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
1878
|
+
code: D.too_small,
|
|
1879
1879
|
minimum: i.value,
|
|
1880
1880
|
type: "number",
|
|
1881
1881
|
inclusive: i.inclusive,
|
|
1882
1882
|
exact: !1,
|
|
1883
1883
|
message: i.message
|
|
1884
|
-
}), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s),
|
|
1885
|
-
code:
|
|
1884
|
+
}), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
1885
|
+
code: D.too_big,
|
|
1886
1886
|
maximum: i.value,
|
|
1887
1887
|
type: "number",
|
|
1888
1888
|
inclusive: i.inclusive,
|
|
1889
1889
|
exact: !1,
|
|
1890
1890
|
message: i.message
|
|
1891
|
-
}), r.dirty()) : i.kind === "multipleOf" ? Da(e.data, i.value) !== 0 && (s = this._getOrReturnCtx(e, s),
|
|
1892
|
-
code:
|
|
1891
|
+
}), r.dirty()) : i.kind === "multipleOf" ? Da(e.data, i.value) !== 0 && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
1892
|
+
code: D.not_multiple_of,
|
|
1893
1893
|
multipleOf: i.value,
|
|
1894
1894
|
message: i.message
|
|
1895
|
-
}), r.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s),
|
|
1896
|
-
code:
|
|
1895
|
+
}), r.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), M(s, {
|
|
1896
|
+
code: D.not_finite,
|
|
1897
1897
|
message: i.message
|
|
1898
1898
|
}), r.dirty()) : te.assertNever(i);
|
|
1899
1899
|
return { status: r.value, value: e.data };
|
|
1900
1900
|
}
|
|
1901
1901
|
gte(e, t) {
|
|
1902
|
-
return this.setLimit("min", e, !0,
|
|
1902
|
+
return this.setLimit("min", e, !0, Z.toString(t));
|
|
1903
1903
|
}
|
|
1904
1904
|
gt(e, t) {
|
|
1905
|
-
return this.setLimit("min", e, !1,
|
|
1905
|
+
return this.setLimit("min", e, !1, Z.toString(t));
|
|
1906
1906
|
}
|
|
1907
1907
|
lte(e, t) {
|
|
1908
|
-
return this.setLimit("max", e, !0,
|
|
1908
|
+
return this.setLimit("max", e, !0, Z.toString(t));
|
|
1909
1909
|
}
|
|
1910
1910
|
lt(e, t) {
|
|
1911
|
-
return this.setLimit("max", e, !1,
|
|
1911
|
+
return this.setLimit("max", e, !1, Z.toString(t));
|
|
1912
1912
|
}
|
|
1913
1913
|
setLimit(e, t, s, r) {
|
|
1914
1914
|
return new It({
|
|
@@ -1919,7 +1919,7 @@ class It extends X {
|
|
|
1919
1919
|
kind: e,
|
|
1920
1920
|
value: t,
|
|
1921
1921
|
inclusive: s,
|
|
1922
|
-
message:
|
|
1922
|
+
message: Z.toString(r)
|
|
1923
1923
|
}
|
|
1924
1924
|
]
|
|
1925
1925
|
});
|
|
@@ -1933,7 +1933,7 @@ class It extends X {
|
|
|
1933
1933
|
int(e) {
|
|
1934
1934
|
return this._addCheck({
|
|
1935
1935
|
kind: "int",
|
|
1936
|
-
message:
|
|
1936
|
+
message: Z.toString(e)
|
|
1937
1937
|
});
|
|
1938
1938
|
}
|
|
1939
1939
|
positive(e) {
|
|
@@ -1941,7 +1941,7 @@ class It extends X {
|
|
|
1941
1941
|
kind: "min",
|
|
1942
1942
|
value: 0,
|
|
1943
1943
|
inclusive: !1,
|
|
1944
|
-
message:
|
|
1944
|
+
message: Z.toString(e)
|
|
1945
1945
|
});
|
|
1946
1946
|
}
|
|
1947
1947
|
negative(e) {
|
|
@@ -1949,7 +1949,7 @@ class It extends X {
|
|
|
1949
1949
|
kind: "max",
|
|
1950
1950
|
value: 0,
|
|
1951
1951
|
inclusive: !1,
|
|
1952
|
-
message:
|
|
1952
|
+
message: Z.toString(e)
|
|
1953
1953
|
});
|
|
1954
1954
|
}
|
|
1955
1955
|
nonpositive(e) {
|
|
@@ -1957,7 +1957,7 @@ class It extends X {
|
|
|
1957
1957
|
kind: "max",
|
|
1958
1958
|
value: 0,
|
|
1959
1959
|
inclusive: !0,
|
|
1960
|
-
message:
|
|
1960
|
+
message: Z.toString(e)
|
|
1961
1961
|
});
|
|
1962
1962
|
}
|
|
1963
1963
|
nonnegative(e) {
|
|
@@ -1965,20 +1965,20 @@ class It extends X {
|
|
|
1965
1965
|
kind: "min",
|
|
1966
1966
|
value: 0,
|
|
1967
1967
|
inclusive: !0,
|
|
1968
|
-
message:
|
|
1968
|
+
message: Z.toString(e)
|
|
1969
1969
|
});
|
|
1970
1970
|
}
|
|
1971
1971
|
multipleOf(e, t) {
|
|
1972
1972
|
return this._addCheck({
|
|
1973
1973
|
kind: "multipleOf",
|
|
1974
1974
|
value: e,
|
|
1975
|
-
message:
|
|
1975
|
+
message: Z.toString(t)
|
|
1976
1976
|
});
|
|
1977
1977
|
}
|
|
1978
1978
|
finite(e) {
|
|
1979
1979
|
return this._addCheck({
|
|
1980
1980
|
kind: "finite",
|
|
1981
|
-
message:
|
|
1981
|
+
message: Z.toString(e)
|
|
1982
1982
|
});
|
|
1983
1983
|
}
|
|
1984
1984
|
safe(e) {
|
|
@@ -1986,12 +1986,12 @@ class It extends X {
|
|
|
1986
1986
|
kind: "min",
|
|
1987
1987
|
inclusive: !0,
|
|
1988
1988
|
value: Number.MIN_SAFE_INTEGER,
|
|
1989
|
-
message:
|
|
1989
|
+
message: Z.toString(e)
|
|
1990
1990
|
})._addCheck({
|
|
1991
1991
|
kind: "max",
|
|
1992
1992
|
inclusive: !0,
|
|
1993
1993
|
value: Number.MAX_SAFE_INTEGER,
|
|
1994
|
-
message:
|
|
1994
|
+
message: Z.toString(e)
|
|
1995
1995
|
});
|
|
1996
1996
|
}
|
|
1997
1997
|
get minValue() {
|
|
@@ -2023,7 +2023,7 @@ It.create = (n) => new It({
|
|
|
2023
2023
|
checks: [],
|
|
2024
2024
|
typeName: G.ZodNumber,
|
|
2025
2025
|
coerce: n?.coerce || !1,
|
|
2026
|
-
...
|
|
2026
|
+
...Q(n)
|
|
2027
2027
|
});
|
|
2028
2028
|
class en extends X {
|
|
2029
2029
|
constructor() {
|
|
@@ -2036,25 +2036,25 @@ class en extends X {
|
|
|
2036
2036
|
} catch {
|
|
2037
2037
|
return this._getInvalidInput(e);
|
|
2038
2038
|
}
|
|
2039
|
-
if (this._getType(e) !==
|
|
2039
|
+
if (this._getType(e) !== L.bigint)
|
|
2040
2040
|
return this._getInvalidInput(e);
|
|
2041
2041
|
let s;
|
|
2042
2042
|
const r = new ve();
|
|
2043
2043
|
for (const i of this._def.checks)
|
|
2044
|
-
i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s),
|
|
2045
|
-
code:
|
|
2044
|
+
i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
2045
|
+
code: D.too_small,
|
|
2046
2046
|
type: "bigint",
|
|
2047
2047
|
minimum: i.value,
|
|
2048
2048
|
inclusive: i.inclusive,
|
|
2049
2049
|
message: i.message
|
|
2050
|
-
}), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s),
|
|
2051
|
-
code:
|
|
2050
|
+
}), r.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
2051
|
+
code: D.too_big,
|
|
2052
2052
|
type: "bigint",
|
|
2053
2053
|
maximum: i.value,
|
|
2054
2054
|
inclusive: i.inclusive,
|
|
2055
2055
|
message: i.message
|
|
2056
|
-
}), r.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s),
|
|
2057
|
-
code:
|
|
2056
|
+
}), r.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), M(s, {
|
|
2057
|
+
code: D.not_multiple_of,
|
|
2058
2058
|
multipleOf: i.value,
|
|
2059
2059
|
message: i.message
|
|
2060
2060
|
}), r.dirty()) : te.assertNever(i);
|
|
@@ -2062,23 +2062,23 @@ class en extends X {
|
|
|
2062
2062
|
}
|
|
2063
2063
|
_getInvalidInput(e) {
|
|
2064
2064
|
const t = this._getOrReturnCtx(e);
|
|
2065
|
-
return
|
|
2066
|
-
code:
|
|
2067
|
-
expected:
|
|
2065
|
+
return M(t, {
|
|
2066
|
+
code: D.invalid_type,
|
|
2067
|
+
expected: L.bigint,
|
|
2068
2068
|
received: t.parsedType
|
|
2069
2069
|
}), Y;
|
|
2070
2070
|
}
|
|
2071
2071
|
gte(e, t) {
|
|
2072
|
-
return this.setLimit("min", e, !0,
|
|
2072
|
+
return this.setLimit("min", e, !0, Z.toString(t));
|
|
2073
2073
|
}
|
|
2074
2074
|
gt(e, t) {
|
|
2075
|
-
return this.setLimit("min", e, !1,
|
|
2075
|
+
return this.setLimit("min", e, !1, Z.toString(t));
|
|
2076
2076
|
}
|
|
2077
2077
|
lte(e, t) {
|
|
2078
|
-
return this.setLimit("max", e, !0,
|
|
2078
|
+
return this.setLimit("max", e, !0, Z.toString(t));
|
|
2079
2079
|
}
|
|
2080
2080
|
lt(e, t) {
|
|
2081
|
-
return this.setLimit("max", e, !1,
|
|
2081
|
+
return this.setLimit("max", e, !1, Z.toString(t));
|
|
2082
2082
|
}
|
|
2083
2083
|
setLimit(e, t, s, r) {
|
|
2084
2084
|
return new en({
|
|
@@ -2089,7 +2089,7 @@ class en extends X {
|
|
|
2089
2089
|
kind: e,
|
|
2090
2090
|
value: t,
|
|
2091
2091
|
inclusive: s,
|
|
2092
|
-
message:
|
|
2092
|
+
message: Z.toString(r)
|
|
2093
2093
|
}
|
|
2094
2094
|
]
|
|
2095
2095
|
});
|
|
@@ -2105,7 +2105,7 @@ class en extends X {
|
|
|
2105
2105
|
kind: "min",
|
|
2106
2106
|
value: BigInt(0),
|
|
2107
2107
|
inclusive: !1,
|
|
2108
|
-
message:
|
|
2108
|
+
message: Z.toString(e)
|
|
2109
2109
|
});
|
|
2110
2110
|
}
|
|
2111
2111
|
negative(e) {
|
|
@@ -2113,7 +2113,7 @@ class en extends X {
|
|
|
2113
2113
|
kind: "max",
|
|
2114
2114
|
value: BigInt(0),
|
|
2115
2115
|
inclusive: !1,
|
|
2116
|
-
message:
|
|
2116
|
+
message: Z.toString(e)
|
|
2117
2117
|
});
|
|
2118
2118
|
}
|
|
2119
2119
|
nonpositive(e) {
|
|
@@ -2121,7 +2121,7 @@ class en extends X {
|
|
|
2121
2121
|
kind: "max",
|
|
2122
2122
|
value: BigInt(0),
|
|
2123
2123
|
inclusive: !0,
|
|
2124
|
-
message:
|
|
2124
|
+
message: Z.toString(e)
|
|
2125
2125
|
});
|
|
2126
2126
|
}
|
|
2127
2127
|
nonnegative(e) {
|
|
@@ -2129,14 +2129,14 @@ class en extends X {
|
|
|
2129
2129
|
kind: "min",
|
|
2130
2130
|
value: BigInt(0),
|
|
2131
2131
|
inclusive: !0,
|
|
2132
|
-
message:
|
|
2132
|
+
message: Z.toString(e)
|
|
2133
2133
|
});
|
|
2134
2134
|
}
|
|
2135
2135
|
multipleOf(e, t) {
|
|
2136
2136
|
return this._addCheck({
|
|
2137
2137
|
kind: "multipleOf",
|
|
2138
2138
|
value: e,
|
|
2139
|
-
message:
|
|
2139
|
+
message: Z.toString(t)
|
|
2140
2140
|
});
|
|
2141
2141
|
}
|
|
2142
2142
|
get minValue() {
|
|
@@ -2156,15 +2156,15 @@ en.create = (n) => new en({
|
|
|
2156
2156
|
checks: [],
|
|
2157
2157
|
typeName: G.ZodBigInt,
|
|
2158
2158
|
coerce: n?.coerce ?? !1,
|
|
2159
|
-
...
|
|
2159
|
+
...Q(n)
|
|
2160
2160
|
});
|
|
2161
2161
|
class _s extends X {
|
|
2162
2162
|
_parse(e) {
|
|
2163
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !==
|
|
2163
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== L.boolean) {
|
|
2164
2164
|
const s = this._getOrReturnCtx(e);
|
|
2165
|
-
return
|
|
2166
|
-
code:
|
|
2167
|
-
expected:
|
|
2165
|
+
return M(s, {
|
|
2166
|
+
code: D.invalid_type,
|
|
2167
|
+
expected: L.boolean,
|
|
2168
2168
|
received: s.parsedType
|
|
2169
2169
|
}), Y;
|
|
2170
2170
|
}
|
|
@@ -2174,36 +2174,36 @@ class _s extends X {
|
|
|
2174
2174
|
_s.create = (n) => new _s({
|
|
2175
2175
|
typeName: G.ZodBoolean,
|
|
2176
2176
|
coerce: n?.coerce || !1,
|
|
2177
|
-
...
|
|
2177
|
+
...Q(n)
|
|
2178
2178
|
});
|
|
2179
2179
|
class xn extends X {
|
|
2180
2180
|
_parse(e) {
|
|
2181
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !==
|
|
2181
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== L.date) {
|
|
2182
2182
|
const i = this._getOrReturnCtx(e);
|
|
2183
|
-
return
|
|
2184
|
-
code:
|
|
2185
|
-
expected:
|
|
2183
|
+
return M(i, {
|
|
2184
|
+
code: D.invalid_type,
|
|
2185
|
+
expected: L.date,
|
|
2186
2186
|
received: i.parsedType
|
|
2187
2187
|
}), Y;
|
|
2188
2188
|
}
|
|
2189
2189
|
if (Number.isNaN(e.data.getTime())) {
|
|
2190
2190
|
const i = this._getOrReturnCtx(e);
|
|
2191
|
-
return
|
|
2192
|
-
code:
|
|
2191
|
+
return M(i, {
|
|
2192
|
+
code: D.invalid_date
|
|
2193
2193
|
}), Y;
|
|
2194
2194
|
}
|
|
2195
2195
|
const s = new ve();
|
|
2196
2196
|
let r;
|
|
2197
2197
|
for (const i of this._def.checks)
|
|
2198
|
-
i.kind === "min" ? e.data.getTime() < i.value && (r = this._getOrReturnCtx(e, r),
|
|
2199
|
-
code:
|
|
2198
|
+
i.kind === "min" ? e.data.getTime() < i.value && (r = this._getOrReturnCtx(e, r), M(r, {
|
|
2199
|
+
code: D.too_small,
|
|
2200
2200
|
message: i.message,
|
|
2201
2201
|
inclusive: !0,
|
|
2202
2202
|
exact: !1,
|
|
2203
2203
|
minimum: i.value,
|
|
2204
2204
|
type: "date"
|
|
2205
|
-
}), s.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (r = this._getOrReturnCtx(e, r),
|
|
2206
|
-
code:
|
|
2205
|
+
}), s.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (r = this._getOrReturnCtx(e, r), M(r, {
|
|
2206
|
+
code: D.too_big,
|
|
2207
2207
|
message: i.message,
|
|
2208
2208
|
inclusive: !0,
|
|
2209
2209
|
exact: !1,
|
|
@@ -2225,14 +2225,14 @@ class xn extends X {
|
|
|
2225
2225
|
return this._addCheck({
|
|
2226
2226
|
kind: "min",
|
|
2227
2227
|
value: e.getTime(),
|
|
2228
|
-
message:
|
|
2228
|
+
message: Z.toString(t)
|
|
2229
2229
|
});
|
|
2230
2230
|
}
|
|
2231
2231
|
max(e, t) {
|
|
2232
2232
|
return this._addCheck({
|
|
2233
2233
|
kind: "max",
|
|
2234
2234
|
value: e.getTime(),
|
|
2235
|
-
message:
|
|
2235
|
+
message: Z.toString(t)
|
|
2236
2236
|
});
|
|
2237
2237
|
}
|
|
2238
2238
|
get minDate() {
|
|
@@ -2252,15 +2252,15 @@ xn.create = (n) => new xn({
|
|
|
2252
2252
|
checks: [],
|
|
2253
2253
|
coerce: n?.coerce || !1,
|
|
2254
2254
|
typeName: G.ZodDate,
|
|
2255
|
-
...
|
|
2255
|
+
...Q(n)
|
|
2256
2256
|
});
|
|
2257
2257
|
class dr extends X {
|
|
2258
2258
|
_parse(e) {
|
|
2259
|
-
if (this._getType(e) !==
|
|
2259
|
+
if (this._getType(e) !== L.symbol) {
|
|
2260
2260
|
const s = this._getOrReturnCtx(e);
|
|
2261
|
-
return
|
|
2262
|
-
code:
|
|
2263
|
-
expected:
|
|
2261
|
+
return M(s, {
|
|
2262
|
+
code: D.invalid_type,
|
|
2263
|
+
expected: L.symbol,
|
|
2264
2264
|
received: s.parsedType
|
|
2265
2265
|
}), Y;
|
|
2266
2266
|
}
|
|
@@ -2269,15 +2269,15 @@ class dr extends X {
|
|
|
2269
2269
|
}
|
|
2270
2270
|
dr.create = (n) => new dr({
|
|
2271
2271
|
typeName: G.ZodSymbol,
|
|
2272
|
-
...
|
|
2272
|
+
...Q(n)
|
|
2273
2273
|
});
|
|
2274
2274
|
class Es extends X {
|
|
2275
2275
|
_parse(e) {
|
|
2276
|
-
if (this._getType(e) !==
|
|
2276
|
+
if (this._getType(e) !== L.undefined) {
|
|
2277
2277
|
const s = this._getOrReturnCtx(e);
|
|
2278
|
-
return
|
|
2279
|
-
code:
|
|
2280
|
-
expected:
|
|
2278
|
+
return M(s, {
|
|
2279
|
+
code: D.invalid_type,
|
|
2280
|
+
expected: L.undefined,
|
|
2281
2281
|
received: s.parsedType
|
|
2282
2282
|
}), Y;
|
|
2283
2283
|
}
|
|
@@ -2286,15 +2286,15 @@ class Es extends X {
|
|
|
2286
2286
|
}
|
|
2287
2287
|
Es.create = (n) => new Es({
|
|
2288
2288
|
typeName: G.ZodUndefined,
|
|
2289
|
-
...
|
|
2289
|
+
...Q(n)
|
|
2290
2290
|
});
|
|
2291
2291
|
class fr extends X {
|
|
2292
2292
|
_parse(e) {
|
|
2293
|
-
if (this._getType(e) !==
|
|
2293
|
+
if (this._getType(e) !== L.null) {
|
|
2294
2294
|
const s = this._getOrReturnCtx(e);
|
|
2295
|
-
return
|
|
2296
|
-
code:
|
|
2297
|
-
expected:
|
|
2295
|
+
return M(s, {
|
|
2296
|
+
code: D.invalid_type,
|
|
2297
|
+
expected: L.null,
|
|
2298
2298
|
received: s.parsedType
|
|
2299
2299
|
}), Y;
|
|
2300
2300
|
}
|
|
@@ -2303,7 +2303,7 @@ class fr extends X {
|
|
|
2303
2303
|
}
|
|
2304
2304
|
fr.create = (n) => new fr({
|
|
2305
2305
|
typeName: G.ZodNull,
|
|
2306
|
-
...
|
|
2306
|
+
...Q(n)
|
|
2307
2307
|
});
|
|
2308
2308
|
class vs extends X {
|
|
2309
2309
|
constructor() {
|
|
@@ -2315,7 +2315,7 @@ class vs extends X {
|
|
|
2315
2315
|
}
|
|
2316
2316
|
vs.create = (n) => new vs({
|
|
2317
2317
|
typeName: G.ZodAny,
|
|
2318
|
-
...
|
|
2318
|
+
...Q(n)
|
|
2319
2319
|
});
|
|
2320
2320
|
class hr extends X {
|
|
2321
2321
|
constructor() {
|
|
@@ -2327,29 +2327,29 @@ class hr extends X {
|
|
|
2327
2327
|
}
|
|
2328
2328
|
hr.create = (n) => new hr({
|
|
2329
2329
|
typeName: G.ZodUnknown,
|
|
2330
|
-
...
|
|
2330
|
+
...Q(n)
|
|
2331
2331
|
});
|
|
2332
2332
|
class ot extends X {
|
|
2333
2333
|
_parse(e) {
|
|
2334
2334
|
const t = this._getOrReturnCtx(e);
|
|
2335
|
-
return
|
|
2336
|
-
code:
|
|
2337
|
-
expected:
|
|
2335
|
+
return M(t, {
|
|
2336
|
+
code: D.invalid_type,
|
|
2337
|
+
expected: L.never,
|
|
2338
2338
|
received: t.parsedType
|
|
2339
2339
|
}), Y;
|
|
2340
2340
|
}
|
|
2341
2341
|
}
|
|
2342
2342
|
ot.create = (n) => new ot({
|
|
2343
2343
|
typeName: G.ZodNever,
|
|
2344
|
-
...
|
|
2344
|
+
...Q(n)
|
|
2345
2345
|
});
|
|
2346
2346
|
class mr extends X {
|
|
2347
2347
|
_parse(e) {
|
|
2348
|
-
if (this._getType(e) !==
|
|
2348
|
+
if (this._getType(e) !== L.undefined) {
|
|
2349
2349
|
const s = this._getOrReturnCtx(e);
|
|
2350
|
-
return
|
|
2351
|
-
code:
|
|
2352
|
-
expected:
|
|
2350
|
+
return M(s, {
|
|
2351
|
+
code: D.invalid_type,
|
|
2352
|
+
expected: L.void,
|
|
2353
2353
|
received: s.parsedType
|
|
2354
2354
|
}), Y;
|
|
2355
2355
|
}
|
|
@@ -2358,21 +2358,21 @@ class mr extends X {
|
|
|
2358
2358
|
}
|
|
2359
2359
|
mr.create = (n) => new mr({
|
|
2360
2360
|
typeName: G.ZodVoid,
|
|
2361
|
-
...
|
|
2361
|
+
...Q(n)
|
|
2362
2362
|
});
|
|
2363
2363
|
class Ue extends X {
|
|
2364
2364
|
_parse(e) {
|
|
2365
2365
|
const { ctx: t, status: s } = this._processInputParams(e), r = this._def;
|
|
2366
|
-
if (t.parsedType !==
|
|
2367
|
-
return
|
|
2368
|
-
code:
|
|
2369
|
-
expected:
|
|
2366
|
+
if (t.parsedType !== L.array)
|
|
2367
|
+
return M(t, {
|
|
2368
|
+
code: D.invalid_type,
|
|
2369
|
+
expected: L.array,
|
|
2370
2370
|
received: t.parsedType
|
|
2371
2371
|
}), Y;
|
|
2372
2372
|
if (r.exactLength !== null) {
|
|
2373
2373
|
const o = t.data.length > r.exactLength.value, a = t.data.length < r.exactLength.value;
|
|
2374
|
-
(o || a) && (
|
|
2375
|
-
code: o ?
|
|
2374
|
+
(o || a) && (M(t, {
|
|
2375
|
+
code: o ? D.too_big : D.too_small,
|
|
2376
2376
|
minimum: a ? r.exactLength.value : void 0,
|
|
2377
2377
|
maximum: o ? r.exactLength.value : void 0,
|
|
2378
2378
|
type: "array",
|
|
@@ -2381,15 +2381,15 @@ class Ue extends X {
|
|
|
2381
2381
|
message: r.exactLength.message
|
|
2382
2382
|
}), s.dirty());
|
|
2383
2383
|
}
|
|
2384
|
-
if (r.minLength !== null && t.data.length < r.minLength.value && (
|
|
2385
|
-
code:
|
|
2384
|
+
if (r.minLength !== null && t.data.length < r.minLength.value && (M(t, {
|
|
2385
|
+
code: D.too_small,
|
|
2386
2386
|
minimum: r.minLength.value,
|
|
2387
2387
|
type: "array",
|
|
2388
2388
|
inclusive: !0,
|
|
2389
2389
|
exact: !1,
|
|
2390
2390
|
message: r.minLength.message
|
|
2391
|
-
}), s.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (
|
|
2392
|
-
code:
|
|
2391
|
+
}), s.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (M(t, {
|
|
2392
|
+
code: D.too_big,
|
|
2393
2393
|
maximum: r.maxLength.value,
|
|
2394
2394
|
type: "array",
|
|
2395
2395
|
inclusive: !0,
|
|
@@ -2406,19 +2406,19 @@ class Ue extends X {
|
|
|
2406
2406
|
min(e, t) {
|
|
2407
2407
|
return new Ue({
|
|
2408
2408
|
...this._def,
|
|
2409
|
-
minLength: { value: e, message:
|
|
2409
|
+
minLength: { value: e, message: Z.toString(t) }
|
|
2410
2410
|
});
|
|
2411
2411
|
}
|
|
2412
2412
|
max(e, t) {
|
|
2413
2413
|
return new Ue({
|
|
2414
2414
|
...this._def,
|
|
2415
|
-
maxLength: { value: e, message:
|
|
2415
|
+
maxLength: { value: e, message: Z.toString(t) }
|
|
2416
2416
|
});
|
|
2417
2417
|
}
|
|
2418
2418
|
length(e, t) {
|
|
2419
2419
|
return new Ue({
|
|
2420
2420
|
...this._def,
|
|
2421
|
-
exactLength: { value: e, message:
|
|
2421
|
+
exactLength: { value: e, message: Z.toString(t) }
|
|
2422
2422
|
});
|
|
2423
2423
|
}
|
|
2424
2424
|
nonempty(e) {
|
|
@@ -2431,7 +2431,7 @@ Ue.create = (n, e) => new Ue({
|
|
|
2431
2431
|
maxLength: null,
|
|
2432
2432
|
exactLength: null,
|
|
2433
2433
|
typeName: G.ZodArray,
|
|
2434
|
-
...
|
|
2434
|
+
...Q(e)
|
|
2435
2435
|
});
|
|
2436
2436
|
function bt(n) {
|
|
2437
2437
|
if (n instanceof fe) {
|
|
@@ -2460,11 +2460,11 @@ class fe extends X {
|
|
|
2460
2460
|
return this._cached = { shape: e, keys: t }, this._cached;
|
|
2461
2461
|
}
|
|
2462
2462
|
_parse(e) {
|
|
2463
|
-
if (this._getType(e) !==
|
|
2463
|
+
if (this._getType(e) !== L.object) {
|
|
2464
2464
|
const c = this._getOrReturnCtx(e);
|
|
2465
|
-
return
|
|
2466
|
-
code:
|
|
2467
|
-
expected:
|
|
2465
|
+
return M(c, {
|
|
2466
|
+
code: D.invalid_type,
|
|
2467
|
+
expected: L.object,
|
|
2468
2468
|
received: c.parsedType
|
|
2469
2469
|
}), Y;
|
|
2470
2470
|
}
|
|
@@ -2490,8 +2490,8 @@ class fe extends X {
|
|
|
2490
2490
|
value: { status: "valid", value: r.data[u] }
|
|
2491
2491
|
});
|
|
2492
2492
|
else if (c === "strict")
|
|
2493
|
-
a.length > 0 && (
|
|
2494
|
-
code:
|
|
2493
|
+
a.length > 0 && (M(r, {
|
|
2494
|
+
code: D.unrecognized_keys,
|
|
2495
2495
|
keys: a
|
|
2496
2496
|
}), s.dirty());
|
|
2497
2497
|
else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
@@ -2526,14 +2526,14 @@ class fe extends X {
|
|
|
2526
2526
|
return this._def.shape();
|
|
2527
2527
|
}
|
|
2528
2528
|
strict(e) {
|
|
2529
|
-
return
|
|
2529
|
+
return Z.errToObj, new fe({
|
|
2530
2530
|
...this._def,
|
|
2531
2531
|
unknownKeys: "strict",
|
|
2532
2532
|
...e !== void 0 ? {
|
|
2533
2533
|
errorMap: (t, s) => {
|
|
2534
2534
|
const r = this._def.errorMap?.(t, s).message ?? s.defaultError;
|
|
2535
2535
|
return t.code === "unrecognized_keys" ? {
|
|
2536
|
-
message:
|
|
2536
|
+
message: Z.errToObj(e).message ?? r
|
|
2537
2537
|
} : {
|
|
2538
2538
|
message: r
|
|
2539
2539
|
};
|
|
@@ -2720,21 +2720,21 @@ fe.create = (n, e) => new fe({
|
|
|
2720
2720
|
unknownKeys: "strip",
|
|
2721
2721
|
catchall: ot.create(),
|
|
2722
2722
|
typeName: G.ZodObject,
|
|
2723
|
-
...
|
|
2723
|
+
...Q(e)
|
|
2724
2724
|
});
|
|
2725
2725
|
fe.strictCreate = (n, e) => new fe({
|
|
2726
2726
|
shape: () => n,
|
|
2727
2727
|
unknownKeys: "strict",
|
|
2728
2728
|
catchall: ot.create(),
|
|
2729
2729
|
typeName: G.ZodObject,
|
|
2730
|
-
...
|
|
2730
|
+
...Q(e)
|
|
2731
2731
|
});
|
|
2732
2732
|
fe.lazycreate = (n, e) => new fe({
|
|
2733
2733
|
shape: n,
|
|
2734
2734
|
unknownKeys: "strip",
|
|
2735
2735
|
catchall: ot.create(),
|
|
2736
2736
|
typeName: G.ZodObject,
|
|
2737
|
-
...
|
|
2737
|
+
...Q(e)
|
|
2738
2738
|
});
|
|
2739
2739
|
class In extends X {
|
|
2740
2740
|
_parse(e) {
|
|
@@ -2747,8 +2747,8 @@ class In extends X {
|
|
|
2747
2747
|
if (a.result.status === "dirty")
|
|
2748
2748
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2749
2749
|
const o = i.map((a) => new Be(a.ctx.common.issues));
|
|
2750
|
-
return
|
|
2751
|
-
code:
|
|
2750
|
+
return M(t, {
|
|
2751
|
+
code: D.invalid_union,
|
|
2752
2752
|
unionErrors: o
|
|
2753
2753
|
}), Y;
|
|
2754
2754
|
}
|
|
@@ -2794,8 +2794,8 @@ class In extends X {
|
|
|
2794
2794
|
if (i)
|
|
2795
2795
|
return t.common.issues.push(...i.ctx.common.issues), i.result;
|
|
2796
2796
|
const a = o.map((l) => new Be(l));
|
|
2797
|
-
return
|
|
2798
|
-
code:
|
|
2797
|
+
return M(t, {
|
|
2798
|
+
code: D.invalid_union,
|
|
2799
2799
|
unionErrors: a
|
|
2800
2800
|
}), Y;
|
|
2801
2801
|
}
|
|
@@ -2807,13 +2807,13 @@ class In extends X {
|
|
|
2807
2807
|
In.create = (n, e) => new In({
|
|
2808
2808
|
options: n,
|
|
2809
2809
|
typeName: G.ZodUnion,
|
|
2810
|
-
...
|
|
2810
|
+
...Q(e)
|
|
2811
2811
|
});
|
|
2812
2812
|
function Os(n, e) {
|
|
2813
2813
|
const t = Xe(n), s = Xe(e);
|
|
2814
2814
|
if (n === e)
|
|
2815
2815
|
return { valid: !0, data: n };
|
|
2816
|
-
if (t ===
|
|
2816
|
+
if (t === L.object && s === L.object) {
|
|
2817
2817
|
const r = te.objectKeys(e), i = te.objectKeys(n).filter((a) => r.indexOf(a) !== -1), o = { ...n, ...e };
|
|
2818
2818
|
for (const a of i) {
|
|
2819
2819
|
const l = Os(n[a], e[a]);
|
|
@@ -2822,7 +2822,7 @@ function Os(n, e) {
|
|
|
2822
2822
|
o[a] = l.data;
|
|
2823
2823
|
}
|
|
2824
2824
|
return { valid: !0, data: o };
|
|
2825
|
-
} else if (t ===
|
|
2825
|
+
} else if (t === L.array && s === L.array) {
|
|
2826
2826
|
if (n.length !== e.length)
|
|
2827
2827
|
return { valid: !1 };
|
|
2828
2828
|
const r = [];
|
|
@@ -2833,7 +2833,7 @@ function Os(n, e) {
|
|
|
2833
2833
|
r.push(l.data);
|
|
2834
2834
|
}
|
|
2835
2835
|
return { valid: !0, data: r };
|
|
2836
|
-
} else return t ===
|
|
2836
|
+
} else return t === L.date && s === L.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2837
2837
|
}
|
|
2838
2838
|
class Dn extends X {
|
|
2839
2839
|
_parse(e) {
|
|
@@ -2841,8 +2841,8 @@ class Dn extends X {
|
|
|
2841
2841
|
if (lr(i) || lr(o))
|
|
2842
2842
|
return Y;
|
|
2843
2843
|
const a = Os(i.value, o.value);
|
|
2844
|
-
return a.valid ? ((cr(i) || cr(o)) && t.dirty(), { status: t.value, value: a.data }) : (
|
|
2845
|
-
code:
|
|
2844
|
+
return a.valid ? ((cr(i) || cr(o)) && t.dirty(), { status: t.value, value: a.data }) : (M(s, {
|
|
2845
|
+
code: D.invalid_intersection_types
|
|
2846
2846
|
}), Y);
|
|
2847
2847
|
};
|
|
2848
2848
|
return s.common.async ? Promise.all([
|
|
@@ -2871,27 +2871,27 @@ Dn.create = (n, e, t) => new Dn({
|
|
|
2871
2871
|
left: n,
|
|
2872
2872
|
right: e,
|
|
2873
2873
|
typeName: G.ZodIntersection,
|
|
2874
|
-
...
|
|
2874
|
+
...Q(t)
|
|
2875
2875
|
});
|
|
2876
2876
|
class yt extends X {
|
|
2877
2877
|
_parse(e) {
|
|
2878
2878
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2879
|
-
if (s.parsedType !==
|
|
2880
|
-
return
|
|
2881
|
-
code:
|
|
2882
|
-
expected:
|
|
2879
|
+
if (s.parsedType !== L.array)
|
|
2880
|
+
return M(s, {
|
|
2881
|
+
code: D.invalid_type,
|
|
2882
|
+
expected: L.array,
|
|
2883
2883
|
received: s.parsedType
|
|
2884
2884
|
}), Y;
|
|
2885
2885
|
if (s.data.length < this._def.items.length)
|
|
2886
|
-
return
|
|
2887
|
-
code:
|
|
2886
|
+
return M(s, {
|
|
2887
|
+
code: D.too_small,
|
|
2888
2888
|
minimum: this._def.items.length,
|
|
2889
2889
|
inclusive: !0,
|
|
2890
2890
|
exact: !1,
|
|
2891
2891
|
type: "array"
|
|
2892
2892
|
}), Y;
|
|
2893
|
-
!this._def.rest && s.data.length > this._def.items.length && (
|
|
2894
|
-
code:
|
|
2893
|
+
!this._def.rest && s.data.length > this._def.items.length && (M(s, {
|
|
2894
|
+
code: D.too_big,
|
|
2895
2895
|
maximum: this._def.items.length,
|
|
2896
2896
|
inclusive: !0,
|
|
2897
2897
|
exact: !1,
|
|
@@ -2920,7 +2920,7 @@ yt.create = (n, e) => {
|
|
|
2920
2920
|
items: n,
|
|
2921
2921
|
typeName: G.ZodTuple,
|
|
2922
2922
|
rest: null,
|
|
2923
|
-
...
|
|
2923
|
+
...Q(e)
|
|
2924
2924
|
});
|
|
2925
2925
|
};
|
|
2926
2926
|
class An extends X {
|
|
@@ -2932,10 +2932,10 @@ class An extends X {
|
|
|
2932
2932
|
}
|
|
2933
2933
|
_parse(e) {
|
|
2934
2934
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2935
|
-
if (s.parsedType !==
|
|
2936
|
-
return
|
|
2937
|
-
code:
|
|
2938
|
-
expected:
|
|
2935
|
+
if (s.parsedType !== L.object)
|
|
2936
|
+
return M(s, {
|
|
2937
|
+
code: D.invalid_type,
|
|
2938
|
+
expected: L.object,
|
|
2939
2939
|
received: s.parsedType
|
|
2940
2940
|
}), Y;
|
|
2941
2941
|
const r = [], i = this._def.keyType, o = this._def.valueType;
|
|
@@ -2955,12 +2955,12 @@ class An extends X {
|
|
|
2955
2955
|
keyType: e,
|
|
2956
2956
|
valueType: t,
|
|
2957
2957
|
typeName: G.ZodRecord,
|
|
2958
|
-
...
|
|
2958
|
+
...Q(s)
|
|
2959
2959
|
}) : new An({
|
|
2960
2960
|
keyType: qe.create(),
|
|
2961
2961
|
valueType: e,
|
|
2962
2962
|
typeName: G.ZodRecord,
|
|
2963
|
-
...
|
|
2963
|
+
...Q(t)
|
|
2964
2964
|
});
|
|
2965
2965
|
}
|
|
2966
2966
|
}
|
|
@@ -2973,10 +2973,10 @@ class pr extends X {
|
|
|
2973
2973
|
}
|
|
2974
2974
|
_parse(e) {
|
|
2975
2975
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2976
|
-
if (s.parsedType !==
|
|
2977
|
-
return
|
|
2978
|
-
code:
|
|
2979
|
-
expected:
|
|
2976
|
+
if (s.parsedType !== L.map)
|
|
2977
|
+
return M(s, {
|
|
2978
|
+
code: D.invalid_type,
|
|
2979
|
+
expected: L.map,
|
|
2980
2980
|
received: s.parsedType
|
|
2981
2981
|
}), Y;
|
|
2982
2982
|
const r = this._def.keyType, i = this._def.valueType, o = [...s.data.entries()].map(([a, l], c) => ({
|
|
@@ -3010,27 +3010,27 @@ pr.create = (n, e, t) => new pr({
|
|
|
3010
3010
|
valueType: e,
|
|
3011
3011
|
keyType: n,
|
|
3012
3012
|
typeName: G.ZodMap,
|
|
3013
|
-
...
|
|
3013
|
+
...Q(t)
|
|
3014
3014
|
});
|
|
3015
3015
|
class tn extends X {
|
|
3016
3016
|
_parse(e) {
|
|
3017
3017
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
3018
|
-
if (s.parsedType !==
|
|
3019
|
-
return
|
|
3020
|
-
code:
|
|
3021
|
-
expected:
|
|
3018
|
+
if (s.parsedType !== L.set)
|
|
3019
|
+
return M(s, {
|
|
3020
|
+
code: D.invalid_type,
|
|
3021
|
+
expected: L.set,
|
|
3022
3022
|
received: s.parsedType
|
|
3023
3023
|
}), Y;
|
|
3024
3024
|
const r = this._def;
|
|
3025
|
-
r.minSize !== null && s.data.size < r.minSize.value && (
|
|
3026
|
-
code:
|
|
3025
|
+
r.minSize !== null && s.data.size < r.minSize.value && (M(s, {
|
|
3026
|
+
code: D.too_small,
|
|
3027
3027
|
minimum: r.minSize.value,
|
|
3028
3028
|
type: "set",
|
|
3029
3029
|
inclusive: !0,
|
|
3030
3030
|
exact: !1,
|
|
3031
3031
|
message: r.minSize.message
|
|
3032
|
-
}), t.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (
|
|
3033
|
-
code:
|
|
3032
|
+
}), t.dirty()), r.maxSize !== null && s.data.size > r.maxSize.value && (M(s, {
|
|
3033
|
+
code: D.too_big,
|
|
3034
3034
|
maximum: r.maxSize.value,
|
|
3035
3035
|
type: "set",
|
|
3036
3036
|
inclusive: !0,
|
|
@@ -3053,13 +3053,13 @@ class tn extends X {
|
|
|
3053
3053
|
min(e, t) {
|
|
3054
3054
|
return new tn({
|
|
3055
3055
|
...this._def,
|
|
3056
|
-
minSize: { value: e, message:
|
|
3056
|
+
minSize: { value: e, message: Z.toString(t) }
|
|
3057
3057
|
});
|
|
3058
3058
|
}
|
|
3059
3059
|
max(e, t) {
|
|
3060
3060
|
return new tn({
|
|
3061
3061
|
...this._def,
|
|
3062
|
-
maxSize: { value: e, message:
|
|
3062
|
+
maxSize: { value: e, message: Z.toString(t) }
|
|
3063
3063
|
});
|
|
3064
3064
|
}
|
|
3065
3065
|
size(e, t) {
|
|
@@ -3074,7 +3074,7 @@ tn.create = (n, e) => new tn({
|
|
|
3074
3074
|
minSize: null,
|
|
3075
3075
|
maxSize: null,
|
|
3076
3076
|
typeName: G.ZodSet,
|
|
3077
|
-
...
|
|
3077
|
+
...Q(e)
|
|
3078
3078
|
});
|
|
3079
3079
|
class yr extends X {
|
|
3080
3080
|
get schema() {
|
|
@@ -3088,15 +3088,15 @@ class yr extends X {
|
|
|
3088
3088
|
yr.create = (n, e) => new yr({
|
|
3089
3089
|
getter: n,
|
|
3090
3090
|
typeName: G.ZodLazy,
|
|
3091
|
-
...
|
|
3091
|
+
...Q(e)
|
|
3092
3092
|
});
|
|
3093
3093
|
class ks extends X {
|
|
3094
3094
|
_parse(e) {
|
|
3095
3095
|
if (e.data !== this._def.value) {
|
|
3096
3096
|
const t = this._getOrReturnCtx(e);
|
|
3097
|
-
return
|
|
3097
|
+
return M(t, {
|
|
3098
3098
|
received: t.data,
|
|
3099
|
-
code:
|
|
3099
|
+
code: D.invalid_literal,
|
|
3100
3100
|
expected: this._def.value
|
|
3101
3101
|
}), Y;
|
|
3102
3102
|
}
|
|
@@ -3109,30 +3109,30 @@ class ks extends X {
|
|
|
3109
3109
|
ks.create = (n, e) => new ks({
|
|
3110
3110
|
value: n,
|
|
3111
3111
|
typeName: G.ZodLiteral,
|
|
3112
|
-
...
|
|
3112
|
+
...Q(e)
|
|
3113
3113
|
});
|
|
3114
3114
|
function wi(n, e) {
|
|
3115
3115
|
return new Dt({
|
|
3116
3116
|
values: n,
|
|
3117
3117
|
typeName: G.ZodEnum,
|
|
3118
|
-
...
|
|
3118
|
+
...Q(e)
|
|
3119
3119
|
});
|
|
3120
3120
|
}
|
|
3121
3121
|
class Dt extends X {
|
|
3122
3122
|
_parse(e) {
|
|
3123
3123
|
if (typeof e.data != "string") {
|
|
3124
3124
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
3125
|
-
return
|
|
3125
|
+
return M(t, {
|
|
3126
3126
|
expected: te.joinValues(s),
|
|
3127
3127
|
received: t.parsedType,
|
|
3128
|
-
code:
|
|
3128
|
+
code: D.invalid_type
|
|
3129
3129
|
}), Y;
|
|
3130
3130
|
}
|
|
3131
3131
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
3132
3132
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
3133
|
-
return
|
|
3133
|
+
return M(t, {
|
|
3134
3134
|
received: t.data,
|
|
3135
|
-
code:
|
|
3135
|
+
code: D.invalid_enum_value,
|
|
3136
3136
|
options: s
|
|
3137
3137
|
}), Y;
|
|
3138
3138
|
}
|
|
@@ -3176,19 +3176,19 @@ Dt.create = wi;
|
|
|
3176
3176
|
class gr extends X {
|
|
3177
3177
|
_parse(e) {
|
|
3178
3178
|
const t = te.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
3179
|
-
if (s.parsedType !==
|
|
3179
|
+
if (s.parsedType !== L.string && s.parsedType !== L.number) {
|
|
3180
3180
|
const r = te.objectValues(t);
|
|
3181
|
-
return
|
|
3181
|
+
return M(s, {
|
|
3182
3182
|
expected: te.joinValues(r),
|
|
3183
3183
|
received: s.parsedType,
|
|
3184
|
-
code:
|
|
3184
|
+
code: D.invalid_type
|
|
3185
3185
|
}), Y;
|
|
3186
3186
|
}
|
|
3187
3187
|
if (this._cache || (this._cache = new Set(te.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
3188
3188
|
const r = te.objectValues(t);
|
|
3189
|
-
return
|
|
3189
|
+
return M(s, {
|
|
3190
3190
|
received: s.data,
|
|
3191
|
-
code:
|
|
3191
|
+
code: D.invalid_enum_value,
|
|
3192
3192
|
options: r
|
|
3193
3193
|
}), Y;
|
|
3194
3194
|
}
|
|
@@ -3201,7 +3201,7 @@ class gr extends X {
|
|
|
3201
3201
|
gr.create = (n, e) => new gr({
|
|
3202
3202
|
values: n,
|
|
3203
3203
|
typeName: G.ZodNativeEnum,
|
|
3204
|
-
...
|
|
3204
|
+
...Q(e)
|
|
3205
3205
|
});
|
|
3206
3206
|
class Cn extends X {
|
|
3207
3207
|
unwrap() {
|
|
@@ -3209,13 +3209,13 @@ class Cn extends X {
|
|
|
3209
3209
|
}
|
|
3210
3210
|
_parse(e) {
|
|
3211
3211
|
const { ctx: t } = this._processInputParams(e);
|
|
3212
|
-
if (t.parsedType !==
|
|
3213
|
-
return
|
|
3214
|
-
code:
|
|
3215
|
-
expected:
|
|
3212
|
+
if (t.parsedType !== L.promise && t.common.async === !1)
|
|
3213
|
+
return M(t, {
|
|
3214
|
+
code: D.invalid_type,
|
|
3215
|
+
expected: L.promise,
|
|
3216
3216
|
received: t.parsedType
|
|
3217
3217
|
}), Y;
|
|
3218
|
-
const s = t.parsedType ===
|
|
3218
|
+
const s = t.parsedType === L.promise ? t.data : Promise.resolve(t.data);
|
|
3219
3219
|
return Ae(s.then((r) => this._def.type.parseAsync(r, {
|
|
3220
3220
|
path: t.path,
|
|
3221
3221
|
errorMap: t.common.contextualErrorMap
|
|
@@ -3225,7 +3225,7 @@ class Cn extends X {
|
|
|
3225
3225
|
Cn.create = (n, e) => new Cn({
|
|
3226
3226
|
type: n,
|
|
3227
3227
|
typeName: G.ZodPromise,
|
|
3228
|
-
...
|
|
3228
|
+
...Q(e)
|
|
3229
3229
|
});
|
|
3230
3230
|
class At extends X {
|
|
3231
3231
|
innerType() {
|
|
@@ -3237,7 +3237,7 @@ class At extends X {
|
|
|
3237
3237
|
_parse(e) {
|
|
3238
3238
|
const { status: t, ctx: s } = this._processInputParams(e), r = this._def.effect || null, i = {
|
|
3239
3239
|
addIssue: (o) => {
|
|
3240
|
-
|
|
3240
|
+
M(s, o), o.fatal ? t.abort() : t.dirty();
|
|
3241
3241
|
},
|
|
3242
3242
|
get path() {
|
|
3243
3243
|
return s.path;
|
|
@@ -3311,17 +3311,17 @@ At.create = (n, e, t) => new At({
|
|
|
3311
3311
|
schema: n,
|
|
3312
3312
|
typeName: G.ZodEffects,
|
|
3313
3313
|
effect: e,
|
|
3314
|
-
...
|
|
3314
|
+
...Q(t)
|
|
3315
3315
|
});
|
|
3316
3316
|
At.createWithPreprocess = (n, e, t) => new At({
|
|
3317
3317
|
schema: e,
|
|
3318
3318
|
effect: { type: "preprocess", transform: n },
|
|
3319
3319
|
typeName: G.ZodEffects,
|
|
3320
|
-
...
|
|
3320
|
+
...Q(t)
|
|
3321
3321
|
});
|
|
3322
3322
|
class st extends X {
|
|
3323
3323
|
_parse(e) {
|
|
3324
|
-
return this._getType(e) ===
|
|
3324
|
+
return this._getType(e) === L.undefined ? Ae(void 0) : this._def.innerType._parse(e);
|
|
3325
3325
|
}
|
|
3326
3326
|
unwrap() {
|
|
3327
3327
|
return this._def.innerType;
|
|
@@ -3330,11 +3330,11 @@ class st extends X {
|
|
|
3330
3330
|
st.create = (n, e) => new st({
|
|
3331
3331
|
innerType: n,
|
|
3332
3332
|
typeName: G.ZodOptional,
|
|
3333
|
-
...
|
|
3333
|
+
...Q(e)
|
|
3334
3334
|
});
|
|
3335
3335
|
class Ct extends X {
|
|
3336
3336
|
_parse(e) {
|
|
3337
|
-
return this._getType(e) ===
|
|
3337
|
+
return this._getType(e) === L.null ? Ae(null) : this._def.innerType._parse(e);
|
|
3338
3338
|
}
|
|
3339
3339
|
unwrap() {
|
|
3340
3340
|
return this._def.innerType;
|
|
@@ -3343,13 +3343,13 @@ class Ct extends X {
|
|
|
3343
3343
|
Ct.create = (n, e) => new Ct({
|
|
3344
3344
|
innerType: n,
|
|
3345
3345
|
typeName: G.ZodNullable,
|
|
3346
|
-
...
|
|
3346
|
+
...Q(e)
|
|
3347
3347
|
});
|
|
3348
3348
|
class bs extends X {
|
|
3349
3349
|
_parse(e) {
|
|
3350
3350
|
const { ctx: t } = this._processInputParams(e);
|
|
3351
3351
|
let s = t.data;
|
|
3352
|
-
return t.parsedType ===
|
|
3352
|
+
return t.parsedType === L.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
3353
3353
|
data: s,
|
|
3354
3354
|
path: t.path,
|
|
3355
3355
|
parent: t
|
|
@@ -3363,7 +3363,7 @@ bs.create = (n, e) => new bs({
|
|
|
3363
3363
|
innerType: n,
|
|
3364
3364
|
typeName: G.ZodDefault,
|
|
3365
3365
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3366
|
-
...
|
|
3366
|
+
...Q(e)
|
|
3367
3367
|
});
|
|
3368
3368
|
class Ss extends X {
|
|
3369
3369
|
_parse(e) {
|
|
@@ -3406,15 +3406,15 @@ Ss.create = (n, e) => new Ss({
|
|
|
3406
3406
|
innerType: n,
|
|
3407
3407
|
typeName: G.ZodCatch,
|
|
3408
3408
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3409
|
-
...
|
|
3409
|
+
...Q(e)
|
|
3410
3410
|
});
|
|
3411
3411
|
class wr extends X {
|
|
3412
3412
|
_parse(e) {
|
|
3413
|
-
if (this._getType(e) !==
|
|
3413
|
+
if (this._getType(e) !== L.nan) {
|
|
3414
3414
|
const s = this._getOrReturnCtx(e);
|
|
3415
|
-
return
|
|
3416
|
-
code:
|
|
3417
|
-
expected:
|
|
3415
|
+
return M(s, {
|
|
3416
|
+
code: D.invalid_type,
|
|
3417
|
+
expected: L.nan,
|
|
3418
3418
|
received: s.parsedType
|
|
3419
3419
|
}), Y;
|
|
3420
3420
|
}
|
|
@@ -3423,7 +3423,7 @@ class wr extends X {
|
|
|
3423
3423
|
}
|
|
3424
3424
|
wr.create = (n) => new wr({
|
|
3425
3425
|
typeName: G.ZodNaN,
|
|
3426
|
-
...
|
|
3426
|
+
...Q(n)
|
|
3427
3427
|
});
|
|
3428
3428
|
class Aa extends X {
|
|
3429
3429
|
_parse(e) {
|
|
@@ -3490,7 +3490,7 @@ class Ts extends X {
|
|
|
3490
3490
|
Ts.create = (n, e) => new Ts({
|
|
3491
3491
|
innerType: n,
|
|
3492
3492
|
typeName: G.ZodReadonly,
|
|
3493
|
-
...
|
|
3493
|
+
...Q(e)
|
|
3494
3494
|
});
|
|
3495
3495
|
var G;
|
|
3496
3496
|
(function(n) {
|
|
@@ -4135,7 +4135,7 @@ function Qa(n, e, t) {
|
|
|
4135
4135
|
function Ka(n) {
|
|
4136
4136
|
const e = [];
|
|
4137
4137
|
for (let t = 1; t <= 12; t++) {
|
|
4138
|
-
const s =
|
|
4138
|
+
const s = P.utc(2009, t, 1);
|
|
4139
4139
|
e.push(n(s));
|
|
4140
4140
|
}
|
|
4141
4141
|
return e;
|
|
@@ -4143,7 +4143,7 @@ function Ka(n) {
|
|
|
4143
4143
|
function Xa(n) {
|
|
4144
4144
|
const e = [];
|
|
4145
4145
|
for (let t = 1; t <= 7; t++) {
|
|
4146
|
-
const s =
|
|
4146
|
+
const s = P.utc(2016, 11, 13 + t);
|
|
4147
4147
|
e.push(n(s));
|
|
4148
4148
|
}
|
|
4149
4149
|
return e;
|
|
@@ -4300,7 +4300,7 @@ class se {
|
|
|
4300
4300
|
() => {
|
|
4301
4301
|
if (!this.meridiemCache) {
|
|
4302
4302
|
const e = { hour: "numeric", hourCycle: "h12" };
|
|
4303
|
-
this.meridiemCache = [
|
|
4303
|
+
this.meridiemCache = [P.utc(2016, 11, 13, 9), P.utc(2016, 11, 13, 19)].map(
|
|
4304
4304
|
(t) => this.extract(t, e, "dayperiod")
|
|
4305
4305
|
);
|
|
4306
4306
|
}
|
|
@@ -4311,7 +4311,7 @@ class se {
|
|
|
4311
4311
|
eras(e) {
|
|
4312
4312
|
return fn(this, e, ro, () => {
|
|
4313
4313
|
const t = { era: e };
|
|
4314
|
-
return this.eraCache[e] || (this.eraCache[e] = [
|
|
4314
|
+
return this.eraCache[e] || (this.eraCache[e] = [P.utc(-40, 1, 1), P.utc(2017, 1, 1)].map(
|
|
4315
4315
|
(s) => this.extract(s, t, "era")
|
|
4316
4316
|
)), this.eraCache[e];
|
|
4317
4317
|
});
|
|
@@ -4730,7 +4730,7 @@ class ce {
|
|
|
4730
4730
|
* @return {void}
|
|
4731
4731
|
*/
|
|
4732
4732
|
static resetCaches() {
|
|
4733
|
-
se.resetCache(), He.resetCache(),
|
|
4733
|
+
se.resetCache(), He.resetCache(), P.resetCache(), al();
|
|
4734
4734
|
}
|
|
4735
4735
|
}
|
|
4736
4736
|
class Fe {
|
|
@@ -5368,8 +5368,8 @@ class _e {
|
|
|
5368
5368
|
const d = r(f);
|
|
5369
5369
|
if (d) {
|
|
5370
5370
|
const m = h.isNegativeDuration && d !== h.largestUnit ? s : 1;
|
|
5371
|
-
let
|
|
5372
|
-
return this.opts.signMode === "negativeLargestOnly" && d !== h.largestUnit ?
|
|
5371
|
+
let b;
|
|
5372
|
+
return this.opts.signMode === "negativeLargestOnly" && d !== h.largestUnit ? b = "never" : this.opts.signMode === "all" ? b = "always" : b = "auto", this.num(u.get(d) * m, f.length, b);
|
|
5373
5373
|
} else
|
|
5374
5374
|
return f;
|
|
5375
5375
|
}, o = _e.parseFormat(t), a = o.reduce(
|
|
@@ -5983,7 +5983,7 @@ class ee {
|
|
|
5983
5983
|
format: "extended",
|
|
5984
5984
|
...e,
|
|
5985
5985
|
includeOffset: !1
|
|
5986
|
-
},
|
|
5986
|
+
}, P.fromMillis(t, { zone: "UTC" }).toISOTime(e));
|
|
5987
5987
|
}
|
|
5988
5988
|
/**
|
|
5989
5989
|
* Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
|
|
@@ -6371,13 +6371,13 @@ class le {
|
|
|
6371
6371
|
if (s && r) {
|
|
6372
6372
|
let i, o;
|
|
6373
6373
|
try {
|
|
6374
|
-
i =
|
|
6374
|
+
i = P.fromISO(s, t), o = i.isValid;
|
|
6375
6375
|
} catch {
|
|
6376
6376
|
o = !1;
|
|
6377
6377
|
}
|
|
6378
6378
|
let a, l;
|
|
6379
6379
|
try {
|
|
6380
|
-
a =
|
|
6380
|
+
a = P.fromISO(r, t), l = a.isValid;
|
|
6381
6381
|
} catch {
|
|
6382
6382
|
l = !1;
|
|
6383
6383
|
}
|
|
@@ -6771,7 +6771,7 @@ class hn {
|
|
|
6771
6771
|
* @return {boolean}
|
|
6772
6772
|
*/
|
|
6773
6773
|
static hasDST(e = ce.defaultZone) {
|
|
6774
|
-
const t =
|
|
6774
|
+
const t = P.now().setZone(e).set({ month: 12 });
|
|
6775
6775
|
return !e.isUniversal && t.offset !== t.set({ month: 6 }).offset;
|
|
6776
6776
|
}
|
|
6777
6777
|
/**
|
|
@@ -6994,7 +6994,7 @@ function _c(n) {
|
|
|
6994
6994
|
return n.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
6995
6995
|
}
|
|
6996
6996
|
function Ec(n, e) {
|
|
6997
|
-
const t = Ce(e), s = Ce(e, "{2}"), r = Ce(e, "{3}"), i = Ce(e, "{4}"), o = Ce(e, "{6}"), a = Ce(e, "{1,2}"), l = Ce(e, "{1,3}"), c = Ce(e, "{1,6}"), u = Ce(e, "{1,9}"), h = Ce(e, "{2,4}"), f = Ce(e, "{4,6}"), d = (y) => ({ regex: RegExp(_c(y.val)), deser: ([
|
|
6997
|
+
const t = Ce(e), s = Ce(e, "{2}"), r = Ce(e, "{3}"), i = Ce(e, "{4}"), o = Ce(e, "{6}"), a = Ce(e, "{1,2}"), l = Ce(e, "{1,3}"), c = Ce(e, "{1,6}"), u = Ce(e, "{1,9}"), h = Ce(e, "{2,4}"), f = Ce(e, "{4,6}"), d = (y) => ({ regex: RegExp(_c(y.val)), deser: ([_]) => _, literal: !0 }), b = ((y) => {
|
|
6998
6998
|
if (n.literal)
|
|
6999
6999
|
return d(y);
|
|
7000
7000
|
switch (y.val) {
|
|
@@ -7117,7 +7117,7 @@ function Ec(n, e) {
|
|
|
7117
7117
|
})(n) || {
|
|
7118
7118
|
invalidReason: yc
|
|
7119
7119
|
};
|
|
7120
|
-
return
|
|
7120
|
+
return b.token = n, b;
|
|
7121
7121
|
}
|
|
7122
7122
|
const vc = {
|
|
7123
7123
|
year: {
|
|
@@ -7239,7 +7239,7 @@ function Sc(n) {
|
|
|
7239
7239
|
}
|
|
7240
7240
|
let ls = null;
|
|
7241
7241
|
function Tc() {
|
|
7242
|
-
return ls || (ls =
|
|
7242
|
+
return ls || (ls = P.fromMillis(1555555555555)), ls;
|
|
7243
7243
|
}
|
|
7244
7244
|
function Rc(n, e) {
|
|
7245
7245
|
if (n.literal)
|
|
@@ -7320,7 +7320,7 @@ function dt(n, e) {
|
|
|
7320
7320
|
loc: n.loc,
|
|
7321
7321
|
invalid: n.invalid
|
|
7322
7322
|
};
|
|
7323
|
-
return new
|
|
7323
|
+
return new P({ ...t, ...e, old: t });
|
|
7324
7324
|
}
|
|
7325
7325
|
function Eo(n, e, t) {
|
|
7326
7326
|
let s = n - e * 60 * 1e3;
|
|
@@ -7370,14 +7370,14 @@ function zr(n, e) {
|
|
|
7370
7370
|
function kt(n, e, t, s, r, i) {
|
|
7371
7371
|
const { setZone: o, zone: a } = t;
|
|
7372
7372
|
if (n && Object.keys(n).length !== 0 || e) {
|
|
7373
|
-
const l = e || a, c =
|
|
7373
|
+
const l = e || a, c = P.fromObject(n, {
|
|
7374
7374
|
...t,
|
|
7375
7375
|
zone: l,
|
|
7376
7376
|
specificOffset: i
|
|
7377
7377
|
});
|
|
7378
7378
|
return o ? c : c.setZone(a);
|
|
7379
7379
|
} else
|
|
7380
|
-
return
|
|
7380
|
+
return P.invalid(
|
|
7381
7381
|
new Fe("unparsable", `the input "${r}" can't be parsed as ${s}`)
|
|
7382
7382
|
);
|
|
7383
7383
|
}
|
|
@@ -7502,7 +7502,7 @@ function Cc(n) {
|
|
|
7502
7502
|
function Hr(n, e) {
|
|
7503
7503
|
const t = tt(e.zone, ce.defaultZone);
|
|
7504
7504
|
if (!t.isValid)
|
|
7505
|
-
return
|
|
7505
|
+
return P.invalid(Gt(t));
|
|
7506
7506
|
const s = se.fromObject(e);
|
|
7507
7507
|
let r, i;
|
|
7508
7508
|
if (H(n.year))
|
|
@@ -7512,11 +7512,11 @@ function Hr(n, e) {
|
|
|
7512
7512
|
H(n[l]) && (n[l] = vo[l]);
|
|
7513
7513
|
const o = Bi(n) || Hi(n);
|
|
7514
7514
|
if (o)
|
|
7515
|
-
return
|
|
7515
|
+
return P.invalid(o);
|
|
7516
7516
|
const a = Cc(t);
|
|
7517
7517
|
[r, i] = _n(n, a, t);
|
|
7518
7518
|
}
|
|
7519
|
-
return new
|
|
7519
|
+
return new P({ ts: r, zone: t, loc: s, o: i });
|
|
7520
7520
|
}
|
|
7521
7521
|
function Gr(n, e, t) {
|
|
7522
7522
|
const s = H(t.round) ? !0 : t.round, r = H(t.rounding) ? "trunc" : t.rounding, i = (a, l) => (a = Hs(a, s || t.calendary ? 0 : 2, t.calendary ? "round" : r), e.loc.clone(t).relFormatter(t).format(a, l)), o = (a) => t.calendary ? e.hasSame(n, a) ? 0 : e.startOf(a).diff(n.startOf(a), a).get(a) : e.diff(n, a).get(a);
|
|
@@ -7535,7 +7535,7 @@ function Yr(n) {
|
|
|
7535
7535
|
}
|
|
7536
7536
|
let Yt;
|
|
7537
7537
|
const Ps = /* @__PURE__ */ new Map();
|
|
7538
|
-
class
|
|
7538
|
+
class P {
|
|
7539
7539
|
/**
|
|
7540
7540
|
* @access private
|
|
7541
7541
|
*/
|
|
@@ -7562,7 +7562,7 @@ class V {
|
|
|
7562
7562
|
* @return {DateTime}
|
|
7563
7563
|
*/
|
|
7564
7564
|
static now() {
|
|
7565
|
-
return new
|
|
7565
|
+
return new P({});
|
|
7566
7566
|
}
|
|
7567
7567
|
/**
|
|
7568
7568
|
* Create a local DateTime
|
|
@@ -7628,13 +7628,13 @@ class V {
|
|
|
7628
7628
|
static fromJSDate(e, t = {}) {
|
|
7629
7629
|
const s = dl(e) ? e.valueOf() : NaN;
|
|
7630
7630
|
if (Number.isNaN(s))
|
|
7631
|
-
return
|
|
7631
|
+
return P.invalid("invalid input");
|
|
7632
7632
|
const r = tt(t.zone, ce.defaultZone);
|
|
7633
|
-
return r.isValid ? new
|
|
7633
|
+
return r.isValid ? new P({
|
|
7634
7634
|
ts: s,
|
|
7635
7635
|
zone: r,
|
|
7636
7636
|
loc: se.fromObject(t)
|
|
7637
|
-
}) :
|
|
7637
|
+
}) : P.invalid(Gt(r));
|
|
7638
7638
|
}
|
|
7639
7639
|
/**
|
|
7640
7640
|
* Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
|
|
@@ -7649,7 +7649,7 @@ class V {
|
|
|
7649
7649
|
*/
|
|
7650
7650
|
static fromMillis(e, t = {}) {
|
|
7651
7651
|
if (rt(e))
|
|
7652
|
-
return e < -Zr || e > Zr ?
|
|
7652
|
+
return e < -Zr || e > Zr ? P.invalid("Timestamp out of range") : new P({
|
|
7653
7653
|
ts: e,
|
|
7654
7654
|
zone: tt(t.zone, ce.defaultZone),
|
|
7655
7655
|
loc: se.fromObject(t)
|
|
@@ -7671,7 +7671,7 @@ class V {
|
|
|
7671
7671
|
*/
|
|
7672
7672
|
static fromSeconds(e, t = {}) {
|
|
7673
7673
|
if (rt(e))
|
|
7674
|
-
return new
|
|
7674
|
+
return new P({
|
|
7675
7675
|
ts: e * 1e3,
|
|
7676
7676
|
zone: tt(t.zone, ce.defaultZone),
|
|
7677
7677
|
loc: se.fromObject(t)
|
|
@@ -7715,7 +7715,7 @@ class V {
|
|
|
7715
7715
|
e = e || {};
|
|
7716
7716
|
const s = tt(t.zone, ce.defaultZone);
|
|
7717
7717
|
if (!s.isValid)
|
|
7718
|
-
return
|
|
7718
|
+
return P.invalid(Gt(s));
|
|
7719
7719
|
const r = se.fromObject(t), i = Vn(e, Br), { minDaysInFirstWeek: o, startOfWeek: a } = Ar(i, r), l = ce.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, u = !H(i.ordinal), h = !H(i.year), f = !H(i.month) || !H(i.day), d = h || f, m = i.weekYear || i.weekNumber;
|
|
7720
7720
|
if ((d || u) && m)
|
|
7721
7721
|
throw new St(
|
|
@@ -7723,27 +7723,27 @@ class V {
|
|
|
7723
7723
|
);
|
|
7724
7724
|
if (f && u)
|
|
7725
7725
|
throw new St("Can't mix ordinal dates with month/day");
|
|
7726
|
-
const
|
|
7727
|
-
let y,
|
|
7728
|
-
|
|
7729
|
-
let
|
|
7726
|
+
const b = m || i.weekday && !d;
|
|
7727
|
+
let y, _, S = pn(l, c);
|
|
7728
|
+
b ? (y = Dc, _ = xc, S = Pn(S, o, a)) : u ? (y = Ac, _ = Ic, S = as(S)) : (y = En, _ = vo);
|
|
7729
|
+
let x = !1;
|
|
7730
7730
|
for (const g of y) {
|
|
7731
7731
|
const k = i[g];
|
|
7732
|
-
H(k) ?
|
|
7732
|
+
H(k) ? x ? i[g] = _[g] : i[g] = S[g] : x = !0;
|
|
7733
7733
|
}
|
|
7734
|
-
const p =
|
|
7735
|
-
if (
|
|
7736
|
-
return
|
|
7737
|
-
const
|
|
7734
|
+
const p = b ? ll(i, o, a) : u ? cl(i) : Bi(i), R = p || Hi(i);
|
|
7735
|
+
if (R)
|
|
7736
|
+
return P.invalid(R);
|
|
7737
|
+
const A = b ? Ir(i, o, a) : u ? Dr(i) : i, [v, j] = _n(A, c, s), I = new P({
|
|
7738
7738
|
ts: v,
|
|
7739
7739
|
zone: s,
|
|
7740
|
-
o:
|
|
7740
|
+
o: j,
|
|
7741
7741
|
loc: r
|
|
7742
7742
|
});
|
|
7743
|
-
return i.weekday && d && e.weekday !==
|
|
7743
|
+
return i.weekday && d && e.weekday !== I.weekday ? P.invalid(
|
|
7744
7744
|
"mismatched weekday",
|
|
7745
|
-
`you can't specify both a weekday of ${i.weekday} and a date of ${
|
|
7746
|
-
) :
|
|
7745
|
+
`you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`
|
|
7746
|
+
) : I.isValid ? I : P.invalid(I.invalid);
|
|
7747
7747
|
}
|
|
7748
7748
|
/**
|
|
7749
7749
|
* Create a DateTime from an ISO 8601 string
|
|
@@ -7827,13 +7827,13 @@ class V {
|
|
|
7827
7827
|
numberingSystem: i,
|
|
7828
7828
|
defaultToEN: !0
|
|
7829
7829
|
}), [a, l, c, u] = Nc(o, e, t);
|
|
7830
|
-
return u ?
|
|
7830
|
+
return u ? P.invalid(u) : kt(a, l, s, `format ${t}`, e, c);
|
|
7831
7831
|
}
|
|
7832
7832
|
/**
|
|
7833
7833
|
* @deprecated use fromFormat instead
|
|
7834
7834
|
*/
|
|
7835
7835
|
static fromString(e, t, s = {}) {
|
|
7836
|
-
return
|
|
7836
|
+
return P.fromFormat(e, t, s);
|
|
7837
7837
|
}
|
|
7838
7838
|
/**
|
|
7839
7839
|
* Create a DateTime from a SQL date, time, or datetime
|
|
@@ -7872,7 +7872,7 @@ class V {
|
|
|
7872
7872
|
const s = e instanceof Fe ? e : new Fe(e, t);
|
|
7873
7873
|
if (ce.throwOnInvalid)
|
|
7874
7874
|
throw new Fa(s);
|
|
7875
|
-
return new
|
|
7875
|
+
return new P({ invalid: s });
|
|
7876
7876
|
}
|
|
7877
7877
|
/**
|
|
7878
7878
|
* Check if an object is an instance of DateTime. Works across context boundaries
|
|
@@ -8311,7 +8311,7 @@ class V {
|
|
|
8311
8311
|
}
|
|
8312
8312
|
return dt(this, { ts: r, zone: e });
|
|
8313
8313
|
} else
|
|
8314
|
-
return
|
|
8314
|
+
return P.invalid(Gt(e));
|
|
8315
8315
|
}
|
|
8316
8316
|
/**
|
|
8317
8317
|
* "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
|
|
@@ -8772,7 +8772,7 @@ class V {
|
|
|
8772
8772
|
* @return {Duration}
|
|
8773
8773
|
*/
|
|
8774
8774
|
diffNow(e = "milliseconds", t = {}) {
|
|
8775
|
-
return this.diff(
|
|
8775
|
+
return this.diff(P.now(), e, t);
|
|
8776
8776
|
}
|
|
8777
8777
|
/**
|
|
8778
8778
|
* Return an Interval spanning between this DateTime and another DateTime
|
|
@@ -8829,7 +8829,7 @@ class V {
|
|
|
8829
8829
|
*/
|
|
8830
8830
|
toRelative(e = {}) {
|
|
8831
8831
|
if (!this.isValid) return null;
|
|
8832
|
-
const t = e.base ||
|
|
8832
|
+
const t = e.base || P.fromObject({}, { zone: this.zone }), s = e.padding ? this < t ? -e.padding : e.padding : 0;
|
|
8833
8833
|
let r = ["years", "months", "days", "hours", "minutes", "seconds"], i = e.unit;
|
|
8834
8834
|
return Array.isArray(e.unit) && (r = e.unit, i = void 0), Gr(t, this.plus(s), {
|
|
8835
8835
|
...e,
|
|
@@ -8852,7 +8852,7 @@ class V {
|
|
|
8852
8852
|
* @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
|
|
8853
8853
|
*/
|
|
8854
8854
|
toRelativeCalendar(e = {}) {
|
|
8855
|
-
return this.isValid ? Gr(e.base ||
|
|
8855
|
+
return this.isValid ? Gr(e.base || P.fromObject({}, { zone: this.zone }), this, {
|
|
8856
8856
|
...e,
|
|
8857
8857
|
numeric: "auto",
|
|
8858
8858
|
units: ["years", "months", "days"],
|
|
@@ -8865,7 +8865,7 @@ class V {
|
|
|
8865
8865
|
* @return {DateTime} the min DateTime, or undefined if called with no argument
|
|
8866
8866
|
*/
|
|
8867
8867
|
static min(...e) {
|
|
8868
|
-
if (!e.every(
|
|
8868
|
+
if (!e.every(P.isDateTime))
|
|
8869
8869
|
throw new we("min requires all arguments be DateTimes");
|
|
8870
8870
|
return Cr(e, (t) => t.valueOf(), Math.min);
|
|
8871
8871
|
}
|
|
@@ -8875,7 +8875,7 @@ class V {
|
|
|
8875
8875
|
* @return {DateTime} the max DateTime, or undefined if called with no argument
|
|
8876
8876
|
*/
|
|
8877
8877
|
static max(...e) {
|
|
8878
|
-
if (!e.every(
|
|
8878
|
+
if (!e.every(P.isDateTime))
|
|
8879
8879
|
throw new we("max requires all arguments be DateTimes");
|
|
8880
8880
|
return Cr(e, (t) => t.valueOf(), Math.max);
|
|
8881
8881
|
}
|
|
@@ -8899,7 +8899,7 @@ class V {
|
|
|
8899
8899
|
* @deprecated use fromFormatExplain instead
|
|
8900
8900
|
*/
|
|
8901
8901
|
static fromStringExplain(e, t, s = {}) {
|
|
8902
|
-
return
|
|
8902
|
+
return P.fromFormatExplain(e, t, s);
|
|
8903
8903
|
}
|
|
8904
8904
|
/**
|
|
8905
8905
|
* Build a parser for `fmt` using the given locale. This parser can be passed
|
|
@@ -8946,7 +8946,7 @@ class V {
|
|
|
8946
8946
|
`fromFormatParser called with a locale of ${o}, but the format parser was created for ${t.locale}`
|
|
8947
8947
|
);
|
|
8948
8948
|
const { result: a, zone: l, specificOffset: c, invalidReason: u } = t.explainFromTokens(e);
|
|
8949
|
-
return u ?
|
|
8949
|
+
return u ? P.invalid(u) : kt(
|
|
8950
8950
|
a,
|
|
8951
8951
|
l,
|
|
8952
8952
|
s,
|
|
@@ -9112,12 +9112,12 @@ class V {
|
|
|
9112
9112
|
}
|
|
9113
9113
|
}
|
|
9114
9114
|
function zt(n) {
|
|
9115
|
-
if (
|
|
9115
|
+
if (P.isDateTime(n))
|
|
9116
9116
|
return n;
|
|
9117
9117
|
if (n && n.valueOf && rt(n.valueOf()))
|
|
9118
|
-
return
|
|
9118
|
+
return P.fromJSDate(n);
|
|
9119
9119
|
if (n && typeof n == "object")
|
|
9120
|
-
return
|
|
9120
|
+
return P.fromObject(n);
|
|
9121
9121
|
throw new we(
|
|
9122
9122
|
`Unknown datetime argument: ${n}, of type ${typeof n}`
|
|
9123
9123
|
);
|
|
@@ -9186,10 +9186,10 @@ const $c = (n, e) => {
|
|
|
9186
9186
|
t ? (s = We({
|
|
9187
9187
|
seconds: ht(),
|
|
9188
9188
|
nanoseconds: ht()
|
|
9189
|
-
}), n.min && n.max ? s = s.describe(`${r}Must be between ${
|
|
9190
|
-
message: `Must be greater than or equal to ${
|
|
9189
|
+
}), n.min && n.max ? s = s.describe(`${r}Must be between ${P.fromMillis(n.min).toLocaleString(P.DATE_MED)} and ${P.fromMillis(n.max).toLocaleString(P.DATE_MED)}`) : n.min ? s = s.describe(`${r}Must be greater than or equal to ${P.fromMillis(n.min).toLocaleString(P.DATE_MED)}`) : n.max ? s = s.describe(`${r}Must be less than or equal to ${P.fromMillis(n.max).toLocaleString(P.DATE_MED)}`) : r && (s = s.describe(r.trim()))) : (s = Fc(), n.min && (s = s.refine((l) => l.toMillis() >= n.min, {
|
|
9190
|
+
message: `Must be greater than or equal to ${P.fromMillis(n.min).toLocaleString(P.DATE_MED)}`
|
|
9191
9191
|
})), n.max && (s = s.refine((l) => l.toMillis() <= n.max, {
|
|
9192
|
-
message: `Must be less than or equal to ${
|
|
9192
|
+
message: `Must be less than or equal to ${P.fromMillis(n.max).toLocaleString(P.DATE_MED)}`
|
|
9193
9193
|
})));
|
|
9194
9194
|
break;
|
|
9195
9195
|
case "Array":
|
|
@@ -9224,7 +9224,7 @@ const $c = (n, e) => {
|
|
|
9224
9224
|
a[`attribute-${c.labels.collection}-${u.type}`] = Kt().optional();
|
|
9225
9225
|
}), c.access.entityRestrictions?.restrictions?.forEach((u) => {
|
|
9226
9226
|
if (u.type === "Individual" && (a[`accessible-${c.labels.collection}-${c.labels.collection}`] = We({}).catchall(ge()).optional()), u.type === "Parent" || u.type === "Parent_Property") {
|
|
9227
|
-
const h =
|
|
9227
|
+
const h = V(c.fields, u.collectionField);
|
|
9228
9228
|
a[`accessible-${c.labels.collection}-${h.collection}`] = We({}).catchall(ge()).optional();
|
|
9229
9229
|
}
|
|
9230
9230
|
});
|
|
@@ -9242,143 +9242,143 @@ const $c = (n, e) => {
|
|
|
9242
9242
|
for (const a of s.fields)
|
|
9243
9243
|
await Jr(a.custom?.preValidate, r);
|
|
9244
9244
|
return Ma(n, t, i).parse(e), e;
|
|
9245
|
-
}, Qs = (n, e, t, s, r, i, o, a, l, c, u, h, f, d, m,
|
|
9246
|
-
const { fields:
|
|
9247
|
-
|
|
9245
|
+
}, Qs = (n, e, t, s, r, i, o, a, l, c, u, h, f, d, m, b, y, _, S, x, p) => {
|
|
9246
|
+
const { fields: R } = o;
|
|
9247
|
+
R.filter((g) => "unique" in g && g.unique).forEach((g) => {
|
|
9248
9248
|
n !== "delete" && (typeof r[g.name] == "string" || typeof r[g.name] == "number") && (e.set(d(g, r[g.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||")), {
|
|
9249
9249
|
id: s,
|
|
9250
9250
|
Collection_Path: t
|
|
9251
9251
|
}), p && p.size++);
|
|
9252
|
-
}),
|
|
9252
|
+
}), R.forEach((g) => {
|
|
9253
9253
|
if (ct(g, o, i)) {
|
|
9254
|
-
const k = dn(g, o, i),
|
|
9255
|
-
r[g.name] !== void 0 && (
|
|
9256
|
-
r[
|
|
9257
|
-
}), Object.keys(
|
|
9254
|
+
const k = dn(g, o, i), E = {};
|
|
9255
|
+
r[g.name] !== void 0 && (E[g.name] = r[g.name], K(g) && (E[`${g.name}_Array`] = r[`${g.name}_Array`])), k.forEach((B) => {
|
|
9256
|
+
r[B.name] !== void 0 && (K(B) ? E[`${B.name}_Array`] = r[`${B.name}_Array`] : E[B.name] = r[B.name]);
|
|
9257
|
+
}), Object.keys(E).length > 0 && (n === "create" && (E.Collection_Path = t, E.Collection_Path_String = t.join("/"), e.set(f(g), E)), n === "update" && e.update(f(g), E), n === "delete" && e.delete(f(g)), p && p.size++);
|
|
9258
9258
|
}
|
|
9259
9259
|
});
|
|
9260
|
-
const
|
|
9261
|
-
for (const g of
|
|
9262
|
-
const k = ia(g, o),
|
|
9263
|
-
k.forEach((
|
|
9264
|
-
delete
|
|
9265
|
-
}), Object.keys(
|
|
9260
|
+
const A = l[o.labels.collection];
|
|
9261
|
+
for (const g of A) {
|
|
9262
|
+
const k = ia(g, o), E = { ...r };
|
|
9263
|
+
k.forEach((B) => {
|
|
9264
|
+
delete E[B.name], delete E[`${B.name}_Array`], delete E[`${B.name}_Single`], delete E[`${B.name}_Lowercase`];
|
|
9265
|
+
}), Object.keys(E).length > 0 && (n === "create" && (E.Collection_Path ||= t, E.Collection_Path_String = t.join("/"), e.set(m(g.key), E)), n === "update" && e.update(m(g.key), E), n === "delete" && e.delete(m(g.key)), p && p.size++);
|
|
9266
9266
|
}
|
|
9267
9267
|
const v = (g, k) => {
|
|
9268
|
-
let
|
|
9269
|
-
ct(k, g, i) &&
|
|
9270
|
-
ct(
|
|
9268
|
+
let E = 1;
|
|
9269
|
+
ct(k, g, i) && E++, g.fields.forEach((w) => {
|
|
9270
|
+
ct(w, g, i) && JSON.parse(es(dn(w, g, i))).includes(k.name) && E++;
|
|
9271
9271
|
});
|
|
9272
|
-
const
|
|
9273
|
-
for (const
|
|
9274
|
-
|
|
9275
|
-
return
|
|
9276
|
-
},
|
|
9277
|
-
const
|
|
9278
|
-
|
|
9279
|
-
[`${
|
|
9280
|
-
[`${
|
|
9281
|
-
}), k.fields.forEach((
|
|
9282
|
-
ct(
|
|
9283
|
-
[`${
|
|
9272
|
+
const B = l[g.labels.collection];
|
|
9273
|
+
for (const w of B)
|
|
9274
|
+
w.fields.some((N) => N.name === k.name) && K(k) && E++;
|
|
9275
|
+
return E;
|
|
9276
|
+
}, j = (g, k, E, B, w) => {
|
|
9277
|
+
const N = {};
|
|
9278
|
+
N[`${E.name}.${s}`] = h(), N[`${E.name}_Array`] = u(s), N[`${E.name}_Single`] = h(), e.update(b(w, B), N), ct(E, k, i) && e.update(y(g, E.name, B), {
|
|
9279
|
+
[`${E.name}.${s}`]: h(),
|
|
9280
|
+
[`${E.name}_Array`]: u(s)
|
|
9281
|
+
}), k.fields.forEach((C) => {
|
|
9282
|
+
ct(C, k, i) && JSON.parse(es(dn(C, k, i))).includes(E.name) && e.update(y(g, C.name, B), {
|
|
9283
|
+
[`${E.name}_Array`]: u(s)
|
|
9284
9284
|
});
|
|
9285
9285
|
});
|
|
9286
|
-
const
|
|
9287
|
-
for (const
|
|
9288
|
-
|
|
9286
|
+
const T = l[k.labels.collection];
|
|
9287
|
+
for (const C of T)
|
|
9288
|
+
C.fields.some((F) => F.name === E.name) && K(E) && e.update(_(g, C.key, B), N);
|
|
9289
9289
|
};
|
|
9290
9290
|
if (n === "delete")
|
|
9291
9291
|
return;
|
|
9292
|
-
const
|
|
9292
|
+
const I = R.filter((g) => K(g) && g.twoWay);
|
|
9293
9293
|
if (!a?.noTwoWay) {
|
|
9294
|
-
for (const g of
|
|
9294
|
+
for (const g of I) {
|
|
9295
9295
|
if (!p)
|
|
9296
9296
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9297
|
-
const k = i.collections[g.collection],
|
|
9298
|
-
if (!
|
|
9297
|
+
const k = i.collections[g.collection], E = V(k.fields, g.twoWay), B = ft(k, k.fields), w = Array.from(B).map((N) => N.name);
|
|
9298
|
+
if (!E)
|
|
9299
9299
|
throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
|
|
9300
|
-
if (K(
|
|
9300
|
+
if (K(E)) {
|
|
9301
9301
|
if (r[`${g.name}_Array`])
|
|
9302
|
-
for (const [
|
|
9303
|
-
if (n === "update" &&
|
|
9302
|
+
for (const [N, T] of Object.entries(r[g.name])) {
|
|
9303
|
+
if (n === "update" && S && S[`${g.name}_Array`]?.includes(N))
|
|
9304
9304
|
continue;
|
|
9305
|
-
const
|
|
9306
|
-
nt(
|
|
9307
|
-
const
|
|
9308
|
-
|
|
9309
|
-
if (
|
|
9310
|
-
|
|
9311
|
-
const
|
|
9312
|
-
wt(o, [
|
|
9305
|
+
const C = { ...S, ...r };
|
|
9306
|
+
nt(C);
|
|
9307
|
+
const F = {};
|
|
9308
|
+
E.includeFields && E.includeFields.forEach((O) => {
|
|
9309
|
+
if (C[O] !== void 0) {
|
|
9310
|
+
F[O] = C[O];
|
|
9311
|
+
const z = V(o.fields, O);
|
|
9312
|
+
wt(o, [z]).size === 1 && (F[`${O}_Lowercase`] = C[`${O}_Lowercase`]);
|
|
9313
9313
|
}
|
|
9314
9314
|
});
|
|
9315
|
-
const
|
|
9315
|
+
const W = {
|
|
9316
9316
|
[`${g.twoWay}.${s}`]: {
|
|
9317
9317
|
Collection_Path: t,
|
|
9318
|
-
...
|
|
9318
|
+
...F
|
|
9319
9319
|
},
|
|
9320
9320
|
[`${g.twoWay}_Array`]: c(s)
|
|
9321
9321
|
};
|
|
9322
|
-
|
|
9322
|
+
w.includes(E.name) && (W[`${g.twoWay}_Single`] = {
|
|
9323
9323
|
Collection_Path: t,
|
|
9324
|
-
...
|
|
9324
|
+
...F
|
|
9325
9325
|
});
|
|
9326
|
-
const
|
|
9327
|
-
e.update(
|
|
9328
|
-
...
|
|
9329
|
-
...
|
|
9330
|
-
}), p.size++, ct(
|
|
9331
|
-
[`${
|
|
9326
|
+
const U = Sn(r);
|
|
9327
|
+
e.update(b(T.Collection_Path, N), {
|
|
9328
|
+
...W,
|
|
9329
|
+
...U
|
|
9330
|
+
}), p.size++, ct(E, k, i) && (e.update(y(g, E.name, N), {
|
|
9331
|
+
[`${E.name}.${s}`]: {
|
|
9332
9332
|
Collection_Path: t,
|
|
9333
|
-
...
|
|
9333
|
+
...F
|
|
9334
9334
|
},
|
|
9335
|
-
[`${
|
|
9336
|
-
}), p.size++), k.fields.forEach((
|
|
9337
|
-
if (ct(
|
|
9338
|
-
const
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
}), Object.keys(
|
|
9335
|
+
[`${E.name}_Array`]: c(s)
|
|
9336
|
+
}), p.size++), k.fields.forEach((O) => {
|
|
9337
|
+
if (ct(O, k, i)) {
|
|
9338
|
+
const z = JSON.parse(es(dn(O, k, i))), q = {};
|
|
9339
|
+
z.includes(E.name) && (q[`${g.twoWay}_Array`] = c(s)), Object.keys(U).forEach((re) => {
|
|
9340
|
+
z.includes(re) && (q[re] = U[re]);
|
|
9341
|
+
}), Object.keys(q).length > 0 && (e.update(y(g, O.name, N), q), p.size++);
|
|
9342
9342
|
}
|
|
9343
9343
|
});
|
|
9344
|
-
const
|
|
9345
|
-
for (const
|
|
9346
|
-
if (
|
|
9347
|
-
const
|
|
9348
|
-
Object.keys(
|
|
9349
|
-
|
|
9350
|
-
}), Object.keys(
|
|
9344
|
+
const J = l[k.labels.collection];
|
|
9345
|
+
for (const O of J)
|
|
9346
|
+
if (O.fields.some((z) => z.name === E.name)) {
|
|
9347
|
+
const z = { ...W };
|
|
9348
|
+
Object.keys(U).forEach((q) => {
|
|
9349
|
+
O.fields.some((re) => re.name === q) && (z[q] = U[q]);
|
|
9350
|
+
}), Object.keys(z).length > 0 && (e.update(_(g, O.key, N), z), p.size++);
|
|
9351
9351
|
}
|
|
9352
9352
|
}
|
|
9353
9353
|
} else
|
|
9354
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9354
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${E.type}`);
|
|
9355
9355
|
}
|
|
9356
9356
|
p && p.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${p.size} operations in the Firestore transaction has exceeded the recommended limit of 500. This is likely due to a large number of two way updates, roles, dependencies on the collection, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
|
|
9357
|
-
for (const g of
|
|
9357
|
+
for (const g of I) {
|
|
9358
9358
|
if (!p)
|
|
9359
9359
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9360
|
-
const k = i.collections[g.collection],
|
|
9361
|
-
if (!
|
|
9360
|
+
const k = i.collections[g.collection], E = V(k.fields, g.twoWay);
|
|
9361
|
+
if (!E)
|
|
9362
9362
|
throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
|
|
9363
|
-
if (K(
|
|
9364
|
-
if (n === "update" &&
|
|
9365
|
-
for (const [
|
|
9366
|
-
!r[`${g.name}_Array`].includes(
|
|
9363
|
+
if (K(E)) {
|
|
9364
|
+
if (n === "update" && S && !(r[g.name] && Me(r[g.name])) && r[`${g.name}_Array`] && S[`${g.name}_Array`]?.length > 0)
|
|
9365
|
+
for (const [B, w] of Object.entries(S[g.name]))
|
|
9366
|
+
!r[`${g.name}_Array`].includes(B) && !x?.get(g.name)?.includes(B) && (p.size += v(k, E), p.size <= 500 && j(g, k, E, B, w.Collection_Path));
|
|
9367
9367
|
} else
|
|
9368
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9368
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${E.type}`);
|
|
9369
9369
|
}
|
|
9370
|
-
for (const g of
|
|
9370
|
+
for (const g of I) {
|
|
9371
9371
|
if (!p)
|
|
9372
9372
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9373
|
-
const k = i.collections[g.collection],
|
|
9374
|
-
if (!
|
|
9373
|
+
const k = i.collections[g.collection], E = V(k.fields, g.twoWay);
|
|
9374
|
+
if (!E)
|
|
9375
9375
|
throw new Error(`SCHEMA_ERROR: Field ${g.twoWay} not found in collection ${g.collection}`);
|
|
9376
|
-
if (K(
|
|
9377
|
-
if (n === "update" &&
|
|
9378
|
-
for (const [
|
|
9379
|
-
|
|
9376
|
+
if (K(E)) {
|
|
9377
|
+
if (n === "update" && S && r[g.name] && Me(r[g.name]) && S[`${g.name}_Array`]?.length > 0)
|
|
9378
|
+
for (const [B, w] of Object.entries(S[g.name]))
|
|
9379
|
+
x?.get(g.name)?.includes(B) || (p.size += v(k, E), p.size <= 500 && j(g, k, E, B, w.Collection_Path));
|
|
9380
9380
|
} else
|
|
9381
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9381
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${E.type}`);
|
|
9382
9382
|
}
|
|
9383
9383
|
}
|
|
9384
9384
|
}, Ve = (n) => {
|
|
@@ -9568,209 +9568,209 @@ const Tt = {
|
|
|
9568
9568
|
const d = r.collections?.[l.collection];
|
|
9569
9569
|
if (!r.Role)
|
|
9570
9570
|
throw new Error("PERMISSION_DENIED");
|
|
9571
|
-
const m = d && Te("Read", d),
|
|
9572
|
-
const
|
|
9573
|
-
if (!
|
|
9571
|
+
const m = d && Te("Read", d), b = ui(a, t, r), y = li(a, r), _ = Ls(a, r), S = ci(a, t, r), x = (w = []) => {
|
|
9572
|
+
const N = [], T = pi(r.Role, a, t);
|
|
9573
|
+
if (!T)
|
|
9574
9574
|
throw new Error("PERMISSION_DENIED");
|
|
9575
9575
|
if (m) {
|
|
9576
|
-
let
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
}),
|
|
9580
|
-
} else if (
|
|
9581
|
-
for (const
|
|
9582
|
-
let
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
}),
|
|
9576
|
+
let C = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${T.key}`).where("Collection_Path_String", "==", e.join("/"));
|
|
9577
|
+
w.forEach((F) => {
|
|
9578
|
+
C = C.where(...F);
|
|
9579
|
+
}), N.push(C);
|
|
9580
|
+
} else if (b)
|
|
9581
|
+
for (const C of b) {
|
|
9582
|
+
let F = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${C.field}`).where("Collection_Path_String", "==", e.join("/"));
|
|
9583
|
+
w.forEach((W) => {
|
|
9584
|
+
F = F.where(...W);
|
|
9585
|
+
}), N.push(F);
|
|
9586
9586
|
}
|
|
9587
|
-
return
|
|
9588
|
-
}, p = y.filter((
|
|
9589
|
-
if (p.length === 0 &&
|
|
9590
|
-
return
|
|
9591
|
-
let
|
|
9592
|
-
const
|
|
9593
|
-
|
|
9587
|
+
return N;
|
|
9588
|
+
}, p = y.filter((w) => "operations" in w && w.operations ? w.operations.includes("Read") : !0);
|
|
9589
|
+
if (p.length === 0 && _.length === 0 && S.length === 0)
|
|
9590
|
+
return x();
|
|
9591
|
+
let R = 0;
|
|
9592
|
+
const A = (w) => {
|
|
9593
|
+
w && (R === 0 ? R = w : R *= w);
|
|
9594
9594
|
};
|
|
9595
9595
|
if (p.length > 0) {
|
|
9596
|
-
for (const
|
|
9597
|
-
if (
|
|
9598
|
-
const
|
|
9599
|
-
if (!
|
|
9596
|
+
for (const w of p)
|
|
9597
|
+
if (w.operations && w.type === "Record_Property") {
|
|
9598
|
+
const N = w.roles.find((T) => T.role === r.Role);
|
|
9599
|
+
if (!N)
|
|
9600
9600
|
throw new Error("PERMISSION_DENIED");
|
|
9601
|
-
|
|
9601
|
+
A(N.values?.length);
|
|
9602
9602
|
}
|
|
9603
9603
|
}
|
|
9604
|
-
u?.roles.includes(r.Role) && u.range &&
|
|
9604
|
+
u?.roles.includes(r.Role) && u.range && A(u.range.fields.length);
|
|
9605
9605
|
const v = h.admin?.statusField;
|
|
9606
|
-
v && !u?.roles.includes(r.Role) &&
|
|
9607
|
-
const
|
|
9608
|
-
p.filter((
|
|
9609
|
-
if ("collectionField" in
|
|
9610
|
-
const
|
|
9611
|
-
|
|
9606
|
+
v && !u?.roles.includes(r.Role) && A(Math.max(v.active?.length || 0, v.archived?.length || 0));
|
|
9607
|
+
const j = R === 0 ? 30 : Math.max(1, Math.floor(30 / R)), I = [];
|
|
9608
|
+
p.filter((w) => w.type === "Record_Owner").forEach(() => I.push(["Created_By", "==", s])), p.filter((w) => w.type === "Record_User").forEach((w) => {
|
|
9609
|
+
if ("collectionField" in w) {
|
|
9610
|
+
const N = V(c, w.collectionField);
|
|
9611
|
+
I.push([`${N.name}_Array`, "array-contains", r.Doc_ID]);
|
|
9612
9612
|
}
|
|
9613
|
-
}), p.filter((
|
|
9614
|
-
if ("propertyField" in
|
|
9615
|
-
const
|
|
9616
|
-
if (!
|
|
9613
|
+
}), p.filter((w) => w.type === "Record_Property").forEach((w) => {
|
|
9614
|
+
if ("propertyField" in w) {
|
|
9615
|
+
const N = w.roles.find((C) => C.role === r.Role);
|
|
9616
|
+
if (!N)
|
|
9617
9617
|
throw new Error("PERMISSION_DENIED");
|
|
9618
|
-
const
|
|
9619
|
-
|
|
9618
|
+
const T = V(c, w.propertyField);
|
|
9619
|
+
T.type === "Array" ? I.push([`${T.name}_Array`, "array-contains-any", N.values]) : I.push([T.name, "in", N.values]);
|
|
9620
9620
|
}
|
|
9621
9621
|
});
|
|
9622
9622
|
const g = [];
|
|
9623
|
-
|
|
9624
|
-
const
|
|
9625
|
-
if (
|
|
9626
|
-
const
|
|
9627
|
-
for (let
|
|
9628
|
-
const
|
|
9629
|
-
|
|
9623
|
+
_.filter((w) => w.type === "Individual").forEach((w) => {
|
|
9624
|
+
const N = d?.individualEntities, T = [];
|
|
9625
|
+
if (N) {
|
|
9626
|
+
const C = w.singleQuery ? w.singleQuery : j;
|
|
9627
|
+
for (let F = 0; F < N.length; F += C) {
|
|
9628
|
+
const W = N.slice(F, F + C);
|
|
9629
|
+
T.push(W);
|
|
9630
9630
|
}
|
|
9631
|
-
if (!
|
|
9632
|
-
|
|
9633
|
-
g.push(...
|
|
9631
|
+
if (!w.singleQuery)
|
|
9632
|
+
T.forEach((F) => {
|
|
9633
|
+
g.push(...x(I.concat([["id", "in", F]])));
|
|
9634
9634
|
});
|
|
9635
9635
|
else {
|
|
9636
|
-
if (
|
|
9637
|
-
throw new Error(`INPUT_ERROR: Individual entity restriction with singleQuery set to true must not have more than ${
|
|
9638
|
-
|
|
9636
|
+
if (N.length > C)
|
|
9637
|
+
throw new Error(`INPUT_ERROR: Individual entity restriction with singleQuery set to true must not have more than ${w.singleQuery} entities`);
|
|
9638
|
+
I.push(["id", "in", N]);
|
|
9639
9639
|
}
|
|
9640
9640
|
}
|
|
9641
|
-
}),
|
|
9642
|
-
const { parentFilter:
|
|
9643
|
-
if ("collectionField" in
|
|
9644
|
-
const
|
|
9645
|
-
if ("collection" in
|
|
9646
|
-
const
|
|
9647
|
-
if (!
|
|
9641
|
+
}), S.filter((w) => w.parentFilter.type === "Individual").forEach((w) => {
|
|
9642
|
+
const { parentFilter: N, parentRestriction: T } = w;
|
|
9643
|
+
if ("collectionField" in N) {
|
|
9644
|
+
const C = V(c, N.collectionField);
|
|
9645
|
+
if ("collection" in C) {
|
|
9646
|
+
const F = r.collections?.[C.collection];
|
|
9647
|
+
if (!F)
|
|
9648
9648
|
throw new Error("PERMISSION_DENIED");
|
|
9649
|
-
const
|
|
9650
|
-
if (
|
|
9651
|
-
const
|
|
9652
|
-
for (let
|
|
9653
|
-
const
|
|
9654
|
-
|
|
9649
|
+
const W = F.individualEntities, U = [];
|
|
9650
|
+
if (W) {
|
|
9651
|
+
const J = T.singleQuery ? T.singleQuery : j;
|
|
9652
|
+
for (let O = 0; O < W.length; O += J) {
|
|
9653
|
+
const z = W.slice(O, O + J);
|
|
9654
|
+
U.push(z);
|
|
9655
9655
|
}
|
|
9656
|
-
if (!
|
|
9657
|
-
|
|
9658
|
-
g.push(...
|
|
9656
|
+
if (!T.singleQuery)
|
|
9657
|
+
U.forEach((O) => {
|
|
9658
|
+
g.push(...x(I.concat([[`${C.name}_Array`, "array-contains-any", O]])));
|
|
9659
9659
|
});
|
|
9660
9660
|
else {
|
|
9661
|
-
if (
|
|
9662
|
-
throw new Error(`INPUT_ERROR: Individual entity parentFilter with singleQuery set to true must not have more than ${
|
|
9663
|
-
|
|
9661
|
+
if (W.length > J)
|
|
9662
|
+
throw new Error(`INPUT_ERROR: Individual entity parentFilter with singleQuery set to true must not have more than ${T.singleQuery} entities`);
|
|
9663
|
+
I.push([`${C.name}_Array`, "array-contains-any", W]);
|
|
9664
9664
|
}
|
|
9665
9665
|
}
|
|
9666
9666
|
}
|
|
9667
9667
|
}
|
|
9668
9668
|
});
|
|
9669
9669
|
const k = [];
|
|
9670
|
-
|
|
9671
|
-
if ("collectionField" in
|
|
9672
|
-
const
|
|
9673
|
-
if ("collection" in
|
|
9674
|
-
const
|
|
9675
|
-
if (
|
|
9676
|
-
const
|
|
9677
|
-
for (let
|
|
9678
|
-
const
|
|
9679
|
-
|
|
9670
|
+
_.filter((w) => w.type === "Parent").forEach((w) => {
|
|
9671
|
+
if ("collectionField" in w) {
|
|
9672
|
+
const N = V(c, w.collectionField);
|
|
9673
|
+
if ("collection" in N) {
|
|
9674
|
+
const T = d?.parentEntities, C = [];
|
|
9675
|
+
if (T) {
|
|
9676
|
+
const F = w.singleQuery ? w.singleQuery : j;
|
|
9677
|
+
for (let W = 0; W < T.length; W += F) {
|
|
9678
|
+
const U = T.slice(W, W + F);
|
|
9679
|
+
C.push(U);
|
|
9680
9680
|
}
|
|
9681
|
-
if (!
|
|
9682
|
-
|
|
9683
|
-
k.push(...
|
|
9681
|
+
if (!w.singleQuery)
|
|
9682
|
+
C.forEach((W) => {
|
|
9683
|
+
k.push(...x(I.concat([[`${N.name}_Array`, "array-contains-any", W]])));
|
|
9684
9684
|
});
|
|
9685
9685
|
else {
|
|
9686
|
-
if (
|
|
9687
|
-
throw new Error(`INPUT_ERROR: Parent entity restriction with singleQuery set to true must not have more than ${
|
|
9688
|
-
|
|
9686
|
+
if (T && T.length > F)
|
|
9687
|
+
throw new Error(`INPUT_ERROR: Parent entity restriction with singleQuery set to true must not have more than ${w.singleQuery} entities`);
|
|
9688
|
+
I.push([`${N.name}_Array`, "array-contains-any", T]);
|
|
9689
9689
|
}
|
|
9690
9690
|
}
|
|
9691
9691
|
}
|
|
9692
9692
|
}
|
|
9693
|
-
}),
|
|
9694
|
-
const { parentFilter:
|
|
9695
|
-
if ("collectionField" in
|
|
9696
|
-
const
|
|
9697
|
-
if ("collection" in
|
|
9698
|
-
const
|
|
9699
|
-
if (!
|
|
9693
|
+
}), S.filter((w) => w.parentFilter.type === "Parent").forEach((w) => {
|
|
9694
|
+
const { parentFilter: N, parentRestriction: T } = w;
|
|
9695
|
+
if ("collectionField" in N && "parentCollectionField" in N) {
|
|
9696
|
+
const C = V(c, N.collectionField), F = V(c, N.parentCollectionField);
|
|
9697
|
+
if ("collection" in C && "collection" in F) {
|
|
9698
|
+
const W = r.collections?.[C.collection];
|
|
9699
|
+
if (!W)
|
|
9700
9700
|
throw new Error("PERMISSION_DENIED");
|
|
9701
|
-
const
|
|
9702
|
-
if (
|
|
9703
|
-
const
|
|
9704
|
-
for (let
|
|
9705
|
-
const
|
|
9706
|
-
|
|
9701
|
+
const U = W.parentEntities, J = [];
|
|
9702
|
+
if (U) {
|
|
9703
|
+
const O = T.singleQuery ? T.singleQuery : j;
|
|
9704
|
+
for (let z = 0; z < U.length; z += O) {
|
|
9705
|
+
const q = U.slice(z, z + O);
|
|
9706
|
+
J.push(q);
|
|
9707
9707
|
}
|
|
9708
|
-
if (!
|
|
9709
|
-
|
|
9710
|
-
k.push(...
|
|
9711
|
-
[`${
|
|
9708
|
+
if (!T.singleQuery)
|
|
9709
|
+
J.forEach((z) => {
|
|
9710
|
+
k.push(...x(I.concat([
|
|
9711
|
+
[`${F.name}_Array`, "array-contains-any", z]
|
|
9712
9712
|
])));
|
|
9713
9713
|
});
|
|
9714
9714
|
else {
|
|
9715
|
-
if (
|
|
9716
|
-
throw new Error(`INPUT_ERROR: Profile_Parent entity parentFilter with singleQuery set to true must not have more than ${
|
|
9717
|
-
|
|
9718
|
-
`${
|
|
9715
|
+
if (U && U.length > O)
|
|
9716
|
+
throw new Error(`INPUT_ERROR: Profile_Parent entity parentFilter with singleQuery set to true must not have more than ${T.singleQuery} entities`);
|
|
9717
|
+
I.push([
|
|
9718
|
+
`${F.name}_Array`,
|
|
9719
9719
|
"array-contains-any",
|
|
9720
|
-
|
|
9720
|
+
U
|
|
9721
9721
|
]);
|
|
9722
9722
|
}
|
|
9723
9723
|
}
|
|
9724
9724
|
}
|
|
9725
9725
|
}
|
|
9726
9726
|
});
|
|
9727
|
-
const
|
|
9728
|
-
k.length === 0 && (
|
|
9729
|
-
if ("collectionField" in
|
|
9730
|
-
const
|
|
9731
|
-
if ("collection" in
|
|
9732
|
-
const
|
|
9733
|
-
Object.entries(
|
|
9734
|
-
if (
|
|
9735
|
-
const
|
|
9736
|
-
for (let
|
|
9737
|
-
const
|
|
9738
|
-
|
|
9727
|
+
const E = [];
|
|
9728
|
+
k.length === 0 && (_.filter((w) => w.type === "Parent_Property").forEach((w) => {
|
|
9729
|
+
if ("collectionField" in w && "propertyField" in w) {
|
|
9730
|
+
const N = V(c, w.collectionField), T = V(c, w.propertyField);
|
|
9731
|
+
if ("collection" in N) {
|
|
9732
|
+
const C = d?.parentPropertyEntities || {};
|
|
9733
|
+
Object.entries(C).forEach(([F, W]) => {
|
|
9734
|
+
if (W.length > 0) {
|
|
9735
|
+
const U = [];
|
|
9736
|
+
for (let J = 0; J < W.length; J += j) {
|
|
9737
|
+
const O = W.slice(J, J + j);
|
|
9738
|
+
U.push(O);
|
|
9739
9739
|
}
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
[`${
|
|
9743
|
-
[
|
|
9740
|
+
U.forEach((J) => {
|
|
9741
|
+
E.push(...x(I.concat([
|
|
9742
|
+
[`${N.name}_Array`, "array-contains-any", J],
|
|
9743
|
+
[T.name, "==", F]
|
|
9744
9744
|
])));
|
|
9745
9745
|
});
|
|
9746
9746
|
}
|
|
9747
9747
|
});
|
|
9748
9748
|
}
|
|
9749
9749
|
}
|
|
9750
|
-
}),
|
|
9751
|
-
const { parentFilter:
|
|
9752
|
-
if ("collectionField" in
|
|
9753
|
-
const
|
|
9754
|
-
if ("collection" in
|
|
9755
|
-
const
|
|
9756
|
-
if (!
|
|
9750
|
+
}), S.filter((w) => w.parentFilter.type === "Parent_Property").forEach((w) => {
|
|
9751
|
+
const { parentFilter: N } = w;
|
|
9752
|
+
if ("collectionField" in N && "parentCollectionField" in N && "parentPropertyField" in N) {
|
|
9753
|
+
const T = V(c, N.collectionField), C = V(c, N.parentCollectionField), F = V(c, N.parentPropertyField);
|
|
9754
|
+
if ("collection" in T && "collection" in C) {
|
|
9755
|
+
const W = r.collections?.[T.collection];
|
|
9756
|
+
if (!W)
|
|
9757
9757
|
throw new Error("PERMISSION_DENIED");
|
|
9758
|
-
const
|
|
9759
|
-
Object.entries(
|
|
9760
|
-
if (
|
|
9761
|
-
const
|
|
9762
|
-
for (let
|
|
9763
|
-
const re =
|
|
9764
|
-
|
|
9758
|
+
const U = W.parentPropertyEntities || {};
|
|
9759
|
+
Object.entries(U).forEach(([J, O]) => {
|
|
9760
|
+
if (O.length > 0) {
|
|
9761
|
+
const z = [];
|
|
9762
|
+
for (let q = 0; q < O.length; q += j) {
|
|
9763
|
+
const re = O.slice(q, q + j);
|
|
9764
|
+
z.push(re);
|
|
9765
9765
|
}
|
|
9766
|
-
|
|
9767
|
-
|
|
9766
|
+
z.forEach((q) => {
|
|
9767
|
+
E.push(...x(I.concat([
|
|
9768
9768
|
[
|
|
9769
|
-
`${
|
|
9769
|
+
`${C.name}_Array`,
|
|
9770
9770
|
"array-contains-any",
|
|
9771
|
-
|
|
9771
|
+
q
|
|
9772
9772
|
],
|
|
9773
|
-
[
|
|
9773
|
+
[F.name, "==", J]
|
|
9774
9774
|
])));
|
|
9775
9775
|
});
|
|
9776
9776
|
}
|
|
@@ -9778,8 +9778,8 @@ const Tt = {
|
|
|
9778
9778
|
}
|
|
9779
9779
|
}
|
|
9780
9780
|
}));
|
|
9781
|
-
const
|
|
9782
|
-
return !
|
|
9781
|
+
const B = [...g, ...k, ...E];
|
|
9782
|
+
return !_.length && !S.length ? x(I) : B;
|
|
9783
9783
|
} else
|
|
9784
9784
|
throw new Error("PERMISSION_DENIED");
|
|
9785
9785
|
else return [f];
|
|
@@ -9798,8 +9798,8 @@ const Tt = {
|
|
|
9798
9798
|
if (h)
|
|
9799
9799
|
d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${m.key}`).doc(t));
|
|
9800
9800
|
else if (f)
|
|
9801
|
-
for (const
|
|
9802
|
-
d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${
|
|
9801
|
+
for (const b of f)
|
|
9802
|
+
d.push(i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${b.field}`).doc(t));
|
|
9803
9803
|
return d;
|
|
9804
9804
|
} else
|
|
9805
9805
|
return [c.doc(t)];
|
|
@@ -9810,7 +9810,7 @@ const Tt = {
|
|
|
9810
9810
|
throw new Error(`SCHEMA_ERROR: Collection ${m} not found in subcollections of ${u}`);
|
|
9811
9811
|
}) : s.collections = h;
|
|
9812
9812
|
const f = s.depth - 1, d = s.collections.map(async (m) => {
|
|
9813
|
-
const
|
|
9813
|
+
const b = await Io([...t, m], s.constraints, {
|
|
9814
9814
|
user: a,
|
|
9815
9815
|
pagination: s.limit,
|
|
9816
9816
|
providedTransaction: l,
|
|
@@ -9818,7 +9818,7 @@ const Tt = {
|
|
|
9818
9818
|
}).catch((y) => {
|
|
9819
9819
|
throw y.code === "permission-denied" && console.info(`PERMISSION_DENIED for subcollection ${m} for document at ${t.join("/")}`), y;
|
|
9820
9820
|
});
|
|
9821
|
-
e[m] =
|
|
9821
|
+
e[m] = b.docs, i && await Promise.all(
|
|
9822
9822
|
// eslint-disable-next-line security/detect-object-injection
|
|
9823
9823
|
e[m].map((y) => Xs(n, y, [...t, m, y.id], i, r, void 0, a, l, c))
|
|
9824
9824
|
), f > 0 && await Promise.all(
|
|
@@ -9837,18 +9837,18 @@ const Tt = {
|
|
|
9837
9837
|
if (!d)
|
|
9838
9838
|
continue;
|
|
9839
9839
|
const m = Object.keys(d);
|
|
9840
|
-
for (const
|
|
9841
|
-
const y = d[
|
|
9840
|
+
for (const b of m) {
|
|
9841
|
+
const y = d[b], _ = at(y.Collection_Path, b, {
|
|
9842
9842
|
user: o,
|
|
9843
9843
|
providedTransaction: a,
|
|
9844
9844
|
noEmbeddingFields: l
|
|
9845
|
-
}).then((
|
|
9846
|
-
if (d[
|
|
9845
|
+
}).then((S) => {
|
|
9846
|
+
if (d[b] = S, u > 0)
|
|
9847
9847
|
return Xs(
|
|
9848
9848
|
n,
|
|
9849
9849
|
// eslint-disable-next-line security/detect-object-injection
|
|
9850
|
-
d[
|
|
9851
|
-
[...y.Collection_Path,
|
|
9850
|
+
d[b],
|
|
9851
|
+
[...y.Collection_Path, b],
|
|
9852
9852
|
{ depth: u },
|
|
9853
9853
|
r,
|
|
9854
9854
|
i,
|
|
@@ -9856,13 +9856,13 @@ const Tt = {
|
|
|
9856
9856
|
a,
|
|
9857
9857
|
l
|
|
9858
9858
|
);
|
|
9859
|
-
}).catch((
|
|
9860
|
-
if (
|
|
9861
|
-
delete d[
|
|
9859
|
+
}).catch((S) => {
|
|
9860
|
+
if (S.message.includes("NOT_FOUND") || S.code === "permission-denied")
|
|
9861
|
+
delete d[b];
|
|
9862
9862
|
else
|
|
9863
|
-
throw
|
|
9863
|
+
throw S;
|
|
9864
9864
|
});
|
|
9865
|
-
h.push(
|
|
9865
|
+
h.push(_);
|
|
9866
9866
|
}
|
|
9867
9867
|
}
|
|
9868
9868
|
await Promise.all(h);
|
|
@@ -9889,67 +9889,69 @@ const Tt = {
|
|
|
9889
9889
|
if (h.data().active)
|
|
9890
9890
|
throw new Error("MAINTENANCE_MODE");
|
|
9891
9891
|
const m = f;
|
|
9892
|
-
let
|
|
9893
|
-
const y = Ut(),
|
|
9894
|
-
if (!
|
|
9892
|
+
let b;
|
|
9893
|
+
const y = Ut(), _ = n.at(-1);
|
|
9894
|
+
if (!_)
|
|
9895
9895
|
throw new Error("EMPTY_PATH");
|
|
9896
|
-
const
|
|
9897
|
-
if (!
|
|
9896
|
+
const S = Object.keys(m.collections).includes(_), x = y.disabledCollections?.includes(_);
|
|
9897
|
+
if (!S || x)
|
|
9898
9898
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
9899
|
-
const p = m.collections[
|
|
9899
|
+
const p = m.collections[_], { labels: R } = p, A = Je(R.collection, m);
|
|
9900
9900
|
if (t?.user) {
|
|
9901
9901
|
if (!u?.exists)
|
|
9902
9902
|
throw new Error("PERMISSION_DENIED");
|
|
9903
|
-
if (
|
|
9903
|
+
if (b = u.data(), !b.Role)
|
|
9904
9904
|
throw new Error("USER_ERROR");
|
|
9905
|
-
if (!
|
|
9905
|
+
if (!b.Enabled)
|
|
9906
9906
|
throw new Error("PERMISSION_DENIED");
|
|
9907
9907
|
}
|
|
9908
|
-
let v = Vc(s, n, m, t?.user,
|
|
9908
|
+
let v = Vc(s, n, m, t?.user, b);
|
|
9909
9909
|
if (v.length === 0)
|
|
9910
9910
|
return { cursor: {}, pages: 0, docs: [] };
|
|
9911
|
-
if (e && (v = v.map((
|
|
9912
|
-
|
|
9913
|
-
}),
|
|
9911
|
+
if (e && (v = v.map((w) => (e.forEach(([N, T, C]) => {
|
|
9912
|
+
w = w.where(N, T, C);
|
|
9913
|
+
}), w))), o = t?.pagination?.startAfter || t?.pagination?.endBefore || {
|
|
9914
9914
|
first: /* @__PURE__ */ new Map(),
|
|
9915
9915
|
last: /* @__PURE__ */ new Map()
|
|
9916
9916
|
}, t?.pagination) {
|
|
9917
9917
|
if (t.pagination.startAfter && t.pagination.endBefore)
|
|
9918
9918
|
throw new Error("INPUT_ERROR: startAfter and endBefore cannot be provided together");
|
|
9919
|
-
const
|
|
9919
|
+
const w = t.pagination.startAfter || t.pagination.endBefore;
|
|
9920
9920
|
if (t?.user) {
|
|
9921
|
-
const
|
|
9922
|
-
if (
|
|
9923
|
-
throw new Error("INPUT_ERROR: Pagination is not allowed when using " +
|
|
9921
|
+
const N = ta(b.Role, p, m);
|
|
9922
|
+
if (w && N !== !0)
|
|
9923
|
+
throw new Error("INPUT_ERROR: Pagination is not allowed when using " + N);
|
|
9924
9924
|
}
|
|
9925
|
-
t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? v = v.map((
|
|
9925
|
+
t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? v = v.map((N) => N.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).limit(t.pagination.number)) : t.pagination.startAfter ? v = v.map((N, T) => N.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).startAfter(o.last.get(T)).limit(t.pagination.number)) : v = v.map((N, T) => N.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).endBefore(o.first.get(T)).limitToLast(t.pagination.number)) : !t.pagination.startAfter && !t.pagination.endBefore ? v = v.map((N) => N.limit(t.pagination.number)) : t.pagination.startAfter ? v = v.map((N, T) => N.startAfter(o.last.get(T)).limit(t.pagination.number)) : v = v.map((N, T) => N.endBefore(o.first.get(T)).limitToLast(t.pagination.number));
|
|
9926
9926
|
}
|
|
9927
|
-
const
|
|
9928
|
-
await ae("preOperation", y,
|
|
9929
|
-
const k = v.map(async (
|
|
9930
|
-
for (const
|
|
9931
|
-
for (const
|
|
9932
|
-
a.has(
|
|
9933
|
-
const
|
|
9934
|
-
|
|
9935
|
-
const F = { ...
|
|
9936
|
-
delete F.Collection_Path_String, a.set(
|
|
9927
|
+
const j = {};
|
|
9928
|
+
await ae("preOperation", y, A, ["read", void 0, void 0, j]), await ae("preRead", y, A, [j, v, !0, !1]), a = /* @__PURE__ */ new Map();
|
|
9929
|
+
const k = v.map(async (w) => await c.get(w)), E = await Promise.all(k);
|
|
9930
|
+
for (const w of E) {
|
|
9931
|
+
for (const N of w.docs) {
|
|
9932
|
+
a.has(N.id) || a.set(N.id, {});
|
|
9933
|
+
const T = N.data(), C = a.get(N.id);
|
|
9934
|
+
C.id ||= N.id;
|
|
9935
|
+
const F = { ...C, ...T };
|
|
9936
|
+
delete F.Collection_Path_String, a.set(N.id, F);
|
|
9937
9937
|
}
|
|
9938
|
-
o.first.set(
|
|
9938
|
+
o.first.set(E.indexOf(w), w.docs[0]), o.last.set(E.indexOf(w), w.docs.at(-1) || w.docs[0]);
|
|
9939
9939
|
}
|
|
9940
9940
|
if (t?.pagination) {
|
|
9941
|
-
let
|
|
9942
|
-
e && (
|
|
9943
|
-
const
|
|
9944
|
-
i =
|
|
9941
|
+
let w = v[0];
|
|
9942
|
+
e && (w = e.reduce((F, [W, U, J]) => F.where(W, U, J), w)), t.pagination.orderByField && t.pagination.orderByDirection && (w = w.orderBy(t.pagination.orderByField, t.pagination.orderByDirection));
|
|
9943
|
+
const T = (await w.count().get()).data().count, C = t.pagination.number;
|
|
9944
|
+
i = C > 0 ? Math.ceil(T / C) : 0;
|
|
9945
9945
|
}
|
|
9946
|
-
|
|
9947
|
-
|
|
9948
|
-
|
|
9946
|
+
let B;
|
|
9947
|
+
t?.noComputedFields || (B = await ie(A.admin?.retriever));
|
|
9948
|
+
for (const w of a.values()) {
|
|
9949
|
+
const N = [], T = [...w.Collection_Path, w.id];
|
|
9950
|
+
t?.subcollections && N.push(xo(
|
|
9949
9951
|
s,
|
|
9950
9952
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9951
|
-
a.get(
|
|
9952
|
-
|
|
9953
|
+
a.get(w.id),
|
|
9954
|
+
T,
|
|
9953
9955
|
ye(t.subcollections),
|
|
9954
9956
|
m,
|
|
9955
9957
|
ye(t?.relations),
|
|
@@ -9957,51 +9959,53 @@ const Tt = {
|
|
|
9957
9959
|
t.user,
|
|
9958
9960
|
t.transactional ? c : void 0,
|
|
9959
9961
|
t?.noEmbeddingFields
|
|
9960
|
-
)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((
|
|
9961
|
-
if (typeof
|
|
9962
|
-
const
|
|
9963
|
-
if (
|
|
9964
|
-
return
|
|
9965
|
-
throw new Error(`SCHEMA_ERROR: Field ${
|
|
9962
|
+
)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((U) => {
|
|
9963
|
+
if (typeof U == "string") {
|
|
9964
|
+
const J = p.fields.find((O) => O.name === U);
|
|
9965
|
+
if (J)
|
|
9966
|
+
return J;
|
|
9967
|
+
throw new Error(`SCHEMA_ERROR: Field ${U} not found in collection ${_}`);
|
|
9966
9968
|
}
|
|
9967
|
-
return
|
|
9968
|
-
})),
|
|
9969
|
+
return U;
|
|
9970
|
+
})), N.push(Xs(
|
|
9969
9971
|
s,
|
|
9970
9972
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9971
|
-
a.get(
|
|
9972
|
-
|
|
9973
|
+
a.get(w.id),
|
|
9974
|
+
T,
|
|
9973
9975
|
ye(t.relations),
|
|
9974
9976
|
m,
|
|
9975
9977
|
void 0,
|
|
9976
9978
|
t.user,
|
|
9977
9979
|
t.transactional ? c : void 0,
|
|
9978
9980
|
t?.noEmbeddingFields
|
|
9979
|
-
))), await Promise.all(
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9981
|
+
))), await Promise.all(N);
|
|
9982
|
+
const C = [];
|
|
9983
|
+
for (const U of p.fields) {
|
|
9984
|
+
if (U.type === "Computed" && !t?.noComputedFields) {
|
|
9985
|
+
const J = Ie(U, A);
|
|
9986
|
+
if (!J.formula)
|
|
9987
|
+
continue;
|
|
9988
|
+
C.push(ie(J.formula, [w, B]).then((O) => {
|
|
9989
|
+
w[U.name] = O;
|
|
9990
|
+
}));
|
|
9989
9991
|
}
|
|
9990
|
-
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9992
|
+
t?.noEmbeddingFields && U.type === "Embedding" && delete w[U.name];
|
|
9993
|
+
}
|
|
9994
|
+
if (await Promise.all(C), t?.user && b?.Role) {
|
|
9995
|
+
const U = b.Role;
|
|
9996
|
+
if (!(A.custom?.serverAccess?.read !== void 0 ? await ie(A.custom.serverAccess.read, [U, w]) : !0)) {
|
|
9997
|
+
a.delete(w.id);
|
|
9994
9998
|
continue;
|
|
9995
9999
|
}
|
|
9996
|
-
for (const
|
|
9997
|
-
const
|
|
9998
|
-
(!
|
|
10000
|
+
for (const O of p.fields) {
|
|
10001
|
+
const z = !O.access || O.access.includes(U), q = Ie(O, A), re = q?.custom?.serverAccess?.read !== void 0 ? await ie(q.custom.serverAccess.read, [U, w]) : !0;
|
|
10002
|
+
(!z || !re) && (K(O) ? (delete a.get(w.id)[O.name], delete a.get(w.id)[`${O.name}_Array`], delete a.get(w.id)[`${O.name}_Single`]) : delete a.get(w.id)[O.name]);
|
|
9999
10003
|
}
|
|
10000
10004
|
}
|
|
10001
|
-
const
|
|
10002
|
-
await ae("postOperation", y,
|
|
10005
|
+
const F = ["read", w, w.id, j];
|
|
10006
|
+
await ae("postOperation", y, A, F), await ae("postRead", y, A, [j, v, w, !1]);
|
|
10003
10007
|
}
|
|
10004
|
-
t?.user && await Xo(Array.from(a.values()), p, m, t.user,
|
|
10008
|
+
t?.user && await Xo(Array.from(a.values()), p, m, t.user, b);
|
|
10005
10009
|
};
|
|
10006
10010
|
return t?.providedTransaction ? await l(t.providedTransaction) : await r.runTransaction(async (c) => {
|
|
10007
10011
|
await l(c);
|
|
@@ -10038,31 +10042,31 @@ const Tt = {
|
|
|
10038
10042
|
const d = t[f.name];
|
|
10039
10043
|
if (!d)
|
|
10040
10044
|
continue;
|
|
10041
|
-
for (const [m,
|
|
10042
|
-
const y = at(
|
|
10045
|
+
for (const [m, b] of Object.entries(d)) {
|
|
10046
|
+
const y = at(b.Collection_Path, m, {
|
|
10043
10047
|
user: o,
|
|
10044
10048
|
providedTransaction: e,
|
|
10045
10049
|
noComputedFields: a,
|
|
10046
10050
|
noEmbeddingFields: l
|
|
10047
|
-
}).then((
|
|
10048
|
-
if (d[m] =
|
|
10051
|
+
}).then((_) => {
|
|
10052
|
+
if (d[m] = _, u > 0)
|
|
10049
10053
|
return Ao(
|
|
10050
10054
|
n,
|
|
10051
10055
|
e,
|
|
10052
10056
|
// eslint-disable-next-line security/detect-object-injection
|
|
10053
10057
|
d[m],
|
|
10054
|
-
[...
|
|
10058
|
+
[...b.Collection_Path, m],
|
|
10055
10059
|
r,
|
|
10056
10060
|
{ depth: u },
|
|
10057
10061
|
o,
|
|
10058
10062
|
a,
|
|
10059
10063
|
l
|
|
10060
10064
|
);
|
|
10061
|
-
}).catch((
|
|
10062
|
-
if (
|
|
10065
|
+
}).catch((_) => {
|
|
10066
|
+
if (_.message.includes("NOT_FOUND") || _.code === "permission-denied")
|
|
10063
10067
|
delete d[m];
|
|
10064
10068
|
else
|
|
10065
|
-
throw
|
|
10069
|
+
throw _;
|
|
10066
10070
|
});
|
|
10067
10071
|
h.push(y);
|
|
10068
10072
|
}
|
|
@@ -10087,14 +10091,14 @@ const Tt = {
|
|
|
10087
10091
|
throw new Error("MAINTENANCE_MODE");
|
|
10088
10092
|
const f = u;
|
|
10089
10093
|
let d;
|
|
10090
|
-
const m = Ut(),
|
|
10091
|
-
if (!
|
|
10094
|
+
const m = Ut(), b = n.at(-1);
|
|
10095
|
+
if (!b)
|
|
10092
10096
|
throw new Error("EMPTY_PATH");
|
|
10093
|
-
const y = Object.keys(f.collections).includes(
|
|
10094
|
-
if (!y ||
|
|
10097
|
+
const y = Object.keys(f.collections).includes(b), _ = m.disabledCollections?.includes(b);
|
|
10098
|
+
if (!y || _)
|
|
10095
10099
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10096
|
-
const
|
|
10097
|
-
let
|
|
10100
|
+
const S = f.collections[b], { labels: x } = S, p = Je(x.collection, f);
|
|
10101
|
+
let R;
|
|
10098
10102
|
if (t?.user) {
|
|
10099
10103
|
if (!l?.exists)
|
|
10100
10104
|
throw new Error("PERMISSION_DENIED");
|
|
@@ -10102,54 +10106,54 @@ const Tt = {
|
|
|
10102
10106
|
throw new Error("USER_ERROR");
|
|
10103
10107
|
if (!d.Enabled)
|
|
10104
10108
|
throw new Error("PERMISSION_DENIED");
|
|
10105
|
-
if (
|
|
10109
|
+
if (R = d.collections?.[x.collection], !R)
|
|
10106
10110
|
throw new Error("PERMISSION_DENIED");
|
|
10107
10111
|
}
|
|
10108
|
-
if (t?.user && (!
|
|
10112
|
+
if (t?.user && (!R || !Te("Read", R)))
|
|
10109
10113
|
throw new Error("PERMISSION_DENIED");
|
|
10110
|
-
const
|
|
10111
|
-
if (
|
|
10114
|
+
const A = No(s, n, e, f, d);
|
|
10115
|
+
if (A.length === 0)
|
|
10112
10116
|
throw new Error("PERMISSION_DENIED");
|
|
10113
10117
|
const v = {};
|
|
10114
|
-
await ae("preOperation", m, p, ["read", void 0, e, v]), await ae("preRead", m, p, [v,
|
|
10115
|
-
const g =
|
|
10116
|
-
for (const
|
|
10117
|
-
if (
|
|
10118
|
-
const
|
|
10119
|
-
i.id ||=
|
|
10118
|
+
await ae("preOperation", m, p, ["read", void 0, e, v]), await ae("preRead", m, p, [v, A, !1, !1]), i = {};
|
|
10119
|
+
const g = A.map((T) => a.get(T)), k = await Promise.all(g);
|
|
10120
|
+
for (const T of k)
|
|
10121
|
+
if (T.exists) {
|
|
10122
|
+
const C = T.data();
|
|
10123
|
+
i.id ||= T.id, i = { ...i, ...C }, delete i.Collection_Path_String;
|
|
10120
10124
|
} else
|
|
10121
|
-
throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") ||
|
|
10122
|
-
const
|
|
10123
|
-
if (t?.subcollections &&
|
|
10124
|
-
if (typeof
|
|
10125
|
-
const
|
|
10126
|
-
if (
|
|
10127
|
-
return
|
|
10128
|
-
throw new Error(`SCHEMA_ERROR: Field ${
|
|
10125
|
+
throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") || x.collection}`);
|
|
10126
|
+
const E = [], B = n ? [...n, e] : [x.collection, e];
|
|
10127
|
+
if (t?.subcollections && E.push(Do(s, a, i, B, t.subcollections, f, void 0, t.user)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((T) => {
|
|
10128
|
+
if (typeof T == "string") {
|
|
10129
|
+
const C = S.fields.find((F) => F.name === T);
|
|
10130
|
+
if (C)
|
|
10131
|
+
return C;
|
|
10132
|
+
throw new Error(`SCHEMA_ERROR: Field ${T} not found in collection ${b}`);
|
|
10129
10133
|
}
|
|
10130
|
-
return
|
|
10131
|
-
})),
|
|
10132
|
-
for (const
|
|
10133
|
-
if (
|
|
10134
|
-
const
|
|
10135
|
-
if (!
|
|
10134
|
+
return T;
|
|
10135
|
+
})), E.push(Ao(s, a, i, B, f, t.relations, t.user, t.noComputedFields, t.noEmbeddingFields))), await Promise.all(E), !t?.noComputedFields) {
|
|
10136
|
+
for (const T of S.fields)
|
|
10137
|
+
if (T.type === "Computed") {
|
|
10138
|
+
const C = Ie(T, p);
|
|
10139
|
+
if (!C.formula)
|
|
10136
10140
|
continue;
|
|
10137
|
-
i[
|
|
10141
|
+
i[T.name] = await C.formula(i);
|
|
10138
10142
|
}
|
|
10139
10143
|
}
|
|
10140
10144
|
if (t?.noEmbeddingFields)
|
|
10141
|
-
for (const
|
|
10142
|
-
|
|
10145
|
+
for (const T of S.fields)
|
|
10146
|
+
T.type === "Embedding" && delete i[T.name];
|
|
10143
10147
|
if (t?.user && d?.Role) {
|
|
10144
|
-
const
|
|
10145
|
-
if (!(p.custom?.serverAccess?.read !== void 0 ? await ie(p.custom?.serverAccess?.read, [
|
|
10148
|
+
const T = d.Role;
|
|
10149
|
+
if (!(p.custom?.serverAccess?.read !== void 0 ? await ie(p.custom?.serverAccess?.read, [T, i]) : !0))
|
|
10146
10150
|
throw new Error("PERMISSION_DENIED");
|
|
10147
|
-
for (const
|
|
10148
|
-
const
|
|
10149
|
-
(!
|
|
10151
|
+
for (const F of S.fields) {
|
|
10152
|
+
const W = !F.access || F.access.includes(T), U = Ie(F, p), J = U?.custom?.serverAccess?.read !== void 0 ? await ie(U.custom.serverAccess.read, [T, i]) : !0;
|
|
10153
|
+
(!W || !J) && (K(F) ? (delete i[F.name], delete i[`${F.name}_Array`], delete i[`${F.name}_Single`]) : delete i[F.name]);
|
|
10150
10154
|
}
|
|
10151
10155
|
}
|
|
10152
|
-
await ae("postOperation", m, p, ["read", i, e, v]), await ae("postRead", m, p, [v,
|
|
10156
|
+
await ae("postOperation", m, p, ["read", i, e, v]), await ae("postRead", m, p, [v, A, i, !1]), t?.user && await Ko(i, S, f, t.user, d);
|
|
10153
10157
|
};
|
|
10154
10158
|
return t?.providedTransaction ? await o(t.providedTransaction) : await r.runTransaction(async (a) => {
|
|
10155
10159
|
await o(a);
|
|
@@ -10165,8 +10169,8 @@ const Tt = {
|
|
|
10165
10169
|
if (!Ks(m))
|
|
10166
10170
|
f.push(`${d.name} "${s[d.name]}" is invalid`);
|
|
10167
10171
|
else {
|
|
10168
|
-
const
|
|
10169
|
-
|
|
10172
|
+
const b = await l.collection("tenants").doc(e).collection("system_unique").doc(u).collection(`Unique-${u}-${d.name}`).doc(m).get();
|
|
10173
|
+
b.exists && !(n === "update" && b.data().id === t) && f.push(`${d.name} "${s[d.name]}" already exists`);
|
|
10170
10174
|
}
|
|
10171
10175
|
}
|
|
10172
10176
|
})), f.length > 0)
|
|
@@ -10187,13 +10191,13 @@ const Tt = {
|
|
|
10187
10191
|
data: {}
|
|
10188
10192
|
};
|
|
10189
10193
|
if (f) {
|
|
10190
|
-
const
|
|
10191
|
-
d.TTL = lt.fromDate(
|
|
10194
|
+
const _ = /* @__PURE__ */ new Date(), S = new Date((/* @__PURE__ */ new Date()).setDate(_.getDate() + f));
|
|
10195
|
+
d.TTL = lt.fromDate(S);
|
|
10192
10196
|
}
|
|
10193
10197
|
const m = ye(t);
|
|
10194
10198
|
nt(m), n !== "delete" && (d.data.data = ye(m)), n === "update" && (d.data.originalRecord = ye(l)), n !== "delete" && ["started", "written"].includes(e) && (delete d.data.data.Saved_At, delete d.data.data.Last_Save_At), e === "failed" && (d.data.error = JSON.stringify(a));
|
|
10195
|
-
const
|
|
10196
|
-
await
|
|
10199
|
+
const b = De(u, r, s), y = t.Last_Write_At;
|
|
10200
|
+
await b.doc(i).collection("system_write_log").doc(`${t.Last_Write_By}-${y.valueOf()}`).set(d);
|
|
10197
10201
|
}, un = async (n) => {
|
|
10198
10202
|
const e = Ye(), t = gt(), s = ue(), r = [];
|
|
10199
10203
|
if (await Promise.all([
|
|
@@ -10224,19 +10228,19 @@ ${i}`);
|
|
|
10224
10228
|
n = h;
|
|
10225
10229
|
else
|
|
10226
10230
|
throw new Error("Admin email not set");
|
|
10227
|
-
const f = hs(n), d = Pc(e), m = t ? Kr(t) : void 0,
|
|
10231
|
+
const f = hs(n), d = Pc(e), m = t ? Kr(t) : void 0, b = s ? Kr(s) : void 0, y = r ? hs(r) : void 0, _ = i ? hs(i) : void 0, S = o ? Un(o) : void 0, x = l ? Un(l) : void 0, p = Array.isArray(f) ? f : [f];
|
|
10228
10232
|
if (p.length === 0 || p.length === 1 && !p[0])
|
|
10229
10233
|
throw new Error("No valid email addresses provided");
|
|
10230
|
-
const
|
|
10231
|
-
if (m && (
|
|
10232
|
-
const
|
|
10233
|
-
|
|
10234
|
+
const R = { to: f, message: { subject: d } };
|
|
10235
|
+
if (m && (R.message.text = m), b && (R.message.html = b), y) {
|
|
10236
|
+
const A = Array.isArray(y) ? y : [y];
|
|
10237
|
+
A.length > 0 && A[0] && (R.cc = y);
|
|
10234
10238
|
}
|
|
10235
|
-
if (
|
|
10236
|
-
const
|
|
10237
|
-
|
|
10239
|
+
if (_) {
|
|
10240
|
+
const A = Array.isArray(_) ? _ : [_];
|
|
10241
|
+
A.length > 0 && A[0] && (R.bcc = _);
|
|
10238
10242
|
}
|
|
10239
|
-
|
|
10243
|
+
S && (R.replyTo = S), a && (R.message.attachments = a), x && (R.from = x), await c.collection("system_mail").add(R);
|
|
10240
10244
|
}, Mo = async (n, e, t, s, r, i, o) => {
|
|
10241
10245
|
const a = gt(), l = ue(), c = "USER_ERROR", u = async (d, m) => {
|
|
10242
10246
|
try {
|
|
@@ -10292,7 +10296,7 @@ ${i}`);
|
|
|
10292
10296
|
d = d.replace("apiKey=&", `apiKey=${m.apiKey}&`);
|
|
10293
10297
|
}
|
|
10294
10298
|
if (d) {
|
|
10295
|
-
const m = `https://${a.app.options.projectId}.firebaseapp.com/__/auth/action${d}`,
|
|
10299
|
+
const m = `https://${a.app.options.projectId}.firebaseapp.com/__/auth/action${d}`, b = await ie(t.appName), y = t?.mail?.emailVerification && t.mail.emailVerification(m, b);
|
|
10296
10300
|
try {
|
|
10297
10301
|
await $o(r.Email, y?.subject || "Please verify your email address", void 0, y?.html || `Please verify your email address by clicking the link:
|
|
10298
10302
|
</br>
|
|
@@ -10341,7 +10345,7 @@ ${i}`);
|
|
|
10341
10345
|
return t.includeFields.forEach((r) => {
|
|
10342
10346
|
if (e[r] !== void 0) {
|
|
10343
10347
|
s[r] = e[r];
|
|
10344
|
-
const i =
|
|
10348
|
+
const i = V(n.fields, r);
|
|
10345
10349
|
wt(n, [i]).size === 1 && (s[`${r}_Lowercase`] = e[`${r}_Lowercase`]);
|
|
10346
10350
|
}
|
|
10347
10351
|
}), s;
|
|
@@ -10362,8 +10366,8 @@ ${i}`);
|
|
|
10362
10366
|
const d = await r.get(f.doc(u));
|
|
10363
10367
|
if (!d.exists)
|
|
10364
10368
|
throw new Error(`VALIDATION_ERROR: Record ${u} not found in collection ${t.collection}`);
|
|
10365
|
-
const m = d.data(),
|
|
10366
|
-
if (!m[y.recordLinkField] || !s[
|
|
10369
|
+
const m = d.data(), b = V(a, t.enforceHierarchy.field), y = t.enforceHierarchy;
|
|
10370
|
+
if (!m[y.recordLinkField] || !s[b.name] || !Object.keys(s[b.name]).every((_) => Object.keys(m[y.recordLinkField]).includes(_)))
|
|
10367
10371
|
throw new Error("VALIDATION_ERROR: Invalid relation hierarchy");
|
|
10368
10372
|
}, gn = async (n, e, t) => {
|
|
10369
10373
|
delete e[n.name][t], e[`${n.name}_Array`] = e[`${n.name}_Array`]?.filter((s) => s !== t), delete e[`${n.name}_Single`];
|
|
@@ -10375,99 +10379,99 @@ ${i}`);
|
|
|
10375
10379
|
K(l) && l.twoWay && l.collection === t && ((n === "Create" || !i?.[l.name]?.[e]) && r[l.name]?.[e] && o.push(l), n === "Update" && i?.[l.name]?.[e] && !r[l.name]?.[e] && a.push(l));
|
|
10376
10380
|
return { addedFields: o, removedFields: a };
|
|
10377
10381
|
}, Po = async (n, e, t, s, r, i, o, a, l, c, u, h) => {
|
|
10378
|
-
const { fields: f } = i, d = ue(), m = /* @__PURE__ */ new Map(),
|
|
10379
|
-
for (const
|
|
10380
|
-
K(
|
|
10381
|
-
for (const
|
|
10382
|
-
if (K(
|
|
10383
|
-
const
|
|
10384
|
-
if (s[
|
|
10385
|
-
const
|
|
10386
|
-
for (const
|
|
10387
|
-
const [v,
|
|
10388
|
-
if (n === "Create" || !h?.[
|
|
10389
|
-
let
|
|
10390
|
-
const g = y.get(
|
|
10382
|
+
const { fields: f } = i, d = ue(), m = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
|
|
10383
|
+
for (const _ of f)
|
|
10384
|
+
K(_) && ["OneToOne", "OneToMany"].includes(_.type) && _.enforceHierarchy && s[_.name] && (n === "Create" || n === "Update" && !ze(h?.[_.name], s[_.name])) && await ei(e, i, _, s, a, l);
|
|
10385
|
+
for (const _ of f)
|
|
10386
|
+
if (K(_) && _.twoWay) {
|
|
10387
|
+
const S = o.collections[_.collection], x = V(S.fields, _.twoWay), p = ft(S, [x]);
|
|
10388
|
+
if (s[_.name]) {
|
|
10389
|
+
const R = Object.entries(s[_.name]);
|
|
10390
|
+
for (const A of R) {
|
|
10391
|
+
const [v, j] = A;
|
|
10392
|
+
if (n === "Create" || !h?.[_.name]?.[v]) {
|
|
10393
|
+
let I;
|
|
10394
|
+
const g = y.get(_.collection)?.[v];
|
|
10391
10395
|
if (g)
|
|
10392
|
-
|
|
10396
|
+
I = g;
|
|
10393
10397
|
else {
|
|
10394
10398
|
l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
|
|
10395
|
-
const
|
|
10396
|
-
if (!
|
|
10397
|
-
gn(
|
|
10399
|
+
const E = De(d, j.Collection_Path, e), B = await a.get(E.doc(v));
|
|
10400
|
+
if (!B.exists) {
|
|
10401
|
+
gn(_, r, v);
|
|
10398
10402
|
continue;
|
|
10399
10403
|
}
|
|
10400
|
-
const
|
|
10401
|
-
|
|
10402
|
-
...
|
|
10403
|
-
[v]:
|
|
10404
|
-
}),
|
|
10404
|
+
const w = B.data();
|
|
10405
|
+
b.set(_.collection, {
|
|
10406
|
+
...b.get(_.collection) || {},
|
|
10407
|
+
[v]: w
|
|
10408
|
+
}), I = ye({ ...w, ...Sn(s) });
|
|
10405
10409
|
}
|
|
10406
10410
|
const k = {
|
|
10407
|
-
...x
|
|
10411
|
+
...I[x.name],
|
|
10408
10412
|
[t]: {
|
|
10409
10413
|
Collection_Path: s.Collection_Path,
|
|
10410
|
-
...Uc(i, s,
|
|
10414
|
+
...Uc(i, s, x)
|
|
10411
10415
|
}
|
|
10412
10416
|
};
|
|
10413
|
-
x
|
|
10414
|
-
...y.get(
|
|
10415
|
-
[v]:
|
|
10417
|
+
I[x.name] = k, I[`${x.name}_Array`] ||= [], I[`${x.name}_Array`].push(t), p.size === 1 && (I[`${x.name}_Single`] = k), y.set(_.collection, {
|
|
10418
|
+
...y.get(_.collection) || {},
|
|
10419
|
+
[v]: I
|
|
10416
10420
|
});
|
|
10417
10421
|
}
|
|
10418
10422
|
}
|
|
10419
10423
|
}
|
|
10420
10424
|
if (n === "Update") {
|
|
10421
|
-
const
|
|
10422
|
-
for (const
|
|
10423
|
-
const [v,
|
|
10424
|
-
if (!s[
|
|
10425
|
-
let
|
|
10426
|
-
const g = y.get(
|
|
10425
|
+
const R = Object.entries(h?.[_.name] || {});
|
|
10426
|
+
for (const A of R) {
|
|
10427
|
+
const [v, j] = A;
|
|
10428
|
+
if (!s[_.name]?.[v]) {
|
|
10429
|
+
let I;
|
|
10430
|
+
const g = y.get(_.collection)?.[v];
|
|
10427
10431
|
if (g)
|
|
10428
|
-
|
|
10432
|
+
I = g;
|
|
10429
10433
|
else {
|
|
10430
10434
|
l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
|
|
10431
|
-
const k = De(d,
|
|
10432
|
-
if (!
|
|
10433
|
-
m.set(
|
|
10435
|
+
const k = De(d, j.Collection_Path, e), E = await a.get(k.doc(v));
|
|
10436
|
+
if (!E.exists) {
|
|
10437
|
+
m.set(_.name, [...m.get(_.name) || [], v]);
|
|
10434
10438
|
continue;
|
|
10435
10439
|
}
|
|
10436
|
-
const
|
|
10437
|
-
|
|
10438
|
-
...
|
|
10439
|
-
[v]:
|
|
10440
|
-
}),
|
|
10440
|
+
const B = E.data();
|
|
10441
|
+
b.set(_.collection, {
|
|
10442
|
+
...b.get(_.collection) || {},
|
|
10443
|
+
[v]: B
|
|
10444
|
+
}), I = ye({ ...B, ...Sn(s) });
|
|
10441
10445
|
}
|
|
10442
|
-
x
|
|
10443
|
-
...y.get(
|
|
10444
|
-
[v]:
|
|
10446
|
+
I[x.name][t] && delete I[x.name][t], Array.isArray(I[`${x.name}_Array`]) && (I[`${x.name}_Array`] = I[`${x.name}_Array`].filter((k) => k !== t)), p.size === 1 && delete I[`${x.name}_Single`], y.set(_.collection, {
|
|
10447
|
+
...y.get(_.collection) || {},
|
|
10448
|
+
[v]: I
|
|
10445
10449
|
});
|
|
10446
10450
|
}
|
|
10447
10451
|
}
|
|
10448
10452
|
}
|
|
10449
10453
|
}
|
|
10450
|
-
for (const [
|
|
10451
|
-
const
|
|
10452
|
-
for (const [
|
|
10453
|
-
const { addedFields: v, removedFields:
|
|
10454
|
+
for (const [_, S] of y.entries()) {
|
|
10455
|
+
const x = o.collections[_], p = Je(_, o);
|
|
10456
|
+
for (const [R, A] of Object.entries(S)) {
|
|
10457
|
+
const { addedFields: v, removedFields: j } = Wc(n, R, _, i, s, h);
|
|
10454
10458
|
if (c && u) {
|
|
10455
|
-
for (const
|
|
10456
|
-
const g =
|
|
10457
|
-
if (!rr(
|
|
10458
|
-
gn(
|
|
10459
|
+
for (const I of v) {
|
|
10460
|
+
const g = V(x.fields, I.twoWay);
|
|
10461
|
+
if (!rr(x, g, u)) {
|
|
10462
|
+
gn(I, r, R);
|
|
10459
10463
|
continue;
|
|
10460
10464
|
}
|
|
10461
10465
|
}
|
|
10462
|
-
for (const
|
|
10463
|
-
const g =
|
|
10464
|
-
if (!rr(
|
|
10466
|
+
for (const I of j) {
|
|
10467
|
+
const g = V(x.fields, I.twoWay), k = ft(x, [g]);
|
|
10468
|
+
if (!rr(x, g, u)) {
|
|
10465
10469
|
ys(
|
|
10466
|
-
|
|
10470
|
+
I,
|
|
10467
10471
|
r,
|
|
10468
10472
|
// eslint-disable-next-line security/detect-object-injection
|
|
10469
|
-
h?.[
|
|
10470
|
-
|
|
10473
|
+
h?.[I.name]?.[R],
|
|
10474
|
+
R,
|
|
10471
10475
|
k.size === 1
|
|
10472
10476
|
);
|
|
10473
10477
|
continue;
|
|
@@ -10475,51 +10479,51 @@ ${i}`);
|
|
|
10475
10479
|
}
|
|
10476
10480
|
if (!it(
|
|
10477
10481
|
"Update",
|
|
10478
|
-
|
|
10482
|
+
x,
|
|
10479
10483
|
o,
|
|
10480
10484
|
c,
|
|
10481
10485
|
u,
|
|
10482
10486
|
// eslint-disable-next-line security/detect-object-injection
|
|
10483
|
-
|
|
10487
|
+
b.get(_)?.[R]
|
|
10484
10488
|
)) {
|
|
10485
|
-
for (const
|
|
10486
|
-
gn(
|
|
10487
|
-
for (const
|
|
10488
|
-
const g =
|
|
10489
|
+
for (const I of v)
|
|
10490
|
+
gn(I, r, R);
|
|
10491
|
+
for (const I of j) {
|
|
10492
|
+
const g = V(x.fields, I.twoWay), k = ft(x, [g]);
|
|
10489
10493
|
ys(
|
|
10490
|
-
|
|
10494
|
+
I,
|
|
10491
10495
|
r,
|
|
10492
10496
|
// eslint-disable-next-line security/detect-object-injection
|
|
10493
|
-
h?.[
|
|
10494
|
-
|
|
10497
|
+
h?.[I.name]?.[R],
|
|
10498
|
+
R,
|
|
10495
10499
|
k.size === 1
|
|
10496
10500
|
);
|
|
10497
10501
|
}
|
|
10498
10502
|
}
|
|
10499
|
-
if (!it("Update",
|
|
10500
|
-
for (const
|
|
10501
|
-
gn(
|
|
10502
|
-
for (const
|
|
10503
|
-
const g =
|
|
10503
|
+
if (!it("Update", x, o, c, u, A)) {
|
|
10504
|
+
for (const I of v)
|
|
10505
|
+
gn(I, r, R);
|
|
10506
|
+
for (const I of j) {
|
|
10507
|
+
const g = V(x.fields, I.twoWay), k = ft(x, [g]);
|
|
10504
10508
|
ys(
|
|
10505
|
-
|
|
10509
|
+
I,
|
|
10506
10510
|
r,
|
|
10507
10511
|
// eslint-disable-next-line security/detect-object-injection
|
|
10508
|
-
h?.[
|
|
10509
|
-
|
|
10512
|
+
h?.[I.name]?.[R],
|
|
10513
|
+
R,
|
|
10510
10514
|
k.size === 1
|
|
10511
10515
|
);
|
|
10512
10516
|
}
|
|
10513
10517
|
}
|
|
10514
10518
|
}
|
|
10515
10519
|
try {
|
|
10516
|
-
await sn("update",
|
|
10517
|
-
} catch (
|
|
10518
|
-
throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${
|
|
10520
|
+
await sn("update", A, x, p, ["update", A, {}, void 0, A], o);
|
|
10521
|
+
} catch (I) {
|
|
10522
|
+
throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${R} in ${_}: ${I.message}`);
|
|
10519
10523
|
}
|
|
10520
|
-
for (const
|
|
10521
|
-
const g =
|
|
10522
|
-
["OneToOne", "OneToMany"].includes(g.type) && K(g) && g.enforceHierarchy && await ei(e,
|
|
10524
|
+
for (const I of v) {
|
|
10525
|
+
const g = V(x.fields, I.twoWay);
|
|
10526
|
+
["OneToOne", "OneToMany"].includes(g.type) && K(g) && g.enforceHierarchy && await ei(e, x, g, A, a, l, !0);
|
|
10523
10527
|
}
|
|
10524
10528
|
}
|
|
10525
10529
|
}
|
|
@@ -10580,22 +10584,22 @@ ${i}`);
|
|
|
10580
10584
|
if (s.collections?.[a]?.restrictEntities || s?.collections?.[a]?.recordOwner?.active || s?.collections?.[a]?.recordUser?.active || s?.collections?.[a]?.recordProperty?.active) {
|
|
10581
10585
|
const f = i?.collections?.[a], d = [];
|
|
10582
10586
|
if (l.individualEntities) {
|
|
10583
|
-
const m = l.individualEntities,
|
|
10584
|
-
for (const
|
|
10587
|
+
const m = l.individualEntities, b = f?.individualEntities || [], y = i ? m.filter((_) => !b.includes(_)) : m;
|
|
10588
|
+
for (const _ of y) {
|
|
10585
10589
|
if (o && o.size++, o && o.size > 500)
|
|
10586
10590
|
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).");
|
|
10587
10591
|
d.push(async () => {
|
|
10588
|
-
if (!await gs(n, u,
|
|
10592
|
+
if (!await gs(n, u, _, t, s))
|
|
10589
10593
|
throw new Error("PERMISSION_DENIED");
|
|
10590
10594
|
});
|
|
10591
10595
|
}
|
|
10592
10596
|
}
|
|
10593
10597
|
if (l.parentEntities) {
|
|
10594
|
-
const m = c.entityRestrictions?.restrictions?.find((p) => p.type === "Parent" && p.roles.some((
|
|
10598
|
+
const m = c.entityRestrictions?.restrictions?.find((p) => p.type === "Parent" && p.roles.some((R) => R.role === e.Role));
|
|
10595
10599
|
if (!m)
|
|
10596
10600
|
throw new Error("PERMISSION_DENIED");
|
|
10597
|
-
const
|
|
10598
|
-
for (const p of
|
|
10601
|
+
const b = V(u.fields, m.collectionField), y = r.collections[b.collection], _ = l.parentEntities, S = f?.parentEntities || [], x = i ? _.filter((p) => !S.includes(p)) : _;
|
|
10602
|
+
for (const p of x) {
|
|
10599
10603
|
if (o && o.size++, o && o.size > 500)
|
|
10600
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).");
|
|
10601
10605
|
d.push(async () => {
|
|
@@ -10605,13 +10609,13 @@ ${i}`);
|
|
|
10605
10609
|
}
|
|
10606
10610
|
}
|
|
10607
10611
|
if (l.parentPropertyEntities) {
|
|
10608
|
-
const m = c.entityRestrictions?.restrictions?.find((
|
|
10612
|
+
const m = c.entityRestrictions?.restrictions?.find((x) => x.type === "Parent_Property" && x.roles.some((p) => p.role === e.Role));
|
|
10609
10613
|
if (!m)
|
|
10610
10614
|
throw new Error("PERMISSION_DENIED");
|
|
10611
|
-
const
|
|
10612
|
-
for (const [
|
|
10613
|
-
const
|
|
10614
|
-
for (const v of
|
|
10615
|
+
const b = V(u.fields, m.collectionField), y = r.collections[b.collection], _ = l.parentPropertyEntities, S = f?.parentPropertyEntities || {};
|
|
10616
|
+
for (const [x, p] of Object.entries(_)) {
|
|
10617
|
+
const R = S[x] || [], A = i ? p.filter((v) => !R.includes(v)) : p;
|
|
10618
|
+
for (const v of A) {
|
|
10615
10619
|
if (o && o.size++, o && o.size > 500)
|
|
10616
10620
|
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).");
|
|
10617
10621
|
d.push(async () => {
|
|
@@ -10632,92 +10636,94 @@ ${i}`);
|
|
|
10632
10636
|
const u = n.at(-1), h = Object.keys(c.collections).includes(u), f = l.disabledCollections?.includes(u);
|
|
10633
10637
|
if (!h || f)
|
|
10634
10638
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10635
|
-
const d = c.collections[u], { labels: m, fields:
|
|
10636
|
-
let
|
|
10639
|
+
const d = c.collections[u], { labels: m, fields: b, enableWriteLog: y, softDelete: _ } = d, S = Je(m.collection, c), x = await ie(l.appName), p = ue(), R = gt(), v = (s ? await R.getUser(s) : void 0)?.customClaims?.role;
|
|
10640
|
+
let j;
|
|
10637
10641
|
s && await er(n, d);
|
|
10638
|
-
const
|
|
10642
|
+
const I = De(p, n, a), g = o || I.doc().id;
|
|
10639
10643
|
i = i || {}, i.collection = m.collection, e.id = g, Fo(e), tr(e);
|
|
10640
|
-
const k = Ws("create", n, e, c,
|
|
10641
|
-
|
|
10644
|
+
const k = Ws("create", n, e, c, x, "Online", s || "System", lt.now(), me.serverTimestamp());
|
|
10645
|
+
r?.createdAt && (k.Created_At = r.createdAt), r?.createdBy && (k.Created_By = r.createdBy);
|
|
10646
|
+
const E = ye(k);
|
|
10647
|
+
_ && (k[_.archivedField] = !1), Ve(e), y && await Mt("create", "started", k, a, n, g, d), await ae("preOperation", l, S, ["create", k, g, i]), await ae("preWrite", l, S, ["create", k, g, i]), Tn(d, k, c), Rn(d, k), await oa(k, d, S, v), Ve(k);
|
|
10642
10648
|
try {
|
|
10643
10649
|
if (d.auth && t && !t.password)
|
|
10644
10650
|
throw new Error("Password is required");
|
|
10645
|
-
await Co("create", a, g, k, d, c), await sn("create", k, d,
|
|
10646
|
-
} catch (
|
|
10647
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10651
|
+
await Co("create", a, g, k, d, c), await sn("create", k, d, S, ["create", k, i], c);
|
|
10652
|
+
} catch (W) {
|
|
10653
|
+
throw new Error(`VALIDATION_ERROR: ${W.message}`);
|
|
10648
10654
|
}
|
|
10649
|
-
Ve(k), e.id = g,
|
|
10655
|
+
Ve(k), e.id = g, _ && (k[_.archivedField] = !1), Tn(d, k, c), Rn(d, k);
|
|
10650
10656
|
try {
|
|
10651
|
-
Lo("create", k,
|
|
10652
|
-
} catch (
|
|
10653
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10657
|
+
Lo("create", k, E), Vo("create", d, k), await sn("create", k, d, S, ["create", k, i], c);
|
|
10658
|
+
} catch (W) {
|
|
10659
|
+
throw new Error(`VALIDATION_ERROR: ${W.message}`);
|
|
10654
10660
|
}
|
|
10655
10661
|
if (s) {
|
|
10656
|
-
const
|
|
10657
|
-
if (!
|
|
10662
|
+
const W = v;
|
|
10663
|
+
if (!W)
|
|
10658
10664
|
throw new Error("USER_ERROR");
|
|
10659
|
-
if (!(
|
|
10665
|
+
if (!(S.custom?.serverAccess?.create !== void 0 ? await ie(S.custom.serverAccess.create, [W, k]) : !0))
|
|
10660
10666
|
throw new Error("PERMISSION_DENIED");
|
|
10661
|
-
for (const
|
|
10662
|
-
if (!(
|
|
10667
|
+
for (const J of d.fields) {
|
|
10668
|
+
if (!(J.name in k))
|
|
10663
10669
|
continue;
|
|
10664
|
-
const
|
|
10665
|
-
if (
|
|
10670
|
+
const O = Ie(J, S);
|
|
10671
|
+
if (O?.custom?.serverAccess?.create !== void 0 && !await ie(O.custom.serverAccess.create, [W, k]))
|
|
10666
10672
|
throw new Error("PERMISSION_DENIED");
|
|
10667
10673
|
}
|
|
10668
10674
|
}
|
|
10669
10675
|
t && (t.permissions ||= {}, t.permissions.Role ||= k.Role, t.permissions.Enabled ||= k.Enabled);
|
|
10670
|
-
const
|
|
10671
|
-
const [
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
s ?
|
|
10676
|
+
const N = async (W, U) => {
|
|
10677
|
+
const [J, O, z, q] = await Promise.all([
|
|
10678
|
+
W.get(p.collection("system_deployment").doc("latest_deploy")),
|
|
10679
|
+
W.get(p.collection("system_deployment").doc("maintenance_mode")),
|
|
10680
|
+
s ? W.get(p.collection("tenants").doc(a).collection("system_user_permissions").doc(s)) : Promise.resolve(Promise.resolve({})),
|
|
10675
10681
|
Ge()
|
|
10676
10682
|
]);
|
|
10677
|
-
if (
|
|
10683
|
+
if (U && (U.size += 3), !J.exists)
|
|
10678
10684
|
throw new Error("VERSION_ERROR");
|
|
10679
|
-
const re =
|
|
10685
|
+
const re = J.data();
|
|
10680
10686
|
if (re.force && k.Last_Write_At.valueOf() < re.time.valueOf())
|
|
10681
10687
|
throw new Error("VERSION_ERROR");
|
|
10682
|
-
if (!
|
|
10688
|
+
if (!O.exists)
|
|
10683
10689
|
throw new Error("MAINTENANCE_MODE");
|
|
10684
|
-
if (
|
|
10690
|
+
if (O.data().active)
|
|
10685
10691
|
throw new Error("MAINTENANCE_MODE");
|
|
10686
|
-
if (c =
|
|
10687
|
-
if (!
|
|
10692
|
+
if (c = q, s) {
|
|
10693
|
+
if (!z?.exists)
|
|
10688
10694
|
throw new Error("PERMISSION_DENIED");
|
|
10689
|
-
if (
|
|
10695
|
+
if (j = z.data(), !j.Role)
|
|
10690
10696
|
throw new Error("USER_ERROR");
|
|
10691
|
-
if (!
|
|
10697
|
+
if (!j.Enabled)
|
|
10692
10698
|
throw new Error("PERMISSION_DENIED");
|
|
10693
10699
|
}
|
|
10694
|
-
const pe =
|
|
10695
|
-
if (!s || !oe.access || oe.access.includes(
|
|
10700
|
+
const pe = b.filter((oe) => "unique" in oe && oe.unique).map(async (oe) => {
|
|
10701
|
+
if (!s || !oe.access || oe.access.includes(j.Role)) {
|
|
10696
10702
|
if (!e[oe.name])
|
|
10697
10703
|
return;
|
|
10698
|
-
const Le = Ie(oe,
|
|
10704
|
+
const Le = Ie(oe, S);
|
|
10699
10705
|
if (!(s && Le?.custom?.serverAccess?.read !== void 0 ? await ie(Le.custom.serverAccess.read, [
|
|
10700
|
-
|
|
10706
|
+
j?.Role,
|
|
10701
10707
|
k
|
|
10702
10708
|
]) : !0))
|
|
10703
10709
|
throw new Error("PERMISSION_DENIED");
|
|
10704
10710
|
const Jn = e[oe.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
|
|
10705
10711
|
if (Ks(Jn)) {
|
|
10706
|
-
if (
|
|
10712
|
+
if (U && U.size++, U && U.size > 500)
|
|
10707
10713
|
throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks.");
|
|
10708
|
-
if ((await
|
|
10714
|
+
if ((await W.get(p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${oe.name}`).doc(Jn)))?.exists)
|
|
10709
10715
|
throw new Error(`VALIDATION_ERROR: ${oe.name} "${k[oe.name]}" already exists`);
|
|
10710
10716
|
} else
|
|
10711
10717
|
throw new Error(`VALIDATION_ERROR: ${oe.name} "${k[oe.name]}" is invalid`);
|
|
10712
10718
|
}
|
|
10713
10719
|
});
|
|
10714
|
-
await Promise.all(pe), ir(k, g, d, c, s,
|
|
10720
|
+
await Promise.all(pe), ir(k, g, d, c, s, j, t?.permissions), t?.permissions && s && j && await Uo(W, t.permissions, s, j, c), ir(k, g, d, c, s, j, t?.permissions);
|
|
10715
10721
|
};
|
|
10716
10722
|
if (d.auth && t) {
|
|
10717
|
-
await p.runTransaction(async (
|
|
10718
|
-
await
|
|
10723
|
+
await p.runTransaction(async (U) => {
|
|
10724
|
+
await N(U);
|
|
10719
10725
|
}, { maxAttempts: 10 });
|
|
10720
|
-
const
|
|
10726
|
+
const W = await Mo(
|
|
10721
10727
|
a,
|
|
10722
10728
|
g,
|
|
10723
10729
|
l,
|
|
@@ -10727,24 +10733,24 @@ ${i}`);
|
|
|
10727
10733
|
t.permissions,
|
|
10728
10734
|
t.password
|
|
10729
10735
|
);
|
|
10730
|
-
k.User_ID =
|
|
10736
|
+
k.User_ID = W;
|
|
10731
10737
|
}
|
|
10732
10738
|
try {
|
|
10733
|
-
const
|
|
10734
|
-
await p.runTransaction(async (
|
|
10735
|
-
await
|
|
10736
|
-
const
|
|
10737
|
-
Qs("create",
|
|
10739
|
+
const W = { size: 1 };
|
|
10740
|
+
await p.runTransaction(async (U) => {
|
|
10741
|
+
await N(U, W), r?.noTwoWay || await Po("Create", a, g, k, k, d, c, U, W, s, j);
|
|
10742
|
+
const J = Us(c);
|
|
10743
|
+
Qs("create", U, n, g, k, c, d, r, J, me.arrayUnion, me.arrayRemove, me.delete, (O) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${O.name}`).doc(g), (O, z) => p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${O.name}`).doc(z), (O) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${O}`).doc(g), (O, z) => De(p, O, a).doc(z), (O, z, q) => p.collection("tenants").doc(a).collection("system_fields").doc(O.collection).collection(`${O.collection}-${z}`).doc(q), (O, z, q) => p.collection("tenants").doc(a).collection("system_fields").doc(O.collection).collection(`${O.collection}-${z.replaceAll(" ", "-")}`).doc(q), void 0, void 0, W), U.set(I.doc(g), k);
|
|
10738
10744
|
}, { maxAttempts: 10 });
|
|
10739
|
-
} catch (
|
|
10740
|
-
const
|
|
10741
|
-
if (y && (await new Promise((
|
|
10742
|
-
setTimeout(
|
|
10743
|
-
}), await Mt("create",
|
|
10744
|
-
throw d.auth && t && await un(k),
|
|
10745
|
-
}
|
|
10746
|
-
const
|
|
10747
|
-
return await ae("postWrite", l,
|
|
10745
|
+
} catch (W) {
|
|
10746
|
+
const J = await ae("postWriteError", l, S, ["create", k, g, i, W]);
|
|
10747
|
+
if (y && (await new Promise((O) => {
|
|
10748
|
+
setTimeout(O, 250);
|
|
10749
|
+
}), await Mt("create", J?.resolved ? "success" : "failed", k, a, n, g, d, J?.resolved ? void 0 : W)), !J?.resolved)
|
|
10750
|
+
throw d.auth && t && await un(k), W;
|
|
10751
|
+
}
|
|
10752
|
+
const T = ["create", k, g, i], C = [...T];
|
|
10753
|
+
return await ae("postWrite", l, S, T), await ae("postOperation", l, S, C), { id: g, ...k };
|
|
10748
10754
|
}, Qt = async (n, e, t, s) => {
|
|
10749
10755
|
const r = Ye(), i = gt(), o = ue(), a = e.customClaims || {};
|
|
10750
10756
|
let l = !1;
|
|
@@ -10781,14 +10787,14 @@ ${i}`);
|
|
|
10781
10787
|
throw new Error(`ROLLBACK_FAILED: ${s}`);
|
|
10782
10788
|
}, zc = async (n, e, t, s, r, i, o, a, l, c, u) => {
|
|
10783
10789
|
const h = gt(), f = ue(), d = a?.customClaims || {}, m = "USER_ERROR";
|
|
10784
|
-
let
|
|
10790
|
+
let b = "";
|
|
10785
10791
|
if (n === "create") {
|
|
10786
10792
|
if (!u)
|
|
10787
10793
|
throw new Error("VALIDATION_ERROR: Password is required");
|
|
10788
10794
|
if (!l)
|
|
10789
10795
|
throw new Error("VALIDATION_ERROR: Permissions are required");
|
|
10790
10796
|
try {
|
|
10791
|
-
|
|
10797
|
+
b = await Mo(e, t, s, r, i, l, u);
|
|
10792
10798
|
} catch (y) {
|
|
10793
10799
|
throw new Error(y.message);
|
|
10794
10800
|
}
|
|
@@ -10823,22 +10829,22 @@ ${i}`);
|
|
|
10823
10829
|
throw await Qt(o.User_ID, a, c, m), new Error(m);
|
|
10824
10830
|
}
|
|
10825
10831
|
if (o.Email !== i.Email) {
|
|
10826
|
-
const
|
|
10827
|
-
if (
|
|
10828
|
-
let
|
|
10832
|
+
const _ = s.auth.enableMultiFactorAuth;
|
|
10833
|
+
if (_ === !0 || typeof _ == "object" && _.includes(i.Role)) {
|
|
10834
|
+
let S = await h.generateEmailVerificationLink(i.Email).catch(() => {
|
|
10829
10835
|
throw new Error("Error generating email verification link");
|
|
10830
10836
|
});
|
|
10831
|
-
if (
|
|
10832
|
-
const
|
|
10833
|
-
|
|
10837
|
+
if (S.includes("apiKey=&")) {
|
|
10838
|
+
const x = JSON.parse(process.env.STOKER_FB_WEB_APP_CONFIG);
|
|
10839
|
+
S = S.replace("apiKey=&", `apiKey=${x.apiKey}&`);
|
|
10834
10840
|
}
|
|
10835
|
-
if (
|
|
10836
|
-
const
|
|
10841
|
+
if (S) {
|
|
10842
|
+
const x = `https://${h.app.options.projectId}.firebaseapp.com/__/auth/action${S}`, p = await ie(s.appName), R = s?.mail?.emailVerification && s.mail.emailVerification(x, p);
|
|
10837
10843
|
try {
|
|
10838
|
-
await $o(i.Email,
|
|
10844
|
+
await $o(i.Email, R?.subject || "Please verify your email address", void 0, R?.html || `Please verify your email address by clicking the link:
|
|
10839
10845
|
</br>
|
|
10840
10846
|
</br>
|
|
10841
|
-
<a href="${
|
|
10847
|
+
<a href="${x}">${x}</a>`);
|
|
10842
10848
|
} catch {
|
|
10843
10849
|
throw await Qt(o.User_ID, a, c, m), new Error(m);
|
|
10844
10850
|
}
|
|
@@ -10851,8 +10857,8 @@ ${i}`);
|
|
|
10851
10857
|
} catch (y) {
|
|
10852
10858
|
throw new Error(y.message);
|
|
10853
10859
|
}
|
|
10854
|
-
if (
|
|
10855
|
-
return
|
|
10860
|
+
if (b)
|
|
10861
|
+
return b;
|
|
10856
10862
|
}, qc = async (n, e, t) => {
|
|
10857
10863
|
const s = Ye(), r = ue(), i = [e];
|
|
10858
10864
|
t && t.trim() !== "" && i.push(t), i.sort();
|
|
@@ -10882,25 +10888,25 @@ ${i}`);
|
|
|
10882
10888
|
const u = n.at(-1), h = Object.keys(c.collections).includes(u), f = l.disabledCollections?.includes(u);
|
|
10883
10889
|
if (!h || f)
|
|
10884
10890
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10885
|
-
const d = c.collections[u], { labels: m, fields:
|
|
10886
|
-
let
|
|
10891
|
+
const d = c.collections[u], { labels: m, fields: b, enableWriteLog: y } = d, _ = Je(m.collection, c), S = await ie(l.appName), x = gt(), p = ue();
|
|
10892
|
+
let R;
|
|
10887
10893
|
r && await er(n, d);
|
|
10888
|
-
const
|
|
10894
|
+
const A = De(p, n, a);
|
|
10889
10895
|
o = o || {}, o.collection = m.collection;
|
|
10890
10896
|
let v = await at(n, e, {
|
|
10891
10897
|
user: r,
|
|
10892
10898
|
noComputedFields: !0,
|
|
10893
10899
|
noEmbeddingFields: !0
|
|
10894
10900
|
});
|
|
10895
|
-
for (const
|
|
10896
|
-
|
|
10901
|
+
for (const O of b)
|
|
10902
|
+
O.type === "Computed" && delete t[O.name];
|
|
10897
10903
|
if (c = {
|
|
10898
10904
|
...c,
|
|
10899
|
-
collections: Object.fromEntries(Object.entries(c.collections).map(([
|
|
10900
|
-
|
|
10905
|
+
collections: Object.fromEntries(Object.entries(c.collections).map(([O, z]) => [
|
|
10906
|
+
O,
|
|
10901
10907
|
{
|
|
10902
|
-
...
|
|
10903
|
-
fields:
|
|
10908
|
+
...z,
|
|
10909
|
+
fields: z.fields.filter((q) => q.type !== "Computed")
|
|
10904
10910
|
}
|
|
10905
10911
|
]))
|
|
10906
10912
|
}, s && !s.operation)
|
|
@@ -10909,58 +10915,58 @@ ${i}`);
|
|
|
10909
10915
|
throw new Error("VALIDATION_ERROR: User operations are only permitted for auth collections");
|
|
10910
10916
|
if (s?.operation === "delete" && s.permissions)
|
|
10911
10917
|
throw new Error("VALIDATION_ERROR: Permissions are not allowed for delete operations");
|
|
10912
|
-
const
|
|
10918
|
+
const j = d.auth && s?.operation === "create", I = d.auth && s?.operation === "delete", g = d.auth && !j && !I && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), k = (O) => O.User_ID && (d.auth && !j && !I && s?.operation === "update" || t.Role && t.Role !== O.Role || t.Enabled !== void 0 && t.Enabled !== O.Enabled || t.Name && t.Name !== O.Name || t.Email && t.Email !== O.Email || t.Photo_URL && t.Photo_URL !== O.Photo_URL);
|
|
10913
10919
|
delete t.id, Fo(t), tr(t);
|
|
10914
|
-
const
|
|
10915
|
-
for (const
|
|
10916
|
-
!K(
|
|
10917
|
-
Ve(
|
|
10918
|
-
const
|
|
10920
|
+
const E = Ws("update", n, t, c, S, "Online", r || "System", lt.now(), me.serverTimestamp()), B = ye(E);
|
|
10921
|
+
for (const O of b)
|
|
10922
|
+
!K(O) && Me(E[O.name]) && O.nullable && (E[O.name] = null);
|
|
10923
|
+
Ve(E), Ve(v), y && await Mt("update", "started", E, a, n, e, d, void 0, v);
|
|
10924
|
+
const w = [
|
|
10919
10925
|
"update",
|
|
10920
|
-
|
|
10926
|
+
E,
|
|
10921
10927
|
e,
|
|
10922
10928
|
o,
|
|
10923
10929
|
void 0,
|
|
10924
10930
|
ye(v)
|
|
10925
10931
|
];
|
|
10926
|
-
await ae("preOperation", l,
|
|
10927
|
-
const
|
|
10928
|
-
await ae("preWrite", l,
|
|
10932
|
+
await ae("preOperation", l, _, w);
|
|
10933
|
+
const N = ["update", E, e, o, void 0, ye(v)];
|
|
10934
|
+
await ae("preWrite", l, _, N), Tn(d, E, c), Rn(d, E), Ve(E);
|
|
10929
10935
|
try {
|
|
10930
|
-
if (
|
|
10936
|
+
if (j && !s.password)
|
|
10931
10937
|
throw new Error("Password is required");
|
|
10932
|
-
const
|
|
10933
|
-
await Co("update", a, e,
|
|
10934
|
-
} catch (
|
|
10935
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10936
|
-
}
|
|
10937
|
-
Ve(
|
|
10938
|
-
for (const
|
|
10939
|
-
!K(
|
|
10938
|
+
const O = { ...v, ...E };
|
|
10939
|
+
await Co("update", a, e, O, d, c), nt(O), await sn("update", O, d, _, ["update", E, o, void 0, ye(v)], c);
|
|
10940
|
+
} catch (O) {
|
|
10941
|
+
throw new Error(`VALIDATION_ERROR: ${O.message}`);
|
|
10942
|
+
}
|
|
10943
|
+
Ve(E), delete t.id, Tn(d, E, c), Rn(d, E);
|
|
10944
|
+
for (const O of b)
|
|
10945
|
+
!K(O) && Me(E[O.name]) && O.nullable && (E[O.name] = null);
|
|
10940
10946
|
try {
|
|
10941
|
-
const
|
|
10942
|
-
nt(
|
|
10943
|
-
} catch (
|
|
10944
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10947
|
+
const O = { ...v, ...E };
|
|
10948
|
+
nt(O), Vo("update", d, E, v), Lo("update", E, B), await sn("update", O, d, _, ["update", E, o, void 0, v], c);
|
|
10949
|
+
} catch (O) {
|
|
10950
|
+
throw new Error(`VALIDATION_ERROR: ${O.message}`);
|
|
10945
10951
|
}
|
|
10946
|
-
let
|
|
10952
|
+
let T;
|
|
10947
10953
|
s && (s.permissions ||= {});
|
|
10948
|
-
const
|
|
10954
|
+
const C = async (O, z, q) => {
|
|
10949
10955
|
const [re, Qe, Wt, pe, oe] = await Promise.all([
|
|
10950
|
-
|
|
10951
|
-
|
|
10956
|
+
O.get(p.collection("system_deployment").doc("latest_deploy")),
|
|
10957
|
+
O.get(p.collection("system_deployment").doc("maintenance_mode")),
|
|
10952
10958
|
at(n, e, {
|
|
10953
10959
|
user: r,
|
|
10954
|
-
providedTransaction:
|
|
10960
|
+
providedTransaction: O,
|
|
10955
10961
|
noComputedFields: !0
|
|
10956
10962
|
}),
|
|
10957
|
-
r ?
|
|
10963
|
+
r ? O.get(p.collection("tenants").doc(a).collection("system_user_permissions").doc(r)) : Promise.resolve(Promise.resolve({})),
|
|
10958
10964
|
Ge()
|
|
10959
10965
|
]);
|
|
10960
|
-
if (
|
|
10966
|
+
if (q && (q.size += 3), !re.exists)
|
|
10961
10967
|
throw new Error("VERSION_ERROR");
|
|
10962
10968
|
const Le = re.data();
|
|
10963
|
-
if (Le.force &&
|
|
10969
|
+
if (Le.force && E.Last_Write_At.valueOf() < Le.time.valueOf())
|
|
10964
10970
|
throw new Error("VERSION_ERROR");
|
|
10965
10971
|
if (!Qe.exists)
|
|
10966
10972
|
throw new Error("MAINTENANCE_MODE");
|
|
@@ -10971,52 +10977,52 @@ ${i}`);
|
|
|
10971
10977
|
if (v = Wt, c = oe, r) {
|
|
10972
10978
|
if (!pe?.exists)
|
|
10973
10979
|
throw new Error("PERMISSION_DENIED");
|
|
10974
|
-
if (
|
|
10980
|
+
if (R = pe.data(), !R.Role)
|
|
10975
10981
|
throw new Error("USER_ERROR");
|
|
10976
|
-
if (!
|
|
10982
|
+
if (!R.Enabled)
|
|
10977
10983
|
throw new Error("PERMISSION_DENIED");
|
|
10978
10984
|
}
|
|
10979
|
-
if (
|
|
10985
|
+
if (q && (q.size += No(a, n, e, c, R).length), j && v.User_ID || I && !v.User_ID)
|
|
10980
10986
|
throw new Error("USER_ERROR");
|
|
10981
10987
|
if (k(v)) {
|
|
10982
|
-
const de = await
|
|
10983
|
-
if (
|
|
10988
|
+
const de = await O.get(p.collection("tenants").doc(a).collection("system_user_permissions").doc(v.User_ID));
|
|
10989
|
+
if (q && q.size++, !de?.exists)
|
|
10984
10990
|
throw new Error("PERMISSION_DENIED");
|
|
10985
|
-
if (
|
|
10986
|
-
if (s.permissions.Role ||=
|
|
10991
|
+
if (T = de.data(), s?.permissions) {
|
|
10992
|
+
if (s.permissions.Role ||= E.Role || v.Role, s.permissions.Enabled ??= E.Enabled ?? v.Enabled, Me(s.permissions.Role))
|
|
10987
10993
|
throw new Error("VALIDATION_ERROR: Role field is required");
|
|
10988
10994
|
if (Me(s.permissions.Enabled))
|
|
10989
10995
|
throw new Error("VALIDATION_ERROR: Enabled field is required");
|
|
10990
10996
|
}
|
|
10991
10997
|
}
|
|
10992
|
-
const nr =
|
|
10993
|
-
if (!r || !de.access || de.access.includes(
|
|
10994
|
-
if (
|
|
10998
|
+
const nr = b.filter((de) => "unique" in de && de.unique).map(async (de) => {
|
|
10999
|
+
if (!r || !de.access || de.access.includes(R.Role)) {
|
|
11000
|
+
if (E[de.name] === void 0 || Me(E[de.name]))
|
|
10995
11001
|
return;
|
|
10996
|
-
const jt = Ie(de,
|
|
11002
|
+
const jt = Ie(de, _), sr = { ...v, ...E };
|
|
10997
11003
|
if (!(r && jt?.custom?.serverAccess?.read !== void 0 ? await ie(jt.custom.serverAccess.read, [
|
|
10998
|
-
|
|
11004
|
+
R?.Role,
|
|
10999
11005
|
sr
|
|
11000
11006
|
]) : !0))
|
|
11001
11007
|
throw new Error("PERMISSION_DENIED");
|
|
11002
|
-
const Zt =
|
|
11008
|
+
const Zt = E[de.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
|
|
11003
11009
|
if (Ks(Zt)) {
|
|
11004
|
-
if (
|
|
11010
|
+
if (q && q.size++, q && q.size > 500)
|
|
11005
11011
|
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.");
|
|
11006
|
-
const Kn = await
|
|
11012
|
+
const Kn = await O.get(p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${de.name}`).doc(Zt));
|
|
11007
11013
|
if (Kn.exists && Kn.data().id !== e)
|
|
11008
|
-
throw new Error(`VALIDATION_ERROR: ${de.name} "${
|
|
11014
|
+
throw new Error(`VALIDATION_ERROR: ${de.name} "${E[de.name]}" already exists`);
|
|
11009
11015
|
} else
|
|
11010
|
-
throw new Error(`VALIDATION_ERROR: ${de.name} "${
|
|
11016
|
+
throw new Error(`VALIDATION_ERROR: ${de.name} "${E[de.name]}" is invalid`);
|
|
11011
11017
|
}
|
|
11012
11018
|
});
|
|
11013
|
-
if (await Promise.all(nr), r &&
|
|
11014
|
-
const de =
|
|
11015
|
-
if (!(
|
|
11019
|
+
if (await Promise.all(nr), r && R?.Role) {
|
|
11020
|
+
const de = R.Role, jt = { ...v, ...E };
|
|
11021
|
+
if (!(_.custom?.serverAccess?.update !== void 0 ? await ie(_.custom.serverAccess.update, [de, jt, v]) : !0))
|
|
11016
11022
|
throw new Error("PERMISSION_DENIED");
|
|
11017
11023
|
for (const Qn of d.fields) {
|
|
11018
|
-
const Zt = Ie(Qn,
|
|
11019
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
11024
|
+
const Zt = Ie(Qn, _);
|
|
11025
|
+
if (Object.prototype.hasOwnProperty.call(E, Qn.name) && Zt?.custom?.serverAccess?.update !== void 0 && !await ie(Zt.custom.serverAccess.update, [
|
|
11020
11026
|
de,
|
|
11021
11027
|
jt,
|
|
11022
11028
|
v
|
|
@@ -11024,63 +11030,63 @@ ${i}`);
|
|
|
11024
11030
|
throw new Error("PERMISSION_DENIED");
|
|
11025
11031
|
}
|
|
11026
11032
|
}
|
|
11027
|
-
or(
|
|
11033
|
+
or(E, v, e, d, c, r, R, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, T), s?.permissions && r && R && await Uo(O, s.permissions, r, R, c, T, q), or(E, v, e, d, c, r, R, s?.operation ? s.operation : g ? "update" : void 0, s?.permissions, T), z && (j || k(v) || I) && await qc(O, e, v.User_ID);
|
|
11028
11034
|
};
|
|
11029
|
-
(
|
|
11030
|
-
await
|
|
11035
|
+
(j || g || I) && await p.runTransaction(async (O) => {
|
|
11036
|
+
await C(O, !0);
|
|
11031
11037
|
}, { maxAttempts: 10 });
|
|
11032
11038
|
try {
|
|
11033
|
-
let
|
|
11034
|
-
if (
|
|
11039
|
+
let O;
|
|
11040
|
+
if (j || k(v) || I) {
|
|
11035
11041
|
if (k(v)) {
|
|
11036
|
-
|
|
11037
|
-
const re =
|
|
11042
|
+
O = await x.getUser(v.User_ID);
|
|
11043
|
+
const re = O.customClaims;
|
|
11038
11044
|
if (!(re && re.role && re.collection && re.doc))
|
|
11039
11045
|
throw new Error("USER_ERROR");
|
|
11040
11046
|
}
|
|
11041
|
-
const
|
|
11042
|
-
nt(
|
|
11043
|
-
const
|
|
11044
|
-
|
|
11047
|
+
const z = { ...v, ...E };
|
|
11048
|
+
nt(z);
|
|
11049
|
+
const q = await zc(s?.operation || "update", a, e, l, m.collection, z, v, O, s?.permissions, T, s?.password);
|
|
11050
|
+
j && (E.User_ID = q), I && (E.User_ID = me.delete());
|
|
11045
11051
|
}
|
|
11046
11052
|
try {
|
|
11047
|
-
const
|
|
11048
|
-
await p.runTransaction(async (
|
|
11049
|
-
const re = { ...v, ...
|
|
11050
|
-
await
|
|
11053
|
+
const z = { size: 1 };
|
|
11054
|
+
await p.runTransaction(async (q) => {
|
|
11055
|
+
const re = { ...v, ...E };
|
|
11056
|
+
await C(q, !1, z);
|
|
11051
11057
|
let Qe;
|
|
11052
|
-
i?.noTwoWay || (Qe = await Po("Update", a, e, re,
|
|
11058
|
+
i?.noTwoWay || (Qe = await Po("Update", a, e, re, E, d, c, q, z, r, R, v));
|
|
11053
11059
|
const Wt = Us(c);
|
|
11054
|
-
Qs("update",
|
|
11060
|
+
Qs("update", q, n, e, E, c, d, i, Wt, me.arrayUnion, me.arrayRemove, me.delete, (pe) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${pe.name}`).doc(e), (pe, oe) => p.collection("tenants").doc(a).collection("system_unique").doc(m.collection).collection(`Unique-${m.collection}-${pe.name}`).doc(oe), (pe) => p.collection("tenants").doc(a).collection("system_fields").doc(m.collection).collection(`${m.collection}-${pe}`).doc(e), (pe, oe) => De(p, pe, a).doc(oe), (pe, oe, Le) => p.collection("tenants").doc(a).collection("system_fields").doc(pe.collection).collection(`${pe.collection}-${oe}`).doc(Le), (pe, oe, Le) => p.collection("tenants").doc(a).collection("system_fields").doc(pe.collection).collection(`${pe.collection}-${oe.replaceAll(" ", "-")}`).doc(Le), v, Qe, z), q.update(A.doc(e), E);
|
|
11055
11061
|
}, { maxAttempts: 10 });
|
|
11056
|
-
} catch (
|
|
11057
|
-
const
|
|
11062
|
+
} catch (z) {
|
|
11063
|
+
const q = [
|
|
11058
11064
|
"update",
|
|
11059
|
-
|
|
11065
|
+
E,
|
|
11060
11066
|
e,
|
|
11061
11067
|
o,
|
|
11062
|
-
|
|
11068
|
+
z,
|
|
11063
11069
|
void 0,
|
|
11064
11070
|
void 0,
|
|
11065
11071
|
ye(v)
|
|
11066
|
-
], re = await ae("postWriteError", l,
|
|
11072
|
+
], re = await ae("postWriteError", l, _, q);
|
|
11067
11073
|
if (y && (await new Promise((Qe) => {
|
|
11068
11074
|
setTimeout(Qe, 250);
|
|
11069
|
-
}), await Mt("update", re?.resolved ? "success" : "failed",
|
|
11070
|
-
throw
|
|
11075
|
+
}), await Mt("update", re?.resolved ? "success" : "failed", E, a, n, e, d, re?.resolved ? void 0 : z, v)), !re?.resolved)
|
|
11076
|
+
throw j && await un(v), k(v) && await Qt(v.User_ID, O, T, "USER_ERROR"), I && await p.collection("tenants").doc(a).collection(m.collection).doc(e).update({ User_ID: me.delete() }), z;
|
|
11071
11077
|
}
|
|
11072
|
-
(
|
|
11078
|
+
(j || k(v) || I) && await Qr(ti, [e, v.User_ID]).catch(() => {
|
|
11073
11079
|
throw new Error("USER_ERROR");
|
|
11074
11080
|
});
|
|
11075
|
-
} catch (
|
|
11076
|
-
throw (
|
|
11081
|
+
} catch (O) {
|
|
11082
|
+
throw (j || k(v) || I) && await Qr(ti, [e, v.User_ID]).catch(() => {
|
|
11077
11083
|
throw new Error("USER_ERROR");
|
|
11078
|
-
}),
|
|
11084
|
+
}), O;
|
|
11079
11085
|
}
|
|
11080
|
-
const
|
|
11081
|
-
await ae("postWrite", l,
|
|
11082
|
-
const
|
|
11083
|
-
return nt(
|
|
11086
|
+
const F = ["update", E, e, o, void 0, ye(v)], W = [...F];
|
|
11087
|
+
await ae("postWrite", l, _, F), await ae("postOperation", l, _, W);
|
|
11088
|
+
const U = { ...v, ...E };
|
|
11089
|
+
return nt(U), { id: e, ...U };
|
|
11084
11090
|
}, gu = async (n, e, t, s, r) => {
|
|
11085
11091
|
const i = Ye(), o = Ut();
|
|
11086
11092
|
let a = await Ge();
|
|
@@ -11089,64 +11095,64 @@ ${i}`);
|
|
|
11089
11095
|
const l = n.at(-1), c = Object.keys(a.collections).includes(l), u = o.disabledCollections?.includes(l);
|
|
11090
11096
|
if (!c || u)
|
|
11091
11097
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
11092
|
-
const h = a.collections[l], { labels: f, auth: d, enableWriteLog: m, softDelete:
|
|
11093
|
-
if (
|
|
11094
|
-
return await Bc(n, e, { [
|
|
11095
|
-
const
|
|
11096
|
-
let
|
|
11098
|
+
const h = a.collections[l], { labels: f, auth: d, enableWriteLog: m, softDelete: b } = h, y = Je(f.collection, a), _ = await ie(o.appName);
|
|
11099
|
+
if (b && !d && !s?.force)
|
|
11100
|
+
return await Bc(n, e, { [b.archivedField]: !0, [b.timestampField]: me.serverTimestamp() }, void 0, t);
|
|
11101
|
+
const S = ue();
|
|
11102
|
+
let x;
|
|
11097
11103
|
t && await er(n, h);
|
|
11098
|
-
const p = De(
|
|
11104
|
+
const p = De(S, n, i);
|
|
11099
11105
|
r = r || {}, r.collection = f.collection;
|
|
11100
|
-
const
|
|
11101
|
-
let
|
|
11102
|
-
const v = Sn(
|
|
11103
|
-
Ve(
|
|
11104
|
-
const g = async (
|
|
11105
|
-
const [
|
|
11106
|
-
|
|
11107
|
-
at([f.collection], e, { user: t, providedTransaction:
|
|
11108
|
-
t ?
|
|
11106
|
+
const R = await at(n, e, { user: t });
|
|
11107
|
+
let A = Ws("delete", n, R, a, _, "Online", t || "System", lt.now(), me.serverTimestamp());
|
|
11108
|
+
const v = Sn(A);
|
|
11109
|
+
Ve(A), m && await Mt("delete", "started", A, i, n, e, h), await ae("preOperation", o, y, ["delete", A, e, r]), await ae("preWrite", o, y, ["delete", A, e, r]), Ve(A);
|
|
11110
|
+
const g = async (w) => {
|
|
11111
|
+
const [N, T, C, F] = await Promise.all([
|
|
11112
|
+
w.get(S.collection("system_deployment").doc("maintenance_mode")),
|
|
11113
|
+
at([f.collection], e, { user: t, providedTransaction: w }),
|
|
11114
|
+
t ? w.get(S.collection("tenants").doc(i).collection("system_user_permissions").doc(t)) : Promise.resolve(Promise.resolve({})),
|
|
11109
11115
|
Ge()
|
|
11110
11116
|
]);
|
|
11111
|
-
if (!
|
|
11117
|
+
if (!N.exists)
|
|
11112
11118
|
throw new Error("MAINTENANCE_MODE");
|
|
11113
|
-
if (
|
|
11119
|
+
if (N.data().active)
|
|
11114
11120
|
throw new Error("MAINTENANCE_MODE");
|
|
11115
|
-
if (!
|
|
11121
|
+
if (!T)
|
|
11116
11122
|
throw new Error("NOT_FOUND");
|
|
11117
|
-
if (
|
|
11118
|
-
if (!
|
|
11123
|
+
if (A = { ...T, ...v }, a = F, t) {
|
|
11124
|
+
if (!C?.exists)
|
|
11119
11125
|
throw new Error("PERMISSION_DENIED");
|
|
11120
|
-
if (
|
|
11126
|
+
if (x = C.data(), !x.Role)
|
|
11121
11127
|
throw new Error("USER_ERROR");
|
|
11122
|
-
if (!
|
|
11128
|
+
if (!x.Enabled)
|
|
11123
11129
|
throw new Error("PERMISSION_DENIED");
|
|
11124
|
-
Qo(
|
|
11130
|
+
Qo(A, e, h, a, t, x);
|
|
11125
11131
|
}
|
|
11126
|
-
if (t &&
|
|
11127
|
-
const
|
|
11128
|
-
if (!(y.custom?.serverAccess?.delete !== void 0 ? await ie(y.custom.serverAccess.delete, [
|
|
11132
|
+
if (t && x?.Role) {
|
|
11133
|
+
const U = x.Role;
|
|
11134
|
+
if (!(y.custom?.serverAccess?.delete !== void 0 ? await ie(y.custom.serverAccess.delete, [U, A]) : !0))
|
|
11129
11135
|
throw new Error("PERMISSION_DENIED");
|
|
11130
11136
|
}
|
|
11131
11137
|
};
|
|
11132
|
-
h.auth && (await
|
|
11133
|
-
await g(
|
|
11134
|
-
}, { maxAttempts: 10 }),
|
|
11138
|
+
h.auth && (await S.runTransaction(async (w) => {
|
|
11139
|
+
await g(w);
|
|
11140
|
+
}, { maxAttempts: 10 }), A.User_ID && await un(A));
|
|
11135
11141
|
try {
|
|
11136
|
-
await
|
|
11137
|
-
await g(
|
|
11138
|
-
const
|
|
11139
|
-
Qs("delete",
|
|
11142
|
+
await S.runTransaction(async (w) => {
|
|
11143
|
+
await g(w);
|
|
11144
|
+
const N = Us(a);
|
|
11145
|
+
Qs("delete", w, n, e, A, a, h, s, N, me.arrayUnion, me.arrayRemove, me.delete, (T) => S.collection("tenants").doc(i).collection("system_fields").doc(f.collection).collection(`${f.collection}-${T.name}`).doc(e), (T, C) => S.collection("tenants").doc(i).collection("system_unique").doc(f.collection).collection(`Unique-${f.collection}-${T.name}`).doc(C), (T) => S.collection("tenants").doc(i).collection("system_fields").doc(f.collection).collection(`${f.collection}-${T}`).doc(e), (T, C) => De(S, T, i).doc(C), (T, C, F) => S.collection("tenants").doc(i).collection("system_fields").doc(T.collection).collection(`${T.collection}-${C}`).doc(F), (T, C, F) => S.collection("tenants").doc(i).collection("system_fields").doc(T.collection).collection(`${T.collection}-${C.replaceAll(" ", "-")}`).doc(F)), w.delete(p.doc(e));
|
|
11140
11146
|
}, { maxAttempts: 10 });
|
|
11141
|
-
} catch (
|
|
11142
|
-
const
|
|
11143
|
-
if (m && (await new Promise((
|
|
11144
|
-
setTimeout(
|
|
11145
|
-
}), await Mt("delete",
|
|
11146
|
-
throw h.auth &&
|
|
11147
|
-
}
|
|
11148
|
-
const k = ["delete",
|
|
11149
|
-
return await ae("postWrite", o, y, k), await ae("postOperation", o, y,
|
|
11147
|
+
} catch (w) {
|
|
11148
|
+
const T = await ae("postWriteError", o, y, ["delete", A, e, r, w]);
|
|
11149
|
+
if (m && (await new Promise((C) => {
|
|
11150
|
+
setTimeout(C, 250);
|
|
11151
|
+
}), await Mt("delete", T?.resolved ? "success" : "failed", A, i, n, e, h, T?.resolved ? void 0 : w)), !T?.resolved)
|
|
11152
|
+
throw h.auth && A.User_ID && await S.collection("tenants").doc(i).collection(f.collection).doc(e).update({ User_ID: me.delete() }), w;
|
|
11153
|
+
}
|
|
11154
|
+
const k = ["delete", A, e, r], E = [...k];
|
|
11155
|
+
return await ae("postWrite", o, y, k), await ae("postOperation", o, y, E), { id: e, ...A };
|
|
11150
11156
|
}, wu = async (n, e) => {
|
|
11151
11157
|
const t = ue(), s = To(), r = process.env.ADMIN_SMS;
|
|
11152
11158
|
if (s === "development")
|
|
@@ -11168,16 +11174,16 @@ ${i}`);
|
|
|
11168
11174
|
e(n);
|
|
11169
11175
|
}, Eu = async (n) => await gt().getUser(n), vu = (n) => {
|
|
11170
11176
|
const e = Ro();
|
|
11171
|
-
return
|
|
11177
|
+
return P.fromJSDate(n).setZone(e);
|
|
11172
11178
|
}, Gc = (n) => {
|
|
11173
11179
|
const e = Ro();
|
|
11174
|
-
return
|
|
11180
|
+
return P.fromJSDate(n.toDate()).setZone(e);
|
|
11175
11181
|
}, Ou = (n, e) => {
|
|
11176
|
-
const s =
|
|
11177
|
-
return
|
|
11182
|
+
const s = P.fromJSDate(n, { zone: e }).offset, i = P.fromJSDate(n).offset, o = s - i;
|
|
11183
|
+
return P.fromJSDate(n).plus({ minutes: o }).toJSDate();
|
|
11178
11184
|
}, ku = (n, e) => {
|
|
11179
|
-
const s =
|
|
11180
|
-
return
|
|
11185
|
+
const s = P.fromJSDate(n, { zone: e }).offset, i = P.fromJSDate(n).offset, o = s - i;
|
|
11186
|
+
return P.fromJSDate(n).minus({ minutes: o }).toJSDate();
|
|
11181
11187
|
}, bu = (n) => "seconds" in n && "nanoseconds" in n ? Gc(new lt(n.seconds, n.nanoseconds)).toFormat("MMMM d, yyyy '@' h:mm a") : "";
|
|
11182
11188
|
export {
|
|
11183
11189
|
yu as addRecord,
|