@authhero/kysely-adapter 10.18.0 → 10.19.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 +6 -0
- package/dist/kysely-adapter.mjs +133 -121
- package/package.json +3 -3
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -4,7 +4,7 @@ var ue = (t) => {
|
|
|
4
4
|
};
|
|
5
5
|
var Ee = (t, e, a) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
6
6
|
var M = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || ue("Cannot " + a);
|
|
7
|
-
var
|
|
7
|
+
var d = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), F = (t, e, a, n) => (U(t, e, "write to private field"), n ? n.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
|
|
8
8
|
import { parseUserId as Z, codeSchema as Ke, connectionSchema as Re, loginSessionSchema as Ue, promptSettingSchema as Be, formSchema as K } from "@authhero/adapter-interfaces";
|
|
9
9
|
import "@hono/zod-openapi";
|
|
10
10
|
var V = class extends Error {
|
|
@@ -83,7 +83,7 @@ function qe(t) {
|
|
|
83
83
|
]);
|
|
84
84
|
if (!n)
|
|
85
85
|
return null;
|
|
86
|
-
const { tenant_id: o, ...s } = n,
|
|
86
|
+
const { tenant_id: o, ...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
|
...r.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((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
|
|
108
|
-
let s = o.startsWith("-"),
|
|
109
|
-
return o.startsWith("-_exists_:") ? (
|
|
110
|
-
}).forEach(({ key: o, value: s, isNegation:
|
|
108
|
+
let s = o.startsWith("-"), c, l, h, m;
|
|
109
|
+
return o.startsWith("-_exists_:") ? (c = o.substring(10), h = !0, s = !0) : o.startsWith("_exists_:") ? (c = o.substring(9), h = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [c, l] = s ? o.substring(1).split(":") : o.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 = o, h = !1), { key: c, value: l, isNegation: s, isExistsQuery: h, operator: m };
|
|
110
|
+
}).forEach(({ key: o, value: s, isNegation: c, isExistsQuery: l, operator: h }) => {
|
|
111
111
|
if (o)
|
|
112
112
|
if (l)
|
|
113
|
-
|
|
114
|
-
else if (
|
|
113
|
+
c ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
|
|
114
|
+
else if (c)
|
|
115
115
|
switch (h) {
|
|
116
116
|
case ">":
|
|
117
117
|
e = e.where(o, "<=", 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 o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.map((m) => m.user_id),
|
|
158
|
-
const w =
|
|
157
|
+
const o = await n.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.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 = o.map((m) => {
|
|
158
|
+
const w = c.filter(
|
|
159
159
|
(x) => x.linked_to === m.user_id
|
|
160
160
|
);
|
|
161
161
|
return f({
|
|
@@ -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 r = 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: r
|
|
283
283
|
};
|
|
284
|
-
const { count: o } = await a.select((
|
|
284
|
+
const { count: o } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(o);
|
|
285
285
|
return {
|
|
286
286
|
tenants: r.map(f),
|
|
287
287
|
start: (e.page - 1) * e.per_page,
|
|
@@ -368,14 +368,14 @@ function lt(t) {
|
|
|
368
368
|
a.q && (n = T(t, n, a.q, ["user_id", "ip"]));
|
|
369
369
|
let r = n;
|
|
370
370
|
if (a.sort && a.sort.sort_by) {
|
|
371
|
-
const { ref:
|
|
371
|
+
const { ref: c } = t.dynamic;
|
|
372
372
|
r = r.orderBy(
|
|
373
|
-
|
|
373
|
+
c(a.sort.sort_by),
|
|
374
374
|
a.sort.sort_order
|
|
375
375
|
);
|
|
376
376
|
}
|
|
377
377
|
r = r.offset(a.page * a.per_page).limit(a.per_page);
|
|
378
|
-
const o = await r.selectAll().execute(), { count: s } = await n.select((
|
|
378
|
+
const o = await r.selectAll().execute(), { count: s } = await n.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
379
379
|
return {
|
|
380
380
|
logs: o.map(ge),
|
|
381
381
|
start: a.page * a.per_page,
|
|
@@ -384,17 +384,17 @@ function lt(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;
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
|
-
function
|
|
393
|
+
function dt(t) {
|
|
394
394
|
return {
|
|
395
395
|
create: it(t),
|
|
396
396
|
list: lt(t),
|
|
397
|
-
get:
|
|
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: r, device: o, clients: s, ...
|
|
405
|
+
const { tenant_id: r, device: o, clients: s, ...c } = n;
|
|
406
406
|
return {
|
|
407
|
-
...
|
|
407
|
+
...c,
|
|
408
408
|
device: JSON.parse(o),
|
|
409
409
|
clients: JSON.parse(s)
|
|
410
410
|
};
|
|
@@ -458,7 +458,7 @@ function ft(t) {
|
|
|
458
458
|
);
|
|
459
459
|
}
|
|
460
460
|
r = r.offset(a.page * a.per_page).limit(a.per_page);
|
|
461
|
-
const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(),
|
|
461
|
+
const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
462
462
|
return {
|
|
463
463
|
sessions: o.map((l) => ({
|
|
464
464
|
...l,
|
|
@@ -467,7 +467,7 @@ function ft(t) {
|
|
|
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
|
}
|
|
@@ -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
|
-
}, r = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins),
|
|
579
|
+
}, r = JSON.stringify(a.allowed_origins), o = 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,7 +585,7 @@ function Ot(t) {
|
|
|
585
585
|
callbacks: o,
|
|
586
586
|
allowed_origins: r,
|
|
587
587
|
web_origins: s,
|
|
588
|
-
allowed_logout_urls:
|
|
588
|
+
allowed_logout_urls: c,
|
|
589
589
|
allowed_clients: l
|
|
590
590
|
}).execute(), n;
|
|
591
591
|
};
|
|
@@ -675,12 +675,12 @@ function Mt(t) {
|
|
|
675
675
|
...l,
|
|
676
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,7 +847,7 @@ function Xt(t) {
|
|
|
847
847
|
colors_primary: r,
|
|
848
848
|
colors_page_background_type: o,
|
|
849
849
|
colors_page_background_start: s,
|
|
850
|
-
colors_page_background_end:
|
|
850
|
+
colors_page_background_end: c,
|
|
851
851
|
colors_page_background_angle_dev: l,
|
|
852
852
|
font_url: h,
|
|
853
853
|
...m
|
|
@@ -859,7 +859,7 @@ function Xt(t) {
|
|
|
859
859
|
page_background: {
|
|
860
860
|
type: o,
|
|
861
861
|
start: s,
|
|
862
|
-
end:
|
|
862
|
+
end: c,
|
|
863
863
|
angle_deg: l
|
|
864
864
|
}
|
|
865
865
|
},
|
|
@@ -869,13 +869,13 @@ 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: r, ...o } = a;
|
|
874
874
|
try {
|
|
875
875
|
await t.insertInto("branding").values({
|
|
876
876
|
...o,
|
|
877
877
|
colors_primary: n == null ? void 0 : n.primary,
|
|
878
|
-
colors_page_background_type: (
|
|
878
|
+
colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
|
|
879
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,
|
|
@@ -889,8 +889,8 @@ 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: (
|
|
893
|
-
font_url: (
|
|
892
|
+
colors_page_background_angle_dev: (ce = (le = a.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
|
|
893
|
+
font_url: (de = a.font) == null ? void 0 : de.url
|
|
894
894
|
}).where("tenant_id", "=", e).execute();
|
|
895
895
|
}
|
|
896
896
|
};
|
|
@@ -994,7 +994,7 @@ function la(t) {
|
|
|
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 r = P({
|
|
1000
1000
|
...n,
|
|
@@ -1003,12 +1003,12 @@ function da(t) {
|
|
|
1003
1003
|
return await t.updateTable("themes").set(r).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
|
|
1004
1004
|
};
|
|
1005
1005
|
}
|
|
1006
|
-
function
|
|
1006
|
+
function da(t) {
|
|
1007
1007
|
return {
|
|
1008
1008
|
create: sa(t),
|
|
1009
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: r,
|
|
1110
1110
|
settings: o,
|
|
1111
1111
|
enabled: s,
|
|
1112
|
-
...
|
|
1112
|
+
...c
|
|
1113
1113
|
} = a;
|
|
1114
1114
|
return f({
|
|
1115
|
-
...
|
|
1115
|
+
...c,
|
|
1116
1116
|
credentials: JSON.parse(r),
|
|
1117
1117
|
settings: JSON.parse(o),
|
|
1118
1118
|
enabled: !!s
|
|
@@ -1208,7 +1208,7 @@ function Oa(t) {
|
|
|
1208
1208
|
);
|
|
1209
1209
|
}
|
|
1210
1210
|
r = r.offset(a.page * a.per_page).limit(a.per_page);
|
|
1211
|
-
const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(),
|
|
1211
|
+
const o = await r.selectAll().execute(), { count: s } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
|
|
1212
1212
|
return {
|
|
1213
1213
|
refresh_tokens: o.map((l) => ({
|
|
1214
1214
|
...l,
|
|
@@ -1218,7 +1218,7 @@ function Oa(t) {
|
|
|
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
|
}
|
|
@@ -1300,12 +1300,12 @@ function Ia(t) {
|
|
|
1300
1300
|
} catch {
|
|
1301
1301
|
}
|
|
1302
1302
|
return K.parse(f(h));
|
|
1303
|
-
}), { count:
|
|
1303
|
+
}), { count: c } = await n.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1304
1304
|
return {
|
|
1305
1305
|
forms: s,
|
|
1306
1306
|
start: a.page * a.per_page,
|
|
1307
1307
|
limit: a.per_page,
|
|
1308
|
-
length: b(
|
|
1308
|
+
length: b(c)
|
|
1309
1309
|
};
|
|
1310
1310
|
};
|
|
1311
1311
|
}
|
|
@@ -1527,7 +1527,7 @@ class za {
|
|
|
1527
1527
|
return this.nodeStack.pop(), g(a);
|
|
1528
1528
|
}
|
|
1529
1529
|
transformNodeImpl(e) {
|
|
1530
|
-
return
|
|
1530
|
+
return d(this, R)[e.kind](e);
|
|
1531
1531
|
}
|
|
1532
1532
|
transformNodeList(e) {
|
|
1533
1533
|
return e && g(e.map((a) => this.transformNode(a)));
|
|
@@ -2288,29 +2288,29 @@ class Ea extends za {
|
|
|
2288
2288
|
return super.transformNodeImpl(a);
|
|
2289
2289
|
const n = u(this, p, ve).call(this, a);
|
|
2290
2290
|
for (const s of n)
|
|
2291
|
-
|
|
2291
|
+
d(this, k).add(s);
|
|
2292
2292
|
const r = u(this, p, we).call(this, a);
|
|
2293
2293
|
for (const s of r)
|
|
2294
|
-
|
|
2294
|
+
d(this, O).add(s);
|
|
2295
2295
|
const o = super.transformNodeImpl(a);
|
|
2296
2296
|
for (const s of r)
|
|
2297
|
-
|
|
2297
|
+
d(this, O).delete(s);
|
|
2298
2298
|
for (const s of n)
|
|
2299
|
-
|
|
2299
|
+
d(this, k).delete(s);
|
|
2300
2300
|
return o;
|
|
2301
2301
|
}
|
|
2302
2302
|
transformSchemableIdentifier(a) {
|
|
2303
2303
|
const n = super.transformSchemableIdentifier(a);
|
|
2304
|
-
return n.schema || !
|
|
2304
|
+
return n.schema || !d(this, O).has(a.identifier.name) ? n : {
|
|
2305
2305
|
...n,
|
|
2306
|
-
schema: E.create(
|
|
2306
|
+
schema: E.create(d(this, j))
|
|
2307
2307
|
};
|
|
2308
2308
|
}
|
|
2309
2309
|
transformReferences(a) {
|
|
2310
2310
|
const n = super.transformReferences(a);
|
|
2311
2311
|
return n.table.table.schema ? n : {
|
|
2312
2312
|
...n,
|
|
2313
|
-
table: B.createWithSchema(
|
|
2313
|
+
table: B.createWithSchema(d(this, j), n.table.table.identifier.name)
|
|
2314
2314
|
};
|
|
2315
2315
|
}
|
|
2316
2316
|
}
|
|
@@ -2333,11 +2333,11 @@ j = new WeakMap(), O = new WeakMap(), k = new WeakMap(), p = new WeakSet(), ye =
|
|
|
2333
2333
|
r && u(this, p, G).call(this, r.table, n);
|
|
2334
2334
|
}, G = function(a, n) {
|
|
2335
2335
|
const r = a.identifier.name;
|
|
2336
|
-
!
|
|
2336
|
+
!d(this, O).has(r) && !d(this, k).has(r) && n.add(r);
|
|
2337
2337
|
}, Ne = function(a, n) {
|
|
2338
2338
|
for (const r of a.expressions) {
|
|
2339
2339
|
const o = r.name.table.table.identifier.name;
|
|
2340
|
-
|
|
2340
|
+
d(this, k).has(o) || n.add(o);
|
|
2341
2341
|
}
|
|
2342
2342
|
};
|
|
2343
2343
|
var z;
|
|
@@ -2347,7 +2347,7 @@ class Ka {
|
|
|
2347
2347
|
F(this, z, new Ea(e));
|
|
2348
2348
|
}
|
|
2349
2349
|
transformQuery(e) {
|
|
2350
|
-
return
|
|
2350
|
+
return d(this, z).transformNode(e.node);
|
|
2351
2351
|
}
|
|
2352
2352
|
async transformResult(e) {
|
|
2353
2353
|
return e.result;
|
|
@@ -2376,7 +2376,7 @@ class Ce {
|
|
|
2376
2376
|
* The returned array is sorted by migration name.
|
|
2377
2377
|
*/
|
|
2378
2378
|
async getMigrations() {
|
|
2379
|
-
const e = await u(this, i, I).call(this,
|
|
2379
|
+
const e = await u(this, i, I).call(this, d(this, i, N)) ? await d(this, _).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select(["name", "timestamp"]).execute() : [];
|
|
2380
2380
|
return (await u(this, i, Y).call(this)).map(({ name: n, ...r }) => {
|
|
2381
2381
|
const o = e.find((s) => s.name === n);
|
|
2382
2382
|
return {
|
|
@@ -2463,9 +2463,9 @@ class Ce {
|
|
|
2463
2463
|
return u(this, i, A).call(this, ({ migrations: a, executedMigrations: n, pendingMigrations: r }) => {
|
|
2464
2464
|
if (e === Qa)
|
|
2465
2465
|
return { direction: "Down", step: 1 / 0 };
|
|
2466
|
-
if (!a.find((
|
|
2466
|
+
if (!a.find((c) => c.name === e))
|
|
2467
2467
|
throw new Error(`migration "${e}" doesn't exist`);
|
|
2468
|
-
const o = n.indexOf(e), s = r.findIndex((
|
|
2468
|
+
const o = n.indexOf(e), s = r.findIndex((c) => c.name === e);
|
|
2469
2469
|
if (o !== -1)
|
|
2470
2470
|
return {
|
|
2471
2471
|
direction: "Down",
|
|
@@ -2518,79 +2518,79 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2518
2518
|
return a instanceof q ? a.resultSet : { error: a };
|
|
2519
2519
|
}
|
|
2520
2520
|
}, v = function() {
|
|
2521
|
-
return
|
|
2521
|
+
return d(this, _).migrationTableSchema;
|
|
2522
2522
|
}, N = function() {
|
|
2523
|
-
return
|
|
2523
|
+
return d(this, _).migrationTableName ?? Ua;
|
|
2524
2524
|
}, D = function() {
|
|
2525
|
-
return
|
|
2525
|
+
return d(this, _).migrationLockTableName ?? fe;
|
|
2526
2526
|
}, be = function() {
|
|
2527
|
-
return
|
|
2527
|
+
return d(this, _).allowUnorderedMigrations ?? Ba;
|
|
2528
2528
|
}, C = function() {
|
|
2529
|
-
return
|
|
2529
|
+
return d(this, i, v) ? new Ka(d(this, i, v)) : new Ra();
|
|
2530
2530
|
}, xe = async function() {
|
|
2531
2531
|
await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this), await u(this, i, ke).call(this);
|
|
2532
2532
|
}, Te = async function() {
|
|
2533
|
-
if (
|
|
2533
|
+
if (d(this, i, v) && !await u(this, i, H).call(this))
|
|
2534
2534
|
try {
|
|
2535
|
-
await u(this, i, L).call(this,
|
|
2535
|
+
await u(this, i, L).call(this, d(this, _).db.schema.createSchema(d(this, i, v)));
|
|
2536
2536
|
} catch (e) {
|
|
2537
2537
|
if (!await u(this, i, H).call(this))
|
|
2538
2538
|
throw e;
|
|
2539
2539
|
}
|
|
2540
2540
|
}, Se = async function() {
|
|
2541
|
-
if (!await u(this, i, I).call(this,
|
|
2541
|
+
if (!await u(this, i, I).call(this, d(this, i, N)))
|
|
2542
2542
|
try {
|
|
2543
|
-
|
|
2543
|
+
d(this, i, v) && await u(this, i, L).call(this, d(this, _).db.schema.createSchema(d(this, i, v))), await u(this, i, L).call(this, d(this, _).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, N)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
|
|
2544
2544
|
} catch (e) {
|
|
2545
|
-
if (!await u(this, i, I).call(this,
|
|
2545
|
+
if (!await u(this, i, I).call(this, d(this, i, N)))
|
|
2546
2546
|
throw e;
|
|
2547
2547
|
}
|
|
2548
2548
|
}, Oe = async function() {
|
|
2549
|
-
if (!await u(this, i, I).call(this,
|
|
2549
|
+
if (!await u(this, i, I).call(this, d(this, i, D)))
|
|
2550
2550
|
try {
|
|
2551
|
-
await u(this, i, L).call(this,
|
|
2551
|
+
await u(this, i, L).call(this, d(this, _).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
|
|
2552
2552
|
} catch (e) {
|
|
2553
|
-
if (!await u(this, i, I).call(this,
|
|
2553
|
+
if (!await u(this, i, I).call(this, d(this, i, D)))
|
|
2554
2554
|
throw e;
|
|
2555
2555
|
}
|
|
2556
2556
|
}, ke = async function() {
|
|
2557
2557
|
if (!await u(this, i, X).call(this))
|
|
2558
2558
|
try {
|
|
2559
|
-
await
|
|
2559
|
+
await d(this, _).db.withPlugin(d(this, i, C)).insertInto(d(this, i, D)).values({ id: Q, is_locked: 0 }).execute();
|
|
2560
2560
|
} catch (e) {
|
|
2561
2561
|
if (!await u(this, i, X).call(this))
|
|
2562
2562
|
throw e;
|
|
2563
2563
|
}
|
|
2564
2564
|
}, H = async function() {
|
|
2565
|
-
return (await
|
|
2565
|
+
return (await d(this, _).db.introspection.getSchemas()).some((a) => a.name === d(this, i, v));
|
|
2566
2566
|
}, I = async function(e) {
|
|
2567
|
-
const a =
|
|
2568
|
-
return (await
|
|
2567
|
+
const a = d(this, i, v);
|
|
2568
|
+
return (await d(this, _).db.introspection.getTables({
|
|
2569
2569
|
withInternalKyselyTables: !0
|
|
2570
2570
|
})).some((r) => r.name === e && (!a || r.schema === a));
|
|
2571
2571
|
}, X = async function() {
|
|
2572
|
-
return !!await
|
|
2572
|
+
return !!await d(this, _).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, D)).where("id", "=", Q).select("id").executeTakeFirst();
|
|
2573
2573
|
}, $e = async function(e) {
|
|
2574
|
-
const a =
|
|
2575
|
-
lockTable:
|
|
2574
|
+
const a = d(this, _).db.getExecutor().adapter, n = g({
|
|
2575
|
+
lockTable: d(this, _).migrationLockTableName ?? fe,
|
|
2576
2576
|
lockRowId: Q,
|
|
2577
|
-
lockTableSchema:
|
|
2577
|
+
lockTableSchema: d(this, _).migrationTableSchema
|
|
2578
2578
|
}), r = async (o) => {
|
|
2579
2579
|
try {
|
|
2580
2580
|
await a.acquireMigrationLock(o, n);
|
|
2581
2581
|
const s = await u(this, i, De).call(this, o);
|
|
2582
2582
|
if (s.migrations.length === 0)
|
|
2583
2583
|
return { results: [] };
|
|
2584
|
-
const { direction:
|
|
2585
|
-
return l <= 0 ? { results: [] } :
|
|
2584
|
+
const { direction: c, step: l } = e(s);
|
|
2585
|
+
return l <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Fe).call(this, o, s, l) : c === "Up" ? await u(this, i, Ae).call(this, o, s, l) : { results: [] };
|
|
2586
2586
|
} finally {
|
|
2587
2587
|
await a.releaseMigrationLock(o, n);
|
|
2588
2588
|
}
|
|
2589
2589
|
};
|
|
2590
|
-
return a.supportsTransactionalDdl ?
|
|
2590
|
+
return a.supportsTransactionalDdl ? d(this, _).db.transaction().execute(r) : d(this, _).db.connection().execute(r);
|
|
2591
2591
|
}, De = async function(e) {
|
|
2592
2592
|
const a = await u(this, i, Y).call(this), n = await u(this, i, je).call(this, e);
|
|
2593
|
-
u(this, i, Pe).call(this, a, n),
|
|
2593
|
+
u(this, i, Pe).call(this, a, n), d(this, i, be) || u(this, i, Me).call(this, a, n);
|
|
2594
2594
|
const r = u(this, i, Ie).call(this, a, n);
|
|
2595
2595
|
return g({
|
|
2596
2596
|
migrations: a,
|
|
@@ -2601,13 +2601,13 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2601
2601
|
}, Ie = function(e, a) {
|
|
2602
2602
|
return e.filter((n) => !a.includes(n.name));
|
|
2603
2603
|
}, Y = async function() {
|
|
2604
|
-
const e = await
|
|
2604
|
+
const e = await d(this, _).provider.getMigrations();
|
|
2605
2605
|
return Object.keys(e).sort().map((a) => ({
|
|
2606
2606
|
...e[a],
|
|
2607
2607
|
name: a
|
|
2608
2608
|
}));
|
|
2609
2609
|
}, je = async function(e) {
|
|
2610
|
-
return (await e.withPlugin(
|
|
2610
|
+
return (await e.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((n) => n.name);
|
|
2611
2611
|
}, Pe = function(e, a) {
|
|
2612
2612
|
for (const n of a)
|
|
2613
2613
|
if (!e.some((r) => r.name === n))
|
|
@@ -2617,22 +2617,22 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2617
2617
|
if (e[n].name !== a[n])
|
|
2618
2618
|
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
2619
|
}, Fe = async function(e, a, n) {
|
|
2620
|
-
const r = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((
|
|
2620
|
+
const r = a.executedMigrations.slice().reverse().slice(0, n).map((s) => a.migrations.find((c) => c.name === s)), o = r.map((s) => ({
|
|
2621
2621
|
migrationName: s.name,
|
|
2622
2622
|
direction: "Down",
|
|
2623
2623
|
status: "NotExecuted"
|
|
2624
2624
|
}));
|
|
2625
2625
|
for (let s = 0; s < o.length; ++s) {
|
|
2626
|
-
const
|
|
2626
|
+
const c = r[s];
|
|
2627
2627
|
try {
|
|
2628
|
-
|
|
2629
|
-
migrationName:
|
|
2628
|
+
c.down && (await c.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, N)).where("name", "=", c.name).execute(), o[s] = {
|
|
2629
|
+
migrationName: c.name,
|
|
2630
2630
|
direction: "Down",
|
|
2631
2631
|
status: "Success"
|
|
2632
2632
|
});
|
|
2633
2633
|
} catch (l) {
|
|
2634
2634
|
throw o[s] = {
|
|
2635
|
-
migrationName:
|
|
2635
|
+
migrationName: c.name,
|
|
2636
2636
|
direction: "Down",
|
|
2637
2637
|
status: "Error"
|
|
2638
2638
|
}, new q({
|
|
@@ -2649,19 +2649,19 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2649
2649
|
status: "NotExecuted"
|
|
2650
2650
|
}));
|
|
2651
2651
|
for (let s = 0; s < o.length; s++) {
|
|
2652
|
-
const
|
|
2652
|
+
const c = a.pendingMigrations[s];
|
|
2653
2653
|
try {
|
|
2654
|
-
await
|
|
2655
|
-
name:
|
|
2654
|
+
await c.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, N)).values({
|
|
2655
|
+
name: c.name,
|
|
2656
2656
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2657
2657
|
}).execute(), o[s] = {
|
|
2658
|
-
migrationName:
|
|
2658
|
+
migrationName: c.name,
|
|
2659
2659
|
direction: "Up",
|
|
2660
2660
|
status: "Success"
|
|
2661
2661
|
};
|
|
2662
2662
|
} catch (l) {
|
|
2663
2663
|
throw o[s] = {
|
|
2664
|
-
migrationName:
|
|
2664
|
+
migrationName: c.name,
|
|
2665
2665
|
direction: "Up",
|
|
2666
2666
|
status: "Error"
|
|
2667
2667
|
}, new q({
|
|
@@ -2672,7 +2672,7 @@ _ = new WeakMap(), i = new WeakSet(), A = async function(e) {
|
|
|
2672
2672
|
}
|
|
2673
2673
|
return { results: o };
|
|
2674
2674
|
}, L = async function(e) {
|
|
2675
|
-
|
|
2675
|
+
d(this, _).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
|
|
2676
2676
|
};
|
|
2677
2677
|
var J;
|
|
2678
2678
|
class q extends Error {
|
|
@@ -2682,7 +2682,7 @@ class q extends Error {
|
|
|
2682
2682
|
F(this, J, a);
|
|
2683
2683
|
}
|
|
2684
2684
|
get resultSet() {
|
|
2685
|
-
return
|
|
2685
|
+
return d(this, J);
|
|
2686
2686
|
}
|
|
2687
2687
|
}
|
|
2688
2688
|
J = new WeakMap();
|
|
@@ -2846,12 +2846,12 @@ async function ln(t) {
|
|
|
2846
2846
|
(e) => e.references("applications.id").onDelete("cascade").notNull()
|
|
2847
2847
|
).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
2848
|
}
|
|
2849
|
-
async function
|
|
2849
|
+
async function cn(t) {
|
|
2850
2850
|
await t.schema.dropTable("sessions").execute(), await t.schema.dropTable("tickets").execute(), await t.schema.dropTable("otps").execute();
|
|
2851
2851
|
}
|
|
2852
|
-
const
|
|
2852
|
+
const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2853
2853
|
__proto__: null,
|
|
2854
|
-
down:
|
|
2854
|
+
down: cn,
|
|
2855
2855
|
up: ln
|
|
2856
2856
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2857
2857
|
async function un(t) {
|
|
@@ -3051,12 +3051,12 @@ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3051
3051
|
async function lr(t) {
|
|
3052
3052
|
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
3053
|
}
|
|
3054
|
-
async function
|
|
3054
|
+
async function cr(t) {
|
|
3055
3055
|
await t.schema.dropIndex("logs_user_id"), await t.schema.dropIndex("logs_tenant_id"), await t.schema.dropIndex("logs_date");
|
|
3056
3056
|
}
|
|
3057
|
-
const
|
|
3057
|
+
const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3058
3058
|
__proto__: null,
|
|
3059
|
-
down:
|
|
3059
|
+
down: cr,
|
|
3060
3060
|
up: lr
|
|
3061
3061
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3062
3062
|
async function ur(t) {
|
|
@@ -3506,14 +3506,14 @@ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3506
3506
|
down: is,
|
|
3507
3507
|
up: ss
|
|
3508
3508
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3509
|
-
async function ds(t) {
|
|
3510
|
-
}
|
|
3511
3509
|
async function cs(t) {
|
|
3512
3510
|
}
|
|
3511
|
+
async function ds(t) {
|
|
3512
|
+
}
|
|
3513
3513
|
const us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3514
3514
|
__proto__: null,
|
|
3515
|
-
down:
|
|
3516
|
-
up:
|
|
3515
|
+
down: ds,
|
|
3516
|
+
up: cs
|
|
3517
3517
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3518
3518
|
async function ms(t) {
|
|
3519
3519
|
await t.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
|
|
@@ -3788,15 +3788,15 @@ const li = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3788
3788
|
down: ii,
|
|
3789
3789
|
up: si
|
|
3790
3790
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3791
|
-
async function
|
|
3791
|
+
async function ci(t) {
|
|
3792
3792
|
await t.schema.dropTable("logins").execute(), await t.schema.dropTable("sessions_2").execute(), await t.schema.dropTable("refresh_tokens_2").execute();
|
|
3793
3793
|
}
|
|
3794
|
-
async function
|
|
3794
|
+
async function di(t) {
|
|
3795
3795
|
}
|
|
3796
3796
|
const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3797
3797
|
__proto__: null,
|
|
3798
|
-
down:
|
|
3799
|
-
up:
|
|
3798
|
+
down: di,
|
|
3799
|
+
up: ci
|
|
3800
3800
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3801
3801
|
async function mi(t) {
|
|
3802
3802
|
await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
|
|
@@ -3899,13 +3899,24 @@ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3899
3899
|
__proto__: null,
|
|
3900
3900
|
down: Mi,
|
|
3901
3901
|
up: Pi
|
|
3902
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3903
|
+
async function Ai(t) {
|
|
3904
|
+
await t.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
|
|
3905
|
+
}
|
|
3906
|
+
async function Li(t) {
|
|
3907
|
+
await t.schema.alterTable("codes").dropColumn("redirect_uri").execute();
|
|
3908
|
+
}
|
|
3909
|
+
const zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3910
|
+
__proto__: null,
|
|
3911
|
+
down: Li,
|
|
3912
|
+
up: Ai
|
|
3902
3913
|
}, Symbol.toStringTag, { value: "Module" })), ze = {
|
|
3903
3914
|
m1_init: Wa,
|
|
3904
3915
|
m2_magicLink: Xa,
|
|
3905
3916
|
m3_updateAt: en,
|
|
3906
3917
|
m4_logTable: nn,
|
|
3907
3918
|
m5_userProfile: sn,
|
|
3908
|
-
m6_sessions:
|
|
3919
|
+
m6_sessions: dn,
|
|
3909
3920
|
m7_passwords: hn,
|
|
3910
3921
|
m8_logsTableNewFields: pn,
|
|
3911
3922
|
m9_passwordTableNewField: wn,
|
|
@@ -3923,7 +3934,7 @@ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3923
3934
|
n21_sessionDeletedAt: tr,
|
|
3924
3935
|
n22_dropLogsFields: rr,
|
|
3925
3936
|
n23_dropUsersFields: ir,
|
|
3926
|
-
n24_logsIndexes:
|
|
3937
|
+
n24_logsIndexes: dr,
|
|
3927
3938
|
n25_logDescMaxLength: hr,
|
|
3928
3939
|
n26_logsTableExtraFields: pr,
|
|
3929
3940
|
n27_usersTableNameIndex: wr,
|
|
@@ -3985,9 +3996,10 @@ const Fi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
3985
3996
|
n84_login_completed: Si,
|
|
3986
3997
|
n85_add_login_session_id_to_sessions: $i,
|
|
3987
3998
|
n86_index_sessions_login_session_id: ji,
|
|
3988
|
-
n87_code_challenge: Fi
|
|
3999
|
+
n87_code_challenge: Fi,
|
|
4000
|
+
n88_add_redirect_uri_to_codes: zi
|
|
3989
4001
|
};
|
|
3990
|
-
async function
|
|
4002
|
+
async function Ui(t, e = !1) {
|
|
3991
4003
|
e && console.log("migrating...");
|
|
3992
4004
|
const a = new Le(ze), n = new Ce({
|
|
3993
4005
|
db: t,
|
|
@@ -4000,7 +4012,7 @@ async function Ei(t, e = !1) {
|
|
|
4000
4012
|
}), r)
|
|
4001
4013
|
throw console.error("failed to migrate"), console.error(r), r;
|
|
4002
4014
|
}
|
|
4003
|
-
async function
|
|
4015
|
+
async function Bi(t) {
|
|
4004
4016
|
console.log("migrating...");
|
|
4005
4017
|
const e = new Le(ze), a = new Ce({
|
|
4006
4018
|
db: t,
|
|
@@ -4011,7 +4023,7 @@ async function Ki(t) {
|
|
|
4011
4023
|
}), n)
|
|
4012
4024
|
throw console.error("failed to migrate"), console.error(n), n;
|
|
4013
4025
|
}
|
|
4014
|
-
function
|
|
4026
|
+
function Qi(t) {
|
|
4015
4027
|
return {
|
|
4016
4028
|
applications: jt(t),
|
|
4017
4029
|
branding: Zt(t),
|
|
@@ -4025,18 +4037,18 @@ function Ri(t) {
|
|
|
4025
4037
|
hooks: oa(t),
|
|
4026
4038
|
keys: Ut(t),
|
|
4027
4039
|
loginSessions: fa(t),
|
|
4028
|
-
logs:
|
|
4040
|
+
logs: dt(t),
|
|
4029
4041
|
passwords: vt(t),
|
|
4030
4042
|
promptSettings: ya(t),
|
|
4031
4043
|
refreshTokens: ka(t),
|
|
4032
4044
|
sessions: pt(t),
|
|
4033
4045
|
tenants: ot(t),
|
|
4034
|
-
themes:
|
|
4046
|
+
themes: da(t),
|
|
4035
4047
|
users: Ye(t)
|
|
4036
4048
|
};
|
|
4037
4049
|
}
|
|
4038
4050
|
export {
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4051
|
+
Qi as default,
|
|
4052
|
+
Bi as migrateDown,
|
|
4053
|
+
Ui as migrateToLatest
|
|
4042
4054
|
};
|