@authhero/kysely-adapter 10.102.0 → 10.103.0
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/kysely-adapter.cjs +7 -7
- package/dist/kysely-adapter.mjs +199 -246
- package/package.json +1 -1
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -83,7 +83,7 @@ function br(t, e) {
|
|
|
83
83
|
} else
|
|
84
84
|
await t.transaction().execute(async (_) => {
|
|
85
85
|
if (await _.insertInto("users").values(u).execute(), s && u.user_id) {
|
|
86
|
-
const
|
|
86
|
+
const m = {
|
|
87
87
|
id: K(),
|
|
88
88
|
user_id: u.user_id,
|
|
89
89
|
password: s.hash,
|
|
@@ -93,7 +93,7 @@ function br(t, e) {
|
|
|
93
93
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
94
94
|
tenant_id: a
|
|
95
95
|
};
|
|
96
|
-
await _.insertInto("passwords").values(
|
|
96
|
+
await _.insertInto("passwords").values(m).execute();
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
} catch (_) {
|
|
@@ -190,8 +190,8 @@ function q(t, e, a, n) {
|
|
|
190
190
|
const r = a.split(/ OR /i);
|
|
191
191
|
if (r.length > 1)
|
|
192
192
|
return e.where((_) => {
|
|
193
|
-
const
|
|
194
|
-
const f =
|
|
193
|
+
const m = r.map((d) => {
|
|
194
|
+
const f = d.trim().match(/^([^:]+):(.+)$/);
|
|
195
195
|
if (f) {
|
|
196
196
|
const [, p, y] = f;
|
|
197
197
|
if (!p || !y) return null;
|
|
@@ -200,55 +200,55 @@ function q(t, e, a, n) {
|
|
|
200
200
|
}
|
|
201
201
|
return null;
|
|
202
202
|
}).filter(Boolean);
|
|
203
|
-
return _.or(
|
|
203
|
+
return _.or(m);
|
|
204
204
|
});
|
|
205
205
|
const o = [];
|
|
206
206
|
let s = "", l = !1;
|
|
207
207
|
for (let _ = 0; _ < a.length; _++) {
|
|
208
|
-
const
|
|
209
|
-
|
|
208
|
+
const m = a[_];
|
|
209
|
+
m === '"' ? (l = !l, s += m) : m === " " && !l ? s.trim() && (o.push(s.trim()), s = "") : s += m;
|
|
210
210
|
}
|
|
211
211
|
return s.trim() && o.push(s.trim()), o.map((_) => _.replace(/^([^:]+)=/g, "$1:")).map((_) => {
|
|
212
|
-
let
|
|
212
|
+
let m = _.startsWith("-"), d = null, f = "", p = !1, y;
|
|
213
213
|
if (_.startsWith("-_exists_:"))
|
|
214
|
-
|
|
214
|
+
d = _.substring(10), p = !0, m = !0;
|
|
215
215
|
else if (_.startsWith("_exists_:"))
|
|
216
|
-
|
|
216
|
+
d = _.substring(9), p = !0, m = !1;
|
|
217
217
|
else if (_.includes(":")) {
|
|
218
|
-
const N =
|
|
219
|
-
|
|
218
|
+
const N = m ? _.substring(1) : _, T = N.indexOf(":");
|
|
219
|
+
d = N.substring(0, T), f = N.substring(T + 1), p = !1, f.startsWith(">=") ? (y = ">=", f = f.substring(2)) : f.startsWith(">") ? (y = ">", f = f.substring(1)) : f.startsWith("<=") ? (y = "<=", f = f.substring(2)) : f.startsWith("<") ? (y = "<", f = f.substring(1)) : y = "=", f.startsWith('"') && f.endsWith('"') && f.length > 1 && (f = f.slice(1, -1));
|
|
220
220
|
} else
|
|
221
|
-
|
|
222
|
-
return { key:
|
|
223
|
-
}).forEach(({ key: _, value:
|
|
221
|
+
d = null, f = _, p = !1;
|
|
222
|
+
return { key: d, value: f, isNegation: m, isExistsQuery: p, operator: y };
|
|
223
|
+
}).forEach(({ key: _, value: m, isNegation: d, isExistsQuery: f, operator: p }) => {
|
|
224
224
|
if (_)
|
|
225
225
|
if (f)
|
|
226
|
-
|
|
227
|
-
else if (
|
|
226
|
+
d ? e = e.where(_, "is", null) : e = e.where(_, "is not", null);
|
|
227
|
+
else if (d)
|
|
228
228
|
switch (p) {
|
|
229
229
|
case ">":
|
|
230
|
-
e = e.where(_, "<=",
|
|
230
|
+
e = e.where(_, "<=", m);
|
|
231
231
|
break;
|
|
232
232
|
case ">=":
|
|
233
|
-
e = e.where(_, "<",
|
|
233
|
+
e = e.where(_, "<", m);
|
|
234
234
|
break;
|
|
235
235
|
case "<":
|
|
236
|
-
e = e.where(_, ">=",
|
|
236
|
+
e = e.where(_, ">=", m);
|
|
237
237
|
break;
|
|
238
238
|
case "<=":
|
|
239
|
-
e = e.where(_, ">",
|
|
239
|
+
e = e.where(_, ">", m);
|
|
240
240
|
break;
|
|
241
241
|
default:
|
|
242
|
-
e = e.where(_, "!=",
|
|
242
|
+
e = e.where(_, "!=", m);
|
|
243
243
|
}
|
|
244
244
|
else
|
|
245
|
-
e = e.where(_, p,
|
|
246
|
-
else if (
|
|
247
|
-
const { ref: y } = t.dynamic, N =
|
|
245
|
+
e = e.where(_, p, m);
|
|
246
|
+
else if (m) {
|
|
247
|
+
const { ref: y } = t.dynamic, N = m.includes("|") ? [...n, "user_id"] : n;
|
|
248
248
|
e = e.where(
|
|
249
249
|
(T) => T.or(
|
|
250
250
|
N.map(
|
|
251
|
-
(b) => b === "user_id" ? T(y(b), "=",
|
|
251
|
+
(b) => b === "user_id" ? T(y(b), "=", m) : T(y(b), "like", `%${m}%`)
|
|
252
252
|
)
|
|
253
253
|
)
|
|
254
254
|
);
|
|
@@ -266,7 +266,7 @@ function Ir(t) {
|
|
|
266
266
|
const { ref: N } = t.dynamic;
|
|
267
267
|
u = u.orderBy(N(s.sort_by), s.sort_order);
|
|
268
268
|
}
|
|
269
|
-
const
|
|
269
|
+
const m = await u.offset(n * r).limit(r).selectAll().execute(), d = m.map((N) => N.user_id), f = d.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", d).orderBy("created_at", "asc").execute() : [], p = m.map((N) => {
|
|
270
270
|
const T = f.filter(
|
|
271
271
|
(b) => b.linked_to === N.user_id
|
|
272
272
|
);
|
|
@@ -409,7 +409,7 @@ function Fr(t) {
|
|
|
409
409
|
const { page: n = 0, per_page: r = 50, include_totals: o = !1, q: s } = a;
|
|
410
410
|
let l = t.selectFrom("flows").where("tenant_id", "=", e);
|
|
411
411
|
s && (l = q(t, l, s, []));
|
|
412
|
-
const
|
|
412
|
+
const m = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
|
|
413
413
|
const p = {
|
|
414
414
|
...f,
|
|
415
415
|
actions: dt(f.actions, [])
|
|
@@ -418,17 +418,17 @@ function Fr(t) {
|
|
|
418
418
|
});
|
|
419
419
|
if (!o)
|
|
420
420
|
return {
|
|
421
|
-
flows:
|
|
421
|
+
flows: m,
|
|
422
422
|
start: 0,
|
|
423
423
|
limit: 0,
|
|
424
424
|
length: 0
|
|
425
425
|
};
|
|
426
|
-
const { count:
|
|
426
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
427
427
|
return {
|
|
428
|
-
flows:
|
|
428
|
+
flows: m,
|
|
429
429
|
start: n * r,
|
|
430
430
|
limit: r,
|
|
431
|
-
length: W(
|
|
431
|
+
length: W(d)
|
|
432
432
|
};
|
|
433
433
|
};
|
|
434
434
|
}
|
|
@@ -544,14 +544,14 @@ function Br(t) {
|
|
|
544
544
|
a = a.orderBy(p(s.sort_by), s.sort_order);
|
|
545
545
|
}
|
|
546
546
|
l && (a = q(t, a, l, ["friendly_name"]));
|
|
547
|
-
const
|
|
547
|
+
const m = (await a.offset(n * r).limit(r).selectAll().execute()).map(yn);
|
|
548
548
|
if (!o)
|
|
549
549
|
return {
|
|
550
|
-
tenants:
|
|
550
|
+
tenants: m
|
|
551
551
|
};
|
|
552
|
-
const { count:
|
|
552
|
+
const { count: d } = await a.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), f = W(d);
|
|
553
553
|
return {
|
|
554
|
-
tenants:
|
|
554
|
+
tenants: m,
|
|
555
555
|
start: n * r,
|
|
556
556
|
limit: r,
|
|
557
557
|
length: f
|
|
@@ -653,17 +653,17 @@ function Hr(t) {
|
|
|
653
653
|
_ = _.orderBy(p(s.sort_by), s.sort_order);
|
|
654
654
|
}
|
|
655
655
|
_ = _.offset(n * r).limit(r);
|
|
656
|
-
const
|
|
656
|
+
const d = (await _.selectAll().execute()).map(Nn);
|
|
657
657
|
if (!o)
|
|
658
658
|
return {
|
|
659
|
-
logs:
|
|
659
|
+
logs: d,
|
|
660
660
|
start: 0,
|
|
661
661
|
limit: 0,
|
|
662
662
|
length: 0
|
|
663
663
|
};
|
|
664
664
|
const { count: f } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
665
665
|
return {
|
|
666
|
-
logs:
|
|
666
|
+
logs: d,
|
|
667
667
|
start: n * r,
|
|
668
668
|
limit: r,
|
|
669
669
|
length: W(f)
|
|
@@ -731,14 +731,14 @@ function eo(t) {
|
|
|
731
731
|
created_at_ts: l,
|
|
732
732
|
updated_at_ts: u,
|
|
733
733
|
expires_at_ts: _,
|
|
734
|
-
idle_expires_at_ts:
|
|
735
|
-
authenticated_at_ts:
|
|
734
|
+
idle_expires_at_ts: m,
|
|
735
|
+
authenticated_at_ts: d,
|
|
736
736
|
last_interaction_at_ts: f,
|
|
737
737
|
used_at_ts: p,
|
|
738
738
|
revoked_at_ts: y,
|
|
739
739
|
...N
|
|
740
740
|
} = n, T = ze(
|
|
741
|
-
{ created_at_ts: l, updated_at_ts: u, expires_at_ts: _, idle_expires_at_ts:
|
|
741
|
+
{ created_at_ts: l, updated_at_ts: u, expires_at_ts: _, idle_expires_at_ts: m, authenticated_at_ts: d, last_interaction_at_ts: f, used_at_ts: p, revoked_at_ts: y },
|
|
742
742
|
["created_at_ts", "updated_at_ts", "authenticated_at_ts", "last_interaction_at_ts"],
|
|
743
743
|
["expires_at_ts", "idle_expires_at_ts", "used_at_ts", "revoked_at_ts"]
|
|
744
744
|
);
|
|
@@ -763,8 +763,8 @@ function to(t) {
|
|
|
763
763
|
idle_expires_at: l,
|
|
764
764
|
used_at: u,
|
|
765
765
|
revoked_at: _,
|
|
766
|
-
device:
|
|
767
|
-
clients:
|
|
766
|
+
device: m,
|
|
767
|
+
clients: d,
|
|
768
768
|
...f
|
|
769
769
|
} = a;
|
|
770
770
|
return await t.insertInto("sessions").values({
|
|
@@ -778,8 +778,8 @@ function to(t) {
|
|
|
778
778
|
idle_expires_at_ts: P(l),
|
|
779
779
|
used_at_ts: P(u),
|
|
780
780
|
revoked_at_ts: P(_),
|
|
781
|
-
device: JSON.stringify(
|
|
782
|
-
clients: JSON.stringify(
|
|
781
|
+
device: JSON.stringify(m),
|
|
782
|
+
clients: JSON.stringify(d)
|
|
783
783
|
}).execute(), o;
|
|
784
784
|
};
|
|
785
785
|
}
|
|
@@ -807,7 +807,7 @@ function ro(t) {
|
|
|
807
807
|
_ = _.orderBy(y(s.sort_by), s.sort_order);
|
|
808
808
|
}
|
|
809
809
|
_ = _.offset(n * r).limit(r);
|
|
810
|
-
const
|
|
810
|
+
const d = (await _.selectAll().execute()).map((y) => {
|
|
811
811
|
const {
|
|
812
812
|
tenant_id: N,
|
|
813
813
|
device: T,
|
|
@@ -835,14 +835,14 @@ function ro(t) {
|
|
|
835
835
|
});
|
|
836
836
|
if (!o)
|
|
837
837
|
return {
|
|
838
|
-
sessions:
|
|
838
|
+
sessions: d,
|
|
839
839
|
start: 0,
|
|
840
840
|
limit: 0,
|
|
841
841
|
length: 0
|
|
842
842
|
};
|
|
843
843
|
const { count: f } = await u.select((y) => y.fn.countAll().as("count")).executeTakeFirstOrThrow(), p = W(f);
|
|
844
844
|
return {
|
|
845
|
-
sessions:
|
|
845
|
+
sessions: d,
|
|
846
846
|
start: n * r,
|
|
847
847
|
limit: r,
|
|
848
848
|
length: p
|
|
@@ -919,23 +919,23 @@ function _o(t) {
|
|
|
919
919
|
const { page: n = 0, per_page: r = 50, include_totals: o = !1, q: s } = a;
|
|
920
920
|
let l = t.selectFrom("codes").where("codes.tenant_id", "=", e);
|
|
921
921
|
s && (l = q(t, l, s, ["code", "login_id"]));
|
|
922
|
-
const
|
|
922
|
+
const m = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
|
|
923
923
|
const { tenant_id: p, ...y } = f;
|
|
924
924
|
return yr.parse(O(y));
|
|
925
925
|
});
|
|
926
926
|
if (!o)
|
|
927
927
|
return {
|
|
928
|
-
codes:
|
|
928
|
+
codes: m,
|
|
929
929
|
start: 0,
|
|
930
930
|
limit: 0,
|
|
931
931
|
length: 0
|
|
932
932
|
};
|
|
933
|
-
const { count:
|
|
933
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
934
934
|
return {
|
|
935
|
-
codes:
|
|
935
|
+
codes: m,
|
|
936
936
|
start: n * r,
|
|
937
937
|
limit: r,
|
|
938
|
-
length: W(
|
|
938
|
+
length: W(d)
|
|
939
939
|
};
|
|
940
940
|
};
|
|
941
941
|
}
|
|
@@ -1037,20 +1037,20 @@ function bo(t) {
|
|
|
1037
1037
|
const { page: n = 0, per_page: r = 50, include_totals: o = !1, q: s } = a;
|
|
1038
1038
|
let l = t.selectFrom("connections").where("connections.tenant_id", "=", e);
|
|
1039
1039
|
s && (l = q(t, l, s, ["user_id", "ip"]));
|
|
1040
|
-
const _ = await l.offset(n * r).limit(r).selectAll().execute(),
|
|
1040
|
+
const _ = await l.offset(n * r).limit(r).selectAll().execute(), m = Oo(_);
|
|
1041
1041
|
if (!o)
|
|
1042
1042
|
return {
|
|
1043
|
-
connections:
|
|
1043
|
+
connections: m,
|
|
1044
1044
|
start: 0,
|
|
1045
1045
|
limit: 0,
|
|
1046
1046
|
length: 0
|
|
1047
1047
|
};
|
|
1048
|
-
const { count:
|
|
1048
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1049
1049
|
return {
|
|
1050
|
-
connections:
|
|
1050
|
+
connections: m,
|
|
1051
1051
|
start: n * r,
|
|
1052
1052
|
limit: r,
|
|
1053
|
-
length: W(
|
|
1053
|
+
length: W(d)
|
|
1054
1054
|
};
|
|
1055
1055
|
};
|
|
1056
1056
|
}
|
|
@@ -1486,7 +1486,7 @@ function Qo(t) {
|
|
|
1486
1486
|
} else
|
|
1487
1487
|
_ = _.orderBy("client_grants.created_at", "desc");
|
|
1488
1488
|
_ = _.limit(r).offset(n * r);
|
|
1489
|
-
const
|
|
1489
|
+
const d = (await _.selectAll().execute()).map((p) => {
|
|
1490
1490
|
const y = {
|
|
1491
1491
|
id: p.id,
|
|
1492
1492
|
client_id: p.client_id,
|
|
@@ -1505,14 +1505,14 @@ function Qo(t) {
|
|
|
1505
1505
|
});
|
|
1506
1506
|
if (!o)
|
|
1507
1507
|
return {
|
|
1508
|
-
client_grants:
|
|
1508
|
+
client_grants: d,
|
|
1509
1509
|
start: 0,
|
|
1510
1510
|
limit: 0,
|
|
1511
1511
|
length: 0
|
|
1512
1512
|
};
|
|
1513
1513
|
const { count: f } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1514
1514
|
return {
|
|
1515
|
-
client_grants:
|
|
1515
|
+
client_grants: d,
|
|
1516
1516
|
start: n * r,
|
|
1517
1517
|
limit: r,
|
|
1518
1518
|
length: W(f)
|
|
@@ -1567,17 +1567,17 @@ function Yo(t) {
|
|
|
1567
1567
|
let u = l.select((p) => p.fn.count("kid").as("count"));
|
|
1568
1568
|
const _ = a * n;
|
|
1569
1569
|
l = l.limit(n).offset(_), o && (l = l.orderBy(o.sort_by, o.sort_order));
|
|
1570
|
-
const
|
|
1570
|
+
const m = await l.selectAll().execute();
|
|
1571
1571
|
if (!r)
|
|
1572
1572
|
return {
|
|
1573
|
-
signingKeys:
|
|
1573
|
+
signingKeys: m,
|
|
1574
1574
|
start: 0,
|
|
1575
1575
|
limit: 0,
|
|
1576
1576
|
length: 0
|
|
1577
1577
|
};
|
|
1578
|
-
const
|
|
1578
|
+
const d = await u.executeTakeFirst(), f = W((d == null ? void 0 : d.count) ?? 0);
|
|
1579
1579
|
return {
|
|
1580
|
-
signingKeys:
|
|
1580
|
+
signingKeys: m,
|
|
1581
1581
|
start: _,
|
|
1582
1582
|
limit: n,
|
|
1583
1583
|
length: f
|
|
@@ -1681,10 +1681,10 @@ function cs(t) {
|
|
|
1681
1681
|
colors_page_background_end: l,
|
|
1682
1682
|
colors_page_background_angle_dev: u,
|
|
1683
1683
|
font_url: _,
|
|
1684
|
-
...
|
|
1684
|
+
...m
|
|
1685
1685
|
} = a;
|
|
1686
1686
|
return O({
|
|
1687
|
-
...
|
|
1687
|
+
...m,
|
|
1688
1688
|
colors: {
|
|
1689
1689
|
primary: r,
|
|
1690
1690
|
page_background: {
|
|
@@ -1700,7 +1700,7 @@ function cs(t) {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
function ls(t) {
|
|
1702
1702
|
return async (e, a) => {
|
|
1703
|
-
var s, l, u, _,
|
|
1703
|
+
var s, l, u, _, m, d, f, p, y, N, T, b, J, R, Q, te, Y, Oe;
|
|
1704
1704
|
const { colors: n, font: r, ...o } = a;
|
|
1705
1705
|
try {
|
|
1706
1706
|
await t.insertInto("branding").values({
|
|
@@ -1708,7 +1708,7 @@ function ls(t) {
|
|
|
1708
1708
|
colors_primary: n == null ? void 0 : n.primary,
|
|
1709
1709
|
colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
|
|
1710
1710
|
colors_page_background_start: (_ = (u = a.colors) == null ? void 0 : u.page_background) == null ? void 0 : _.start,
|
|
1711
|
-
colors_page_background_end: (
|
|
1711
|
+
colors_page_background_end: (d = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : d.end,
|
|
1712
1712
|
colors_page_background_angle_dev: (p = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : p.angle_deg,
|
|
1713
1713
|
font_url: (y = a.font) == null ? void 0 : y.url,
|
|
1714
1714
|
tenant_id: e
|
|
@@ -1775,7 +1775,7 @@ function fs(t) {
|
|
|
1775
1775
|
const { page: n = 0, per_page: r = 50, include_totals: o = !1, q: s } = a;
|
|
1776
1776
|
let l = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
|
|
1777
1777
|
s && (l = q(t, l, s, ["url", "form_id", "template_id"]));
|
|
1778
|
-
const
|
|
1778
|
+
const m = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
|
|
1779
1779
|
const {
|
|
1780
1780
|
tenant_id: p,
|
|
1781
1781
|
enabled: y,
|
|
@@ -1796,17 +1796,17 @@ function fs(t) {
|
|
|
1796
1796
|
});
|
|
1797
1797
|
if (!o)
|
|
1798
1798
|
return {
|
|
1799
|
-
hooks:
|
|
1799
|
+
hooks: m,
|
|
1800
1800
|
start: 0,
|
|
1801
1801
|
limit: 0,
|
|
1802
1802
|
length: 0
|
|
1803
1803
|
};
|
|
1804
|
-
const { count:
|
|
1804
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1805
1805
|
return {
|
|
1806
|
-
hooks:
|
|
1806
|
+
hooks: m,
|
|
1807
1807
|
start: n * r,
|
|
1808
1808
|
limit: r,
|
|
1809
|
-
length: W(
|
|
1809
|
+
length: W(d)
|
|
1810
1810
|
};
|
|
1811
1811
|
};
|
|
1812
1812
|
}
|
|
@@ -2164,14 +2164,14 @@ function Qs(t) {
|
|
|
2164
2164
|
idle_expires_at_ts: l,
|
|
2165
2165
|
last_exchanged_at_ts: u,
|
|
2166
2166
|
..._
|
|
2167
|
-
} = n,
|
|
2167
|
+
} = n, m = ze(
|
|
2168
2168
|
{ created_at_ts: o, expires_at_ts: s, idle_expires_at_ts: l, last_exchanged_at_ts: u },
|
|
2169
2169
|
["created_at_ts"],
|
|
2170
2170
|
["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
|
|
2171
2171
|
);
|
|
2172
2172
|
return {
|
|
2173
2173
|
..._,
|
|
2174
|
-
...
|
|
2174
|
+
...m,
|
|
2175
2175
|
rotating: !!n.rotating,
|
|
2176
2176
|
device: n.device ? JSON.parse(n.device) : {},
|
|
2177
2177
|
resource_servers: n.resource_servers ? JSON.parse(n.resource_servers) : []
|
|
@@ -2189,13 +2189,13 @@ function Vs(t) {
|
|
|
2189
2189
|
last_exchanged_at: l,
|
|
2190
2190
|
device: u,
|
|
2191
2191
|
resource_servers: _,
|
|
2192
|
-
rotating:
|
|
2193
|
-
...
|
|
2192
|
+
rotating: m,
|
|
2193
|
+
...d
|
|
2194
2194
|
} = a, f = Date.now();
|
|
2195
2195
|
return await t.insertInto("refresh_tokens").values({
|
|
2196
|
-
...
|
|
2196
|
+
...d,
|
|
2197
2197
|
tenant_id: e,
|
|
2198
|
-
rotating:
|
|
2198
|
+
rotating: m ? 1 : 0,
|
|
2199
2199
|
device: JSON.stringify(u),
|
|
2200
2200
|
resource_servers: JSON.stringify(_),
|
|
2201
2201
|
created_at_ts: f,
|
|
@@ -2217,13 +2217,13 @@ function Hs(t) {
|
|
|
2217
2217
|
last_exchanged_at: l,
|
|
2218
2218
|
device: u,
|
|
2219
2219
|
resource_servers: _,
|
|
2220
|
-
rotating:
|
|
2221
|
-
...
|
|
2220
|
+
rotating: m,
|
|
2221
|
+
...d
|
|
2222
2222
|
} = n, f = {
|
|
2223
|
-
...
|
|
2223
|
+
...d,
|
|
2224
2224
|
device: u ? JSON.stringify(u) : void 0,
|
|
2225
2225
|
resource_servers: _ ? JSON.stringify(_) : void 0,
|
|
2226
|
-
rotating:
|
|
2226
|
+
rotating: m !== void 0 ? m ? 1 : 0 : void 0,
|
|
2227
2227
|
// Convert date fields to bigint format
|
|
2228
2228
|
expires_at_ts: o ? P(o) : void 0,
|
|
2229
2229
|
idle_expires_at_ts: s ? P(s) : void 0,
|
|
@@ -2243,7 +2243,7 @@ function Ys(t) {
|
|
|
2243
2243
|
_ = _.orderBy(y(s.sort_by), s.sort_order);
|
|
2244
2244
|
}
|
|
2245
2245
|
_ = _.offset(n * r).limit(r);
|
|
2246
|
-
const
|
|
2246
|
+
const d = (await _.selectAll().execute()).map((y) => {
|
|
2247
2247
|
const {
|
|
2248
2248
|
tenant_id: N,
|
|
2249
2249
|
created_at_ts: T,
|
|
@@ -2266,14 +2266,14 @@ function Ys(t) {
|
|
|
2266
2266
|
});
|
|
2267
2267
|
if (!o)
|
|
2268
2268
|
return {
|
|
2269
|
-
refresh_tokens:
|
|
2269
|
+
refresh_tokens: d,
|
|
2270
2270
|
start: 0,
|
|
2271
2271
|
limit: 0,
|
|
2272
2272
|
length: 0
|
|
2273
2273
|
};
|
|
2274
2274
|
const { count: f } = await u.select((y) => y.fn.countAll().as("count")).executeTakeFirstOrThrow(), p = W(f);
|
|
2275
2275
|
return {
|
|
2276
|
-
refresh_tokens:
|
|
2276
|
+
refresh_tokens: d,
|
|
2277
2277
|
start: n * r,
|
|
2278
2278
|
limit: r,
|
|
2279
2279
|
length: p
|
|
@@ -2293,77 +2293,30 @@ function Zs(t) {
|
|
|
2293
2293
|
return async (e) => {
|
|
2294
2294
|
const { tenant_id: a, user_id: n } = e || {}, r = Date.now();
|
|
2295
2295
|
try {
|
|
2296
|
-
let o = t.
|
|
2297
|
-
(
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
d("expires_at_ts", ">=", r)
|
|
2301
|
-
]),
|
|
2302
|
-
d.or([
|
|
2303
|
-
d("idle_expires_at_ts", "is", null),
|
|
2304
|
-
d("idle_expires_at_ts", ">=", r)
|
|
2305
|
-
])
|
|
2296
|
+
let o = t.deleteFrom("refresh_tokens").where(
|
|
2297
|
+
(u) => u.or([
|
|
2298
|
+
u("expires_at_ts", "<", r),
|
|
2299
|
+
u("idle_expires_at_ts", "<", r)
|
|
2306
2300
|
])
|
|
2307
2301
|
);
|
|
2308
2302
|
a && (o = o.where(
|
|
2309
2303
|
"tenant_id",
|
|
2310
2304
|
"=",
|
|
2311
2305
|
a
|
|
2312
|
-
)), n && (o = o.where(
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
let s = t.deleteFrom("login_sessions").where("expires_at_ts", "<", r).where("id", "not in", o);
|
|
2318
|
-
a && (s = s.where(
|
|
2319
|
-
"tenant_id",
|
|
2320
|
-
"=",
|
|
2321
|
-
a
|
|
2322
|
-
)), n && (s = s.where("user_id", "=", n)), await s.limit(1e3).execute();
|
|
2323
|
-
let l = t.deleteFrom("refresh_tokens").where(
|
|
2324
|
-
(d) => d.or([
|
|
2325
|
-
d("expires_at_ts", "<", r),
|
|
2326
|
-
d("idle_expires_at_ts", "<", r)
|
|
2306
|
+
)), n && (o = o.where("user_id", "=", n)), await o.limit(1e3).execute();
|
|
2307
|
+
let s = t.deleteFrom("sessions").where(
|
|
2308
|
+
(u) => u.or([
|
|
2309
|
+
u("expires_at_ts", "<", r),
|
|
2310
|
+
u("idle_expires_at_ts", "<", r)
|
|
2327
2311
|
])
|
|
2328
2312
|
);
|
|
2313
|
+
a && (s = s.where("tenant_id", "=", a)), n && (s = s.where("user_id", "=", n)), await s.limit(1e3).execute();
|
|
2314
|
+
let l = t.deleteFrom("login_sessions").where("expires_at_ts", "<", r);
|
|
2329
2315
|
a && (l = l.where(
|
|
2330
2316
|
"tenant_id",
|
|
2331
2317
|
"=",
|
|
2332
2318
|
a
|
|
2333
2319
|
)), n && (l = l.where("user_id", "=", n)), await l.limit(1e3).execute();
|
|
2334
|
-
let u = t.selectFrom("refresh_tokens").select("login_id").where(
|
|
2335
|
-
(d) => d.and([
|
|
2336
|
-
d.or([
|
|
2337
|
-
d("expires_at_ts", "is", null),
|
|
2338
|
-
d("expires_at_ts", ">=", r)
|
|
2339
|
-
]),
|
|
2340
|
-
d.or([
|
|
2341
|
-
d("idle_expires_at_ts", "is", null),
|
|
2342
|
-
d("idle_expires_at_ts", ">=", r)
|
|
2343
|
-
])
|
|
2344
|
-
])
|
|
2345
|
-
);
|
|
2346
|
-
a && (u = u.where(
|
|
2347
|
-
"tenant_id",
|
|
2348
|
-
"=",
|
|
2349
|
-
a
|
|
2350
|
-
)), n && (u = u.where(
|
|
2351
|
-
"user_id",
|
|
2352
|
-
"=",
|
|
2353
|
-
n
|
|
2354
|
-
));
|
|
2355
|
-
let _ = t.deleteFrom("sessions").where(
|
|
2356
|
-
(d) => d.or([
|
|
2357
|
-
d("expires_at_ts", "<", r),
|
|
2358
|
-
d("idle_expires_at_ts", "<", r)
|
|
2359
|
-
])
|
|
2360
|
-
).where(
|
|
2361
|
-
(d) => d.or([
|
|
2362
|
-
d("login_session_id", "is", null),
|
|
2363
|
-
d("login_session_id", "not in", u)
|
|
2364
|
-
])
|
|
2365
|
-
);
|
|
2366
|
-
a && (_ = _.where("tenant_id", "=", a)), n && (_ = _.where("user_id", "=", n)), await _.limit(1e3).execute();
|
|
2367
2320
|
} catch (o) {
|
|
2368
2321
|
console.error("Error during session cleanup:", o);
|
|
2369
2322
|
}
|
|
@@ -2392,7 +2345,7 @@ function ti(t) {
|
|
|
2392
2345
|
const { page: n = 0, per_page: r = 50, include_totals: o = !1, q: s } = a;
|
|
2393
2346
|
let l = t.selectFrom("forms").where("tenant_id", "=", e);
|
|
2394
2347
|
s && (l = q(t, l, s, []));
|
|
2395
|
-
const
|
|
2348
|
+
const m = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
|
|
2396
2349
|
const p = { ...f };
|
|
2397
2350
|
if (typeof p.nodes == "string")
|
|
2398
2351
|
try {
|
|
@@ -2413,17 +2366,17 @@ function ti(t) {
|
|
|
2413
2366
|
});
|
|
2414
2367
|
if (!o)
|
|
2415
2368
|
return {
|
|
2416
|
-
forms:
|
|
2369
|
+
forms: m,
|
|
2417
2370
|
start: 0,
|
|
2418
2371
|
limit: 0,
|
|
2419
2372
|
length: 0
|
|
2420
2373
|
};
|
|
2421
|
-
const { count:
|
|
2374
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2422
2375
|
return {
|
|
2423
|
-
forms:
|
|
2376
|
+
forms: m,
|
|
2424
2377
|
start: n * r,
|
|
2425
2378
|
limit: r,
|
|
2426
|
-
length: W(
|
|
2379
|
+
length: W(d)
|
|
2427
2380
|
};
|
|
2428
2381
|
};
|
|
2429
2382
|
}
|
|
@@ -2488,8 +2441,8 @@ function si(t) {
|
|
|
2488
2441
|
scopes: l,
|
|
2489
2442
|
options: u,
|
|
2490
2443
|
skip_consent_for_verifiable_first_party_clients: _,
|
|
2491
|
-
allow_offline_access:
|
|
2492
|
-
is_system:
|
|
2444
|
+
allow_offline_access: m,
|
|
2445
|
+
is_system: d,
|
|
2493
2446
|
metadata: f,
|
|
2494
2447
|
...p
|
|
2495
2448
|
} = o, y = {
|
|
@@ -2498,8 +2451,8 @@ function si(t) {
|
|
|
2498
2451
|
scopes: l ? JSON.stringify(l) : "[]",
|
|
2499
2452
|
options: u ? JSON.stringify(u) : "{}",
|
|
2500
2453
|
skip_consent_for_verifiable_first_party_clients: _ ? 1 : 0,
|
|
2501
|
-
allow_offline_access:
|
|
2502
|
-
is_system:
|
|
2454
|
+
allow_offline_access: m ? 1 : 0,
|
|
2455
|
+
is_system: d ? 1 : 0,
|
|
2503
2456
|
metadata: f ? JSON.stringify(f) : void 0,
|
|
2504
2457
|
verification_key: s,
|
|
2505
2458
|
created_at: n,
|
|
@@ -2518,8 +2471,8 @@ function ii(t) {
|
|
|
2518
2471
|
options: l,
|
|
2519
2472
|
skip_consent_for_verifiable_first_party_clients: u,
|
|
2520
2473
|
allow_offline_access: _,
|
|
2521
|
-
is_system:
|
|
2522
|
-
metadata:
|
|
2474
|
+
is_system: m,
|
|
2475
|
+
metadata: d,
|
|
2523
2476
|
...f
|
|
2524
2477
|
} = r, p = {
|
|
2525
2478
|
...f,
|
|
@@ -2527,8 +2480,8 @@ function ii(t) {
|
|
|
2527
2480
|
options: l ? JSON.parse(l) : {},
|
|
2528
2481
|
skip_consent_for_verifiable_first_party_clients: !!u,
|
|
2529
2482
|
allow_offline_access: !!_,
|
|
2530
|
-
is_system:
|
|
2531
|
-
metadata:
|
|
2483
|
+
is_system: m ? !0 : void 0,
|
|
2484
|
+
metadata: d ? JSON.parse(d) : void 0,
|
|
2532
2485
|
// Convert verification_key back to verificationKey for API
|
|
2533
2486
|
verificationKey: o
|
|
2534
2487
|
};
|
|
@@ -2550,7 +2503,7 @@ function ci(t) {
|
|
|
2550
2503
|
"resource_servers.identifier"
|
|
2551
2504
|
]);
|
|
2552
2505
|
}
|
|
2553
|
-
const
|
|
2506
|
+
const m = (await l.offset(n * r).limit(r).selectAll().execute()).map((f) => {
|
|
2554
2507
|
const p = f, {
|
|
2555
2508
|
verification_key: y,
|
|
2556
2509
|
scopes: N,
|
|
@@ -2575,17 +2528,17 @@ function ci(t) {
|
|
|
2575
2528
|
});
|
|
2576
2529
|
if (!o)
|
|
2577
2530
|
return {
|
|
2578
|
-
resource_servers:
|
|
2531
|
+
resource_servers: m,
|
|
2579
2532
|
start: 0,
|
|
2580
2533
|
limit: 0,
|
|
2581
2534
|
length: 0
|
|
2582
2535
|
};
|
|
2583
|
-
const { count:
|
|
2536
|
+
const { count: d } = await l.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2584
2537
|
return {
|
|
2585
|
-
resource_servers:
|
|
2538
|
+
resource_servers: m,
|
|
2586
2539
|
start: n * r,
|
|
2587
2540
|
limit: r,
|
|
2588
|
-
length: W(
|
|
2541
|
+
length: W(d)
|
|
2589
2542
|
};
|
|
2590
2543
|
};
|
|
2591
2544
|
}
|
|
@@ -2604,17 +2557,17 @@ function ui(t) {
|
|
|
2604
2557
|
skip_consent_for_verifiable_first_party_clients: l,
|
|
2605
2558
|
allow_offline_access: u,
|
|
2606
2559
|
is_system: _,
|
|
2607
|
-
metadata:
|
|
2608
|
-
...
|
|
2560
|
+
metadata: m,
|
|
2561
|
+
...d
|
|
2609
2562
|
} = n, f = {
|
|
2610
|
-
...
|
|
2563
|
+
...d,
|
|
2611
2564
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
2612
2565
|
};
|
|
2613
2566
|
if (r !== void 0 && (f.verification_key = r), o !== void 0 && (f.scopes = JSON.stringify(o)), s !== void 0) {
|
|
2614
2567
|
const y = await t.selectFrom("resource_servers").select("options").where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst(), T = { ...y != null && y.options ? JSON.parse(y.options) : {}, ...s };
|
|
2615
2568
|
f.options = JSON.stringify(T);
|
|
2616
2569
|
}
|
|
2617
|
-
|
|
2570
|
+
m !== void 0 && (f.metadata = JSON.stringify(m)), l !== void 0 && (f.skip_consent_for_verifiable_first_party_clients = l ? 1 : 0), u !== void 0 && (f.allow_offline_access = u ? 1 : 0), _ !== void 0 && (f.is_system = _ ? 1 : 0);
|
|
2618
2571
|
const p = await t.updateTable("resource_servers").set(f).where("tenant_id", "=", e).where("id", "=", a).executeTakeFirst();
|
|
2619
2572
|
return Number(p.numUpdatedRows) > 0;
|
|
2620
2573
|
};
|
|
@@ -2666,8 +2619,8 @@ function hi(t) {
|
|
|
2666
2619
|
let n = t.selectFrom("roles").where("roles.tenant_id", "=", e);
|
|
2667
2620
|
const { page: r = 0, per_page: o = 50, include_totals: s = !1 } = a;
|
|
2668
2621
|
a.q && (n = q(t, n, a.q, ["name"]));
|
|
2669
|
-
const _ = (await n.offset(r * o).limit(o).selectAll().execute()).map((
|
|
2670
|
-
const f =
|
|
2622
|
+
const _ = (await n.offset(r * o).limit(o).selectAll().execute()).map((d) => {
|
|
2623
|
+
const f = d, { is_system: p, tenant_id: y, metadata: N, ...T } = f;
|
|
2671
2624
|
return {
|
|
2672
2625
|
...T,
|
|
2673
2626
|
is_system: p ? !0 : void 0,
|
|
@@ -2681,12 +2634,12 @@ function hi(t) {
|
|
|
2681
2634
|
limit: o,
|
|
2682
2635
|
length: _.length
|
|
2683
2636
|
};
|
|
2684
|
-
const { count:
|
|
2637
|
+
const { count: m } = await n.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
2685
2638
|
return {
|
|
2686
2639
|
roles: _,
|
|
2687
2640
|
start: r * o,
|
|
2688
2641
|
limit: o,
|
|
2689
|
-
length: W(
|
|
2642
|
+
length: W(m)
|
|
2690
2643
|
};
|
|
2691
2644
|
};
|
|
2692
2645
|
}
|
|
@@ -2770,7 +2723,7 @@ function vi(t) {
|
|
|
2770
2723
|
const { page: r = 0, per_page: o = 50, include_totals: s = !1 } = n;
|
|
2771
2724
|
let l = t.selectFrom("role_permissions").leftJoin(
|
|
2772
2725
|
"resource_servers",
|
|
2773
|
-
(
|
|
2726
|
+
(d) => d.onRef(
|
|
2774
2727
|
"role_permissions.tenant_id",
|
|
2775
2728
|
"=",
|
|
2776
2729
|
"resource_servers.tenant_id"
|
|
@@ -2786,17 +2739,17 @@ function vi(t) {
|
|
|
2786
2739
|
"role_permissions.created_at",
|
|
2787
2740
|
"resource_servers.name as resource_server_name"
|
|
2788
2741
|
]).where("role_permissions.tenant_id", "=", e).where("role_permissions.role_id", "=", a);
|
|
2789
|
-
const
|
|
2790
|
-
role_id:
|
|
2791
|
-
resource_server_identifier:
|
|
2792
|
-
resource_server_name:
|
|
2742
|
+
const m = (await l.offset(r * o).limit(o).execute()).map((d) => ({
|
|
2743
|
+
role_id: d.role_id,
|
|
2744
|
+
resource_server_identifier: d.resource_server_identifier,
|
|
2745
|
+
resource_server_name: d.resource_server_name || d.resource_server_identifier,
|
|
2793
2746
|
// Fallback to identifier if name is null
|
|
2794
|
-
permission_name:
|
|
2747
|
+
permission_name: d.permission_name,
|
|
2795
2748
|
description: null,
|
|
2796
2749
|
// No description available from role_permissions directly
|
|
2797
|
-
created_at:
|
|
2750
|
+
created_at: d.created_at
|
|
2798
2751
|
}));
|
|
2799
|
-
return s && await l.select((
|
|
2752
|
+
return s && await l.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), m;
|
|
2800
2753
|
};
|
|
2801
2754
|
}
|
|
2802
2755
|
function Ni(t) {
|
|
@@ -7370,44 +7323,44 @@ function nl(t) {
|
|
|
7370
7323
|
return async (e, a) => {
|
|
7371
7324
|
let n = t.selectFrom("organizations").selectAll().where("tenant_id", "=", e);
|
|
7372
7325
|
if (a != null && a.q && (n = n.where(
|
|
7373
|
-
(
|
|
7374
|
-
|
|
7375
|
-
|
|
7326
|
+
(m) => m.or([
|
|
7327
|
+
m("name", "like", `%${a.q}%`),
|
|
7328
|
+
m("display_name", "like", `%${a.q}%`)
|
|
7376
7329
|
])
|
|
7377
7330
|
)), a != null && a.sort) {
|
|
7378
|
-
const
|
|
7379
|
-
["name", "display_name", "created_at"].includes(
|
|
7331
|
+
const m = a.sort.sort_order === "asc" ? "asc" : "desc", d = a.sort.sort_by;
|
|
7332
|
+
["name", "display_name", "created_at"].includes(d) ? n = n.orderBy(d, m) : n = n.orderBy("created_at", "desc");
|
|
7380
7333
|
} else
|
|
7381
7334
|
n = n.orderBy("created_at", "desc");
|
|
7382
7335
|
if ((a == null ? void 0 : a.from) !== void 0) {
|
|
7383
|
-
const
|
|
7384
|
-
isNaN(
|
|
7336
|
+
const m = parseInt(a.from, 10);
|
|
7337
|
+
isNaN(m) || (n = n.offset(m));
|
|
7385
7338
|
} else if ((a == null ? void 0 : a.page) !== void 0) {
|
|
7386
|
-
const
|
|
7387
|
-
n = n.offset(
|
|
7339
|
+
const m = (a == null ? void 0 : a.per_page) || (a == null ? void 0 : a.take) || 10, d = a.page * m;
|
|
7340
|
+
n = n.offset(d);
|
|
7388
7341
|
}
|
|
7389
7342
|
const r = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10;
|
|
7390
7343
|
n = n.limit(r);
|
|
7391
7344
|
const o = await n.execute();
|
|
7392
7345
|
let s = o.length;
|
|
7393
7346
|
if (a != null && a.include_totals) {
|
|
7394
|
-
let
|
|
7395
|
-
a != null && a.q && (
|
|
7347
|
+
let m = t.selectFrom("organizations").select(w`count(*)`.as("count")).where("tenant_id", "=", e);
|
|
7348
|
+
a != null && a.q && (m = m.where(
|
|
7396
7349
|
(f) => f.or([
|
|
7397
7350
|
f("name", "like", `%${a.q}%`),
|
|
7398
7351
|
f("display_name", "like", `%${a.q}%`)
|
|
7399
7352
|
])
|
|
7400
7353
|
));
|
|
7401
|
-
const
|
|
7402
|
-
s = Number((
|
|
7354
|
+
const d = await m.executeTakeFirst();
|
|
7355
|
+
s = Number((d == null ? void 0 : d.count) || 0);
|
|
7403
7356
|
}
|
|
7404
7357
|
const l = o.map(
|
|
7405
|
-
(
|
|
7406
|
-
...
|
|
7407
|
-
branding:
|
|
7408
|
-
metadata:
|
|
7409
|
-
enabled_connections:
|
|
7410
|
-
token_quota:
|
|
7358
|
+
(m) => O({
|
|
7359
|
+
...m,
|
|
7360
|
+
branding: m.branding ? JSON.parse(m.branding) : {},
|
|
7361
|
+
metadata: m.metadata ? JSON.parse(m.metadata) : {},
|
|
7362
|
+
enabled_connections: m.enabled_connections ? JSON.parse(m.enabled_connections) : [],
|
|
7363
|
+
token_quota: m.token_quota ? JSON.parse(m.token_quota) : {}
|
|
7411
7364
|
})
|
|
7412
7365
|
), u = (a == null ? void 0 : a.take) || (a == null ? void 0 : a.per_page) || 10, _ = a != null && a.from ? parseInt(a.from, 10) : a != null && a.page ? a.page * u : 0;
|
|
7413
7366
|
return {
|
|
@@ -7484,11 +7437,11 @@ function ll(t) {
|
|
|
7484
7437
|
let s = t.selectFrom("user_organizations").selectAll().where("tenant_id", "=", e);
|
|
7485
7438
|
if (a != null && a.q) {
|
|
7486
7439
|
if (a.q.startsWith("user_id:")) {
|
|
7487
|
-
const
|
|
7488
|
-
s = s.where("user_id", "=",
|
|
7440
|
+
const d = a.q.replace("user_id:", "");
|
|
7441
|
+
s = s.where("user_id", "=", d);
|
|
7489
7442
|
} else if (a.q.startsWith("organization_id:")) {
|
|
7490
|
-
const
|
|
7491
|
-
s = s.where("organization_id", "=",
|
|
7443
|
+
const d = a.q.replace("organization_id:", "");
|
|
7444
|
+
s = s.where("organization_id", "=", d);
|
|
7492
7445
|
}
|
|
7493
7446
|
}
|
|
7494
7447
|
s = s.orderBy("created_at", "desc"), r > 0 && (s = s.limit(r).offset(o));
|
|
@@ -7496,21 +7449,21 @@ function ll(t) {
|
|
|
7496
7449
|
let u = t.selectFrom("user_organizations").select(t.fn.count("id").as("count")).where("tenant_id", "=", e);
|
|
7497
7450
|
if (a != null && a.q) {
|
|
7498
7451
|
if (a.q.startsWith("user_id:")) {
|
|
7499
|
-
const
|
|
7500
|
-
u = u.where("user_id", "=",
|
|
7452
|
+
const d = a.q.replace("user_id:", "");
|
|
7453
|
+
u = u.where("user_id", "=", d);
|
|
7501
7454
|
} else if (a.q.startsWith("organization_id:")) {
|
|
7502
|
-
const
|
|
7503
|
-
u = u.where("organization_id", "=",
|
|
7455
|
+
const d = a.q.replace("organization_id:", "");
|
|
7456
|
+
u = u.where("organization_id", "=", d);
|
|
7504
7457
|
}
|
|
7505
7458
|
}
|
|
7506
7459
|
const _ = await u.executeTakeFirst();
|
|
7507
7460
|
return {
|
|
7508
|
-
userOrganizations: l.map((
|
|
7509
|
-
id:
|
|
7510
|
-
user_id:
|
|
7511
|
-
organization_id:
|
|
7512
|
-
created_at:
|
|
7513
|
-
updated_at:
|
|
7461
|
+
userOrganizations: l.map((d) => ({
|
|
7462
|
+
id: d.id,
|
|
7463
|
+
user_id: d.user_id,
|
|
7464
|
+
organization_id: d.organization_id,
|
|
7465
|
+
created_at: d.created_at,
|
|
7466
|
+
updated_at: d.updated_at
|
|
7514
7467
|
})),
|
|
7515
7468
|
start: o,
|
|
7516
7469
|
limit: r,
|
|
@@ -7523,7 +7476,7 @@ function ul(t) {
|
|
|
7523
7476
|
const r = (n == null ? void 0 : n.page) || 0, o = (n == null ? void 0 : n.per_page) || 50, s = r * o;
|
|
7524
7477
|
let l = t.selectFrom("user_organizations").innerJoin(
|
|
7525
7478
|
"organizations",
|
|
7526
|
-
(
|
|
7479
|
+
(d) => d.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", e)
|
|
7527
7480
|
).select([
|
|
7528
7481
|
"organizations.id",
|
|
7529
7482
|
"organizations.name",
|
|
@@ -7539,21 +7492,21 @@ function ul(t) {
|
|
|
7539
7492
|
l = l.orderBy("user_organizations.created_at", "desc"), o > 0 && (l = l.limit(o).offset(s));
|
|
7540
7493
|
const u = await l.execute(), _ = await t.selectFrom("user_organizations").innerJoin(
|
|
7541
7494
|
"organizations",
|
|
7542
|
-
(
|
|
7495
|
+
(d) => d.onRef("organizations.id", "=", "user_organizations.organization_id").on("organizations.tenant_id", "=", e)
|
|
7543
7496
|
).select(t.fn.count("user_organizations.id").as("count")).where("user_organizations.tenant_id", "=", e).where("user_organizations.user_id", "=", a).executeTakeFirst();
|
|
7544
7497
|
return {
|
|
7545
|
-
organizations: u.map((
|
|
7546
|
-
id:
|
|
7547
|
-
name:
|
|
7548
|
-
display_name:
|
|
7549
|
-
branding:
|
|
7550
|
-
metadata:
|
|
7551
|
-
enabled_connections:
|
|
7552
|
-
token_quota:
|
|
7553
|
-
created_at:
|
|
7554
|
-
updated_at:
|
|
7498
|
+
organizations: u.map((d) => ({
|
|
7499
|
+
id: d.id,
|
|
7500
|
+
name: d.name,
|
|
7501
|
+
display_name: d.display_name,
|
|
7502
|
+
branding: d.branding ? JSON.parse(d.branding) : void 0,
|
|
7503
|
+
metadata: d.metadata ? JSON.parse(d.metadata) : {},
|
|
7504
|
+
enabled_connections: d.enabled_connections ? JSON.parse(d.enabled_connections) : [],
|
|
7505
|
+
token_quota: d.token_quota ? JSON.parse(d.token_quota) : void 0,
|
|
7506
|
+
created_at: d.created_at,
|
|
7507
|
+
updated_at: d.updated_at,
|
|
7555
7508
|
// Add membership info
|
|
7556
|
-
joined_at:
|
|
7509
|
+
joined_at: d.joined_at
|
|
7557
7510
|
})),
|
|
7558
7511
|
start: s,
|
|
7559
7512
|
limit: o,
|
|
@@ -7729,26 +7682,26 @@ function Nl(t) {
|
|
|
7729
7682
|
const { from: n, to: r } = a, o = /* @__PURE__ */ new Date(), s = new Date(o);
|
|
7730
7683
|
s.setDate(s.getDate() - 30);
|
|
7731
7684
|
const l = n ? _n(n) : mn(s), u = r ? _n(r) : mn(o), _ = w`DATE(logs.date)`;
|
|
7732
|
-
return (await t.selectFrom("logs").where("tenant_id", "=", e).where(_, ">=", l).where(_, "<=", u).select((
|
|
7685
|
+
return (await t.selectFrom("logs").where("tenant_id", "=", e).where(_, ">=", l).where(_, "<=", u).select((d) => [
|
|
7733
7686
|
_.as("date"),
|
|
7734
|
-
|
|
7735
|
-
|
|
7687
|
+
d.fn.sum(
|
|
7688
|
+
d.case().when("type", "in", dn).then(1).else(0).end()
|
|
7736
7689
|
).as("logins"),
|
|
7737
|
-
|
|
7738
|
-
|
|
7690
|
+
d.fn.sum(
|
|
7691
|
+
d.case().when("type", "=", "ss").then(1).else(0).end()
|
|
7739
7692
|
).as("signups"),
|
|
7740
|
-
|
|
7741
|
-
|
|
7693
|
+
d.fn.sum(
|
|
7694
|
+
d.case().when("type", "in", vl).then(1).else(0).end()
|
|
7742
7695
|
).as("leaked_passwords"),
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
]).groupBy(_).orderBy("date", "asc").execute()).map((
|
|
7746
|
-
date:
|
|
7747
|
-
logins: Number(
|
|
7748
|
-
signups: Number(
|
|
7749
|
-
leaked_passwords: Number(
|
|
7750
|
-
created_at:
|
|
7751
|
-
updated_at:
|
|
7696
|
+
d.fn.min("date").as("first_event"),
|
|
7697
|
+
d.fn.max("date").as("last_event")
|
|
7698
|
+
]).groupBy(_).orderBy("date", "asc").execute()).map((d) => ({
|
|
7699
|
+
date: d.date,
|
|
7700
|
+
logins: Number(d.logins) || 0,
|
|
7701
|
+
signups: Number(d.signups) || 0,
|
|
7702
|
+
leaked_passwords: Number(d.leaked_passwords) || 0,
|
|
7703
|
+
created_at: d.first_event || (/* @__PURE__ */ new Date()).toISOString(),
|
|
7704
|
+
updated_at: d.last_event || (/* @__PURE__ */ new Date()).toISOString()
|
|
7752
7705
|
}));
|
|
7753
7706
|
},
|
|
7754
7707
|
async getActiveUsers(e) {
|
|
@@ -10302,12 +10255,12 @@ async function zp(t) {
|
|
|
10302
10255
|
console.log(
|
|
10303
10256
|
"Running preflight length check on columns being narrowed..."
|
|
10304
10257
|
);
|
|
10305
|
-
const { rows:
|
|
10258
|
+
const { rows: m } = await w`SELECT
|
|
10306
10259
|
SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
|
|
10307
10260
|
SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
|
|
10308
10261
|
SUM(CASE WHEN CHAR_LENGTH(template_id) > 64 THEN 1 ELSE 0 END) AS long_template_id
|
|
10309
|
-
FROM hooks`.execute(t),
|
|
10310
|
-
if (
|
|
10262
|
+
FROM hooks`.execute(t), d = Number(((l = m[0]) == null ? void 0 : l.long_hook_id) ?? 0), f = Number(((u = m[0]) == null ? void 0 : u.long_form_id) ?? 0), p = Number(((_ = m[0]) == null ? void 0 : _.long_template_id) ?? 0), y = [];
|
|
10263
|
+
if (d > 0 && y.push(`${d} row(s) with hook_id longer than 21 chars`), f > 0 && y.push(
|
|
10311
10264
|
`${f} row(s) with form_id longer than 128 chars`
|
|
10312
10265
|
), p > 0 && y.push(
|
|
10313
10266
|
`${p} row(s) with template_id longer than 64 chars`
|
|
@@ -10322,7 +10275,7 @@ async function zp(t) {
|
|
|
10322
10275
|
console.log("Dropping old date columns from hooks..."), await hn(t, "hooks", "created_at"), await hn(t, "hooks", "updated_at"), e === "mysql" && (console.log("Fixing hook column types..."), await t.schema.alterTable("hooks").modifyColumn(
|
|
10323
10276
|
"hook_id",
|
|
10324
10277
|
"varchar(21)",
|
|
10325
|
-
(
|
|
10278
|
+
(m) => m.notNull().primaryKey()
|
|
10326
10279
|
).execute(), await t.schema.alterTable("hooks").modifyColumn("form_id", "varchar(128)").execute(), await t.schema.alterTable("hooks").modifyColumn("template_id", "varchar(64)").execute());
|
|
10327
10280
|
}
|
|
10328
10281
|
async function Fp(t) {
|