@authhero/kysely-adapter 10.121.0 → 10.121.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ var Oe = Object.defineProperty;
2
2
  var ke = (e, t, a) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var K = (e, t, a) => ke(e, typeof t != "symbol" ? t + "" : t, a);
4
4
  import { nanoid as k, customAlphabet as $e } from "nanoid";
5
- import { parseUserId as Ee, flowSchema as U, codeSchema as Ie, loginSessionSchema as ze, LoginSessionState as ie, promptSettingSchema as Pe, formSchema as q, resourceServerSchema as De } from "@authhero/adapter-interfaces";
5
+ import { parseUserId as Ee, flowSchema as B, codeSchema as Ie, loginSessionSchema as ze, LoginSessionState as ie, promptSettingSchema as Pe, formSchema as q, resourceServerSchema as De } from "@authhero/adapter-interfaces";
6
6
  import "@hono/zod-openapi";
7
7
  import { sql as h, Migrator as ce } from "kysely";
8
8
  var R = class extends Error {
@@ -64,7 +64,7 @@ function Ae(e) {
64
64
  };
65
65
  e.isTransaction ? await d(e) : await e.transaction().execute(d);
66
66
  } catch (d) {
67
- throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new R(409, { message: "User already exists" }) : new R(500, { message: `${d.code}, ${d.message}` });
67
+ throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.code === "ER_DUP_ENTRY" || d.message.includes("AlreadyExists") ? new R(409, { message: "User already exists" }) : new R(500, { message: `${d.code}, ${d.message}` });
68
68
  }
