@authhero/kysely-adapter 10.122.0 → 10.123.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
  }
@@ -685,7 +685,7 @@ function pe(e) {
685
685
  };
686
686
  return e.session_cookie && typeof e.session_cookie == "string" && (t.session_cookie = JSON.parse(e.session_cookie)), e.enabled_locales && typeof e.enabled_locales == "string" && (t.enabled_locales = JSON.parse(e.enabled_locales)), e.error_page && typeof e.error_page == "string" && (t.error_page = JSON.parse(e.error_page)), e.flags && typeof e.flags == "string" && (t.flags = JSON.parse(e.flags)), e.sandbox_versions_available && typeof e.sandbox_versions_available == "string" && (t.sandbox_versions_available = JSON.parse(
687
687
  e.sandbox_versions_available
688
- )), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), w(t);
688
+ )), e.change_password && typeof e.change_password == "string" && (t.change_password = JSON.parse(e.change_password)), e.guardian_mfa_page && typeof e.guardian_mfa_page == "string" && (t.guardian_mfa_page = JSON.parse(e.guardian_mfa_page)), e.sessions && typeof e.sessions == "string" && (t.sessions = JSON.parse(e.sessions)), e.oidc_logout && typeof e.oidc_logout == "string" && (t.oidc_logout = JSON.parse(e.oidc_logout)), e.device_flow && typeof e.device_flow == "string" && (t.device_flow = JSON.parse(e.device_flow)), e.default_token_quota && typeof e.default_token_quota == "string" && (t.default_token_quota = JSON.parse(e.default_token_quota)), e.allowed_logout_urls && typeof e.allowed_logout_urls == "string" && (t.allowed_logout_urls = JSON.parse(e.allowed_logout_urls)), e.acr_values_supported && typeof e.acr_values_supported == "string" && (t.acr_values_supported = JSON.parse(e.acr_values_supported)), e.mtls && typeof e.mtls == "string" && (t.mtls = JSON.parse(e.mtls)), e.mfa && typeof e.mfa == "string" && (t.mfa = JSON.parse(e.mfa)), e.allow_organization_name_in_authentication_api !== void 0 && (t.allow_organization_name_in_authentication_api = e.allow_organization_name_in_authentication_api === 1), e.customize_mfa_in_postlogin_action !== void 0 && (t.customize_mfa_in_postlogin_action = e.customize_mfa_in_postlogin_action === 1), e.pushed_authorization_requests_supported !== void 0 && (t.pushed_authorization_requests_supported = e.pushed_authorization_requests_supported === 1), e.authorization_response_iss_parameter_supported !== void 0 && (t.authorization_response_iss_parameter_supported = e.authorization_response_iss_parameter_supported === 1), t.session_lifetime ?? (t.session_lifetime = 168), t.idle_session_lifetime ?? (t.idle_session_lifetime = 72), w(t);
689
689
  }
690
690
  function fe(e) {
691
691
  const t = { ...e };
@@ -715,7 +715,9 @@ 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
+ session_lifetime: 168,
720
+ idle_session_lifetime: 72,
719
721
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
720
722
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
721
723
  ...t
@@ -747,21 +749,21 @@ function pt(e) {
747
749
  q: i
748
750
  } = t || {};
749
751
  if (s && s.sort_by) {
750
- const { ref: m } = e.dynamic;
751
- a = a.orderBy(m(s.sort_by), s.sort_order);
752
+ const { ref: _ } = e.dynamic;
753
+ a = a.orderBy(_(s.sort_by), s.sort_order);
752
754
  }
753
- i && (a = O(e, a, i, ["friendly_name"]));
755
+ i && (a = k(e, a, i, ["friendly_name"]));
754
756
  const c = (await a.offset(n * o).limit(o).selectAll().execute()).map(pe);
755
757
  if (!r)
756
758
  return {
757
759
  tenants: c
758
760
  };
759
- const { count: l } = await a.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = k(l);
761
+ const { count: l } = await a.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = $(l);
760
762
  return {
761
763
  tenants: c,
762
764
  start: n * o,
763
765
  limit: o,
764
- length: _
766
+ length: m
765
767
  };
766
768
  };
767
769
  }
