@stoker-platform/node-client 0.5.40 → 0.5.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.js CHANGED
@@ -8,13 +8,13 @@ import { pathToFileURL as ni } from "node:url";
8
8
  import Wo from "cross-spawn";
9
9
  import { getDatabase as si } from "firebase-admin/database";
10
10
  import { getAuth as gt } from "firebase-admin/auth";
11
- const jn = (n) => !!n.auth, Re = (n, e) => {
11
+ const jn = (n) => !!n.auth, Te = (n, e) => {
12
12
  if (e?.operations)
13
13
  return e.operations.includes(n);
14
14
  }, Zn = (n, e) => e ? e.Role ? n.access?.includes(e.Role) : !1 : !0, jo = (n, e) => e ? !e.Role || n.restrictCreate === !0 ? !1 : typeof n.restrictCreate == "object" ? n.restrictCreate?.includes(e.Role) : !0 : !0, ri = (n, e) => e ? !e.Role || n.restrictUpdate === !0 ? !1 : typeof n.restrictUpdate == "object" ? n.restrictUpdate?.includes(e.Role) : !0 : !0, tr = (n, e, t) => {
15
15
  const { labels: s } = n;
16
16
  return t.collections && // eslint-disable-next-line security/detect-object-injection
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));
17
+ Te("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",
@@ -153,7 +153,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
153
153
  let l = !0;
154
154
  if (!o || !r.Role)
155
155
  return l = !1, l;
156
- Re(n, o) || (l = !1);
156
+ Te(n, o) || (l = !1);
157
157
  const u = Fs(e, r)?.filter((m) => m.type === "Individual").length > 0;
158
158
  return n === "Create" && u && (l = !1), Zo(n, e, t, s, r, i) || (l = !1), l;
159
159
  }, li = (n, e, t) => {
@@ -388,7 +388,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
388
388
  return;
389
389
  }
390
390
  for (const u of o?.operations || [])
391
- if (!l?.operations.includes(u) && (!Re("Read", c) || !Re(u, c))) {
391
+ if (!l?.operations.includes(u) && (!Te("Read", c) || !Te(u, c))) {
392
392
  i = `User does not have ${u.toLowerCase()} access to collection ${a.labels.collection}`, r = !1;
393
393
  return;
394
394
  }
@@ -436,7 +436,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
436
436
  let u = !0;
437
437
  if (r && !c)
438
438
  throw new Error("PERMISSION_DENIED");
439
- r && !Re("Create", c) && (u = !1), r && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
439
+ r && !Te("Create", c) && (u = !1), r && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
440
440
  !it("Create", t, s, r, i, n) && (u = !1), t.auth && a && (r && !jn(c) && (u = !1), Ps("create", n, e, t, s, r, i, a) || (u = !1));
441
441
  for (const m of l) {
442
442
  const d = n[m.name];
@@ -453,9 +453,10 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
453
453
  let h = !0, v = "";
454
454
  if (i && !d)
455
455
  throw new Error("PERMISSION_DENIED");
456
- i && !Re("Update", d) && (h = !1, v = "Authenticated user does not have Update access to this collection"), i && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
456
+ i && !Te("Update", d) && (h = !1, v = "Authenticated user does not have Update access to this collection"), i && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
457
457
  (!it("Update", s, r, i, a, e) || // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
458
- !it("Update", s, r, i, a, f)) && (h = !1, v = "Authenticated user does not have Update access to this document"), o && (i && !jn(d) && (h = !1, v = "Authenticated user does not have Auth access for this collection"), Ps("update", f, t, s, r, i, a, l, c, e, o) || (v = "Authenticated user does not have sufficient write access for this record", h = !1));
458
+ !it("Update", s, r, i, a, f)) && (h = !1, v = "Authenticated user does not have Update access to this document"), i && s.softDelete && n[s.softDelete.archivedField] === !0 && !e[s.softDelete.archivedField] && // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
459
+ !Te("Delete", d) && (h = !1, v = "Authenticated user does not have Delete access to this document"), o && (i && !jn(d) && (h = !1, v = "Authenticated user does not have Auth access for this collection"), Ps("update", f, t, s, r, i, a, l, c, e, o) || (v = "Authenticated user does not have sufficient write access for this record", h = !1));
459
460
  for (const p of m) {
460
461
  const E = n[p.name];
461
462
  p.access && !Zn(p, a) && E !== void 0 && (v = `Authenticated user does not have access to field ${p.name}`, h = !1), E !== void 0 && !ri(p, a) && (v = `Authenticated user does not have Update access to field ${p.name}`, h = !1);
@@ -467,7 +468,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
467
468
  let l = !0;
468
469
  if (!o)
469
470
  throw new Error("PERMISSION_DENIED");
470
- if (Re("Delete", o) || (l = !1), it("Delete", t, s, r, i, n) || (l = !1), t.auth && n.User_ID && (jn(o) || (l = !1), Ps("delete", n, e, t, s, r, i) || (l = !1)), !l)
471
+ if (Te("Delete", o) || (l = !1), it("Delete", t, s, r, i, n) || (l = !1), t.auth && n.User_ID && (jn(o) || (l = !1), Ps("delete", n, e, t, s, r, i) || (l = !1)), !l)
471
472
  throw new Error("PERMISSION_DENIED");
472
473
  }, Yo = async (n, e, t, s, r) => {
473
474
  const { labels: i } = e, a = r.collections?.[i.collection];
@@ -476,7 +477,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
476
477
  o = !1;
477
478
  return;
478
479
  }
479
- if (Re("Read", a) || (o = !1), it("Read", e, t, s, r, n) || (o = !1), !o)
480
+ if (Te("Read", a) || (o = !1), it("Read", e, t, s, r, n) || (o = !1), !o)
480
481
  throw new Error("PERMISSION_DENIED");
481
482
  }, Jo = async (n, e, t, s, r) => {
482
483
  const { labels: i } = e, a = r.collections?.[i.collection];
@@ -485,7 +486,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
485
486
  o = !1;
486
487
  return;
487
488
  }