69
69
  return {
70
70
  ...i,
@@ -104,7 +104,7 @@ const je = [
104
104
  "phone_verified",
105
105
  "username"
106
106
  ];
107
- function B(e, t = !1) {
107
+ function U(e, t = !1) {
108
108
  const a = {
109
109
  connection: e.connection,
110
110
  provider: e.provider,
@@ -146,8 +146,8 @@ function Fe(e) {
146
146
  user_metadata: JSON.parse(n.user_metadata),
147
147
  address: n.address ? JSON.parse(n.address) : void 0,
148
148
  identities: [
149
- B(n, !0),
150
- ...o.map((d) => B(d))
149
+ U(n, !0),
150
+ ...o.map((d) => U(d))
151
151
  ]
152
152
  };
153
153
  return w(i);
@@ -246,8 +246,8 @@ function Re(e) {
246
246
  user_metadata: JSON.parse(f.user_metadata),
247
247
  address: f.address ? JSON.parse(f.address) : void 0,
248
248
  identities: [
249
- B(f, !0),
250
- ...g.map((y) => B(y))
249
+ U(f, !0),
250
+ ...g.map((y) => U(y))
251
251
  ]
252
252
  });
253
253
  });
@@ -337,7 +337,7 @@ function Ke(e) {
337
337
  }
338
338
  function qe(e) {
339
339
  return async (t, a) => {
340
- const n = (/* @__PURE__ */ new Date()).toISOString(), o = U.parse({
340
+ const n = (/* @__PURE__ */ new Date()).toISOString(), o = B.parse({
341
341
  id: `af_${k()}`,
342
342
  ...a,
343
343
  actions: a.actions || [],
@@ -369,7 +369,7 @@ function de(e, t, a = { ...e }) {
369
369
  ));
370
370
  return a;
371
371
  }
372
- function Be(e) {
372
+ function Ue(e) {
373
373
  return async (t, a) => {
374
374
  const n = await e.selectFrom("flows").selectAll().where("flows.id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
375
375
  if (!n) return null;
@@ -377,10 +377,10 @@ function Be(e) {
377
377
  ...n,
378
378
  actions: D(n.actions, [])
379
379
  };
380
- return U.parse(w(o));
380
+ return B.parse(w(o));
381
381
  };
382
382
  }
383
- function Ue(e) {
383
+ function Be(e) {
384
384
  return async (t, a = {}) => {
385
385
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s } = a;
386
386
  let i = e.selectFrom("flows").where("tenant_id", "=", t);
@@ -390,7 +390,7 @@ function Ue(e) {
390
390
  ...m,
391
391
  actions: D(m.actions, [])
392
392
  };
393
- return U.parse(w(_));
393
+ return B.parse(w(_));
394
394
  });
395
395
  if (!r)
396
396
  return {
@@ -418,25 +418,25 @@ function Qe(e) {
418
418
  const { numUpdatedRows: r } = await e.updateTable("flows").set(o).where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
419
419
  if (r === 0n) return null;
420
420
  const s = await e.selectFrom("flows").selectAll().where("id", "=", a).where("tenant_id", "=", t).executeTakeFirst();
421
- return s ? U.parse({
421
+ return s ? B.parse({
422
422
  ...s,
423
423
  actions: s.actions ? JSON.parse(s.actions) : []
424
424
  }) : null;
425
425
  };
426
426
  }
427
- function He(e) {
427
+ function Ye(e) {
428
428
  return async (t, a) => {
429
429
  var o;
430
430
  return (((o = (await e.deleteFrom("flows").where("id", "=", a).where("tenant_id", "=", t).execute())[0]) == null ? void 0 : o.numDeletedRows) ?? 0n) > 0n;
431
431
  };
432
432
  }
433
- function Ye(e) {
433
+ function He(e) {
434
434
  return {
435
435
  create: qe(e),
436
- get: Be(e),
437
- list: Ue(e),
436
+ get: Ue(e),
437
+ list: Be(e),
438
438
  update: Qe(e),
439
- remove: He(e)
439
+ remove: Ye(e)
440
440
  };
441
441
  }
442
442
  function L(e, t, a = { ...e }) {
@@ -498,7 +498,7 @@ function Ge(e) {
498
498
  try {
499
499
  await e.insertInto("tenants").values(n).execute();
500
500
  } catch (s) {
501
- throw (o = s == null ? void 0 : s.message) != null && o.includes("UNIQUE constraint failed") || (r = s == null ? void 0 : s.message) != null && r.includes("duplicate key") || (s == null ? void 0 : s.code) === "SQLITE_CONSTRAINT" || (s == null ? void 0 : s.code) === "23505" ? new R(409, {
501
+ throw (o = s == null ? void 0 : s.message) != null && o.includes("UNIQUE constraint failed") || (r = s == null ? void 0 : s.message) != null && r.includes("duplicate key") || (s == null ? void 0 : s.code) === "SQLITE_CONSTRAINT" || (s == null ? void 0 : s.code) === "ER_DUP_ENTRY" || (s == null ? void 0 : s.code) === "23505" ? new R(409, {
502
502
  message: `Tenant with ID '${a.id}' already exists`
503
503
  }) : s;
504
504
  }
@@ -1345,10 +1345,10 @@ function qt(e) {
1345
1345
  };
1346
1346
  };
1347
1347
  }
1348
- function Bt(e) {
1348
+ function Ut(e) {
1349
1349
  return async (t, a) => (await e.deleteFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).executeTakeFirst()).numDeletedRows > 0;
1350
1350
  }
1351
- function Ut(e) {
1351
+ function Bt(e) {
1352
1352
  return async (t, a, n) => {
1353
1353
  const o = {
1354
1354
  ...n,
@@ -1405,11 +1405,11 @@ function Qt(e) {
1405
1405
  get: Lt(e),
1406
1406
  getByClientId: Kt(e),
1407
1407
  list: qt(e),
1408
- remove: Bt(e),
1409
- update: Ut(e)
1408
+ remove: Ut(e),
1409
+ update: Bt(e)
1410
1410
  };
1411
1411
  }
1412
- function Ht(e) {
1412
+ function Yt(e) {
1413
1413
  return async (t, a) => {
1414
1414
  const n = await e.selectFrom("clients").where("clients.tenant_id", "=", t).where("clients.client_id", "=", a).select("connections").executeTakeFirst();
1415
1415
  if (!n)
@@ -1423,7 +1423,7 @@ function Ht(e) {
1423
1423
  return o.map((i) => s.get(i)).filter((i) => i !== void 0);
1424
1424
  };
1425
1425
  }
1426
- function Yt(e) {
1426
+ function Ht(e) {
1427
1427
  return async (t, a, n) => (await e.updateTable("clients").set({
1428
1428
  connections: JSON.stringify(n),
1429
1429
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1465,8 +1465,8 @@ function Vt(e) {
1465
1465
  }
1466
1466
  function Xt(e) {
1467
1467
  return {
1468
- listByClient: Ht(e),
1469
- updateByClient: Yt(e),
1468
+ listByClient: Yt(e),
1469
+ updateByClient: Ht(e),
1470
1470
  listByConnection: Wt(e),
1471
1471
  addClientToConnection: Gt(e),
1472
1472
  removeClientFromConnection: Vt(e)
@@ -2102,11 +2102,11 @@ function Ma(e) {
2102
2102
  );
2103
2103
  };
2104
2104
  }
2105
- const V = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", Y = V.length, Ja = 10, te = 16;
2105
+ const V = "0123456789ABCDEFGHJKMNPQRSTVWXYZ", H = V.length, Ja = 10, te = 16;
2106
2106
  function La(e) {
2107
2107
  let t = "";
2108
2108
  for (let a = Ja; a > 0; a--)
2109
- t = V.charAt(e % Y) + t, e = Math.floor(e / Y);
2109
+ t = V.charAt(e % H) + t, e = Math.floor(e / H);
2110
2110
  return t;
2111
2111
  }
2112
2112
  function Ka() {
@@ -2114,7 +2114,7 @@ function Ka() {
2114
2114
  crypto.getRandomValues(e);
2115
2115
  let t = "";
2116
2116
  for (let a = 0; a < te; a++)
2117
- t += V.charAt(e[a] % Y);
2117
+ t += V.charAt(e[a] % H);
2118
2118
  return t;
2119
2119
  }
2120
2120
  function fe() {
@@ -2143,7 +2143,7 @@ function qa(e) {
2143
2143
  }).execute(), o;
2144
2144
  };
2145
2145
  }
2146
- function Ba(e) {
2146
+ function Ua(e) {
2147
2147
  return async (t, a, n) => {
2148
2148
  const { created_at: o, updated_at: r, expires_at: s, ...i } = n, d = M(i);
2149
2149
  return delete d.created_at_ts, delete d.updated_at_ts, delete d.expires_at_ts, delete d.id, delete d.tenant_id, (await e.updateTable("login_sessions").set({
@@ -2155,18 +2155,18 @@ function Ba(e) {
2155
2155
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2156
2156
  };
2157
2157
  }
2158
- function Ua(e) {
2158
+ function Ba(e) {
2159
2159
  return async (t, a) => (await e.deleteFrom("login_sessions").where("login_sessions.tenant_id", "=", t).where("login_sessions.id", "=", a).execute()).length > 0;
2160
2160
  }
2161
2161
  function Qa(e) {
2162
2162
  return {
2163
2163
  create: qa(e),
2164
2164
  get: Ma(e),
2165
- update: Ba(e),
2166
- remove: Ua(e)
2165
+ update: Ua(e),
2166
+ remove: Ba(e)
2167
2167
  };
2168
2168
  }
2169
- function Ha(e) {
2169
+ function Ya(e) {
2170
2170
  return async (t) => {
2171
2171
  const [a] = await e.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", t).selectAll().execute();
2172
2172
  return w({
@@ -2186,7 +2186,7 @@ function ae(e) {
2186
2186
  universal_login_experience: e.universal_login_experience
2187
2187
  });
2188
2188
  }
2189
- function Ya(e) {
2189
+ function Ha(e) {
2190
2190
  return async (t, a) => {
2191
2191
  try {
2192
2192
  const n = Pe.parse(a);
@@ -2201,8 +2201,8 @@ function Ya(e) {
2201
2201
  }
2202
2202
  function Wa(e) {
2203
2203
  return {
2204
- get: Ha(e),
2205
- set: Ya(e)
2204
+ get: Ya(e),
2205
+ set: Ha(e)
2206
2206
  };
2207
2207
  }
2208
2208
  function Ga(e) {
@@ -2839,7 +2839,7 @@ function kn(e) {
2839
2839
  try {
2840
2840
  await e.insertInto("role_permissions").values(s).execute();
2841
2841
  } catch (i) {
2842
- if (i.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || i.code === "SQLITE_CONSTRAINT_UNIQUE")
2842
+ if (i.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || i.code === "SQLITE_CONSTRAINT_UNIQUE" || i.code === "ER_DUP_ENTRY")
2843
2843
  continue;
2844
2844
  throw i;
2845
2845
  }
@@ -2923,7 +2923,7 @@ function zn(e) {
2923
2923
  };
2924
2924
  return await e.insertInto("user_permissions").values(s).execute(), !0;
2925
2925
  } catch (s) {
2926
- return s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.code === "SQLITE_CONSTRAINT" || s.message && s.message.includes("UNIQUE constraint failed") || s.message && s.message.includes("PRIMARY KEY constraint failed") ? !0 : (console.error("Error creating user permission:", s), !1);
2926
+ return s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.code === "SQLITE_CONSTRAINT" || s.code === "ER_DUP_ENTRY" || s.message && s.message.includes("UNIQUE constraint failed") || s.message && s.message.includes("PRIMARY KEY constraint failed") ? !0 : (console.error("Error creating user permission:", s), !1);
2927
2927
  }
2928
2928
  };
2929
2929
  }
@@ -3021,7 +3021,7 @@ function Rn(e) {
3021
3021
  created_at: r
3022
3022
  }).execute(), !0;
3023
3023
  } catch (s) {
3024
- return s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.code === "SQLITE_CONSTRAINT" || s.message && s.message.includes("UNIQUE constraint failed") || s.message && s.message.includes("PRIMARY KEY constraint failed") ? !0 : (console.error("Error creating user role:", s), !1);
3024
+ return s.code === "SQLITE_CONSTRAINT_PRIMARYKEY" || s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.code === "SQLITE_CONSTRAINT" || s.code === "ER_DUP_ENTRY" || s.message && s.message.includes("UNIQUE constraint failed") || s.message && s.message.includes("PRIMARY KEY constraint failed") ? !0 : (console.error("Error creating user role:", s), !1);
3025
3025
  }
3026
3026
  };
3027
3027
  }
@@ -3068,7 +3068,7 @@ function Kn(e) {
3068
3068
  try {
3069
3069
  await e.insertInto("organizations").values(n).execute();
3070
3070
  } catch (o) {
3071
- throw o.code === "SQLITE_CONSTRAINT_UNIQUE" || o.message.includes("AlreadyExists") ? new R(409, {
3071
+ throw o.code === "SQLITE_CONSTRAINT_UNIQUE" || o.code === "ER_DUP_ENTRY" || o.message.includes("AlreadyExists") ? new R(409, {
3072
3072
  message: "Organization already exists"
3073
3073
  }) : o;
3074
3074
  }
@@ -3092,7 +3092,7 @@ function qn(e) {
3092
3092
  }) : null;
3093
3093
  };
3094
3094
  }
3095
- function Bn(e) {
3095
+ function Un(e) {
3096
3096
  return async (t, a) => {
3097
3097
  let n = e.selectFrom("organizations").selectAll().where("tenant_id", "=", t);
3098
3098
  if (a != null && a.q && (n = n.where(
@@ -3145,7 +3145,7 @@ function Bn(e) {
3145
3145
  };
3146
3146
  };
3147
3147
  }
3148
- function Un(e) {
3148
+ function Bn(e) {
3149
3149
  return async (t, a) => (await e.deleteFrom("organizations").where("tenant_id", "=", t).where("id", "=", a).execute()).length > 0;
3150
3150
  }
3151
3151
  function Qn(e) {
@@ -3161,16 +3161,16 @@ function Qn(e) {
3161
3161
  ), (await e.updateTable("organizations").set(u).where("tenant_id", "=", t).where("id", "=", a).execute()).length > 0;
3162
3162
  };
3163
3163
  }
3164
- function Hn(e) {
3164
+ function Yn(e) {
3165
3165
  return {
3166
3166
  create: Kn(e),
3167
3167
  get: qn(e),
3168
- list: Bn(e),
3169
- remove: Un(e),
3168
+ list: Un(e),
3169
+ remove: Bn(e),
3170
3170
  update: Qn(e)
3171
3171
  };
3172
3172
  }
3173
- function Yn(e) {
3173
+ function Hn(e) {
3174
3174
  return async (t, a) => {
3175
3175
  const n = {
3176
3176
  id: k(),
@@ -3302,7 +3302,7 @@ function Zn(e) {
3302
3302
  function eo(e) {
3303
3303
  return {
3304
3304
  // CRUD operations
3305
- create: Yn(e),
3305
+ create: Hn(e),
3306
3306
  get: Wn(e),
3307
3307
  list: Gn(e),
3308
3308
  listUserOrganizations: Vn(e),
@@ -3336,7 +3336,7 @@ function to(e) {
3336
3336
  try {
3337
3337
  await e.insertInto("invites").values(i).execute();
3338
3338
  } catch (d) {
3339
- throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.message.includes("AlreadyExists") ? new R(409, {
3339
+ throw d.code === "SQLITE_CONSTRAINT_UNIQUE" || d.code === "ER_DUP_ENTRY" || d.message.includes("AlreadyExists") ? new R(409, {
3340
3340
  message: "Invite already exists"
3341
3341
  }) : d;
3342
3342
  }
@@ -3927,21 +3927,21 @@ async function qo(e) {
3927
3927
  (t) => t.onDelete("cascade")
3928
3928
  ).addColumn("type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute(), await e.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute();
3929
3929
  }
3930
- async function Bo(e) {
3930
+ async function Uo(e) {
3931
3931
  await e.schema.dropTable("passwords").execute(), await e.schema.dropTable("codes").execute();
3932
3932
  }
3933
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3933
+ const Bo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3934
3934
  __proto__: null,
3935
- down: Bo,
3935
+ down: Uo,
3936
3936
  up: qo
3937
3937
  }, Symbol.toStringTag, { value: "Module" }));
3938
3938
  async function Qo(e) {
3939
3939
  }
3940
- async function Ho(e) {
3940
+ async function Yo(e) {
3941
3941
  }
3942
- const Yo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3942
+ const Ho = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3943
3943
  __proto__: null,
3944
- down: Ho,
3944
+ down: Yo,
3945
3945
  up: Qo
3946
3946
  }, Symbol.toStringTag, { value: "Module" }));
3947
3947
  async function Wo(e) {
@@ -4128,23 +4128,23 @@ const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4128
4128
  async function qr(e) {
4129
4129
  await e.schema.alterTable("logs").dropColumn("details").execute(), await e.schema.alterTable("logs").addColumn("details", "varchar(8192)").execute();
4130
4130
  }
4131
- async function Br(e) {
4131
+ async function Ur(e) {
4132
4132
  await e.schema.alterTable("logs").dropColumn("details").execute(), await e.schema.alterTable("logs").addColumn("details", "varchar(2048)").execute();
4133
4133
  }
4134
- const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4134
+ const Br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4135
4135
  __proto__: null,
4136
- down: Br,
4136
+ down: Ur,
4137
4137
  up: qr
4138
4138
  }, Symbol.toStringTag, { value: "Module" }));
4139
4139
  async function Qr(e) {
4140
4140
  await e.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await e.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await e.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
4141
4141
  }
4142
- async function Hr(e) {
4142
+ async function Yr(e) {
4143
4143
  await e.schema.alterTable("logs").dropColumn("user_name").execute(), await e.schema.alterTable("logs").dropColumn("auth0_client").execute(), await e.schema.alterTable("logs").dropColumn("isMobile").execute(), await e.schema.alterTable("logs").dropColumn("connection").execute(), await e.schema.alterTable("logs").dropColumn("connection_id").execute(), await e.schema.alterTable("logs").dropColumn("audience").execute(), await e.schema.alterTable("logs").dropColumn("scope").execute(), await e.schema.alterTable("logs").dropColumn("strategy").execute(), await e.schema.alterTable("logs").dropColumn("strategy_type").execute(), await e.schema.alterTable("logs").dropColumn("hostname").execute(), await e.schema.alterTable("logs").dropColumn("session_connection").execute();
4144
4144
  }
4145
- const Yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4145
+ const Hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4146
4146
  __proto__: null,
4147
- down: Hr,
4147
+ down: Yr,
4148
4148
  up: Qr
4149
4149
  }, Symbol.toStringTag, { value: "Module" }));
4150
4150
  async function Wr(e) {
@@ -4330,11 +4330,11 @@ const Ks = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4330
4330
  }, Symbol.toStringTag, { value: "Module" }));
4331
4331
  async function qs(e) {
4332
4332
  }
4333
- async function Bs(e) {
4333
+ async function Us(e) {
4334
4334
  }
4335
- const Us = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4335
+ const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4336
4336
  __proto__: null,
4337
- down: Bs,
4337
+ down: Us,
4338
4338
  up: qs
4339
4339
  }, Symbol.toStringTag, { value: "Module" }));
4340
4340
  async function Qs(e) {
@@ -4354,7 +4354,7 @@ async function Qs(e) {
4354
4354
  (t) => t.onDelete("cascade")
4355
4355
  ).addColumn("code_type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4356
4356
  }
4357
- async function Hs(e) {
4357
+ async function Ys(e) {
4358
4358
  await e.schema.dropTable("logins").execute(), await e.schema.alterTable("passwords").dropColumn("algorithm").execute(), await e.schema.dropTable("codes").execute(), await e.schema.createTable("codes").addColumn("id", "varchar(255)", (t) => t.primaryKey()).addColumn("code", "varchar(255)", (t) => t.notNull()).addColumn("user_id", "varchar(255)").addColumn("tenant_id", "varchar(255)").addForeignKeyConstraint(
4359
4359
  "codes_user_id_tenant_id_constraint",
4360
4360
  ["user_id", "tenant_id"],
@@ -4363,9 +4363,9 @@ async function Hs(e) {
4363
4363
  (t) => t.onDelete("cascade")
4364
4364
  ).addColumn("type", "varchar(255)", (t) => t.notNull()).addColumn("created_at", "varchar(255)", (t) => t.notNull()).addColumn("expires_at", "varchar(255)", (t) => t.notNull()).addColumn("used_at", "varchar(255)").execute();
4365
4365
  }
4366
- const Ys = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4366
+ const Hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4367
4367
  __proto__: null,
4368
- down: Hs,
4368
+ down: Ys,
4369
4369
  up: Qs
4370
4370
  }, Symbol.toStringTag, { value: "Module" }));
4371
4371
  async function Ws(e) {
@@ -4584,23 +4584,23 @@ const Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4584
4584
  async function qi(e) {
4585
4585
  await e.schema.alterTable("logins").addColumn("authParams_ui_locales", "varchar(32)").execute();
4586
4586
  }
4587
- async function Bi(e) {
4587
+ async function Ui(e) {
4588
4588
  await e.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute();
4589
4589
  }
4590
- const Ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4590
+ const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4591
4591
  __proto__: null,
4592
- down: Bi,
4592
+ down: Ui,
4593
4593
  up: qi
4594
4594
  }, Symbol.toStringTag, { value: "Module" }));
4595
4595
  async function Qi(e) {
4596
4596
  await e.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
4597
4597
  }
4598
- async function Hi(e) {
4598
+ async function Yi(e) {
4599
4599
  await e.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
4600
4600
  }
4601
- const Yi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4601
+ const Hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4602
4602
  __proto__: null,
4603
- down: Hi,
4603
+ down: Yi,
4604
4604
  up: Qi
4605
4605
  }, Symbol.toStringTag, { value: "Module" }));
4606
4606
  async function Wi(e) {
@@ -4875,21 +4875,21 @@ async function qc(e) {
4875
4875
  (t) => t.references("tenants.id").onDelete("cascade").notNull()
4876
4876
  ).addColumn("domain", "varchar(255)", (t) => t.notNull()).addColumn("primary", "boolean", (t) => t.notNull()).addColumn("status", "varchar(50)", (t) => t.notNull()).addColumn("type", "varchar(50)", (t) => t.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (t) => t.notNull()).addColumn("updated_at", "varchar(35)", (t) => t.notNull()).execute();
4877
4877
  }
4878
- async function Bc(e) {
4878
+ async function Uc(e) {
4879
4879
  }
4880
- const Uc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4880
+ const Bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4881
4881
  __proto__: null,
4882
- down: Bc,
4882
+ down: Uc,
4883
4883
  up: qc
4884
4884
  }, Symbol.toStringTag, { value: "Module" }));
4885
4885
  async function Qc(e) {
4886
4886
  }
4887
- async function Hc(e) {
4887
+ async function Yc(e) {
4888
4888
  await e.schema.alterTable("users").dropColumn("phone_number").dropColumn("phone_verified").dropColumn("username").execute();
4889
4889
  }
4890
- const Yc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4890
+ const Hc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4891
4891
  __proto__: null,
4892
- down: Hc,
4892
+ down: Yc,
4893
4893
  up: Qc
4894
4894
  }, Symbol.toStringTag, { value: "Module" }));
4895
4895
  async function Wc(e) {
@@ -5251,12 +5251,12 @@ async function ql(e) {
5251
5251
  "client_id"
5252
5252
  ]).execute();
5253
5253
  }
5254
- async function Bl(e) {
5254
+ async function Ul(e) {
5255
5255
  await e.schema.dropTable("clients").execute();
5256
5256
  }
5257
- const Ul = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5257
+ const Bl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5258
5258
  __proto__: null,
5259
- down: Bl,
5259
+ down: Ul,
5260
5260
  up: ql
5261
5261
  }, Symbol.toStringTag, { value: "Module" }));
5262
5262
  async function ye(e) {
@@ -5267,9 +5267,9 @@ async function ye(e) {
5267
5267
  }
5268
5268
  }
5269
5269
  async function Ql(e) {
5270
- await ye(e) === "mysql" ? await Hl(e) : await Yl(e);
5270
+ await ye(e) === "mysql" ? await Yl(e) : await Hl(e);
5271
5271
  }
5272
- async function Hl(e) {
5272
+ async function Yl(e) {
5273
5273
  await e.transaction().execute(async (t) => {
5274
5274
  const a = await h`
5275
5275
  SELECT
@@ -5350,7 +5350,7 @@ async function Hl(e) {
5350
5350
  FROM login_sessions_backup`.execute(t), await h`DROP TABLE sessions_backup`.execute(t), await h`DROP TABLE login_sessions_backup`.execute(t), await h`DROP TABLE refresh_tokens_backup`.execute(t);
5351
5351
  });
5352
5352
  }
5353
- async function Yl(e) {
5353
+ async function Hl(e) {
5354
5354
  await e.transaction().execute(async (t) => {
5355
5355
  const a = [
5356
5356
  "sessions_backup",
@@ -5827,18 +5827,18 @@ const qd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5827
5827
  down: Kd,
5828
5828
  up: Ld
5829
5829
  }, Symbol.toStringTag, { value: "Module" }));
5830
- async function Bd(e) {
5830
+ async function Ud(e) {
5831
5831
  await e.schema.alterTable("resource_servers").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute(), await e.schema.alterTable("roles").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute(), await e.schema.alterTable("connections").addColumn("is_system", "integer", (t) => t.defaultTo(0).notNull()).execute();
5832
5832
  }
5833
- async function Ud(e) {
5833
+ async function Bd(e) {
5834
5834
  await e.schema.alterTable("resource_servers").dropColumn("is_system").execute(), await e.schema.alterTable("roles").dropColumn("is_system").execute(), await e.schema.alterTable("connections").dropColumn("is_system").execute();
5835
5835
  }
5836
5836
  const Qd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5837
5837
  __proto__: null,
5838
- down: Ud,
5839
- up: Bd
5838
+ down: Bd,
5839
+ up: Ud
5840
5840
  }, Symbol.toStringTag, { value: "Module" }));
5841
- async function Hd(e) {
5841
+ async function Yd(e) {
5842
5842
  const t = await e.selectFrom("keys").selectAll().execute();
5843
5843
  await e.schema.dropTable("keys").execute(), await h`ALTER TABLE connections RENAME TO connections_old`.execute(e), await e.schema.createTable("connections").addColumn("id", "varchar(255)", (a) => a.notNull()).addColumn(
5844
5844
  "tenant_id",
@@ -5871,7 +5871,7 @@ async function Hd(e) {
5871
5871
  for (const a of t)
5872
5872
  await e.insertInto("keys").values(a).execute();
5873
5873
  }
5874
- async function Yd(e) {
5874
+ async function Hd(e) {
5875
5875
  const t = await e.selectFrom("keys").selectAll().execute();
5876
5876
  await e.schema.dropTable("keys").execute(), await h`ALTER TABLE connections RENAME TO connections_new`.execute(e), await e.schema.createTable("connections").addColumn("id", "varchar(255)", (a) => a.notNull().primaryKey()).addColumn(
5877
5877
  "tenant_id",
@@ -5910,8 +5910,8 @@ async function Yd(e) {
5910
5910
  }
5911
5911
  const Wd = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5912
5912
  __proto__: null,
5913
- down: Yd,
5914
- up: Hd
5913
+ down: Hd,
5914
+ up: Yd
5915
5915
  }, Symbol.toStringTag, { value: "Module" }));
5916
5916
  async function Gd(e) {
5917
5917
  await e.schema.alterTable("login_sessions").addColumn("state", "varchar(50)", (t) => t.defaultTo("pending")).execute(), await e.schema.alterTable("login_sessions").addColumn("state_data", "text").execute(), await e.schema.alterTable("login_sessions").addColumn("failure_reason", "text").execute(), await e.schema.alterTable("login_sessions").addColumn("user_id", "varchar(255)").execute(), await e.schema.createIndex("login_sessions_tenant_user_idx").on("login_sessions").columns(["tenant_id", "user_id"]).execute(), await e.updateTable("login_sessions").set({
@@ -6196,7 +6196,7 @@ async function Du(e) {
6196
6196
  WHERE created_at_ts IS NULL AND created_at IS NOT NULL
6197
6197
  `.execute(e), t === "mysql" && (await e.schema.alterTable("hooks").modifyColumn("created_at", "varchar(255)").execute(), await e.schema.alterTable("hooks").modifyColumn("updated_at", "varchar(255)").execute());
6198
6198
  }
6199
- async function H(e, t, a) {
6199
+ async function Y(e, t, a) {
6200
6200
  try {
6201
6201
  await e.schema.alterTable(t).dropColumn(a).execute();
6202
6202
  } catch (n) {
@@ -6206,7 +6206,7 @@ async function H(e, t, a) {
6206
6206
  }
6207
6207
  }
6208
6208
  async function Au(e) {
6209
- await H(e, "hooks", "template_id"), await H(e, "hooks", "created_at_ts"), await H(e, "hooks", "updated_at_ts");
6209
+ await Y(e, "hooks", "template_id"), await Y(e, "hooks", "created_at_ts"), await Y(e, "hooks", "updated_at_ts");
6210
6210
  }
6211
6211
  const ju = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6212
6212
  __proto__: null,
@@ -6343,12 +6343,12 @@ const Ku = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6343
6343
  async function qu(e) {
6344
6344
  await e.schema.alterTable("refresh_tokens").addColumn("login_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_login_id").on("refresh_tokens").column("login_id").execute();
6345
6345
  }
6346
- async function Bu(e) {
6346
+ async function Uu(e) {
6347
6347
  await e.schema.dropIndex("idx_refresh_tokens_login_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("login_id").execute();
6348
6348
  }
6349
- const Uu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6349
+ const Bu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6350
6350
  __proto__: null,
6351
- down: Bu,
6351
+ down: Uu,
6352
6352
  up: qu
6353
6353
  }, Symbol.toStringTag, { value: "Module" }));
6354
6354
  async function xe(e) {
@@ -6361,12 +6361,12 @@ async function xe(e) {
6361
6361
  async function Qu(e) {
6362
6362
  await xe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)", (a) => a.notNull()).execute(), await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute()) : (await e.schema.dropIndex("idx_refresh_tokens_session_id").execute(), await e.schema.alterTable("refresh_tokens").dropColumn("session_id").execute());
6363
6363
  }
6364
- async function Hu(e) {
6364
+ async function Yu(e) {
6365
6365
  await xe(e) === "mysql" ? (await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(26)").execute(), await e.schema.createIndex("idx_refresh_tokens_session_id").on("refresh_tokens").column("session_id").execute(), await e.schema.alterTable("refresh_tokens").modifyColumn("login_id", "varchar(26)").execute()) : await e.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(21)").execute();
6366
6366
  }
6367
- const Yu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6367
+ const Hu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6368
6368
  __proto__: null,
6369
- down: Hu,
6369
+ down: Yu,
6370
6370
  up: Qu
6371
6371
  }, Symbol.toStringTag, { value: "Module" }));
6372
6372
  async function Wu(e) {
@@ -6483,8 +6483,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6483
6483
  m4_logTable: jo,
6484
6484
  m5_userProfile: Mo,
6485
6485
  m6_sessions: Ko,
6486
- m7_passwords: Uo,
6487
- m8_logsTableNewFields: Yo,
6486
+ m7_passwords: Bo,
6487
+ m8_logsTableNewFields: Ho,
6488
6488
  m9_passwordTableNewField: Vo,
6489
6489
  n01_codesTable: er,
6490
6490
  n11_universalLoginSession: nr,
@@ -6501,8 +6501,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6501
6501
  n22_dropLogsFields: jr,
6502
6502
  n23_dropUsersFields: Mr,
6503
6503
  n24_logsIndexes: Kr,
6504
- n25_logDescMaxLength: Ur,
6505
- n26_logsTableExtraFields: Yr,
6504
+ n25_logDescMaxLength: Br,
6505
+ n26_logsTableExtraFields: Hr,
6506
6506
  n27_usersTableNameIndex: Vr,
6507
6507
  n28_usersEmailConstrain: es,
6508
6508
  n29_increaseOtpStateLength: ns,
@@ -6519,8 +6519,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6519
6519
  n40_userId: js,
6520
6520
  n41_hooks: Ms,
6521
6521
  n42_userIdIndexes: Ks,
6522
- n43_userIdIndexes: Us,
6523
- n44_codes: Ys,
6522
+ n43_userIdIndexes: Bs,
6523
+ n44_codes: Hs,
6524
6524
  n45_hookProperties: Vs,
6525
6525
  n46_loginAuth0Client: ei,
6526
6526
  n47_loginAuth0Client: ni,
@@ -6537,8 +6537,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6537
6537
  n58_connection_client_id: ji,
6538
6538
  n59_connection_options: Mi,
6539
6539
  n60_users_metadata: Ki,
6540
- n61_userLocales: Ui,
6541
- n62_prompt: Yi,
6540
+ n61_userLocales: Bi,
6541
+ n62_prompt: Hi,
6542
6542
  n63_connection_cleanup: Vi,
6543
6543
  n64_act_as: ec,
6544
6544
  n65_code_verifier: nc,
@@ -6555,8 +6555,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6555
6555
  n77_drop_sessions: jc,
6556
6556
  n78_login_sessions: Mc,
6557
6557
  n79_drop_sessions_2: Kc,
6558
- n80_recreate_custom_domains: Uc,
6559
- n81_phone: Yc,
6558
+ n80_recreate_custom_domains: Bc,
6559
+ n81_phone: Hc,
6560
6560
  n82_forms: Vc,
6561
6561
  n83_addFormsIdToHooks: el,
6562
6562
  n84_login_completed: nl,
@@ -6573,7 +6573,7 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6573
6573
  n95_create_organizations_table: jl,
6574
6574
  n96_create_user_organizations_table: Ml,
6575
6575
  n97_add_organization_to_user_permissions_and_roles: Kl,
6576
- n98_clients: Ul,
6576
+ n98_clients: Bl,
6577
6577
  n99_update_client_foreign_keys: Xl,
6578
6578
  o001_client_grants: td,
6579
6579
  o002_drop_applications: od,
@@ -6607,8 +6607,8 @@ const C_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6607
6607
  o030_add_template_id_to_hooks: ju,
6608
6608
  o031_hooks_cleanup: Mu,
6609
6609
  o032_unique_username_provider: Ku,
6610
- o033_add_login_id_to_refresh_tokens: Uu,
6611
- o034_refresh_tokens_replace_session_id_with_login_id: Yu,
6610
+ o033_add_login_id_to_refresh_tokens: Bu,
6611
+ o034_refresh_tokens_replace_session_id_with_login_id: Hu,
6612
6612
  o035_idle_expires_at_ts_indexes: Vu,
6613
6613
  o036_add_connection_to_login_sessions: e_,
6614
6614
  o037_mfa_enrollments: n_,
@@ -6653,7 +6653,7 @@ function x_(e, t = { useTransactions: !0 }) {
6653
6653
  connections: Mt(e),
6654
6654
  emailProviders: en(e),
6655
6655
  customDomains: pa(e),
6656
- flows: Ye(e),
6656
+ flows: He(e),
6657
6657
  forms: pn(e),
6658
6658
  hookCode: Pa(e),
6659
6659
  hooks: ka(e),
@@ -6677,7 +6677,7 @@ function x_(e, t = { useTransactions: !0 }) {
6677
6677
  universalLoginTemplates: xa(e),
6678
6678
  customText: lo(e),
6679
6679
  users: Ke(e),
6680
- organizations: Hn(e),
6680
+ organizations: Yn(e),
6681
6681
  userOrganizations: eo(e),
6682
6682
  stats: co(e),
6683
6683
  outbox: No(e),