@authhero/kysely-adapter 10.3.0 → 10.5.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.
@@ -4,7 +4,7 @@ var le = (t) => {
4
4
  };
5
5
  var Ee = (t, e, a) => e in t ? ze(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
6
  var j = (t, e, a) => Ee(t, typeof e != "symbol" ? e + "" : e, a), R = (t, e, a) => e.has(t) || le("Cannot " + a);
7
- var d = (t, e, a) => (R(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? le("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (R(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (R(t, e, "access private method"), a);
7
+ var c = (t, e, a) => (R(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? le("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, a), M = (t, e, a, r) => (R(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (R(t, e, "access private method"), a);
8
8
  import { parseUserId as Y, codeSchema as Je, connectionSchema as Ke, loginSessionSchema as Re, promptSettingSchema as Ue } from "@authhero/adapter-interfaces";
9
9
  import "@hono/zod-openapi";
10
10
  var V = class extends Error {
@@ -105,11 +105,11 @@ function Qe(t) {
105
105
  }
106
106
  function O(t, e, a, r) {
107
107
  return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
108
- let s = n.startsWith("-"), l, c, g, m;
109
- return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, c] = s ? n.substring(1).split(":") : n.split(":"), g = !1, c.startsWith(">=") ? (m = ">=", c = c.substring(2)) : c.startsWith(">") ? (m = ">", c = c.substring(1)) : c.startsWith("<=") ? (m = "<=", c = c.substring(2)) : c.startsWith("<") ? (m = "<", c = c.substring(1)) : m = "=") : (l = null, c = n, g = !1), { key: l, value: c, isNegation: s, isExistsQuery: g, operator: m };
110
- }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: c, operator: g }) => {
108
+ let s = n.startsWith("-"), l, d, g, m;
109
+ return n.startsWith("-_exists_:") ? (l = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (l = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [l, d] = s ? n.substring(1).split(":") : n.split(":"), g = !1, d.startsWith(">=") ? (m = ">=", d = d.substring(2)) : d.startsWith(">") ? (m = ">", d = d.substring(1)) : d.startsWith("<=") ? (m = "<=", d = d.substring(2)) : d.startsWith("<") ? (m = "<", d = d.substring(1)) : m = "=") : (l = null, d = n, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
+ }).forEach(({ key: n, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
111
111
  if (n)
112
- if (c)
112
+ if (d)
113
113
  l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
114
  else if (l)
115
115
  switch (g) {
@@ -154,7 +154,7 @@ function Ve(t) {
154
154
  const { ref: m } = t.dynamic;
155
155
  r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], c = n.map((m) => {
157
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
158
  const w = l.filter(
159
159
  (b) => b.linked_to === m.user_id
160
160
  );
@@ -176,7 +176,7 @@ function Ve(t) {
176
176
  });
177
177
  }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
- users: c,
179
+ users: d,
180
180
  start: a.page * a.per_page,
181
181
  limit: a.per_page,
182
182
  length: x(g)
@@ -361,17 +361,17 @@ function it(t) {
361
361
  };
362
362
  };
363
363
  }
364
- function ct(t) {
364
+ function dt(t) {
365
365
  return async (e, a) => {
366
366
  const r = await t.selectFrom("logs").where("logs.tenant_id", "=", e).where("logs.id", "=", a).selectAll().executeTakeFirst();
367
367
  return r ? pe(r) : null;
368
368
  };
369
369
  }
370
- function dt(t) {
370
+ function ct(t) {
371
371
  return {
372
372
  create: st(t),
373
373
  list: it(t),
374
- get: ct(t)
374
+ get: dt(t)
375
375
  };
376
376
  }
377
377
  function lt(t) {
@@ -428,19 +428,19 @@ function _t(t) {
428
428
  a.q && (r = O(t, r, a.q, ["user_id", "session_id"]));
429
429
  let o = r;
430
430
  if (a.sort && a.sort.sort_by) {
431
- const { ref: c } = t.dynamic;
431
+ const { ref: d } = t.dynamic;
432
432
  o = o.orderBy(
433
- c(a.sort.sort_by),
433
+ d(a.sort.sort_by),
434
434
  a.sort.sort_order
435
435
  );
436
436
  }
437
437
  o = o.offset(a.page * a.per_page).limit(a.per_page);
438
- const n = await o.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
438
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
439
439
  return {
440
- sessions: n.map((c) => ({
441
- ...c,
442
- device: JSON.parse(c.device),
443
- clients: JSON.parse(c.clients)
440
+ sessions: n.map((d) => ({
441
+ ...d,
442
+ device: JSON.parse(d.device),
443
+ clients: JSON.parse(d.clients)
444
444
  })),
445
445
  start: a.page * a.per_page,
446
446
  limit: a.per_page,
@@ -500,10 +500,10 @@ function vt(t) {
500
500
  }) => {
501
501
  let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
502
  a.q && (r = O(t, r, a.q, ["code", "login_id"]));
503
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
503
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
504
504
  return {
505
- codes: n.map((c) => {
506
- const { tenant_id: g, ...m } = c;
505
+ codes: n.map((d) => {
506
+ const { tenant_id: g, ...m } = d;
507
507
  return Je.parse(_(m));
508
508
  }),
509
509
  start: a.page * a.per_page,
@@ -553,7 +553,7 @@ function St(t) {
553
553
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
554
554
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
555
555
  ...a
556
- }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), c = JSON.stringify(a.allowed_clients);
556
+ }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = JSON.stringify(a.allowed_clients);
557
557
  return await t.insertInto("applications").values({
558
558
  ...r,
559
559
  tenant_id: e,
@@ -563,7 +563,7 @@ function St(t) {
563
563
  allowed_origins: o,
564
564
  web_origins: s,
565
565
  allowed_logout_urls: l,
566
- allowed_clients: c
566
+ allowed_clients: d
567
567
  }).execute(), r;
568
568
  };
569
569
  }
@@ -648,11 +648,11 @@ function jt(t) {
648
648
  let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
649
649
  a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
650
650
  const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
651
- (c) => _({
652
- ...c,
653
- options: JSON.parse(c.options)
651
+ (d) => _({
652
+ ...d,
653
+ options: JSON.parse(d.options)
654
654
  })
655
- ), { count: l } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
655
+ ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
656
656
  return {
657
657
  connections: s,
658
658
  start: a.page * a.per_page,
@@ -815,7 +815,7 @@ function Gt(t) {
815
815
  colors_page_background_type: n,
816
816
  colors_page_background_start: s,
817
817
  colors_page_background_end: l,
818
- colors_page_background_angle_dev: c,
818
+ colors_page_background_angle_dev: d,
819
819
  font_url: g,
820
820
  ...m
821
821
  } = a;
@@ -827,7 +827,7 @@ function Gt(t) {
827
827
  type: n,
828
828
  start: s,
829
829
  end: l,
830
- angle_deg: c
830
+ angle_deg: d
831
831
  }
832
832
  },
833
833
  font: g ? { url: g } : void 0
@@ -836,14 +836,14 @@ function Gt(t) {
836
836
  }
837
837
  function Ht(t) {
838
838
  return async (e, a) => {
839
- var s, l, c, g, m, w, b, Z, ee, te, ae, re, ne, oe, se, ie, ce, de;
839
+ var s, l, d, g, m, w, b, Z, ee, te, ae, re, ne, oe, se, ie, de, ce;
840
840
  const { colors: r, font: o, ...n } = a;
841
841
  try {
842
842
  await t.insertInto("branding").values({
843
843
  ...n,
844
844
  colors_primary: r == null ? void 0 : r.primary,
845
845
  colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
846
- colors_page_background_start: (g = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : g.start,
846
+ colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
847
847
  colors_page_background_end: (w = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : w.end,
848
848
  colors_page_background_angle_dev: (Z = (b = a.colors) == null ? void 0 : b.page_background) == null ? void 0 : Z.angle_deg,
849
849
  font_url: (ee = a.font) == null ? void 0 : ee.url,
@@ -856,8 +856,8 @@ function Ht(t) {
856
856
  colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
857
857
  colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
858
858
  colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
859
- colors_page_background_angle_dev: (ce = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : ce.angle_deg,
860
- font_url: (de = a.font) == null ? void 0 : de.url
859
+ colors_page_background_angle_dev: (de = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : de.angle_deg,
860
+ font_url: (ce = a.font) == null ? void 0 : ce.url
861
861
  }).where("tenant_id", "=", e).execute();
862
862
  }
863
863
  };
@@ -876,10 +876,10 @@ function Yt(t) {
876
876
  }) => {
877
877
  let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
878
878
  a.q && (r = O(t, r, a.q, ["url"]));
879
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
879
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
880
880
  return {
881
- hooks: n.map((c) => {
882
- const { tenant_id: g, enabled: m, synchronous: w, ...b } = c;
881
+ hooks: n.map((d) => {
882
+ const { tenant_id: g, enabled: m, synchronous: w, ...b } = d;
883
883
  return _({
884
884
  ...b,
885
885
  enabled: !!m,
@@ -987,7 +987,7 @@ function ia(t) {
987
987
  return r ? _(r) : null;
988
988
  };
989
989
  }
990
- function ca(t) {
990
+ function da(t) {
991
991
  return async (e, a, r) => {
992
992
  const o = E({
993
993
  ...r,
@@ -996,12 +996,12 @@ function ca(t) {
996
996
  return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
997
997
  };
998
998
  }
999
- function da(t) {
999
+ function ca(t) {
1000
1000
  return {
1001
1001
  create: oa(t),
1002
1002
  get: ia(t),
1003
1003
  remove: sa(t),
1004
- update: ca(t)
1004
+ update: da(t)
1005
1005
  };
1006
1006
  }
1007
1007
  function la(t) {
@@ -1180,20 +1180,20 @@ function Sa(t) {
1180
1180
  a.q && (r = O(t, r, a.q, ["token", "session_id"]));
1181
1181
  let o = r;
1182
1182
  if (a.sort && a.sort.sort_by) {
1183
- const { ref: c } = t.dynamic;
1183
+ const { ref: d } = t.dynamic;
1184
1184
  o = o.orderBy(
1185
- c(a.sort.sort_by),
1185
+ d(a.sort.sort_by),
1186
1186
  a.sort.sort_order
1187
1187
  );
1188
1188
  }
1189
1189
  o = o.offset(a.page * a.per_page).limit(a.per_page);
1190
- const n = await o.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1190
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1191
1191
  return {
1192
- refresh_tokens: n.map((c) => ({
1193
- ...c,
1194
- rotating: !!c.rotating,
1195
- device: c.device ? JSON.parse(c.device) : {},
1196
- resource_servers: c.resource_servers ? JSON.parse(c.resource_servers) : []
1192
+ refresh_tokens: n.map((d) => ({
1193
+ ...d,
1194
+ rotating: !!d.rotating,
1195
+ device: d.device ? JSON.parse(d.device) : {},
1196
+ resource_servers: d.resource_servers ? JSON.parse(d.resource_servers) : []
1197
1197
  })),
1198
1198
  start: a.page * a.per_page,
1199
1199
  limit: a.per_page,
@@ -1404,7 +1404,7 @@ class Ia {
1404
1404
  return this.nodeStack.pop(), p(a);
1405
1405
  }
1406
1406
  transformNodeImpl(e) {
1407
- return d(this, K)[e.kind](e);
1407
+ return c(this, K)[e.kind](e);
1408
1408
  }
1409
1409
  transformNodeList(e) {
1410
1410
  return e && p(e.map((a) => this.transformNode(a)));
@@ -2165,29 +2165,29 @@ class ja extends Ia {
2165
2165
  return super.transformNodeImpl(a);
2166
2166
  const r = u(this, f, we).call(this, a);
2167
2167
  for (const s of r)
2168
- d(this, S).add(s);
2168
+ c(this, S).add(s);
2169
2169
  const o = u(this, f, ye).call(this, a);
2170
2170
  for (const s of o)
2171
- d(this, T).add(s);
2171
+ c(this, T).add(s);
2172
2172
  const n = super.transformNodeImpl(a);
2173
2173
  for (const s of o)
2174
- d(this, T).delete(s);
2174
+ c(this, T).delete(s);
2175
2175
  for (const s of r)
2176
- d(this, S).delete(s);
2176
+ c(this, S).delete(s);
2177
2177
  return n;
2178
2178
  }
2179
2179
  transformSchemableIdentifier(a) {
2180
2180
  const r = super.transformSchemableIdentifier(a);
2181
- return r.schema || !d(this, T).has(a.identifier.name) ? r : {
2181
+ return r.schema || !c(this, T).has(a.identifier.name) ? r : {
2182
2182
  ...r,
2183
- schema: J.create(d(this, P))
2183
+ schema: J.create(c(this, P))
2184
2184
  };
2185
2185
  }
2186
2186
  transformReferences(a) {
2187
2187
  const r = super.transformReferences(a);
2188
2188
  return r.table.table.schema ? r : {
2189
2189
  ...r,
2190
- table: U.createWithSchema(d(this, P), r.table.table.identifier.name)
2190
+ table: U.createWithSchema(c(this, P), r.table.table.identifier.name)
2191
2191
  };
2192
2192
  }
2193
2193
  }
@@ -2210,11 +2210,11 @@ P = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge =
2210
2210
  o && u(this, f, q).call(this, o.table, r);
2211
2211
  }, q = function(a, r) {
2212
2212
  const o = a.identifier.name;
2213
- !d(this, T).has(o) && !d(this, S).has(o) && r.add(o);
2213
+ !c(this, T).has(o) && !c(this, S).has(o) && r.add(o);
2214
2214
  }, ve = function(a, r) {
2215
2215
  for (const o of a.expressions) {
2216
2216
  const n = o.name.table.table.identifier.name;
2217
- d(this, S).has(n) || r.add(n);
2217
+ c(this, S).has(n) || r.add(n);
2218
2218
  }
2219
2219
  };
2220
2220
  var L;
@@ -2224,7 +2224,7 @@ class Ma {
2224
2224
  M(this, L, new ja(e));
2225
2225
  }
2226
2226
  transformQuery(e) {
2227
- return d(this, L).transformNode(e.node);
2227
+ return c(this, L).transformNode(e.node);
2228
2228
  }
2229
2229
  async transformResult(e) {
2230
2230
  return e.result;
@@ -2253,7 +2253,7 @@ class Ne {
2253
2253
  * The returned array is sorted by migration name.
2254
2254
  */
2255
2255
  async getMigrations() {
2256
- const e = await u(this, i, I).call(this, d(this, i, N)) ? await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select(["name", "timestamp"]).execute() : [];
2256
+ const e = await u(this, i, I).call(this, c(this, i, N)) ? await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select(["name", "timestamp"]).execute() : [];
2257
2257
  return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2258
2258
  const n = e.find((s) => s.name === r);
2259
2259
  return {
@@ -2395,79 +2395,79 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2395
2395
  return a instanceof Q ? a.resultSet : { error: a };
2396
2396
  }
2397
2397
  }, v = function() {
2398
- return d(this, h).migrationTableSchema;
2398
+ return c(this, h).migrationTableSchema;
2399
2399
  }, N = function() {
2400
- return d(this, h).migrationTableName ?? Aa;
2400
+ return c(this, h).migrationTableName ?? Aa;
2401
2401
  }, D = function() {
2402
- return d(this, h).migrationLockTableName ?? _e;
2402
+ return c(this, h).migrationLockTableName ?? _e;
2403
2403
  }, Ce = function() {
2404
- return d(this, h).allowUnorderedMigrations ?? La;
2404
+ return c(this, h).allowUnorderedMigrations ?? La;
2405
2405
  }, C = function() {
2406
- return d(this, i, v) ? new Ma(d(this, i, v)) : new Fa();
2406
+ return c(this, i, v) ? new Ma(c(this, i, v)) : new Fa();
2407
2407
  }, be = async function() {
2408
2408
  await u(this, i, xe).call(this), await u(this, i, Te).call(this), await u(this, i, Se).call(this), await u(this, i, Oe).call(this);
2409
2409
  }, xe = async function() {
2410
- if (d(this, i, v) && !await u(this, i, G).call(this))
2410
+ if (c(this, i, v) && !await u(this, i, G).call(this))
2411
2411
  try {
2412
- await u(this, i, A).call(this, d(this, h).db.schema.createSchema(d(this, i, v)));
2412
+ await u(this, i, A).call(this, c(this, h).db.schema.createSchema(c(this, i, v)));
2413
2413
  } catch (e) {
2414
2414
  if (!await u(this, i, G).call(this))
2415
2415
  throw e;
2416
2416
  }
2417
2417
  }, Te = async function() {
2418
- if (!await u(this, i, I).call(this, d(this, i, N)))
2418
+ if (!await u(this, i, I).call(this, c(this, i, N)))
2419
2419
  try {
2420
- d(this, i, v) && await u(this, i, A).call(this, d(this, h).db.schema.createSchema(d(this, i, v))), await u(this, i, A).call(this, d(this, h).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, N)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2420
+ c(this, i, v) && await u(this, i, A).call(this, c(this, h).db.schema.createSchema(c(this, i, v))), await u(this, i, A).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, N)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2421
2421
  } catch (e) {
2422
- if (!await u(this, i, I).call(this, d(this, i, N)))
2422
+ if (!await u(this, i, I).call(this, c(this, i, N)))
2423
2423
  throw e;
2424
2424
  }
2425
2425
  }, Se = async function() {
2426
- if (!await u(this, i, I).call(this, d(this, i, D)))
2426
+ if (!await u(this, i, I).call(this, c(this, i, D)))
2427
2427
  try {
2428
- await u(this, i, A).call(this, d(this, h).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2428
+ await u(this, i, A).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2429
2429
  } catch (e) {
2430
- if (!await u(this, i, I).call(this, d(this, i, D)))
2430
+ if (!await u(this, i, I).call(this, c(this, i, D)))
2431
2431
  throw e;
2432
2432
  }
2433
2433
  }, Oe = async function() {
2434
2434
  if (!await u(this, i, H).call(this))
2435
2435
  try {
2436
- await d(this, h).db.withPlugin(d(this, i, C)).insertInto(d(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2436
+ await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2437
2437
  } catch (e) {
2438
2438
  if (!await u(this, i, H).call(this))
2439
2439
  throw e;
2440
2440
  }
2441
2441
  }, G = async function() {
2442
- return (await d(this, h).db.introspection.getSchemas()).some((a) => a.name === d(this, i, v));
2442
+ return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, v));
2443
2443
  }, I = async function(e) {
2444
- const a = d(this, i, v);
2445
- return (await d(this, h).db.introspection.getTables({
2444
+ const a = c(this, i, v);
2445
+ return (await c(this, h).db.introspection.getTables({
2446
2446
  withInternalKyselyTables: !0
2447
2447
  })).some((o) => o.name === e && (!a || o.schema === a));
2448
2448
  }, H = async function() {
2449
- return !!await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2449
+ return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2450
2450
  }, ke = async function(e) {
2451
- const a = d(this, h).db.getExecutor().adapter, r = p({
2452
- lockTable: d(this, h).migrationLockTableName ?? _e,
2451
+ const a = c(this, h).db.getExecutor().adapter, r = p({
2452
+ lockTable: c(this, h).migrationLockTableName ?? _e,
2453
2453
  lockRowId: B,
2454
- lockTableSchema: d(this, h).migrationTableSchema
2454
+ lockTableSchema: c(this, h).migrationTableSchema
2455
2455
  }), o = async (n) => {
2456
2456
  try {
2457
2457
  await a.acquireMigrationLock(n, r);
2458
2458
  const s = await u(this, i, $e).call(this, n);
2459
2459
  if (s.migrations.length === 0)
2460
2460
  return { results: [] };
2461
- const { direction: l, step: c } = e(s);
2462
- return c <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, c) : l === "Up" ? await u(this, i, Fe).call(this, n, s, c) : { results: [] };
2461
+ const { direction: l, step: d } = e(s);
2462
+ return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Fe).call(this, n, s, d) : { results: [] };
2463
2463
  } finally {
2464
2464
  await a.releaseMigrationLock(n, r);
2465
2465
  }
2466
2466
  };
2467
- return a.supportsTransactionalDdl ? d(this, h).db.transaction().execute(o) : d(this, h).db.connection().execute(o);
2467
+ return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2468
2468
  }, $e = async function(e) {
2469
2469
  const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2470
- u(this, i, Pe).call(this, a, r), d(this, i, Ce) || u(this, i, je).call(this, a, r);
2470
+ u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2471
2471
  const o = u(this, i, De).call(this, a, r);
2472
2472
  return p({
2473
2473
  migrations: a,
@@ -2478,13 +2478,13 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2478
2478
  }, De = function(e, a) {
2479
2479
  return e.filter((r) => !a.includes(r.name));
2480
2480
  }, X = async function() {
2481
- const e = await d(this, h).provider.getMigrations();
2481
+ const e = await c(this, h).provider.getMigrations();
2482
2482
  return Object.keys(e).sort().map((a) => ({
2483
2483
  ...e[a],
2484
2484
  name: a
2485
2485
  }));
2486
2486
  }, Ie = async function(e) {
2487
- return (await e.withPlugin(d(this, i, C)).selectFrom(d(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2487
+ return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2488
2488
  }, Pe = function(e, a) {
2489
2489
  for (const r of a)
2490
2490
  if (!e.some((o) => o.name === r))
@@ -2502,18 +2502,18 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2502
2502
  for (let s = 0; s < n.length; ++s) {
2503
2503
  const l = o[s];
2504
2504
  try {
2505
- l.down && (await l.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, N)).where("name", "=", l.name).execute(), n[s] = {
2505
+ l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", l.name).execute(), n[s] = {
2506
2506
  migrationName: l.name,
2507
2507
  direction: "Down",
2508
2508
  status: "Success"
2509
2509
  });
2510
- } catch (c) {
2510
+ } catch (d) {
2511
2511
  throw n[s] = {
2512
2512
  migrationName: l.name,
2513
2513
  direction: "Down",
2514
2514
  status: "Error"
2515
2515
  }, new Q({
2516
- error: c,
2516
+ error: d,
2517
2517
  results: n
2518
2518
  });
2519
2519
  }
@@ -2528,7 +2528,7 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2528
2528
  for (let s = 0; s < n.length; s++) {
2529
2529
  const l = a.pendingMigrations[s];
2530
2530
  try {
2531
- await l.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, N)).values({
2531
+ await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, N)).values({
2532
2532
  name: l.name,
2533
2533
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2534
2534
  }).execute(), n[s] = {
@@ -2536,20 +2536,20 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2536
2536
  direction: "Up",
2537
2537
  status: "Success"
2538
2538
  };
2539
- } catch (c) {
2539
+ } catch (d) {
2540
2540
  throw n[s] = {
2541
2541
  migrationName: l.name,
2542
2542
  direction: "Up",
2543
2543
  status: "Error"
2544
2544
  }, new Q({
2545
- error: c,
2545
+ error: d,
2546
2546
  results: n
2547
2547
  });
2548
2548
  }
2549
2549
  }
2550
2550
  return { results: n };
2551
2551
  }, A = async function(e) {
2552
- d(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2552
+ c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2553
2553
  };
2554
2554
  var z;
2555
2555
  class Q extends Error {
@@ -2559,7 +2559,7 @@ class Q extends Error {
2559
2559
  M(this, z, a);
2560
2560
  }
2561
2561
  get resultSet() {
2562
- return d(this, z);
2562
+ return c(this, z);
2563
2563
  }
2564
2564
  }
2565
2565
  z = new WeakMap();
@@ -2754,12 +2754,12 @@ async function sr(t) {
2754
2754
  }
2755
2755
  async function ir(t) {
2756
2756
  }
2757
- const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2757
+ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2758
2758
  __proto__: null,
2759
2759
  down: ir,
2760
2760
  up: sr
2761
2761
  }, Symbol.toStringTag, { value: "Module" }));
2762
- async function dr(t) {
2762
+ async function cr(t) {
2763
2763
  await t.schema.alterTable("passwords").addColumn(
2764
2764
  "password",
2765
2765
  "varchar(255)",
@@ -2773,7 +2773,7 @@ async function lr(t) {
2773
2773
  const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2774
2774
  __proto__: null,
2775
2775
  down: lr,
2776
- up: dr
2776
+ up: cr
2777
2777
  }, Symbol.toStringTag, { value: "Module" }));
2778
2778
  async function mr(t) {
2779
2779
  }
@@ -2946,12 +2946,12 @@ const on = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2946
2946
  async function sn(t) {
2947
2947
  await t.schema.alterTable("logs").addColumn("user_name", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("auth0_client", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("isMobile", "boolean").execute(), await t.schema.alterTable("logs").addColumn("connection", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("connection_id", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("strategy_type", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("hostname", "varchar(255)").execute(), await t.schema.alterTable("logs").addColumn("session_connection", "varchar(255)").execute();
2948
2948
  }
2949
- async function cn(t) {
2949
+ async function dn(t) {
2950
2950
  await t.schema.alterTable("logs").dropColumn("user_name").execute(), await t.schema.alterTable("logs").dropColumn("auth0_client").execute(), await t.schema.alterTable("logs").dropColumn("isMobile").execute(), await t.schema.alterTable("logs").dropColumn("connection").execute(), await t.schema.alterTable("logs").dropColumn("connection_id").execute(), await t.schema.alterTable("logs").dropColumn("audience").execute(), await t.schema.alterTable("logs").dropColumn("scope").execute(), await t.schema.alterTable("logs").dropColumn("strategy").execute(), await t.schema.alterTable("logs").dropColumn("strategy_type").execute(), await t.schema.alterTable("logs").dropColumn("hostname").execute(), await t.schema.alterTable("logs").dropColumn("session_connection").execute();
2951
2951
  }
2952
- const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2952
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2953
2953
  __proto__: null,
2954
- down: cn,
2954
+ down: dn,
2955
2955
  up: sn
2956
2956
  }, Symbol.toStringTag, { value: "Module" }));
2957
2957
  async function ln(t) {
@@ -3399,16 +3399,16 @@ const is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3399
3399
  down: ss,
3400
3400
  up: os
3401
3401
  }, Symbol.toStringTag, { value: "Module" }));
3402
- async function cs(t) {
3402
+ async function ds(t) {
3403
3403
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3404
3404
  }
3405
- async function ds(t) {
3405
+ async function cs(t) {
3406
3406
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3407
3407
  }
3408
3408
  const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3409
3409
  __proto__: null,
3410
- down: ds,
3411
- up: cs
3410
+ down: cs,
3411
+ up: ds
3412
3412
  }, Symbol.toStringTag, { value: "Module" }));
3413
3413
  async function us(t) {
3414
3414
  }
@@ -3670,6 +3670,24 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3670
3670
  __proto__: null,
3671
3671
  down: ri,
3672
3672
  up: ai
3673
+ }, Symbol.toStringTag, { value: "Module" }));
3674
+ async function oi(t) {
3675
+ await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
3676
+ "custom_domain_id",
3677
+ "varchar(256)",
3678
+ (e) => e.notNull().primaryKey()
3679
+ ).addColumn(
3680
+ "tenant_id",
3681
+ "varchar(255)",
3682
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3683
+ ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.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)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute();
3684
+ }
3685
+ async function si(t) {
3686
+ }
3687
+ const ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3688
+ __proto__: null,
3689
+ down: si,
3690
+ up: oi
3673
3691
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3674
3692
  m1_init: Ka,
3675
3693
  m2_magicLink: Ba,
@@ -3678,7 +3696,7 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3678
3696
  m5_userProfile: Za,
3679
3697
  m6_sessions: ar,
3680
3698
  m7_passwords: or,
3681
- m8_logsTableNewFields: cr,
3699
+ m8_logsTableNewFields: dr,
3682
3700
  m9_passwordTableNewField: ur,
3683
3701
  n01_codesTable: _r,
3684
3702
  n11_universalLoginSession: gr,
@@ -3696,7 +3714,7 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3696
3714
  n23_dropUsersFields: Zr,
3697
3715
  n24_logsIndexes: an,
3698
3716
  n25_logDescMaxLength: on,
3699
- n26_logsTableExtraFields: dn,
3717
+ n26_logsTableExtraFields: cn,
3700
3718
  n27_usersTableNameIndex: mn,
3701
3719
  n28_usersEmailConstrain: fn,
3702
3720
  n29_increaseOtpStateLength: yn,
@@ -3748,9 +3766,10 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3748
3766
  n76_authorization_url_length: Gs,
3749
3767
  n77_drop_sessions: Ys,
3750
3768
  n78_login_sessions: ti,
3751
- n79_drop_sessions_2: ni
3769
+ n79_drop_sessions_2: ni,
3770
+ n80_recreate_custom_domains: ii
3752
3771
  };
3753
- async function di(t, e = !1) {
3772
+ async function mi(t, e = !1) {
3754
3773
  e && console.log("migrating...");
3755
3774
  const a = new Ae(Le), r = new Ne({
3756
3775
  db: t,
@@ -3763,7 +3782,7 @@ async function di(t, e = !1) {
3763
3782
  }), o)
3764
3783
  throw console.error("failed to migrate"), console.error(o), o;
3765
3784
  }
3766
- async function li(t) {
3785
+ async function hi(t) {
3767
3786
  console.log("migrating...");
3768
3787
  const e = new Ae(Le), a = new Ne({
3769
3788
  db: t,
@@ -3774,7 +3793,7 @@ async function li(t) {
3774
3793
  }), r)
3775
3794
  throw console.error("failed to migrate"), console.error(r), r;
3776
3795
  }
3777
- function ui(t) {
3796
+ function _i(t) {
3778
3797
  return {
3779
3798
  applications: It(t),
3780
3799
  branding: Xt(t),
@@ -3787,18 +3806,18 @@ function ui(t) {
3787
3806
  hooks: ra(t),
3788
3807
  keys: Rt(t),
3789
3808
  loginSessions: _a(t),
3790
- logs: dt(t),
3809
+ logs: ct(t),
3791
3810
  passwords: wt(t),
3792
3811
  promptSettings: ga(t),
3793
3812
  refreshTokens: Oa(t),
3794
3813
  sessions: ft(t),
3795
3814
  tenants: nt(t),
3796
- themes: da(t),
3815
+ themes: ca(t),
3797
3816
  users: Xe(t)
3798
3817
  };
3799
3818
  }
3800
3819
  export {
3801
- ui as default,
3802
- li as migrateDown,
3803
- di as migrateToLatest
3820
+ _i as default,
3821
+ hi as migrateDown,
3822
+ mi as migrateToLatest
3804
3823
  };