@@ -794,7 +796,7 @@ const yt = 256;
794
796
  function vt(e) {
795
797
  return async (t, a) => {
796
798
  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;
799
+ const n = (i = a.user_agent) == null ? void 0 : i.slice(0, yt), o = a.log_id || E(), { location_info: r, ...s } = a;
798
800
  return await e.insertInto("logs").values({
799
801
  ...s,
800
802
  log_id: o,
@@ -853,11 +855,11 @@ function Ct(e) {
853
855
  return async (t, a = {}) => {
854
856
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
855
857
  let u = e.selectFrom("logs").where("logs.tenant_id", "=", t);
856
- i && (u = O(e, u, i, ["user_id", "ip"]));
858
+ i && (u = k(e, u, i, ["user_id", "ip"]));
857
859
  let d = u;
858
860
  if (s && s.sort_by) {
859
- const { ref: m } = e.dynamic;
860
- d = d.orderBy(m(s.sort_by), s.sort_order);
861
+ const { ref: _ } = e.dynamic;
862
+ d = d.orderBy(_(s.sort_by), s.sort_order);
861
863
  }
862
864
  d = d.offset(n * o).limit(o);
863
865
  const l = (await d.selectAll().execute()).map(ge);
@@ -868,12 +870,12 @@ function Ct(e) {
868
870
  limit: 0,
869
871
  length: 0
870
872
  };
871
- const { count: _ } = await u.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
873
+ const { count: m } = await u.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
872
874
  return {
873
875
  logs: l,
874
876
  start: n * o,
875
877
  limit: o,
876
- length: k(_)
878
+ length: $(m)
877
879
  };
878
880
  };
879
881
  }
@@ -904,8 +906,8 @@ function Nt(e) {
904
906
  expires_at_ts: d,
905
907
  idle_expires_at_ts: c,
906
908
  authenticated_at_ts: l,
907
- last_interaction_at_ts: _,
908
- used_at_ts: m,
909
+ last_interaction_at_ts: m,
910
+ used_at_ts: _,
909
911
  revoked_at_ts: p,
910
912
  ...f
911
913
  } = n, g = z(
@@ -915,8 +917,8 @@ function Nt(e) {
915
917
  expires_at_ts: d,
916
918
  idle_expires_at_ts: c,
917
919
  authenticated_at_ts: l,
918
- last_interaction_at_ts: _,
919
- used_at_ts: m,
920
+ last_interaction_at_ts: m,
921
+ used_at_ts: _,
920
922
  revoked_at_ts: p
921
923
  },
922
924
  [
@@ -950,19 +952,19 @@ function bt(e) {
950
952
  revoked_at: d,
951
953
  device: c,
952
954
  clients: l,
953
- ..._
955
+ ...m
954
956
  } = a;
955
957
  return await e.insertInto("sessions").values({
956
- ..._,
958
+ ...m,
957
959
  tenant_id: t,
958
960
  created_at_ts: n,
959
961
  updated_at_ts: n,
960
962
  authenticated_at_ts: n,
961
963
  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),
964
+ expires_at_ts: x(s),
965
+ idle_expires_at_ts: x(i),
966
+ used_at_ts: x(u),
967
+ revoked_at_ts: x(d),
966
968
  device: JSON.stringify(c),
967
969
  clients: JSON.stringify(l)
968
970
  }).execute(), r;
@@ -978,16 +980,16 @@ function Ot(e) {
978
980
  device: n.device ? JSON.stringify(n.device) : void 0,
979
981
  clients: n.clients ? JSON.stringify(n.clients) : void 0
980
982
  };
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(
983
+ 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
984
  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;
985
+ )), 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
986
  };
985
987
  }
986
988
  function kt(e) {
987
989
  return async (t, a = {}) => {
988
990
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
989
991
  let u = e.selectFrom("sessions").where("sessions.tenant_id", "=", t);
990
- i && (u = O(e, u, i, ["user_id", "session_id"]));
992
+ i && (u = k(e, u, i, ["user_id", "session_id"]));
991
993
  let d = u;
992
994
  if (s && s.sort_by) {
993
995
  const { ref: p } = e.dynamic;
@@ -999,22 +1001,22 @@ function kt(e) {
999
1001
  tenant_id: f,
1000
1002
  device: g,
1001
1003
  clients: y,
1002
- created_at_ts: x,
1004
+ created_at_ts: T,
1003
1005
  updated_at_ts: v,
1004
- expires_at_ts: T,
1005
- idle_expires_at_ts: E,
1006
- authenticated_at_ts: I,
1006
+ expires_at_ts: N,
1007
+ idle_expires_at_ts: I,
1008
+ authenticated_at_ts: C,
1007
1009
  last_interaction_at_ts: P,
1008
1010
  used_at_ts: ee,
1009
1011
  revoked_at_ts: Se,
1010
1012
  ...Oe
1011
1013
  } = p, ke = z(
1012
1014
  {
1013
- created_at_ts: x,
1015
+ created_at_ts: T,
1014
1016
  updated_at_ts: v,
1015
- expires_at_ts: T,
1016
- idle_expires_at_ts: E,
1017
- authenticated_at_ts: I,
1017
+ expires_at_ts: N,
1018
+ idle_expires_at_ts: I,
1019
+ authenticated_at_ts: C,
1018
1020
  last_interaction_at_ts: P,
1019
1021
  used_at_ts: ee,
1020
1022
  revoked_at_ts: Se
@@ -1041,12 +1043,12 @@ function kt(e) {
1041
1043
  limit: 0,
1042
1044
  length: 0
1043
1045
  };
1044
- const { count: _ } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = k(_);
1046
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
1045
1047
  return {
1046
1048
  sessions: l,
1047
1049
  start: n * o,
1048
1050
  limit: o,
1049
- length: m
1051
+ length: _
1050
1052
  };
1051
1053
  };
1052
1054
  }
@@ -1073,7 +1075,7 @@ function Et(e) {
1073
1075
  }
1074
1076
  function It(e) {
1075
1077
  return async (t, a) => {
1076
- const n = a.id || $(), o = a.is_current ?? !0, r = {
1078
+ const n = a.id || E(), o = a.is_current ?? !0, r = {
1077
1079
  id: n,
1078
1080
  ...a,
1079
1081
  is_current: o,
@@ -1119,9 +1121,9 @@ function At(e) {
1119
1121
  return async (t, a = {}) => {
1120
1122
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1121
1123
  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 } = _;
1124
+ s && (i = k(e, i, s, ["code", "login_id"]));
1125
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
1126
+ const { tenant_id: _, ...p } = m;
1125
1127
  return Pe.parse(w(p));
1126
1128
  });
1127
1129
  if (!r)
@@ -1131,12 +1133,12 @@ function At(e) {
1131
1133
  limit: 0,
1132
1134
  length: 0
1133
1135
  };
1134
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1136
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1135
1137
  return {
1136
1138
  codes: c,
1137
1139
  start: n * o,
1138
1140
  limit: o,
1139
- length: k(l)
1141
+ length: $(l)
1140
1142
  };
1141
1143
  };
1142
1144
  }
@@ -1212,7 +1214,7 @@ function Ut(e) {
1212
1214
  return async (t, a = {}) => {
1213
1215
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
1214
1216
  let i = e.selectFrom("connections").where("connections.tenant_id", "=", t);
1215
- s && (i = O(e, i, s, ["user_id", "ip"]));
1217
+ s && (i = k(e, i, s, ["user_id", "ip"]));
1216
1218
  const d = await i.offset(n * o).limit(o).selectAll().execute(), c = qt(d);
1217
1219
  if (!r)
1218
1220
  return {
@@ -1221,12 +1223,12 @@ function Ut(e) {
1221
1223
  limit: 0,
1222
1224
  length: 0
1223
1225
  };
1224
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1226
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1225
1227
  return {
1226
1228
  connections: c,
1227
1229
  start: n * o,
1228
1230
  limit: o,
1229
- length: k(l)
1231
+ length: $(l)
1230
1232
  };
1231
1233
  };
1232
1234
  }
@@ -1443,9 +1445,9 @@ function Xt(e) {
1443
1445
  if (a != null && a.include_totals) {
1444
1446
  let c = e.selectFrom("clients").select(h`count(*)`.as("count")).where("clients.tenant_id", "=", t);
1445
1447
  a != null && a.q && (c = c.where(
1446
- (_) => _.or([
1447
- _("name", "like", `%${a.q}%`),
1448
- _("client_id", "like", `%${a.q}%`)
1448
+ (m) => m.or([
1449
+ m("name", "like", `%${a.q}%`),
1450
+ m("client_id", "like", `%${a.q}%`)
1449
1451
  ])
1450
1452
  ));
1451
1453
  const l = await c.executeTakeFirst();
@@ -1630,7 +1632,7 @@ function ia(e) {
1630
1632
  }
1631
1633
  function ca(e) {
1632
1634
  return async (t, a) => {
1633
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = $(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1635
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = E(), { scope: r, authorization_details_types: s, ...i } = a, u = {
1634
1636
  id: o,
1635
1637
  tenant_id: t,
1636
1638
  ...i,
@@ -1683,38 +1685,38 @@ function da(e) {
1683
1685
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1684
1686
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1685
1687
  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") {
1688
+ 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 || "");
1689
+ if (g && !T && y) {
1690
+ const v = !!g[1], N = g[2], { ref: I } = e.dynamic, C = I(`client_grants.${N}`);
1691
+ if (N === "allow_any_organization") {
1690
1692
  const P = y === "true" ? 1 : 0;
1691
- v ? u = u.where(I, "!=", P) : u = u.where(I, "=", P);
1693
+ v ? u = u.where(C, "!=", P) : u = u.where(C, "=", P);
1692
1694
  } else
1693
- v ? u = u.where(I, "!=", y) : u = u.where(I, "=", y);
1695
+ v ? u = u.where(C, "!=", y) : u = u.where(C, "=", y);
1694
1696
  } else
1695
- u = O(e, u, m, []);
1697
+ u = k(e, u, _, []);
1696
1698
  }
1697
1699
  let d = u;
1698
1700
  if (i) {
1699
- const { ref: m } = e.dynamic;
1700
- d = d.orderBy(m(i.sort_by), i.sort_order);
1701
+ const { ref: _ } = e.dynamic;
1702
+ d = d.orderBy(_(i.sort_by), i.sort_order);
1701
1703
  } else
1702
1704
  d = d.orderBy("client_grants.created_at", "desc");
1703
1705
  d = d.limit(o).offset(n * o);
1704
- const l = (await d.selectAll().execute()).map((m) => {
1706
+ const l = (await d.selectAll().execute()).map((_) => {
1705
1707
  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,
1708
+ id: _.id,
1709
+ client_id: _.client_id,
1710
+ audience: _.audience,
1711
+ scope: _.scope ? JSON.parse(_.scope) : [],
1712
+ organization_usage: _.organization_usage,
1711
1713
  // 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
1714
+ allow_any_organization: _.allow_any_organization !== void 0 ? !!_.allow_any_organization : !1,
1715
+ is_system: _.is_system !== void 0 ? !!_.is_system : !1,
1716
+ subject_type: _.subject_type,
1717
+ authorization_details_types: _.authorization_details_types ? JSON.parse(_.authorization_details_types) : [],
1718
+ created_at: _.created_at,
1719
+ updated_at: _.updated_at
1718
1720
  };
1719
1721
  return w(p);
1720
1722
  });
@@ -1725,12 +1727,12 @@ function da(e) {
1725
1727
  limit: 0,
1726
1728
  length: 0
1727
1729
  };
1728
- const { count: _ } = await u.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
1730
+ const { count: m } = await u.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
1729
1731
  return {
1730
1732
  client_grants: l,
1731
1733
  start: n * o,
1732
1734
  limit: o,
1733
- length: k(_)
1735
+ length: $(m)
1734
1736
  };
1735
1737
  };
1736
1738
  }
@@ -1767,19 +1769,19 @@ function ha(e) {
1767
1769
  q: s
1768
1770
  } = t;
1769
1771
  let i = e.selectFrom("keys").where(
1770
- (m) => m.or([
1771
- m("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1772
- m("revoked_at", "is", null)
1772
+ (_) => _.or([
1773
+ _("revoked_at", ">", (/* @__PURE__ */ new Date()).toISOString()),
1774
+ _("revoked_at", "is", null)
1773
1775
  ])
1774
1776
  );
1775
- s && (i = O(e, i, s, [
1777
+ s && (i = k(e, i, s, [
1776
1778
  "kid",
1777
1779
  "connection",
1778
1780
  "fingerprint",
1779
1781
  "thumbprint",
1780
1782
  "type"
1781
1783
  ]));
1782
- let u = i.select((m) => m.fn.count("kid").as("count"));
1784
+ let u = i.select((_) => _.fn.count("kid").as("count"));
1783
1785
  const d = a * n;
1784
1786
  i = i.limit(n).offset(d), r && (i = i.orderBy(r.sort_by, r.sort_order));
1785
1787
  const c = await i.selectAll().execute();
@@ -1790,12 +1792,12 @@ function ha(e) {
1790
1792
  limit: 0,
1791
1793
  length: 0
1792
1794
  };
1793
- const l = await u.executeTakeFirst(), _ = k((l == null ? void 0 : l.count) ?? 0);
1795
+ const l = await u.executeTakeFirst(), m = $((l == null ? void 0 : l.count) ?? 0);
1794
1796
  return {
1795
1797
  signingKeys: c,
1796
1798
  start: d,
1797
1799
  limit: n,
1798
- length: _
1800
+ length: m
1799
1801
  };
1800
1802
  };
1801
1803
  }
@@ -1817,7 +1819,7 @@ function ga(e) {
1817
1819
  function wa(e) {
1818
1820
  return async (t, a) => {
1819
1821
  const n = {
1820
- custom_domain_id: a.custom_domain_id || $(),
1822
+ custom_domain_id: a.custom_domain_id || E(),
1821
1823
  status: "pending",
1822
1824
  primary: !1,
1823
1825
  ...a
@@ -1933,7 +1935,7 @@ function ba(e) {
1933
1935
  }
1934
1936
  function Sa(e) {
1935
1937
  return async (t, a) => {
1936
- var s, i, u, d, c, l, _, m, p, f, g, y, x, v, T, E, I, P;
1938
+ var s, i, u, d, c, l, m, _, p, f, g, y, T, v, N, I, C, P;
1937
1939
  const { colors: n, font: o, ...r } = a;
1938
1940
  try {
1939
1941
  await e.insertInto("branding").values({
@@ -1942,7 +1944,7 @@ function Sa(e) {
1942
1944
  colors_page_background_type: (i = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : i.type,
1943
1945
  colors_page_background_start: (d = (u = a.colors) == null ? void 0 : u.page_background) == null ? void 0 : d.start,
1944
1946
  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,
1947
+ colors_page_background_angle_dev: (_ = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : _.angle_deg,
1946
1948
  font_url: (p = a.font) == null ? void 0 : p.url,
1947
1949
  tenant_id: t
1948
1950
  }).execute();
@@ -1951,9 +1953,9 @@ function Sa(e) {
1951
1953
  ...r,
1952
1954
  colors_primary: n == null ? void 0 : n.primary,
1953
1955
  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,
1956
+ colors_page_background_start: (T = (y = a.colors) == null ? void 0 : y.page_background) == null ? void 0 : T.start,
1957
+ colors_page_background_end: (N = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : N.end,
1958
+ colors_page_background_angle_dev: (C = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : C.angle_deg,
1957
1959
  font_url: (P = a.font) == null ? void 0 : P.url
1958
1960
  }).where("tenant_id", "=", t).execute();
1959
1961
  }
@@ -2007,26 +2009,26 @@ function za(e) {
2007
2009
  return async (t, a = {}) => {
2008
2010
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2009
2011
  let i = e.selectFrom("hooks").where("hooks.tenant_id", "=", t);
2010
- s && (i = O(e, i, s, [
2012
+ s && (i = k(e, i, s, [
2011
2013
  "url",
2012
2014
  "form_id",
2013
2015
  "template_id",
2014
2016
  "code_id"
2015
2017
  ]));
2016
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
2018
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2017
2019
  const {
2018
- tenant_id: m,
2020
+ tenant_id: _,
2019
2021
  enabled: p,
2020
2022
  synchronous: f,
2021
2023
  created_at_ts: g,
2022
2024
  updated_at_ts: y,
2023
- ...x
2024
- } = _, v = z({ created_at_ts: g, updated_at_ts: y }, [
2025
+ ...T
2026
+ } = m, v = z({ created_at_ts: g, updated_at_ts: y }, [
2025
2027
  "created_at_ts",
2026
2028
  "updated_at_ts"
2027
2029
  ]);
2028
2030
  return w({
2029
- ...x,
2031
+ ...T,
2030
2032
  ...v,
2031
2033
  enabled: !!p,
2032
2034
  synchronous: !!f
@@ -2039,12 +2041,12 @@ function za(e) {
2039
2041
  limit: 0,
2040
2042
  length: 0
2041
2043
  };
2042
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2044
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2043
2045
  return {
2044
2046
  hooks: c,
2045
2047
  start: n * o,
2046
2048
  limit: o,
2047
- length: k(l)
2049
+ length: $(l)
2048
2050
  };
2049
2051
  };
2050
2052
  }
@@ -2179,7 +2181,7 @@ function Ka(e) {
2179
2181
  function qa(e) {
2180
2182
  return async (t, a, n) => {
2181
2183
  const o = {
2182
- themeId: n || $(),
2184
+ themeId: n || E(),
2183
2185
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2184
2186
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
2185
2187
  ...a
@@ -2307,7 +2309,7 @@ function Za(e) {
2307
2309
  updated_at_ts: Date.now(),
2308
2310
  // Only update expires_at_ts if a new expires_at was provided
2309
2311
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2310
- ...s !== void 0 ? { expires_at_ts: C(s) } : {}
2312
+ ...s !== void 0 ? { expires_at_ts: x(s) } : {}
2311
2313
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2312
2314
  };
2313
2315
  }
@@ -2463,17 +2465,17 @@ function _n(e) {
2463
2465
  resource_servers: d,
2464
2466
  rotating: c,
2465
2467
  ...l
2466
- } = a, _ = Date.now();
2468
+ } = a, m = Date.now();
2467
2469
  return await e.insertInto("refresh_tokens").values({
2468
2470
  ...l,
2469
2471
  tenant_id: t,
2470
2472
  rotating: c ? 1 : 0,
2471
2473
  device: JSON.stringify(u),
2472
2474
  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
2475
+ created_at_ts: m,
2476
+ expires_at_ts: x(r),
2477
+ idle_expires_at_ts: s ? x(s) : null,
2478
+ last_exchanged_at_ts: i ? x(i) : null
2477
2479
  }).execute(), { ...a, ...o };
2478
2480
  };
2479
2481
  }
@@ -2491,25 +2493,25 @@ function hn(e) {
2491
2493
  resource_servers: d,
2492
2494
  rotating: c,
2493
2495
  ...l
2494
- } = n, _ = {
2496
+ } = n, m = {
2495
2497
  ...l,
2496
2498
  device: u ? JSON.stringify(u) : void 0,
2497
2499
  resource_servers: d ? JSON.stringify(d) : void 0,
2498
2500
  rotating: c !== void 0 ? c ? 1 : 0 : void 0,
2499
2501
  // Convert date fields to bigint format
2500
2502
  // 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
2503
+ expires_at_ts: r !== void 0 ? x(r) : void 0,
2504
+ idle_expires_at_ts: s !== void 0 ? x(s) : void 0,
2505
+ last_exchanged_at_ts: i !== void 0 ? x(i) : void 0
2504
2506
  };
2505
- return !!(await e.updateTable("refresh_tokens").set(_).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length;
2507
+ return !!(await e.updateTable("refresh_tokens").set(m).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length;
2506
2508
  };
2507
2509
  }
2508
2510
  function pn(e) {
2509
2511
  return async (t, a = {}) => {
2510
2512
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, sort: s, q: i } = a;
2511
2513
  let u = e.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", t);
2512
- i && (u = O(e, u, i, ["token", "login_id"]));
2514
+ i && (u = k(e, u, i, ["token", "login_id"]));
2513
2515
  let d = u;
2514
2516
  if (s && s.sort_by) {
2515
2517
  const { ref: p } = e.dynamic;
@@ -2521,22 +2523,22 @@ function pn(e) {
2521
2523
  tenant_id: f,
2522
2524
  created_at_ts: g,
2523
2525
  expires_at_ts: y,
2524
- idle_expires_at_ts: x,
2526
+ idle_expires_at_ts: T,
2525
2527
  last_exchanged_at_ts: v,
2526
- ...T
2527
- } = p, E = z(
2528
+ ...N
2529
+ } = p, I = z(
2528
2530
  {
2529
2531
  created_at_ts: g,
2530
2532
  expires_at_ts: y,
2531
- idle_expires_at_ts: x,
2533
+ idle_expires_at_ts: T,
2532
2534
  last_exchanged_at_ts: v
2533
2535
  },
2534
2536
  ["created_at_ts"],
2535
2537
  ["expires_at_ts", "idle_expires_at_ts", "last_exchanged_at_ts"]
2536
2538
  );
2537
2539
  return {
2538
- ...T,
2539
- ...E,
2540
+ ...N,
2541
+ ...I,
2540
2542
  rotating: !!p.rotating,
2541
2543
  device: p.device ? JSON.parse(p.device) : {},
2542
2544
  resource_servers: p.resource_servers ? JSON.parse(p.resource_servers) : []
@@ -2549,12 +2551,12 @@ function pn(e) {
2549
2551
  limit: 0,
2550
2552
  length: 0
2551
2553
  };
2552
- const { count: _ } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), m = k(_);
2554
+ const { count: m } = await u.select((p) => p.fn.countAll().as("count")).executeTakeFirstOrThrow(), _ = $(m);
2553
2555
  return {
2554
2556
  refresh_tokens: l,
2555
2557
  start: n * o,
2556
2558
  limit: o,
2557
- length: m
2559
+ length: _
2558
2560
  };
2559
2561
  };
2560
2562
  }
@@ -2575,53 +2577,53 @@ function wn(e) {
2575
2577
  try {
2576
2578
  let c = 0;
2577
2579
  for (; ; ) {
2578
- let m = e.deleteFrom("refresh_tokens").where(
2580
+ let _ = e.deleteFrom("refresh_tokens").where(
2579
2581
  (g) => g.or([
2580
2582
  g("expires_at_ts", "<", r),
2581
2583
  g("idle_expires_at_ts", "<", r)
2582
2584
  ])
2583
2585
  );
2584
- a && (m = m.where(
2586
+ a && (_ = _.where(
2585
2587
  "tenant_id",
2586
2588
  "=",
2587
2589
  a
2588
- )), n && (m = m.where(
2590
+ )), n && (_ = _.where(
2589
2591
  "user_id",
2590
2592
  "=",
2591
2593
  n
2592
2594
  ));
2593
- const p = await m.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
2595
+ const p = await _.limit(s).execute(), f = Number(((i = p[0]) == null ? void 0 : i.numDeletedRows) ?? 0);
2594
2596
  if (c += f, f < s) break;
2595
2597
  }
2596
2598
  let l = 0;
2597
2599
  for (; ; ) {
2598
- let m = e.deleteFrom("sessions").where(
2600
+ let _ = e.deleteFrom("sessions").where(
2599
2601
  (g) => g.or([
2600
2602
  g("expires_at_ts", "<", r),
2601
2603
  g("idle_expires_at_ts", "<", r)
2602
2604
  ])
2603
2605
  );
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);
2606
+ a && (_ = _.where("tenant_id", "=", a)), n && (_ = _.where("user_id", "=", n));
2607
+ const p = await _.limit(s).execute(), f = Number(((u = p[0]) == null ? void 0 : u.numDeletedRows) ?? 0);
2606
2608
  if (l += f, f < s) break;
2607
2609
  }
2608
- let _ = 0;
2610
+ let m = 0;
2609
2611
  for (; ; ) {
2610
- let m = e.deleteFrom("login_sessions").where("expires_at_ts", "<", r);
2611
- a && (m = m.where(
2612
+ let _ = e.deleteFrom("login_sessions").where("expires_at_ts", "<", r);
2613
+ a && (_ = _.where(
2612
2614
  "tenant_id",
2613
2615
  "=",
2614
2616
  a
2615
- )), n && (m = m.where(
2617
+ )), n && (_ = _.where(
2616
2618
  "user_id",
2617
2619
  "=",
2618
2620
  n
2619
2621
  ));
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;
2622
+ const p = await _.limit(s).execute(), f = Number(((d = p[0]) == null ? void 0 : d.numDeletedRows) ?? 0);
2623
+ if (m += f, f < s) break;
2622
2624
  }
2623
- (c > 0 || l > 0 || _ > 0) && console.log(
2624
- `Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${_} login_sessions`
2625
+ (c > 0 || l > 0 || m > 0) && console.log(
2626
+ `Session cleanup: deleted ${c} refresh_tokens, ${l} sessions, ${m} login_sessions`
2625
2627
  );
2626
2628
  } catch (c) {
2627
2629
  console.error("Error during session cleanup:", c);
@@ -2631,7 +2633,7 @@ function wn(e) {
2631
2633
  function yn(e) {
2632
2634
  return async (t, a) => {
2633
2635
  const n = q.parse({
2634
- id: $(),
2636
+ id: E(),
2635
2637
  ...a,
2636
2638
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
2637
2639
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -2650,25 +2652,25 @@ function vn(e) {
2650
2652
  return async (t, a = {}) => {
2651
2653
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2652
2654
  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")
2655
+ s && (i = k(e, i, s, []));
2656
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2657
+ const _ = { ...m };
2658
+ if (typeof _.nodes == "string")
2657
2659
  try {
2658
- m.nodes = JSON.parse(m.nodes);
2660
+ _.nodes = JSON.parse(_.nodes);
2659
2661
  } catch {
2660
2662
  }
2661
- if (typeof m.start == "string")
2663
+ if (typeof _.start == "string")
2662
2664
  try {
2663
- m.start = JSON.parse(m.start);
2665
+ _.start = JSON.parse(_.start);
2664
2666
  } catch {
2665
2667
  }
2666
- if (typeof m.ending == "string")
2668
+ if (typeof _.ending == "string")
2667
2669
  try {
2668
- m.ending = JSON.parse(m.ending);
2670
+ _.ending = JSON.parse(_.ending);
2669
2671
  } catch {
2670
2672
  }
2671
- return q.parse(w(m));
2673
+ return q.parse(w(_));
2672
2674
  });
2673
2675
  if (!r)
2674
2676
  return {
@@ -2677,12 +2679,12 @@ function vn(e) {
2677
2679
  limit: 0,
2678
2680
  length: 0
2679
2681
  };
2680
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2682
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2681
2683
  return {
2682
2684
  forms: c,
2683
2685
  start: n * o,
2684
2686
  limit: o,
2685
- length: k(l)
2687
+ length: $(l)
2686
2688
  };
2687
2689
  };
2688
2690
  }
@@ -2749,17 +2751,17 @@ function bn(e) {
2749
2751
  skip_consent_for_verifiable_first_party_clients: d,
2750
2752
  allow_offline_access: c,
2751
2753
  is_system: l,
2752
- metadata: _,
2753
- ...m
2754
+ metadata: m,
2755
+ ..._
2754
2756
  } = r, p = {
2755
- ...m,
2757
+ ..._,
2756
2758
  tenant_id: t,
2757
2759
  scopes: i ? JSON.stringify(i) : "[]",
2758
2760
  options: u ? JSON.stringify(u) : "{}",
2759
2761
  skip_consent_for_verifiable_first_party_clients: d ? 1 : 0,
2760
2762
  allow_offline_access: c ? 1 : 0,
2761
2763
  is_system: l ? 1 : 0,
2762
- metadata: _ ? JSON.stringify(_) : void 0,
2764
+ metadata: m ? JSON.stringify(m) : void 0,
2763
2765
  verification_key: s,
2764
2766
  created_at: n,
2765
2767
  updated_at: n
@@ -2779,9 +2781,9 @@ function Sn(e) {
2779
2781
  allow_offline_access: d,
2780
2782
  is_system: c,
2781
2783
  metadata: l,
2782
- ..._
2783
- } = o, m = {
2784
- ..._,
2784
+ ...m
2785
+ } = o, _ = w({
2786
+ ...m,
2785
2787
  scopes: s ? JSON.parse(s) : [],
2786
2788
  options: i ? JSON.parse(i) : {},
2787
2789
  skip_consent_for_verifiable_first_party_clients: !!u,
@@ -2790,8 +2792,8 @@ function Sn(e) {
2790
2792
  metadata: l ? JSON.parse(l) : void 0,
2791
2793
  // Convert verification_key back to verificationKey for API
2792
2794
  verificationKey: r
2793
- };
2794
- return w(m);
2795
+ });
2796
+ return _.token_lifetime ?? (_.token_lifetime = 86400), _.token_lifetime_for_web ?? (_.token_lifetime_for_web = 7200), _;
2795
2797
  };
2796
2798
  }
2797
2799
  function On(e) {
@@ -2799,38 +2801,38 @@ function On(e) {
2799
2801
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
2800
2802
  let i = e.selectFrom("resource_servers").where("resource_servers.tenant_id", "=", t);
2801
2803
  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 || "");
2804
+ 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
2805
  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}%`);
2806
+ const T = !!f[1], v = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2807
+ i = T ? i.where(v, "not like", `%${g}%`) : i.where(v, "like", `%${g}%`);
2806
2808
  } else
2807
- i = O(e, i, _, [
2809
+ i = k(e, i, m, [
2808
2810
  "resource_servers.name",
2809
2811
  "resource_servers.identifier"
2810
2812
  ]);
2811
2813
  }
2812
- const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((_) => {
2813
- const m = _, {
2814
+ const c = (await i.offset(n * o).limit(o).selectAll().execute()).map((m) => {
2815
+ const _ = m, {
2814
2816
  verification_key: p,
2815
2817
  scopes: f,
2816
2818
  options: g,
2817
2819
  skip_consent_for_verifiable_first_party_clients: y,
2818
- allow_offline_access: x,
2820
+ allow_offline_access: T,
2819
2821
  is_system: v,
2820
- metadata: T,
2821
- ...E
2822
- } = m, I = {
2823
- ...E,
2822
+ metadata: N,
2823
+ ...I
2824
+ } = _, C = w({
2825
+ ...I,
2824
2826
  scopes: f ? JSON.parse(f) : [],
2825
2827
  options: g ? JSON.parse(g) : {},
2826
2828
  skip_consent_for_verifiable_first_party_clients: !!y,
2827
- allow_offline_access: !!x,
2829
+ allow_offline_access: !!T,
2828
2830
  is_system: v ? !0 : void 0,
2829
- metadata: T ? JSON.parse(T) : void 0,
2831
+ metadata: N ? JSON.parse(N) : void 0,
2830
2832
  // Convert verification_key back to verificationKey for API
2831
2833
  verificationKey: p
2832
- };
2833
- return w(I);
2834
+ });
2835
+ return C.token_lifetime ?? (C.token_lifetime = 86400), C.token_lifetime_for_web ?? (C.token_lifetime_for_web = 7200), C;
2834
2836
  });
2835
2837
  if (!r)
2836
2838
  return {
@@ -2839,12 +2841,12 @@ function On(e) {
2839
2841
  limit: 0,
2840
2842
  length: 0
2841
2843
  };
2842
- const { count: l } = await i.select((_) => _.fn.countAll().as("count")).executeTakeFirstOrThrow();
2844
+ const { count: l } = await i.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
2843
2845
  return {
2844
2846
  resource_servers: c,
2845
2847
  start: n * o,
2846
2848
  limit: o,
2847
- length: k(l)
2849
+ length: $(l)
2848
2850
  };
2849
2851
  };
2850
2852
  }
@@ -2865,17 +2867,17 @@ function $n(e) {
2865
2867
  is_system: d,
2866
2868
  metadata: c,
2867
2869
  ...l
2868
- } = n, _ = {
2870
+ } = n, m = {
2869
2871
  ...l,
2870
2872
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
2871
2873
  };
2872
- if (o !== void 0 && (_.verification_key = o), r !== void 0 && (_.scopes = JSON.stringify(r)), s !== void 0) {
2874
+ if (o !== void 0 && (m.verification_key = o), r !== void 0 && (m.scopes = JSON.stringify(r)), s !== void 0) {
2873
2875
  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);
2876
+ m.options = JSON.stringify(g);
2875
2877
  }
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;
2878
+ 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);
2879
+ const _ = await e.updateTable("resource_servers").set(m).where("tenant_id", "=", t).where("id", "=", a).executeTakeFirst();
2880
+ return Number(_.numUpdatedRows) > 0;
2879
2881
  };
2880
2882
  }
2881
2883
  function En(e) {
@@ -2889,7 +2891,7 @@ function En(e) {
2889
2891
  }
2890
2892
  function In(e) {
2891
2893
  return async (t, a) => {
2892
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || $(), { is_system: r, id: s, metadata: i, ...u } = a, d = {
2894
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = a.id || E(), { is_system: r, id: s, metadata: i, ...u } = a, d = {
2893
2895
  id: o,
2894
2896
  ...u,
2895
2897
  tenant_id: t,
@@ -2924,12 +2926,12 @@ function Pn(e) {
2924
2926
  return async (t, a) => {
2925
2927
  let n = e.selectFrom("roles").where("roles.tenant_id", "=", t);
2926
2928
  const { page: o = 0, per_page: r = 50, include_totals: s = !1 } = a;
2927
- a.q && (n = O(e, n, a.q, ["name"]));
2929
+ a.q && (n = k(e, n, a.q, ["name"]));
2928
2930
  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 } = _;
2931
+ const m = l, { is_system: _, tenant_id: p, metadata: f, ...g } = m;
2930
2932
  return {
2931
2933
  ...g,
2932
- is_system: m ? !0 : void 0,
2934
+ is_system: _ ? !0 : void 0,
2933
2935
  metadata: f ? JSON.parse(f) : void 0
2934
2936
  };
2935
2937
  });
@@ -2945,7 +2947,7 @@ function Pn(e) {
2945
2947
  roles: d,
2946
2948
  start: o * r,
2947
2949
  limit: r,
2948
- length: k(c)
2950
+ length: $(c)
2949
2951
  };
2950
2952
  };
2951
2953
  }
@@ -3275,9 +3277,9 @@ function Zn(e) {
3275
3277
  if (a != null && a.include_totals) {
3276
3278
  let c = e.selectFrom("organizations").select(h`count(*)`.as("count")).where("tenant_id", "=", t);
3277
3279
  a != null && a.q && (c = c.where(
3278
- (_) => _.or([
3279
- _("name", "like", `%${a.q}%`),
3280
- _("display_name", "like", `%${a.q}%`)
3280
+ (m) => m.or([
3281
+ m("name", "like", `%${a.q}%`),
3282
+ m("display_name", "like", `%${a.q}%`)
3281
3283
  ])
3282
3284
  ));
3283
3285
  const l = await c.executeTakeFirst();
@@ -3329,7 +3331,7 @@ function ao(e) {
3329
3331
  function no(e) {
3330
3332
  return async (t, a) => {
3331
3333
  const n = {
3332
- id: $(),
3334
+ id: E(),
3333
3335
  tenant_id: t,
3334
3336
  user_id: a.user_id,
3335
3337
  organization_id: a.organization_id,
@@ -3798,7 +3800,7 @@ function bo(e) {
3798
3800
  }
3799
3801
  function So(e) {
3800
3802
  return async (t, a) => {
3801
- const n = $();
3803
+ const n = E();
3802
3804
  return await e.insertInto("outbox_events").values({
3803
3805
  id: n,
3804
3806
  tenant_id: t,
@@ -5949,7 +5951,7 @@ async function Ud(e) {
5949
5951
  }
5950
5952
  for (const o of n)
5951
5953
  await e.insertInto("password_history").values({
5952
- id: $(),
5954
+ id: E(),
5953
5955
  user_id: o.user_id,
5954
5956
  tenant_id: o.tenant_id,
5955
5957
  password: o.password,
@@ -6171,7 +6173,7 @@ async function hu(e) {
6171
6173
  return "sqlite";
6172
6174
  }
6173
6175
  }
6174
- async function N(e, t, a, n) {
6176
+ async function b(e, t, a, n) {
6175
6177
  try {
6176
6178
  await e.schema.alterTable(t).addColumn(a, n).execute();
6177
6179
  } catch (o) {
@@ -6186,7 +6188,7 @@ async function N(e, t, a, n) {
6186
6188
  }
6187
6189
  async function pu(e) {
6188
6190
  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();
6191
+ 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
6192
  }
6191
6193
  async function F(e, t, a) {
6192
6194
  try {
@@ -6197,7 +6199,7 @@ async function F(e, t, a) {
6197
6199
  throw n;
6198
6200
  }
6199
6201
  }
6200
- async function b(e, t, a) {
6202
+ async function S(e, t, a) {
6201
6203
  try {
6202
6204
  await e.schema.alterTable(t).dropColumn(a).execute();
6203
6205
  } catch (n) {
@@ -6207,7 +6209,7 @@ async function b(e, t, a) {
6207
6209
  }
6208
6210
  }
6209
6211
  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");
6212
+ 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
6213
  }
6212
6214
  const gu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6213
6215
  __proto__: null,
@@ -6221,7 +6223,7 @@ async function xe(e) {
6221
6223
  return "sqlite";
6222
6224
  }
6223
6225
  }
6224
- async function S(e, t, a) {
6226
+ async function O(e, t, a) {
6225
6227
  try {
6226
6228
  await e.schema.alterTable(t).dropColumn(a).execute();
6227
6229
  } catch (n) {
@@ -6247,7 +6249,7 @@ async function wu(e) {
6247
6249
  ` Warning: Failed to drop index login_sessions_state_updated_idx: ${a instanceof Error ? a.message : String(a)}`
6248
6250
  );
6249
6251
  }
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");
6252
+ 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
6253
  }
6252
6254
  async function yu(e) {
6253
6255
  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 +6477,11 @@ async function Wu(e) {
6475
6477
  SUM(CASE WHEN CHAR_LENGTH(hook_id) > 21 THEN 1 ELSE 0 END) AS long_hook_id,
6476
6478
  SUM(CASE WHEN CHAR_LENGTH(form_id) > 128 THEN 1 ELSE 0 END) AS long_form_id,
6477
6479
  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`
6480
+ 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 = [];
6481
+ if (l > 0 && p.push(`${l} row(s) with hook_id longer than 21 chars`), m > 0 && p.push(
6482
+ `${m} row(s) with form_id longer than 128 chars`
6483
+ ), _ > 0 && p.push(
6484
+ `${_} row(s) with template_id longer than 64 chars`
6483
6485
  ), p.length > 0)
6484
6486
  throw new Error(
6485
6487
  `Preflight length check failed: ${p.join("; ")}. Truncate or fix oversized values before running this migration.`