@authhero/kysely-adapter 10.122.0 → 10.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var $e = Object.defineProperty;
2
2
  var Ee = (e, t, a) => t in e ? $e(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var K = (e, t, a) => Ee(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { customAlphabet as Ie, nanoid as $ } from "nanoid";
4
+ import { customAlphabet as Ie, nanoid as E } from "nanoid";
5
5
  import { parseUserId as ze, flowSchema as B, codeSchema as Pe, loginSessionSchema as De, LoginSessionState as le, promptSettingSchema as Ae, formSchema as q, resourceServerSchema as je } from "@authhero/adapter-interfaces";
6
6
  import "@hono/zod-openapi";
7
7
  import { sql as h, Migrator as de } from "kysely";
@@ -87,7 +87,7 @@ function ue(e) {
87
87
  function D(e, t = (/* @__PURE__ */ new Date(0)).toISOString()) {
88
88
  return ue(e) ?? t;
89
89
  }
90
- function C(e) {
90
+ function x(e) {
91
91
  if (!e || e === "")
92
92
  return null;
93
93
  const t = new Date(e);
@@ -130,14 +130,14 @@ function Ye(e) {
130
130
  supported_triggers: d,
131
131
  tenant_id: c,
132
132
  ...l
133
- } = n, _ = z({ created_at_ts: o, updated_at_ts: r }, [
133
+ } = n, m = z({ created_at_ts: o, updated_at_ts: r }, [
134
134
  "created_at_ts",
135
135
  "updated_at_ts"
136
136
  ]);
137
137
  return {
138
138
  ...l,
139
139
  tenant_id: t,
140
- ..._,
140
+ ...m,
141
141
  runtime: l.runtime ?? void 0,
142
142
  status: l.status || "built",
143
143
  deployed_at: s ? new Date(Number(s)).toISOString() : void 0,
@@ -149,17 +149,17 @@ function Ye(e) {
149
149
  };
150
150
  };
151
151
  }
152
- function O(e, t, a, n) {
152
+ function k(e, t, a, n) {
153
153
  const o = a.split(/ OR /i);
154
154
  if (o.length > 1)
155
155
  return t.where((d) => {
156
156
  const c = o.map((l) => {
157
- const _ = l.trim().match(/^([^:]+):(.+)$/);
158
- if (_) {
159
- const [, m, p] = _;
160
- if (!m || !p) return null;
157
+ const m = l.trim().match(/^([^:]+):(.+)$/);
158
+ if (m) {
159
+ const [, _, p] = m;
160
+ if (!_ || !p) return null;
161
161
  const f = p.replace(/^"(.*)"$/, "$1");
162
- return d(m.trim(), "=", f.trim());
162
+ return d(_.trim(), "=", f.trim());
163
163
  }
164
164
  return null;
165
165
  }).filter(Boolean);
@@ -172,23 +172,23 @@ function O(e, t, a, n) {
172
172
  c === '"' ? (i = !i, s += c) : c === " " && !i ? s.trim() && (r.push(s.trim()), s = "") : s += c;
173
173
  }
174
174
  return s.trim() && r.push(s.trim()), r.map((d) => d.replace(/^([^:]+)=/g, "$1:")).map((d) => {
175
- let c = d.startsWith("-"), l = null, _ = "", m = !1, p;
175
+ let c = d.startsWith("-"), l = null, m = "", _ = !1, p;
176
176
  if (d.startsWith("-_exists_:"))
177
- l = d.substring(10), m = !0, c = !0;
177
+ l = d.substring(10), _ = !0, c = !0;
178
178
  else if (d.startsWith("_exists_:"))
179
- l = d.substring(9), m = !0, c = !1;
179
+ l = d.substring(9), _ = !0, c = !1;
180
180
  else if (d.includes(":")) {
181
181
  const f = c ? d.substring(1) : d, g = f.indexOf(":");
182
- l = f.substring(0, g), _ = f.substring(g + 1), m = !1, _.startsWith(">=") ? (p = ">=", _ = _.substring(2)) : _.startsWith(">") ? (p = ">", _ = _.substring(1)) : _.startsWith("<=") ? (p = "<=", _ = _.substring(2)) : _.startsWith("<") ? (p = "<", _ = _.substring(1)) : p = "=", _.startsWith('"') && _.endsWith('"') && _.length > 1 && (_ = _.slice(1, -1));
182
+ l = f.substring(0, g), m = f.substring(g + 1), _ = !1, m.startsWith(">=") ? (p = ">=", m = m.substring(2)) : m.startsWith(">") ? (p = ">", m = m.substring(1)) : m.startsWith("<=") ? (p = "<=", m = m.substring(2)) : m.startsWith("<") ? (p = "<", m = m.substring(1)) : p = "=", m.startsWith('"') && m.endsWith('"') && m.length > 1 && (m = m.slice(1, -1));
183
183
  } else
184
- l = null, _ = d, m = !1;
185
- return { key: l, value: _, isNegation: c, isExistsQuery: m, operator: p };
186
- }).forEach(({ key: d, value: c, isNegation: l, isExistsQuery: _, operator: m }) => {
184
+ l = null, m = d, _ = !1;
185
+ return { key: l, value: m, isNegation: c, isExistsQuery: _, operator: p };
186
+ }).forEach(({ key: d, value: c, isNegation: l, isExistsQuery: m, operator: _ }) => {
187
187
  if (d)
188
- if (_)
188
+ if (m)
189
189
  l ? t = t.where(d, "is", null) : t = t.where(d, "is not", null);
190
190
  else if (l)
191
- switch (m) {
191
+ switch (_) {
192
192
  case ">":
193
193
  t = t.where(d, "<=", c);
194
194
  break;
@@ -205,7 +205,7 @@ function O(e, t, a, n) {
205
205
  t = t.where(d, "!=", c);
206
206
  }
207
207
  else
208
- t = t.where(d, m, c);
208
+ t = t.where(d, _, c);
209
209
  else if (c) {
210
210
  const { ref: p } = e.dynamic, f = c.includes("|") ? [...n, "user_id"] : n;
211
211
  t = t.where(
@@ -218,7 +218,7 @@ function O(e, t, a, n) {
218
218
  }
219
219
  }), t;
220
220
  }
221
- function k(e) {
221
+ function $(e) {
222
222
  return typeof e == "string" ? parseInt(e, 10) : typeof e == "bigint" ? Number(e) : e;
223
223
  }
224
224
  function Y(e) {
@@ -233,34 +233,34 @@ function He(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 = O(e, i, s, ["name"]));
237
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
236
+ s && (i = k(e, i, s, ["name"]));
237
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
238
238
  const {
239
- created_at_ts: m,
239
+ created_at_ts: _,
240
240
  updated_at_ts: p,
241
241
  deployed_at_ts: f,
242
242
  secrets: g,
243
243
  dependencies: y,
244
- supported_triggers: x,
244
+ supported_triggers: T,
245
245
  tenant_id: v,
246
- ...T
247
- } = _, E = z({ created_at_ts: m, updated_at_ts: p }, [
246
+ ...N
247
+ } = m, I = z({ created_at_ts: _, updated_at_ts: p }, [
248
248
  "created_at_ts",
249
249
  "updated_at_ts"
250
250
  ]);
251
251
  return {
252
- ...T,
252
+ ...N,
253
253
  tenant_id: t,
254
- ...E,
255
- runtime: T.runtime ?? void 0,
256
- status: T.status || "built",
254
+ ...I,
255
+ runtime: N.runtime ?? void 0,
256
+ status: N.status || "built",
257
257
  deployed_at: f ? new Date(Number(f)).toISOString() : void 0,
258
258
  secrets: Y(g),
259
259
  dependencies: Y(
260
260
  y
261
261
  ),
262
262
  supported_triggers: Y(
263
- x
263
+ T
264
264
  )
265
265
  };
266
266
  });
@@ -271,12 +271,12 @@ function He(e) {
271
271
  limit: 0,
272
272
  length: 0
273
273
  };
274
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
274
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
275
275
  return {
276
276
  actions: c,
277
277
  start: n * o,
278
278
  limit: o,
279
- length: k(l)
279
+ length: $(l)
280
280
  };
281
281
  };
282
282
  }
@@ -345,7 +345,7 @@ function Xe(e) {
345
345
  const u = async (d) => {
346
346
  if (await d.insertInto("users").values(i).execute(), r && i.user_id) {
347
347
  const c = {
348
- id: $(),
348
+ id: E(),
349
349
  user_id: i.user_id,
350
350
  password: r.hash,
351
351
  algorithm: r.algorithm,
@@ -452,12 +452,12 @@ function tt(e) {
452
452
  return async (t, a = {}) => {
453
453
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
454
454
  let u = e.selectFrom("users").where("users.tenant_id", "=", t);
455
- if (i && (u = O(e, u, i, ["email", "name", "phone_number"])), s && s.sort_by) {
455
+ if (i && (u = k(e, u, i, ["email", "name", "phone_number"])), s && s.sort_by) {
456
456
  const { ref: f } = e.dynamic;
457
457
  u = u.orderBy(f(s.sort_by), s.sort_order);
458
458
  }
459
- const c = await u.offset(n * o).limit(o).selectAll().execute(), l = c.map((f) => f.user_id), _ = l.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", l).orderBy("created_at", "asc").execute() : [], m = c.map((f) => {
460
- const g = _.filter(
459
+ const c = await u.offset(n * o).limit(o).selectAll().execute(), l = c.map((f) => f.user_id), m = l.length ? await e.selectFrom("users").selectAll().where("users.tenant_id", "=", t).where("users.linked_to", "in", l).orderBy("created_at", "asc").execute() : [], _ = c.map((f) => {
460
+ const g = m.filter(
461
461
  (y) => y.linked_to === f.user_id
462
462
  );
463
463
  return w({
@@ -476,17 +476,17 @@ function tt(e) {
476
476
  });
477
477
  if (!r)
478
478
  return {
479
- users: m,
479
+ users: _,
480
480
  start: 0,
481
481
  limit: 0,
482
482
  length: 0
483
483
  };
484
484
  const { count: p } = await u.select((f) => f.fn.countAll().as("count")).executeTakeFirstOrThrow();
485
485
  return {
486
- users: m,
486
+ users: _,
487
487
  start: n * o,
488
488
  limit: o,
489
- length: k(p)
489
+ length: $(p)
490
490
  };
491
491
  };
492
492
  }
@@ -563,7 +563,7 @@ function rt(e) {
563
563
  function st(e) {
564
564
  return async (t, a) => {
565
565
  const n = (/* @__PURE__ */ new Date()).toISOString(), o = B.parse({
566
- id: `af_${$()}`,
566
+ id: `af_${E()}`,
567
567
  ...a,
568
568
  actions: a.actions || [],
569
569
  created_at: n,
@@ -609,13 +609,13 @@ function ct(e) {
609
609
  return async (t, a = {}) => {
610
610
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
611
611
  let i = e.selectFrom("flows").where("tenant_id", "=", t);
612
- s && (i = O(e, i, s, []));
613
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
614
- const m = {
615
- ..._,
616
- actions: A(_.actions, [])
612
+ s && (i = k(e, i, s, []));
613
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
614
+ const _ = {
615
+ ...m,
616
+ actions: A(m.actions, [])
617
617
  };
618
- return B.parse(w(m));
618
+ return B.parse(w(_));
619
619
  });
620
620
  if (!r)
621
621
  return {
@@ -624,12 +624,12 @@ function ct(e) {
624
624
  limit: 0,
625
625
  length: 0
626
626
  };
627
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
627
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
628
628
  return {
629
629
  flows: c,
630
630
  start: n * o,
631
631
  limit: o,
632
- length: k(l)
632
+ length: $(l)
633
633
  };
634
634
  };
635
635
  }
@@ -715,7 +715,7 @@ function mt(e) {
715
715
  return async (t) => {
716
716
  var o, r;
717
717
  const a = {
718
- id: t.id || $(),
718
+ id: t.id || E(),
719
719
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
720
720
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
721
721
  ...t
@@ -747,21 +747,21 @@ function pt(e) {
747
747
  q: i
748
748
  } = t || {};
749
749
  if (s && s.sort_by) {
750
- const { ref: m } = e.dynamic;
751
- a = a.orderBy(m(s.sort_by), s.sort_order);
750
+ const { ref: _ } = e.dynamic;
751
+ a = a.orderBy(_(s.sort_by), s.sort_order);
752
752
  }
753
- i && (a = O(e, a, i, ["friendly_name"]));
753
+ i && (a = k(e, a, i, ["friendly_name"]));
754
754
  const c = (await a.offset(n * o).limit(o).selectAll().execute()).map(pe);
755
755
  if (!r)
756
756
  return {
757
757
  tenants: c
758
758
  };
759
- const { count: l } = await a.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = k(l);
759
+ const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = $(l);
760
760
  return {
761
761
  tenants: c,
762
762
  start: n * o,
763
763
  limit: o,
764
- length: _
764
+ length: m
765
765
  };
766
766
  };
767
767
  }
@@ -794,7 +794,7 @@ const yt = 256;
794
794
  function vt(e) {
795
795
  return async (t, a) => {
796
796
  var i, u, d;
797
- const n = (i = a.user_agent) == null ? void 0 : i.slice(0, yt), o = a.log_id || $(), { location_info: r, ...s } = a;
797
+ const n = (i = a.user_agent) == null ? void 0 : i.slice(0, yt), o = a.log_id || E(), { location_info: r, ...s } = a;
798
798
  return await e.insertInto("logs").values({
799
799
  ...s,
800
800
  log_id: o,
@@ -853,11 +853,11 @@ function Ct(e) {
853
853
  return async (t, a = {}) => {
854
854
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
855
855
  let u = e.selectFrom("logs").where("logs.tenant_id", "=", t);
856
- i && (u = O(e, u, i, ["user_id", "ip"]));
856
+ i && (u = k(e, u, i, ["user_id", "ip"]));
857
857
  let d = u;
858
858
  if (s && s.sort_by) {
859
- const { ref: m } = e.dynamic;
860
- d = d.orderBy(m(s.sort_by), s.sort_order);
859
+ const { ref: _ } = e.dynamic;
860
+ d = d.orderBy(_(s.sort_by), s.sort_order);
861
861
  }
862
862
  d = d.offset(n * o).limit(o);
863
863
  const l = (await d.selectAll().execute()).map(ge);
@@ -868,12 +868,12 @@ function Ct(e) {
868
868
  limit: 0,
869
869
  length: 0
870
870
  };
871
- const { count: _ } = await u.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
871
+ const { count: m } = await u.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
872
872
  return {
873
873
  logs: l,
874
874
  start: n * o,
875
875
  limit: o,
876
- length: k(_)
876
+ length: $(m)
877
877
  };
878
878
  };
879
879
  }
@@ -904,8 +904,8 @@ function Nt(e) {
904
904
  expires_at_ts: d,
905
905
  idle_expires_at_ts: c,
906
906
  authenticated_at_ts: l,
907
- last_interaction_at_ts: _,
908
- used_at_ts: m,
907
+ last_interaction_at_ts: m,
908
+ used_at_ts: _,
909
909
  revoked_at_ts: p,
910
910
  ...f
911
911
  } = n, g = z(
@@ -915,8 +915,8 @@ function Nt(e) {
915
915
  expires_at_ts: d,
916
916
  idle_expires_at_ts: c,
917
917
  authenticated_at_ts: l,
918
- last_interaction_at_ts: _,
919
- used_at_ts: m,
918
+ last_interaction_at_ts: m,
919
+ used_at_ts: _,
920
920
  revoked_at_ts: p
921
921
  },
922
922
  [
@@ -950,19 +950,19 @@ function bt(e) {
950
950
  revoked_at: d,
951
951
  device: c,
952
952
  clients: l,
953
- ..._
953
+ ...m
954
954
  } = a;
955
955
  return await e.insertInto("sessions").values({
956
- ..._,
956
+ ...m,
957
957
  tenant_id: t,
958
958
  created_at_ts: n,
959
959
  updated_at_ts: n,
960
960
  authenticated_at_ts: n,
961
961
  last_interaction_at_ts: n,
962
- expires_at_ts: C(s),
963
- idle_expires_at_ts: C(i),
964
- used_at_ts: C(u),
965
- revoked_at_ts: C(d),
962
+ expires_at_ts: x(s),
963
+ idle_expires_at_ts: x(i),
964
+ used_at_ts: x(u),
965
+ revoked_at_ts: x(d),
966
966
  device: JSON.stringify(c),
967
967
  clients: JSON.stringify(l)
968
968
  }).execute(), r;
@@ -978,16 +978,16 @@ function Ot(e) {
978
978
  device: n.device ? JSON.stringify(n.device) : void 0,
979
979
  clients: n.clients ? JSON.stringify(n.clients) : void 0
980
980
  };
981
- return n.expires_at !== void 0 && (o.expires_at_ts = C(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = C(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = C(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = C(
981
+ return n.expires_at !== void 0 && (o.expires_at_ts = x(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = x(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = x(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = x(
982
982
  n.last_interaction_at
983
- )), n.used_at !== void 0 && (o.used_at_ts = C(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = C(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;
983
+ )), n.used_at !== void 0 && (o.used_at_ts = x(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = x(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;
984
984
  };
985
985
  }
986
986
  function kt(e) {
987
987
  return async (t, a = {}) => {
988
988
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
989
989
  let u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
990
- i && (u = O(e, u, i, ["user_id", "session_id"]));
990
+ i && (u = k(e, u, i, ["user_id", "session_id"]));
991
991
  let d = u;
992
992
  if (s && s.sort_by) {
993
993
  const { ref: p } = e.dynamic;
@@ -999,22 +999,22 @@ function kt(e) {
999
999
  tenant_id: f,
1000
1000
  device: g,
1001
1001
  clients: y,
1002
- created_at_ts: x,
1002
+ created_at_ts: T,
1003
1003
  updated_at_ts: v,
1004
- expires_at_ts: T,
1005
- idle_expires_at_ts: E,
1006
- authenticated_at_ts: I,
1004
+ expires_at_ts: N,
1005
+ idle_expires_at_ts: I,
1006
+ authenticated_at_ts: C,
1007
1007
  last_interaction_at_ts: P,
1008
1008
  used_at_ts: ee,
1009
1009
  revoked_at_ts: Se,
1010
1010
  ...Oe
1011
1011
  } = p, ke = z(
1012
1012
  {
1013
- created_at_ts: x,
1013
+ created_at_ts: T,
1014
1014
  updated_at_ts: v,
1015
- expires_at_ts: T,
1016
- idle_expires_at_ts: E,
1017
- authenticated_at_ts: I,
1015
+ expires_at_ts: N,
1016
+ idle_expires_at_ts: I,
1017
+ authenticated_at_ts: C,
1018
1018
  last_interaction_at_ts: P,
1019
1019
  used_at_ts: ee,
1020
1020
  revoked_at_ts: Se
@@ -1041,12 +1041,12 @@ function kt(e) {
1041
1041
  limit: 0,
1042
1042
  length: 0
1043
1043
  };
1044
- const { count: _ } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = k(_);
1044
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
1045
1045
  return {
1046
1046
  sessions: l,
1047
1047
  start: n * o,
1048
1048
  limit: o,
1049
- length: m
1049
+ length: _
1050
1050
  };
1051
1051
  };
1052
1052
  }
@@ -1073,7 +1073,7 @@ function Et(e) {
1073
1073
  }
1074
1074
  function It(e) {
1075
1075
  return async (t, a) => {
1076
- const n = a.id || $(), o = a.is_current ?? !0, r = {
1076
+ const n = a.id || E(), o = a.is_current ?? !0, r = {
1077
1077
  id: n,
1078
1078
  ...a,
1079
1079
  is_current: o,
@@ -1119,9 +1119,9 @@ function At(e) {
1119
1119
  return async (t, a = {}) => {
1120
1120
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1121
1121
  let i = e.selectFrom("codes").where("codes.tenant_id", "=", t);
1122
- s && (i = O(e, i, s, ["code", "login_id"]));
1123
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
1124
- const { tenant_id: m, ...p } = _;
1122
+ s && (i = k(e, i, s, ["code", "login_id"]));
1123
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1124
+ const { tenant_id: _, ...p } = m;
1125
1125
  return Pe.parse(w(p));
1126
1126
  });
1127
1127
  if (!r)
@@ -1131,12 +1131,12 @@ function At(e) {
1131
1131
  limit: 0,
1132
1132
  length: 0
1133
1133
  };
1134
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1134
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1135
1135
  return {
1136
1136
  codes: c,
1137
1137
  start: n * o,
1138
1138
  limit: o,
1139
- length: k(l)
1139
+ length: $(l)
1140
1140
  };
1141
1141
  };
1142
1142
  }
@@ -1212,7 +1212,7 @@ function Ut(e) {
1212
1212
  return async (t, a = {}) => {
1213
1213
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1214
1214
  let i = e.selectFrom("connections").where("connections.tenant_id", "=", t);
1215
- s && (i = O(e, i, s, ["user_id", "ip"]));
1215
+ s && (i = k(e, i, s, ["user_id", "ip"]));
1216
1216
  const d = await i.offset(n * o).limit(o).selectAll().execute(), c = qt(d);
1217
1217
  if (!r)
1218
1218
  return {
@@ -1221,12 +1221,12 @@ function Ut(e) {
1221
1221
  limit: 0,
1222
1222
  length: 0
1223
1223
  };
1224
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1224
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1225
1225
  return {
1226
1226
  connections: c,
1227
1227
  start: n * o,
1228
1228
  limit: o,
1229
- length: k(l)
1229
+ length: $(l)
1230
1230
  };
1231
1231
  };
1232
1232
  }
@@ -1443,9 +1443,9 @@ function Xt(e) {
1443
1443
  if (a != null && a.include_totals) {
1444
1444
  let c = e.selectFrom("clients").select(h`count(*)`.as("count")).where("clients.tenant_id", "=", t);
1445
1445
  a != null && a.q && (c = c.where(
1446
- (_) => _.or([
1447
- _("name", "like", `%${a.q}%`),
1448
- _("client_id", "like", `%${a.q}%`)
1446
+ (m) => m.or([
1447
+ m("name", "like", `%${a.q}%`),
1448
+ m("client_id", "like", `%${a.q}%`)
1449
1449
  ])
1450
1450
  ));
1451
1451
  const l = await c.executeTakeFirst();
@@ -1630,7 +1630,7 @@ function ia(e) {
1630
1630
  }
1631
1631
  function ca(e) {
1632
1632
  return async (t, a) => {
1633
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = $(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1633
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = E(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1634
1634
  id: o,
1635
1635
  tenant_id: t,
1636
1636
  ...i,
@@ -1683,38 +1683,38 @@ function da(e) {
1683
1683
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1684
1684
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1685
1685
  if (s) {
1686
- const m = s.trim(), p = m.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] : "", x = /^(>=|>|<=|<)/.test(y || "");
1687
- if (g && !x && y) {
1688
- const v = !!g[1], T = g[2], { ref: E } = e.dynamic, I = E(`client_grants.${T}`);
1689
- if (T === "allow_any_organization") {
1686
+ 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] : "", T = /^(>=|>|<=|<)/.test(y || "");
1687
+ if (g && !T && y) {
1688
+ const v = !!g[1], N = g[2], { ref: I } = e.dynamic, C = I(`client_grants.${N}`);
1689
+ if (N === "allow_any_organization") {
1690
1690
  const P = y === "true" ? 1 : 0;
1691
- v ? u = u.where(I, "!=", P) : u = u.where(I, "=", P);
1691
+ v ? u = u.where(C, "!=", P) : u = u.where(C, "=", P);
1692
1692
  } else
1693
- v ? u = u.where(I, "!=", y) : u = u.where(I, "=", y);
1693
+ v ? u = u.where(C, "!=", y) : u = u.where(C, "=", y);
1694
1694
  } else
1695
- u = O(e, u, m, []);
1695
+ u = k(e, u, _, []);
1696
1696
  }
1697
1697
  let d = u;
1698
1698
  if (i) {
1699
- const { ref: m } = e.dynamic;
1700
- d = d.orderBy(m(i.sort_by), i.sort_order);
1699
+ const { ref: _ } = e.dynamic;
1700
+ d = d.orderBy(_(i.sort_by), i.sort_order);
1701
1701
  } else
1702
1702
  d = d.orderBy("client_grants.created_at", "desc");
1703
1703
  d = d.limit(o).offset(n * o);
1704
- const l = (await d.selectAll().execute()).map((m) => {
1704
+ const l = (await d.selectAll().execute()).map((_) => {
1705
1705
  const p = {
1706
- id: m.id,
1707
- client_id: m.client_id,
1708
- audience: m.audience,
1709
- scope: m.scope ? JSON.parse(m.scope) : [],
1710
- organization_usage: m.organization_usage,
1706
+ id: _.id,
1707
+ client_id: _.client_id,
1708
+ audience: _.audience,
1709
+ scope: _.scope ? JSON.parse(_.scope) : [],
1710
+ organization_usage: _.organization_usage,
1711
1711
  // Convert integers back to booleans for API response (with defaults)
1712
- allow_any_organization: m.allow_any_organization !== void 0 ? !!m.allow_any_organization : !1,
1713
- is_system: m.is_system !== void 0 ? !!m.is_system : !1,
1714
- subject_type: m.subject_type,
1715
- authorization_details_types: m.authorization_details_types ? JSON.parse(m.authorization_details_types) : [],
1716
- created_at: m.created_at,
1717
- updated_at: m.updated_at
1712
+ allow_any_organization: _.allow_any_organization !== void 0 ? !!_.allow_any_organization : !1,
1713
+ is_system: _.is_system !== void 0 ? !!_.is_system : !1,
1714
+ subject_type: _.subject_type,
1715
+ authorization_details_types: _.authorization_details_types ? JSON.parse(_.authorization_details_types) : [],
1716
+ created_at: _.created_at,
1717
+ updated_at: _.updated_at
1718
1718
  };
1719
1719
  return w(p);
1720
1720
  });
@@ -1725,12 +1725,12 @@ function da(e) {
1725
1725
  limit: 0,
1726
1726
  length: 0
1727
1727
  };
1728
- const { count: _ } = await u.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1728
+ const { count: m } = await u.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1729
1729
  return {
1730
1730
  client_grants: l,
1731
1731
  start: n * o,
1732
1732
  limit: o,
1733
- length: k(_)
1733
+ length: $(m)
1734
1734
  };
1735
1735
  };
1736
1736
  }
@@ -1767,19 +1767,19 @@ function ha(e) {
1767
1767
  q: s
1768
1768
  } = t;
1769
1769
  let i = e.selectFrom("keys").where(
1770
- (m) => m.or([
1771
- m("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1772
- m("revoked_at", "is", null)
1770
+ (_) => _.or([
1771
+ _("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1772
+ _("revoked_at", "is", null)
1773
1773
  ])
1774
1774
  );
1775
- s && (i = O(e, i, s, [
1775
+ s && (i = k(e, i, s, [
1776
1776
  "kid",
1777
1777
  "connection",
1778
1778
  "fingerprint",
1779
1779
  "thumbprint",
1780
1780
  "type"
1781
1781
  ]));
1782
- let u = i.select((m) => m.fn.count("kid").as("count"));
1782
+ let u = i.select((_) => _.fn.count("kid").as("count"));
1783
1783
  const d = a * n;
1784
1784
  i = i.limit(n).offset(d), r && (i = i.orderBy(r.sort_by, r.sort_order));
1785
1785
  const c = await i.selectAll().execute();
@@ -1790,12 +1790,12 @@ function ha(e) {
1790
1790
  limit: 0,
1791
1791
  length: 0
1792
1792
  };
1793
- const l = await u.executeTakeFirst(), _ = k((l == null ? void 0 : l.count) ?? 0);
1793
+ const l = await u.executeTakeFirst(), m = $((l == null ? void 0 : l.count) ?? 0);
1794
1794
  return {
1795
1795
  signingKeys: c,
1796
1796
  start: d,
1797
1797
  limit: n,
1798
- length: _
1798
+ length: m
1799
1799
  };
1800
1800
  };
1801
1801
  }
@@ -1817,7 +1817,7 @@ function ga(e) {
1817
1817
  function wa(e) {
1818
1818
  return async (t, a) => {
1819
1819
  const n = {
1820
- custom_domain_id: a.custom_domain_id || $(),
1820
+ custom_domain_id: a.custom_domain_id || E(),
1821
1821
  status: "pending",
1822
1822
  primary: !1,
1823
1823
  ...a
@@ -1933,7 +1933,7 @@ function ba(e) {
1933
1933
  }
1934
1934
  function Sa(e) {
1935
1935
  return async (t, a) => {
1936
- var s, i, u, d, c, l, _, m, p, f, g, y, x, v, T, E, I, P;
1936
+ var s, i, u, d, c, l, m, _, p, f, g, y, T, v, N, I, C, P;
1937
1937
  const { colors: n, font: o, ...r } = a;
1938
1938
  try {
1939
1939
  await e.insertInto("branding").values({
@@ -1942,7 +1942,7 @@ function Sa(e) {
1942
1942
  colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
1943
1943
  colors_page_background_start: (d = (u = a.colors) == null ? void 0 : u.page_background) == null ? void 0 : d.start,
1944
1944
  colors_page_background_end: (l = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : l.end,
1945
- colors_page_background_angle_dev: (m = (_ = a.colors) == null ? void 0 : _.page_background) == null ? void 0 : m.angle_deg,
1945
+ colors_page_background_angle_dev: (_ = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : _.angle_deg,
1946
1946
  font_url: (p = a.font) == null ? void 0 : p.url,
1947
1947
  tenant_id: t
1948
1948
  }).execute();
@@ -1951,9 +1951,9 @@ function Sa(e) {
1951
1951
  ...r,
1952
1952
  colors_primary: n == null ? void 0 : n.primary,
1953
1953
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1954
- colors_page_background_start: (x = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : x.start,
1955
- colors_page_background_end: (T = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : T.end,
1956
- colors_page_background_angle_dev: (I = (E = a.colors) == null ? void 0 : E.page_background) == null ? void 0 : I.angle_deg,
1954
+ colors_page_background_start: (T = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : T.start,
1955
+ colors_page_background_end: (N = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : N.end,
1956
+ colors_page_background_angle_dev: (C = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : C.angle_deg,
1957
1957
  font_url: (P = a.font) == null ? void 0 : P.url
1958
1958
  }).where("tenant_id", "=", t).execute();
1959
1959
  }
@@ -2007,26 +2007,26 @@ function za(e) {
2007
2007
  return async (t, a = {}) => {
2008
2008
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2009
2009
  let i = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
2010
- s && (i = O(e, i, s, [
2010
+ s && (i = k(e, i, s, [
2011
2011
  "url",
2012
2012
  "form_id",
2013
2013
  "template_id",
2014
2014
  "code_id"
2015
2015
  ]));
2016
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
2016
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2017
2017
  const {
2018
- tenant_id: m,
2018
+ tenant_id: _,
2019
2019
  enabled: p,
2020
2020
  synchronous: f,
2021
2021
  created_at_ts: g,
2022
2022
  updated_at_ts: y,
2023
- ...x
2024
- } = _, v = z({ created_at_ts: g, updated_at_ts: y }, [
2023
+ ...T
2024
+ } = m, v = z({ created_at_ts: g, updated_at_ts: y }, [
2025
2025
  "created_at_ts",
2026
2026
  "updated_at_ts"
2027
2027
  ]);
2028
2028
  return w({
2029
- ...x,
2029
+ ...T,
2030
2030
  ...v,
2031
2031
  enabled: !!p,
2032
2032
  synchronous: !!f
@@ -2039,12 +2039,12 @@ function za(e) {
2039
2039
  limit: 0,
2040
2040
  length: 0
2041
2041
  };
2042
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2042
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2043
2043
  return {
2044
2044
  hooks: c,
2045
2045
  start: n * o,
2046
2046
  limit: o,
2047
- length: k(l)
2047
+ length: $(l)
2048
2048
  };
2049
2049
  };
2050
2050
  }
@@ -2179,7 +2179,7 @@ function Ka(e) {
2179
2179
  function qa(e) {
2180
2180
  return async (t, a, n) => {
2181
2181
  const o = {
2182
- themeId: n || $(),
2182
+ themeId: n || E(),
2183
2183
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2184
2184
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2185
2185
  ...a
@@ -2307,7 +2307,7 @@ function Za(e) {
2307
2307
  updated_at_ts: Date.now(),
2308
2308
  // Only update expires_at_ts if a new expires_at was provided
2309
2309
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2310
- ...s !== void 0 ? { expires_at_ts: C(s) } : {}
2310
+ ...s !== void 0 ? { expires_at_ts: x(s) } : {}
2311
2311
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2312
2312
  };
2313
2313
  }
@@ -2463,17 +2463,17 @@ function _n(e) {
2463
2463
  resource_servers: d,
2464
2464
  rotating: c,
2465
2465
  ...l
2466
- } = a, _ = Date.now();
2466
+ } = a, m = Date.now();
2467
2467
  return await e.insertInto("refresh_tokens").values({
2468
2468
  ...l,
2469
2469
  tenant_id: t,
2470
2470
  rotating: c ? 1 : 0,
2471
2471
  device: JSON.stringify(u),
2472
2472
  resource_servers: JSON.stringify(d),
2473
- created_at_ts: _,
2474
- expires_at_ts: C(r),
2475
- idle_expires_at_ts: s ? C(s) : null,
2476
- last_exchanged_at_ts: i ? C(i) : null
2473
+ created_at_ts: m,
2474
+ expires_at_ts: x(r),
2475
+ idle_expires_at_ts: s ? x(s) : null,
2476
+ last_exchanged_at_ts: i ? x(i) : null
2477
2477
  }).execute(), { ...a, ...o };
2478
2478
  };
2479
2479
  }
@@ -2491,25 +2491,25 @@ function hn(e) {
2491
2491
  resource_servers: d,
2492
2492
  rotating: c,
2493
2493
  ...l
2494
- } = n, _ = {
2494
+ } = n, m = {
2495
2495
  ...l,
2496
2496
  device: u ? JSON.stringify(u) : void 0,
2497
2497
  resource_servers: d ? JSON.stringify(d) : void 0,
2498
2498
  rotating: c !== void 0 ? c ? 1 : 0 : void 0,
2499
2499
  // Convert date fields to bigint format
2500
2500
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2501
- expires_at_ts: r !== void 0 ? C(r) : void 0,
2502
- idle_expires_at_ts: s !== void 0 ? C(s) : void 0,
2503
- last_exchanged_at_ts: i !== void 0 ? C(i) : void 0
2501
+ expires_at_ts: r !== void 0 ? x(r) : void 0,
2502
+ idle_expires_at_ts: s !== void 0 ? x(s) : void 0,
2503
+ last_exchanged_at_ts: i !== void 0 ? x(i) : void 0
2504
2504
  };
2505
- return !!(await e.updateTable("refresh_tokens").set(_).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length;
2505
+ return !!(await e.updateTable("refresh_tokens").set(m).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length;
2506
2506
  };
2507
2507
  }
2508
2508
  function pn(e) {
2509
2509
  return async (t, a = {}) => {
2510
2510
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
2511
2511
  let u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
2512
- i && (u = O(e, u, i, ["token", "login_id"]));
2512
+ i && (u = k(e, u, i, ["token", "login_id"]));
2513
2513
  let d = u;
2514
2514
  if (s && s.sort_by) {
2515
2515
  const { ref: p } = e.dynamic;
@@ -2521,22 +2521,22 @@ function pn(e) {
2521
2521
  tenant_id: f,
2522
2522
  created_at_ts: g,
2523
2523
  expires_at_ts: y,
2524
- idle_expires_at_ts: x,
2524
+ idle_expires_at_ts: T,
2525
2525
  last_exchanged_at_ts: v,
2526
- ...T
2527
- } = p, E = z(
2526
+ ...N
2527
+ } = p, I = z(
2528
2528
  {
2529
2529
  created_at_ts: g,
2530
2530
  expires_at_ts: y,
2531
- idle_expires_at_ts: x,
2531
+ idle_expires_at_ts: T,
2532
2532
  last_exchanged_at_ts: v
2533
2533
  },
2534
2534
  ["created_at_ts"],
2535
2535
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
2536
2536
  );
2537
2537
  return {
2538
- ...T,
2539
- ...E,
2538
+ ...N,
2539
+ ...I,
2540
2540
  rotating: !!p.rotating,
2541
2541
  device: p.device ? JSON.parse(p.device) : {},
2542
2542
  resource_servers: p.resource_servers ? JSON.parse(p.resource_servers) : []
@@ -2549,12 +2549,12 @@ function pn(e) {
2549
2549
  limit: 0,
2550
2550
  length: 0
2551
2551
  };
2552
- const { count: _ } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = k(_);
2552
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
2553
2553
  return {
2554
2554
  refresh_tokens: l,
2555
2555
  start: n * o,
2556
2556
  limit: o,
2557
- length: m
2557
+ length: _
2558
2558
  };
2559
2559
  };
2560
2560
  }
@@ -2575,53 +2575,53 @@ function wn(e) {
2575
2575
  try {
2576
2576
  let c = 0;
2577
2577
  for (; ; ) {
2578
- let m = e.deleteFrom("refresh_tokens").where(
2578
+ let _ = e.deleteFrom("refresh_tokens").where(
2579
2579
  (g) => g.or([
2580
2580
  g("expires_at_ts", "<", r),
2581
2581
  g("idle_expires_at_ts", "<", r)
2582
2582
  ])
2583
2583
  );
2584
- a && (m = m.where(
2584
+ a && (_ = _.where(
2585
2585
  "tenant_id",
2586
2586
  "=",
2587
2587
  a
2588
- )), n && (m = m.where(
2588
+ )), n && (_ = _.where(
2589
2589
  "user_id",
2590
2590
  "=",
2591
2591
  n
2592
2592
  ));
2593
- const p = await m.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
2593
+ const p = await _.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
2594
2594
  if (c += f, f < s) break;
2595
2595
  }
2596
2596
  let l = 0;
2597
2597
  for (; ; ) {
2598
- let m = e.deleteFrom("sessions").where(
2598
+ let _ = e.deleteFrom("sessions").where(
2599
2599
  (g) => g.or([
2600
2600
  g("expires_at_ts", "<", r),
2601
2601
  g("idle_expires_at_ts", "<", r)
2602
2602
  ])
2603
2603
  );
2604
- a && (m = m.where("tenant_id", "=", a)), n && (m = m.where("user_id", "=", n));
2605
- const p = await m.limit(s).execute(), f = Number(((u = p[0]) == null ? void 0 : u.numDeletedRows) ?? 0);
2604
+ a && (_ = _.where("tenant_id", "=", a)), n && (_ = _.where("user_id", "=", n));
2605
+ const p = await _.limit(s).execute(), f = Number(((u = p[0]) == null ? void 0 : u.numDeletedRows) ?? 0);
2606
2606
  if (l += f, f < s) break;
2607
2607
  }
2608
- let _ = 0;
2608
+ let m = 0;
2609
2609
  for (; ; ) {
2610
- let m = e.deleteFrom("login_sessions").where("expires_at_ts", "<", r);
2611
- a && (m = m.where(
2610
+ let _ = e.deleteFrom("login_sessions").where("expires_at_ts", "<", r);
2611
+ a && (_ = _.where(
2612
2612
  "tenant_id",
2613
2613
  "=",
2614
2614
  a
2615
- )), n && (m = m.where(
2615
+ )), n && (_ = _.where(
2616
2616
  "user_id",
2617
2617
  "=",
2618
2618
  n
2619
2619
  ));
2620
- const p = await m.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
2621
- if (_ += f, f < s) break;
2620
+ const p = await _.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
2621
+ if (m += f, f < s) break;
2622
2622
  }
2623
- (c > 0 || l > 0 || _ > 0) && console.log(
2624
- `Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${_} login_sessions`
2623
+ (c > 0 || l > 0 || m > 0) && console.log(
2624
+ `Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${m} login_sessions`
2625
2625
  );
2626
2626
  } catch (c) {
2627
2627
  console.error("Error during session cleanup:", c);
@@ -2631,7 +2631,7 @@ function wn(e) {
2631
2631
  function yn(e) {
2632
2632
  return async (t, a) => {
2633
2633
  const n = q.parse({
2634
- id: $(),
2634
+ id: E(),
2635
2635
  ...a,
2636
2636
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2637
2637
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -2650,25 +2650,25 @@ function vn(e) {
2650
2650
  return async (t, a = {}) => {
2651
2651
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2652
2652
  let i = e.selectFrom("forms").where("tenant_id", "=", t);
2653
- s && (i = O(e, i, s, []));
2654
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
2655
- const m = { ..._ };
2656
- if (typeof m.nodes == "string")
2653
+ s && (i = k(e, i, s, []));
2654
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2655
+ const _ = { ...m };
2656
+ if (typeof _.nodes == "string")
2657
2657
  try {
2658
- m.nodes = JSON.parse(m.nodes);
2658
+ _.nodes = JSON.parse(_.nodes);
2659
2659
  } catch {
2660
2660
  }
2661
- if (typeof m.start == "string")
2661
+ if (typeof _.start == "string")
2662
2662
  try {
2663
- m.start = JSON.parse(m.start);
2663
+ _.start = JSON.parse(_.start);
2664
2664
  } catch {
2665
2665
  }
2666
- if (typeof m.ending == "string")
2666
+ if (typeof _.ending == "string")
2667
2667
  try {
2668
- m.ending = JSON.parse(m.ending);
2668
+ _.ending = JSON.parse(_.ending);
2669
2669
  } catch {
2670
2670
  }
2671
- return q.parse(w(m));
2671
+ return q.parse(w(_));
2672
2672
  });
2673
2673
  if (!r)
2674
2674
  return {
@@ -2677,12 +2677,12 @@ function vn(e) {
2677
2677
  limit: 0,
2678
2678
  length: 0
2679
2679
  };
2680
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2680
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2681
2681
  return {
2682
2682
  forms: c,
2683
2683
  start: n * o,
2684
2684
  limit: o,
2685
- length: k(l)
2685
+ length: $(l)
2686
2686
  };
2687
2687
  };
2688
2688
  }
@@ -2749,17 +2749,17 @@ function bn(e) {
2749
2749
  skip_consent_for_verifiable_first_party_clients: d,
2750
2750
  allow_offline_access: c,
2751
2751
  is_system: l,
2752
- metadata: _,
2753
- ...m
2752
+ metadata: m,
2753
+ ..._
2754
2754
  } = r, p = {
2755
- ...m,
2755
+ ..._,
2756
2756
  tenant_id: t,
2757
2757
  scopes: i ? JSON.stringify(i) : "[]",
2758
2758
  options: u ? JSON.stringify(u) : "{}",
2759
2759
  skip_consent_for_verifiable_first_party_clients: d ? 1 : 0,
2760
2760
  allow_offline_access: c ? 1 : 0,
2761
2761
  is_system: l ? 1 : 0,
2762
- metadata: _ ? JSON.stringify(_) : void 0,
2762
+ metadata: m ? JSON.stringify(m) : void 0,
2763
2763
  verification_key: s,
2764
2764
  created_at: n,
2765
2765
  updated_at: n
@@ -2779,9 +2779,9 @@ function Sn(e) {
2779
2779
  allow_offline_access: d,
2780
2780
  is_system: c,
2781
2781
  metadata: l,
2782
- ..._
2783
- } = o, m = {
2784
- ..._,
2782
+ ...m
2783
+ } = o, _ = w({
2784
+ ...m,
2785
2785
  scopes: s ? JSON.parse(s) : [],
2786
2786
  options: i ? JSON.parse(i) : {},
2787
2787
  skip_consent_for_verifiable_first_party_clients: !!u,
@@ -2790,8 +2790,8 @@ function Sn(e) {
2790
2790
  metadata: l ? JSON.parse(l) : void 0,
2791
2791
  // Convert verification_key back to verificationKey for API
2792
2792
  verificationKey: r
2793
- };
2794
- return w(m);
2793
+ });
2794
+ return _.token_lifetime ?? (_.token_lifetime = 86400), _.token_lifetime_for_web ?? (_.token_lifetime_for_web = 7200), _;
2795
2795
  };
2796
2796
  }
2797
2797
  function On(e) {
@@ -2799,38 +2799,38 @@ function On(e) {
2799
2799
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2800
2800
  let i = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
2801
2801
  if (s) {
2802
- const _ = s.trim(), m = _.split(/\s+/), p = m.length === 1 ? m[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", y = /^(>=|>|<=|<)/.test(g || "");
2802
+ 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 || "");
2803
2803
  if (f && !y) {
2804
- const x = !!f[1], v = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2805
- i = x ? i.where(v, "not like", `%${g}%`) : i.where(v, "like", `%${g}%`);
2804
+ const T = !!f[1], v = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2805
+ i = T ? i.where(v, "not like", `%${g}%`) : i.where(v, "like", `%${g}%`);
2806
2806
  } else
2807
- i = O(e, i, _, [
2807
+ i = k(e, i, m, [
2808
2808
  "resource_servers.name",
2809
2809
  "resource_servers.identifier"
2810
2810
  ]);
2811
2811
  }
2812
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
2813
- const m = _, {
2812
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2813
+ const _ = m, {
2814
2814
  verification_key: p,
2815
2815
  scopes: f,
2816
2816
  options: g,
2817
2817
  skip_consent_for_verifiable_first_party_clients: y,
2818
- allow_offline_access: x,
2818
+ allow_offline_access: T,
2819
2819
  is_system: v,
2820
- metadata: T,
2821
- ...E
2822
- } = m, I = {
2823
- ...E,
2820
+ metadata: N,
2821
+ ...I
2822
+ } = _, C = w({
2823
+ ...I,
2824
2824
  scopes: f ? JSON.parse(f) : [],
2825
2825
  options: g ? JSON.parse(g) : {},
2826
2826
  skip_consent_for_verifiable_first_party_clients: !!y,
2827
- allow_offline_access: !!x,
2827
+ allow_offline_access: !!T,
2828
2828
  is_system: v ? !0 : void 0,
2829
- metadata: T ? JSON.parse(T) : void 0,
2829
+ metadata: N ? JSON.parse(N) : void 0,
2830
2830
  // Convert verification_key back to verificationKey for API
2831
2831
  verificationKey: p
2832
- };
2833
- return w(I);
2832
+ });
2833
+ return C.token_lifetime ?? (C.token_lifetime = 86400), C.token_lifetime_for_web ?? (C.token_lifetime_for_web = 7200), C;
2834
2834
  });
2835
2835
  if (!r)
2836
2836
  return {
@@ -2839,12 +2839,12 @@ function On(e) {
2839
2839
  limit: 0,
2840
2840
  length: 0
2841
2841
  };
2842
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2842
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2843
2843
  return {
2844
2844
  resource_servers: c,
2845
2845
  start: n * o,
2846
2846
  limit: o,
2847
- length: k(l)
2847
+ length: $(l)
2848
2848
  };
2849
2849
  };
2850
2850
  }
@@ -2865,17 +2865,17 @@ function $n(e) {
2865
2865
  is_system: d,
2866
2866
  metadata: c,
2867
2867
  ...l
2868
- } = n, _ = {
2868
+ } = n, m = {
2869
2869
  ...l,
2870
2870
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2871
2871
  };
2872
- if (o !== void 0 && (_.verification_key = o), r !== void 0 && (_.scopes = JSON.stringify(r)), s !== void 0) {
2872
+ if (o !== void 0 && (m.verification_key = o), r !== void 0 && (m.scopes = JSON.stringify(r)), s !== void 0) {
2873
2873
  const p = await e.selectFrom("resource_servers").select("options").where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst(), g = { ...p != null && p.options ? JSON.parse(p.options) : {}, ...s };
2874
- _.options = JSON.stringify(g);
2874
+ m.options = JSON.stringify(g);
2875
2875
  }
2876
- c !== void 0 && (_.metadata = JSON.stringify(c)), i !== void 0 && (_.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), u !== void 0 && (_.allow_offline_access = u ? 1 : 0), d !== void 0 && (_.is_system = d ? 1 : 0);
2877
- const m = await e.updateTable("resource_servers").set(_).where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
2878
- return Number(m.numUpdatedRows) > 0;
2876
+ c !== void 0 && (m.metadata = JSON.stringify(c)), i !== void 0 && (m.skip_consent_for_verifiable_first_party_clients = i ? 1 : 0), u !== void 0 && (m.allow_offline_access = u ? 1 : 0), d !== void 0 && (m.is_system = d ? 1 : 0);
2877
+ const _ = await e.updateTable("resource_servers").set(m).where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
2878
+ return Number(_.numUpdatedRows) > 0;
2879
2879
  };
2880
2880
  }
2881
2881
  function En(e) {
@@ -2889,7 +2889,7 @@ function En(e) {
2889
2889
  }
2890
2890
  function In(e) {
2891
2891
  return async (t, a) => {
2892
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || $(), { is_system: r, id: s, metadata: i, ...u } = a, d = {
2892
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || E(), { is_system: r, id: s, metadata: i, ...u } = a, d = {
2893
2893
  id: o,
2894
2894
  ...u,
2895
2895
  tenant_id: t,
@@ -2924,12 +2924,12 @@ function Pn(e) {
2924
2924
  return async (t, a) => {
2925
2925
  let n = e.selectFrom("roles").where("roles.tenant_id", "=", t);
2926
2926
  const { page: o = 0, per_page: r = 50, include_totals: s = !1 } = a;
2927
- a.q && (n = O(e, n, a.q, ["name"]));
2927
+ a.q && (n = k(e, n, a.q, ["name"]));
2928
2928
  const d = (await n.offset(o * r).limit(r).selectAll().execute()).map((l) => {
2929
- const _ = l, { is_system: m, tenant_id: p, metadata: f, ...g } = _;
2929
+ const m = l, { is_system: _, tenant_id: p, metadata: f, ...g } = m;
2930
2930
  return {
2931
2931
  ...g,
2932
- is_system: m ? !0 : void 0,
2932
+ is_system: _ ? !0 : void 0,
2933
2933
  metadata: f ? JSON.parse(f) : void 0
2934
2934
  };
2935
2935
  });
@@ -2945,7 +2945,7 @@ function Pn(e) {
2945
2945
  roles: d,
2946
2946
  start: o * r,
2947
2947
  limit: r,
2948
- length: k(c)
2948
+ length: $(c)
2949
2949
  };
2950
2950
  };
2951
2951
  }
@@ -3275,9 +3275,9 @@ function Zn(e) {
3275
3275
  if (a != null && a.include_totals) {
3276
3276
  let c = e.selectFrom("organizations").select(h`count(*)`.as("count")).where("tenant_id", "=", t);
3277
3277
  a != null && a.q && (c = c.where(
3278
- (_) => _.or([
3279
- _("name", "like", `%${a.q}%`),
3280
- _("display_name", "like", `%${a.q}%`)
3278
+ (m) => m.or([
3279
+ m("name", "like", `%${a.q}%`),
3280
+ m("display_name", "like", `%${a.q}%`)
3281
3281
  ])
3282
3282
  ));
3283
3283
  const l = await c.executeTakeFirst();
@@ -3329,7 +3329,7 @@ function ao(e) {
3329
3329
  function no(e) {
3330
3330
  return async (t, a) => {
3331
3331
  const n = {
3332
- id: $(),
3332
+ id: E(),
3333
3333
  tenant_id: t,
3334
3334
  user_id: a.user_id,
3335
3335
  organization_id: a.organization_id,
@@ -3798,7 +3798,7 @@ function bo(e) {
3798
3798
  }
3799
3799
  function So(e) {
3800
3800
  return async (t, a) => {
3801
- const n = $();
3801
+ const n = E();
3802
3802
  return await e.insertInto("outbox_events").values({
3803
3803
  id: n,
3804
3804
  tenant_id: t,
@@ -5949,7 +5949,7 @@ async function Ud(e) {
5949
5949
  }
5950
5950
  for (const o of n)
5951
5951
  await e.insertInto("password_history").values({
5952
- id: $(),
5952
+ id: E(),
5953
5953
  user_id: o.user_id,
5954
5954
  tenant_id: o.tenant_id,
5955
5955
  password: o.password,
@@ -6171,7 +6171,7 @@ async function hu(e) {
6171
6171
  return "sqlite";
6172
6172
  }
6173
6173
  }
6174
- async function N(e, t, a, n) {
6174
+ async function b(e, t, a, n) {
6175
6175
  try {
6176
6176
  await e.schema.alterTable(t).addColumn(a, n).execute();
6177
6177
  } catch (o) {
@@ -6186,7 +6186,7 @@ async function N(e, t, a, n) {
6186
6186
  }
6187
6187
  async function pu(e) {
6188
6188
  const t = await hu(e);
6189
- await N(e, "refresh_tokens", "created_at_ts", "bigint"), await N(e, "refresh_tokens", "expires_at_ts", "bigint"), await N(e, "refresh_tokens", "idle_expires_at_ts", "bigint"), await N(e, "refresh_tokens", "last_exchanged_at_ts", "bigint"), await N(e, "sessions", "created_at_ts", "bigint"), await N(e, "sessions", "updated_at_ts", "bigint"), await N(e, "sessions", "expires_at_ts", "bigint"), await N(e, "sessions", "idle_expires_at_ts", "bigint"), await N(e, "sessions", "authenticated_at_ts", "bigint"), await N(e, "sessions", "last_interaction_at_ts", "bigint"), await N(e, "sessions", "used_at_ts", "bigint"), await N(e, "sessions", "revoked_at_ts", "bigint"), await N(e, "login_sessions", "created_at_ts", "bigint"), await N(e, "login_sessions", "updated_at_ts", "bigint"), await N(e, "login_sessions", "expires_at_ts", "bigint"), t === "mysql" && (await e.schema.alterTable("refresh_tokens").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("expires_at", "varchar(35)").execute()), await e.schema.createIndex("idx_sessions_user_id").on("sessions").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_user_id").on("refresh_tokens").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.createIndex("idx_refresh_tokens_expires_at_ts").on("refresh_tokens").column("expires_at_ts").execute(), await e.schema.createIndex("idx_sessions_expires_at_ts").on("sessions").column("expires_at_ts").execute(), await e.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
6189
+ await b(e, "refresh_tokens", "created_at_ts", "bigint"), await b(e, "refresh_tokens", "expires_at_ts", "bigint"), await b(e, "refresh_tokens", "idle_expires_at_ts", "bigint"), await b(e, "refresh_tokens", "last_exchanged_at_ts", "bigint"), await b(e, "sessions", "created_at_ts", "bigint"), await b(e, "sessions", "updated_at_ts", "bigint"), await b(e, "sessions", "expires_at_ts", "bigint"), await b(e, "sessions", "idle_expires_at_ts", "bigint"), await b(e, "sessions", "authenticated_at_ts", "bigint"), await b(e, "sessions", "last_interaction_at_ts", "bigint"), await b(e, "sessions", "used_at_ts", "bigint"), await b(e, "sessions", "revoked_at_ts", "bigint"), await b(e, "login_sessions", "created_at_ts", "bigint"), await b(e, "login_sessions", "updated_at_ts", "bigint"), await b(e, "login_sessions", "expires_at_ts", "bigint"), t === "mysql" && (await e.schema.alterTable("refresh_tokens").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("sessions").modifyColumn("expires_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("created_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("updated_at", "varchar(35)").execute(), await e.schema.alterTable("login_sessions").modifyColumn("expires_at", "varchar(35)").execute()), await e.schema.createIndex("idx_sessions_user_id").on("sessions").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_user_id").on("refresh_tokens").columns(["tenant_id", "user_id"]).execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.createIndex("idx_refresh_tokens_expires_at_ts").on("refresh_tokens").column("expires_at_ts").execute(), await e.schema.createIndex("idx_sessions_expires_at_ts").on("sessions").column("expires_at_ts").execute(), await e.schema.createIndex("idx_login_sessions_expires_at_ts").on("login_sessions").column("expires_at_ts").execute();
6190
6190
  }
6191
6191
  async function F(e, t, a) {
6192
6192
  try {
@@ -6197,7 +6197,7 @@ async function F(e, t, a) {
6197
6197
  throw n;
6198
6198
  }
6199
6199
  }
6200
- async function b(e, t, a) {
6200
+ async function S(e, t, a) {
6201
6201
  try {
6202
6202
  await e.schema.alterTable(t).dropColumn(a).execute();
6203
6203
  } catch (n) {
@@ -6207,7 +6207,7 @@ async function b(e, t, a) {
6207
6207
  }
6208
6208
  }
6209
6209
  async function fu(e) {
6210
- await F(e, "idx_sessions_user_id", "sessions"), await F(e, "idx_refresh_tokens_user_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_session_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_expires_at_ts", "refresh_tokens"), await F(e, "idx_sessions_expires_at_ts", "sessions"), await F(e, "idx_login_sessions_expires_at_ts", "login_sessions"), await b(e, "refresh_tokens", "created_at_ts"), await b(e, "refresh_tokens", "expires_at_ts"), await b(e, "refresh_tokens", "idle_expires_at_ts"), await b(e, "refresh_tokens", "last_exchanged_at_ts"), await b(e, "sessions", "created_at_ts"), await b(e, "sessions", "updated_at_ts"), await b(e, "sessions", "expires_at_ts"), await b(e, "sessions", "idle_expires_at_ts"), await b(e, "sessions", "authenticated_at_ts"), await b(e, "sessions", "last_interaction_at_ts"), await b(e, "sessions", "used_at_ts"), await b(e, "sessions", "revoked_at_ts"), await b(e, "login_sessions", "created_at_ts"), await b(e, "login_sessions", "updated_at_ts"), await b(e, "login_sessions", "expires_at_ts");
6210
+ await F(e, "idx_sessions_user_id", "sessions"), await F(e, "idx_refresh_tokens_user_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_session_id", "refresh_tokens"), await F(e, "idx_refresh_tokens_expires_at_ts", "refresh_tokens"), await F(e, "idx_sessions_expires_at_ts", "sessions"), await F(e, "idx_login_sessions_expires_at_ts", "login_sessions"), await S(e, "refresh_tokens", "created_at_ts"), await S(e, "refresh_tokens", "expires_at_ts"), await S(e, "refresh_tokens", "idle_expires_at_ts"), await S(e, "refresh_tokens", "last_exchanged_at_ts"), await S(e, "sessions", "created_at_ts"), await S(e, "sessions", "updated_at_ts"), await S(e, "sessions", "expires_at_ts"), await S(e, "sessions", "idle_expires_at_ts"), await S(e, "sessions", "authenticated_at_ts"), await S(e, "sessions", "last_interaction_at_ts"), await S(e, "sessions", "used_at_ts"), await S(e, "sessions", "revoked_at_ts"), await S(e, "login_sessions", "created_at_ts"), await S(e, "login_sessions", "updated_at_ts"), await S(e, "login_sessions", "expires_at_ts");
6211
6211
  }
6212
6212
  const gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6213
6213
  __proto__: null,
@@ -6221,7 +6221,7 @@ async function xe(e) {
6221
6221
  return "sqlite";
6222
6222
  }
6223
6223
  }
6224
- async function S(e, t, a) {
6224
+ async function O(e, t, a) {
6225
6225
  try {
6226
6226
  await e.schema.alterTable(t).dropColumn(a).execute();
6227
6227
  } catch (n) {
@@ -6247,7 +6247,7 @@ async function wu(e) {
6247
6247
  ` Warning: Failed to drop index login_sessions_state_updated_idx: ${a instanceof Error ? a.message : String(a)}`
6248
6248
  );
6249
6249
  }
6250
- console.log("Dropping old date columns..."), await S(e, "refresh_tokens", "created_at"), await S(e, "refresh_tokens", "expires_at"), await S(e, "refresh_tokens", "idle_expires_at"), await S(e, "refresh_tokens", "last_exchanged_at"), await S(e, "sessions", "created_at"), await S(e, "sessions", "updated_at"), await S(e, "sessions", "expires_at"), await S(e, "sessions", "idle_expires_at"), await S(e, "sessions", "authenticated_at"), await S(e, "sessions", "last_interaction_at"), await S(e, "sessions", "used_at"), await S(e, "sessions", "revoked_at"), await S(e, "login_sessions", "created_at"), await S(e, "login_sessions", "updated_at"), await S(e, "login_sessions", "expires_at"), t === "mysql" && (console.log("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()), console.log("Migration completed successfully");
6250
+ console.log("Dropping old date columns..."), await O(e, "refresh_tokens", "created_at"), await O(e, "refresh_tokens", "expires_at"), await O(e, "refresh_tokens", "idle_expires_at"), await O(e, "refresh_tokens", "last_exchanged_at"), await O(e, "sessions", "created_at"), await O(e, "sessions", "updated_at"), await O(e, "sessions", "expires_at"), await O(e, "sessions", "idle_expires_at"), await O(e, "sessions", "authenticated_at"), await O(e, "sessions", "last_interaction_at"), await O(e, "sessions", "used_at"), await O(e, "sessions", "revoked_at"), await O(e, "login_sessions", "created_at"), await O(e, "login_sessions", "updated_at"), await O(e, "login_sessions", "expires_at"), t === "mysql" && (console.log("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()), console.log("Migration completed successfully");
6251
6251
  }
6252
6252
  async function yu(e) {
6253
6253
  await xe(e) === "mysql" && (console.log("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()), console.log("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(), console.log("Rollback completed");
@@ -6475,11 +6475,11 @@ async function Wu(e) {
6475
6475
  SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
6476
6476
  SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
6477
6477
  SUM(CASE WHEN CHAR_LENGTH(template_id) > 64 THEN 1 ELSE 0 END) AS long_template_id
6478
- FROM hooks`.execute(e), l = Number(((i = c[0]) == null ? void 0 : i.long_hook_id) ?? 0), _ = Number(((u = c[0]) == null ? void 0 : u.long_form_id) ?? 0), m = Number(((d = c[0]) == null ? void 0 : d.long_template_id) ?? 0), p = [];
6479
- if (l > 0 && p.push(`${l} row(s) with hook_id longer than 21 chars`), _ > 0 && p.push(
6480
- `${_} row(s) with form_id longer than 128 chars`
6481
- ), m > 0 && p.push(
6482
- `${m} row(s) with template_id longer than 64 chars`
6478
+ FROM hooks`.execute(e), l = Number(((i = c[0]) == null ? void 0 : i.long_hook_id) ?? 0), m = Number(((u = c[0]) == null ? void 0 : u.long_form_id) ?? 0), _ = Number(((d = c[0]) == null ? void 0 : d.long_template_id) ?? 0), p = [];
6479
+ if (l > 0 && p.push(`${l} row(s) with hook_id longer than 21 chars`), m > 0 && p.push(
6480
+ `${m} row(s) with form_id longer than 128 chars`
6481
+ ), _ > 0 && p.push(
6482
+ `${_} row(s) with template_id longer than 64 chars`
6483
6483
  ), p.length > 0)
6484
6484
  throw new Error(
6485
6485
  `Preflight length check failed: ${p.join("; ")}. Truncate or fix oversized values before running this migration.`