@authhero/kysely-adapter 10.24.0 → 10.26.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 +1 -1
- package/dist/kysely-adapter.d.ts +157 -56
- package/dist/kysely-adapter.mjs +117 -112
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -83,7 +83,7 @@ function qe(t) {
|
|
|
83
83
|
]);
|
|
84
84
|
if (!n)
|
|
85
85
|
return null;
|
|
86
|
-
const { tenant_id: r, ...s } = n,
|
|
86
|
+
const { tenant_id: r, ...s } = n, c = {
|
|
87
87
|
...s,
|
|
88
88
|
email: n.email || "",
|
|
89
89
|
email_verified: n.email_verified === 1,
|
|
@@ -100,18 +100,18 @@ function qe(t) {
|
|
|
100
100
|
...o.map(pe)
|
|
101
101
|
]
|
|
102
102
|
};
|
|
103
|
-
return f(
|
|
103
|
+
return f(c);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
function T(t, e, a, n) {
|
|
107
107
|
return a.split(/\s+/).map((r) => r.replace(/^([^:]+)=/g, "$1:")).map((r) => {
|
|
108
|
-
let s = r.startsWith("-"),
|
|
109
|
-
return r.startsWith("-_exists_:") ? (
|
|
110
|
-
}).forEach(({ key: r, value: s, isNegation:
|
|
108
|
+
let s = r.startsWith("-"), c, l, h, m;
|
|
109
|
+
return r.startsWith("-_exists_:") ? (c = r.substring(10), h = !0, s = !0) : r.startsWith("_exists_:") ? (c = r.substring(9), h = !0, s = !1) : r.includes(":") ? (s = r.startsWith("-"), [c, l] = s ? r.substring(1).split(":") : r.split(":"), h = !1, l.startsWith(">=") ? (m = ">=", l = l.substring(2)) : l.startsWith(">") ? (m = ">", l = l.substring(1)) : l.startsWith("<=") ? (m = "<=", l = l.substring(2)) : l.startsWith("<") ? (m = "<", l = l.substring(1)) : m = "=") : (c = null, l = r, h = !1), { key: c, value: l, isNegation: s, isExistsQuery: h, operator: m };
|
|
110
|
+
}).forEach(({ key: r, value: s, isNegation: c, isExistsQuery: l, operator: h }) => {
|
|
111
111
|
if (r)
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
else if (
|
|
112
|
+
if (l)
|
|
113
|
+
c ? e = e.where(r, "is", null) : e = e.where(r, "is not", null);
|
|
114
|
+
else if (c)
|
|
115
115
|
switch (h) {
|
|
116
116
|
case ">":
|
|
117
117
|
e = e.where(r, "<=", s);
|
|
@@ -154,8 +154,8 @@ function Ve(t) {
|
|
|
154
154
|
const { ref: m } = t.dynamic;
|
|
155
155
|
n = n.orderBy(m(a.sort.sort_by), a.sort.sort_order);
|
|
156
156
|
}
|
|
157
|
-
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = r.map((m) => m.user_id),
|
|
158
|
-
const w =
|
|
157
|
+
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = r.map((m) => m.user_id), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = r.map((m) => {
|
|
158
|
+
const w = c.filter(
|
|
159
159
|
(x) => x.linked_to === m.user_id
|
|
160
160
|
);
|
|
161
161
|
return f({
|
|
@@ -176,7 +176,7 @@ function Ve(t) {
|
|
|
176
176
|
});
|
|
177
177
|
}), { count: h } = await n.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
178
178
|
return {
|
|
179
|
-
users:
|
|
179
|
+
users: l,
|
|
180
180
|
start: a.page * a.per_page,
|
|
181
181
|
limit: a.per_page,
|
|
182
182
|
length: b(h)
|
|
@@ -272,16 +272,16 @@ function at(t) {
|
|
|
272
272
|
}) => {
|
|
273
273
|
let a = t.selectFrom("tenants");
|
|
274
274
|
if (e.sort && e.sort.sort_by) {
|
|
275
|
-
const { ref:
|
|
276
|
-
a = a.orderBy(
|
|
275
|
+
const { ref: c } = t.dynamic;
|
|
276
|
+
a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
|
|
277
277
|
}
|
|
278
|
-
e.q && (a = a.where((
|
|
278
|
+
e.q && (a = a.where((c) => c.or([c("name", "like", `%${e.q}%`)])));
|
|
279
279
|
const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
|
|
280
280
|
if (!e.include_totals)
|
|
281
281
|
return {
|
|
282
282
|
tenants: o
|
|
283
283
|
};
|
|
284
|
-
const { count: r } = await a.select((
|
|
284
|
+
const { count: r } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(r);
|
|
285
285
|
return {
|
|
286
286
|
tenants: o.map(f),
|
|
287
287
|
start: (e.page - 1) * e.per_page,
|
|
@@ -358,7 +358,7 @@ function ge(t) {
|
|
|
358
358
|
_id: t.id
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function lt(t) {
|
|
362
362
|
return async (e, a = {
|
|
363
363
|
page: 0,
|
|
364
364
|
per_page: 50,
|
|
@@ -368,14 +368,14 @@ function ct(t) {
|
|
|
368
368
|
a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
|
|
369
369
|
let o = n;
|
|
370
370
|
if (a.sort && a.sort.sort_by) {
|
|
371
|
-
const { ref:
|
|
371
|
+
const { ref: c } = t.dynamic;
|
|
372
372
|
o = o.orderBy(
|
|
373
|
-
|
|
373
|
+
c(a.sort.sort_by),
|
|
374
374
|
a.sort.sort_order
|
|
375
375
|
);
|
|
376
376
|
}
|
|
377
377
|
o = o.offset(a.page * a.per_page).limit(a.per_page);
|
|
378
|
-
const r = await o.selectAll().execute(), { count: s } = await n.select((
|
|
378
|
+
const r = await o.selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
379
379
|
return {
|
|
380
380
|
logs: r.map(ge),
|
|
381
381
|
start: a.page * a.per_page,
|
|
@@ -384,7 +384,7 @@ function ct(t) {
|
|
|
384
384
|
};
|
|
385
385
|
};
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function ct(t) {
|
|
388
388
|
return async (e, a) => {
|
|
389
389
|
const n = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
|
|
390
390
|
return n ? ge(n) : null;
|
|
@@ -393,8 +393,8 @@ function lt(t) {
|
|
|
393
393
|
function dt(t) {
|
|
394
394
|
return {
|
|
395
395
|
create: it(t),
|
|
396
|
-
list:
|
|
397
|
-
get:
|
|
396
|
+
list: lt(t),
|
|
397
|
+
get: ct(t)
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
400
|
function ut(t) {
|
|
@@ -402,9 +402,9 @@ function ut(t) {
|
|
|
402
402
|
const n = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
|
|
403
403
|
if (!n)
|
|
404
404
|
return null;
|
|
405
|
-
const { tenant_id: o, device: r, clients: s, ...
|
|
405
|
+
const { tenant_id: o, device: r, clients: s, ...c } = n;
|
|
406
406
|
return {
|
|
407
|
-
...
|
|
407
|
+
...c,
|
|
408
408
|
device: JSON.parse(r),
|
|
409
409
|
clients: JSON.parse(s)
|
|
410
410
|
};
|
|
@@ -451,23 +451,23 @@ function ft(t) {
|
|
|
451
451
|
a.q && (n = T(t, n, a.q, ["user_id", "session_id"]));
|
|
452
452
|
let o = n;
|
|
453
453
|
if (a.sort && a.sort.sort_by) {
|
|
454
|
-
const { ref:
|
|
454
|
+
const { ref: l } = t.dynamic;
|
|
455
455
|
o = o.orderBy(
|
|
456
|
-
|
|
456
|
+
l(a.sort.sort_by),
|
|
457
457
|
a.sort.sort_order
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
460
|
o = o.offset(a.page * a.per_page).limit(a.per_page);
|
|
461
|
-
const r = await o.selectAll().execute(), { count: s } = await n.select((
|
|
461
|
+
const r = await o.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
462
462
|
return {
|
|
463
|
-
sessions: r.map((
|
|
464
|
-
...
|
|
465
|
-
device: JSON.parse(
|
|
466
|
-
clients: JSON.parse(
|
|
463
|
+
sessions: r.map((l) => ({
|
|
464
|
+
...l,
|
|
465
|
+
device: JSON.parse(l.device),
|
|
466
|
+
clients: JSON.parse(l.clients)
|
|
467
467
|
})),
|
|
468
468
|
start: a.page * a.per_page,
|
|
469
469
|
limit: a.per_page,
|
|
470
|
-
length:
|
|
470
|
+
length: c
|
|
471
471
|
};
|
|
472
472
|
};
|
|
473
473
|
}
|
|
@@ -523,10 +523,10 @@ function Nt(t) {
|
|
|
523
523
|
}) => {
|
|
524
524
|
let n = t.selectFrom("codes").where("codes.tenant_id", "=", e);
|
|
525
525
|
a.q && (n = T(t, n, a.q, ["code", "login_id"]));
|
|
526
|
-
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((
|
|
526
|
+
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
527
527
|
return {
|
|
528
|
-
codes: r.map((
|
|
529
|
-
const { tenant_id: h, ...m } =
|
|
528
|
+
codes: r.map((l) => {
|
|
529
|
+
const { tenant_id: h, ...m } = l;
|
|
530
530
|
return Ke.parse(f(m));
|
|
531
531
|
}),
|
|
532
532
|
start: a.page * a.per_page,
|
|
@@ -576,7 +576,7 @@ function Ot(t) {
|
|
|
576
576
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
577
577
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
578
578
|
...a
|
|
579
|
-
}, o = JSON.stringify(a.allowed_origins), r = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins),
|
|
579
|
+
}, o = JSON.stringify(a.allowed_origins), r = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), l = JSON.stringify(a.allowed_clients);
|
|
580
580
|
return await t.insertInto("applications").values({
|
|
581
581
|
...n,
|
|
582
582
|
tenant_id: e,
|
|
@@ -585,8 +585,8 @@ function Ot(t) {
|
|
|
585
585
|
callbacks: r,
|
|
586
586
|
allowed_origins: o,
|
|
587
587
|
web_origins: s,
|
|
588
|
-
allowed_logout_urls:
|
|
589
|
-
allowed_clients:
|
|
588
|
+
allowed_logout_urls: c,
|
|
589
|
+
allowed_clients: l
|
|
590
590
|
}).execute(), n;
|
|
591
591
|
};
|
|
592
592
|
}
|
|
@@ -671,16 +671,16 @@ function Mt(t) {
|
|
|
671
671
|
let n = t.selectFrom("connections").where("connections.tenant_id", "=", e);
|
|
672
672
|
a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
|
|
673
673
|
const s = (await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
|
|
674
|
-
(
|
|
675
|
-
...
|
|
676
|
-
options: JSON.parse(
|
|
674
|
+
(l) => f({
|
|
675
|
+
...l,
|
|
676
|
+
options: JSON.parse(l.options)
|
|
677
677
|
})
|
|
678
|
-
), { count:
|
|
678
|
+
), { count: c } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
679
679
|
return {
|
|
680
680
|
connections: s,
|
|
681
681
|
start: a.page * a.per_page,
|
|
682
682
|
limit: a.per_page,
|
|
683
|
-
length: b(
|
|
683
|
+
length: b(c)
|
|
684
684
|
};
|
|
685
685
|
};
|
|
686
686
|
}
|
|
@@ -847,8 +847,8 @@ function Xt(t) {
|
|
|
847
847
|
colors_primary: o,
|
|
848
848
|
colors_page_background_type: r,
|
|
849
849
|
colors_page_background_start: s,
|
|
850
|
-
colors_page_background_end:
|
|
851
|
-
colors_page_background_angle_dev:
|
|
850
|
+
colors_page_background_end: c,
|
|
851
|
+
colors_page_background_angle_dev: l,
|
|
852
852
|
font_url: h,
|
|
853
853
|
...m
|
|
854
854
|
} = a;
|
|
@@ -859,8 +859,8 @@ function Xt(t) {
|
|
|
859
859
|
page_background: {
|
|
860
860
|
type: r,
|
|
861
861
|
start: s,
|
|
862
|
-
end:
|
|
863
|
-
angle_deg:
|
|
862
|
+
end: c,
|
|
863
|
+
angle_deg: l
|
|
864
864
|
}
|
|
865
865
|
},
|
|
866
866
|
font: h ? { url: h } : void 0
|
|
@@ -869,14 +869,14 @@ function Xt(t) {
|
|
|
869
869
|
}
|
|
870
870
|
function Yt(t) {
|
|
871
871
|
return async (e, a) => {
|
|
872
|
-
var s,
|
|
872
|
+
var s, c, l, h, m, w, x, ee, te, ae, ne, re, oe, se, ie, le, ce, de;
|
|
873
873
|
const { colors: n, font: o, ...r } = a;
|
|
874
874
|
try {
|
|
875
875
|
await t.insertInto("branding").values({
|
|
876
876
|
...r,
|
|
877
877
|
colors_primary: n == null ? void 0 : n.primary,
|
|
878
|
-
colors_page_background_type: (
|
|
879
|
-
colors_page_background_start: (h = (
|
|
878
|
+
colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
|
|
879
|
+
colors_page_background_start: (h = (l = a.colors) == null ? void 0 : l.page_background) == null ? void 0 : h.start,
|
|
880
880
|
colors_page_background_end: (w = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
|
|
881
881
|
colors_page_background_angle_dev: (ee = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : ee.angle_deg,
|
|
882
882
|
font_url: (te = a.font) == null ? void 0 : te.url,
|
|
@@ -889,7 +889,7 @@ function Yt(t) {
|
|
|
889
889
|
colors_page_background_type: (ne = (ae = a.colors) == null ? void 0 : ae.page_background) == null ? void 0 : ne.type,
|
|
890
890
|
colors_page_background_start: (oe = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : oe.start,
|
|
891
891
|
colors_page_background_end: (ie = (se = a.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
|
|
892
|
-
colors_page_background_angle_dev: (
|
|
892
|
+
colors_page_background_angle_dev: (ce = (le = a.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
|
|
893
893
|
font_url: (de = a.font) == null ? void 0 : de.url
|
|
894
894
|
}).where("tenant_id", "=", e).execute();
|
|
895
895
|
}
|
|
@@ -909,10 +909,10 @@ function ea(t) {
|
|
|
909
909
|
}) => {
|
|
910
910
|
let n = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
|
|
911
911
|
a.q && (n = T(t, n, a.q, ["url", "form_id"]));
|
|
912
|
-
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((
|
|
912
|
+
const r = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
913
913
|
return {
|
|
914
|
-
hooks: r.map((
|
|
915
|
-
const { tenant_id: h, enabled: m, synchronous: w, ...x } =
|
|
914
|
+
hooks: r.map((l) => {
|
|
915
|
+
const { tenant_id: h, enabled: m, synchronous: w, ...x } = l;
|
|
916
916
|
return f({
|
|
917
917
|
...x,
|
|
918
918
|
enabled: !!m,
|
|
@@ -988,13 +988,13 @@ function sa(t) {
|
|
|
988
988
|
function ia(t) {
|
|
989
989
|
return async (e, a) => (await t.deleteFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
|
|
990
990
|
}
|
|
991
|
-
function
|
|
991
|
+
function la(t) {
|
|
992
992
|
return async (e, a) => {
|
|
993
993
|
const n = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
|
|
994
994
|
return n ? f(n) : null;
|
|
995
995
|
};
|
|
996
996
|
}
|
|
997
|
-
function
|
|
997
|
+
function ca(t) {
|
|
998
998
|
return async (e, a, n) => {
|
|
999
999
|
const o = P({
|
|
1000
1000
|
...n,
|
|
@@ -1006,9 +1006,9 @@ function la(t) {
|
|
|
1006
1006
|
function da(t) {
|
|
1007
1007
|
return {
|
|
1008
1008
|
create: sa(t),
|
|
1009
|
-
get:
|
|
1009
|
+
get: la(t),
|
|
1010
1010
|
remove: ia(t),
|
|
1011
|
-
update:
|
|
1011
|
+
update: ca(t)
|
|
1012
1012
|
};
|
|
1013
1013
|
}
|
|
1014
1014
|
function ua(t) {
|
|
@@ -1109,10 +1109,10 @@ function wa(t) {
|
|
|
1109
1109
|
credentials: o,
|
|
1110
1110
|
settings: r,
|
|
1111
1111
|
enabled: s,
|
|
1112
|
-
...
|
|
1112
|
+
...c
|
|
1113
1113
|
} = a;
|
|
1114
1114
|
return f({
|
|
1115
|
-
...
|
|
1115
|
+
...c,
|
|
1116
1116
|
credentials: JSON.parse(o),
|
|
1117
1117
|
settings: JSON.parse(r),
|
|
1118
1118
|
enabled: !!s
|
|
@@ -1201,24 +1201,24 @@ function Oa(t) {
|
|
|
1201
1201
|
a.q && (n = T(t, n, a.q, ["token", "session_id"]));
|
|
1202
1202
|
let o = n;
|
|
1203
1203
|
if (a.sort && a.sort.sort_by) {
|
|
1204
|
-
const { ref:
|
|
1204
|
+
const { ref: l } = t.dynamic;
|
|
1205
1205
|
o = o.orderBy(
|
|
1206
|
-
|
|
1206
|
+
l(a.sort.sort_by),
|
|
1207
1207
|
a.sort.sort_order
|
|
1208
1208
|
);
|
|
1209
1209
|
}
|
|
1210
1210
|
o = o.offset(a.page * a.per_page).limit(a.per_page);
|
|
1211
|
-
const r = await o.selectAll().execute(), { count: s } = await n.select((
|
|
1211
|
+
const r = await o.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
1212
1212
|
return {
|
|
1213
|
-
refresh_tokens: r.map((
|
|
1214
|
-
...
|
|
1215
|
-
rotating: !!
|
|
1216
|
-
device:
|
|
1217
|
-
resource_servers:
|
|
1213
|
+
refresh_tokens: r.map((l) => ({
|
|
1214
|
+
...l,
|
|
1215
|
+
rotating: !!l.rotating,
|
|
1216
|
+
device: l.device ? JSON.parse(l.device) : {},
|
|
1217
|
+
resource_servers: l.resource_servers ? JSON.parse(l.resource_servers) : []
|
|
1218
1218
|
})),
|
|
1219
1219
|
start: a.page * a.per_page,
|
|
1220
1220
|
limit: a.per_page,
|
|
1221
|
-
length:
|
|
1221
|
+
length: c
|
|
1222
1222
|
};
|
|
1223
1223
|
};
|
|
1224
1224
|
}
|
|
@@ -1238,7 +1238,12 @@ function $a(t) {
|
|
|
1238
1238
|
).toISOString(), n = new Date(
|
|
1239
1239
|
Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
|
|
1240
1240
|
).toISOString();
|
|
1241
|
-
console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", n).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where(
|
|
1241
|
+
console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", n).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where(
|
|
1242
|
+
(r) => r.or([
|
|
1243
|
+
r("expires_at", "<", a),
|
|
1244
|
+
r("idle_expires_at", "<", a)
|
|
1245
|
+
])
|
|
1246
|
+
).limit(1e4).execute(), console.log("delete sessions");
|
|
1242
1247
|
const o = await t.selectFrom("sessions").select("id").where(
|
|
1243
1248
|
(r) => r.or([
|
|
1244
1249
|
r("expires_at", "<", a),
|
|
@@ -1282,8 +1287,8 @@ function Ia(t) {
|
|
|
1282
1287
|
}) => {
|
|
1283
1288
|
let n = t.selectFrom("forms").where("tenant_id", "=", e);
|
|
1284
1289
|
a != null && a.q && (n = T(t, n, a.q, []));
|
|
1285
|
-
const s = (await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((
|
|
1286
|
-
const h = { ...
|
|
1290
|
+
const s = (await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map((l) => {
|
|
1291
|
+
const h = { ...l };
|
|
1287
1292
|
if (typeof h.nodes == "string")
|
|
1288
1293
|
try {
|
|
1289
1294
|
h.nodes = JSON.parse(h.nodes);
|
|
@@ -1300,12 +1305,12 @@ function Ia(t) {
|
|
|
1300
1305
|
} catch {
|
|
1301
1306
|
}
|
|
1302
1307
|
return K.parse(f(h));
|
|
1303
|
-
}), { count:
|
|
1308
|
+
}), { count: c } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1304
1309
|
return {
|
|
1305
1310
|
forms: s,
|
|
1306
1311
|
start: a.page * a.per_page,
|
|
1307
1312
|
limit: a.per_page,
|
|
1308
|
-
length: b(
|
|
1313
|
+
length: b(c)
|
|
1309
1314
|
};
|
|
1310
1315
|
};
|
|
1311
1316
|
}
|
|
@@ -2463,9 +2468,9 @@ class Ce {
|
|
|
2463
2468
|
return u(this, i, A).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: o }) => {
|
|
2464
2469
|
if (e === Qa)
|
|
2465
2470
|
return { direction: "Down", step: 1 / 0 };
|
|
2466
|
-
if (!a.find((
|
|
2471
|
+
if (!a.find((c) => c.name === e))
|
|
2467
2472
|
throw new Error(`migration "${e}" doesn't exist`);
|
|
2468
|
-
const r = n.indexOf(e), s = o.findIndex((
|
|
2473
|
+
const r = n.indexOf(e), s = o.findIndex((c) => c.name === e);
|
|
2469
2474
|
if (r !== -1)
|
|
2470
2475
|
return {
|
|
2471
2476
|
direction: "Down",
|
|
@@ -2581,8 +2586,8 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2581
2586
|
const s = await u(this, i, De).call(this, r);
|
|
2582
2587
|
if (s.migrations.length === 0)
|
|
2583
2588
|
return { results: [] };
|
|
2584
|
-
const { direction:
|
|
2585
|
-
return
|
|
2589
|
+
const { direction: c, step: l } = e(s);
|
|
2590
|
+
return l <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Fe).call(this, r, s, l) : c === "Up" ? await u(this, i, Ae).call(this, r, s, l) : { results: [] };
|
|
2586
2591
|
} finally {
|
|
2587
2592
|
await a.releaseMigrationLock(r, n);
|
|
2588
2593
|
}
|
|
@@ -2617,26 +2622,26 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2617
2622
|
if (e[n].name !== a[n])
|
|
2618
2623
|
throw new Error(`corrupted migrations: expected previously executed migration ${a[n]} to be at index ${n} but ${e[n].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
|
|
2619
2624
|
}, Fe = async function(e, a, n) {
|
|
2620
|
-
const o = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((
|
|
2625
|
+
const o = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((c) => c.name === s)), r = o.map((s) => ({
|
|
2621
2626
|
migrationName: s.name,
|
|
2622
2627
|
direction: "Down",
|
|
2623
2628
|
status: "NotExecuted"
|
|
2624
2629
|
}));
|
|
2625
2630
|
for (let s = 0; s < r.length; ++s) {
|
|
2626
|
-
const
|
|
2631
|
+
const c = o[s];
|
|
2627
2632
|
try {
|
|
2628
|
-
|
|
2629
|
-
migrationName:
|
|
2633
|
+
c.down && (await c.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, N)).where("name", "=", c.name).execute(), r[s] = {
|
|
2634
|
+
migrationName: c.name,
|
|
2630
2635
|
direction: "Down",
|
|
2631
2636
|
status: "Success"
|
|
2632
2637
|
});
|
|
2633
|
-
} catch (
|
|
2638
|
+
} catch (l) {
|
|
2634
2639
|
throw r[s] = {
|
|
2635
|
-
migrationName:
|
|
2640
|
+
migrationName: c.name,
|
|
2636
2641
|
direction: "Down",
|
|
2637
2642
|
status: "Error"
|
|
2638
2643
|
}, new q({
|
|
2639
|
-
error:
|
|
2644
|
+
error: l,
|
|
2640
2645
|
results: r
|
|
2641
2646
|
});
|
|
2642
2647
|
}
|
|
@@ -2649,23 +2654,23 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2649
2654
|
status: "NotExecuted"
|
|
2650
2655
|
}));
|
|
2651
2656
|
for (let s = 0; s < r.length; s++) {
|
|
2652
|
-
const
|
|
2657
|
+
const c = a.pendingMigrations[s];
|
|
2653
2658
|
try {
|
|
2654
|
-
await
|
|
2655
|
-
name:
|
|
2659
|
+
await c.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, N)).values({
|
|
2660
|
+
name: c.name,
|
|
2656
2661
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2657
2662
|
}).execute(), r[s] = {
|
|
2658
|
-
migrationName:
|
|
2663
|
+
migrationName: c.name,
|
|
2659
2664
|
direction: "Up",
|
|
2660
2665
|
status: "Success"
|
|
2661
2666
|
};
|
|
2662
|
-
} catch (
|
|
2667
|
+
} catch (l) {
|
|
2663
2668
|
throw r[s] = {
|
|
2664
|
-
migrationName:
|
|
2669
|
+
migrationName: c.name,
|
|
2665
2670
|
direction: "Up",
|
|
2666
2671
|
status: "Error"
|
|
2667
2672
|
}, new q({
|
|
2668
|
-
error:
|
|
2673
|
+
error: l,
|
|
2669
2674
|
results: r
|
|
2670
2675
|
});
|
|
2671
2676
|
}
|
|
@@ -2821,7 +2826,7 @@ const sn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2821
2826
|
down: on,
|
|
2822
2827
|
up: rn
|
|
2823
2828
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2824
|
-
async function
|
|
2829
|
+
async function ln(t) {
|
|
2825
2830
|
await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
|
|
2826
2831
|
"user_id_constraint",
|
|
2827
2832
|
["user_id", "tenant_id"],
|
|
@@ -2846,13 +2851,13 @@ async function cn(t) {
|
|
|
2846
2851
|
(e) => e.references("applications.id").onDelete("cascade").notNull()
|
|
2847
2852
|
).addColumn("code", "varchar(255)", (e) => e.notNull()).addColumn("email", "varchar(255)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addColumn("send", "varchar(255)").addColumn("nonce", "varchar(255)").addColumn("state", "varchar(1024)").addColumn("scope", "varchar(1024)").addColumn("response_type", "varchar(256)").addColumn("response_mode", "varchar(256)").addColumn("redirect_uri", "varchar(1024)").addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("expires_at", "varchar(255)", (e) => e.notNull()).addColumn("used_at", "varchar(255)").execute(), await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(), await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute();
|
|
2848
2853
|
}
|
|
2849
|
-
async function
|
|
2854
|
+
async function cn(t) {
|
|
2850
2855
|
await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
|
|
2851
2856
|
}
|
|
2852
2857
|
const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2853
2858
|
__proto__: null,
|
|
2854
|
-
down:
|
|
2855
|
-
up:
|
|
2859
|
+
down: cn,
|
|
2860
|
+
up: ln
|
|
2856
2861
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2857
2862
|
async function un(t) {
|
|
2858
2863
|
await t.schema.createTable("passwords").addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addPrimaryKeyConstraint("passwords_pkey", ["user_id", "tenant_id"]).addForeignKeyConstraint(
|
|
@@ -3048,16 +3053,16 @@ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3048
3053
|
down: sr,
|
|
3049
3054
|
up: or
|
|
3050
3055
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3051
|
-
async function
|
|
3056
|
+
async function lr(t) {
|
|
3052
3057
|
await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
|
|
3053
3058
|
}
|
|
3054
|
-
async function
|
|
3059
|
+
async function cr(t) {
|
|
3055
3060
|
await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
|
|
3056
3061
|
}
|
|
3057
3062
|
const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3058
3063
|
__proto__: null,
|
|
3059
|
-
down:
|
|
3060
|
-
up:
|
|
3064
|
+
down: cr,
|
|
3065
|
+
up: lr
|
|
3061
3066
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3062
3067
|
async function ur(t) {
|
|
3063
3068
|
await t.schema.alterTable("logs").dropColumn("details").execute(), await t.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
|
|
@@ -3253,14 +3258,14 @@ const io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3253
3258
|
down: so,
|
|
3254
3259
|
up: oo
|
|
3255
3260
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3256
|
-
async function co(t) {
|
|
3257
|
-
}
|
|
3258
3261
|
async function lo(t) {
|
|
3259
3262
|
}
|
|
3263
|
+
async function co(t) {
|
|
3264
|
+
}
|
|
3260
3265
|
const uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3261
3266
|
__proto__: null,
|
|
3262
|
-
down:
|
|
3263
|
-
up:
|
|
3267
|
+
down: co,
|
|
3268
|
+
up: lo
|
|
3264
3269
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3265
3270
|
async function mo(t) {
|
|
3266
3271
|
}
|
|
@@ -3501,19 +3506,19 @@ async function ss(t) {
|
|
|
3501
3506
|
}
|
|
3502
3507
|
async function is(t) {
|
|
3503
3508
|
}
|
|
3504
|
-
const
|
|
3509
|
+
const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3505
3510
|
__proto__: null,
|
|
3506
3511
|
down: is,
|
|
3507
3512
|
up: ss
|
|
3508
3513
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3509
|
-
async function
|
|
3514
|
+
async function cs(t) {
|
|
3510
3515
|
}
|
|
3511
3516
|
async function ds(t) {
|
|
3512
3517
|
}
|
|
3513
3518
|
const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3514
3519
|
__proto__: null,
|
|
3515
3520
|
down: ds,
|
|
3516
|
-
up:
|
|
3521
|
+
up: cs
|
|
3517
3522
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3518
3523
|
async function ms(t) {
|
|
3519
3524
|
await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
|
|
@@ -3783,12 +3788,12 @@ async function si(t) {
|
|
|
3783
3788
|
async function ii(t) {
|
|
3784
3789
|
await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("login_sessions").execute(), await t.schema.dropTable("refresh_tokens").execute();
|
|
3785
3790
|
}
|
|
3786
|
-
const
|
|
3791
|
+
const li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3787
3792
|
__proto__: null,
|
|
3788
3793
|
down: ii,
|
|
3789
3794
|
up: si
|
|
3790
3795
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3791
|
-
async function
|
|
3796
|
+
async function ci(t) {
|
|
3792
3797
|
await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
|
|
3793
3798
|
}
|
|
3794
3799
|
async function di(t) {
|
|
@@ -3796,7 +3801,7 @@ async function di(t) {
|
|
|
3796
3801
|
const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3797
3802
|
__proto__: null,
|
|
3798
3803
|
down: di,
|
|
3799
|
-
up:
|
|
3804
|
+
up: ci
|
|
3800
3805
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3801
3806
|
async function mi(t) {
|
|
3802
3807
|
await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
|
|
@@ -3980,7 +3985,7 @@ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3980
3985
|
n56_application_fields: Zo,
|
|
3981
3986
|
n57_prompt_settings: as,
|
|
3982
3987
|
n58_connection_client_id: os,
|
|
3983
|
-
n59_connection_options:
|
|
3988
|
+
n59_connection_options: ls,
|
|
3984
3989
|
n60_users_metadata: us,
|
|
3985
3990
|
n61_userLocales: _s,
|
|
3986
3991
|
n62_prompt: gs,
|
|
@@ -3998,7 +4003,7 @@ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3998
4003
|
n75_organizations: Zs,
|
|
3999
4004
|
n76_authorization_url_length: ai,
|
|
4000
4005
|
n77_drop_sessions: oi,
|
|
4001
|
-
n78_login_sessions:
|
|
4006
|
+
n78_login_sessions: li,
|
|
4002
4007
|
n79_drop_sessions_2: ui,
|
|
4003
4008
|
n80_recreate_custom_domains: _i,
|
|
4004
4009
|
n81_phone: gi,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/markusahlstrand/authhero"
|
|
13
13
|
},
|
|
14
|
-
"version": "10.
|
|
14
|
+
"version": "10.26.0",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript": "^5.6.3",
|
|
39
39
|
"vite": "^5.4.11",
|
|
40
40
|
"vitest": "^2.1.5",
|
|
41
|
-
"@authhero/adapter-interfaces": "0.
|
|
41
|
+
"@authhero/adapter-interfaces": "0.74.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"kysely": "^0.27.4",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"hono": "^4.6.8",
|
|
50
50
|
"kysely-bun-sqlite": "^0.3.2",
|
|
51
51
|
"kysely-planetscale": "^1.5.0",
|
|
52
|
-
"@authhero/adapter-interfaces": "0.
|
|
52
|
+
"@authhero/adapter-interfaces": "0.74.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts",
|