@authhero/kysely-adapter 10.34.0 → 10.35.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.mjs +111 -98
- package/package.json +1 -1
package/dist/kysely-adapter.mjs
CHANGED
|
@@ -3,11 +3,11 @@ var ue = (t) => {
|
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
5
|
var Re = (t, e, r) => e in t ? Je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
6
|
-
var z = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r),
|
|
7
|
-
var d = (t, e, r) => (
|
|
8
|
-
import { parseUserId as
|
|
6
|
+
var z = (t, e, r) => Re(t, typeof e != "symbol" ? e + "" : e, r), V = (t, e, r) => e.has(t) || ue("Cannot " + r);
|
|
7
|
+
var d = (t, e, r) => (V(t, e, "read from private field"), r ? r.call(t) : e.get(t)), N = (t, e, r) => e.has(t) ? ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), L = (t, e, r, a) => (V(t, e, "write to private field"), a ? a.call(t, r) : e.set(t, r), r), m = (t, e, r) => (V(t, e, "access private method"), r);
|
|
8
|
+
import { parseUserId as ae, codeSchema as Ke, connectionSchema as Ue, loginSessionSchema as Be, promptSettingSchema as Qe, formSchema as Q, resourceServerSchema as qe } from "@authhero/adapter-interfaces";
|
|
9
9
|
import "@hono/zod-openapi";
|
|
10
|
-
var
|
|
10
|
+
var X = class extends Error {
|
|
11
11
|
constructor(e = 500, r) {
|
|
12
12
|
super(r == null ? void 0 : r.message, { cause: r == null ? void 0 : r.cause });
|
|
13
13
|
z(this, "res");
|
|
@@ -39,7 +39,7 @@ function Ve(t) {
|
|
|
39
39
|
try {
|
|
40
40
|
await t.insertInto("users").values(n).execute();
|
|
41
41
|
} catch (s) {
|
|
42
|
-
throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new
|
|
42
|
+
throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new X(409, { message: "User already exists" }) : new X(500, { message: `${s.code}, ${s.message}` });
|
|
43
43
|
}
|
|
44
44
|
return {
|
|
45
45
|
...n,
|
|
@@ -50,10 +50,23 @@ function Ve(t) {
|
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function f(t) {
|
|
54
|
+
if (t == null || typeof t != "object")
|
|
55
|
+
return t;
|
|
56
|
+
if (Array.isArray(t))
|
|
57
|
+
return t.map(
|
|
58
|
+
(r) => (
|
|
59
|
+
// Only recurse into objects; leave primitives untouched
|
|
60
|
+
r !== null && typeof r == "object" ? f(r) : r
|
|
61
|
+
)
|
|
62
|
+
);
|
|
54
63
|
const e = { ...t };
|
|
55
|
-
for (const r in e)
|
|
56
|
-
|
|
64
|
+
for (const r in e) {
|
|
65
|
+
const a = e[r];
|
|
66
|
+
a === null ? delete e[r] : a !== null && typeof a == "object" && (Array.isArray(a) ? e[r] = a.map(
|
|
67
|
+
(o) => o !== null && typeof o == "object" ? f(o) : o
|
|
68
|
+
) : e[r] = f(a));
|
|
69
|
+
}
|
|
57
70
|
return e;
|
|
58
71
|
}
|
|
59
72
|
function pe(t) {
|
|
@@ -66,7 +79,7 @@ function pe(t) {
|
|
|
66
79
|
return {
|
|
67
80
|
connection: t.connection,
|
|
68
81
|
provider: t.provider,
|
|
69
|
-
user_id:
|
|
82
|
+
user_id: ae(t.user_id).id,
|
|
70
83
|
isSocial: !!t.is_social,
|
|
71
84
|
profileData: {
|
|
72
85
|
email: t.email,
|
|
@@ -94,13 +107,13 @@ function We(t) {
|
|
|
94
107
|
{
|
|
95
108
|
connection: a.connection,
|
|
96
109
|
provider: a.provider,
|
|
97
|
-
user_id:
|
|
110
|
+
user_id: ae(a.user_id).id,
|
|
98
111
|
isSocial: !!a.is_social
|
|
99
112
|
},
|
|
100
113
|
...o.map(pe)
|
|
101
114
|
]
|
|
102
115
|
};
|
|
103
|
-
return
|
|
116
|
+
return f(l);
|
|
104
117
|
};
|
|
105
118
|
}
|
|
106
119
|
function C(t, e, r, a) {
|
|
@@ -167,7 +180,7 @@ function Ge(t) {
|
|
|
167
180
|
const h = l.filter(
|
|
168
181
|
(g) => g.linked_to === u.user_id
|
|
169
182
|
);
|
|
170
|
-
return
|
|
183
|
+
return f({
|
|
171
184
|
...u,
|
|
172
185
|
email_verified: u.email_verified === 1,
|
|
173
186
|
is_social: u.is_social === 1,
|
|
@@ -177,7 +190,7 @@ function Ge(t) {
|
|
|
177
190
|
{
|
|
178
191
|
connection: u.connection,
|
|
179
192
|
provider: u.provider,
|
|
180
|
-
user_id:
|
|
193
|
+
user_id: ae(u.user_id).id,
|
|
181
194
|
isSocial: !!u.is_social
|
|
182
195
|
},
|
|
183
196
|
...h.map(pe)
|
|
@@ -270,7 +283,7 @@ function tt(t) {
|
|
|
270
283
|
function rt(t) {
|
|
271
284
|
return async (e) => {
|
|
272
285
|
const r = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
|
|
273
|
-
return r ?
|
|
286
|
+
return r ? f(r) : null;
|
|
274
287
|
};
|
|
275
288
|
}
|
|
276
289
|
function at(t) {
|
|
@@ -292,7 +305,7 @@ function at(t) {
|
|
|
292
305
|
};
|
|
293
306
|
const { count: n } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = v(n);
|
|
294
307
|
return {
|
|
295
|
-
tenants: o.map(
|
|
308
|
+
tenants: o.map(f),
|
|
296
309
|
start: (e.page - 1) * e.per_page,
|
|
297
310
|
limit: e.per_page,
|
|
298
311
|
length: s
|
|
@@ -536,7 +549,7 @@ function Ct(t) {
|
|
|
536
549
|
return {
|
|
537
550
|
codes: n.map((c) => {
|
|
538
551
|
const { tenant_id: _, ...u } = c;
|
|
539
|
-
return Ke.parse(
|
|
552
|
+
return Ke.parse(f(u));
|
|
540
553
|
}),
|
|
541
554
|
start: r.page * r.per_page,
|
|
542
555
|
limit: r.per_page,
|
|
@@ -564,7 +577,7 @@ function Tt(t) {
|
|
|
564
577
|
let o = t.selectFrom("codes").where("codes.code_id", "=", r).where("codes.code_type", "=", a);
|
|
565
578
|
e.length && (o = o.where("codes.tenant_id", "=", e));
|
|
566
579
|
const n = await o.selectAll().executeTakeFirst();
|
|
567
|
-
return n ?
|
|
580
|
+
return n ? f(n) : null;
|
|
568
581
|
};
|
|
569
582
|
}
|
|
570
583
|
function St(t) {
|
|
@@ -617,7 +630,7 @@ function $t(t) {
|
|
|
617
630
|
function It(t) {
|
|
618
631
|
return async (e, r) => {
|
|
619
632
|
const a = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", r).selectAll().executeTakeFirst();
|
|
620
|
-
return a ?
|
|
633
|
+
return a ? f({
|
|
621
634
|
...a,
|
|
622
635
|
disable_sign_ups: !!a.disable_sign_ups,
|
|
623
636
|
addons: JSON.parse(a.addons),
|
|
@@ -681,7 +694,7 @@ function Mt(t) {
|
|
|
681
694
|
let a = t.selectFrom("connections").where("connections.tenant_id", "=", e);
|
|
682
695
|
r.q && (a = C(t, a, r.q, ["user_id", "ip"]));
|
|
683
696
|
const s = (await a.offset(r.page * r.per_page).limit(r.per_page).selectAll().execute()).map(
|
|
684
|
-
(c) =>
|
|
697
|
+
(c) => f({
|
|
685
698
|
...c,
|
|
686
699
|
options: JSON.parse(c.options)
|
|
687
700
|
})
|
|
@@ -700,7 +713,7 @@ function At(t) {
|
|
|
700
713
|
function zt(t) {
|
|
701
714
|
return async (e, r) => {
|
|
702
715
|
const a = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", r).selectAll().executeTakeFirst();
|
|
703
|
-
return a ?
|
|
716
|
+
return a ? f({
|
|
704
717
|
...a,
|
|
705
718
|
options: JSON.parse(a.options)
|
|
706
719
|
}) : null;
|
|
@@ -735,13 +748,13 @@ function Jt(t) {
|
|
|
735
748
|
return null;
|
|
736
749
|
const a = await t.selectFrom("tenants").selectAll().where("id", "=", r.tenant_id).executeTakeFirst();
|
|
737
750
|
if (!a)
|
|
738
|
-
throw new
|
|
751
|
+
throw new X(404, { message: "Tenant not found" });
|
|
739
752
|
const o = await t.selectFrom("connections").where("tenant_id", "=", r.tenant_id).selectAll().execute();
|
|
740
753
|
return {
|
|
741
754
|
...r,
|
|
742
755
|
connections: o.map(
|
|
743
756
|
(s) => Ue.parse(
|
|
744
|
-
|
|
757
|
+
f({
|
|
745
758
|
...s,
|
|
746
759
|
options: s.options ? JSON.parse(s.options) : {}
|
|
747
760
|
})
|
|
@@ -753,7 +766,7 @@ function Jt(t) {
|
|
|
753
766
|
web_origins: r.web_origins ? JSON.parse(r.web_origins) : [],
|
|
754
767
|
allowed_logout_urls: r.allowed_logout_urls ? JSON.parse(r.allowed_logout_urls) : [],
|
|
755
768
|
allowed_clients: r.allowed_clients ? JSON.parse(r.allowed_clients) : [],
|
|
756
|
-
tenant:
|
|
769
|
+
tenant: f(a),
|
|
757
770
|
// this is really an integer in the database
|
|
758
771
|
disable_sign_ups: !!r.disable_sign_ups
|
|
759
772
|
};
|
|
@@ -862,7 +875,7 @@ function Yt(t) {
|
|
|
862
875
|
font_url: _,
|
|
863
876
|
...u
|
|
864
877
|
} = r;
|
|
865
|
-
return
|
|
878
|
+
return f({
|
|
866
879
|
...u,
|
|
867
880
|
colors: {
|
|
868
881
|
primary: o,
|
|
@@ -879,7 +892,7 @@ function Yt(t) {
|
|
|
879
892
|
}
|
|
880
893
|
function Zt(t) {
|
|
881
894
|
return async (e, r) => {
|
|
882
|
-
var s, l, c, _, u, h, g, I, D, O,
|
|
895
|
+
var s, l, c, _, u, h, g, I, D, O, U, ne, oe, se, ie, le, ce, de;
|
|
883
896
|
const { colors: a, font: o, ...n } = r;
|
|
884
897
|
try {
|
|
885
898
|
await t.insertInto("branding").values({
|
|
@@ -896,7 +909,7 @@ function Zt(t) {
|
|
|
896
909
|
await t.updateTable("branding").set({
|
|
897
910
|
...n,
|
|
898
911
|
colors_primary: a == null ? void 0 : a.primary,
|
|
899
|
-
colors_page_background_type: (
|
|
912
|
+
colors_page_background_type: (U = (O = r.colors) == null ? void 0 : O.page_background) == null ? void 0 : U.type,
|
|
900
913
|
colors_page_background_start: (oe = (ne = r.colors) == null ? void 0 : ne.page_background) == null ? void 0 : oe.start,
|
|
901
914
|
colors_page_background_end: (ie = (se = r.colors) == null ? void 0 : se.page_background) == null ? void 0 : ie.end,
|
|
902
915
|
colors_page_background_angle_dev: (ce = (le = r.colors) == null ? void 0 : le.page_background) == null ? void 0 : ce.angle_deg,
|
|
@@ -923,7 +936,7 @@ function tr(t) {
|
|
|
923
936
|
return {
|
|
924
937
|
hooks: n.map((c) => {
|
|
925
938
|
const { tenant_id: _, enabled: u, synchronous: h, ...g } = c;
|
|
926
|
-
return
|
|
939
|
+
return f({
|
|
927
940
|
...g,
|
|
928
941
|
enabled: !!u,
|
|
929
942
|
synchronous: !!h
|
|
@@ -938,7 +951,7 @@ function tr(t) {
|
|
|
938
951
|
function rr(t) {
|
|
939
952
|
return async (e, r) => {
|
|
940
953
|
const a = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", r).selectAll().executeTakeFirst();
|
|
941
|
-
return a ?
|
|
954
|
+
return a ? f({
|
|
942
955
|
...a,
|
|
943
956
|
enabled: !!a.enabled,
|
|
944
957
|
synchronous: !!a.synchronous
|
|
@@ -1016,7 +1029,7 @@ function cr(t) {
|
|
|
1016
1029
|
fonts_subtitle_bold: !!a.fonts_subtitle_bold,
|
|
1017
1030
|
fonts_title_bold: !!a.fonts_title_bold
|
|
1018
1031
|
};
|
|
1019
|
-
return
|
|
1032
|
+
return f(
|
|
1020
1033
|
ge(o, [
|
|
1021
1034
|
"widget",
|
|
1022
1035
|
"colors",
|
|
@@ -1049,7 +1062,7 @@ function mr(t) {
|
|
|
1049
1062
|
const a = await t.selectFrom("login_sessions").where("login_sessions.id", "=", r).selectAll().executeTakeFirst();
|
|
1050
1063
|
return a ? Be.parse(
|
|
1051
1064
|
ge(
|
|
1052
|
-
|
|
1065
|
+
f({
|
|
1053
1066
|
...a,
|
|
1054
1067
|
login_completed: !!a.login_completed
|
|
1055
1068
|
}),
|
|
@@ -1096,7 +1109,7 @@ function pr(t) {
|
|
|
1096
1109
|
function gr(t) {
|
|
1097
1110
|
return async (e) => {
|
|
1098
1111
|
const [r] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
|
|
1099
|
-
return
|
|
1112
|
+
return f({
|
|
1100
1113
|
identifier_first: !!(r != null && r.identifier_first),
|
|
1101
1114
|
password_first: !!(r != null && r.password_first),
|
|
1102
1115
|
webauthn_platform_first_factor: !!(r != null && r.webauthn_platform_first_factor),
|
|
@@ -1105,7 +1118,7 @@ function gr(t) {
|
|
|
1105
1118
|
};
|
|
1106
1119
|
}
|
|
1107
1120
|
function he(t) {
|
|
1108
|
-
return
|
|
1121
|
+
return f({
|
|
1109
1122
|
...t,
|
|
1110
1123
|
webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
|
|
1111
1124
|
identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
|
|
@@ -1144,7 +1157,7 @@ function vr(t) {
|
|
|
1144
1157
|
enabled: s,
|
|
1145
1158
|
...l
|
|
1146
1159
|
} = r;
|
|
1147
|
-
return
|
|
1160
|
+
return f({
|
|
1148
1161
|
...l,
|
|
1149
1162
|
credentials: JSON.parse(o),
|
|
1150
1163
|
settings: JSON.parse(n),
|
|
@@ -1296,7 +1309,7 @@ function Ir(t) {
|
|
|
1296
1309
|
}
|
|
1297
1310
|
function Dr(t) {
|
|
1298
1311
|
return async (e, r) => {
|
|
1299
|
-
const a =
|
|
1312
|
+
const a = Q.parse({
|
|
1300
1313
|
id: b(),
|
|
1301
1314
|
...r,
|
|
1302
1315
|
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1309,7 +1322,7 @@ function Dr(t) {
|
|
|
1309
1322
|
start: JSON.stringify(a.start || {}),
|
|
1310
1323
|
ending: JSON.stringify(a.ending || {}),
|
|
1311
1324
|
tenant_id: e
|
|
1312
|
-
}).execute(),
|
|
1325
|
+
}).execute(), Q.parse(a);
|
|
1313
1326
|
};
|
|
1314
1327
|
}
|
|
1315
1328
|
function Pr(t) {
|
|
@@ -1337,7 +1350,7 @@ function Pr(t) {
|
|
|
1337
1350
|
_.ending = JSON.parse(_.ending);
|
|
1338
1351
|
} catch {
|
|
1339
1352
|
}
|
|
1340
|
-
return
|
|
1353
|
+
return Q.parse(f(_));
|
|
1341
1354
|
}), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1342
1355
|
return {
|
|
1343
1356
|
forms: s,
|
|
@@ -1373,7 +1386,7 @@ function Fr(t) {
|
|
|
1373
1386
|
o.ending = JSON.parse(o.ending);
|
|
1374
1387
|
} catch {
|
|
1375
1388
|
}
|
|
1376
|
-
return
|
|
1389
|
+
return Q.parse(f(o));
|
|
1377
1390
|
};
|
|
1378
1391
|
}
|
|
1379
1392
|
function Mr(t) {
|
|
@@ -1421,7 +1434,7 @@ function zr(t) {
|
|
|
1421
1434
|
created_at: a,
|
|
1422
1435
|
updated_at: a
|
|
1423
1436
|
};
|
|
1424
|
-
return await t.insertInto("resource_servers").values(g).execute(), n;
|
|
1437
|
+
return await t.insertInto("resource_servers").values(g).execute(), f(n);
|
|
1425
1438
|
};
|
|
1426
1439
|
}
|
|
1427
1440
|
function Lr(t) {
|
|
@@ -1435,8 +1448,7 @@ function Lr(t) {
|
|
|
1435
1448
|
skip_consent_for_verifiable_first_party_clients: c,
|
|
1436
1449
|
allow_offline_access: _,
|
|
1437
1450
|
...u
|
|
1438
|
-
} = o
|
|
1439
|
-
return {
|
|
1451
|
+
} = o, h = {
|
|
1440
1452
|
...u,
|
|
1441
1453
|
scopes: s ? JSON.parse(s) : [],
|
|
1442
1454
|
options: l ? JSON.parse(l) : {},
|
|
@@ -1445,6 +1457,7 @@ function Lr(t) {
|
|
|
1445
1457
|
// Convert verification_key back to verificationKey for API
|
|
1446
1458
|
verificationKey: n
|
|
1447
1459
|
};
|
|
1460
|
+
return f(h);
|
|
1448
1461
|
};
|
|
1449
1462
|
}
|
|
1450
1463
|
function Er(t) {
|
|
@@ -1469,8 +1482,7 @@ function Er(t) {
|
|
|
1469
1482
|
skip_consent_for_verifiable_first_party_clients: I,
|
|
1470
1483
|
allow_offline_access: D,
|
|
1471
1484
|
...O
|
|
1472
|
-
} = _
|
|
1473
|
-
return {
|
|
1485
|
+
} = _, U = {
|
|
1474
1486
|
...O,
|
|
1475
1487
|
scopes: h ? JSON.parse(h) : [],
|
|
1476
1488
|
options: g ? JSON.parse(g) : {},
|
|
@@ -1479,6 +1491,7 @@ function Er(t) {
|
|
|
1479
1491
|
// Convert verification_key back to verificationKey for API
|
|
1480
1492
|
verificationKey: u
|
|
1481
1493
|
};
|
|
1494
|
+
return f(U);
|
|
1482
1495
|
}), { count: l } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
|
|
1483
1496
|
return {
|
|
1484
1497
|
resource_servers: s,
|
|
@@ -1753,7 +1766,7 @@ function aa(t) {
|
|
|
1753
1766
|
function y(t) {
|
|
1754
1767
|
return Object.freeze(t);
|
|
1755
1768
|
}
|
|
1756
|
-
const
|
|
1769
|
+
const B = y({
|
|
1757
1770
|
is(t) {
|
|
1758
1771
|
return t.kind === "IdentifierNode";
|
|
1759
1772
|
},
|
|
@@ -1763,21 +1776,21 @@ const U = y({
|
|
|
1763
1776
|
name: t
|
|
1764
1777
|
});
|
|
1765
1778
|
}
|
|
1766
|
-
}),
|
|
1779
|
+
}), Y = y({
|
|
1767
1780
|
is(t) {
|
|
1768
1781
|
return t.kind === "SchemableIdentifierNode";
|
|
1769
1782
|
},
|
|
1770
1783
|
create(t) {
|
|
1771
1784
|
return y({
|
|
1772
1785
|
kind: "SchemableIdentifierNode",
|
|
1773
|
-
identifier:
|
|
1786
|
+
identifier: B.create(t)
|
|
1774
1787
|
});
|
|
1775
1788
|
},
|
|
1776
1789
|
createWithSchema(t, e) {
|
|
1777
1790
|
return y({
|
|
1778
1791
|
kind: "SchemableIdentifierNode",
|
|
1779
|
-
schema:
|
|
1780
|
-
identifier:
|
|
1792
|
+
schema: B.create(t),
|
|
1793
|
+
identifier: B.create(e)
|
|
1781
1794
|
});
|
|
1782
1795
|
}
|
|
1783
1796
|
}), na = y({
|
|
@@ -1791,28 +1804,28 @@ const U = y({
|
|
|
1791
1804
|
alias: e
|
|
1792
1805
|
});
|
|
1793
1806
|
}
|
|
1794
|
-
}),
|
|
1807
|
+
}), W = y({
|
|
1795
1808
|
is(t) {
|
|
1796
1809
|
return t.kind === "TableNode";
|
|
1797
1810
|
},
|
|
1798
1811
|
create(t) {
|
|
1799
1812
|
return y({
|
|
1800
1813
|
kind: "TableNode",
|
|
1801
|
-
table:
|
|
1814
|
+
table: Y.create(t)
|
|
1802
1815
|
});
|
|
1803
1816
|
},
|
|
1804
1817
|
createWithSchema(t, e) {
|
|
1805
1818
|
return y({
|
|
1806
1819
|
kind: "TableNode",
|
|
1807
|
-
table:
|
|
1820
|
+
table: Y.createWithSchema(t, e)
|
|
1808
1821
|
});
|
|
1809
1822
|
}
|
|
1810
1823
|
});
|
|
1811
|
-
var
|
|
1824
|
+
var q;
|
|
1812
1825
|
class oa {
|
|
1813
1826
|
constructor() {
|
|
1814
1827
|
z(this, "nodeStack", []);
|
|
1815
|
-
N(this,
|
|
1828
|
+
N(this, q, y({
|
|
1816
1829
|
AliasNode: this.transformAlias.bind(this),
|
|
1817
1830
|
ColumnNode: this.transformColumn.bind(this),
|
|
1818
1831
|
IdentifierNode: this.transformIdentifier.bind(this),
|
|
@@ -1916,7 +1929,7 @@ class oa {
|
|
|
1916
1929
|
return this.nodeStack.pop(), y(r);
|
|
1917
1930
|
}
|
|
1918
1931
|
transformNodeImpl(e) {
|
|
1919
|
-
return d(this,
|
|
1932
|
+
return d(this, q)[e.kind](e);
|
|
1920
1933
|
}
|
|
1921
1934
|
transformNodeList(e) {
|
|
1922
1935
|
return e && y(e.map((r) => this.transformNode(r)));
|
|
@@ -2642,7 +2655,7 @@ class oa {
|
|
|
2642
2655
|
return e;
|
|
2643
2656
|
}
|
|
2644
2657
|
}
|
|
2645
|
-
|
|
2658
|
+
q = new WeakMap();
|
|
2646
2659
|
const sa = y({
|
|
2647
2660
|
AlterTableNode: !0,
|
|
2648
2661
|
CreateIndexNode: !0,
|
|
@@ -2662,7 +2675,7 @@ const sa = y({
|
|
|
2662
2675
|
UpdateQueryNode: !0,
|
|
2663
2676
|
MergeQueryNode: !0
|
|
2664
2677
|
});
|
|
2665
|
-
var M, k, $, w, ye, ve, Ne, P,
|
|
2678
|
+
var M, k, $, w, ye, ve, Ne, P, Z, Ce;
|
|
2666
2679
|
class ia extends oa {
|
|
2667
2680
|
constructor(r) {
|
|
2668
2681
|
super();
|
|
@@ -2692,14 +2705,14 @@ class ia extends oa {
|
|
|
2692
2705
|
const a = super.transformSchemableIdentifier(r);
|
|
2693
2706
|
return a.schema || !d(this, k).has(r.identifier.name) ? a : {
|
|
2694
2707
|
...a,
|
|
2695
|
-
schema:
|
|
2708
|
+
schema: B.create(d(this, M))
|
|
2696
2709
|
};
|
|
2697
2710
|
}
|
|
2698
2711
|
transformReferences(r) {
|
|
2699
2712
|
const a = super.transformReferences(r);
|
|
2700
2713
|
return a.table.table.schema ? a : {
|
|
2701
2714
|
...a,
|
|
2702
|
-
table:
|
|
2715
|
+
table: W.createWithSchema(d(this, M), a.table.table.identifier.name)
|
|
2703
2716
|
};
|
|
2704
2717
|
}
|
|
2705
2718
|
}
|
|
@@ -2707,7 +2720,7 @@ M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), w = new WeakSet(), ye =
|
|
|
2707
2720
|
return r.kind in sa;
|
|
2708
2721
|
}, ve = function(r) {
|
|
2709
2722
|
const a = /* @__PURE__ */ new Set();
|
|
2710
|
-
if ("name" in r && r.name &&
|
|
2723
|
+
if ("name" in r && r.name && Y.is(r.name) && m(this, w, Z).call(this, r.name, a), "from" in r && r.from)
|
|
2711
2724
|
for (const o of r.from.froms)
|
|
2712
2725
|
m(this, w, P).call(this, o, a);
|
|
2713
2726
|
if ("into" in r && r.into && m(this, w, P).call(this, r.into, a), "table" in r && r.table && m(this, w, P).call(this, r.table, a), "joins" in r && r.joins)
|
|
@@ -2718,9 +2731,9 @@ M = new WeakMap(), k = new WeakMap(), $ = new WeakMap(), w = new WeakSet(), ye =
|
|
|
2718
2731
|
const a = /* @__PURE__ */ new Set();
|
|
2719
2732
|
return "with" in r && r.with && m(this, w, Ce).call(this, r.with, a), a;
|
|
2720
2733
|
}, P = function(r, a) {
|
|
2721
|
-
const o =
|
|
2722
|
-
o && m(this, w,
|
|
2723
|
-
},
|
|
2734
|
+
const o = W.is(r) ? r : na.is(r) && W.is(r.node) ? r.node : null;
|
|
2735
|
+
o && m(this, w, Z).call(this, o.table, a);
|
|
2736
|
+
}, Z = function(r, a) {
|
|
2724
2737
|
const o = r.identifier.name;
|
|
2725
2738
|
!d(this, k).has(o) && !d(this, $).has(o) && a.add(o);
|
|
2726
2739
|
}, Ce = function(r, a) {
|
|
@@ -2751,13 +2764,13 @@ class ca {
|
|
|
2751
2764
|
return e.result;
|
|
2752
2765
|
}
|
|
2753
2766
|
}
|
|
2754
|
-
const da = "kysely_migration", fe = "kysely_migration_lock", ua = !1,
|
|
2755
|
-
var
|
|
2767
|
+
const da = "kysely_migration", fe = "kysely_migration_lock", ua = !1, G = "migration_lock", ma = y({ __noMigrations__: !0 });
|
|
2768
|
+
var p, i, E, x, T, j, xe, S, Te, Se, Oe, ke, $e, ee, F, te, Ie, De, Pe, re, je, Fe, Me, Ae, ze, J;
|
|
2756
2769
|
class be {
|
|
2757
2770
|
constructor(e) {
|
|
2758
2771
|
N(this, i);
|
|
2759
|
-
N(this,
|
|
2760
|
-
L(this,
|
|
2772
|
+
N(this, p);
|
|
2773
|
+
L(this, p, y(e));
|
|
2761
2774
|
}
|
|
2762
2775
|
/**
|
|
2763
2776
|
* Returns a {@link MigrationInfo} object for each migration.
|
|
@@ -2765,8 +2778,8 @@ class be {
|
|
|
2765
2778
|
* The returned array is sorted by migration name.
|
|
2766
2779
|
*/
|
|
2767
2780
|
async getMigrations() {
|
|
2768
|
-
const e = await m(this, i, F).call(this, d(this, i, T)) ? await d(this,
|
|
2769
|
-
return (await m(this, i,
|
|
2781
|
+
const e = await m(this, i, F).call(this, d(this, i, T)) ? await d(this, p).db.withPlugin(d(this, i, S)).selectFrom(d(this, i, T)).select(["name", "timestamp"]).execute() : [];
|
|
2782
|
+
return (await m(this, i, re).call(this)).map(({ name: a, ...o }) => {
|
|
2770
2783
|
const n = e.find((s) => s.name === a);
|
|
2771
2784
|
return {
|
|
2772
2785
|
name: a,
|
|
@@ -2900,36 +2913,36 @@ class be {
|
|
|
2900
2913
|
return m(this, i, E).call(this, () => ({ direction: "Down", step: 1 }));
|
|
2901
2914
|
}
|
|
2902
2915
|
}
|
|
2903
|
-
|
|
2916
|
+
p = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
2904
2917
|
try {
|
|
2905
2918
|
return await m(this, i, Te).call(this), await m(this, i, Ie).call(this, e);
|
|
2906
2919
|
} catch (r) {
|
|
2907
|
-
return r instanceof
|
|
2920
|
+
return r instanceof H ? r.resultSet : { error: r };
|
|
2908
2921
|
}
|
|
2909
2922
|
}, x = function() {
|
|
2910
|
-
return d(this,
|
|
2923
|
+
return d(this, p).migrationTableSchema;
|
|
2911
2924
|
}, T = function() {
|
|
2912
|
-
return d(this,
|
|
2925
|
+
return d(this, p).migrationTableName ?? da;
|
|
2913
2926
|
}, j = function() {
|
|
2914
|
-
return d(this,
|
|
2927
|
+
return d(this, p).migrationLockTableName ?? fe;
|
|
2915
2928
|
}, xe = function() {
|
|
2916
|
-
return d(this,
|
|
2929
|
+
return d(this, p).allowUnorderedMigrations ?? ua;
|
|
2917
2930
|
}, S = function() {
|
|
2918
2931
|
return d(this, i, x) ? new la(d(this, i, x)) : new ca();
|
|
2919
2932
|
}, Te = async function() {
|
|
2920
2933
|
await m(this, i, Se).call(this), await m(this, i, Oe).call(this), await m(this, i, ke).call(this), await m(this, i, $e).call(this);
|
|
2921
2934
|
}, Se = async function() {
|
|
2922
|
-
if (d(this, i, x) && !await m(this, i,
|
|
2935
|
+
if (d(this, i, x) && !await m(this, i, ee).call(this))
|
|
2923
2936
|
try {
|
|
2924
|
-
await m(this, i, J).call(this, d(this,
|
|
2937
|
+
await m(this, i, J).call(this, d(this, p).db.schema.createSchema(d(this, i, x)));
|
|
2925
2938
|
} catch (e) {
|
|
2926
|
-
if (!await m(this, i,
|
|
2939
|
+
if (!await m(this, i, ee).call(this))
|
|
2927
2940
|
throw e;
|
|
2928
2941
|
}
|
|
2929
2942
|
}, Oe = async function() {
|
|
2930
2943
|
if (!await m(this, i, F).call(this, d(this, i, T)))
|
|
2931
2944
|
try {
|
|
2932
|
-
d(this, i, x) && await m(this, i, J).call(this, d(this,
|
|
2945
|
+
d(this, i, x) && await m(this, i, J).call(this, d(this, p).db.schema.createSchema(d(this, i, x))), await m(this, i, J).call(this, d(this, p).db.schema.withPlugin(d(this, i, S)).createTable(d(this, i, T)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
|
|
2933
2946
|
} catch (e) {
|
|
2934
2947
|
if (!await m(this, i, F).call(this, d(this, i, T)))
|
|
2935
2948
|
throw e;
|
|
@@ -2937,33 +2950,33 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
2937
2950
|
}, ke = async function() {
|
|
2938
2951
|
if (!await m(this, i, F).call(this, d(this, i, j)))
|
|
2939
2952
|
try {
|
|
2940
|
-
await m(this, i, J).call(this, d(this,
|
|
2953
|
+
await m(this, i, J).call(this, d(this, p).db.schema.withPlugin(d(this, i, S)).createTable(d(this, i, j)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
|
|
2941
2954
|
} catch (e) {
|
|
2942
2955
|
if (!await m(this, i, F).call(this, d(this, i, j)))
|
|
2943
2956
|
throw e;
|
|
2944
2957
|
}
|
|
2945
2958
|
}, $e = async function() {
|
|
2946
|
-
if (!await m(this, i,
|
|
2959
|
+
if (!await m(this, i, te).call(this))
|
|
2947
2960
|
try {
|
|
2948
|
-
await d(this,
|
|
2961
|
+
await d(this, p).db.withPlugin(d(this, i, S)).insertInto(d(this, i, j)).values({ id: G, is_locked: 0 }).execute();
|
|
2949
2962
|
} catch (e) {
|
|
2950
|
-
if (!await m(this, i,
|
|
2963
|
+
if (!await m(this, i, te).call(this))
|
|
2951
2964
|
throw e;
|
|
2952
2965
|
}
|
|
2953
|
-
},
|
|
2954
|
-
return (await d(this,
|
|
2966
|
+
}, ee = async function() {
|
|
2967
|
+
return (await d(this, p).db.introspection.getSchemas()).some((r) => r.name === d(this, i, x));
|
|
2955
2968
|
}, F = async function(e) {
|
|
2956
2969
|
const r = d(this, i, x);
|
|
2957
|
-
return (await d(this,
|
|
2970
|
+
return (await d(this, p).db.introspection.getTables({
|
|
2958
2971
|
withInternalKyselyTables: !0
|
|
2959
2972
|
})).some((o) => o.name === e && (!r || o.schema === r));
|
|
2960
|
-
},
|
|
2961
|
-
return !!await d(this,
|
|
2973
|
+
}, te = async function() {
|
|
2974
|
+
return !!await d(this, p).db.withPlugin(d(this, i, S)).selectFrom(d(this, i, j)).where("id", "=", G).select("id").executeTakeFirst();
|
|
2962
2975
|
}, Ie = async function(e) {
|
|
2963
|
-
const r = d(this,
|
|
2964
|
-
lockTable: d(this,
|
|
2965
|
-
lockRowId:
|
|
2966
|
-
lockTableSchema: d(this,
|
|
2976
|
+
const r = d(this, p).db.getExecutor().adapter, a = y({
|
|
2977
|
+
lockTable: d(this, p).migrationLockTableName ?? fe,
|
|
2978
|
+
lockRowId: G,
|
|
2979
|
+
lockTableSchema: d(this, p).migrationTableSchema
|
|
2967
2980
|
}), o = async (n) => {
|
|
2968
2981
|
try {
|
|
2969
2982
|
await r.acquireMigrationLock(n, a);
|
|
@@ -2976,9 +2989,9 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
2976
2989
|
await r.releaseMigrationLock(n, a);
|
|
2977
2990
|
}
|
|
2978
2991
|
};
|
|
2979
|
-
return r.supportsTransactionalDdl ? d(this,
|
|
2992
|
+
return r.supportsTransactionalDdl ? d(this, p).db.transaction().execute(o) : d(this, p).db.connection().execute(o);
|
|
2980
2993
|
}, De = async function(e) {
|
|
2981
|
-
const r = await m(this, i,
|
|
2994
|
+
const r = await m(this, i, re).call(this), a = await m(this, i, je).call(this, e);
|
|
2982
2995
|
m(this, i, Fe).call(this, r, a), d(this, i, xe) || m(this, i, Me).call(this, r, a);
|
|
2983
2996
|
const o = m(this, i, Pe).call(this, r, a);
|
|
2984
2997
|
return y({
|
|
@@ -2989,8 +3002,8 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
2989
3002
|
});
|
|
2990
3003
|
}, Pe = function(e, r) {
|
|
2991
3004
|
return e.filter((a) => !r.includes(a.name));
|
|
2992
|
-
},
|
|
2993
|
-
const e = await d(this,
|
|
3005
|
+
}, re = async function() {
|
|
3006
|
+
const e = await d(this, p).provider.getMigrations();
|
|
2994
3007
|
return Object.keys(e).sort().map((r) => ({
|
|
2995
3008
|
...e[r],
|
|
2996
3009
|
name: r
|
|
@@ -3024,7 +3037,7 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
3024
3037
|
migrationName: l.name,
|
|
3025
3038
|
direction: "Down",
|
|
3026
3039
|
status: "Error"
|
|
3027
|
-
}, new
|
|
3040
|
+
}, new H({
|
|
3028
3041
|
error: c,
|
|
3029
3042
|
results: n
|
|
3030
3043
|
});
|
|
@@ -3053,7 +3066,7 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
3053
3066
|
migrationName: l.name,
|
|
3054
3067
|
direction: "Up",
|
|
3055
3068
|
status: "Error"
|
|
3056
|
-
}, new
|
|
3069
|
+
}, new H({
|
|
3057
3070
|
error: c,
|
|
3058
3071
|
results: n
|
|
3059
3072
|
});
|
|
@@ -3061,10 +3074,10 @@ f = new WeakMap(), i = new WeakSet(), E = async function(e) {
|
|
|
3061
3074
|
}
|
|
3062
3075
|
return { results: n };
|
|
3063
3076
|
}, J = async function(e) {
|
|
3064
|
-
d(this,
|
|
3077
|
+
d(this, p).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
|
|
3065
3078
|
};
|
|
3066
3079
|
var K;
|
|
3067
|
-
class
|
|
3080
|
+
class H extends Error {
|
|
3068
3081
|
constructor(r) {
|
|
3069
3082
|
super();
|
|
3070
3083
|
N(this, K);
|