488
- if (Re("Read", a) || (o = !1), n.forEach((l) => {
489
+ if (Te("Read", a) || (o = !1), n.forEach((l) => {
489
490
  it("Read", e, t, s, r, l) || (o = !1);
490
491
  }), !o)
491
492
  throw new Error("PERMISSION_DENIED");
@@ -3642,7 +3643,7 @@ class Ke extends Et {
3642
3643
  super("Zone is an abstract class");
3643
3644
  }
3644
3645
  }
3645
- const M = "numeric", Le = "short", Te = "long", Fn = {
3646
+ const M = "numeric", Le = "short", Re = "long", Fn = {
3646
3647
  year: M,
3647
3648
  month: M,
3648
3649
  day: M
@@ -3657,13 +3658,13 @@ const M = "numeric", Le = "short", Te = "long", Fn = {
3657
3658
  weekday: Le
3658
3659
  }, _i = {
3659
3660
  year: M,
3660
- month: Te,
3661
+ month: Re,
3661
3662
  day: M
3662
3663
  }, Ei = {
3663
3664
  year: M,
3664
- month: Te,
3665
+ month: Re,
3665
3666
  day: M,
3666
- weekday: Te
3667
+ weekday: Re
3667
3668
  }, vi = {
3668
3669
  hour: M,
3669
3670
  minute: M
@@ -3680,7 +3681,7 @@ const M = "numeric", Le = "short", Te = "long", Fn = {
3680
3681
  hour: M,
3681
3682
  minute: M,
3682
3683
  second: M,
3683
- timeZoneName: Te
3684
+ timeZoneName: Re
3684
3685
  }, Si = {
3685
3686
  hour: M,
3686
3687
  minute: M,
@@ -3701,7 +3702,7 @@ const M = "numeric", Le = "short", Te = "long", Fn = {
3701
3702
  minute: M,
3702
3703
  second: M,
3703
3704
  hourCycle: "h23",
3704
- timeZoneName: Te
3705
+ timeZoneName: Re
3705
3706
  }, xi = {
3706
3707
  year: M,
3707
3708
  month: M,
@@ -3737,14 +3738,14 @@ const M = "numeric", Le = "short", Te = "long", Fn = {
3737
3738
  minute: M
3738
3739
  }, Ci = {
3739
3740
  year: M,
3740
- month: Te,
3741
+ month: Re,
3741
3742
  day: M,
3742
3743
  hour: M,
3743
3744
  minute: M,
3744
3745
  timeZoneName: Le
3745
3746
  }, $i = {
3746
3747
  year: M,
3747
- month: Te,
3748
+ month: Re,
3748
3749
  day: M,
3749
3750
  hour: M,
3750
3751
  minute: M,
@@ -3752,21 +3753,21 @@ const M = "numeric", Le = "short", Te = "long", Fn = {
3752
3753
  timeZoneName: Le
3753
3754
  }, Mi = {
3754
3755
  year: M,
3755
- month: Te,
3756
+ month: Re,
3756
3757
  day: M,
3757
- weekday: Te,
3758
+ weekday: Re,
3758
3759
  hour: M,
3759
3760
  minute: M,
3760
- timeZoneName: Te
3761
+ timeZoneName: Re
3761
3762
  }, Fi = {
3762
3763
  year: M,
3763
- month: Te,
3764
+ month: Re,
3764
3765
  day: M,
3765
- weekday: Te,
3766
+ weekday: Re,
3766
3767
  hour: M,
3767
3768
  minute: M,
3768
3769
  second: M,
3769
- timeZoneName: Te
3770
+ timeZoneName: Re
3770
3771
  };
3771
3772
  class rn {
3772
3773
  /**
@@ -9572,7 +9573,7 @@ const Rt = {
9572
9573
  const f = r.collections?.[l.collection];
9573
9574
  if (!r.Role)
9574
9575
  throw new Error("PERMISSION_DENIED");
9575
- 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 = []) => {
9576
+ const h = f && Te("Read", f), v = ai(o, t, r), p = ii(o, r), E = Fs(o, r), O = oi(o, t, r), R = (g = []) => {
9576
9577
  const T = [], S = fi(r.Role, o, t);
9577
9578
  if (!S)
9578
9579
  throw new Error("PERMISSION_DENIED");
@@ -9796,7 +9797,7 @@ const Rt = {
9796
9797
  const u = r.collections?.[l.collection];
9797
9798
  if (!r.Role)
9798
9799
  throw new Error("PERMISSION_DENIED");
9799
- const m = u && Re("Read", u), d = ai(o, s, r), f = [], h = fi(r.Role, o, s);
9800
+ const m = u && Te("Read", u), d = ai(o, s, r), f = [], h = fi(r.Role, o, s);
9800
9801
  if (!h)
9801
9802
  throw new Error("PERMISSION_DENIED");
9802
9803
  if (m)
@@ -10113,7 +10114,7 @@ const Rt = {
10113
10114
  if (_ = f.collections?.[R.collection], !_)
10114
10115
  throw new Error("PERMISSION_DENIED");
10115
10116
  }
10116
- if (t?.user && (!_ || !Re("Read", _)))
10117
+ if (t?.user && (!_ || !Te("Read", _)))
10117
10118
  throw new Error("PERMISSION_DENIED");
10118
10119
  const N = So(s, n, e, d, f);
10119
10120
  if (N.length === 0)
@@ -10560,7 +10561,7 @@ ${i}`);
10560
10561
  throw new Error("Soft delete timestamp cannot be changed");
10561
10562
  }
10562
10563
  }, ps = async (n, e, t, s, r) => {
10563
- if (!Re("Read", r.collections?.[e.labels.collection]))
10564
+ if (!Te("Read", r.collections?.[e.labels.collection]))
10564
10565
  return !1;
10565
10566
  try {
10566
10567
  await at([e.labels.collection], t, { user: s, providedTransaction: n });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/node-client",
3
- "version": "0.5.40",
3
+ "version": "0.5.42",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "files": [
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@google-cloud/storage": "^7.19.0",
27
- "@stoker-platform/types": "0.5.27",
28
- "@stoker-platform/utils": "0.5.34",
27
+ "@stoker-platform/types": "0.5.28",
28
+ "@stoker-platform/utils": "0.5.36",
29
29
  "@types/luxon": "^3.7.1",
30
30
  "cross-spawn": "^7.0.6",
31
31
  "firebase-admin": "^13.7.0",