@authhero/kysely-adapter 10.128.0 → 10.128.1

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.
@@ -1,7 +1,7 @@
1
- var Fe = Object.defineProperty;
2
- var Re = (e, t, a) => t in e ? Fe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
1
+ var je = Object.defineProperty;
2
+ var Re = (e, t, a) => t in e ? je(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var B = (e, t, a) => Re(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { customAlphabet as Me, nanoid as I } from "nanoid";
4
+ import { customAlphabet as Me, nanoid as P } from "nanoid";
5
5
  import { parseUserId as Je, flowSchema as Y, codeSchema as Le, LoginSessionState as he, loginSessionSchema as qe, promptSettingSchema as Ke, formSchema as U, resourceServerSchema as Be } from "@authhero/adapter-interfaces";
6
6
  import "@hono/zod-openapi";
7
7
  import { sql as h, Migrator as pe } from "kysely";
@@ -84,7 +84,7 @@ function fe(e) {
84
84
  }
85
85
  }
86
86
  }
87
- function j(e, t = (/* @__PURE__ */ new Date(0)).toISOString()) {
87
+ function F(e, t = (/* @__PURE__ */ new Date(0)).toISOString()) {
88
88
  return fe(e) ?? t;
89
89
  }
90
90
  function N(e) {
@@ -100,7 +100,7 @@ function D(e, t, a = []) {
100
100
  const n = {};
101
101
  for (const o of t) {
102
102
  const r = o.replace(/_ts$/, "");
103
- n[r] = j(e[o]);
103
+ n[r] = F(e[o]);
104
104
  }
105
105
  for (const o of a) {
106
106
  const r = o.replace(/_ts$/, "");
@@ -149,7 +149,7 @@ function tt(e) {
149
149
  };
150
150
  };
151
151
  }
152
- function $(e, t, a, n) {
152
+ function E(e, t, a, n) {
153
153
  const o = a.split(/ OR /i);
154
154
  if (o.length > 1)
155
155
  return t.where((l) => {
@@ -211,14 +211,14 @@ function $(e, t, a, n) {
211
211
  t = t.where(
212
212
  (g) => g.or(
213
213
  f.map(
214
- (w) => w === "user_id" ? g(p(w), "=", c) : g(p(w), "like", `%${c}%`)
214
+ (y) => y === "user_id" ? g(p(y), "=", c) : g(p(y), "like", `%${c}%`)
215
215
  )
216
216
  )
217
217
  );
218
218
  }
219
219
  }), t;
220
220
  }
221
- function E(e) {
221
+ function $(e) {
222
222
  return typeof e == "string" ? parseInt(e, 10) : typeof e == "bigint" ? Number(e) : e;
223
223
  }
224
224
  function H(e) {
@@ -233,31 +233,31 @@ function at(e) {
233
233
  return async (t, a = {}) => {
234
234
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
235
235
  let i = e.selectFrom("actions").where("actions.tenant_id", "=", t);
236
- s && (i = $(e, i, s, ["name"]));
236
+ s && (i = E(e, i, s, ["name"]));
237
237
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
238
238
  const {
239
239
  created_at_ts: _,
240
240
  updated_at_ts: p,
241
241
  deployed_at_ts: f,
242
242
  secrets: g,
243
- dependencies: w,
243
+ dependencies: y,
244
244
  supported_triggers: C,
245
245
  tenant_id: x,
246
246
  ...b
247
- } = m, P = D({ created_at_ts: _, updated_at_ts: p }, [
247
+ } = m, I = D({ created_at_ts: _, updated_at_ts: p }, [
248
248
  "created_at_ts",
249
249
  "updated_at_ts"
250
250
  ]);
251
251
  return {
252
252
  ...b,
253
253
  tenant_id: t,
254
- ...P,
254
+ ...I,
255
255
  runtime: b.runtime ?? void 0,
256
256
  status: b.status || "built",
257
257
  deployed_at: f ? new Date(Number(f)).toISOString() : void 0,
258
258
  secrets: H(g),
259
259
  dependencies: H(
260
- w
260
+ y
261
261
  ),
262
262
  supported_triggers: H(
263
263
  C
@@ -276,7 +276,7 @@ function at(e) {
276
276
  actions: c,
277
277
  start: n * o,
278
278
  limit: o,
279
- length: E(d)
279
+ length: $(d)
280
280
  };
281
281
  };
282
282
  }
@@ -349,7 +349,7 @@ function st(e) {
349
349
  const u = async (l) => {
350
350
  if (await l.insertInto("users").values(i).execute(), r && i.user_id) {
351
351
  const c = {
352
- id: I(),
352
+ id: P(),
353
353
  user_id: i.user_id,
354
354
  password: r.hash,
355
355
  algorithm: r.algorithm,
@@ -456,13 +456,13 @@ function lt(e) {
456
456
  return async (t, a = {}) => {
457
457
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
458
458
  let u = e.selectFrom("users").where("users.tenant_id", "=", t);
459
- if (i && (u = $(e, u, i, ["email", "name", "phone_number"])), s && s.sort_by) {
459
+ if (i && (u = E(e, u, i, ["email", "name", "phone_number"])), s && s.sort_by) {
460
460
  const { ref: f } = e.dynamic;
461
461
  u = u.orderBy(f(s.sort_by), s.sort_order);
462
462
  }
463
463
  const c = await u.offset(n * o).limit(o).selectAll().execute(), d = c.map((f) => f.user_id), m = d.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", d).orderBy("created_at", "asc").execute() : [], _ = c.map((f) => {
464
464
  const g = m.filter(
465
- (w) => w.linked_to === f.user_id
465
+ (y) => y.linked_to === f.user_id
466
466
  );
467
467
  return v({
468
468
  ...f,
@@ -474,7 +474,7 @@ function lt(e) {
474
474
  address: f.address ? JSON.parse(f.address) : void 0,
475
475
  identities: [
476
476
  Q(f, !0),
477
- ...g.map((w) => Q(w))
477
+ ...g.map((y) => Q(y))
478
478
  ]
479
479
  });
480
480
  });
@@ -490,7 +490,7 @@ function lt(e) {
490
490
  users: _,
491
491
  start: n * o,
492
492
  limit: o,
493
- length: E(p)
493
+ length: $(p)
494
494
  };
495
495
  };
496
496
  }
@@ -567,7 +567,7 @@ function mt(e) {
567
567
  function ht(e) {
568
568
  return async (t, a) => {
569
569
  const n = (/* @__PURE__ */ new Date()).toISOString(), o = Y.parse({
570
- id: `af_${I()}`,
570
+ id: `af_${P()}`,
571
571
  ...a,
572
572
  actions: a.actions || [],
573
573
  created_at: n,
@@ -581,7 +581,7 @@ function ht(e) {
581
581
  }).execute(), o;
582
582
  };
583
583
  }
584
- function F(e, t) {
584
+ function j(e, t) {
585
585
  if (!e)
586
586
  return t;
587
587
  try {
@@ -592,7 +592,7 @@ function F(e, t) {
592
592
  }
593
593
  function we(e, t, a = { ...e }) {
594
594
  for (const n in t)
595
- n in e && (a[n] = F(
595
+ n in e && (a[n] = j(
596
596
  e[n],
597
597
  t[n]
598
598
  ));
@@ -604,7 +604,7 @@ function pt(e) {
604
604
  if (!n) return null;
605
605
  const o = {
606
606
  ...n,
607
- actions: F(n.actions, [])
607
+ actions: j(n.actions, [])
608
608
  };
609
609
  return Y.parse(v(o));
610
610
  };
@@ -613,11 +613,11 @@ function ft(e) {
613
613
  return async (t, a = {}) => {
614
614
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
615
615
  let i = e.selectFrom("flows").where("tenant_id", "=", t);
616
- s && (i = $(e, i, s, []));
616
+ s && (i = E(e, i, s, []));
617
617
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
618
618
  const _ = {
619
619
  ...m,
620
- actions: F(m.actions, [])
620
+ actions: j(m.actions, [])
621
621
  };
622
622
  return Y.parse(v(_));
623
623
  });
@@ -633,7 +633,7 @@ function ft(e) {
633
633
  flows: c,
634
634
  start: n * o,
635
635
  limit: o,
636
- length: E(d)
636
+ length: $(d)
637
637
  };
638
638
  };
639
639
  }
@@ -719,7 +719,7 @@ function Ct(e) {
719
719
  return async (t) => {
720
720
  var o, r;
721
721
  const a = {
722
- id: t.id || I(),
722
+ id: t.id || P(),
723
723
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
724
724
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
725
725
  ...t
@@ -754,13 +754,13 @@ function Tt(e) {
754
754
  const { ref: _ } = e.dynamic;
755
755
  a = a.orderBy(_(s.sort_by), s.sort_order);
756
756
  }
757
- i && (a = $(e, a, i, ["friendly_name"]));
757
+ i && (a = E(e, a, i, ["friendly_name"]));
758
758
  const c = (await a.offset(n * o).limit(o).selectAll().execute()).map(ve);
759
759
  if (!r)
760
760
  return {
761
761
  tenants: c
762
762
  };
763
- const { count: d } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = E(d);
763
+ const { count: d } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = $(d);
764
764
  return {
765
765
  tenants: c,
766
766
  start: n * o,
@@ -798,7 +798,7 @@ const Ot = 256;
798
798
  function kt(e) {
799
799
  return async (t, a) => {
800
800
  var i, u, l;
801
- const n = (i = a.user_agent) == null ? void 0 : i.slice(0, Ot), o = a.log_id || I(), { location_info: r, ...s } = a;
801
+ const n = (i = a.user_agent) == null ? void 0 : i.slice(0, Ot), o = a.log_id || P(), { location_info: r, ...s } = a;
802
802
  return await e.insertInto("logs").values({
803
803
  ...s,
804
804
  log_id: o,
@@ -853,11 +853,11 @@ function xe(e) {
853
853
  } : void 0
854
854
  };
855
855
  }
856
- function $t(e) {
856
+ function Et(e) {
857
857
  return async (t, a = {}) => {
858
858
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
859
859
  let u = e.selectFrom("logs").where("logs.tenant_id", "=", t);
860
- i && (u = $(e, u, i, ["user_id", "ip"]));
860
+ i && (u = E(e, u, i, ["user_id", "ip"]));
861
861
  let l = u;
862
862
  if (s && s.sort_by) {
863
863
  const { ref: _ } = e.dynamic;
@@ -877,24 +877,24 @@ function $t(e) {
877
877
  logs: d,
878
878
  start: n * o,
879
879
  limit: o,
880
- length: E(m)
880
+ length: $(m)
881
881
  };
882
882
  };
883
883
  }
884
- function Et(e) {
884
+ function $t(e) {
885
885
  return async (t, a) => {
886
886
  const n = await e.selectFrom("logs").where("logs.tenant_id", "=", t).where("logs.log_id", "=", a).selectAll().executeTakeFirst();
887
887
  return n ? xe(n) : null;
888
888
  };
889
889
  }
890
- function It(e) {
890
+ function Pt(e) {
891
891
  return {
892
892
  create: kt(e),
893
- list: $t(e),
894
- get: Et(e)
893
+ list: Et(e),
894
+ get: $t(e)
895
895
  };
896
896
  }
897
- function Pt(e) {
897
+ function It(e) {
898
898
  return async (t, a) => {
899
899
  const n = await e.selectFrom("sessions").where("sessions.tenant_id", "=", t).where("sessions.id", "=", a).selectAll().executeTakeFirst();
900
900
  if (!n)
@@ -987,11 +987,11 @@ function At(e) {
987
987
  )), n.used_at !== void 0 && (o.used_at_ts = N(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = N(n.revoked_at)), n.user_id !== void 0 && (o.user_id = n.user_id), n.login_session_id !== void 0 && (o.login_session_id = n.login_session_id), !!(await e.updateTable("sessions").set(o).where("tenant_id", "=", t).where("sessions.id", "=", a).execute()).length;
988
988
  };
989
989
  }
990
- function jt(e) {
990
+ function Ft(e) {
991
991
  return async (t, a = {}) => {
992
992
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
993
993
  let u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
994
- i && (u = $(e, u, i, ["user_id", "session_id"]));
994
+ i && (u = E(e, u, i, ["user_id", "session_id"]));
995
995
  let l = u;
996
996
  if (s && s.sort_by) {
997
997
  const { ref: p } = e.dynamic;
@@ -1002,22 +1002,22 @@ function jt(e) {
1002
1002
  const {
1003
1003
  tenant_id: f,
1004
1004
  device: g,
1005
- clients: w,
1005
+ clients: y,
1006
1006
  created_at_ts: C,
1007
1007
  updated_at_ts: x,
1008
1008
  expires_at_ts: b,
1009
- idle_expires_at_ts: P,
1009
+ idle_expires_at_ts: I,
1010
1010
  authenticated_at_ts: T,
1011
1011
  last_interaction_at_ts: A,
1012
1012
  used_at_ts: ae,
1013
1013
  revoked_at_ts: De,
1014
1014
  ...Ae
1015
- } = p, je = D(
1015
+ } = p, Fe = D(
1016
1016
  {
1017
1017
  created_at_ts: C,
1018
1018
  updated_at_ts: x,
1019
1019
  expires_at_ts: b,
1020
- idle_expires_at_ts: P,
1020
+ idle_expires_at_ts: I,
1021
1021
  authenticated_at_ts: T,
1022
1022
  last_interaction_at_ts: A,
1023
1023
  used_at_ts: ae,
@@ -1033,9 +1033,9 @@ function jt(e) {
1033
1033
  );
1034
1034
  return {
1035
1035
  ...Ae,
1036
- ...je,
1036
+ ...Fe,
1037
1037
  device: JSON.parse(g),
1038
- clients: JSON.parse(w)
1038
+ clients: JSON.parse(y)
1039
1039
  };
1040
1040
  });
1041
1041
  if (!r)
@@ -1045,7 +1045,7 @@ function jt(e) {
1045
1045
  limit: 0,
1046
1046
  length: 0
1047
1047
  };
1048
- const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = E(m);
1048
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
1049
1049
  return {
1050
1050
  sessions: d,
1051
1051
  start: n * o,
@@ -1054,11 +1054,11 @@ function jt(e) {
1054
1054
  };
1055
1055
  };
1056
1056
  }
1057
- function Ft(e) {
1057
+ function jt(e) {
1058
1058
  return {
1059
1059
  create: zt(e),
1060
- get: Pt(e),
1061
- list: jt(e),
1060
+ get: It(e),
1061
+ list: Ft(e),
1062
1062
  remove: Dt(e),
1063
1063
  update: At(e)
1064
1064
  };
@@ -1077,7 +1077,7 @@ function Rt(e) {
1077
1077
  }
1078
1078
  function Mt(e) {
1079
1079
  return async (t, a) => {
1080
- const n = a.id || I(), o = a.is_current ?? !0, r = {
1080
+ const n = a.id || P(), o = a.is_current ?? !0, r = {
1081
1081
  id: n,
1082
1082
  ...a,
1083
1083
  is_current: o,
@@ -1123,7 +1123,7 @@ function Kt(e) {
1123
1123
  return async (t, a = {}) => {
1124
1124
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1125
1125
  let i = e.selectFrom("codes").where("codes.tenant_id", "=", t);
1126
- s && (i = $(e, i, s, ["code", "login_id"]));
1126
+ s && (i = E(e, i, s, ["code", "login_id"]));
1127
1127
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1128
1128
  const { tenant_id: _, ...p } = m;
1129
1129
  return Le.parse(v(p));
@@ -1140,7 +1140,7 @@ function Kt(e) {
1140
1140
  codes: c,
1141
1141
  start: n * o,
1142
1142
  limit: o,
1143
- length: E(d)
1143
+ length: $(d)
1144
1144
  };
1145
1145
  };
1146
1146
  }
@@ -1216,7 +1216,7 @@ function Xt(e) {
1216
1216
  return async (t, a = {}) => {
1217
1217
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1218
1218
  let i = e.selectFrom("connections").where("connections.tenant_id", "=", t);
1219
- s && (i = $(e, i, s, ["user_id", "ip"]));
1219
+ s && (i = E(e, i, s, ["user_id", "ip"]));
1220
1220
  const l = await i.offset(n * o).limit(o).selectAll().execute(), c = Vt(l);
1221
1221
  if (!r)
1222
1222
  return {
@@ -1230,7 +1230,7 @@ function Xt(e) {
1230
1230
  connections: c,
1231
1231
  start: n * o,
1232
1232
  limit: o,
1233
- length: E(d)
1233
+ length: $(d)
1234
1234
  };
1235
1235
  };
1236
1236
  }
@@ -1634,7 +1634,7 @@ function pa(e) {
1634
1634
  }
1635
1635
  function fa(e) {
1636
1636
  return async (t, a) => {
1637
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = I(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1637
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = P(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1638
1638
  id: o,
1639
1639
  tenant_id: t,
1640
1640
  ...i,
@@ -1687,16 +1687,16 @@ function wa(e) {
1687
1687
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1688
1688
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1689
1689
  if (s) {
1690
- const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, w = g ? g[3] : "", C = /^(>=|>|<=|<)/.test(w || "");
1691
- if (g && !C && w) {
1692
- const x = !!g[1], b = g[2], { ref: P } = e.dynamic, T = P(`client_grants.${b}`);
1690
+ const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, y = g ? g[3] : "", C = /^(>=|>|<=|<)/.test(y || "");
1691
+ if (g && !C && y) {
1692
+ const x = !!g[1], b = g[2], { ref: I } = e.dynamic, T = I(`client_grants.${b}`);
1693
1693
  if (b === "allow_any_organization") {
1694
- const A = w === "true" ? 1 : 0;
1694
+ const A = y === "true" ? 1 : 0;
1695
1695
  x ? u = u.where(T, "!=", A) : u = u.where(T, "=", A);
1696
1696
  } else
1697
- x ? u = u.where(T, "!=", w) : u = u.where(T, "=", w);
1697
+ x ? u = u.where(T, "!=", y) : u = u.where(T, "=", y);
1698
1698
  } else
1699
- u = $(e, u, _, []);
1699
+ u = E(e, u, _, []);
1700
1700
  }
1701
1701
  let l = u;
1702
1702
  if (i) {
@@ -1734,7 +1734,7 @@ function wa(e) {
1734
1734
  client_grants: d,
1735
1735
  start: n * o,
1736
1736
  limit: o,
1737
- length: E(m)
1737
+ length: $(m)
1738
1738
  };
1739
1739
  };
1740
1740
  }
@@ -1776,7 +1776,7 @@ function xa(e) {
1776
1776
  _("revoked_at", "is", null)
1777
1777
  ])
1778
1778
  );
1779
- s && (i = $(e, i, s, [
1779
+ s && (i = E(e, i, s, [
1780
1780
  "kid",
1781
1781
  "connection",
1782
1782
  "fingerprint",
@@ -1794,7 +1794,7 @@ function xa(e) {
1794
1794
  limit: 0,
1795
1795
  length: 0
1796
1796
  };
1797
- const d = await u.executeTakeFirst(), m = E((d == null ? void 0 : d.count) ?? 0);
1797
+ const d = await u.executeTakeFirst(), m = $((d == null ? void 0 : d.count) ?? 0);
1798
1798
  return {
1799
1799
  signingKeys: c,
1800
1800
  start: l,
@@ -1821,7 +1821,7 @@ function ba(e) {
1821
1821
  function Sa(e) {
1822
1822
  return async (t, a) => {
1823
1823
  const n = {
1824
- custom_domain_id: a.custom_domain_id || I(),
1824
+ custom_domain_id: a.custom_domain_id || P(),
1825
1825
  status: "pending",
1826
1826
  primary: !1,
1827
1827
  ...a
@@ -1840,7 +1840,7 @@ function Oa(e) {
1840
1840
  return async (t) => (await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).selectAll().execute()).map((n) => ({
1841
1841
  ...n,
1842
1842
  primary: n.primary === 1,
1843
- domain_metadata: F(
1843
+ domain_metadata: j(
1844
1844
  n.domain_metadata,
1845
1845
  void 0
1846
1846
  )
@@ -1849,24 +1849,24 @@ function Oa(e) {
1849
1849
  function ka(e) {
1850
1850
  return async (t, a) => (await e.deleteFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
1851
1851
  }
1852
- function $a(e) {
1852
+ function Ea(e) {
1853
1853
  return async (t, a) => {
1854
1854
  const n = await e.selectFrom("custom_domains").where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).selectAll().executeTakeFirst();
1855
1855
  return n ? {
1856
1856
  ...n,
1857
1857
  primary: n.primary === 1,
1858
- domain_metadata: F(
1858
+ domain_metadata: j(
1859
1859
  n.domain_metadata,
1860
1860
  void 0
1861
1861
  ),
1862
- verification: F(
1862
+ verification: j(
1863
1863
  n.verification,
1864
1864
  void 0
1865
1865
  )
1866
1866
  } : null;
1867
1867
  };
1868
1868
  }
1869
- function Ea(e) {
1869
+ function $a(e) {
1870
1870
  return async (t, a, n) => {
1871
1871
  const { verification: o, domain_metadata: r, primary: s, ...i } = n, u = {
1872
1872
  ...i,
@@ -1882,27 +1882,27 @@ function Ea(e) {
1882
1882
  return (await e.updateTable("custom_domains").set(u).where("custom_domains.tenant_id", "=", t).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
1883
1883
  };
1884
1884
  }
1885
- function Ia(e) {
1885
+ function Pa(e) {
1886
1886
  return async (t) => {
1887
1887
  const a = await e.selectFrom("custom_domains").where("custom_domains.domain", "=", t).selectAll().executeTakeFirst();
1888
1888
  return a ? {
1889
1889
  ...a,
1890
1890
  primary: a.primary === 1,
1891
- domain_metadata: F(
1891
+ domain_metadata: j(
1892
1892
  a.domain_metadata,
1893
1893
  void 0
1894
1894
  )
1895
1895
  } : null;
1896
1896
  };
1897
1897
  }
1898
- function Pa(e) {
1898
+ function Ia(e) {
1899
1899
  return {
1900
1900
  create: Sa(e),
1901
- get: $a(e),
1902
- getByDomain: Ia(e),
1901
+ get: Ea(e),
1902
+ getByDomain: Pa(e),
1903
1903
  list: Oa(e),
1904
1904
  remove: ka(e),
1905
- update: Ea(e)
1905
+ update: $a(e)
1906
1906
  };
1907
1907
  }
1908
1908
  function za(e) {
@@ -1937,7 +1937,7 @@ function za(e) {
1937
1937
  }
1938
1938
  function Da(e) {
1939
1939
  return async (t, a) => {
1940
- var s, i, u, l, c, d, m, _, p, f, g, w, C, x, b, P, T, A;
1940
+ var s, i, u, l, c, d, m, _, p, f, g, y, C, x, b, I, T, A;
1941
1941
  const { colors: n, font: o, ...r } = a;
1942
1942
  try {
1943
1943
  await e.insertInto("branding").values({
@@ -1955,9 +1955,9 @@ function Da(e) {
1955
1955
  ...r,
1956
1956
  colors_primary: n == null ? void 0 : n.primary,
1957
1957
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1958
- colors_page_background_start: (C = (w = a.colors) == null ? void 0 : w.page_background) == null ? void 0 : C.start,
1958
+ colors_page_background_start: (C = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : C.start,
1959
1959
  colors_page_background_end: (b = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : b.end,
1960
- colors_page_background_angle_dev: (T = (P = a.colors) == null ? void 0 : P.page_background) == null ? void 0 : T.angle_deg,
1960
+ colors_page_background_angle_dev: (T = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : T.angle_deg,
1961
1961
  font_url: (A = a.font) == null ? void 0 : A.url
1962
1962
  }).where("tenant_id", "=", t).execute();
1963
1963
  }
@@ -1969,7 +1969,7 @@ function Aa(e) {
1969
1969
  set: Da(e)
1970
1970
  };
1971
1971
  }
1972
- function ja(e) {
1972
+ function Fa(e) {
1973
1973
  return async (t) => {
1974
1974
  const a = await e.selectFrom("universal_login_templates").select(["body"]).where("tenant_id", "=", t).executeTakeFirst();
1975
1975
  return a ? {
@@ -1977,7 +1977,7 @@ function ja(e) {
1977
1977
  } : null;
1978
1978
  };
1979
1979
  }
1980
- function Fa(e) {
1980
+ function ja(e) {
1981
1981
  return async (t, a) => {
1982
1982
  const n = Date.now();
1983
1983
  try {
@@ -2002,8 +2002,8 @@ function Ra(e) {
2002
2002
  }
2003
2003
  function Ma(e) {
2004
2004
  return {
2005
- get: ja(e),
2006
- set: Fa(e),
2005
+ get: Fa(e),
2006
+ set: ja(e),
2007
2007
  delete: Ra(e)
2008
2008
  };
2009
2009
  }
@@ -2011,7 +2011,7 @@ function Ja(e) {
2011
2011
  return async (t, a = {}) => {
2012
2012
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2013
2013
  let i = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
2014
- s && (i = $(e, i, s, [
2014
+ s && (i = E(e, i, s, [
2015
2015
  "url",
2016
2016
  "form_id",
2017
2017
  "template_id",
@@ -2023,9 +2023,9 @@ function Ja(e) {
2023
2023
  enabled: p,
2024
2024
  synchronous: f,
2025
2025
  created_at_ts: g,
2026
- updated_at_ts: w,
2026
+ updated_at_ts: y,
2027
2027
  ...C
2028
- } = m, x = D({ created_at_ts: g, updated_at_ts: w }, [
2028
+ } = m, x = D({ created_at_ts: g, updated_at_ts: y }, [
2029
2029
  "created_at_ts",
2030
2030
  "updated_at_ts"
2031
2031
  ]);
@@ -2048,7 +2048,7 @@ function Ja(e) {
2048
2048
  hooks: c,
2049
2049
  start: n * o,
2050
2050
  limit: o,
2051
- length: E(d)
2051
+ length: $(d)
2052
2052
  };
2053
2053
  };
2054
2054
  }
@@ -2183,7 +2183,7 @@ function Ga(e) {
2183
2183
  function Va(e) {
2184
2184
  return async (t, a, n) => {
2185
2185
  const o = {
2186
- themeId: n || I(),
2186
+ themeId: n || P(),
2187
2187
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2188
2188
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2189
2189
  ...a
@@ -2531,16 +2531,16 @@ function xn(e) {
2531
2531
  return e.transaction().execute(async (_) => {
2532
2532
  const f = !!(await _.updateTable("refresh_tokens").set(m).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length, g = m.expires_at_ts !== void 0 || m.idle_expires_at_ts !== void 0;
2533
2533
  if (f && g) {
2534
- const w = await _.selectFrom("refresh_tokens").select(["login_id", "expires_at_ts", "idle_expires_at_ts"]).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).executeTakeFirst();
2535
- if (w != null && w.login_id) {
2534
+ const y = await _.selectFrom("refresh_tokens").select(["login_id", "expires_at_ts", "idle_expires_at_ts"]).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).executeTakeFirst();
2535
+ if (y != null && y.login_id) {
2536
2536
  const C = Math.max(
2537
- w.expires_at_ts ?? 0,
2538
- w.idle_expires_at_ts ?? 0
2537
+ y.expires_at_ts ?? 0,
2538
+ y.idle_expires_at_ts ?? 0
2539
2539
  );
2540
2540
  C > 0 && await _.updateTable("login_sessions").set({
2541
2541
  expires_at_ts: C,
2542
2542
  updated_at_ts: Date.now()
2543
- }).where("tenant_id", "=", t).where("id", "=", w.login_id).where("expires_at_ts", "<", C).execute();
2543
+ }).where("tenant_id", "=", t).where("id", "=", y.login_id).where("expires_at_ts", "<", C).execute();
2544
2544
  }
2545
2545
  }
2546
2546
  return f;
@@ -2551,7 +2551,7 @@ function Tn(e) {
2551
2551
  return async (t, a = {}) => {
2552
2552
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
2553
2553
  let u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
2554
- i && (u = $(e, u, i, ["token", "login_id"]));
2554
+ i && (u = E(e, u, i, ["token", "login_id"]));
2555
2555
  let l = u;
2556
2556
  if (s && s.sort_by) {
2557
2557
  const { ref: p } = e.dynamic;
@@ -2562,14 +2562,14 @@ function Tn(e) {
2562
2562
  const {
2563
2563
  tenant_id: f,
2564
2564
  created_at_ts: g,
2565
- expires_at_ts: w,
2565
+ expires_at_ts: y,
2566
2566
  idle_expires_at_ts: C,
2567
2567
  last_exchanged_at_ts: x,
2568
2568
  ...b
2569
- } = p, P = D(
2569
+ } = p, I = D(
2570
2570
  {
2571
2571
  created_at_ts: g,
2572
- expires_at_ts: w,
2572
+ expires_at_ts: y,
2573
2573
  idle_expires_at_ts: C,
2574
2574
  last_exchanged_at_ts: x
2575
2575
  },
@@ -2578,7 +2578,7 @@ function Tn(e) {
2578
2578
  );
2579
2579
  return {
2580
2580
  ...b,
2581
- ...P,
2581
+ ...I,
2582
2582
  rotating: !!p.rotating,
2583
2583
  device: p.device ? JSON.parse(p.device) : {},
2584
2584
  resource_servers: p.resource_servers ? JSON.parse(p.resource_servers) : []
@@ -2591,7 +2591,7 @@ function Tn(e) {
2591
2591
  limit: 0,
2592
2592
  length: 0
2593
2593
  };
2594
- const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = E(m);
2594
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
2595
2595
  return {
2596
2596
  refresh_tokens: d,
2597
2597
  start: n * o,
@@ -2673,7 +2673,7 @@ function Sn(e) {
2673
2673
  function On(e) {
2674
2674
  return async (t, a) => {
2675
2675
  const n = U.parse({
2676
- id: I(),
2676
+ id: P(),
2677
2677
  ...a,
2678
2678
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2679
2679
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -2692,7 +2692,7 @@ function kn(e) {
2692
2692
  return async (t, a = {}) => {
2693
2693
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2694
2694
  let i = e.selectFrom("forms").where("tenant_id", "=", t);
2695
- s && (i = $(e, i, s, []));
2695
+ s && (i = E(e, i, s, []));
2696
2696
  const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2697
2697
  const _ = { ...m };
2698
2698
  if (typeof _.nodes == "string")
@@ -2724,17 +2724,17 @@ function kn(e) {
2724
2724
  forms: c,
2725
2725
  start: n * o,
2726
2726
  limit: o,
2727
- length: E(d)
2727
+ length: $(d)
2728
2728
  };
2729
2729
  };
2730
2730
  }
2731
- function $n(e) {
2731
+ function En(e) {
2732
2732
  return async (t, a) => {
2733
2733
  const { numDeletedRows: n } = await e.deleteFrom("forms").where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
2734
2734
  return n > 0;
2735
2735
  };
2736
2736
  }
2737
- function En(e) {
2737
+ function $n(e) {
2738
2738
  return async (t, a) => {
2739
2739
  const n = await e.selectFrom("forms").selectAll().where("forms.id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
2740
2740
  if (!n) return null;
@@ -2757,7 +2757,7 @@ function En(e) {
2757
2757
  return U.parse(v(o));
2758
2758
  };
2759
2759
  }
2760
- function In(e) {
2760
+ function Pn(e) {
2761
2761
  return async (t, a, n) => {
2762
2762
  const o = {
2763
2763
  ...n,
@@ -2768,13 +2768,13 @@ function In(e) {
2768
2768
  return r > 0;
2769
2769
  };
2770
2770
  }
2771
- function Pn(e) {
2771
+ function In(e) {
2772
2772
  return {
2773
2773
  create: On(e),
2774
- get: En(e),
2774
+ get: $n(e),
2775
2775
  list: kn(e),
2776
- remove: $n(e),
2777
- update: In(e)
2776
+ remove: En(e),
2777
+ update: Pn(e)
2778
2778
  };
2779
2779
  }
2780
2780
  function zn(e) {
@@ -2841,12 +2841,12 @@ function An(e) {
2841
2841
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2842
2842
  let i = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
2843
2843
  if (s) {
2844
- const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", w = /^(>=|>|<=|<)/.test(g || "");
2845
- if (f && !w) {
2844
+ const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", y = /^(>=|>|<=|<)/.test(g || "");
2845
+ if (f && !y) {
2846
2846
  const C = !!f[1], x = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2847
2847
  i = C ? i.where(x, "not like", `%${g}%`) : i.where(x, "like", `%${g}%`);
2848
2848
  } else
2849
- i = $(e, i, m, [
2849
+ i = E(e, i, m, [
2850
2850
  "resource_servers.name",
2851
2851
  "resource_servers.identifier"
2852
2852
  ]);
@@ -2856,16 +2856,16 @@ function An(e) {
2856
2856
  verification_key: p,
2857
2857
  scopes: f,
2858
2858
  options: g,
2859
- skip_consent_for_verifiable_first_party_clients: w,
2859
+ skip_consent_for_verifiable_first_party_clients: y,
2860
2860
  allow_offline_access: C,
2861
2861
  is_system: x,
2862
2862
  metadata: b,
2863
- ...P
2863
+ ...I
2864
2864
  } = _, T = v({
2865
- ...P,
2865
+ ...I,
2866
2866
  scopes: f ? JSON.parse(f) : [],
2867
2867
  options: g ? JSON.parse(g) : {},
2868
- skip_consent_for_verifiable_first_party_clients: !!w,
2868
+ skip_consent_for_verifiable_first_party_clients: !!y,
2869
2869
  allow_offline_access: !!C,
2870
2870
  is_system: x ? !0 : void 0,
2871
2871
  metadata: b ? JSON.parse(b) : void 0,
@@ -2886,17 +2886,17 @@ function An(e) {
2886
2886
  resource_servers: c,
2887
2887
  start: n * o,
2888
2888
  limit: o,
2889
- length: E(d)
2889
+ length: $(d)
2890
2890
  };
2891
2891
  };
2892
2892
  }
2893
- function jn(e) {
2893
+ function Fn(e) {
2894
2894
  return async (t, a) => {
2895
2895
  const n = await e.deleteFrom("resource_servers").where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
2896
2896
  return Number(n.numDeletedRows) > 0;
2897
2897
  };
2898
2898
  }
2899
- function Fn(e) {
2899
+ function jn(e) {
2900
2900
  return async (t, a, n) => {
2901
2901
  const {
2902
2902
  verificationKey: o,
@@ -2925,13 +2925,13 @@ function Rn(e) {
2925
2925
  create: zn(e),
2926
2926
  get: Dn(e),
2927
2927
  list: An(e),
2928
- remove: jn(e),
2929
- update: Fn(e)
2928
+ remove: Fn(e),
2929
+ update: jn(e)
2930
2930
  };
2931
2931
  }
2932
2932
  function Mn(e) {
2933
2933
  return async (t, a) => {
2934
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || I(), { is_system: r, id: s, metadata: i, ...u } = a, l = {
2934
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || P(), { is_system: r, id: s, metadata: i, ...u } = a, l = {
2935
2935
  id: o,
2936
2936
  ...u,
2937
2937
  tenant_id: t,
@@ -2966,7 +2966,7 @@ function Ln(e) {
2966
2966
  return async (t, a) => {
2967
2967
  let n = e.selectFrom("roles").where("roles.tenant_id", "=", t);
2968
2968
  const { page: o = 0, per_page: r = 50, include_totals: s = !1 } = a;
2969
- a.q && (n = $(e, n, a.q, ["name"]));
2969
+ a.q && (n = E(e, n, a.q, ["name"]));
2970
2970
  const l = (await n.offset(o * r).limit(r).selectAll().execute()).map((d) => {
2971
2971
  const m = d, { is_system: _, tenant_id: p, metadata: f, ...g } = m;
2972
2972
  return {
@@ -2987,7 +2987,7 @@ function Ln(e) {
2987
2987
  roles: l,
2988
2988
  start: o * r,
2989
2989
  limit: r,
2990
- length: E(c)
2990
+ length: $(c)
2991
2991
  };
2992
2992
  };
2993
2993
  }
@@ -3371,7 +3371,7 @@ function uo(e) {
3371
3371
  function _o(e) {
3372
3372
  return async (t, a) => {
3373
3373
  const n = {
3374
- id: I(),
3374
+ id: P(),
3375
3375
  tenant_id: t,
3376
3376
  user_id: a.user_id,
3377
3377
  organization_id: a.organization_id,
@@ -3769,12 +3769,12 @@ function Ne(e) {
3769
3769
  transports: n.transports ? JSON.parse(n.transports) : void 0,
3770
3770
  friendly_name: n.friendly_name ?? void 0,
3771
3771
  confirmed: n.confirmed === 1,
3772
- created_at: j(n.created_at_ts),
3773
- updated_at: j(n.updated_at_ts)
3772
+ created_at: F(n.created_at_ts),
3773
+ updated_at: F(n.updated_at_ts)
3774
3774
  } : null;
3775
3775
  };
3776
3776
  }
3777
- function $o(e) {
3777
+ function Eo(e) {
3778
3778
  return async (t, a) => {
3779
3779
  const n = await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.credential_id", "=", a).selectAll().executeTakeFirst();
3780
3780
  return n ? {
@@ -3790,12 +3790,12 @@ function $o(e) {
3790
3790
  transports: n.transports ? JSON.parse(n.transports) : void 0,
3791
3791
  friendly_name: n.friendly_name ?? void 0,
3792
3792
  confirmed: n.confirmed === 1,
3793
- created_at: j(n.created_at_ts),
3794
- updated_at: j(n.updated_at_ts)
3793
+ created_at: F(n.created_at_ts),
3794
+ updated_at: F(n.updated_at_ts)
3795
3795
  } : null;
3796
3796
  };
3797
3797
  }
3798
- function Eo(e) {
3798
+ function $o(e) {
3799
3799
  return async (t, a) => (await e.selectFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.user_id", "=", a).selectAll().execute()).map((o) => ({
3800
3800
  id: o.id,
3801
3801
  user_id: o.user_id,
@@ -3809,11 +3809,11 @@ function Eo(e) {
3809
3809
  transports: o.transports ? JSON.parse(o.transports) : void 0,
3810
3810
  friendly_name: o.friendly_name ?? void 0,
3811
3811
  confirmed: o.confirmed === 1,
3812
- created_at: j(o.created_at_ts),
3813
- updated_at: j(o.updated_at_ts)
3812
+ created_at: F(o.created_at_ts),
3813
+ updated_at: F(o.updated_at_ts)
3814
3814
  }));
3815
3815
  }
3816
- function Io(e) {
3816
+ function Po(e) {
3817
3817
  return async (t, a, n) => {
3818
3818
  const r = {
3819
3819
  updated_at_ts: Date.now()
@@ -3825,22 +3825,22 @@ function Io(e) {
3825
3825
  return s;
3826
3826
  };
3827
3827
  }
3828
- function Po(e) {
3828
+ function Io(e) {
3829
3829
  return async (t, a) => (await e.deleteFrom("authentication_methods").where("authentication_methods.tenant_id", "=", t).where("authentication_methods.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
3830
3830
  }
3831
3831
  function zo(e) {
3832
3832
  return {
3833
3833
  create: ko(e),
3834
3834
  get: Ne(e),
3835
- getByCredentialId: $o(e),
3836
- list: Eo(e),
3837
- update: Io(e),
3838
- remove: Po(e)
3835
+ getByCredentialId: Eo(e),
3836
+ list: $o(e),
3837
+ update: Po(e),
3838
+ remove: Io(e)
3839
3839
  };
3840
3840
  }
3841
3841
  function Do(e) {
3842
3842
  return async (t, a) => {
3843
- const n = I();
3843
+ const n = P();
3844
3844
  return await e.insertInto("outbox_events").values({
3845
3845
  id: n,
3846
3846
  tenant_id: t,
@@ -3868,7 +3868,7 @@ function Ao(e) {
3868
3868
  error: n.error
3869
3869
  }));
3870
3870
  }
3871
- function jo(e) {
3871
+ function Fo(e) {
3872
3872
  return async (t) => {
3873
3873
  const a = (/* @__PURE__ */ new Date()).toISOString();
3874
3874
  return (await e.selectFrom("outbox_events").selectAll().where("processed_at", "is", null).where(
@@ -3892,7 +3892,7 @@ function jo(e) {
3892
3892
  }));
3893
3893
  };
3894
3894
  }
3895
- function Fo(e) {
3895
+ function jo(e) {
3896
3896
  return async (t, a, n) => {
3897
3897
  if (t.length === 0) return [];
3898
3898
  const o = (/* @__PURE__ */ new Date()).toISOString(), r = new Date(Date.now() + n).toISOString();
@@ -3997,8 +3997,8 @@ function Bo(e) {
3997
3997
  return {
3998
3998
  create: Do(e),
3999
3999
  getByIds: Ao(e),
4000
- getUnprocessed: jo(e),
4001
- claimEvents: Fo(e),
4000
+ getUnprocessed: Fo(e),
4001
+ claimEvents: jo(e),
4002
4002
  markProcessed: Ro(e),
4003
4003
  markRetry: Mo(e),
4004
4004
  deadLetter: Jo(e),
@@ -4256,21 +4256,21 @@ async function Or(e) {
4256
4256
  async function kr(e) {
4257
4257
  await e.schema.dropIndex("users_email_index").execute();
4258
4258
  }
4259
- const $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4259
+ const Er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4260
4260
  __proto__: null,
4261
4261
  down: kr,
4262
4262
  up: Or
4263
4263
  }, Symbol.toStringTag, { value: "Module" }));
4264
- async function Er(e) {
4264
+ async function $r(e) {
4265
4265
  await e.schema.alterTable("users").addColumn("profileData", "varchar(2048)").execute();
4266
4266
  }
4267
- async function Ir(e) {
4267
+ async function Pr(e) {
4268
4268
  await e.schema.alterTable("users").dropColumn("profileData").execute();
4269
4269
  }
4270
- const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4270
+ const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4271
4271
  __proto__: null,
4272
- down: Ir,
4273
- up: Er
4272
+ down: Pr,
4273
+ up: $r
4274
4274
  }, Symbol.toStringTag, { value: "Module" }));
4275
4275
  async function zr(e) {
4276
4276
  await e.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute();
@@ -4283,16 +4283,16 @@ const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4283
4283
  down: Dr,
4284
4284
  up: zr
4285
4285
  }, Symbol.toStringTag, { value: "Module" }));
4286
- async function jr(e) {
4286
+ async function Fr(e) {
4287
4287
  await e.schema.alterTable("users").addColumn("locale", "varchar(255)").execute();
4288
4288
  }
4289
- async function Fr(e) {
4289
+ async function jr(e) {
4290
4290
  await e.schema.alterTable("users").dropColumn("locale").execute();
4291
4291
  }
4292
4292
  const Rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4293
4293
  __proto__: null,
4294
- down: Fr,
4295
- up: jr
4294
+ down: jr,
4295
+ up: Fr
4296
4296
  }, Symbol.toStringTag, { value: "Module" }));
4297
4297
  async function Mr(e) {
4298
4298
  await e.schema.createTable("keys").addColumn("kid", "varchar(255)", (t) => t.primaryKey()).addColumn(
@@ -4463,19 +4463,19 @@ async function Os(e) {
4463
4463
  async function ks(e) {
4464
4464
  await e.schema.dropTable("branding").execute();
4465
4465
  }
4466
- const $s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4466
+ const Es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4467
4467
  __proto__: null,
4468
4468
  down: ks,
4469
4469
  up: Os
4470
4470
  }, Symbol.toStringTag, { value: "Module" }));
4471
- async function Es(e) {
4471
+ async function $s(e) {
4472
4472
  }
4473
- async function Is(e) {
4473
+ async function Ps(e) {
4474
4474
  }
4475
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4475
+ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4476
4476
  __proto__: null,
4477
- down: Is,
4478
- up: Es
4477
+ down: Ps,
4478
+ up: $s
4479
4479
  }, Symbol.toStringTag, { value: "Module" }));
4480
4480
  async function zs(e) {
4481
4481
  }
@@ -4486,14 +4486,14 @@ const As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4486
4486
  down: Ds,
4487
4487
  up: zs
4488
4488
  }, Symbol.toStringTag, { value: "Module" }));
4489
- async function js(e) {
4490
- }
4491
4489
  async function Fs(e) {
4492
4490
  }
4491
+ async function js(e) {
4492
+ }
4493
4493
  const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4494
4494
  __proto__: null,
4495
- down: Fs,
4496
- up: js
4495
+ down: js,
4496
+ up: Fs
4497
4497
  }, Symbol.toStringTag, { value: "Module" }));
4498
4498
  async function Ms(e) {
4499
4499
  }
@@ -4675,21 +4675,21 @@ async function Oi(e) {
4675
4675
  }
4676
4676
  async function ki(e) {
4677
4677
  }
4678
- const $i = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4678
+ const Ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4679
4679
  __proto__: null,
4680
4680
  down: ki,
4681
4681
  up: Oi
4682
4682
  }, Symbol.toStringTag, { value: "Module" }));
4683
- async function Ei(e) {
4683
+ async function $i(e) {
4684
4684
  await e.schema.alterTable("logins").addColumn("authParams_nonce", "varchar(255)").execute();
4685
4685
  }
4686
- async function Ii(e) {
4686
+ async function Pi(e) {
4687
4687
  await e.schema.alterTable("logins").dropColumn("nonce").execute();
4688
4688
  }
4689
- const Pi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4689
+ const Ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4690
4690
  __proto__: null,
4691
- down: Ii,
4692
- up: Ei
4691
+ down: Pi,
4692
+ up: $i
4693
4693
  }, Symbol.toStringTag, { value: "Module" }));
4694
4694
  async function zi(e) {
4695
4695
  }
@@ -4700,14 +4700,14 @@ const Ai = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4700
4700
  down: Di,
4701
4701
  up: zi
4702
4702
  }, Symbol.toStringTag, { value: "Module" }));
4703
- async function ji(e) {
4704
- }
4705
4703
  async function Fi(e) {
4706
4704
  }
4705
+ async function ji(e) {
4706
+ }
4707
4707
  const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4708
4708
  __proto__: null,
4709
- down: Fi,
4710
- up: ji
4709
+ down: ji,
4710
+ up: Fi
4711
4711
  }, Symbol.toStringTag, { value: "Module" }));
4712
4712
  async function Mi(e) {
4713
4713
  await e.schema.dropTable("codes").execute(), await e.schema.createTable("codes").addColumn("code_id", "varchar(255)", (t) => t.notNull()).addColumn(
@@ -4930,20 +4930,20 @@ async function kc(e) {
4930
4930
  (t) => t.references("applications.id").onDelete("cascade").notNull()
4931
4931
  ).addColumn("email", "varchar(255)", (t) => t.notNull()).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)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4932
4932
  }
4933
- const $c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4933
+ const Ec = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4934
4934
  __proto__: null,
4935
4935
  down: kc,
4936
4936
  up: Oc
4937
4937
  }, Symbol.toStringTag, { value: "Module" }));
4938
- async function Ec(e) {
4938
+ async function $c(e) {
4939
4939
  }
4940
- async function Ic(e) {
4940
+ async function Pc(e) {
4941
4941
  await e.schema.alterTable("logins").dropColumn("ip").dropColumn("useragent").execute();
4942
4942
  }
4943
- const Pc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4943
+ const Ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4944
4944
  __proto__: null,
4945
- down: Ic,
4946
- up: Ec
4945
+ down: Pc,
4946
+ up: $c
4947
4947
  }, Symbol.toStringTag, { value: "Module" }));
4948
4948
  async function zc(e) {
4949
4949
  await e.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn(
@@ -4966,14 +4966,14 @@ const Ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4966
4966
  down: Dc,
4967
4967
  up: zc
4968
4968
  }, Symbol.toStringTag, { value: "Module" }));
4969
- async function jc(e) {
4970
- }
4971
4969
  async function Fc(e) {
4972
4970
  }
4971
+ async function jc(e) {
4972
+ }
4973
4973
  const Rc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4974
4974
  __proto__: null,
4975
- down: Fc,
4976
- up: jc
4975
+ down: jc,
4976
+ up: Fc
4977
4977
  }, Symbol.toStringTag, { value: "Module" }));
4978
4978
  async function Mc(e) {
4979
4979
  await e.schema.dropTable("sessions").execute(), await e.schema.dropTable("refresh_tokens").execute();
@@ -5213,21 +5213,21 @@ async function Ol(e) {
5213
5213
  async function kl(e) {
5214
5214
  await e.schema.dropIndex("IDX_sessions_login_session_id").on("sessions").execute();
5215
5215
  }
5216
- const $l = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5216
+ const El = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5217
5217
  __proto__: null,
5218
5218
  down: kl,
5219
5219
  up: Ol
5220
5220
  }, Symbol.toStringTag, { value: "Module" }));
5221
- async function El(e) {
5221
+ async function $l(e) {
5222
5222
  await e.schema.alterTable("codes").addColumn("code_challenge", "varchar(128)").execute(), await e.schema.alterTable("codes").addColumn("code_challenge_method", "varchar(5)").execute();
5223
5223
  }
5224
- async function Il(e) {
5224
+ async function Pl(e) {
5225
5225
  await e.schema.alterTable("codes").dropColumn("code_challenge").execute(), await e.schema.alterTable("codes").dropColumn("code_challenge_method").execute();
5226
5226
  }
5227
- const Pl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5227
+ const Il = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5228
5228
  __proto__: null,
5229
- down: Il,
5230
- up: El
5229
+ down: Pl,
5230
+ up: $l
5231
5231
  }, Symbol.toStringTag, { value: "Module" }));
5232
5232
  async function zl(e) {
5233
5233
  await e.schema.alterTable("codes").addColumn("redirect_uri", "varchar(1024)").execute();
@@ -5240,16 +5240,16 @@ const Al = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5240
5240
  down: Dl,
5241
5241
  up: zl
5242
5242
  }, Symbol.toStringTag, { value: "Module" }));
5243
- async function jl(e) {
5243
+ async function Fl(e) {
5244
5244
  await e.schema.alterTable("codes").addColumn("nonce", "varchar(1024)").execute(), await e.schema.alterTable("codes").addColumn("state", "varchar(2048)").execute();
5245
5245
  }
5246
- async function Fl(e) {
5246
+ async function jl(e) {
5247
5247
  await e.schema.alterTable("codes").dropColumn("nonce").execute(), await e.schema.alterTable("codes").dropColumn("state").execute();
5248
5248
  }
5249
5249
  const Rl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5250
5250
  __proto__: null,
5251
- down: Fl,
5252
- up: jl
5251
+ down: jl,
5252
+ up: Fl
5253
5253
  }, Symbol.toStringTag, { value: "Module" }));
5254
5254
  async function Ml(e) {
5255
5255
  await e.schema.createTable("themes").addColumn(
@@ -5526,7 +5526,7 @@ let Se = !1;
5526
5526
  function Oe(e) {
5527
5527
  Se = e;
5528
5528
  }
5529
- function y(...e) {
5529
+ function w(...e) {
5530
5530
  Se && console.log(...e);
5531
5531
  }
5532
5532
  function z(...e) {
@@ -5557,7 +5557,7 @@ async function md(e) {
5557
5557
  try {
5558
5558
  await h`ALTER TABLE ${h.raw(s)} DROP FOREIGN KEY ${h.raw(r)}`.execute(
5559
5559
  t
5560
- ), y(
5560
+ ), w(
5561
5561
  `Dropped foreign key constraint ${r} from ${s}`
5562
5562
  );
5563
5563
  } catch (i) {
@@ -5798,24 +5798,24 @@ const Od = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5798
5798
  async function kd(e) {
5799
5799
  await e.schema.createIndex("login_sessions_id_index").on("login_sessions").column("id").execute();
5800
5800
  }
5801
- async function $d(e) {
5801
+ async function Ed(e) {
5802
5802
  await e.schema.dropIndex("login_sessions_id_index").execute();
5803
5803
  }
5804
- const Ed = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5804
+ const $d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5805
5805
  __proto__: null,
5806
- down: $d,
5806
+ down: Ed,
5807
5807
  up: kd
5808
5808
  }, Symbol.toStringTag, { value: "Module" }));
5809
- async function Id(e) {
5809
+ async function Pd(e) {
5810
5810
  await e.schema.createIndex("connections_tenant_id_index").on("connections").column("tenant_id").execute();
5811
5811
  }
5812
- async function Pd(e) {
5812
+ async function Id(e) {
5813
5813
  await e.schema.dropIndex("connections_tenant_id_index").execute();
5814
5814
  }
5815
5815
  const zd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5816
5816
  __proto__: null,
5817
- down: Pd,
5818
- up: Id
5817
+ down: Id,
5818
+ up: Pd
5819
5819
  }, Symbol.toStringTag, { value: "Module" }));
5820
5820
  async function Dd(e) {
5821
5821
  await e.schema.dropIndex("idx_user_organizations_tenant_id").execute();
@@ -5823,12 +5823,12 @@ async function Dd(e) {
5823
5823
  async function Ad(e) {
5824
5824
  await e.schema.createIndex("idx_user_organizations_tenant_id").on("user_organizations").column("tenant_id").execute();
5825
5825
  }
5826
- const jd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5826
+ const Fd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5827
5827
  __proto__: null,
5828
5828
  down: Ad,
5829
5829
  up: Dd
5830
5830
  }, Symbol.toStringTag, { value: "Module" }));
5831
- async function Fd(e) {
5831
+ async function jd(e) {
5832
5832
  await e.schema.createTable("tenant_settings").addColumn(
5833
5833
  "tenant_id",
5834
5834
  "varchar(191)",
@@ -5841,7 +5841,7 @@ async function Rd(e) {
5841
5841
  const Md = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5842
5842
  __proto__: null,
5843
5843
  down: Rd,
5844
- up: Fd
5844
+ up: jd
5845
5845
  }, Symbol.toStringTag, { value: "Module" }));
5846
5846
  async function Jd(e) {
5847
5847
  if (await e.schema.alterTable("tenants").addColumn("idle_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("session_cookie", "text").execute(), await e.schema.alterTable("tenants").addColumn("allowed_logout_urls", "text").execute(), await e.schema.alterTable("tenants").addColumn("ephemeral_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("idle_ephemeral_session_lifetime", "integer").execute(), await e.schema.alterTable("tenants").addColumn("default_redirection_uri", "text").execute(), await e.schema.alterTable("tenants").addColumn("enabled_locales", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_directory", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("error_page", "text").execute(), await e.schema.alterTable("tenants").addColumn("flags", "text").execute(), await e.schema.alterTable("tenants").addColumn("friendly_name", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("picture_url", "text").execute(), await e.schema.alterTable("tenants").addColumn("support_email", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("sandbox_version", "varchar(50)").execute(), await e.schema.alterTable("tenants").addColumn("sandbox_versions_available", "text").execute(), await e.schema.alterTable("tenants").addColumn("legacy_sandbox_version", "varchar(50)").execute(), await e.schema.alterTable("tenants").addColumn("change_password", "text").execute(), await e.schema.alterTable("tenants").addColumn("guardian_mfa_page", "text").execute(), await e.schema.alterTable("tenants").addColumn("device_flow", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_token_quota", "text").execute(), await e.schema.alterTable("tenants").addColumn("default_audience", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("default_organization", "varchar(255)").execute(), await e.schema.alterTable("tenants").addColumn("sessions", "text").execute(), await e.schema.alterTable("tenants").addColumn("oidc_logout", "text").execute(), await e.schema.alterTable("tenants").addColumn("allow_organization_name_in_authentication_api", "integer").execute(), await e.schema.alterTable("tenants").addColumn("customize_mfa_in_postlogin_action", "integer").execute(), await e.schema.alterTable("tenants").addColumn("acr_values_supported", "text").execute(), await e.schema.alterTable("tenants").addColumn("mtls", "text").execute(), await e.schema.alterTable("tenants").addColumn("pushed_authorization_requests_supported", "integer").execute(), await e.schema.alterTable("tenants").addColumn("authorization_response_iss_parameter_supported", "integer").execute(), await e.updateTable("tenants").set({
@@ -6001,7 +6001,7 @@ async function Xd(e) {
6001
6001
  }
6002
6002
  for (const o of n)
6003
6003
  await e.insertInto("password_history").values({
6004
- id: I(),
6004
+ id: P(),
6005
6005
  user_id: o.user_id,
6006
6006
  tenant_id: o.tenant_id,
6007
6007
  password: o.password,
@@ -6228,7 +6228,7 @@ async function S(e, t, a, n) {
6228
6228
  await e.schema.alterTable(t).addColumn(a, n).execute();
6229
6229
  } catch (o) {
6230
6230
  if (o instanceof Error && (o.message.includes("1060") || o.message.includes("duplicate column"))) {
6231
- y(
6231
+ w(
6232
6232
  ` Column ${t}.${a} already exists, skipping`
6233
6233
  );
6234
6234
  return;
@@ -6266,7 +6266,7 @@ const bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6266
6266
  down: Nu,
6267
6267
  up: Tu
6268
6268
  }, Symbol.toStringTag, { value: "Module" }));
6269
- async function $e(e) {
6269
+ async function Ee(e) {
6270
6270
  try {
6271
6271
  return await h`SELECT VERSION()`.execute(e), "mysql";
6272
6272
  } catch {
@@ -6279,7 +6279,7 @@ async function k(e, t, a) {
6279
6279
  } catch (n) {
6280
6280
  const o = n instanceof Error ? n.message : String(n);
6281
6281
  if (o.includes("1091") || o.includes("no such column")) {
6282
- y(
6282
+ w(
6283
6283
  ` Column ${t}.${a} doesn't exist, skipping`
6284
6284
  );
6285
6285
  return;
@@ -6288,39 +6288,39 @@ async function k(e, t, a) {
6288
6288
  }
6289
6289
  }
6290
6290
  async function Su(e) {
6291
- const t = await $e(e);
6292
- y("Dropping indexes that depend on old date columns...");
6291
+ const t = await Ee(e);
6292
+ w("Dropping indexes that depend on old date columns...");
6293
6293
  try {
6294
6294
  await h`DROP INDEX IF EXISTS login_sessions_state_updated_idx`.execute(
6295
6295
  e
6296
- ), y(" Dropped index login_sessions_state_updated_idx");
6296
+ ), w(" Dropped index login_sessions_state_updated_idx");
6297
6297
  } catch (a) {
6298
6298
  z(
6299
6299
  ` Warning: Failed to drop index login_sessions_state_updated_idx: ${a instanceof Error ? a.message : String(a)}`
6300
6300
  );
6301
6301
  }
6302
- y("Dropping old date columns..."), await k(e, "refresh_tokens", "created_at"), await k(e, "refresh_tokens", "expires_at"), await k(e, "refresh_tokens", "idle_expires_at"), await k(e, "refresh_tokens", "last_exchanged_at"), await k(e, "sessions", "created_at"), await k(e, "sessions", "updated_at"), await k(e, "sessions", "expires_at"), await k(e, "sessions", "idle_expires_at"), await k(e, "sessions", "authenticated_at"), await k(e, "sessions", "last_interaction_at"), await k(e, "sessions", "used_at"), await k(e, "sessions", "revoked_at"), await k(e, "login_sessions", "created_at"), await k(e, "login_sessions", "updated_at"), await k(e, "login_sessions", "expires_at"), t === "mysql" && (y("Increasing ID column sizes for ULID support..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(26)").execute()), y("Migration completed successfully");
6302
+ w("Dropping old date columns..."), await k(e, "refresh_tokens", "created_at"), await k(e, "refresh_tokens", "expires_at"), await k(e, "refresh_tokens", "idle_expires_at"), await k(e, "refresh_tokens", "last_exchanged_at"), await k(e, "sessions", "created_at"), await k(e, "sessions", "updated_at"), await k(e, "sessions", "expires_at"), await k(e, "sessions", "idle_expires_at"), await k(e, "sessions", "authenticated_at"), await k(e, "sessions", "last_interaction_at"), await k(e, "sessions", "used_at"), await k(e, "sessions", "revoked_at"), await k(e, "login_sessions", "created_at"), await k(e, "login_sessions", "updated_at"), await k(e, "login_sessions", "expires_at"), t === "mysql" && (w("Increasing ID column sizes for ULID support..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(26)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(26)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(26)").execute()), w("Migration completed successfully");
6303
6303
  }
6304
6304
  async function Ou(e) {
6305
- await $e(e) === "mysql" && (y("Restoring ID column sizes to varchar(21)..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(21)").execute()), y("Re-adding old date columns (data will be empty)..."), await e.schema.alterTable("refresh_tokens").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("last_exchanged_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("authenticated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("last_interaction_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("used_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("revoked_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("expires_at", "varchar(35)").execute(), y("Rollback completed");
6305
+ await Ee(e) === "mysql" && (w("Restoring ID column sizes to varchar(21)..."), await e.schema.alterTable("login_sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("session_id", "varchar(21)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("csrf_token", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("sessions").modifyColumn("login_session_id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("id", "varchar(21)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("session_id", "varchar(21)").execute()), w("Re-adding old date columns (data will be empty)..."), await e.schema.alterTable("refresh_tokens").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").addColumn("last_exchanged_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("idle_expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("authenticated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("last_interaction_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("used_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").addColumn("revoked_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").addColumn("expires_at", "varchar(35)").execute(), w("Rollback completed");
6306
6306
  }
6307
6307
  const ku = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6308
6308
  __proto__: null,
6309
6309
  down: Ou,
6310
6310
  up: Su
6311
6311
  }, Symbol.toStringTag, { value: "Module" }));
6312
- async function $u(e) {
6312
+ async function Eu(e) {
6313
6313
  await e.schema.alterTable("users").dropColumn("user_metadata").execute(), await e.schema.alterTable("users").addColumn("user_metadata", "text").execute(), await e.schema.alterTable("users").addColumn("middle_name", "varchar(100)").execute(), await e.schema.alterTable("users").addColumn("profile", "text").execute(), await e.schema.alterTable("users").addColumn("website", "text").execute(), await e.schema.alterTable("users").addColumn("gender", "varchar(50)").execute(), await e.schema.alterTable("users").addColumn("birthdate", "varchar(10)").execute(), await e.schema.alterTable("users").addColumn("zoneinfo", "varchar(100)").execute();
6314
6314
  }
6315
- async function Eu(e) {
6315
+ async function $u(e) {
6316
6316
  await e.schema.alterTable("users").dropColumn("middle_name").execute(), await e.schema.alterTable("users").dropColumn("profile").execute(), await e.schema.alterTable("users").dropColumn("website").execute(), await e.schema.alterTable("users").dropColumn("gender").execute(), await e.schema.alterTable("users").dropColumn("birthdate").execute(), await e.schema.alterTable("users").dropColumn("zoneinfo").execute(), await e.schema.alterTable("users").dropColumn("user_metadata").execute(), await e.schema.alterTable("users").addColumn("user_metadata", "varchar(4096)").execute();
6317
6317
  }
6318
- const Iu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6318
+ const Pu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6319
6319
  __proto__: null,
6320
- down: Eu,
6321
- up: $u
6320
+ down: $u,
6321
+ up: Eu
6322
6322
  }, Symbol.toStringTag, { value: "Module" }));
6323
- async function Pu(e) {
6323
+ async function Iu(e) {
6324
6324
  await e.schema.alterTable("users").addColumn("preferred_username", "varchar(255)").execute();
6325
6325
  }
6326
6326
  async function zu(e) {
@@ -6329,29 +6329,29 @@ async function zu(e) {
6329
6329
  const Du = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6330
6330
  __proto__: null,
6331
6331
  down: zu,
6332
- up: Pu
6332
+ up: Iu
6333
6333
  }, Symbol.toStringTag, { value: "Module" }));
6334
6334
  async function Au(e) {
6335
6335
  await e.schema.alterTable("users").addColumn("address", "text").execute();
6336
6336
  }
6337
- async function ju(e) {
6337
+ async function Fu(e) {
6338
6338
  await e.schema.alterTable("users").dropColumn("address").execute();
6339
6339
  }
6340
- const Fu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6340
+ const ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6341
6341
  __proto__: null,
6342
- down: ju,
6342
+ down: Fu,
6343
6343
  up: Au
6344
6344
  }, Symbol.toStringTag, { value: "Module" }));
6345
6345
  async function Ru(e) {
6346
6346
  try {
6347
- await e.schema.alterTable("login_sessions").addColumn("authParams_max_age", "integer").execute(), y(" Added column authParams_max_age to login_sessions");
6347
+ await e.schema.alterTable("login_sessions").addColumn("authParams_max_age", "integer").execute(), w(" Added column authParams_max_age to login_sessions");
6348
6348
  } catch (t) {
6349
6349
  z(
6350
6350
  ` Warning: Could not add authParams_max_age column: ${t instanceof Error ? t.message : String(t)}`
6351
6351
  );
6352
6352
  }
6353
6353
  try {
6354
- await e.schema.alterTable("login_sessions").addColumn("authParams_acr_values", "text").execute(), y(" Added column authParams_acr_values to login_sessions");
6354
+ await e.schema.alterTable("login_sessions").addColumn("authParams_acr_values", "text").execute(), w(" Added column authParams_acr_values to login_sessions");
6355
6355
  } catch (t) {
6356
6356
  z(
6357
6357
  ` Warning: Could not add authParams_acr_values column: ${t instanceof Error ? t.message : String(t)}`
@@ -6447,7 +6447,7 @@ async function G(e, t, a, n) {
6447
6447
  await e.schema.alterTable(t).addColumn(a, h.raw(n)).execute();
6448
6448
  } catch (o) {
6449
6449
  if (o instanceof Error && (o.message.includes("1060") || o.message.includes("duplicate column"))) {
6450
- y(
6450
+ w(
6451
6451
  ` Column ${t}.${a} already exists, skipping`
6452
6452
  );
6453
6453
  return;
@@ -6486,7 +6486,7 @@ const a_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6486
6486
  down: t_,
6487
6487
  up: e_
6488
6488
  }, Symbol.toStringTag, { value: "Module" }));
6489
- async function Ee(e) {
6489
+ async function $e(e) {
6490
6490
  try {
6491
6491
  return await h`SELECT VERSION()`.execute(e), "mysql";
6492
6492
  } catch {
@@ -6499,7 +6499,7 @@ async function de(e, t, a) {
6499
6499
  } catch (n) {
6500
6500
  const o = n instanceof Error ? n.message : String(n);
6501
6501
  if (o.includes("1091") || o.includes("no such column")) {
6502
- y(
6502
+ w(
6503
6503
  ` Column ${t}.${a} doesn't exist, skipping`
6504
6504
  );
6505
6505
  return;
@@ -6509,8 +6509,8 @@ async function de(e, t, a) {
6509
6509
  }
6510
6510
  async function n_(e) {
6511
6511
  var r, s, i, u, l;
6512
- const t = await Ee(e);
6513
- y(
6512
+ const t = await $e(e);
6513
+ w(
6514
6514
  "Running preflight integrity check on hooks timestamp columns..."
6515
6515
  );
6516
6516
  const { rows: a } = await h`SELECT
@@ -6521,8 +6521,8 @@ async function n_(e) {
6521
6521
  throw new Error(
6522
6522
  `Preflight check failed: ${n} row(s) with NULL created_at_ts, ${o} row(s) with NULL updated_at_ts. All timestamp data must be migrated to _ts columns before dropping legacy columns.`
6523
6523
  );
6524
- if (y(" Preflight check passed — all _ts columns are populated."), t === "mysql") {
6525
- y("Running preflight length check on columns being narrowed...");
6524
+ if (w(" Preflight check passed — all _ts columns are populated."), t === "mysql") {
6525
+ w("Running preflight length check on columns being narrowed...");
6526
6526
  const { rows: c } = await h`SELECT
6527
6527
  SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
6528
6528
  SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
@@ -6536,18 +6536,18 @@ async function n_(e) {
6536
6536
  throw new Error(
6537
6537
  `Preflight length check failed: ${p.join("; ")}. Truncate or fix oversized values before running this migration.`
6538
6538
  );
6539
- y(
6539
+ w(
6540
6540
  " Preflight length check passed — all values fit within new column sizes."
6541
6541
  );
6542
6542
  }
6543
- y("Dropping old date columns from hooks..."), await de(e, "hooks", "created_at"), await de(e, "hooks", "updated_at"), t === "mysql" && (y("Fixing hook column types..."), await e.schema.alterTable("hooks").modifyColumn(
6543
+ w("Dropping old date columns from hooks..."), await de(e, "hooks", "created_at"), await de(e, "hooks", "updated_at"), t === "mysql" && (w("Fixing hook column types..."), await e.schema.alterTable("hooks").modifyColumn(
6544
6544
  "hook_id",
6545
6545
  "varchar(21)",
6546
6546
  (c) => c.notNull().primaryKey()
6547
6547
  ).execute(), await e.schema.alterTable("hooks").modifyColumn("form_id", "varchar(128)").execute(), await e.schema.alterTable("hooks").modifyColumn("template_id", "varchar(64)").execute());
6548
6548
  }
6549
6549
  async function o_(e) {
6550
- const t = await Ee(e);
6550
+ const t = await $e(e);
6551
6551
  await e.schema.alterTable("hooks").addColumn("created_at", "varchar(255)").execute(), await e.schema.alterTable("hooks").addColumn("updated_at", "varchar(255)").execute(), t === "mysql" ? await h`
6552
6552
  UPDATE hooks
6553
6553
  SET created_at = DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(created_at_ts / 1000), @@session.time_zone, '+00:00'), '%Y-%m-%dT%H:%i:%s.000Z'),
@@ -6578,11 +6578,11 @@ async function s_(e) {
6578
6578
  HAVING COUNT(*) > 1
6579
6579
  `.execute(e);
6580
6580
  if (t.length > 0) {
6581
- y(
6581
+ w(
6582
6582
  `Found ${t.length} duplicate (username, provider, tenant_id) group(s) – cleaning up…`
6583
6583
  );
6584
6584
  for (const a of t)
6585
- y(` provider=${a.provider} count=${a.cnt}`);
6585
+ w(` provider=${a.provider} count=${a.cnt}`);
6586
6586
  await h`
6587
6587
  DELETE FROM users
6588
6588
  WHERE username IS NOT NULL
@@ -6599,7 +6599,7 @@ async function s_(e) {
6599
6599
  GROUP BY username, provider, tenant_id
6600
6600
  HAVING COUNT(*) > 1
6601
6601
  )
6602
- `.execute(e), y("Duplicate rows removed.");
6602
+ `.execute(e), w("Duplicate rows removed.");
6603
6603
  }
6604
6604
  await e.schema.createIndex("unique_username_provider").on("users").unique().columns(["username", "provider", "tenant_id"]).execute();
6605
6605
  }
@@ -6622,7 +6622,7 @@ const u_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6622
6622
  down: d_,
6623
6623
  up: l_
6624
6624
  }, Symbol.toStringTag, { value: "Module" }));
6625
- async function Ie(e) {
6625
+ async function Pe(e) {
6626
6626
  try {
6627
6627
  return await h`SELECT VERSION()`.execute(e), "mysql";
6628
6628
  } catch {
@@ -6630,10 +6630,10 @@ async function Ie(e) {
6630
6630
  }
6631
6631
  }
6632
6632
  async function __(e) {
6633
- await Ie(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)", (a) => a.notNull()).execute(), await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute()) : (await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute());
6633
+ await Pe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)", (a) => a.notNull()).execute(), await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute()) : (await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute());
6634
6634
  }
6635
6635
  async function m_(e) {
6636
- await Ie(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)").execute()) : await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(21)").execute();
6636
+ await Pe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)").execute()) : await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(21)").execute();
6637
6637
  }
6638
6638
  const h_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6639
6639
  __proto__: null,
@@ -6694,21 +6694,21 @@ async function O_(e) {
6694
6694
  async function k_(e) {
6695
6695
  await e.schema.dropIndex("authentication_methods_credential_id_idx").execute(), await e.schema.alterTable("authentication_methods").dropColumn("friendly_name").execute(), await e.schema.alterTable("authentication_methods").dropColumn("transports").execute(), await e.schema.alterTable("authentication_methods").dropColumn("credential_backed_up").execute(), await e.schema.alterTable("authentication_methods").dropColumn("sign_count").execute(), await e.schema.alterTable("authentication_methods").dropColumn("public_key").execute(), await e.schema.alterTable("authentication_methods").dropColumn("credential_id").execute(), await e.schema.alterTable("authentication_methods").renameTo("mfa_enrollments").execute();
6696
6696
  }
6697
- const $_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6697
+ const E_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6698
6698
  __proto__: null,
6699
6699
  down: k_,
6700
6700
  up: O_
6701
6701
  }, Symbol.toStringTag, { value: "Module" }));
6702
- async function E_(e) {
6702
+ async function $_(e) {
6703
6703
  await e.schema.createTable("outbox_events").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("event_type", "varchar(255)", (t) => t.notNull()).addColumn("log_type", "varchar(64)", (t) => t.notNull()).addColumn("aggregate_type", "varchar(64)", (t) => t.notNull()).addColumn("aggregate_id", "varchar(255)", (t) => t.notNull()).addColumn("payload", "text", (t) => t.notNull()).addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("processed_at", "varchar(35)").addColumn("retry_count", "integer", (t) => t.notNull().defaultTo(0)).addColumn("next_retry_at", "varchar(35)").addColumn("error", "text").execute(), await e.schema.createIndex("idx_outbox_unprocessed").on("outbox_events").columns(["processed_at", "created_at"]).execute(), await e.schema.createIndex("idx_outbox_tenant_type").on("outbox_events").columns(["tenant_id", "event_type", "created_at"]).execute();
6704
6704
  }
6705
- async function I_(e) {
6705
+ async function P_(e) {
6706
6706
  await e.schema.dropTable("outbox_events").execute();
6707
6707
  }
6708
- const P_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6708
+ const I_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6709
6709
  __proto__: null,
6710
- down: I_,
6711
- up: E_
6710
+ down: P_,
6711
+ up: $_
6712
6712
  }, Symbol.toStringTag, { value: "Module" }));
6713
6713
  async function z_(e) {
6714
6714
  await e.schema.alterTable("outbox_events").addColumn("claimed_by", "varchar(64)").execute(), await e.schema.alterTable("outbox_events").addColumn("claim_expires_at", "varchar(35)").execute();
@@ -6721,7 +6721,7 @@ const A_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6721
6721
  down: D_,
6722
6722
  up: z_
6723
6723
  }, Symbol.toStringTag, { value: "Module" }));
6724
- async function j_(e) {
6724
+ async function F_(e) {
6725
6725
  await e.schema.createIndex("idx_outbox_claim").on("outbox_events").columns([
6726
6726
  "processed_at",
6727
6727
  "claim_expires_at",
@@ -6729,13 +6729,13 @@ async function j_(e) {
6729
6729
  "created_at"
6730
6730
  ]).execute();
6731
6731
  }
6732
- async function F_(e) {
6732
+ async function j_(e) {
6733
6733
  await e.schema.dropIndex("idx_outbox_claim").on("outbox_events").execute();
6734
6734
  }
6735
6735
  const R_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6736
6736
  __proto__: null,
6737
- down: F_,
6738
- up: j_
6737
+ down: j_,
6738
+ up: F_
6739
6739
  }, Symbol.toStringTag, { value: "Module" }));
6740
6740
  async function M_(e) {
6741
6741
  await e.schema.createTable("hook_code").addColumn("id", "varchar(21)", (t) => t.primaryKey()).addColumn("tenant_id", "varchar(191)", (t) => t.notNull()).addColumn("code", "text", (t) => t.notNull()).addColumn("secrets", "text").addColumn("created_at_ts", "bigint", (t) => t.notNull()).addColumn("updated_at_ts", "bigint", (t) => t.notNull()).execute(), await e.schema.createIndex("idx_hook_code_tenant").on("hook_code").columns(["tenant_id"]).execute(), await e.schema.alterTable("hooks").addColumn("code_id", "varchar(21)").execute();
@@ -6805,7 +6805,7 @@ const am = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6805
6805
  down: tm,
6806
6806
  up: em
6807
6807
  }, Symbol.toStringTag, { value: "Module" }));
6808
- async function Pe(e) {
6808
+ async function Ie(e) {
6809
6809
  try {
6810
6810
  return await h`SELECT VERSION()`.execute(e), "mysql";
6811
6811
  } catch {
@@ -6813,9 +6813,9 @@ async function Pe(e) {
6813
6813
  }
6814
6814
  }
6815
6815
  async function nm(e) {
6816
- const t = await Pe(e);
6816
+ const t = await Ie(e);
6817
6817
  try {
6818
- await e.schema.alterTable("login_sessions").addColumn("auth_params", "text").execute(), y(" Added column auth_params to login_sessions");
6818
+ await e.schema.alterTable("login_sessions").addColumn("auth_params", "text").execute(), w(" Added column auth_params to login_sessions");
6819
6819
  } catch (a) {
6820
6820
  z(
6821
6821
  ` Warning: Could not add auth_params column: ${a instanceof Error ? a.message : String(a)}`
@@ -6823,7 +6823,7 @@ async function nm(e) {
6823
6823
  }
6824
6824
  if (t === "mysql")
6825
6825
  try {
6826
- await e.schema.alterTable("login_sessions").modifyColumn("authorization_url", "text").execute(), y(" Widened authorization_url to text");
6826
+ await e.schema.alterTable("login_sessions").modifyColumn("authorization_url", "text").execute(), w(" Widened authorization_url to text");
6827
6827
  } catch (a) {
6828
6828
  z(
6829
6829
  ` Warning: Could not widen authorization_url: ${a instanceof Error ? a.message : String(a)}`
@@ -6831,7 +6831,7 @@ async function nm(e) {
6831
6831
  }
6832
6832
  }
6833
6833
  async function om(e) {
6834
- const t = await Pe(e);
6834
+ const t = await Ie(e);
6835
6835
  try {
6836
6836
  await e.schema.alterTable("login_sessions").dropColumn("auth_params").execute();
6837
6837
  } catch (a) {
@@ -6891,11 +6891,11 @@ async function im(e) {
6891
6891
  })
6892
6892
  );
6893
6893
  }
6894
- if (t += a.length, y(
6894
+ if (t += a.length, w(
6895
6895
  ` Backfilled auth_params for ${t} login_sessions row(s)...`
6896
6896
  ), a.length < ue) break;
6897
6897
  }
6898
- y(
6898
+ w(
6899
6899
  t === 0 ? " No login_sessions rows to backfill (auth_params all set)" : ` Backfilled auth_params for ${t} login_sessions row(s) total`
6900
6900
  );
6901
6901
  } catch (t) {
@@ -6910,6 +6910,90 @@ const lm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6910
6910
  __proto__: null,
6911
6911
  down: cm,
6912
6912
  up: im
6913
+ }, Symbol.toStringTag, { value: "Module" }));
6914
+ async function dm(e) {
6915
+ try {
6916
+ return await h`SELECT @@version_comment`.execute(e), "mysql";
6917
+ } catch {
6918
+ return "sqlite";
6919
+ }
6920
+ }
6921
+ async function um(e) {
6922
+ await dm(e) === "mysql" ? await _m(e) : await mm(e);
6923
+ }
6924
+ async function _m(e) {
6925
+ try {
6926
+ await h`ALTER TABLE login_sessions DROP FOREIGN KEY login_sessions_client_fk`.execute(
6927
+ e
6928
+ ), w(" Dropped FK login_sessions_client_fk");
6929
+ } catch (t) {
6930
+ const a = t instanceof Error ? t.message : String(t);
6931
+ a.includes("1091") || a.includes("doesn't exist") ? w(" FK login_sessions_client_fk already absent, skipping") : z(
6932
+ ` Warning: could not drop login_sessions_client_fk: ${a}`
6933
+ );
6934
+ }
6935
+ try {
6936
+ await h`ALTER TABLE login_sessions MODIFY authParams_client_id varchar(191) NULL`.execute(
6937
+ e
6938
+ ), w(" Relaxed NOT NULL on login_sessions.authParams_client_id");
6939
+ } catch (t) {
6940
+ const a = t instanceof Error ? t.message : String(t);
6941
+ throw z(
6942
+ ` Failed to relax authParams_client_id NOT NULL: ${a}`
6943
+ ), t;
6944
+ }
6945
+ }
6946
+ async function mm(e) {
6947
+ await e.transaction().execute(async (t) => {
6948
+ await t.schema.createTable("login_sessions_new").addColumn("id", "varchar(26)", (a) => a.notNull()).addColumn(
6949
+ "tenant_id",
6950
+ "varchar(255)",
6951
+ (a) => a.references("tenants.id").onDelete("cascade").notNull()
6952
+ ).addColumn("session_id", "varchar(26)").addColumn("csrf_token", "varchar(26)", (a) => a.notNull()).addColumn("authParams_client_id", "varchar(191)").addColumn("authParams_vendor_id", "varchar(255)").addColumn("authParams_username", "varchar(255)").addColumn("authParams_response_type", "varchar(255)").addColumn("authParams_response_mode", "varchar(255)").addColumn("authParams_audience", "varchar(255)").addColumn("authParams_scope", "text").addColumn("authParams_state", "text").addColumn("authParams_nonce", "varchar(255)").addColumn("authParams_code_challenge_method", "varchar(255)").addColumn("authParams_code_challenge", "varchar(255)").addColumn("authParams_redirect_uri", "text").addColumn("authParams_organization", "varchar(255)").addColumn("authParams_prompt", "varchar(32)").addColumn("authParams_act_as", "varchar(256)").addColumn("authParams_ui_locales", "varchar(32)").addColumn("authParams_max_age", "integer").addColumn("authParams_acr_values", "varchar(255)").addColumn("authorization_url", "text").addColumn("ip", "varchar(39)").addColumn("useragent", "text").addColumn("auth0Client", "varchar(255)").addColumn("state", "varchar(50)", (a) => a.defaultTo("pending")).addColumn("state_data", "text").addColumn("failure_reason", "text").addColumn("user_id", "varchar(255)").addColumn("created_at_ts", "bigint").addColumn("updated_at_ts", "bigint").addColumn("expires_at_ts", "bigint").addColumn("auth_connection", "varchar(255)").addColumn("auth_strategy_strategy", "varchar(64)").addColumn("auth_strategy_strategy_type", "varchar(64)").addColumn("authenticated_at", "varchar(35)").addColumn("auth_params", "text").addPrimaryKeyConstraint("login_sessions_pk", ["tenant_id", "id"]).addForeignKeyConstraint(
6953
+ "login_sessions_session_fk",
6954
+ ["tenant_id", "session_id"],
6955
+ "sessions",
6956
+ ["tenant_id", "id"],
6957
+ (a) => a.onDelete("cascade")
6958
+ ).execute(), await h`INSERT INTO login_sessions_new (
6959
+ id, tenant_id, session_id, csrf_token,
6960
+ authParams_client_id, authParams_vendor_id, authParams_username,
6961
+ authParams_response_type, authParams_response_mode, authParams_audience,
6962
+ authParams_scope, authParams_state, authParams_nonce,
6963
+ authParams_code_challenge_method, authParams_code_challenge,
6964
+ authParams_redirect_uri, authParams_organization, authParams_prompt,
6965
+ authParams_act_as, authParams_ui_locales, authParams_max_age,
6966
+ authParams_acr_values, authorization_url,
6967
+ ip, useragent, auth0Client, state, state_data, failure_reason,
6968
+ user_id, created_at_ts, updated_at_ts, expires_at_ts,
6969
+ auth_connection, auth_strategy_strategy, auth_strategy_strategy_type,
6970
+ authenticated_at, auth_params
6971
+ ) SELECT
6972
+ id, tenant_id, session_id, csrf_token,
6973
+ authParams_client_id, authParams_vendor_id, authParams_username,
6974
+ authParams_response_type, authParams_response_mode, authParams_audience,
6975
+ authParams_scope, authParams_state, authParams_nonce,
6976
+ authParams_code_challenge_method, authParams_code_challenge,
6977
+ authParams_redirect_uri, authParams_organization, authParams_prompt,
6978
+ authParams_act_as, authParams_ui_locales, authParams_max_age,
6979
+ authParams_acr_values, authorization_url,
6980
+ ip, useragent, auth0Client, state, state_data, failure_reason,
6981
+ user_id, created_at_ts, updated_at_ts, expires_at_ts,
6982
+ auth_connection, auth_strategy_strategy, auth_strategy_strategy_type,
6983
+ authenticated_at, auth_params
6984
+ FROM login_sessions`.execute(t), await h`DROP TABLE login_sessions`.execute(t), await h`ALTER TABLE login_sessions_new RENAME TO login_sessions`.execute(
6985
+ t
6986
+ ), await t.schema.createIndex("login_sessions_id_index").on("login_sessions").column("id").execute(), await t.schema.createIndex("idx_login_sessions_session_id").on("login_sessions").column("session_id").execute(), await t.schema.createIndex("login_sessions_tenant_user_idx").on("login_sessions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("login_sessions_state_idx").on("login_sessions").column("state").execute(), await t.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
6987
+ }), w(
6988
+ " Rebuilt login_sessions with FK dropped and authParams_client_id nullable"
6989
+ );
6990
+ }
6991
+ async function hm(e) {
6992
+ }
6993
+ const pm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6994
+ __proto__: null,
6995
+ down: hm,
6996
+ up: um
6913
6997
  }, Symbol.toStringTag, { value: "Module" })), me = [
6914
6998
  "authParams_client_id",
6915
6999
  "authParams_vendor_id",
@@ -6930,46 +7014,36 @@ const lm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6930
7014
  "authParams_max_age",
6931
7015
  "authParams_acr_values"
6932
7016
  ];
6933
- async function dm(e) {
7017
+ async function fm(e) {
6934
7018
  try {
6935
7019
  return await h`SELECT @@version_comment`.execute(e), "mysql";
6936
7020
  } catch {
6937
7021
  return "sqlite";
6938
7022
  }
6939
7023
  }
6940
- async function um(e, t, a) {
7024
+ async function gm(e, t, a) {
6941
7025
  try {
6942
7026
  await e.schema.alterTable(t).dropColumn(a).execute();
6943
7027
  } catch (n) {
6944
7028
  const o = n instanceof Error ? n.message : String(n);
6945
7029
  if (o.includes("1091") || o.includes("no such column")) {
6946
- y(` ${t}.${a} already absent, skipping`);
7030
+ w(` ${t}.${a} already absent, skipping`);
6947
7031
  return;
6948
7032
  }
6949
7033
  throw n;
6950
7034
  }
6951
7035
  }
6952
- async function _m(e) {
6953
- await dm(e) === "mysql" ? await mm(e) : await hm(e);
7036
+ async function wm(e) {
7037
+ await fm(e) === "mysql" ? await ym(e) : await vm(e);
6954
7038
  }
6955
- async function mm(e) {
6956
- try {
6957
- await h`ALTER TABLE login_sessions DROP FOREIGN KEY login_sessions_client_fk`.execute(
6958
- e
6959
- ), y(" Dropped FK login_sessions_client_fk");
6960
- } catch (t) {
6961
- const a = t instanceof Error ? t.message : String(t);
6962
- a.includes("1091") || a.includes("doesn't exist") ? y(" FK login_sessions_client_fk already absent, skipping") : z(
6963
- ` Warning: could not drop login_sessions_client_fk: ${a}`
6964
- );
6965
- }
7039
+ async function ym(e) {
6966
7040
  for (const t of me)
6967
- await um(e, "login_sessions", t);
6968
- y(
7041
+ await gm(e, "login_sessions", t);
7042
+ w(
6969
7043
  ` Dropped ${me.length} hoisted authParams_* columns from login_sessions`
6970
7044
  );
6971
7045
  }
6972
- async function hm(e) {
7046
+ async function vm(e) {
6973
7047
  await e.transaction().execute(async (t) => {
6974
7048
  await t.schema.createTable("login_sessions_new").addColumn("id", "varchar(26)", (a) => a.notNull()).addColumn(
6975
7049
  "tenant_id",
@@ -6995,17 +7069,17 @@ async function hm(e) {
6995
7069
  authenticated_at, auth_params
6996
7070
  FROM login_sessions`.execute(t), await h`DROP TABLE login_sessions`.execute(t), await h`ALTER TABLE login_sessions_new RENAME TO login_sessions`.execute(
6997
7071
  t
6998
- ), await t.schema.createIndex("login_sessions_id_index").on("login_sessions").column("id").execute(), await t.schema.createIndex("login_sessions_tenant_user_idx").on("login_sessions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("login_sessions_state_idx").on("login_sessions").column("state").execute(), await t.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
6999
- }), y(
7072
+ ), await t.schema.createIndex("login_sessions_id_index").on("login_sessions").column("id").execute(), await t.schema.createIndex("idx_login_sessions_session_id").on("login_sessions").column("session_id").execute(), await t.schema.createIndex("login_sessions_tenant_user_idx").on("login_sessions").columns(["tenant_id", "user_id"]).execute(), await t.schema.createIndex("login_sessions_state_idx").on("login_sessions").column("state").execute(), await t.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
7073
+ }), w(
7000
7074
  " Recreated login_sessions without hoisted authParams_* columns"
7001
7075
  );
7002
7076
  }
7003
- async function pm(e) {
7077
+ async function Cm(e) {
7004
7078
  }
7005
- const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7079
+ const xm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7006
7080
  __proto__: null,
7007
- down: pm,
7008
- up: _m
7081
+ down: Cm,
7082
+ up: wm
7009
7083
  }, Symbol.toStringTag, { value: "Module" })), ze = {
7010
7084
  m1_init: Yo,
7011
7085
  m2_magicLink: Go,
@@ -7019,8 +7093,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7019
7093
  n01_codesTable: vr,
7020
7094
  n11_universalLoginSession: Tr,
7021
7095
  n12_userFields: Sr,
7022
- n13_userEmailIndex: $r,
7023
- n14_profileDataField: Pr,
7096
+ n13_userEmailIndex: Er,
7097
+ n14_profileDataField: Ir,
7024
7098
  n15_userEmailIndex: Ar,
7025
7099
  n16_userLocale: Rr,
7026
7100
  n17_signingKeys: Lr,
@@ -7037,8 +7111,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7037
7111
  n28_usersEmailConstrain: vs,
7038
7112
  n29_increaseOtpStateLength: Ts,
7039
7113
  n30_increaseTicketStateLength: Ss,
7040
- n31_branding: $s,
7041
- n32_indexesAndNotNull: Ps,
7114
+ n31_branding: Es,
7115
+ n32_indexesAndNotNull: Is,
7042
7116
  n33_vendorIdInUniversalLoginSession: As,
7043
7117
  n34_auth0ClientInUniversalLoginSession: Rs,
7044
7118
  n35_increaseUniversalSessionStateLength: Ls,
@@ -7055,8 +7129,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7055
7129
  n46_loginAuth0Client: vi,
7056
7130
  n47_loginAuth0Client: Ti,
7057
7131
  n48_saml: Si,
7058
- n49_removeFields: $i,
7059
- n50_authParamsNonce: Pi,
7132
+ n49_removeFields: Ei,
7133
+ n50_authParamsNonce: Ii,
7060
7134
  n51_connectionid: Ai,
7061
7135
  n52_cert: Ri,
7062
7136
  n53_codes_primary_key: Li,
@@ -7073,8 +7147,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7073
7147
  n64_act_as: vc,
7074
7148
  n65_code_verifier: Tc,
7075
7149
  n66_email_providers: Sc,
7076
- n67_drop_tickets: $c,
7077
- n68_login_useragents: Pc,
7150
+ n67_drop_tickets: Ec,
7151
+ n68_login_useragents: Ic,
7078
7152
  n70_refresh_tokens: Ac,
7079
7153
  n71_session_new_fields: Rc,
7080
7154
  n72_session_primary_key: Lc,
@@ -7091,8 +7165,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7091
7165
  n83_addFormsIdToHooks: vl,
7092
7166
  n84_login_completed: Tl,
7093
7167
  n85_add_login_session_id_to_sessions: Sl,
7094
- n86_index_sessions_login_session_id: $l,
7095
- n87_code_challenge: Pl,
7168
+ n86_index_sessions_login_session_id: El,
7169
+ n87_code_challenge: Il,
7096
7170
  n88_add_redirect_uri_to_codes: Al,
7097
7171
  n89_add_nonce_and_state_to_codes: Rl,
7098
7172
  n90_themes: Ll,
@@ -7108,9 +7182,9 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7108
7182
  o001_client_grants: Cd,
7109
7183
  o002_drop_applications: Nd,
7110
7184
  o003_phone_number_index: Od,
7111
- o004_login_sessions_id_index: Ed,
7185
+ o004_login_sessions_id_index: $d,
7112
7186
  o005_connections_tenant_index: zd,
7113
- o006_remove_redundant_user_organizations_tenant_index: jd,
7187
+ o006_remove_redundant_user_organizations_tenant_index: Fd,
7114
7188
  o007_tenant_settings: Md,
7115
7189
  o008_merge_tenant_settings_into_tenants: qd,
7116
7190
  o009_create_invites_table: Ud,
@@ -7126,9 +7200,9 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7126
7200
  o019_roles_resource_servers_metadata: Cu,
7127
7201
  o020_session_add_timestamp_columns: bu,
7128
7202
  o021_session_cleanup_and_ulid: ku,
7129
- o022_oidc_profile_claims: Iu,
7203
+ o022_oidc_profile_claims: Pu,
7130
7204
  o023_preferred_username: Du,
7131
- o024_user_address: Fu,
7205
+ o024_user_address: ju,
7132
7206
  o025_authparams_max_age: Ju,
7133
7207
  o026_auth0_conformant: Ku,
7134
7208
  o027_universal_login_templates: Qu,
@@ -7143,8 +7217,8 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7143
7217
  o036_add_connection_to_login_sessions: v_,
7144
7218
  o037_mfa_enrollments: T_,
7145
7219
  o038_add_otp_to_codes: S_,
7146
- o039_rename_mfa_enrollments_to_authentication_methods: $_,
7147
- o040_create_outbox_events: P_,
7220
+ o039_rename_mfa_enrollments_to_authentication_methods: E_,
7221
+ o040_create_outbox_events: I_,
7148
7222
  o041_add_outbox_claim_columns: A_,
7149
7223
  o042_add_outbox_claim_index: R_,
7150
7224
  o043_add_code_hooks: L_,
@@ -7155,9 +7229,10 @@ const fm = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7155
7229
  o048_add_auth_strategy_to_login_sessions: am,
7156
7230
  o049_login_sessions_auth_params: rm,
7157
7231
  o050_login_sessions_auth_params_backfill: lm,
7158
- o051_drop_login_sessions_hoisted_authparams: fm
7232
+ o051_relax_login_sessions_authparams: pm,
7233
+ o052_drop_login_sessions_hoisted_authparams: xm
7159
7234
  };
7160
- async function Tm(e, t = !1) {
7235
+ async function Em(e, t = !1) {
7161
7236
  Oe(t), t && console.log("migrating...");
7162
7237
  const a = new be(ze), n = new pe({
7163
7238
  db: e,
@@ -7170,7 +7245,7 @@ async function Tm(e, t = !1) {
7170
7245
  }), o)
7171
7246
  throw console.error("failed to migrate"), console.error(o), o;
7172
7247
  }
7173
- async function Nm(e, t = !1) {
7248
+ async function $m(e, t = !1) {
7174
7249
  Oe(t), t && console.log("migrating...");
7175
7250
  const a = new be(ze), n = new pe({
7176
7251
  db: e,
@@ -7183,7 +7258,7 @@ async function Nm(e, t = !1) {
7183
7258
  }), o)
7184
7259
  throw console.error("failed to migrate"), console.error(o), o;
7185
7260
  }
7186
- function gm(e, t = { useTransactions: !0 }) {
7261
+ function Tm(e, t = { useTransactions: !0 }) {
7187
7262
  const a = {
7188
7263
  actions: rt(e),
7189
7264
  branding: Aa(e),
@@ -7193,15 +7268,15 @@ function gm(e, t = { useTransactions: !0 }) {
7193
7268
  codes: Ht(e),
7194
7269
  connections: aa(e),
7195
7270
  emailProviders: wn(e),
7196
- customDomains: Pa(e),
7271
+ customDomains: Ia(e),
7197
7272
  flows: yt(e),
7198
- forms: Pn(e),
7273
+ forms: In(e),
7199
7274
  hookCode: Ga(e),
7200
7275
  hooks: Ua(e),
7201
7276
  invites: No(e),
7202
7277
  keys: ba(e),
7203
7278
  loginSessions: dn(e),
7204
- logs: It(e),
7279
+ logs: Pt(e),
7205
7280
  authenticationMethods: zo(e),
7206
7281
  passwords: qt(e),
7207
7282
  promptSettings: mn(e),
@@ -7211,7 +7286,7 @@ function gm(e, t = { useTransactions: !0 }) {
7211
7286
  userPermissions: Zn(e),
7212
7287
  userRoles: oo(e),
7213
7288
  roles: Bn(e),
7214
- sessions: Ft(e),
7289
+ sessions: jt(e),
7215
7290
  sessionCleanup: Sn(e),
7216
7291
  tenants: St(e),
7217
7292
  themes: tn(e),
@@ -7224,7 +7299,7 @@ function gm(e, t = { useTransactions: !0 }) {
7224
7299
  outbox: Bo(e),
7225
7300
  async transaction(n) {
7226
7301
  return t.useTransactions === !1 ? n(a) : e.transaction().execute(async (o) => {
7227
- const r = gm(o, {
7302
+ const r = Tm(o, {
7228
7303
  ...t,
7229
7304
  useTransactions: !1
7230
7305
  });
@@ -7235,7 +7310,7 @@ function gm(e, t = { useTransactions: !0 }) {
7235
7310
  return a;
7236
7311
  }
7237
7312
  export {
7238
- gm as default,
7239
- Nm as migrateDown,
7240
- Tm as migrateToLatest
7313
+ Tm as default,
7314
+ $m as migrateDown,
7315
+ Em as migrateToLatest
7241
7316
  };