@stoker-platform/node-client 0.5.16 → 0.5.17
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 +623 -623
- package/package.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -15,7 +15,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
15
15
|
const { labels: s } = n;
|
|
16
16
|
return t.collections && // eslint-disable-next-line security/detect-object-injection
|
|
17
17
|
Re("Update", t.collections[s.collection]) && (!e.access || Zn(e, t)) && ri(e, t) && !(n.auth && !t.collections?.[s.collection].auth && ["Enabled", "Role", "Name", "Email", "Photo_URL"].includes(e.name));
|
|
18
|
-
},
|
|
18
|
+
}, W = (n, e) => n.filter((t) => t.name === e)[0], K = (n) => ["OneToOne", "OneToMany", "ManyToOne", "ManyToMany"].includes(n.type), ii = (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, Re = (n, e) => {
|
|
|
39
39
|
return i?.parentFilters?.forEach((a) => {
|
|
40
40
|
if (!a.roles.some((f) => f.role === t.Role))
|
|
41
41
|
return;
|
|
42
|
-
const o = a.collectionField, l =
|
|
42
|
+
const o = a.collectionField, l = W(n.fields, o);
|
|
43
43
|
if (!K(l))
|
|
44
44
|
throw new Error("PERMISSION_DENIED");
|
|
45
45
|
const c = t.collections?.[l.collection], m = e.collections[l.collection].access.entityRestrictions;
|
|
@@ -62,92 +62,92 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
62
62
|
!i.find((m) => m.field === c.field) && c.roles.includes(t.Role) && i.push(c);
|
|
63
63
|
}
|
|
64
64
|
return i;
|
|
65
|
-
}, Zo = (n, e, t, s, r, i) => {
|
|
66
|
-
const { fields:
|
|
67
|
-
let
|
|
68
|
-
if (!
|
|
69
|
-
|
|
65
|
+
}, Zo = (n, e, t, s, r, i, a) => {
|
|
66
|
+
const { fields: o } = e, l = r.collections?.[e.labels.collection];
|
|
67
|
+
let c = !0;
|
|
68
|
+
if (!l) {
|
|
69
|
+
c = !1;
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
"operations" in
|
|
75
|
-
}),
|
|
76
|
-
if ("operations" in
|
|
72
|
+
const u = ii(e, r), m = Fs(e, r), d = oi(e, t, r);
|
|
73
|
+
u?.filter((_) => _.type === "Record_Owner").forEach((_) => {
|
|
74
|
+
"operations" in _ && _.operations && !_.operations.includes(n) || i.Created_By !== s && (c = !1);
|
|
75
|
+
}), u?.filter((_) => _.type === "Record_User").forEach((_) => {
|
|
76
|
+
if ("operations" in _ && _.operations && !_.operations.includes(n))
|
|
77
77
|
return;
|
|
78
|
-
const
|
|
79
|
-
i[`${
|
|
80
|
-
}),
|
|
81
|
-
if ("operations" in
|
|
78
|
+
const N = W(o, _.collectionField);
|
|
79
|
+
i[`${N.name}_Array`]?.includes(r.Doc_ID) || (c = !1);
|
|
80
|
+
}), u?.filter((_) => _.type === "Record_Property").forEach((_) => {
|
|
81
|
+
if ("operations" in _ && _.operations && !_.operations.includes(n))
|
|
82
82
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const N = W(o, _.propertyField), C = _.roles.find((L) => L.role === r.Role);
|
|
84
|
+
N.type === "Array" ? C.values?.some((L) => i[N.name].includes(L)) || (c = !1) : C.values?.includes(i[N.name]) || (c = !1);
|
|
85
85
|
});
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
let f = !0, h = !1;
|
|
87
|
+
m?.filter((_) => _.type === "Individual").forEach(() => {
|
|
88
|
+
h = !0, l?.individualEntities?.includes(i.id) || (f = !1);
|
|
89
89
|
});
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
Object.entries(
|
|
99
|
-
const [
|
|
100
|
-
return
|
|
101
|
-
}) || (
|
|
102
|
-
}),
|
|
103
|
-
if (!(
|
|
104
|
-
|
|
90
|
+
let v = !0, p = !1;
|
|
91
|
+
if (m?.filter((_) => _.type === "Parent").forEach((_) => {
|
|
92
|
+
p = !0;
|
|
93
|
+
const N = W(o, _.collectionField);
|
|
94
|
+
l?.parentEntities?.some((C) => i[`${N.name}_Array`].includes(C)) || (v = !1);
|
|
95
|
+
}), m?.filter((_) => _.type === "Parent_Property").forEach((_) => {
|
|
96
|
+
p = !0;
|
|
97
|
+
const N = W(o, _.collectionField), C = W(o, _.propertyField);
|
|
98
|
+
Object.entries(l?.parentPropertyEntities || {}).some((L) => {
|
|
99
|
+
const [I, y] = L;
|
|
100
|
+
return I === i[C.name] && i[`${N.name}_Array`].some((k) => y.includes(k));
|
|
101
|
+
}) || (v = !1);
|
|
102
|
+
}), h && p) {
|
|
103
|
+
if (!(f || v)) {
|
|
104
|
+
c = !1;
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
} else if (!
|
|
108
|
-
|
|
107
|
+
} else if (!f || !v) {
|
|
108
|
+
c = !1;
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const { parentFilter:
|
|
115
|
-
if (!
|
|
116
|
-
|
|
111
|
+
let E = !0, O = !1;
|
|
112
|
+
d?.filter((_) => _.parentFilter.type === "Individual").forEach((_) => {
|
|
113
|
+
O = !0;
|
|
114
|
+
const { parentFilter: N } = _, C = W(o, N.collectionField), L = r.collections?.[C.collection];
|
|
115
|
+
if (!L) {
|
|
116
|
+
c = !1;
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
L.individualEntities?.some((I) => i[`${C.name}_Array`].includes(I)) || (E = !1);
|
|
120
120
|
});
|
|
121
|
-
let
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
const { parentFilter:
|
|
125
|
-
if (!
|
|
126
|
-
|
|
121
|
+
let R = !0, x = !1;
|
|
122
|
+
if (d?.filter((_) => _.parentFilter.type === "Parent").forEach((_) => {
|
|
123
|
+
x = !0;
|
|
124
|
+
const { parentFilter: N } = _, C = W(o, N.collectionField), L = W(o, N.parentCollectionField), I = r.collections?.[C.collection];
|
|
125
|
+
if (!I) {
|
|
126
|
+
c = !1;
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
const { parentFilter:
|
|
133
|
-
if (!
|
|
134
|
-
|
|
129
|
+
I.parentEntities?.some((y) => i[`${L.name}_Array`].includes(y)) || (R = !1);
|
|
130
|
+
}), d?.filter((_) => _.parentFilter.type === "Parent_Property").forEach((_) => {
|
|
131
|
+
x = !0;
|
|
132
|
+
const { parentFilter: N } = _, C = W(o, N.collectionField), L = W(o, N.parentPropertyField), I = W(o, N.parentCollectionField), y = r.collections?.[C.collection];
|
|
133
|
+
if (!y) {
|
|
134
|
+
c = !1;
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
Object.entries(
|
|
138
|
-
const [
|
|
139
|
-
return
|
|
140
|
-
}) || (
|
|
141
|
-
}),
|
|
142
|
-
if (!(
|
|
143
|
-
|
|
137
|
+
Object.entries(y.parentPropertyEntities || {}).some((k) => {
|
|
138
|
+
const [w, B] = k;
|
|
139
|
+
return w === i[L.name] && i[`${I.name}_Array`].some((g) => B.includes(g));
|
|
140
|
+
}) || (R = !1);
|
|
141
|
+
}), O && x) {
|
|
142
|
+
if (!(E || R)) {
|
|
143
|
+
c = !1;
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
} else if (!
|
|
147
|
-
|
|
146
|
+
} else if (!E || !R) {
|
|
147
|
+
c = !1;
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
-
return
|
|
150
|
+
return c;
|
|
151
151
|
}, it = (n, e, t, s, r, i) => {
|
|
152
152
|
const { labels: a } = e, o = r.collections?.[a.collection];
|
|
153
153
|
let l = !0;
|
|
@@ -261,12 +261,12 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
261
261
|
if (d !== !0 && !(typeof d == "object" && d.includes(t)) ? h.forEach((p) => {
|
|
262
262
|
const E = p.charAt(0).toUpperCase() + p.slice(1);
|
|
263
263
|
if (p !== "assignable") {
|
|
264
|
-
const O = !!o.operations[p]?.includes(t),
|
|
265
|
-
if (!O &&
|
|
264
|
+
const O = !!o.operations[p]?.includes(t), R = !!f?.operations.includes(E);
|
|
265
|
+
if (!O && R) {
|
|
266
266
|
r = `Collection ${a.collection} has excess ${p} operation for role ${t}`, s = !1;
|
|
267
267
|
return;
|
|
268
268
|
}
|
|
269
|
-
if (O && !
|
|
269
|
+
if (O && !R) {
|
|
270
270
|
r = `Collection ${a.collection} has missing ${p} operation for role ${t}`, s = !1;
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
@@ -274,8 +274,8 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
274
274
|
}) : h.forEach((p) => {
|
|
275
275
|
const E = p.charAt(0).toUpperCase() + p.slice(1);
|
|
276
276
|
if (p !== "assignable") {
|
|
277
|
-
const O = !!o.operations[p]?.includes(t),
|
|
278
|
-
if (!O &&
|
|
277
|
+
const O = !!o.operations[p]?.includes(t), R = !!f?.operations.includes(E);
|
|
278
|
+
if (!O && R) {
|
|
279
279
|
r = `Collection ${a.collection} has excess ${p} operation for role ${t}`, s = !1;
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
@@ -307,7 +307,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
if (p.type === "Parent") {
|
|
310
|
-
const O =
|
|
310
|
+
const O = W(l, p.collectionField);
|
|
311
311
|
if (!K(O)) {
|
|
312
312
|
s = !1;
|
|
313
313
|
return;
|
|
@@ -318,7 +318,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
if (p.type === "Parent_Property") {
|
|
321
|
-
const O =
|
|
321
|
+
const O = W(l, p.collectionField);
|
|
322
322
|
if (!K(O)) {
|
|
323
323
|
s = !1;
|
|
324
324
|
return;
|
|
@@ -344,30 +344,30 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
344
344
|
s === h.userRole && h.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((v) => {
|
|
345
345
|
const p = i.collections?.[v], E = l?.collections?.[v];
|
|
346
346
|
if (!(n === "update" && qe(p, E)) && p) {
|
|
347
|
-
const O = h.collections.some((
|
|
347
|
+
const O = h.collections.some((R) => R.collection === v);
|
|
348
348
|
if (O) {
|
|
349
349
|
if (O) {
|
|
350
|
-
const
|
|
351
|
-
if (!(p.operations.every((
|
|
350
|
+
const R = h.collections.find((_) => _.collection === v);
|
|
351
|
+
if (!(p.operations.every((_) => R.operations.includes(_)) || n === "update" && qe(p.operations, E?.operations))) {
|
|
352
352
|
d = `User ${s} does not have write access to all included operations for collection ${v}`, m = !1;
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
|
-
if (!
|
|
355
|
+
if (!R.auth && p.auth && !(n === "update" && qe(p.auth, E?.auth))) {
|
|
356
356
|
d = `User ${s} does not have write access to auth for collection ${v}`, m = !1;
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
|
-
const
|
|
359
|
+
const x = {
|
|
360
360
|
recordOwner: "Record_Owner",
|
|
361
361
|
recordUser: "Record_User",
|
|
362
362
|
recordProperty: "Record_Property"
|
|
363
363
|
};
|
|
364
|
-
if (Object.keys(
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
d = `User ${s} does not have write access to attribute restriction ${
|
|
364
|
+
if (Object.keys(x).forEach((_) => {
|
|
365
|
+
const N = x[_];
|
|
366
|
+
if (R.attributeRestrictions?.includes(N) && !(p[_]?.active || n === "update" && qe(p[_], E?.[_]))) {
|
|
367
|
+
d = `User ${s} does not have write access to attribute restriction ${_} for collection ${v}`, m = !1;
|
|
368
368
|
return;
|
|
369
369
|
}
|
|
370
|
-
}),
|
|
370
|
+
}), R.restrictEntities && !p.restrictEntities && !(n === "update" && qe(p.restrictEntities, E?.restrictEntities))) {
|
|
371
371
|
d = `User ${s} does not have write access to restrictEntities for collection ${v}`, m = !1;
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
@@ -504,7 +504,7 @@ const jn = (n) => !!n.auth, Re = (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 a =
|
|
507
|
+
const a = W(e.fields, i.collectionField);
|
|
508
508
|
if (!K(a))
|
|
509
509
|
throw new Error("PERMISSION_DENIED");
|
|
510
510
|
const l = t.collections[a.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, Re = (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(W(o, "Created_By"));
|
|
660
660
|
break;
|
|
661
661
|
case "Record_User":
|
|
662
|
-
t.push(
|
|
662
|
+
t.push(W(r, l.collectionField));
|
|
663
663
|
break;
|
|
664
664
|
case "Record_Property":
|
|
665
|
-
t.push(
|
|
665
|
+
t.push(W(r, l.propertyField));
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
668
|
}), a && (a.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(W(o, "id"));
|
|
673
673
|
break;
|
|
674
674
|
case "Parent":
|
|
675
|
-
t.push(
|
|
675
|
+
t.push(W(r, l.collectionField));
|
|
676
676
|
break;
|
|
677
677
|
case "Parent_Property":
|
|
678
|
-
t.push(
|
|
678
|
+
t.push(W(r, l.collectionField)), t.push(W(r, l.propertyField));
|
|
679
679
|
break;
|
|
680
680
|
}
|
|
681
681
|
}), a.parentFilters && a.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(W(r, l.collectionField));
|
|
686
686
|
break;
|
|
687
687
|
case "Parent":
|
|
688
|
-
t.push(
|
|
688
|
+
t.push(W(r, l.parentCollectionField));
|
|
689
689
|
break;
|
|
690
690
|
case "Parent_Property":
|
|
691
|
-
t.push(
|
|
691
|
+
t.push(W(r, l.parentCollectionField)), t.push(W(r, l.parentPropertyField));
|
|
692
692
|
break;
|
|
693
693
|
}
|
|
694
694
|
})), [...new Set(t)];
|
|
@@ -701,19 +701,19 @@ const jn = (n) => !!n.auth, Re = (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(W(o, c.field));
|
|
705
705
|
}), i?.range && i.range.fields.forEach((c) => {
|
|
706
|
-
pt.includes(c) && t.push(
|
|
706
|
+
pt.includes(c) && t.push(W(o, c));
|
|
707
707
|
}), a?.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 = W(s.concat(o), c.field);
|
|
709
|
+
(!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(W(o, c.field));
|
|
710
710
|
}), ui(n, e).forEach((c) => {
|
|
711
|
-
pt.includes(c.name) && t.push(
|
|
711
|
+
pt.includes(c.name) && t.push(W(o, c.name));
|
|
712
712
|
}), [...new Set(t)];
|
|
713
713
|
}, ta = (n, e, t) => {
|
|
714
714
|
const s = [], { fields: r, preloadCache: i } = e, a = zn();
|
|
715
715
|
i?.range && i.range.fields.forEach((c) => {
|
|
716
|
-
pt.includes(c) ? s.push(
|
|
716
|
+
pt.includes(c) ? s.push(W(a, c)) : s.push(W(r, c));
|
|
717
717
|
});
|
|
718
718
|
const o = /* @__PURE__ */ new Set(), l = ci(e, t);
|
|
719
719
|
return Object.entries(l).map(([c, u]) => {
|
|
@@ -746,9 +746,9 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
|
|
|
746
746
|
});
|
|
747
747
|
});
|
|
748
748
|
}), a.forEach((l) => {
|
|
749
|
-
s.push(
|
|
749
|
+
s.push(W(r, l));
|
|
750
750
|
}), i) {
|
|
751
|
-
const l =
|
|
751
|
+
const l = W(r, i.archivedField);
|
|
752
752
|
l && s.push(l);
|
|
753
753
|
}
|
|
754
754
|
return s.push(...ta(n, e, t)), [...new Set(s)];
|
|
@@ -810,7 +810,7 @@ const Vs = (n, e, t, s, r, i, a, o, 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 a of s) {
|
|
813
|
-
const o =
|
|
813
|
+
const o = W(e, a.field);
|
|
814
814
|
e.find((l) => l.name === a.field) && K(o) && ["OneToOne", "OneToMany"].includes(o.type) && i.add(o);
|
|
815
815
|
}
|
|
816
816
|
return e.forEach((a) => {
|
|
@@ -830,7 +830,7 @@ const Vs = (n, e, t, s, r, i, a, o, 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 a of i.includeFields) {
|
|
833
|
-
const o = t.collections[i.collection], l =
|
|
833
|
+
const o = t.collections[i.collection], l = W(o.fields, a);
|
|
834
834
|
wt(o, [l]).size === 1 && Object.keys(e[i.name]).forEach((u) => {
|
|
835
835
|
e[i.name][u][a] ? e[i.name][u][`${a}_Lowercase`] = e[i.name][u][a].toLowerCase() : delete e[i.name][u][`${a}_Lowercase`];
|
|
836
836
|
});
|
|
@@ -856,7 +856,7 @@ const Vs = (n, e, t, s, r, i, a, o, l, c) => (n == "create" && (t.Collection_Pat
|
|
|
856
856
|
}, sa = async (n, e, t, s) => {
|
|
857
857
|
const { fields: r } = e;
|
|
858
858
|
for (const i of t.fields) {
|
|
859
|
-
const a =
|
|
859
|
+
const a = W(r, i.name);
|
|
860
860
|
i.custom?.initialValue && !(s && a.access && !a.access.includes(s)) && (n[i.name] = await re(i.custom.initialValue, [n]), wt(e, [a]).size === 1 && (n[`${i.name}_Lowercase`] = n[i.name].toLowerCase()));
|
|
861
861
|
}
|
|
862
862
|
for (const i of r)
|
|
@@ -907,7 +907,7 @@ var rr;
|
|
|
907
907
|
// second overwrites first
|
|
908
908
|
});
|
|
909
909
|
})(rr || (rr = {}));
|
|
910
|
-
const
|
|
910
|
+
const U = te.arrayToEnum([
|
|
911
911
|
"string",
|
|
912
912
|
"nan",
|
|
913
913
|
"number",
|
|
@@ -931,23 +931,23 @@ const V = te.arrayToEnum([
|
|
|
931
931
|
]), Xe = (n) => {
|
|
932
932
|
switch (typeof n) {
|
|
933
933
|
case "undefined":
|
|
934
|
-
return
|
|
934
|
+
return U.undefined;
|
|
935
935
|
case "string":
|
|
936
|
-
return
|
|
936
|
+
return U.string;
|
|
937
937
|
case "number":
|
|
938
|
-
return Number.isNaN(n) ?
|
|
938
|
+
return Number.isNaN(n) ? U.nan : U.number;
|
|
939
939
|
case "boolean":
|
|
940
|
-
return
|
|
940
|
+
return U.boolean;
|
|
941
941
|
case "function":
|
|
942
|
-
return
|
|
942
|
+
return U.function;
|
|
943
943
|
case "bigint":
|
|
944
|
-
return
|
|
944
|
+
return U.bigint;
|
|
945
945
|
case "symbol":
|
|
946
|
-
return
|
|
946
|
+
return U.symbol;
|
|
947
947
|
case "object":
|
|
948
|
-
return Array.isArray(n) ?
|
|
948
|
+
return Array.isArray(n) ? U.array : n === null ? U.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? U.promise : typeof Map < "u" && n instanceof Map ? U.map : typeof Set < "u" && n instanceof Set ? U.set : typeof Date < "u" && n instanceof Date ? U.date : U.object;
|
|
949
949
|
default:
|
|
950
|
-
return
|
|
950
|
+
return U.unknown;
|
|
951
951
|
}
|
|
952
952
|
}, A = te.arrayToEnum([
|
|
953
953
|
"invalid_type",
|
|
@@ -1035,7 +1035,7 @@ const ys = (n, e) => {
|
|
|
1035
1035
|
let t;
|
|
1036
1036
|
switch (n.code) {
|
|
1037
1037
|
case A.invalid_type:
|
|
1038
|
-
n.received ===
|
|
1038
|
+
n.received === U.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
1039
1039
|
break;
|
|
1040
1040
|
case A.invalid_literal:
|
|
1041
1041
|
t = `Invalid literal value, expected ${JSON.stringify(n.expected, te.jsonStringifyReplacer)}`;
|
|
@@ -1468,11 +1468,11 @@ function Ra(n, e) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
class Be 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) !== U.string) {
|
|
1472
1472
|
const i = this._getOrReturnCtx(e);
|
|
1473
1473
|
return P(i, {
|
|
1474
1474
|
code: A.invalid_type,
|
|
1475
|
-
expected:
|
|
1475
|
+
expected: U.string,
|
|
1476
1476
|
received: i.parsedType
|
|
1477
1477
|
}), Y;
|
|
1478
1478
|
}
|
|
@@ -1858,11 +1858,11 @@ class Dt 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) !== U.number) {
|
|
1862
1862
|
const i = this._getOrReturnCtx(e);
|
|
1863
1863
|
return P(i, {
|
|
1864
1864
|
code: A.invalid_type,
|
|
1865
|
-
expected:
|
|
1865
|
+
expected: U.number,
|
|
1866
1866
|
received: i.parsedType
|
|
1867
1867
|
}), Y;
|
|
1868
1868
|
}
|
|
@@ -2036,7 +2036,7 @@ class Xt extends X {
|
|
|
2036
2036
|
} catch {
|
|
2037
2037
|
return this._getInvalidInput(e);
|
|
2038
2038
|
}
|
|
2039
|
-
if (this._getType(e) !==
|
|
2039
|
+
if (this._getType(e) !== U.bigint)
|
|
2040
2040
|
return this._getInvalidInput(e);
|
|
2041
2041
|
let s;
|
|
2042
2042
|
const r = new Oe();
|
|
@@ -2064,7 +2064,7 @@ class Xt extends X {
|
|
|
2064
2064
|
const t = this._getOrReturnCtx(e);
|
|
2065
2065
|
return P(t, {
|
|
2066
2066
|
code: A.invalid_type,
|
|
2067
|
-
expected:
|
|
2067
|
+
expected: U.bigint,
|
|
2068
2068
|
received: t.parsedType
|
|
2069
2069
|
}), Y;
|
|
2070
2070
|
}
|
|
@@ -2160,11 +2160,11 @@ Xt.create = (n) => new Xt({
|
|
|
2160
2160
|
});
|
|
2161
2161
|
class gs 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) !== U.boolean) {
|
|
2164
2164
|
const s = this._getOrReturnCtx(e);
|
|
2165
2165
|
return P(s, {
|
|
2166
2166
|
code: A.invalid_type,
|
|
2167
|
-
expected:
|
|
2167
|
+
expected: U.boolean,
|
|
2168
2168
|
received: s.parsedType
|
|
2169
2169
|
}), Y;
|
|
2170
2170
|
}
|
|
@@ -2178,11 +2178,11 @@ gs.create = (n) => new gs({
|
|
|
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) !== U.date) {
|
|
2182
2182
|
const i = this._getOrReturnCtx(e);
|
|
2183
2183
|
return P(i, {
|
|
2184
2184
|
code: A.invalid_type,
|
|
2185
|
-
expected:
|
|
2185
|
+
expected: U.date,
|
|
2186
2186
|
received: i.parsedType
|
|
2187
2187
|
}), Y;
|
|
2188
2188
|
}
|
|
@@ -2256,11 +2256,11 @@ xn.create = (n) => new xn({
|
|
|
2256
2256
|
});
|
|
2257
2257
|
class lr extends X {
|
|
2258
2258
|
_parse(e) {
|
|
2259
|
-
if (this._getType(e) !==
|
|
2259
|
+
if (this._getType(e) !== U.symbol) {
|
|
2260
2260
|
const s = this._getOrReturnCtx(e);
|
|
2261
2261
|
return P(s, {
|
|
2262
2262
|
code: A.invalid_type,
|
|
2263
|
-
expected:
|
|
2263
|
+
expected: U.symbol,
|
|
2264
2264
|
received: s.parsedType
|
|
2265
2265
|
}), Y;
|
|
2266
2266
|
}
|
|
@@ -2273,11 +2273,11 @@ lr.create = (n) => new lr({
|
|
|
2273
2273
|
});
|
|
2274
2274
|
class ws extends X {
|
|
2275
2275
|
_parse(e) {
|
|
2276
|
-
if (this._getType(e) !==
|
|
2276
|
+
if (this._getType(e) !== U.undefined) {
|
|
2277
2277
|
const s = this._getOrReturnCtx(e);
|
|
2278
2278
|
return P(s, {
|
|
2279
2279
|
code: A.invalid_type,
|
|
2280
|
-
expected:
|
|
2280
|
+
expected: U.undefined,
|
|
2281
2281
|
received: s.parsedType
|
|
2282
2282
|
}), Y;
|
|
2283
2283
|
}
|
|
@@ -2290,11 +2290,11 @@ ws.create = (n) => new ws({
|
|
|
2290
2290
|
});
|
|
2291
2291
|
class cr extends X {
|
|
2292
2292
|
_parse(e) {
|
|
2293
|
-
if (this._getType(e) !==
|
|
2293
|
+
if (this._getType(e) !== U.null) {
|
|
2294
2294
|
const s = this._getOrReturnCtx(e);
|
|
2295
2295
|
return P(s, {
|
|
2296
2296
|
code: A.invalid_type,
|
|
2297
|
-
expected:
|
|
2297
|
+
expected: U.null,
|
|
2298
2298
|
received: s.parsedType
|
|
2299
2299
|
}), Y;
|
|
2300
2300
|
}
|
|
@@ -2334,7 +2334,7 @@ class ot extends X {
|
|
|
2334
2334
|
const t = this._getOrReturnCtx(e);
|
|
2335
2335
|
return P(t, {
|
|
2336
2336
|
code: A.invalid_type,
|
|
2337
|
-
expected:
|
|
2337
|
+
expected: U.never,
|
|
2338
2338
|
received: t.parsedType
|
|
2339
2339
|
}), Y;
|
|
2340
2340
|
}
|
|
@@ -2345,11 +2345,11 @@ ot.create = (n) => new ot({
|
|
|
2345
2345
|
});
|
|
2346
2346
|
class dr extends X {
|
|
2347
2347
|
_parse(e) {
|
|
2348
|
-
if (this._getType(e) !==
|
|
2348
|
+
if (this._getType(e) !== U.undefined) {
|
|
2349
2349
|
const s = this._getOrReturnCtx(e);
|
|
2350
2350
|
return P(s, {
|
|
2351
2351
|
code: A.invalid_type,
|
|
2352
|
-
expected:
|
|
2352
|
+
expected: U.void,
|
|
2353
2353
|
received: s.parsedType
|
|
2354
2354
|
}), Y;
|
|
2355
2355
|
}
|
|
@@ -2363,10 +2363,10 @@ dr.create = (n) => new dr({
|
|
|
2363
2363
|
class We extends X {
|
|
2364
2364
|
_parse(e) {
|
|
2365
2365
|
const { ctx: t, status: s } = this._processInputParams(e), r = this._def;
|
|
2366
|
-
if (t.parsedType !==
|
|
2366
|
+
if (t.parsedType !== U.array)
|
|
2367
2367
|
return P(t, {
|
|
2368
2368
|
code: A.invalid_type,
|
|
2369
|
-
expected:
|
|
2369
|
+
expected: U.array,
|
|
2370
2370
|
received: t.parsedType
|
|
2371
2371
|
}), Y;
|
|
2372
2372
|
if (r.exactLength !== null) {
|
|
@@ -2460,11 +2460,11 @@ class de 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) !== U.object) {
|
|
2464
2464
|
const c = this._getOrReturnCtx(e);
|
|
2465
2465
|
return P(c, {
|
|
2466
2466
|
code: A.invalid_type,
|
|
2467
|
-
expected:
|
|
2467
|
+
expected: U.object,
|
|
2468
2468
|
received: c.parsedType
|
|
2469
2469
|
}), Y;
|
|
2470
2470
|
}
|
|
@@ -2813,7 +2813,7 @@ function Es(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 === U.object && s === U.object) {
|
|
2817
2817
|
const r = te.objectKeys(e), i = te.objectKeys(n).filter((o) => r.indexOf(o) !== -1), a = { ...n, ...e };
|
|
2818
2818
|
for (const o of i) {
|
|
2819
2819
|
const l = Es(n[o], e[o]);
|
|
@@ -2822,7 +2822,7 @@ function Es(n, e) {
|
|
|
2822
2822
|
a[o] = l.data;
|
|
2823
2823
|
}
|
|
2824
2824
|
return { valid: !0, data: a };
|
|
2825
|
-
} else if (t ===
|
|
2825
|
+
} else if (t === U.array && s === U.array) {
|
|
2826
2826
|
if (n.length !== e.length)
|
|
2827
2827
|
return { valid: !1 };
|
|
2828
2828
|
const r = [];
|
|
@@ -2833,7 +2833,7 @@ function Es(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 === U.date && s === U.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2837
2837
|
}
|
|
2838
2838
|
class Dn extends X {
|
|
2839
2839
|
_parse(e) {
|
|
@@ -2876,10 +2876,10 @@ Dn.create = (n, e, t) => new Dn({
|
|
|
2876
2876
|
class yt extends X {
|
|
2877
2877
|
_parse(e) {
|
|
2878
2878
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2879
|
-
if (s.parsedType !==
|
|
2879
|
+
if (s.parsedType !== U.array)
|
|
2880
2880
|
return P(s, {
|
|
2881
2881
|
code: A.invalid_type,
|
|
2882
|
-
expected:
|
|
2882
|
+
expected: U.array,
|
|
2883
2883
|
received: s.parsedType
|
|
2884
2884
|
}), Y;
|
|
2885
2885
|
if (s.data.length < this._def.items.length)
|
|
@@ -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 !==
|
|
2935
|
+
if (s.parsedType !== U.object)
|
|
2936
2936
|
return P(s, {
|
|
2937
2937
|
code: A.invalid_type,
|
|
2938
|
-
expected:
|
|
2938
|
+
expected: U.object,
|
|
2939
2939
|
received: s.parsedType
|
|
2940
2940
|
}), Y;
|
|
2941
2941
|
const r = [], i = this._def.keyType, a = this._def.valueType;
|
|
@@ -2973,10 +2973,10 @@ class fr extends X {
|
|
|
2973
2973
|
}
|
|
2974
2974
|
_parse(e) {
|
|
2975
2975
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2976
|
-
if (s.parsedType !==
|
|
2976
|
+
if (s.parsedType !== U.map)
|
|
2977
2977
|
return P(s, {
|
|
2978
2978
|
code: A.invalid_type,
|
|
2979
|
-
expected:
|
|
2979
|
+
expected: U.map,
|
|
2980
2980
|
received: s.parsedType
|
|
2981
2981
|
}), Y;
|
|
2982
2982
|
const r = this._def.keyType, i = this._def.valueType, a = [...s.data.entries()].map(([o, l], c) => ({
|
|
@@ -3015,10 +3015,10 @@ fr.create = (n, e, t) => new fr({
|
|
|
3015
3015
|
class en extends X {
|
|
3016
3016
|
_parse(e) {
|
|
3017
3017
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
3018
|
-
if (s.parsedType !==
|
|
3018
|
+
if (s.parsedType !== U.set)
|
|
3019
3019
|
return P(s, {
|
|
3020
3020
|
code: A.invalid_type,
|
|
3021
|
-
expected:
|
|
3021
|
+
expected: U.set,
|
|
3022
3022
|
received: s.parsedType
|
|
3023
3023
|
}), Y;
|
|
3024
3024
|
const r = this._def;
|
|
@@ -3176,7 +3176,7 @@ At.create = pi;
|
|
|
3176
3176
|
class mr 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 !== U.string && s.parsedType !== U.number) {
|
|
3180
3180
|
const r = te.objectValues(t);
|
|
3181
3181
|
return P(s, {
|
|
3182
3182
|
expected: te.joinValues(r),
|
|
@@ -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 !==
|
|
3212
|
+
if (t.parsedType !== U.promise && t.common.async === !1)
|
|
3213
3213
|
return P(t, {
|
|
3214
3214
|
code: A.invalid_type,
|
|
3215
|
-
expected:
|
|
3215
|
+
expected: U.promise,
|
|
3216
3216
|
received: t.parsedType
|
|
3217
3217
|
}), Y;
|
|
3218
|
-
const s = t.parsedType ===
|
|
3218
|
+
const s = t.parsedType === U.promise ? t.data : Promise.resolve(t.data);
|
|
3219
3219
|
return Ce(s.then((r) => this._def.type.parseAsync(r, {
|
|
3220
3220
|
path: t.path,
|
|
3221
3221
|
errorMap: t.common.contextualErrorMap
|
|
@@ -3321,7 +3321,7 @@ Ct.createWithPreprocess = (n, e, t) => new Ct({
|
|
|
3321
3321
|
});
|
|
3322
3322
|
class st extends X {
|
|
3323
3323
|
_parse(e) {
|
|
3324
|
-
return this._getType(e) ===
|
|
3324
|
+
return this._getType(e) === U.undefined ? Ce(void 0) : this._def.innerType._parse(e);
|
|
3325
3325
|
}
|
|
3326
3326
|
unwrap() {
|
|
3327
3327
|
return this._def.innerType;
|
|
@@ -3334,7 +3334,7 @@ st.create = (n, e) => new st({
|
|
|
3334
3334
|
});
|
|
3335
3335
|
class $t extends X {
|
|
3336
3336
|
_parse(e) {
|
|
3337
|
-
return this._getType(e) ===
|
|
3337
|
+
return this._getType(e) === U.null ? Ce(null) : this._def.innerType._parse(e);
|
|
3338
3338
|
}
|
|
3339
3339
|
unwrap() {
|
|
3340
3340
|
return this._def.innerType;
|
|
@@ -3349,7 +3349,7 @@ class Os 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 === U.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
3353
3353
|
data: s,
|
|
3354
3354
|
path: t.path,
|
|
3355
3355
|
parent: t
|
|
@@ -3410,11 +3410,11 @@ ks.create = (n, e) => new ks({
|
|
|
3410
3410
|
});
|
|
3411
3411
|
class pr extends X {
|
|
3412
3412
|
_parse(e) {
|
|
3413
|
-
if (this._getType(e) !==
|
|
3413
|
+
if (this._getType(e) !== U.nan) {
|
|
3414
3414
|
const s = this._getOrReturnCtx(e);
|
|
3415
3415
|
return P(s, {
|
|
3416
3416
|
code: A.invalid_type,
|
|
3417
|
-
expected:
|
|
3417
|
+
expected: U.nan,
|
|
3418
3418
|
received: s.parsedType
|
|
3419
3419
|
}), Y;
|
|
3420
3420
|
}
|
|
@@ -4135,7 +4135,7 @@ function Ga(n, e, t) {
|
|
|
4135
4135
|
function Ya(n) {
|
|
4136
4136
|
const e = [];
|
|
4137
4137
|
for (let t = 1; t <= 12; t++) {
|
|
4138
|
-
const s =
|
|
4138
|
+
const s = V.utc(2009, t, 1);
|
|
4139
4139
|
e.push(n(s));
|
|
4140
4140
|
}
|
|
4141
4141
|
return e;
|
|
@@ -4143,7 +4143,7 @@ function Ya(n) {
|
|
|
4143
4143
|
function Ja(n) {
|
|
4144
4144
|
const e = [];
|
|
4145
4145
|
for (let t = 1; t <= 7; t++) {
|
|
4146
|
-
const s =
|
|
4146
|
+
const s = V.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 = [V.utc(2016, 11, 13, 9), V.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, to, () => {
|
|
4313
4313
|
const t = { era: e };
|
|
4314
|
-
return this.eraCache[e] || (this.eraCache[e] = [
|
|
4314
|
+
return this.eraCache[e] || (this.eraCache[e] = [V.utc(-40, 1, 1), V.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 le {
|
|
|
4730
4730
|
* @return {void}
|
|
4731
4731
|
*/
|
|
4732
4732
|
static resetCaches() {
|
|
4733
|
-
se.resetCache(), Ge.resetCache(),
|
|
4733
|
+
se.resetCache(), Ge.resetCache(), V.resetCache(), rl();
|
|
4734
4734
|
}
|
|
4735
4735
|
}
|
|
4736
4736
|
class Pe {
|
|
@@ -5983,7 +5983,7 @@ class ee {
|
|
|
5983
5983
|
format: "extended",
|
|
5984
5984
|
...e,
|
|
5985
5985
|
includeOffset: !1
|
|
5986
|
-
},
|
|
5986
|
+
}, V.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 ae {
|
|
|
6371
6371
|
if (s && r) {
|
|
6372
6372
|
let i, a;
|
|
6373
6373
|
try {
|
|
6374
|
-
i =
|
|
6374
|
+
i = V.fromISO(s, t), a = i.isValid;
|
|
6375
6375
|
} catch {
|
|
6376
6376
|
a = !1;
|
|
6377
6377
|
}
|
|
6378
6378
|
let o, l;
|
|
6379
6379
|
try {
|
|
6380
|
-
o =
|
|
6380
|
+
o = V.fromISO(r, t), l = o.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 = le.defaultZone) {
|
|
6774
|
-
const t =
|
|
6774
|
+
const t = V.now().setZone(e).set({ month: 12 });
|
|
6775
6775
|
return !e.isUniversal && t.offset !== t.set({ month: 6 }).offset;
|
|
6776
6776
|
}
|
|
6777
6777
|
/**
|
|
@@ -7239,7 +7239,7 @@ function Oc(n) {
|
|
|
7239
7239
|
}
|
|
7240
7240
|
let os = null;
|
|
7241
7241
|
function kc() {
|
|
7242
|
-
return os || (os =
|
|
7242
|
+
return os || (os = V.fromMillis(1555555555555)), os;
|
|
7243
7243
|
}
|
|
7244
7244
|
function bc(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 V({ ...t, ...e, old: t });
|
|
7324
7324
|
}
|
|
7325
7325
|
function go(n, e, t) {
|
|
7326
7326
|
let s = n - e * 60 * 1e3;
|
|
@@ -7370,14 +7370,14 @@ function Wr(n, e) {
|
|
|
7370
7370
|
function bt(n, e, t, s, r, i) {
|
|
7371
7371
|
const { setZone: a, zone: o } = t;
|
|
7372
7372
|
if (n && Object.keys(n).length !== 0 || e) {
|
|
7373
|
-
const l = e || o, c =
|
|
7373
|
+
const l = e || o, c = V.fromObject(n, {
|
|
7374
7374
|
...t,
|
|
7375
7375
|
zone: l,
|
|
7376
7376
|
specificOffset: i
|
|
7377
7377
|
});
|
|
7378
7378
|
return a ? c : c.setZone(o);
|
|
7379
7379
|
} else
|
|
7380
|
-
return
|
|
7380
|
+
return V.invalid(
|
|
7381
7381
|
new Pe("unparsable", `the input "${r}" can't be parsed as ${s}`)
|
|
7382
7382
|
);
|
|
7383
7383
|
}
|
|
@@ -7502,7 +7502,7 @@ function Ic(n) {
|
|
|
7502
7502
|
function zr(n, e) {
|
|
7503
7503
|
const t = tt(e.zone, le.defaultZone);
|
|
7504
7504
|
if (!t.isValid)
|
|
7505
|
-
return
|
|
7505
|
+
return V.invalid(Ht(t));
|
|
7506
7506
|
const s = se.fromObject(e);
|
|
7507
7507
|
let r, i;
|
|
7508
7508
|
if (H(n.year))
|
|
@@ -7512,11 +7512,11 @@ function zr(n, e) {
|
|
|
7512
7512
|
H(n[l]) && (n[l] = wo[l]);
|
|
7513
7513
|
const a = Zi(n) || zi(n);
|
|
7514
7514
|
if (a)
|
|
7515
|
-
return
|
|
7515
|
+
return V.invalid(a);
|
|
7516
7516
|
const o = Ic(t);
|
|
7517
7517
|
[r, i] = _n(n, o, t);
|
|
7518
7518
|
}
|
|
7519
|
-
return new
|
|
7519
|
+
return new V({ ts: r, zone: t, loc: s, o: i });
|
|
7520
7520
|
}
|
|
7521
7521
|
function qr(n, e, t) {
|
|
7522
7522
|
const s = H(t.round) ? !0 : t.round, r = H(t.rounding) ? "trunc" : t.rounding, i = (o, l) => (o = qs(o, s || t.calendary ? 0 : 2, t.calendary ? "round" : r), e.loc.clone(t).relFormatter(t).format(o, l)), a = (o) => t.calendary ? e.hasSame(n, o) ? 0 : e.startOf(o).diff(n.startOf(o), o).get(o) : e.diff(n, o).get(o);
|
|
@@ -7535,7 +7535,7 @@ function Br(n) {
|
|
|
7535
7535
|
}
|
|
7536
7536
|
let Gt;
|
|
7537
7537
|
const Ms = /* @__PURE__ */ new Map();
|
|
7538
|
-
class
|
|
7538
|
+
class V {
|
|
7539
7539
|
/**
|
|
7540
7540
|
* @access private
|
|
7541
7541
|
*/
|
|
@@ -7562,7 +7562,7 @@ class L {
|
|
|
7562
7562
|
* @return {DateTime}
|
|
7563
7563
|
*/
|
|
7564
7564
|
static now() {
|
|
7565
|
-
return new
|
|
7565
|
+
return new V({});
|
|
7566
7566
|
}
|
|
7567
7567
|
/**
|
|
7568
7568
|
* Create a local DateTime
|
|
@@ -7628,13 +7628,13 @@ class L {
|
|
|
7628
7628
|
static fromJSDate(e, t = {}) {
|
|
7629
7629
|
const s = ll(e) ? e.valueOf() : NaN;
|
|
7630
7630
|
if (Number.isNaN(s))
|
|
7631
|
-
return
|
|
7631
|
+
return V.invalid("invalid input");
|
|
7632
7632
|
const r = tt(t.zone, le.defaultZone);
|
|
7633
|
-
return r.isValid ? new
|
|
7633
|
+
return r.isValid ? new V({
|
|
7634
7634
|
ts: s,
|
|
7635
7635
|
zone: r,
|
|
7636
7636
|
loc: se.fromObject(t)
|
|
7637
|
-
}) :
|
|
7637
|
+
}) : V.invalid(Ht(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 L {
|
|
|
7649
7649
|
*/
|
|
7650
7650
|
static fromMillis(e, t = {}) {
|
|
7651
7651
|
if (rt(e))
|
|
7652
|
-
return e < -Ur || e > Ur ?
|
|
7652
|
+
return e < -Ur || e > Ur ? V.invalid("Timestamp out of range") : new V({
|
|
7653
7653
|
ts: e,
|
|
7654
7654
|
zone: tt(t.zone, le.defaultZone),
|
|
7655
7655
|
loc: se.fromObject(t)
|
|
@@ -7671,7 +7671,7 @@ class L {
|
|
|
7671
7671
|
*/
|
|
7672
7672
|
static fromSeconds(e, t = {}) {
|
|
7673
7673
|
if (rt(e))
|
|
7674
|
-
return new
|
|
7674
|
+
return new V({
|
|
7675
7675
|
ts: e * 1e3,
|
|
7676
7676
|
zone: tt(t.zone, le.defaultZone),
|
|
7677
7677
|
loc: se.fromObject(t)
|
|
@@ -7715,7 +7715,7 @@ class L {
|
|
|
7715
7715
|
e = e || {};
|
|
7716
7716
|
const s = tt(t.zone, le.defaultZone);
|
|
7717
7717
|
if (!s.isValid)
|
|
7718
|
-
return
|
|
7718
|
+
return V.invalid(Ht(s));
|
|
7719
7719
|
const r = se.fromObject(t), i = Vn(e, Zr), { minDaysInFirstWeek: a, startOfWeek: o } = xr(i, r), l = le.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, u = !H(i.ordinal), m = !H(i.year), d = !H(i.month) || !H(i.day), f = m || d, h = i.weekYear || i.weekNumber;
|
|
7720
7720
|
if ((f || u) && h)
|
|
7721
7721
|
throw new Tt(
|
|
@@ -7726,24 +7726,24 @@ class L {
|
|
|
7726
7726
|
const v = h || i.weekday && !f;
|
|
7727
7727
|
let p, E, O = pn(l, c);
|
|
7728
7728
|
v ? (p = Nc, E = Tc, O = Pn(O, a, o)) : u ? (p = xc, E = Rc, O = is(O)) : (p = En, E = wo);
|
|
7729
|
-
let
|
|
7729
|
+
let R = !1;
|
|
7730
7730
|
for (const y of p) {
|
|
7731
7731
|
const k = i[y];
|
|
7732
|
-
H(k) ?
|
|
7732
|
+
H(k) ? R ? i[y] = E[y] : i[y] = O[y] : R = !0;
|
|
7733
7733
|
}
|
|
7734
|
-
const
|
|
7735
|
-
if (
|
|
7736
|
-
return
|
|
7737
|
-
const
|
|
7734
|
+
const x = v ? il(i, a, o) : u ? ol(i) : Zi(i), _ = x || zi(i);
|
|
7735
|
+
if (_)
|
|
7736
|
+
return V.invalid(_);
|
|
7737
|
+
const N = v ? Rr(i, a, o) : u ? Nr(i) : i, [C, L] = _n(N, c, s), I = new V({
|
|
7738
7738
|
ts: C,
|
|
7739
7739
|
zone: s,
|
|
7740
|
-
o:
|
|
7740
|
+
o: L,
|
|
7741
7741
|
loc: r
|
|
7742
7742
|
});
|
|
7743
|
-
return i.weekday && f && e.weekday !==
|
|
7743
|
+
return i.weekday && f && e.weekday !== I.weekday ? V.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 : V.invalid(I.invalid);
|
|
7747
7747
|
}
|
|
7748
7748
|
/**
|
|
7749
7749
|
* Create a DateTime from an ISO 8601 string
|
|
@@ -7827,13 +7827,13 @@ class L {
|
|
|
7827
7827
|
numberingSystem: i,
|
|
7828
7828
|
defaultToEN: !0
|
|
7829
7829
|
}), [o, l, c, u] = Sc(a, e, t);
|
|
7830
|
-
return u ?
|
|
7830
|
+
return u ? V.invalid(u) : bt(o, 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 V.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 L {
|
|
|
7872
7872
|
const s = e instanceof Pe ? e : new Pe(e, t);
|
|
7873
7873
|
if (le.throwOnInvalid)
|
|
7874
7874
|
throw new Ca(s);
|
|
7875
|
-
return new
|
|
7875
|
+
return new V({ 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 L {
|
|
|
8311
8311
|
}
|
|
8312
8312
|
return dt(this, { ts: r, zone: e });
|
|
8313
8313
|
} else
|
|
8314
|
-
return
|
|
8314
|
+
return V.invalid(Ht(e));
|
|
8315
8315
|
}
|
|
8316
8316
|
/**
|
|
8317
8317
|
* "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
|
|
@@ -8772,7 +8772,7 @@ class L {
|
|
|
8772
8772
|
* @return {Duration}
|
|
8773
8773
|
*/
|
|
8774
8774
|
diffNow(e = "milliseconds", t = {}) {
|
|
8775
|
-
return this.diff(
|
|
8775
|
+
return this.diff(V.now(), e, t);
|
|
8776
8776
|
}
|
|
8777
8777
|
/**
|
|
8778
8778
|
* Return an Interval spanning between this DateTime and another DateTime
|
|
@@ -8829,7 +8829,7 @@ class L {
|
|
|
8829
8829
|
*/
|
|
8830
8830
|
toRelative(e = {}) {
|
|
8831
8831
|
if (!this.isValid) return null;
|
|
8832
|
-
const t = e.base ||
|
|
8832
|
+
const t = e.base || V.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), qr(t, this.plus(s), {
|
|
8835
8835
|
...e,
|
|
@@ -8852,7 +8852,7 @@ class L {
|
|
|
8852
8852
|
* @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
|
|
8853
8853
|
*/
|
|
8854
8854
|
toRelativeCalendar(e = {}) {
|
|
8855
|
-
return this.isValid ? qr(e.base ||
|
|
8855
|
+
return this.isValid ? qr(e.base || V.fromObject({}, { zone: this.zone }), this, {
|
|
8856
8856
|
...e,
|
|
8857
8857
|
numeric: "auto",
|
|
8858
8858
|
units: ["years", "months", "days"],
|
|
@@ -8865,7 +8865,7 @@ class L {
|
|
|
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(V.isDateTime))
|
|
8869
8869
|
throw new we("min requires all arguments be DateTimes");
|
|
8870
8870
|
return Ir(e, (t) => t.valueOf(), Math.min);
|
|
8871
8871
|
}
|
|
@@ -8875,7 +8875,7 @@ class L {
|
|
|
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(V.isDateTime))
|
|
8879
8879
|
throw new we("max requires all arguments be DateTimes");
|
|
8880
8880
|
return Ir(e, (t) => t.valueOf(), Math.max);
|
|
8881
8881
|
}
|
|
@@ -8899,7 +8899,7 @@ class L {
|
|
|
8899
8899
|
* @deprecated use fromFormatExplain instead
|
|
8900
8900
|
*/
|
|
8901
8901
|
static fromStringExplain(e, t, s = {}) {
|
|
8902
|
-
return
|
|
8902
|
+
return V.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 L {
|
|
|
8946
8946
|
`fromFormatParser called with a locale of ${a}, but the format parser was created for ${t.locale}`
|
|
8947
8947
|
);
|
|
8948
8948
|
const { result: o, zone: l, specificOffset: c, invalidReason: u } = t.explainFromTokens(e);
|
|
8949
|
-
return u ?
|
|
8949
|
+
return u ? V.invalid(u) : bt(
|
|
8950
8950
|
o,
|
|
8951
8951
|
l,
|
|
8952
8952
|
s,
|
|
@@ -9112,12 +9112,12 @@ class L {
|
|
|
9112
9112
|
}
|
|
9113
9113
|
}
|
|
9114
9114
|
function Zt(n) {
|
|
9115
|
-
if (
|
|
9115
|
+
if (V.isDateTime(n))
|
|
9116
9116
|
return n;
|
|
9117
9117
|
if (n && n.valueOf && rt(n.valueOf()))
|
|
9118
|
-
return
|
|
9118
|
+
return V.fromJSDate(n);
|
|
9119
9119
|
if (n && typeof n == "object")
|
|
9120
|
-
return
|
|
9120
|
+
return V.fromObject(n);
|
|
9121
9121
|
throw new we(
|
|
9122
9122
|
`Unknown datetime argument: ${n}, of type ${typeof n}`
|
|
9123
9123
|
);
|
|
@@ -9188,10 +9188,10 @@ const Dc = (n, e) => {
|
|
|
9188
9188
|
t ? (s = je({
|
|
9189
9189
|
seconds: ht(),
|
|
9190
9190
|
nanoseconds: ht()
|
|
9191
|
-
}), n.min && n.max ? s = s.describe(`${r}Must be between ${
|
|
9192
|
-
message: `Must be greater than or equal to ${
|
|
9191
|
+
}), n.min && n.max ? s = s.describe(`${r}Must be between ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)} and ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`) : n.min ? s = s.describe(`${r}Must be greater than or equal to ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)}`) : n.max ? s = s.describe(`${r}Must be less than or equal to ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`) : r && (s = s.describe(r.trim()))) : (s = Cc(), n.min && (s = s.refine((l) => l.toMillis() >= n.min, {
|
|
9192
|
+
message: `Must be greater than or equal to ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)}`
|
|
9193
9193
|
})), n.max && (s = s.refine((l) => l.toMillis() <= n.max, {
|
|
9194
|
-
message: `Must be less than or equal to ${
|
|
9194
|
+
message: `Must be less than or equal to ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`
|
|
9195
9195
|
})));
|
|
9196
9196
|
break;
|
|
9197
9197
|
case "Array":
|
|
@@ -9226,7 +9226,7 @@ const Dc = (n, e) => {
|
|
|
9226
9226
|
o[`attribute-${c.labels.collection}-${u.type}`] = Qt().optional();
|
|
9227
9227
|
}), c.access.entityRestrictions?.restrictions?.forEach((u) => {
|
|
9228
9228
|
if (u.type === "Individual" && (o[`accessible-${c.labels.collection}-${c.labels.collection}`] = je({}).catchall(ge()).optional()), u.type === "Parent" || u.type === "Parent_Property") {
|
|
9229
|
-
const m =
|
|
9229
|
+
const m = W(c.fields, u.collectionField);
|
|
9230
9230
|
o[`accessible-${c.labels.collection}-${m.collection}`] = je({}).catchall(ge()).optional();
|
|
9231
9231
|
}
|
|
9232
9232
|
});
|
|
@@ -9244,143 +9244,143 @@ const Dc = (n, e) => {
|
|
|
9244
9244
|
for (const o of s.fields)
|
|
9245
9245
|
await Hr(o.custom?.preValidate, r);
|
|
9246
9246
|
return Aa(n, t, i).parse(e), e;
|
|
9247
|
-
}, Ys = (n, e, t, s, r, i, a, o, l, c, u, m, d, f, h, v, p, E, O,
|
|
9248
|
-
const { fields:
|
|
9249
|
-
|
|
9247
|
+
}, Ys = (n, e, t, s, r, i, a, o, l, c, u, m, d, f, h, v, p, E, O, R, x) => {
|
|
9248
|
+
const { fields: _ } = a;
|
|
9249
|
+
_.filter((y) => "unique" in y && y.unique).forEach((y) => {
|
|
9250
9250
|
n !== "delete" && (typeof r[y.name] == "string" || typeof r[y.name] == "number") && (e.set(f(y, r[y.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||")), {
|
|
9251
9251
|
id: s,
|
|
9252
9252
|
Collection_Path: t
|
|
9253
|
-
}),
|
|
9254
|
-
}),
|
|
9253
|
+
}), x && x.size++);
|
|
9254
|
+
}), _.forEach((y) => {
|
|
9255
9255
|
if (ct(y, a, i)) {
|
|
9256
|
-
const k = dn(y, a, i),
|
|
9257
|
-
r[y.name] !== void 0 && (
|
|
9258
|
-
r[B.name] !== void 0 && (K(B) ?
|
|
9259
|
-
}), Object.keys(
|
|
9256
|
+
const k = dn(y, a, i), w = {};
|
|
9257
|
+
r[y.name] !== void 0 && (w[y.name] = r[y.name], K(y) && (w[`${y.name}_Array`] = r[`${y.name}_Array`])), k.forEach((B) => {
|
|
9258
|
+
r[B.name] !== void 0 && (K(B) ? w[`${B.name}_Array`] = r[`${B.name}_Array`] : w[B.name] = r[B.name]);
|
|
9259
|
+
}), Object.keys(w).length > 0 && (n === "create" && (w.Collection_Path = t, w.Collection_Path_String = t.join("/"), e.set(d(y), w)), n === "update" && e.update(d(y), w), n === "delete" && e.delete(d(y)), x && x.size++);
|
|
9260
9260
|
}
|
|
9261
9261
|
});
|
|
9262
|
-
const
|
|
9263
|
-
for (const y of
|
|
9264
|
-
const k = na(y, a),
|
|
9262
|
+
const N = l[a.labels.collection];
|
|
9263
|
+
for (const y of N) {
|
|
9264
|
+
const k = na(y, a), w = { ...r };
|
|
9265
9265
|
k.forEach((B) => {
|
|
9266
|
-
delete
|
|
9267
|
-
}), Object.keys(
|
|
9266
|
+
delete w[B.name], delete w[`${B.name}_Array`], delete w[`${B.name}_Single`], delete w[`${B.name}_Lowercase`];
|
|
9267
|
+
}), Object.keys(w).length > 0 && (n === "create" && (w.Collection_Path ||= t, w.Collection_Path_String = t.join("/"), e.set(h(y.key), w)), n === "update" && e.update(h(y.key), w), n === "delete" && e.delete(h(y.key)), x && x.size++);
|
|
9268
9268
|
}
|
|
9269
9269
|
const C = (y, k) => {
|
|
9270
|
-
let
|
|
9271
|
-
ct(k, y, i) &&
|
|
9272
|
-
ct(g, y, i) && JSON.parse(Kn(dn(g, y, i))).includes(k.name) &&
|
|
9270
|
+
let w = 1;
|
|
9271
|
+
ct(k, y, i) && w++, y.fields.forEach((g) => {
|
|
9272
|
+
ct(g, y, i) && JSON.parse(Kn(dn(g, y, i))).includes(k.name) && w++;
|
|
9273
9273
|
});
|
|
9274
9274
|
const B = l[y.labels.collection];
|
|
9275
9275
|
for (const g of B)
|
|
9276
|
-
g.fields.some((
|
|
9277
|
-
return
|
|
9278
|
-
},
|
|
9279
|
-
const
|
|
9280
|
-
|
|
9281
|
-
[`${
|
|
9282
|
-
[`${
|
|
9276
|
+
g.fields.some((T) => T.name === k.name) && K(k) && w++;
|
|
9277
|
+
return w;
|
|
9278
|
+
}, L = (y, k, w, B, g) => {
|
|
9279
|
+
const T = {};
|
|
9280
|
+
T[`${w.name}.${s}`] = m(), T[`${w.name}_Array`] = u(s), T[`${w.name}_Single`] = m(), e.update(v(g, B), T), ct(w, k, i) && e.update(p(y, w.name, B), {
|
|
9281
|
+
[`${w.name}.${s}`]: m(),
|
|
9282
|
+
[`${w.name}_Array`]: u(s)
|
|
9283
9283
|
}), k.fields.forEach(($) => {
|
|
9284
|
-
ct($, k, i) && JSON.parse(Kn(dn($, k, i))).includes(
|
|
9285
|
-
[`${
|
|
9284
|
+
ct($, k, i) && JSON.parse(Kn(dn($, k, i))).includes(w.name) && e.update(p(y, $.name, B), {
|
|
9285
|
+
[`${w.name}_Array`]: u(s)
|
|
9286
9286
|
});
|
|
9287
9287
|
});
|
|
9288
9288
|
const S = l[k.labels.collection];
|
|
9289
9289
|
for (const $ of S)
|
|
9290
|
-
$.fields.some((
|
|
9290
|
+
$.fields.some((D) => D.name === w.name) && K(w) && e.update(E(y, $.key, B), T);
|
|
9291
9291
|
};
|
|
9292
9292
|
if (n === "delete")
|
|
9293
9293
|
return;
|
|
9294
|
-
const
|
|
9294
|
+
const I = _.filter((y) => K(y) && y.twoWay);
|
|
9295
9295
|
if (!o?.noTwoWay) {
|
|
9296
|
-
for (const y of
|
|
9297
|
-
if (!
|
|
9296
|
+
for (const y of I) {
|
|
9297
|
+
if (!x)
|
|
9298
9298
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9299
|
-
const k = i.collections[y.collection],
|
|
9300
|
-
if (!
|
|
9299
|
+
const k = i.collections[y.collection], w = W(k.fields, y.twoWay), B = ft(k, k.fields), g = Array.from(B).map((T) => T.name);
|
|
9300
|
+
if (!w)
|
|
9301
9301
|
throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
|
|
9302
|
-
if (K(
|
|
9302
|
+
if (K(w)) {
|
|
9303
9303
|
if (r[`${y.name}_Array`])
|
|
9304
|
-
for (const [
|
|
9305
|
-
if (n === "update" && O && O[`${y.name}_Array`]?.includes(
|
|
9304
|
+
for (const [T, S] of Object.entries(r[y.name])) {
|
|
9305
|
+
if (n === "update" && O && O[`${y.name}_Array`]?.includes(T))
|
|
9306
9306
|
continue;
|
|
9307
9307
|
const $ = { ...O, ...r };
|
|
9308
9308
|
nt($);
|
|
9309
|
-
const
|
|
9310
|
-
|
|
9309
|
+
const D = {};
|
|
9310
|
+
w.includeFields && w.includeFields.forEach((F) => {
|
|
9311
9311
|
if ($[F] !== void 0) {
|
|
9312
|
-
|
|
9313
|
-
const z =
|
|
9314
|
-
wt(a, [z]).size === 1 && (
|
|
9312
|
+
D[F] = $[F];
|
|
9313
|
+
const z = W(a.fields, F);
|
|
9314
|
+
wt(a, [z]).size === 1 && (D[`${F}_Lowercase`] = $[`${F}_Lowercase`]);
|
|
9315
9315
|
}
|
|
9316
9316
|
});
|
|
9317
9317
|
const j = {
|
|
9318
9318
|
[`${y.twoWay}.${s}`]: {
|
|
9319
9319
|
Collection_Path: t,
|
|
9320
|
-
...
|
|
9320
|
+
...D
|
|
9321
9321
|
},
|
|
9322
9322
|
[`${y.twoWay}_Array`]: c(s)
|
|
9323
9323
|
};
|
|
9324
|
-
g.includes(
|
|
9324
|
+
g.includes(w.name) && (j[`${y.twoWay}_Single`] = {
|
|
9325
9325
|
Collection_Path: t,
|
|
9326
|
-
...
|
|
9326
|
+
...D
|
|
9327
9327
|
});
|
|
9328
9328
|
const q = Sn(r);
|
|
9329
|
-
e.update(v(S.Collection_Path,
|
|
9329
|
+
e.update(v(S.Collection_Path, T), {
|
|
9330
9330
|
...j,
|
|
9331
9331
|
...q
|
|
9332
|
-
}),
|
|
9333
|
-
[`${
|
|
9332
|
+
}), x.size++, ct(w, k, i) && (e.update(p(y, w.name, T), {
|
|
9333
|
+
[`${w.name}.${s}`]: {
|
|
9334
9334
|
Collection_Path: t,
|
|
9335
|
-
...
|
|
9335
|
+
...D
|
|
9336
9336
|
},
|
|
9337
|
-
[`${
|
|
9338
|
-
}),
|
|
9337
|
+
[`${w.name}_Array`]: c(s)
|
|
9338
|
+
}), x.size++), k.fields.forEach((F) => {
|
|
9339
9339
|
if (ct(F, k, i)) {
|
|
9340
9340
|
const z = JSON.parse(Kn(dn(F, k, i))), Q = {};
|
|
9341
|
-
z.includes(
|
|
9341
|
+
z.includes(w.name) && (Q[`${y.twoWay}_Array`] = c(s)), Object.keys(q).forEach((oe) => {
|
|
9342
9342
|
z.includes(oe) && (Q[oe] = q[oe]);
|
|
9343
|
-
}), Object.keys(Q).length > 0 && (e.update(p(y, F.name,
|
|
9343
|
+
}), Object.keys(Q).length > 0 && (e.update(p(y, F.name, T), Q), x.size++);
|
|
9344
9344
|
}
|
|
9345
9345
|
});
|
|
9346
9346
|
const b = l[k.labels.collection];
|
|
9347
9347
|
for (const F of b)
|
|
9348
|
-
if (F.fields.some((z) => z.name ===
|
|
9348
|
+
if (F.fields.some((z) => z.name === w.name)) {
|
|
9349
9349
|
const z = { ...j };
|
|
9350
9350
|
Object.keys(q).forEach((Q) => {
|
|
9351
9351
|
F.fields.some((oe) => oe.name === Q) && (z[Q] = q[Q]);
|
|
9352
|
-
}), Object.keys(z).length > 0 && (e.update(E(y, F.key,
|
|
9352
|
+
}), Object.keys(z).length > 0 && (e.update(E(y, F.key, T), z), x.size++);
|
|
9353
9353
|
}
|
|
9354
9354
|
}
|
|
9355
9355
|
} else
|
|
9356
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9356
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
|
|
9357
9357
|
}
|
|
9358
|
-
|
|
9359
|
-
for (const y of
|
|
9360
|
-
if (!
|
|
9358
|
+
x && x.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${x.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.`));
|
|
9359
|
+
for (const y of I) {
|
|
9360
|
+
if (!x)
|
|
9361
9361
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9362
|
-
const k = i.collections[y.collection],
|
|
9363
|
-
if (!
|
|
9362
|
+
const k = i.collections[y.collection], w = W(k.fields, y.twoWay);
|
|
9363
|
+
if (!w)
|
|
9364
9364
|
throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
|
|
9365
|
-
if (K(
|
|
9365
|
+
if (K(w)) {
|
|
9366
9366
|
if (n === "update" && O && !(r[y.name] && Fe(r[y.name])) && r[`${y.name}_Array`] && O[`${y.name}_Array`]?.length > 0)
|
|
9367
9367
|
for (const [B, g] of Object.entries(O[y.name]))
|
|
9368
|
-
!r[`${y.name}_Array`].includes(B) && !
|
|
9368
|
+
!r[`${y.name}_Array`].includes(B) && !R?.get(y.name)?.includes(B) && (x.size += C(k, w), x.size <= 500 && L(y, k, w, B, g.Collection_Path));
|
|
9369
9369
|
} else
|
|
9370
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9370
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
|
|
9371
9371
|
}
|
|
9372
|
-
for (const y of
|
|
9373
|
-
if (!
|
|
9372
|
+
for (const y of I) {
|
|
9373
|
+
if (!x)
|
|
9374
9374
|
throw new Error("VALIDATION_ERROR: batchSize is required");
|
|
9375
|
-
const k = i.collections[y.collection],
|
|
9376
|
-
if (!
|
|
9375
|
+
const k = i.collections[y.collection], w = W(k.fields, y.twoWay);
|
|
9376
|
+
if (!w)
|
|
9377
9377
|
throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
|
|
9378
|
-
if (K(
|
|
9378
|
+
if (K(w)) {
|
|
9379
9379
|
if (n === "update" && O && r[y.name] && Fe(r[y.name]) && O[`${y.name}_Array`]?.length > 0)
|
|
9380
9380
|
for (const [B, g] of Object.entries(O[y.name]))
|
|
9381
|
-
|
|
9381
|
+
R?.get(y.name)?.includes(B) || (x.size += C(k, w), x.size <= 500 && L(y, k, w, B, g.Collection_Path));
|
|
9382
9382
|
} else
|
|
9383
|
-
throw new Error(`SCHEMA_ERROR: Invalid field type: ${
|
|
9383
|
+
throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
|
|
9384
9384
|
}
|
|
9385
9385
|
}
|
|
9386
9386
|
}, Ue = (n) => {
|
|
@@ -9570,99 +9570,99 @@ const Rt = {
|
|
|
9570
9570
|
const f = r.collections?.[l.collection];
|
|
9571
9571
|
if (!r.Role)
|
|
9572
9572
|
throw new Error("PERMISSION_DENIED");
|
|
9573
|
-
const h = f && Re("Read", f), v = ai(o, t, r), p = ii(o, r), E = Fs(o, r), O = oi(o, t, r),
|
|
9574
|
-
const
|
|
9573
|
+
const h = f && Re("Read", f), v = ai(o, t, r), p = ii(o, r), E = Fs(o, r), O = oi(o, t, r), R = (g = []) => {
|
|
9574
|
+
const T = [], S = fi(r.Role, o, t);
|
|
9575
9575
|
if (!S)
|
|
9576
9576
|
throw new Error("PERMISSION_DENIED");
|
|
9577
9577
|
if (h) {
|
|
9578
9578
|
let $ = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${S.key}`).where("Collection_Path_String", "==", e.join("/"));
|
|
9579
|
-
g.forEach((
|
|
9580
|
-
$ = $.where(...
|
|
9581
|
-
}),
|
|
9579
|
+
g.forEach((D) => {
|
|
9580
|
+
$ = $.where(...D);
|
|
9581
|
+
}), T.push($);
|
|
9582
9582
|
} else if (v)
|
|
9583
9583
|
for (const $ of v) {
|
|
9584
|
-
let
|
|
9584
|
+
let D = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${$.field}`).where("Collection_Path_String", "==", e.join("/"));
|
|
9585
9585
|
g.forEach((j) => {
|
|
9586
|
-
|
|
9587
|
-
}),
|
|
9586
|
+
D = D.where(...j);
|
|
9587
|
+
}), T.push(D);
|
|
9588
9588
|
}
|
|
9589
|
-
return
|
|
9590
|
-
},
|
|
9591
|
-
if (
|
|
9592
|
-
return
|
|
9593
|
-
let
|
|
9594
|
-
const
|
|
9595
|
-
g && (
|
|
9589
|
+
return T;
|
|
9590
|
+
}, x = p.filter((g) => "operations" in g && g.operations ? g.operations.includes("Read") : !0);
|
|
9591
|
+
if (x.length === 0 && E.length === 0 && O.length === 0)
|
|
9592
|
+
return R();
|
|
9593
|
+
let _ = 0;
|
|
9594
|
+
const N = (g) => {
|
|
9595
|
+
g && (_ === 0 ? _ = g : _ *= g);
|
|
9596
9596
|
};
|
|
9597
|
-
if (
|
|
9598
|
-
for (const g of
|
|
9597
|
+
if (x.length > 0) {
|
|
9598
|
+
for (const g of x)
|
|
9599
9599
|
if (g.operations && g.type === "Record_Property") {
|
|
9600
|
-
const
|
|
9601
|
-
if (!
|
|
9600
|
+
const T = g.roles.find((S) => S.role === r.Role);
|
|
9601
|
+
if (!T)
|
|
9602
9602
|
throw new Error("PERMISSION_DENIED");
|
|
9603
|
-
|
|
9603
|
+
N(T.values?.length);
|
|
9604
9604
|
}
|
|
9605
9605
|
}
|
|
9606
|
-
u?.roles.includes(r.Role) && u.range &&
|
|
9606
|
+
u?.roles.includes(r.Role) && u.range && N(u.range.fields.length);
|
|
9607
9607
|
const C = m.admin?.statusField;
|
|
9608
|
-
C && !u?.roles.includes(r.Role) &&
|
|
9609
|
-
const
|
|
9610
|
-
|
|
9608
|
+
C && !u?.roles.includes(r.Role) && N(Math.max(C.active?.length || 0, C.archived?.length || 0));
|
|
9609
|
+
const L = _ === 0 ? 30 : Math.max(1, Math.floor(30 / _)), I = [];
|
|
9610
|
+
x.filter((g) => g.type === "Record_Owner").forEach(() => I.push(["Created_By", "==", s])), x.filter((g) => g.type === "Record_User").forEach((g) => {
|
|
9611
9611
|
if ("collectionField" in g) {
|
|
9612
|
-
const
|
|
9613
|
-
|
|
9612
|
+
const T = W(c, g.collectionField);
|
|
9613
|
+
I.push([`${T.name}_Array`, "array-contains", r.Doc_ID]);
|
|
9614
9614
|
}
|
|
9615
|
-
}),
|
|
9615
|
+
}), x.filter((g) => g.type === "Record_Property").forEach((g) => {
|
|
9616
9616
|
if ("propertyField" in g) {
|
|
9617
|
-
const
|
|
9618
|
-
if (!
|
|
9617
|
+
const T = g.roles.find(($) => $.role === r.Role);
|
|
9618
|
+
if (!T)
|
|
9619
9619
|
throw new Error("PERMISSION_DENIED");
|
|
9620
|
-
const S =
|
|
9621
|
-
S.type === "Array" ?
|
|
9620
|
+
const S = W(c, g.propertyField);
|
|
9621
|
+
S.type === "Array" ? I.push([`${S.name}_Array`, "array-contains-any", T.values]) : I.push([S.name, "in", T.values]);
|
|
9622
9622
|
}
|
|
9623
9623
|
});
|
|
9624
9624
|
const y = [];
|
|
9625
9625
|
E.filter((g) => g.type === "Individual").forEach((g) => {
|
|
9626
|
-
const
|
|
9627
|
-
if (
|
|
9628
|
-
const $ = g.singleQuery ? g.singleQuery :
|
|
9629
|
-
for (let
|
|
9630
|
-
const j =
|
|
9626
|
+
const T = f?.individualEntities, S = [];
|
|
9627
|
+
if (T) {
|
|
9628
|
+
const $ = g.singleQuery ? g.singleQuery : L;
|
|
9629
|
+
for (let D = 0; D < T.length; D += $) {
|
|
9630
|
+
const j = T.slice(D, D + $);
|
|
9631
9631
|
S.push(j);
|
|
9632
9632
|
}
|
|
9633
9633
|
if (!g.singleQuery)
|
|
9634
|
-
S.forEach((
|
|
9635
|
-
y.push(...
|
|
9634
|
+
S.forEach((D) => {
|
|
9635
|
+
y.push(...R(I.concat([["id", "in", D]])));
|
|
9636
9636
|
});
|
|
9637
9637
|
else {
|
|
9638
|
-
if (
|
|
9638
|
+
if (T.length > $)
|
|
9639
9639
|
throw new Error(`INPUT_ERROR: Individual entity restriction with singleQuery set to true must not have more than ${g.singleQuery} entities`);
|
|
9640
|
-
|
|
9640
|
+
I.push(["id", "in", T]);
|
|
9641
9641
|
}
|
|
9642
9642
|
}
|
|
9643
9643
|
}), O.filter((g) => g.parentFilter.type === "Individual").forEach((g) => {
|
|
9644
|
-
const { parentFilter:
|
|
9645
|
-
if ("collectionField" in
|
|
9646
|
-
const $ =
|
|
9644
|
+
const { parentFilter: T, parentRestriction: S } = g;
|
|
9645
|
+
if ("collectionField" in T) {
|
|
9646
|
+
const $ = W(c, T.collectionField);
|
|
9647
9647
|
if ("collection" in $) {
|
|
9648
|
-
const
|
|
9649
|
-
if (!
|
|
9648
|
+
const D = r.collections?.[$.collection];
|
|
9649
|
+
if (!D)
|
|
9650
9650
|
throw new Error("PERMISSION_DENIED");
|
|
9651
|
-
const j =
|
|
9651
|
+
const j = D.individualEntities, q = [];
|
|
9652
9652
|
if (j) {
|
|
9653
|
-
const b = S.singleQuery ? S.singleQuery :
|
|
9653
|
+
const b = S.singleQuery ? S.singleQuery : L;
|
|
9654
9654
|
for (let F = 0; F < j.length; F += b) {
|
|
9655
9655
|
const z = j.slice(F, F + b);
|
|
9656
9656
|
q.push(z);
|
|
9657
9657
|
}
|
|
9658
9658
|
if (!S.singleQuery)
|
|
9659
9659
|
q.forEach((F) => {
|
|
9660
|
-
y.push(...
|
|
9660
|
+
y.push(...R(I.concat([[`${$.name}_Array`, "array-contains-any", F]])));
|
|
9661
9661
|
});
|
|
9662
9662
|
else {
|
|
9663
9663
|
if (j.length > b)
|
|
9664
9664
|
throw new Error(`INPUT_ERROR: Individual entity parentFilter with singleQuery set to true must not have more than ${S.singleQuery} entities`);
|
|
9665
|
-
|
|
9665
|
+
I.push([`${$.name}_Array`, "array-contains-any", j]);
|
|
9666
9666
|
}
|
|
9667
9667
|
}
|
|
9668
9668
|
}
|
|
@@ -9671,53 +9671,53 @@ const Rt = {
|
|
|
9671
9671
|
const k = [];
|
|
9672
9672
|
E.filter((g) => g.type === "Parent").forEach((g) => {
|
|
9673
9673
|
if ("collectionField" in g) {
|
|
9674
|
-
const
|
|
9675
|
-
if ("collection" in
|
|
9674
|
+
const T = W(c, g.collectionField);
|
|
9675
|
+
if ("collection" in T) {
|
|
9676
9676
|
const S = f?.parentEntities, $ = [];
|
|
9677
9677
|
if (S) {
|
|
9678
|
-
const
|
|
9679
|
-
for (let j = 0; j < S.length; j +=
|
|
9680
|
-
const q = S.slice(j, j +
|
|
9678
|
+
const D = g.singleQuery ? g.singleQuery : L;
|
|
9679
|
+
for (let j = 0; j < S.length; j += D) {
|
|
9680
|
+
const q = S.slice(j, j + D);
|
|
9681
9681
|
$.push(q);
|
|
9682
9682
|
}
|
|
9683
9683
|
if (!g.singleQuery)
|
|
9684
9684
|
$.forEach((j) => {
|
|
9685
|
-
k.push(...
|
|
9685
|
+
k.push(...R(I.concat([[`${T.name}_Array`, "array-contains-any", j]])));
|
|
9686
9686
|
});
|
|
9687
9687
|
else {
|
|
9688
|
-
if (S && S.length >
|
|
9688
|
+
if (S && S.length > D)
|
|
9689
9689
|
throw new Error(`INPUT_ERROR: Parent entity restriction with singleQuery set to true must not have more than ${g.singleQuery} entities`);
|
|
9690
|
-
|
|
9690
|
+
I.push([`${T.name}_Array`, "array-contains-any", S]);
|
|
9691
9691
|
}
|
|
9692
9692
|
}
|
|
9693
9693
|
}
|
|
9694
9694
|
}
|
|
9695
9695
|
}), O.filter((g) => g.parentFilter.type === "Parent").forEach((g) => {
|
|
9696
|
-
const { parentFilter:
|
|
9697
|
-
if ("collectionField" in
|
|
9698
|
-
const $ =
|
|
9699
|
-
if ("collection" in $ && "collection" in
|
|
9696
|
+
const { parentFilter: T, parentRestriction: S } = g;
|
|
9697
|
+
if ("collectionField" in T && "parentCollectionField" in T) {
|
|
9698
|
+
const $ = W(c, T.collectionField), D = W(c, T.parentCollectionField);
|
|
9699
|
+
if ("collection" in $ && "collection" in D) {
|
|
9700
9700
|
const j = r.collections?.[$.collection];
|
|
9701
9701
|
if (!j)
|
|
9702
9702
|
throw new Error("PERMISSION_DENIED");
|
|
9703
9703
|
const q = j.parentEntities, b = [];
|
|
9704
9704
|
if (q) {
|
|
9705
|
-
const F = S.singleQuery ? S.singleQuery :
|
|
9705
|
+
const F = S.singleQuery ? S.singleQuery : L;
|
|
9706
9706
|
for (let z = 0; z < q.length; z += F) {
|
|
9707
9707
|
const Q = q.slice(z, z + F);
|
|
9708
9708
|
b.push(Q);
|
|
9709
9709
|
}
|
|
9710
9710
|
if (!S.singleQuery)
|
|
9711
9711
|
b.forEach((z) => {
|
|
9712
|
-
k.push(...
|
|
9713
|
-
[`${
|
|
9712
|
+
k.push(...R(I.concat([
|
|
9713
|
+
[`${D.name}_Array`, "array-contains-any", z]
|
|
9714
9714
|
])));
|
|
9715
9715
|
});
|
|
9716
9716
|
else {
|
|
9717
9717
|
if (q && q.length > F)
|
|
9718
9718
|
throw new Error(`INPUT_ERROR: Profile_Parent entity parentFilter with singleQuery set to true must not have more than ${S.singleQuery} entities`);
|
|
9719
|
-
|
|
9720
|
-
`${
|
|
9719
|
+
I.push([
|
|
9720
|
+
`${D.name}_Array`,
|
|
9721
9721
|
"array-contains-any",
|
|
9722
9722
|
q
|
|
9723
9723
|
]);
|
|
@@ -9726,23 +9726,23 @@ const Rt = {
|
|
|
9726
9726
|
}
|
|
9727
9727
|
}
|
|
9728
9728
|
});
|
|
9729
|
-
const
|
|
9729
|
+
const w = [];
|
|
9730
9730
|
k.length === 0 && (E.filter((g) => g.type === "Parent_Property").forEach((g) => {
|
|
9731
9731
|
if ("collectionField" in g && "propertyField" in g) {
|
|
9732
|
-
const
|
|
9733
|
-
if ("collection" in
|
|
9732
|
+
const T = W(c, g.collectionField), S = W(c, g.propertyField);
|
|
9733
|
+
if ("collection" in T) {
|
|
9734
9734
|
const $ = f?.parentPropertyEntities || {};
|
|
9735
|
-
Object.entries($).forEach(([
|
|
9735
|
+
Object.entries($).forEach(([D, j]) => {
|
|
9736
9736
|
if (j.length > 0) {
|
|
9737
9737
|
const q = [];
|
|
9738
|
-
for (let b = 0; b < j.length; b +=
|
|
9739
|
-
const F = j.slice(b, b +
|
|
9738
|
+
for (let b = 0; b < j.length; b += L) {
|
|
9739
|
+
const F = j.slice(b, b + L);
|
|
9740
9740
|
q.push(F);
|
|
9741
9741
|
}
|
|
9742
9742
|
q.forEach((b) => {
|
|
9743
|
-
|
|
9744
|
-
[`${
|
|
9745
|
-
[S.name, "==",
|
|
9743
|
+
w.push(...R(I.concat([
|
|
9744
|
+
[`${T.name}_Array`, "array-contains-any", b],
|
|
9745
|
+
[S.name, "==", D]
|
|
9746
9746
|
])));
|
|
9747
9747
|
});
|
|
9748
9748
|
}
|
|
@@ -9750,9 +9750,9 @@ const Rt = {
|
|
|
9750
9750
|
}
|
|
9751
9751
|
}
|
|
9752
9752
|
}), O.filter((g) => g.parentFilter.type === "Parent_Property").forEach((g) => {
|
|
9753
|
-
const { parentFilter:
|
|
9754
|
-
if ("collectionField" in
|
|
9755
|
-
const S =
|
|
9753
|
+
const { parentFilter: T } = g;
|
|
9754
|
+
if ("collectionField" in T && "parentCollectionField" in T && "parentPropertyField" in T) {
|
|
9755
|
+
const S = W(c, T.collectionField), $ = W(c, T.parentCollectionField), D = W(c, T.parentPropertyField);
|
|
9756
9756
|
if ("collection" in S && "collection" in $) {
|
|
9757
9757
|
const j = r.collections?.[S.collection];
|
|
9758
9758
|
if (!j)
|
|
@@ -9761,18 +9761,18 @@ const Rt = {
|
|
|
9761
9761
|
Object.entries(q).forEach(([b, F]) => {
|
|
9762
9762
|
if (F.length > 0) {
|
|
9763
9763
|
const z = [];
|
|
9764
|
-
for (let Q = 0; Q < F.length; Q +=
|
|
9765
|
-
const oe = F.slice(Q, Q +
|
|
9764
|
+
for (let Q = 0; Q < F.length; Q += L) {
|
|
9765
|
+
const oe = F.slice(Q, Q + L);
|
|
9766
9766
|
z.push(oe);
|
|
9767
9767
|
}
|
|
9768
9768
|
z.forEach((Q) => {
|
|
9769
|
-
|
|
9769
|
+
w.push(...R(I.concat([
|
|
9770
9770
|
[
|
|
9771
9771
|
`${$.name}_Array`,
|
|
9772
9772
|
"array-contains-any",
|
|
9773
9773
|
Q
|
|
9774
9774
|
],
|
|
9775
|
-
[
|
|
9775
|
+
[D.name, "==", b]
|
|
9776
9776
|
])));
|
|
9777
9777
|
});
|
|
9778
9778
|
}
|
|
@@ -9780,8 +9780,8 @@ const Rt = {
|
|
|
9780
9780
|
}
|
|
9781
9781
|
}
|
|
9782
9782
|
}));
|
|
9783
|
-
const B = [...y, ...k, ...
|
|
9784
|
-
return !E.length && !O.length ?
|
|
9783
|
+
const B = [...y, ...k, ...w];
|
|
9784
|
+
return !E.length && !O.length ? R(I) : B;
|
|
9785
9785
|
} else
|
|
9786
9786
|
throw new Error("PERMISSION_DENIED");
|
|
9787
9787
|
else return [d];
|
|
@@ -9895,10 +9895,10 @@ const Rt = {
|
|
|
9895
9895
|
const p = Wt(), E = n.at(-1);
|
|
9896
9896
|
if (!E)
|
|
9897
9897
|
throw new Error("EMPTY_PATH");
|
|
9898
|
-
const O = Object.keys(h.collections).includes(E),
|
|
9899
|
-
if (!O ||
|
|
9898
|
+
const O = Object.keys(h.collections).includes(E), R = p.disabledCollections?.includes(E);
|
|
9899
|
+
if (!O || R)
|
|
9900
9900
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
9901
|
-
const
|
|
9901
|
+
const x = h.collections[E], { labels: _ } = x, N = Qe(_.collection, h);
|
|
9902
9902
|
if (t?.user) {
|
|
9903
9903
|
if (!u?.exists)
|
|
9904
9904
|
throw new Error("PERMISSION_DENIED");
|
|
@@ -9910,8 +9910,8 @@ const Rt = {
|
|
|
9910
9910
|
let C = Fc(s, n, h, t?.user, v);
|
|
9911
9911
|
if (C.length === 0)
|
|
9912
9912
|
return { cursor: {}, pages: 0, docs: [] };
|
|
9913
|
-
if (e && (C = C.map((g) => (e.forEach(([
|
|
9914
|
-
g = g.where(
|
|
9913
|
+
if (e && (C = C.map((g) => (e.forEach(([T, S, $]) => {
|
|
9914
|
+
g = g.where(T, S, $);
|
|
9915
9915
|
}), g))), a = t?.pagination?.startAfter || t?.pagination?.endBefore || {
|
|
9916
9916
|
first: /* @__PURE__ */ new Map(),
|
|
9917
9917
|
last: /* @__PURE__ */ new Map()
|
|
@@ -9920,36 +9920,36 @@ const Rt = {
|
|
|
9920
9920
|
throw new Error("INPUT_ERROR: startAfter and endBefore cannot be provided together");
|
|
9921
9921
|
const g = t.pagination.startAfter || t.pagination.endBefore;
|
|
9922
9922
|
if (t?.user) {
|
|
9923
|
-
const
|
|
9924
|
-
if (g &&
|
|
9925
|
-
throw new Error("INPUT_ERROR: Pagination is not allowed when using " +
|
|
9923
|
+
const T = Ko(v.Role, x, h);
|
|
9924
|
+
if (g && T !== !0)
|
|
9925
|
+
throw new Error("INPUT_ERROR: Pagination is not allowed when using " + T);
|
|
9926
9926
|
}
|
|
9927
|
-
t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((
|
|
9927
|
+
t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((T) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((T, S) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((T, S) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).endBefore(a.first.get(S)).limitToLast(t.pagination.number)) : !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((T) => T.limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((T, S) => T.startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((T, S) => T.endBefore(a.first.get(S)).limitToLast(t.pagination.number));
|
|
9928
9928
|
}
|
|
9929
|
-
const
|
|
9930
|
-
await ie("preOperation", p,
|
|
9931
|
-
const k = C.map(async (g) => await c.get(g)),
|
|
9932
|
-
for (const g of
|
|
9933
|
-
for (const
|
|
9934
|
-
o.has(
|
|
9935
|
-
const S =
|
|
9936
|
-
$.id ||=
|
|
9937
|
-
const
|
|
9938
|
-
delete
|
|
9929
|
+
const L = {};
|
|
9930
|
+
await ie("preOperation", p, N, ["read", void 0, void 0, L]), await ie("preRead", p, N, [L, C, !0, !1]), o = /* @__PURE__ */ new Map();
|
|
9931
|
+
const k = C.map(async (g) => await c.get(g)), w = await Promise.all(k);
|
|
9932
|
+
for (const g of w) {
|
|
9933
|
+
for (const T of g.docs) {
|
|
9934
|
+
o.has(T.id) || o.set(T.id, {});
|
|
9935
|
+
const S = T.data(), $ = o.get(T.id);
|
|
9936
|
+
$.id ||= T.id;
|
|
9937
|
+
const D = { ...$, ...S };
|
|
9938
|
+
delete D.Collection_Path_String, o.set(T.id, D);
|
|
9939
9939
|
}
|
|
9940
|
-
a.first.set(
|
|
9940
|
+
a.first.set(w.indexOf(g), g.docs[0]), a.last.set(w.indexOf(g), g.docs.at(-1) || g.docs[0]);
|
|
9941
9941
|
}
|
|
9942
9942
|
if (t?.pagination) {
|
|
9943
9943
|
let g = C[0];
|
|
9944
|
-
e && (g = e.reduce((
|
|
9944
|
+
e && (g = e.reduce((D, [j, q, b]) => D.where(j, q, b), g)), t.pagination.orderByField && t.pagination.orderByDirection && (g = g.orderBy(t.pagination.orderByField, t.pagination.orderByDirection));
|
|
9945
9945
|
const S = (await g.count().get()).data().count, $ = t.pagination.number;
|
|
9946
9946
|
i = $ > 0 ? Math.ceil(S / $) : 0;
|
|
9947
9947
|
}
|
|
9948
9948
|
let B;
|
|
9949
|
-
t?.noComputedFields || (B = await re(
|
|
9949
|
+
t?.noComputedFields || (B = await re(N.admin?.retriever));
|
|
9950
9950
|
for (const g of o.values()) {
|
|
9951
|
-
const
|
|
9952
|
-
t?.subcollections &&
|
|
9951
|
+
const T = [], S = [...g.Collection_Path, g.id];
|
|
9952
|
+
t?.subcollections && T.push(To(
|
|
9953
9953
|
s,
|
|
9954
9954
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9955
9955
|
o.get(g.id),
|
|
@@ -9963,13 +9963,13 @@ const Rt = {
|
|
|
9963
9963
|
t?.noEmbeddingFields
|
|
9964
9964
|
)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((q) => {
|
|
9965
9965
|
if (typeof q == "string") {
|
|
9966
|
-
const b =
|
|
9966
|
+
const b = x.fields.find((F) => F.name === q);
|
|
9967
9967
|
if (b)
|
|
9968
9968
|
return b;
|
|
9969
9969
|
throw new Error(`SCHEMA_ERROR: Field ${q} not found in collection ${E}`);
|
|
9970
9970
|
}
|
|
9971
9971
|
return q;
|
|
9972
|
-
})),
|
|
9972
|
+
})), T.push(Qs(
|
|
9973
9973
|
s,
|
|
9974
9974
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
9975
9975
|
o.get(g.id),
|
|
@@ -9980,11 +9980,11 @@ const Rt = {
|
|
|
9980
9980
|
t.user,
|
|
9981
9981
|
t.transactional ? c : void 0,
|
|
9982
9982
|
t?.noEmbeddingFields
|
|
9983
|
-
))), await Promise.all(
|
|
9983
|
+
))), await Promise.all(T);
|
|
9984
9984
|
const $ = [];
|
|
9985
|
-
for (const q of
|
|
9985
|
+
for (const q of x.fields) {
|
|
9986
9986
|
if (q.type === "Computed" && !t?.noComputedFields) {
|
|
9987
|
-
const b = De(q,
|
|
9987
|
+
const b = De(q, N);
|
|
9988
9988
|
if (!b.formula)
|
|
9989
9989
|
continue;
|
|
9990
9990
|
$.push(re(b.formula, [g, B]).then((F) => {
|
|
@@ -9995,19 +9995,19 @@ const Rt = {
|
|
|
9995
9995
|
}
|
|
9996
9996
|
if (await Promise.all($), t?.user && v?.Role) {
|
|
9997
9997
|
const q = v.Role;
|
|
9998
|
-
if (!(
|
|
9998
|
+
if (!(N.custom?.serverAccess?.read !== void 0 ? await re(N.custom.serverAccess.read, [q, g]) : !0)) {
|
|
9999
9999
|
o.delete(g.id);
|
|
10000
10000
|
continue;
|
|
10001
10001
|
}
|
|
10002
|
-
for (const F of
|
|
10003
|
-
const z = !F.access || F.access.includes(q), Q = De(F,
|
|
10002
|
+
for (const F of x.fields) {
|
|
10003
|
+
const z = !F.access || F.access.includes(q), Q = De(F, N), oe = Q?.custom?.serverAccess?.read !== void 0 ? await re(Q.custom.serverAccess.read, [q, g]) : !0;
|
|
10004
10004
|
(!z || !oe) && (K(F) ? (delete o.get(g.id)[F.name], delete o.get(g.id)[`${F.name}_Array`], delete o.get(g.id)[`${F.name}_Single`]) : delete o.get(g.id)[F.name]);
|
|
10005
10005
|
}
|
|
10006
10006
|
}
|
|
10007
|
-
const
|
|
10008
|
-
await ie("postOperation", p,
|
|
10007
|
+
const D = ["read", g, g.id, L];
|
|
10008
|
+
await ie("postOperation", p, N, D), await ie("postRead", p, N, [L, C, g, !1]);
|
|
10009
10009
|
}
|
|
10010
|
-
t?.user && await Jo(Array.from(o.values()),
|
|
10010
|
+
t?.user && await Jo(Array.from(o.values()), x, h, t.user, v);
|
|
10011
10011
|
};
|
|
10012
10012
|
return t?.providedTransaction ? await l(t.providedTransaction) : await r.runTransaction(async (c) => {
|
|
10013
10013
|
await l(c);
|
|
@@ -10099,8 +10099,8 @@ const Rt = {
|
|
|
10099
10099
|
const p = Object.keys(d.collections).includes(v), E = h.disabledCollections?.includes(v);
|
|
10100
10100
|
if (!p || E)
|
|
10101
10101
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10102
|
-
const O = d.collections[v], { labels:
|
|
10103
|
-
let
|
|
10102
|
+
const O = d.collections[v], { labels: R } = O, x = Qe(R.collection, d);
|
|
10103
|
+
let _;
|
|
10104
10104
|
if (t?.user) {
|
|
10105
10105
|
if (!l?.exists)
|
|
10106
10106
|
throw new Error("PERMISSION_DENIED");
|
|
@@ -10108,36 +10108,36 @@ const Rt = {
|
|
|
10108
10108
|
throw new Error("USER_ERROR");
|
|
10109
10109
|
if (!f.Enabled)
|
|
10110
10110
|
throw new Error("PERMISSION_DENIED");
|
|
10111
|
-
if (
|
|
10111
|
+
if (_ = f.collections?.[R.collection], !_)
|
|
10112
10112
|
throw new Error("PERMISSION_DENIED");
|
|
10113
10113
|
}
|
|
10114
|
-
if (t?.user && (!
|
|
10114
|
+
if (t?.user && (!_ || !Re("Read", _)))
|
|
10115
10115
|
throw new Error("PERMISSION_DENIED");
|
|
10116
|
-
const
|
|
10117
|
-
if (
|
|
10116
|
+
const N = So(s, n, e, d, f);
|
|
10117
|
+
if (N.length === 0)
|
|
10118
10118
|
throw new Error("PERMISSION_DENIED");
|
|
10119
10119
|
const C = {};
|
|
10120
|
-
await ie("preOperation", h,
|
|
10121
|
-
const y =
|
|
10120
|
+
await ie("preOperation", h, x, ["read", void 0, e, C]), await ie("preRead", h, x, [C, N, !1, !1]), i = {};
|
|
10121
|
+
const y = N.map((S) => o.get(S)), k = await Promise.all(y);
|
|
10122
10122
|
for (const S of k)
|
|
10123
10123
|
if (S.exists) {
|
|
10124
10124
|
const $ = S.data();
|
|
10125
10125
|
i.id ||= S.id, i = { ...i, ...$ }, delete i.Collection_Path_String;
|
|
10126
10126
|
} else
|
|
10127
|
-
throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") ||
|
|
10128
|
-
const
|
|
10129
|
-
if (t?.subcollections &&
|
|
10127
|
+
throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") || R.collection}`);
|
|
10128
|
+
const w = [], B = n ? [...n, e] : [R.collection, e];
|
|
10129
|
+
if (t?.subcollections && w.push(No(s, o, i, B, t.subcollections, d, void 0, t.user)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((S) => {
|
|
10130
10130
|
if (typeof S == "string") {
|
|
10131
|
-
const $ = O.fields.find((
|
|
10131
|
+
const $ = O.fields.find((D) => D.name === S);
|
|
10132
10132
|
if ($)
|
|
10133
10133
|
return $;
|
|
10134
10134
|
throw new Error(`SCHEMA_ERROR: Field ${S} not found in collection ${v}`);
|
|
10135
10135
|
}
|
|
10136
10136
|
return S;
|
|
10137
|
-
})),
|
|
10137
|
+
})), w.push(xo(s, o, i, B, d, t.relations, t.user, t.noComputedFields, t.noEmbeddingFields))), await Promise.all(w), !t?.noComputedFields) {
|
|
10138
10138
|
for (const S of O.fields)
|
|
10139
10139
|
if (S.type === "Computed") {
|
|
10140
|
-
const $ = De(S,
|
|
10140
|
+
const $ = De(S, x);
|
|
10141
10141
|
if (!$.formula)
|
|
10142
10142
|
continue;
|
|
10143
10143
|
i[S.name] = await $.formula(i);
|
|
@@ -10148,14 +10148,14 @@ const Rt = {
|
|
|
10148
10148
|
S.type === "Embedding" && delete i[S.name];
|
|
10149
10149
|
if (t?.user && f?.Role) {
|
|
10150
10150
|
const S = f.Role;
|
|
10151
|
-
if (!(
|
|
10151
|
+
if (!(x.custom?.serverAccess?.read !== void 0 ? await re(x.custom?.serverAccess?.read, [S, i]) : !0))
|
|
10152
10152
|
throw new Error("PERMISSION_DENIED");
|
|
10153
|
-
for (const
|
|
10154
|
-
const j = !
|
|
10155
|
-
(!j || !b) && (K(
|
|
10153
|
+
for (const D of O.fields) {
|
|
10154
|
+
const j = !D.access || D.access.includes(S), q = De(D, x), b = q?.custom?.serverAccess?.read !== void 0 ? await re(q.custom.serverAccess.read, [S, i]) : !0;
|
|
10155
|
+
(!j || !b) && (K(D) ? (delete i[D.name], delete i[`${D.name}_Array`], delete i[`${D.name}_Single`]) : delete i[D.name]);
|
|
10156
10156
|
}
|
|
10157
10157
|
}
|
|
10158
|
-
await ie("postOperation", h,
|
|
10158
|
+
await ie("postOperation", h, x, ["read", i, e, C]), await ie("postRead", h, x, [C, N, i, !1]), t?.user && await Yo(i, O, d, t.user, f);
|
|
10159
10159
|
};
|
|
10160
10160
|
return t?.providedTransaction ? await a(t.providedTransaction) : await r.runTransaction(async (o) => {
|
|
10161
10161
|
await a(o);
|
|
@@ -10230,19 +10230,19 @@ ${i}`);
|
|
|
10230
10230
|
n = m;
|
|
10231
10231
|
else
|
|
10232
10232
|
throw new Error("Admin email not set");
|
|
10233
|
-
const d = ds(n), f = $c(e), h = t ? Yr(t) : void 0, v = s ? Yr(s) : void 0, p = r ? ds(r) : void 0, E = i ? ds(i) : void 0, O = a ? Un(a) : void 0,
|
|
10234
|
-
if (
|
|
10233
|
+
const d = ds(n), f = $c(e), h = t ? Yr(t) : void 0, v = s ? Yr(s) : void 0, p = r ? ds(r) : void 0, E = i ? ds(i) : void 0, O = a ? Un(a) : void 0, R = l ? Un(l) : void 0, x = Array.isArray(d) ? d : [d];
|
|
10234
|
+
if (x.length === 0 || x.length === 1 && !x[0])
|
|
10235
10235
|
throw new Error("No valid email addresses provided");
|
|
10236
|
-
const
|
|
10237
|
-
if (h && (
|
|
10238
|
-
const
|
|
10239
|
-
|
|
10236
|
+
const _ = { to: d, message: { subject: f } };
|
|
10237
|
+
if (h && (_.message.text = h), v && (_.message.html = v), p) {
|
|
10238
|
+
const N = Array.isArray(p) ? p : [p];
|
|
10239
|
+
N.length > 0 && N[0] && (_.cc = p);
|
|
10240
10240
|
}
|
|
10241
10241
|
if (E) {
|
|
10242
|
-
const
|
|
10243
|
-
|
|
10242
|
+
const N = Array.isArray(E) ? E : [E];
|
|
10243
|
+
N.length > 0 && N[0] && (_.bcc = E);
|
|
10244
10244
|
}
|
|
10245
|
-
O && (
|
|
10245
|
+
O && (_.replyTo = O), o && (_.message.attachments = o), R && (_.from = R), await c.collection("system_mail").add(_);
|
|
10246
10246
|
}, Ao = async (n, e, t, s, r, i, a) => {
|
|
10247
10247
|
const o = gt(), l = ce(), c = "USER_ERROR", u = async (f, h) => {
|
|
10248
10248
|
try {
|
|
@@ -10347,7 +10347,7 @@ ${i}`);
|
|
|
10347
10347
|
return t.includeFields.forEach((r) => {
|
|
10348
10348
|
if (e[r] !== void 0) {
|
|
10349
10349
|
s[r] = e[r];
|
|
10350
|
-
const i =
|
|
10350
|
+
const i = W(n.fields, r);
|
|
10351
10351
|
wt(n, [i]).size === 1 && (s[`${r}_Lowercase`] = e[`${r}_Lowercase`]);
|
|
10352
10352
|
}
|
|
10353
10353
|
}), s;
|
|
@@ -10368,7 +10368,7 @@ ${i}`);
|
|
|
10368
10368
|
const f = await r.get(d.doc(u));
|
|
10369
10369
|
if (!f.exists)
|
|
10370
10370
|
throw new Error(`VALIDATION_ERROR: Record ${u} not found in collection ${t.collection}`);
|
|
10371
|
-
const h = f.data(), v =
|
|
10371
|
+
const h = f.data(), v = W(o, t.enforceHierarchy.field), p = t.enforceHierarchy;
|
|
10372
10372
|
if (!h[p.recordLinkField] || !s[v.name] || !Object.keys(s[v.name]).every((E) => Object.keys(h[p.recordLinkField]).includes(E)))
|
|
10373
10373
|
throw new Error("VALIDATION_ERROR: Invalid relation hierarchy");
|
|
10374
10374
|
}, gn = async (n, e, t) => {
|
|
@@ -10386,19 +10386,19 @@ ${i}`);
|
|
|
10386
10386
|
K(E) && ["OneToOne", "OneToMany"].includes(E.type) && E.enforceHierarchy && s[E.name] && (n === "Create" || n === "Update" && !qe(m?.[E.name], s[E.name])) && await Qr(e, i, E, s, o, l);
|
|
10387
10387
|
for (const E of d)
|
|
10388
10388
|
if (K(E) && E.twoWay) {
|
|
10389
|
-
const O = a.collections[E.collection],
|
|
10389
|
+
const O = a.collections[E.collection], R = W(O.fields, E.twoWay), x = ft(O, [R]);
|
|
10390
10390
|
if (s[E.name]) {
|
|
10391
|
-
const
|
|
10392
|
-
for (const
|
|
10393
|
-
const [C,
|
|
10391
|
+
const _ = Object.entries(s[E.name]);
|
|
10392
|
+
for (const N of _) {
|
|
10393
|
+
const [C, L] = N;
|
|
10394
10394
|
if (n === "Create" || !m?.[E.name]?.[C]) {
|
|
10395
|
-
let
|
|
10395
|
+
let I;
|
|
10396
10396
|
const y = p.get(E.collection)?.[C];
|
|
10397
10397
|
if (y)
|
|
10398
|
-
|
|
10398
|
+
I = y;
|
|
10399
10399
|
else {
|
|
10400
10400
|
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.`));
|
|
10401
|
-
const
|
|
10401
|
+
const w = Ae(f, L.Collection_Path, e), B = await o.get(w.doc(C));
|
|
10402
10402
|
if (!B.exists) {
|
|
10403
10403
|
gn(E, r, C);
|
|
10404
10404
|
continue;
|
|
@@ -10407,73 +10407,73 @@ ${i}`);
|
|
|
10407
10407
|
v.set(E.collection, {
|
|
10408
10408
|
...v.get(E.collection) || {},
|
|
10409
10409
|
[C]: g
|
|
10410
|
-
}),
|
|
10410
|
+
}), I = ye({ ...g, ...Sn(s) });
|
|
10411
10411
|
}
|
|
10412
10412
|
const k = {
|
|
10413
|
-
...
|
|
10413
|
+
...I[R.name],
|
|
10414
10414
|
[t]: {
|
|
10415
10415
|
Collection_Path: s.Collection_Path,
|
|
10416
|
-
...Pc(i, s,
|
|
10416
|
+
...Pc(i, s, R)
|
|
10417
10417
|
}
|
|
10418
10418
|
};
|
|
10419
|
-
|
|
10419
|
+
I[R.name] = k, I[`${R.name}_Array`] ||= [], I[`${R.name}_Array`].push(t), x.size === 1 && (I[`${R.name}_Single`] = k), p.set(E.collection, {
|
|
10420
10420
|
...p.get(E.collection) || {},
|
|
10421
|
-
[C]:
|
|
10421
|
+
[C]: I
|
|
10422
10422
|
});
|
|
10423
10423
|
}
|
|
10424
10424
|
}
|
|
10425
10425
|
}
|
|
10426
10426
|
if (n === "Update") {
|
|
10427
|
-
const
|
|
10428
|
-
for (const
|
|
10429
|
-
const [C,
|
|
10427
|
+
const _ = Object.entries(m?.[E.name] || {});
|
|
10428
|
+
for (const N of _) {
|
|
10429
|
+
const [C, L] = N;
|
|
10430
10430
|
if (!s[E.name]?.[C]) {
|
|
10431
|
-
let
|
|
10431
|
+
let I;
|
|
10432
10432
|
const y = p.get(E.collection)?.[C];
|
|
10433
10433
|
if (y)
|
|
10434
|
-
|
|
10434
|
+
I = y;
|
|
10435
10435
|
else {
|
|
10436
10436
|
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.`));
|
|
10437
|
-
const k = Ae(f,
|
|
10438
|
-
if (!
|
|
10437
|
+
const k = Ae(f, L.Collection_Path, e), w = await o.get(k.doc(C));
|
|
10438
|
+
if (!w.exists) {
|
|
10439
10439
|
h.set(E.name, [...h.get(E.name) || [], C]);
|
|
10440
10440
|
continue;
|
|
10441
10441
|
}
|
|
10442
|
-
const B =
|
|
10442
|
+
const B = w.data();
|
|
10443
10443
|
v.set(E.collection, {
|
|
10444
10444
|
...v.get(E.collection) || {},
|
|
10445
10445
|
[C]: B
|
|
10446
|
-
}),
|
|
10446
|
+
}), I = ye({ ...B, ...Sn(s) });
|
|
10447
10447
|
}
|
|
10448
|
-
|
|
10448
|
+
I[R.name][t] && delete I[R.name][t], Array.isArray(I[`${R.name}_Array`]) && (I[`${R.name}_Array`] = I[`${R.name}_Array`].filter((k) => k !== t)), x.size === 1 && delete I[`${R.name}_Single`], p.set(E.collection, {
|
|
10449
10449
|
...p.get(E.collection) || {},
|
|
10450
|
-
[C]:
|
|
10450
|
+
[C]: I
|
|
10451
10451
|
});
|
|
10452
10452
|
}
|
|
10453
10453
|
}
|
|
10454
10454
|
}
|
|
10455
10455
|
}
|
|
10456
10456
|
for (const [E, O] of p.entries()) {
|
|
10457
|
-
const
|
|
10458
|
-
for (const [
|
|
10459
|
-
const { addedFields: C, removedFields:
|
|
10457
|
+
const R = a.collections[E], x = Qe(E, a);
|
|
10458
|
+
for (const [_, N] of Object.entries(O)) {
|
|
10459
|
+
const { addedFields: C, removedFields: L } = Lc(n, _, E, i, s, m);
|
|
10460
10460
|
if (c && u) {
|
|
10461
|
-
for (const
|
|
10462
|
-
const y =
|
|
10463
|
-
if (!tr(
|
|
10464
|
-
gn(
|
|
10461
|
+
for (const I of C) {
|
|
10462
|
+
const y = W(R.fields, I.twoWay);
|
|
10463
|
+
if (!tr(R, y, u)) {
|
|
10464
|
+
gn(I, r, _);
|
|
10465
10465
|
continue;
|
|
10466
10466
|
}
|
|
10467
10467
|
}
|
|
10468
|
-
for (const
|
|
10469
|
-
const y =
|
|
10470
|
-
if (!tr(
|
|
10468
|
+
for (const I of L) {
|
|
10469
|
+
const y = W(R.fields, I.twoWay), k = ft(R, [y]);
|
|
10470
|
+
if (!tr(R, y, u)) {
|
|
10471
10471
|
ms(
|
|
10472
|
-
|
|
10472
|
+
I,
|
|
10473
10473
|
r,
|
|
10474
10474
|
// eslint-disable-next-line security/detect-object-injection
|
|
10475
|
-
m?.[
|
|
10476
|
-
|
|
10475
|
+
m?.[I.name]?.[_],
|
|
10476
|
+
_,
|
|
10477
10477
|
k.size === 1
|
|
10478
10478
|
);
|
|
10479
10479
|
continue;
|
|
@@ -10481,51 +10481,51 @@ ${i}`);
|
|
|
10481
10481
|
}
|
|
10482
10482
|
if (!it(
|
|
10483
10483
|
"Update",
|
|
10484
|
-
|
|
10484
|
+
R,
|
|
10485
10485
|
a,
|
|
10486
10486
|
c,
|
|
10487
10487
|
u,
|
|
10488
10488
|
// eslint-disable-next-line security/detect-object-injection
|
|
10489
|
-
v.get(E)?.[
|
|
10489
|
+
v.get(E)?.[_]
|
|
10490
10490
|
)) {
|
|
10491
|
-
for (const
|
|
10492
|
-
gn(
|
|
10493
|
-
for (const
|
|
10494
|
-
const y =
|
|
10491
|
+
for (const I of C)
|
|
10492
|
+
gn(I, r, _);
|
|
10493
|
+
for (const I of L) {
|
|
10494
|
+
const y = W(R.fields, I.twoWay), k = ft(R, [y]);
|
|
10495
10495
|
ms(
|
|
10496
|
-
|
|
10496
|
+
I,
|
|
10497
10497
|
r,
|
|
10498
10498
|
// eslint-disable-next-line security/detect-object-injection
|
|
10499
|
-
m?.[
|
|
10500
|
-
|
|
10499
|
+
m?.[I.name]?.[_],
|
|
10500
|
+
_,
|
|
10501
10501
|
k.size === 1
|
|
10502
10502
|
);
|
|
10503
10503
|
}
|
|
10504
10504
|
}
|
|
10505
|
-
if (!it("Update",
|
|
10506
|
-
for (const
|
|
10507
|
-
gn(
|
|
10508
|
-
for (const
|
|
10509
|
-
const y =
|
|
10505
|
+
if (!it("Update", R, a, c, u, N)) {
|
|
10506
|
+
for (const I of C)
|
|
10507
|
+
gn(I, r, _);
|
|
10508
|
+
for (const I of L) {
|
|
10509
|
+
const y = W(R.fields, I.twoWay), k = ft(R, [y]);
|
|
10510
10510
|
ms(
|
|
10511
|
-
|
|
10511
|
+
I,
|
|
10512
10512
|
r,
|
|
10513
10513
|
// eslint-disable-next-line security/detect-object-injection
|
|
10514
|
-
m?.[
|
|
10515
|
-
|
|
10514
|
+
m?.[I.name]?.[_],
|
|
10515
|
+
_,
|
|
10516
10516
|
k.size === 1
|
|
10517
10517
|
);
|
|
10518
10518
|
}
|
|
10519
10519
|
}
|
|
10520
10520
|
}
|
|
10521
10521
|
try {
|
|
10522
|
-
await nn("update",
|
|
10523
|
-
} catch (
|
|
10524
|
-
throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${
|
|
10522
|
+
await nn("update", N, R, x, ["update", N, {}, void 0, N], a);
|
|
10523
|
+
} catch (I) {
|
|
10524
|
+
throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${_} in ${E}: ${I.message}`);
|
|
10525
10525
|
}
|
|
10526
|
-
for (const
|
|
10527
|
-
const y =
|
|
10528
|
-
["OneToOne", "OneToMany"].includes(y.type) && K(y) && y.enforceHierarchy && await Qr(e,
|
|
10526
|
+
for (const I of C) {
|
|
10527
|
+
const y = W(R.fields, I.twoWay);
|
|
10528
|
+
["OneToOne", "OneToMany"].includes(y.type) && K(y) && y.enforceHierarchy && await Qr(e, R, y, N, o, l, !0);
|
|
10529
10529
|
}
|
|
10530
10530
|
}
|
|
10531
10531
|
}
|
|
@@ -10597,27 +10597,27 @@ ${i}`);
|
|
|
10597
10597
|
}
|
|
10598
10598
|
}
|
|
10599
10599
|
if (l.parentEntities) {
|
|
10600
|
-
const h = c.entityRestrictions?.restrictions?.find((
|
|
10600
|
+
const h = c.entityRestrictions?.restrictions?.find((x) => x.type === "Parent" && x.roles.some((_) => _.role === e.Role));
|
|
10601
10601
|
if (!h)
|
|
10602
10602
|
throw new Error("PERMISSION_DENIED");
|
|
10603
|
-
const v =
|
|
10604
|
-
for (const
|
|
10603
|
+
const v = W(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentEntities, O = d?.parentEntities || [], R = i ? E.filter((x) => !O.includes(x)) : E;
|
|
10604
|
+
for (const x of R) {
|
|
10605
10605
|
if (a && a.size++, a && a.size > 500)
|
|
10606
10606
|
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).");
|
|
10607
10607
|
f.push(async () => {
|
|
10608
|
-
if (!await ps(n, p,
|
|
10608
|
+
if (!await ps(n, p, x, t, s))
|
|
10609
10609
|
throw new Error("PERMISSION_DENIED");
|
|
10610
10610
|
});
|
|
10611
10611
|
}
|
|
10612
10612
|
}
|
|
10613
10613
|
if (l.parentPropertyEntities) {
|
|
10614
|
-
const h = c.entityRestrictions?.restrictions?.find((
|
|
10614
|
+
const h = c.entityRestrictions?.restrictions?.find((R) => R.type === "Parent_Property" && R.roles.some((x) => x.role === e.Role));
|
|
10615
10615
|
if (!h)
|
|
10616
10616
|
throw new Error("PERMISSION_DENIED");
|
|
10617
|
-
const v =
|
|
10618
|
-
for (const [
|
|
10619
|
-
const
|
|
10620
|
-
for (const C of
|
|
10617
|
+
const v = W(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentPropertyEntities, O = d?.parentPropertyEntities || {};
|
|
10618
|
+
for (const [R, x] of Object.entries(E)) {
|
|
10619
|
+
const _ = O[R] || [], N = i ? x.filter((C) => !_.includes(C)) : x;
|
|
10620
|
+
for (const C of N) {
|
|
10621
10621
|
if (a && a.size++, a && a.size > 500)
|
|
10622
10622
|
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).");
|
|
10623
10623
|
f.push(async () => {
|
|
@@ -10642,48 +10642,48 @@ ${i}`);
|
|
|
10642
10642
|
const u = n.at(-1), m = Object.keys(c.collections).includes(u), d = l.disabledCollections?.includes(u);
|
|
10643
10643
|
if (!m || d)
|
|
10644
10644
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10645
|
-
const f = c.collections[u], { labels: h, fields: v, enableWriteLog: p, softDelete: E } = f, O = Qe(h.collection, c),
|
|
10646
|
-
let
|
|
10645
|
+
const f = c.collections[u], { labels: h, fields: v, enableWriteLog: p, softDelete: E } = f, O = Qe(h.collection, c), R = await re(l.appName), x = ce(), _ = gt(), C = (s ? await _.getUser(s) : void 0)?.customClaims?.role;
|
|
10646
|
+
let L;
|
|
10647
10647
|
s && await Ks(n, f);
|
|
10648
|
-
const
|
|
10648
|
+
const I = Ae(x, n, o), y = a || I.doc().id;
|
|
10649
10649
|
i = i || {}, i.collection = h.collection, e.id = y, Co(e), Xs(e);
|
|
10650
|
-
const k = Vs("create", n, e, c,
|
|
10650
|
+
const k = Vs("create", n, e, c, R, "Online", s || "System", lt.now(), me.serverTimestamp());
|
|
10651
10651
|
r?.createdAt && (k.Created_At = r.createdAt), r?.createdBy && (k.Created_By = r.createdBy);
|
|
10652
|
-
const
|
|
10652
|
+
const w = ye(k);
|
|
10653
10653
|
E && (k[E.archivedField] = !1), Ue(e), p && !r?.providedTransaction && await Ft("create", "started", k, o, n, y, f), await ie("preOperation", l, O, ["create", k, y, i]), await ie("preWrite", l, O, ["create", k, y, i]), Tn(f, k, c), Rn(f, k), await sa(k, f, O, C), Ue(k);
|
|
10654
10654
|
try {
|
|
10655
10655
|
if (f.auth && t && !t.password)
|
|
10656
10656
|
throw new Error("Password is required");
|
|
10657
10657
|
r?.providedTransaction || (await Io("create", o, y, k, f, c), await nn("create", k, f, O, ["create", k, i], c));
|
|
10658
|
-
} catch (
|
|
10659
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10658
|
+
} catch (D) {
|
|
10659
|
+
throw new Error(`VALIDATION_ERROR: ${D.message}`);
|
|
10660
10660
|
}
|
|
10661
10661
|
Ue(k), e.id = y, E && (k[E.archivedField] = !1), Tn(f, k, c), Rn(f, k);
|
|
10662
10662
|
try {
|
|
10663
|
-
Mo("create", k,
|
|
10664
|
-
} catch (
|
|
10665
|
-
throw new Error(`VALIDATION_ERROR: ${
|
|
10663
|
+
Mo("create", k, w), Fo("create", f, k), await nn("create", k, f, O, ["create", k, i], c);
|
|
10664
|
+
} catch (D) {
|
|
10665
|
+
throw new Error(`VALIDATION_ERROR: ${D.message}`);
|
|
10666
10666
|
}
|
|
10667
10667
|
if (s) {
|
|
10668
|
-
const
|
|
10669
|
-
if (!
|
|
10668
|
+
const D = C;
|
|
10669
|
+
if (!D)
|
|
10670
10670
|
throw new Error("USER_ERROR");
|
|
10671
|
-
if (!(O.custom?.serverAccess?.create !== void 0 ? await re(O.custom.serverAccess.create, [
|
|
10671
|
+
if (!(O.custom?.serverAccess?.create !== void 0 ? await re(O.custom.serverAccess.create, [D, k]) : !0))
|
|
10672
10672
|
throw new Error("PERMISSION_DENIED");
|
|
10673
10673
|
for (const q of f.fields) {
|
|
10674
10674
|
if (!(q.name in k))
|
|
10675
10675
|
continue;
|
|
10676
10676
|
const b = De(q, O);
|
|
10677
|
-
if (b?.custom?.serverAccess?.create !== void 0 && !await re(b.custom.serverAccess.create, [
|
|
10677
|
+
if (b?.custom?.serverAccess?.create !== void 0 && !await re(b.custom.serverAccess.create, [D, k]))
|
|
10678
10678
|
throw new Error("PERMISSION_DENIED");
|
|
10679
10679
|
}
|
|
10680
10680
|
}
|
|
10681
10681
|
t && (t.permissions ||= {}, t.permissions.Role ||= k.Role, t.permissions.Enabled ||= k.Enabled);
|
|
10682
|
-
const
|
|
10682
|
+
const T = async (D, j) => {
|
|
10683
10683
|
const [q, b, F, z] = await Promise.all([
|
|
10684
|
-
r?.providedTransaction ? Promise.resolve({}) :
|
|
10685
|
-
r?.providedTransaction ? Promise.resolve({}) :
|
|
10686
|
-
s ?
|
|
10684
|
+
r?.providedTransaction ? Promise.resolve({}) : D.get(x.collection("system_deployment").doc("latest_deploy")),
|
|
10685
|
+
r?.providedTransaction ? Promise.resolve({}) : D.get(x.collection("system_deployment").doc("maintenance_mode")),
|
|
10686
|
+
s ? D.get(x.collection("tenants").doc(o).collection("system_user_permissions").doc(s)) : Promise.resolve({}),
|
|
10687
10687
|
r?.providedSchema ? Promise.resolve(r.providedSchema) : Ye()
|
|
10688
10688
|
]);
|
|
10689
10689
|
if (j && (j.size += 3), !r?.providedTransaction) {
|
|
@@ -10700,19 +10700,19 @@ ${i}`);
|
|
|
10700
10700
|
if (c = z, s) {
|
|
10701
10701
|
if (!F?.exists)
|
|
10702
10702
|
throw new Error("PERMISSION_DENIED");
|
|
10703
|
-
if (
|
|
10703
|
+
if (L = F.data(), !L.Role)
|
|
10704
10704
|
throw new Error("USER_ERROR");
|
|
10705
|
-
if (!
|
|
10705
|
+
if (!L.Enabled)
|
|
10706
10706
|
throw new Error("PERMISSION_DENIED");
|
|
10707
10707
|
}
|
|
10708
10708
|
if (!r?.providedTransaction) {
|
|
10709
10709
|
const oe = v.filter((ue) => "unique" in ue && ue.unique).map(async (ue) => {
|
|
10710
|
-
if (!s || !ue.access || ue.access.includes(
|
|
10710
|
+
if (!s || !ue.access || ue.access.includes(L.Role)) {
|
|
10711
10711
|
if (!e[ue.name])
|
|
10712
10712
|
return;
|
|
10713
10713
|
const he = De(ue, O);
|
|
10714
10714
|
if (!(s && he?.custom?.serverAccess?.read !== void 0 ? await re(he.custom.serverAccess.read, [
|
|
10715
|
-
|
|
10715
|
+
L?.Role,
|
|
10716
10716
|
k
|
|
10717
10717
|
]) : !0))
|
|
10718
10718
|
throw new Error("PERMISSION_DENIED");
|
|
@@ -10720,7 +10720,7 @@ ${i}`);
|
|
|
10720
10720
|
if (Js(pe)) {
|
|
10721
10721
|
if (j && j.size++, j && j.size > 500)
|
|
10722
10722
|
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.");
|
|
10723
|
-
if ((await
|
|
10723
|
+
if ((await D.get(x.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${ue.name}`).doc(pe)))?.exists)
|
|
10724
10724
|
throw new Error(`VALIDATION_ERROR: ${ue.name} "${k[ue.name]}" already exists`);
|
|
10725
10725
|
} else
|
|
10726
10726
|
throw new Error(`VALIDATION_ERROR: ${ue.name} "${k[ue.name]}" is invalid`);
|
|
@@ -10728,13 +10728,13 @@ ${i}`);
|
|
|
10728
10728
|
});
|
|
10729
10729
|
await Promise.all(oe);
|
|
10730
10730
|
}
|
|
10731
|
-
nr(k, y, f, c, s,
|
|
10731
|
+
nr(k, y, f, c, s, L, t?.permissions), t?.permissions && s && L && await Po(D, t.permissions, s, L, c), nr(k, y, f, c, s, L, t?.permissions);
|
|
10732
10732
|
};
|
|
10733
10733
|
if (f.auth && t) {
|
|
10734
|
-
await
|
|
10735
|
-
await
|
|
10734
|
+
await x.runTransaction(async (j) => {
|
|
10735
|
+
await T(j);
|
|
10736
10736
|
}, { maxAttempts: 10 });
|
|
10737
|
-
const
|
|
10737
|
+
const D = await Ao(
|
|
10738
10738
|
o,
|
|
10739
10739
|
y,
|
|
10740
10740
|
l,
|
|
@@ -10744,14 +10744,14 @@ ${i}`);
|
|
|
10744
10744
|
t.permissions,
|
|
10745
10745
|
t.password
|
|
10746
10746
|
);
|
|
10747
|
-
k.User_ID =
|
|
10747
|
+
k.User_ID = D;
|
|
10748
10748
|
}
|
|
10749
|
-
const S = async (
|
|
10749
|
+
const S = async (D) => {
|
|
10750
10750
|
try {
|
|
10751
10751
|
const j = { size: 1 };
|
|
10752
|
-
await
|
|
10752
|
+
await T(D, j), r?.noTwoWay || await $o("Create", o, y, k, k, f, c, D, j, s, L);
|
|
10753
10753
|
const q = Ls(c);
|
|
10754
|
-
Ys("create",
|
|
10754
|
+
Ys("create", D, n, y, k, c, f, r, q, me.arrayUnion, me.arrayRemove, me.delete, (b) => x.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b.name}`).doc(y), (b, F) => x.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${b.name}`).doc(F), (b) => x.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b}`).doc(y), (b, F) => Ae(x, b, o).doc(F), (b, F, z) => x.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F}`).doc(z), (b, F, z) => x.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F.replaceAll(" ", "-")}`).doc(z), void 0, void 0, j), D.set(I.doc(y), k);
|
|
10755
10755
|
} catch (j) {
|
|
10756
10756
|
if (r?.providedTransaction)
|
|
10757
10757
|
throw j;
|
|
@@ -10764,11 +10764,11 @@ ${i}`);
|
|
|
10764
10764
|
}
|
|
10765
10765
|
}
|
|
10766
10766
|
};
|
|
10767
|
-
if (r?.providedTransaction ? await S(r.providedTransaction) : await
|
|
10768
|
-
await S(
|
|
10767
|
+
if (r?.providedTransaction ? await S(r.providedTransaction) : await x.runTransaction(async (D) => {
|
|
10768
|
+
await S(D);
|
|
10769
10769
|
}, { maxAttempts: 10 }), !r?.providedTransaction) {
|
|
10770
|
-
const
|
|
10771
|
-
await ie("postWrite", l, O,
|
|
10770
|
+
const D = ["create", k, y, i], j = [...D];
|
|
10771
|
+
await ie("postWrite", l, O, D), await ie("postOperation", l, O, j);
|
|
10772
10772
|
}
|
|
10773
10773
|
return { id: y, ...k };
|
|
10774
10774
|
}, Jt = async (n, e, t, s) => {
|
|
@@ -10855,16 +10855,16 @@ ${i}`);
|
|
|
10855
10855
|
throw new Error("Error generating email verification link");
|
|
10856
10856
|
});
|
|
10857
10857
|
if (O.includes("apiKey=&")) {
|
|
10858
|
-
const
|
|
10859
|
-
O = O.replace("apiKey=&", `apiKey=${
|
|
10858
|
+
const R = JSON.parse(process.env.STOKER_FB_WEB_APP_CONFIG);
|
|
10859
|
+
O = O.replace("apiKey=&", `apiKey=${R.apiKey}&`);
|
|
10860
10860
|
}
|
|
10861
10861
|
if (O) {
|
|
10862
|
-
const
|
|
10862
|
+
const R = `https://${m.app.options.projectId}.firebaseapp.com/__/auth/action${O}`, x = await re(s.appName), _ = s?.mail?.emailVerification && s.mail.emailVerification(R, x);
|
|
10863
10863
|
try {
|
|
10864
|
-
await Do(i.Email,
|
|
10864
|
+
await Do(i.Email, _?.subject || "Please verify your email address", void 0, _?.html || `Please verify your email address by clicking the link:
|
|
10865
10865
|
</br>
|
|
10866
10866
|
</br>
|
|
10867
|
-
<a href="${
|
|
10867
|
+
<a href="${R}">${R}</a>`);
|
|
10868
10868
|
} catch {
|
|
10869
10869
|
throw await Jt(a.User_ID, o, c, h), new Error(h);
|
|
10870
10870
|
}
|
|
@@ -10914,10 +10914,10 @@ ${i}`);
|
|
|
10914
10914
|
const m = n.at(-1), d = Object.keys(u.collections).includes(m), f = c.disabledCollections?.includes(m);
|
|
10915
10915
|
if (!d || f)
|
|
10916
10916
|
throw new Error("COLLECTION_NOT_FOUND");
|
|
10917
|
-
const h = u.collections[m], { labels: v, fields: p, enableWriteLog: E } = h, O = Qe(v.collection, u),
|
|
10918
|
-
let
|
|
10917
|
+
const h = u.collections[m], { labels: v, fields: p, enableWriteLog: E } = h, O = Qe(v.collection, u), R = await re(c.appName), x = gt(), _ = ce();
|
|
10918
|
+
let N;
|
|
10919
10919
|
r && await Ks(n, h);
|
|
10920
|
-
const C = Ae(
|
|
10920
|
+
const C = Ae(_, n, l);
|
|
10921
10921
|
a = a || {}, a.collection = v.collection, o = o || await at(n, e, {
|
|
10922
10922
|
user: r,
|
|
10923
10923
|
noComputedFields: !0,
|
|
@@ -10940,39 +10940,39 @@ ${i}`);
|
|
|
10940
10940
|
throw new Error("VALIDATION_ERROR: User operations are only permitted for auth collections");
|
|
10941
10941
|
if (s?.operation === "delete" && s.permissions)
|
|
10942
10942
|
throw new Error("VALIDATION_ERROR: Permissions are not allowed for delete operations");
|
|
10943
|
-
const
|
|
10943
|
+
const L = h.auth && s?.operation === "create", I = h.auth && s?.operation === "delete", y = h.auth && !L && !I && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), k = (b) => b.User_ID && (h.auth && !L && !I && s?.operation === "update" || t.Role && t.Role !== b.Role || t.Enabled !== void 0 && t.Enabled !== b.Enabled || t.Name && t.Name !== b.Name || t.Email && t.Email !== b.Email || t.Photo_URL && t.Photo_URL !== b.Photo_URL);
|
|
10944
10944
|
delete t.id, Co(t), Xs(t);
|
|
10945
|
-
const
|
|
10945
|
+
const w = Vs("update", n, t, u, R, "Online", r || "System", lt.now(), me.serverTimestamp()), B = ye(w);
|
|
10946
10946
|
for (const b of p)
|
|
10947
|
-
!K(b) && Fe(
|
|
10948
|
-
Ue(
|
|
10947
|
+
!K(b) && Fe(w[b.name]) && b.nullable && (w[b.name] = null);
|
|
10948
|
+
Ue(w), Ue(o), E && !i?.providedTransaction && await Ft("update", "started", w, l, n, e, h, void 0, o);
|
|
10949
10949
|
const g = [
|
|
10950
10950
|
"update",
|
|
10951
|
-
|
|
10951
|
+
w,
|
|
10952
10952
|
e,
|
|
10953
10953
|
a,
|
|
10954
10954
|
void 0,
|
|
10955
10955
|
ye(o)
|
|
10956
10956
|
];
|
|
10957
10957
|
await ie("preOperation", c, O, g);
|
|
10958
|
-
const
|
|
10959
|
-
await ie("preWrite", c, O,
|
|
10958
|
+
const T = ["update", w, e, a, void 0, ye(o)];
|
|
10959
|
+
await ie("preWrite", c, O, T), Tn(h, w, u), Rn(h, w), Ue(w);
|
|
10960
10960
|
try {
|
|
10961
|
-
if (
|
|
10961
|
+
if (L && !s.password)
|
|
10962
10962
|
throw new Error("Password is required");
|
|
10963
10963
|
if (!i?.providedTransaction) {
|
|
10964
|
-
const b = { ...o, ...
|
|
10965
|
-
await Io("update", l, e, b, h, u), nt(b), await nn("update", b, h, O, ["update",
|
|
10964
|
+
const b = { ...o, ...w };
|
|
10965
|
+
await Io("update", l, e, b, h, u), nt(b), await nn("update", b, h, O, ["update", w, a, void 0, ye(o)], u);
|
|
10966
10966
|
}
|
|
10967
10967
|
} catch (b) {
|
|
10968
10968
|
throw new Error(`VALIDATION_ERROR: ${b.message}`);
|
|
10969
10969
|
}
|
|
10970
|
-
Ue(
|
|
10970
|
+
Ue(w), delete t.id, Tn(h, w, u), Rn(h, w);
|
|
10971
10971
|
for (const b of p)
|
|
10972
|
-
!K(b) && Fe(
|
|
10972
|
+
!K(b) && Fe(w[b.name]) && b.nullable && (w[b.name] = null);
|
|
10973
10973
|
try {
|
|
10974
|
-
const b = { ...o, ...
|
|
10975
|
-
nt(b), Fo("update", h,
|
|
10974
|
+
const b = { ...o, ...w };
|
|
10975
|
+
nt(b), Fo("update", h, w, o), Mo("update", w, B), await nn("update", b, h, O, ["update", w, a, void 0, o], u);
|
|
10976
10976
|
} catch (b) {
|
|
10977
10977
|
throw new Error(`VALIDATION_ERROR: ${b.message}`);
|
|
10978
10978
|
}
|
|
@@ -10980,21 +10980,21 @@ ${i}`);
|
|
|
10980
10980
|
s && (s.permissions ||= {});
|
|
10981
10981
|
const $ = async (b, F, z) => {
|
|
10982
10982
|
const [Q, oe, ue, he, Ve] = await Promise.all([
|
|
10983
|
-
i?.providedTransaction ? Promise.resolve({}) : b.get(
|
|
10984
|
-
i?.providedTransaction ? Promise.resolve({}) : b.get(
|
|
10983
|
+
i?.providedTransaction ? Promise.resolve({}) : b.get(_.collection("system_deployment").doc("latest_deploy")),
|
|
10984
|
+
i?.providedTransaction ? Promise.resolve({}) : b.get(_.collection("system_deployment").doc("maintenance_mode")),
|
|
10985
10985
|
i?.providedTransaction ? Promise.resolve(o) : at(n, e, {
|
|
10986
10986
|
user: r,
|
|
10987
10987
|
providedTransaction: b,
|
|
10988
10988
|
noComputedFields: !0
|
|
10989
10989
|
}),
|
|
10990
|
-
r ? b.get(
|
|
10990
|
+
r ? b.get(_.collection("tenants").doc(l).collection("system_user_permissions").doc(r)) : Promise.resolve({}),
|
|
10991
10991
|
i?.providedSchema ? Promise.resolve(i.providedSchema) : Ye()
|
|
10992
10992
|
]);
|
|
10993
10993
|
if (z && (z.size += 3), !i?.providedTransaction) {
|
|
10994
10994
|
if (!Q.exists)
|
|
10995
10995
|
throw new Error("VERSION_ERROR");
|
|
10996
10996
|
const pe = Q.data();
|
|
10997
|
-
if (pe.force &&
|
|
10997
|
+
if (pe.force && w.Last_Write_At.valueOf() < pe.time.valueOf())
|
|
10998
10998
|
throw new Error("VERSION_ERROR");
|
|
10999
10999
|
if (!oe.exists)
|
|
11000
11000
|
throw new Error("MAINTENANCE_MODE");
|
|
@@ -11006,19 +11006,19 @@ ${i}`);
|
|
|
11006
11006
|
if (o = ue, u = Ve, r) {
|
|
11007
11007
|
if (!he?.exists)
|
|
11008
11008
|
throw new Error("PERMISSION_DENIED");
|
|
11009
|
-
if (
|
|
11009
|
+
if (N = he.data(), !N.Role)
|
|
11010
11010
|
throw new Error("USER_ERROR");
|
|
11011
|
-
if (!
|
|
11011
|
+
if (!N.Enabled)
|
|
11012
11012
|
throw new Error("PERMISSION_DENIED");
|
|
11013
11013
|
}
|
|
11014
|
-
if (z && (z.size += So(l, n, e, u,
|
|
11014
|
+
if (z && (z.size += So(l, n, e, u, N).length), L && o.User_ID || I && !o.User_ID)
|
|
11015
11015
|
throw new Error("USER_ERROR");
|
|
11016
11016
|
if (k(o)) {
|
|
11017
|
-
const pe = await b.get(
|
|
11017
|
+
const pe = await b.get(_.collection("tenants").doc(l).collection("system_user_permissions").doc(o.User_ID));
|
|
11018
11018
|
if (z && z.size++, !pe?.exists)
|
|
11019
11019
|
throw new Error("PERMISSION_DENIED");
|
|
11020
11020
|
if (S = pe.data(), s?.permissions) {
|
|
11021
|
-
if (s.permissions.Role ||=
|
|
11021
|
+
if (s.permissions.Role ||= w.Role || o.Role, s.permissions.Enabled ??= w.Enabled ?? o.Enabled, Fe(s.permissions.Role))
|
|
11022
11022
|
throw new Error("VALIDATION_ERROR: Role field is required");
|
|
11023
11023
|
if (Fe(s.permissions.Enabled))
|
|
11024
11024
|
throw new Error("VALIDATION_ERROR: Enabled field is required");
|
|
@@ -11026,35 +11026,35 @@ ${i}`);
|
|
|
11026
11026
|
}
|
|
11027
11027
|
if (!i?.providedTransaction) {
|
|
11028
11028
|
const vt = p.filter((Ee) => "unique" in Ee && Ee.unique).map(async (Ee) => {
|
|
11029
|
-
if (!r || !Ee.access || Ee.access.includes(
|
|
11030
|
-
if (
|
|
11029
|
+
if (!r || !Ee.access || Ee.access.includes(N.Role)) {
|
|
11030
|
+
if (w[Ee.name] === void 0 || Fe(w[Ee.name]))
|
|
11031
11031
|
return;
|
|
11032
|
-
const jt = De(Ee, O), un = { ...o, ...
|
|
11032
|
+
const jt = De(Ee, O), un = { ...o, ...w };
|
|
11033
11033
|
if (!(r && jt?.custom?.serverAccess?.read !== void 0 ? await re(jt.custom.serverAccess.read, [
|
|
11034
|
-
|
|
11034
|
+
N?.Role,
|
|
11035
11035
|
un
|
|
11036
11036
|
]) : !0))
|
|
11037
11037
|
throw new Error("PERMISSION_DENIED");
|
|
11038
|
-
const Jn =
|
|
11038
|
+
const Jn = w[Ee.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
|
|
11039
11039
|
if (Js(Jn)) {
|
|
11040
11040
|
if (z && z.size++, z && z.size > 500)
|
|
11041
11041
|
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.");
|
|
11042
|
-
const er = await b.get(
|
|
11042
|
+
const er = await b.get(_.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${Ee.name}`).doc(Jn));
|
|
11043
11043
|
if (er.exists && er.data().id !== e)
|
|
11044
|
-
throw new Error(`VALIDATION_ERROR: ${Ee.name} "${
|
|
11044
|
+
throw new Error(`VALIDATION_ERROR: ${Ee.name} "${w[Ee.name]}" already exists`);
|
|
11045
11045
|
} else
|
|
11046
|
-
throw new Error(`VALIDATION_ERROR: ${Ee.name} "${
|
|
11046
|
+
throw new Error(`VALIDATION_ERROR: ${Ee.name} "${w[Ee.name]}" is invalid`);
|
|
11047
11047
|
}
|
|
11048
11048
|
});
|
|
11049
11049
|
await Promise.all(vt);
|
|
11050
11050
|
}
|
|
11051
|
-
if (r &&
|
|
11052
|
-
const pe =
|
|
11051
|
+
if (r && N?.Role) {
|
|
11052
|
+
const pe = N.Role, vt = { ...o, ...w };
|
|
11053
11053
|
if (!(O.custom?.serverAccess?.update !== void 0 ? await re(O.custom.serverAccess.update, [pe, vt, o]) : !0))
|
|
11054
11054
|
throw new Error("PERMISSION_DENIED");
|
|
11055
11055
|
for (const jt of h.fields) {
|
|
11056
11056
|
const un = De(jt, O);
|
|
11057
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
11057
|
+
if (Object.prototype.hasOwnProperty.call(w, jt.name) && un?.custom?.serverAccess?.update !== void 0 && !await re(un.custom.serverAccess.update, [
|
|
11058
11058
|
pe,
|
|
11059
11059
|
vt,
|
|
11060
11060
|
o
|
|
@@ -11062,28 +11062,28 @@ ${i}`);
|
|
|
11062
11062
|
throw new Error("PERMISSION_DENIED");
|
|
11063
11063
|
}
|
|
11064
11064
|
}
|
|
11065
|
-
sr(
|
|
11065
|
+
sr(w, o, e, h, u, r, N, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), s?.permissions && r && N && await Po(b, s.permissions, r, N, u, S, z), sr(w, o, e, h, u, r, N, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), F && (L || k(o) || I) && await jc(b, e, o.User_ID);
|
|
11066
11066
|
};
|
|
11067
|
-
(
|
|
11067
|
+
(L || y || I) && await _.runTransaction(async (b) => {
|
|
11068
11068
|
await $(b, !0);
|
|
11069
11069
|
}, { maxAttempts: 10 });
|
|
11070
|
-
const
|
|
11070
|
+
const D = async (b, F) => {
|
|
11071
11071
|
if (!o)
|
|
11072
11072
|
throw new Error("NOT_FOUND");
|
|
11073
11073
|
try {
|
|
11074
|
-
const z = { size: 1 }, Q = { ...o, ...
|
|
11074
|
+
const z = { size: 1 }, Q = { ...o, ...w };
|
|
11075
11075
|
await $(b, !1, z);
|
|
11076
11076
|
let oe;
|
|
11077
|
-
!i?.noTwoWay && !i?.providedTransaction && (oe = await $o("Update", l, e, Q,
|
|
11077
|
+
!i?.noTwoWay && !i?.providedTransaction && (oe = await $o("Update", l, e, Q, w, h, u, b, z, r, N, o));
|
|
11078
11078
|
const ue = Ls(u);
|
|
11079
|
-
Ys("update", b, n, e,
|
|
11079
|
+
Ys("update", b, n, e, w, u, h, i, ue, me.arrayUnion, me.arrayRemove, me.delete, (he) => _.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he.name}`).doc(e), (he, Ve) => _.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${he.name}`).doc(Ve), (he) => _.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he}`).doc(e), (he, Ve) => Ae(_, he, l).doc(Ve), (he, Ve, pe) => _.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve}`).doc(pe), (he, Ve, pe) => _.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve.replaceAll(" ", "-")}`).doc(pe), o, oe, z), b.update(C.doc(e), w);
|
|
11080
11080
|
} catch (z) {
|
|
11081
11081
|
if (i?.providedTransaction)
|
|
11082
11082
|
throw z;
|
|
11083
11083
|
{
|
|
11084
11084
|
const Q = [
|
|
11085
11085
|
"update",
|
|
11086
|
-
|
|
11086
|
+
w,
|
|
11087
11087
|
e,
|
|
11088
11088
|
a,
|
|
11089
11089
|
z,
|
|
@@ -11093,40 +11093,40 @@ ${i}`);
|
|
|
11093
11093
|
], oe = await ie("postWriteError", c, O, Q);
|
|
11094
11094
|
if (E && (await new Promise((ue) => {
|
|
11095
11095
|
setTimeout(ue, 250);
|
|
11096
|
-
}), await Ft("update", oe?.resolved ? "success" : "failed",
|
|
11097
|
-
throw
|
|
11096
|
+
}), await Ft("update", oe?.resolved ? "success" : "failed", w, l, n, e, h, oe?.resolved ? void 0 : z, o)), !oe?.resolved)
|
|
11097
|
+
throw L && await cn(o), k(o) && await Jt(o.User_ID, F, S, "USER_ERROR"), I && await _.collection("tenants").doc(l).collection(v.collection).doc(e).update({ User_ID: me.delete() }), z;
|
|
11098
11098
|
}
|
|
11099
11099
|
}
|
|
11100
|
-
(
|
|
11100
|
+
(L || k(o) || I) && await Gr(Kr, [e, o.User_ID]).catch(() => {
|
|
11101
11101
|
throw new Error("USER_ERROR");
|
|
11102
11102
|
});
|
|
11103
11103
|
};
|
|
11104
11104
|
try {
|
|
11105
11105
|
let b;
|
|
11106
|
-
if (
|
|
11106
|
+
if (L || k(o) || I) {
|
|
11107
11107
|
if (k(o)) {
|
|
11108
|
-
b = await
|
|
11108
|
+
b = await x.getUser(o.User_ID);
|
|
11109
11109
|
const Q = b.customClaims;
|
|
11110
11110
|
if (!(Q && Q.role && Q.collection && Q.doc))
|
|
11111
11111
|
throw new Error("USER_ERROR");
|
|
11112
11112
|
}
|
|
11113
|
-
const F = { ...o, ...
|
|
11113
|
+
const F = { ...o, ...w };
|
|
11114
11114
|
nt(F);
|
|
11115
11115
|
const z = await Wc(s?.operation || "update", l, e, c, v.collection, F, o, b, s?.permissions, S, s?.password);
|
|
11116
|
-
|
|
11116
|
+
L && (w.User_ID = z), I && (w.User_ID = me.delete());
|
|
11117
11117
|
}
|
|
11118
|
-
i?.providedTransaction ? await
|
|
11119
|
-
await
|
|
11118
|
+
i?.providedTransaction ? await D(i.providedTransaction, b) : await _.runTransaction(async (F) => {
|
|
11119
|
+
await D(F, b);
|
|
11120
11120
|
}, { maxAttempts: 10 });
|
|
11121
11121
|
} catch (b) {
|
|
11122
|
-
throw (
|
|
11122
|
+
throw (L || k(o) || I) && await Gr(Kr, [e, o.User_ID]).catch(() => {
|
|
11123
11123
|
throw new Error("USER_ERROR");
|
|
11124
11124
|
}), b;
|
|
11125
11125
|
}
|
|
11126
11126
|
if (!i?.providedTransaction) {
|
|
11127
11127
|
const b = [
|
|
11128
11128
|
"update",
|
|
11129
|
-
|
|
11129
|
+
w,
|
|
11130
11130
|
e,
|
|
11131
11131
|
a,
|
|
11132
11132
|
void 0,
|
|
@@ -11134,7 +11134,7 @@ ${i}`);
|
|
|
11134
11134
|
], F = [...b];
|
|
11135
11135
|
await ie("postWrite", c, O, b), await ie("postOperation", c, O, F);
|
|
11136
11136
|
}
|
|
11137
|
-
const j = { ...o, ...
|
|
11137
|
+
const j = { ...o, ...w };
|
|
11138
11138
|
return nt(j), { id: e, ...j };
|
|
11139
11139
|
}, hu = async (n, e, t, s, r) => {
|
|
11140
11140
|
const i = Je(), a = Wt();
|
|
@@ -11148,60 +11148,60 @@ ${i}`);
|
|
|
11148
11148
|
if (v && !f && !s?.force)
|
|
11149
11149
|
return await Zc(n, e, { [v.archivedField]: !0, [v.timestampField]: me.serverTimestamp() }, void 0, t);
|
|
11150
11150
|
const O = ce();
|
|
11151
|
-
let
|
|
11151
|
+
let R;
|
|
11152
11152
|
t && await Ks(n, m);
|
|
11153
|
-
const
|
|
11153
|
+
const x = Ae(O, n, i);
|
|
11154
11154
|
r = r || {}, r.collection = d.collection;
|
|
11155
|
-
const
|
|
11156
|
-
let
|
|
11157
|
-
const C = Sn(
|
|
11158
|
-
Ue(
|
|
11155
|
+
const _ = await at(n, e, { user: t });
|
|
11156
|
+
let N = Vs("delete", n, _, o, E, "Online", t || "System", lt.now(), me.serverTimestamp());
|
|
11157
|
+
const C = Sn(N);
|
|
11158
|
+
Ue(N), h && await Ft("delete", "started", N, i, n, e, m), await ie("preOperation", a, p, ["delete", N, e, r]), await ie("preWrite", a, p, ["delete", N, e, r]), Ue(N);
|
|
11159
11159
|
const y = async (g) => {
|
|
11160
|
-
const [
|
|
11160
|
+
const [T, S, $, D] = await Promise.all([
|
|
11161
11161
|
g.get(O.collection("system_deployment").doc("maintenance_mode")),
|
|
11162
11162
|
at([d.collection], e, { user: t, providedTransaction: g }),
|
|
11163
11163
|
t ? g.get(O.collection("tenants").doc(i).collection("system_user_permissions").doc(t)) : Promise.resolve({}),
|
|
11164
11164
|
Ye()
|
|
11165
11165
|
]);
|
|
11166
|
-
if (!
|
|
11166
|
+
if (!T.exists)
|
|
11167
11167
|
throw new Error("MAINTENANCE_MODE");
|
|
11168
|
-
if (
|
|
11168
|
+
if (T.data().active)
|
|
11169
11169
|
throw new Error("MAINTENANCE_MODE");
|
|
11170
11170
|
if (!S)
|
|
11171
11171
|
throw new Error("NOT_FOUND");
|
|
11172
|
-
if (
|
|
11172
|
+
if (N = { ...S, ...C }, o = D, t) {
|
|
11173
11173
|
if (!$?.exists)
|
|
11174
11174
|
throw new Error("PERMISSION_DENIED");
|
|
11175
|
-
if (
|
|
11175
|
+
if (R = $.data(), !R.Role)
|
|
11176
11176
|
throw new Error("USER_ERROR");
|
|
11177
|
-
if (!
|
|
11177
|
+
if (!R.Enabled)
|
|
11178
11178
|
throw new Error("PERMISSION_DENIED");
|
|
11179
|
-
Go(
|
|
11179
|
+
Go(N, e, m, o, t, R);
|
|
11180
11180
|
}
|
|
11181
|
-
if (t &&
|
|
11182
|
-
const q =
|
|
11183
|
-
if (!(p.custom?.serverAccess?.delete !== void 0 ? await re(p.custom.serverAccess.delete, [q,
|
|
11181
|
+
if (t && R?.Role) {
|
|
11182
|
+
const q = R.Role;
|
|
11183
|
+
if (!(p.custom?.serverAccess?.delete !== void 0 ? await re(p.custom.serverAccess.delete, [q, N]) : !0))
|
|
11184
11184
|
throw new Error("PERMISSION_DENIED");
|
|
11185
11185
|
}
|
|
11186
11186
|
};
|
|
11187
11187
|
m.auth && (await O.runTransaction(async (g) => {
|
|
11188
11188
|
await y(g);
|
|
11189
|
-
}, { maxAttempts: 10 }),
|
|
11189
|
+
}, { maxAttempts: 10 }), N.User_ID && await cn(N));
|
|
11190
11190
|
try {
|
|
11191
11191
|
await O.runTransaction(async (g) => {
|
|
11192
11192
|
await y(g);
|
|
11193
|
-
const
|
|
11194
|
-
Ys("delete", g, n, e,
|
|
11193
|
+
const T = Ls(o);
|
|
11194
|
+
Ys("delete", g, n, e, N, o, m, s, T, me.arrayUnion, me.arrayRemove, me.delete, (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S.name}`).doc(e), (S, $) => O.collection("tenants").doc(i).collection("system_unique").doc(d.collection).collection(`Unique-${d.collection}-${S.name}`).doc($), (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S}`).doc(e), (S, $) => Ae(O, S, i).doc($), (S, $, D) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$}`).doc(D), (S, $, D) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$.replaceAll(" ", "-")}`).doc(D)), g.delete(x.doc(e));
|
|
11195
11195
|
}, { maxAttempts: 10 });
|
|
11196
11196
|
} catch (g) {
|
|
11197
|
-
const S = await ie("postWriteError", a, p, ["delete",
|
|
11197
|
+
const S = await ie("postWriteError", a, p, ["delete", N, e, r, g]);
|
|
11198
11198
|
if (h && (await new Promise(($) => {
|
|
11199
11199
|
setTimeout($, 250);
|
|
11200
|
-
}), await Ft("delete", S?.resolved ? "success" : "failed",
|
|
11201
|
-
throw m.auth &&
|
|
11200
|
+
}), await Ft("delete", S?.resolved ? "success" : "failed", N, i, n, e, m, S?.resolved ? void 0 : g)), !S?.resolved)
|
|
11201
|
+
throw m.auth && N.User_ID && await O.collection("tenants").doc(i).collection(d.collection).doc(e).update({ User_ID: me.delete() }), g;
|
|
11202
11202
|
}
|
|
11203
|
-
const k = ["delete",
|
|
11204
|
-
return await ie("postWrite", a, p, k), await ie("postOperation", a, p,
|
|
11203
|
+
const k = ["delete", N, e, r], w = [...k];
|
|
11204
|
+
return await ie("postWrite", a, p, k), await ie("postOperation", a, p, w), { id: e, ...N };
|
|
11205
11205
|
}, mu = async (n, e) => {
|
|
11206
11206
|
const t = ce(), s = ko(), r = process.env.ADMIN_SMS;
|
|
11207
11207
|
if (s === "development")
|
|
@@ -11223,16 +11223,16 @@ ${i}`);
|
|
|
11223
11223
|
e(n);
|
|
11224
11224
|
}, yu = async (n) => await gt().getUser(n), gu = (n) => {
|
|
11225
11225
|
const e = bo();
|
|
11226
|
-
return
|
|
11226
|
+
return V.fromJSDate(n).setZone(e);
|
|
11227
11227
|
}, qc = (n) => {
|
|
11228
11228
|
const e = bo();
|
|
11229
|
-
return
|
|
11229
|
+
return V.fromJSDate(n.toDate()).setZone(e);
|
|
11230
11230
|
}, wu = (n, e) => {
|
|
11231
|
-
const s =
|
|
11232
|
-
return
|
|
11231
|
+
const s = V.fromJSDate(n, { zone: e }).offset, i = V.fromJSDate(n).offset, a = s - i;
|
|
11232
|
+
return V.fromJSDate(n).plus({ minutes: a }).toJSDate();
|
|
11233
11233
|
}, _u = (n, e) => {
|
|
11234
|
-
const s =
|
|
11235
|
-
return
|
|
11234
|
+
const s = V.fromJSDate(n, { zone: e }).offset, i = V.fromJSDate(n).offset, a = s - i;
|
|
11235
|
+
return V.fromJSDate(n).minus({ minutes: a }).toJSDate();
|
|
11236
11236
|
}, Eu = (n) => "seconds" in n && "nanoseconds" in n ? qc(new lt(n.seconds, n.nanoseconds)).toFormat("MMMM d, yyyy '@' h:mm a") : "";
|
|
11237
11237
|
export {
|
|
11238
11238
|
fu as addRecord,
|