@authhero/kysely-adapter 9.5.0 → 9.6.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,17 +1,17 @@
1
1
  var Ee = Object.defineProperty;
2
- var de = (t) => {
2
+ var le = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var ze = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var P = (t, e, a) => ze(t, typeof e != "symbol" ? e + "" : e, a), R = (t, e, a) => e.has(t) || de("Cannot " + a);
7
- var l = (t, e, a) => (R(t, e, "read from private field"), a ? a.call(t) : e.get(t)), y = (t, e, a) => e.has(t) ? de("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);
6
+ var j = (t, e, a) => ze(t, typeof e != "symbol" ? e + "" : e, a), R = (t, e, a) => e.has(t) || le("Cannot " + 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 {
11
11
  constructor(e = 500, a) {
12
12
  super(a == null ? void 0 : a.message, { cause: a == null ? void 0 : a.cause });
13
- P(this, "res");
14
- P(this, "status");
13
+ j(this, "res");
14
+ j(this, "status");
15
15
  this.res = a == null ? void 0 : a.res, this.status = e;
16
16
  }
17
17
  getResponse() {
@@ -83,7 +83,7 @@ function Qe(t) {
83
83
  ]);
84
84
  if (!r)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, d = {
86
+ const { tenant_id: n, ...s } = r, l = {
87
87
  ...s,
88
88
  email: r.email || "",
89
89
  email_verified: r.email_verified === 1,
@@ -100,18 +100,18 @@ function Qe(t) {
100
100
  ...o.map(fe)
101
101
  ]
102
102
  };
103
- return _(d);
103
+ return _(l);
104
104
  };
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("-"), d, c, g, m;
109
- return n.startsWith("-_exists_:") ? (d = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (d = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [d, 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 = "=") : (d = null, c = n, g = !1), { key: d, value: c, isNegation: s, isExistsQuery: g, operator: m };
110
- }).forEach(({ key: n, value: s, isNegation: d, 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)
113
- d ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
- else if (d)
112
+ if (d)
113
+ l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
+ else if (l)
115
115
  switch (g) {
116
116
  case ">":
117
117
  e = e.where(n, "<=", s);
@@ -154,8 +154,8 @@ 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), d = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], c = n.map((m) => {
158
- const w = d.filter(
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
+ const w = l.filter(
159
159
  (b) => b.linked_to === m.user_id
160
160
  );
161
161
  return _({
@@ -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)
@@ -249,16 +249,16 @@ function tt(t) {
249
249
  }) => {
250
250
  let a = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
- const { ref: d } = t.dynamic;
253
- a = a.orderBy(d(e.sort.sort_by), e.sort.sort_order);
252
+ const { ref: l } = t.dynamic;
253
+ a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((d) => d.or([d("name", "like", `%${e.q}%`)])));
255
+ e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
256
  const o = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
257
257
  if (!e.include_totals)
258
258
  return {
259
259
  tenants: o
260
260
  };
261
- const { count: n } = await a.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(n);
261
+ const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(n);
262
262
  return {
263
263
  tenants: o.map(_),
264
264
  start: (e.page - 1) * e.per_page,
@@ -345,14 +345,14 @@ function it(t) {
345
345
  a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
346
346
  let o = r;
347
347
  if (a.sort && a.sort.sort_by) {
348
- const { ref: d } = t.dynamic;
348
+ const { ref: l } = t.dynamic;
349
349
  o = o.orderBy(
350
- d(a.sort.sort_by),
350
+ l(a.sort.sort_by),
351
351
  a.sort.sort_order
352
352
  );
353
353
  }
354
354
  o = o.offset(a.page * a.per_page).limit(a.per_page);
355
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
355
+ const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
357
  logs: n.map(pe),
358
358
  start: a.page * a.per_page,
@@ -361,27 +361,27 @@ 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 lt(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
- function dt(t) {
377
+ function lt(t) {
378
378
  return async (e, a) => {
379
379
  const r = await t.selectFrom("sessions_2").where("sessions_2.tenant_id", "=", e).where("sessions_2.id", "=", a).where("sessions_2.revoked_at", "is", null).selectAll().executeTakeFirst();
380
380
  if (!r)
381
381
  return null;
382
- const { tenant_id: o, device: n, clients: s, ...d } = r;
382
+ const { tenant_id: o, device: n, clients: s, ...l } = r;
383
383
  return {
384
- ...d,
384
+ ...l,
385
385
  device: JSON.parse(n),
386
386
  clients: JSON.parse(s)
387
387
  };
@@ -428,30 +428,30 @@ 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(), d = 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,
447
- length: d
447
+ length: l
448
448
  };
449
449
  };
450
450
  }
451
451
  function ft(t) {
452
452
  return {
453
453
  create: ut(t),
454
- get: dt(t),
454
+ get: lt(t),
455
455
  list: _t(t),
456
456
  remove: mt(t),
457
457
  update: ht(t)
@@ -500,10 +500,10 @@ function Nt(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), d = 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,
@@ -562,8 +562,8 @@ function St(t) {
562
562
  callbacks: n,
563
563
  allowed_origins: o,
564
564
  web_origins: s,
565
- allowed_logout_urls: d,
566
- allowed_clients: c
565
+ allowed_logout_urls: l,
566
+ allowed_clients: d
567
567
  }).execute(), r;
568
568
  };
569
569
  }
@@ -623,7 +623,7 @@ function It(t) {
623
623
  update: Dt(t)
624
624
  };
625
625
  }
626
- function jt(t) {
626
+ function Pt(t) {
627
627
  return async (e, a) => {
628
628
  const r = {
629
629
  id: k(),
@@ -639,7 +639,7 @@ function jt(t) {
639
639
  }).execute(), r;
640
640
  };
641
641
  }
642
- function Pt(t) {
642
+ function jt(t) {
643
643
  return async (e, a = {
644
644
  page: 0,
645
645
  per_page: 50,
@@ -648,16 +648,16 @@ function Pt(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: d } = 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,
659
659
  limit: a.per_page,
660
- length: x(d)
660
+ length: x(l)
661
661
  };
662
662
  };
663
663
  }
@@ -687,9 +687,9 @@ function Ft(t) {
687
687
  }
688
688
  function Lt(t) {
689
689
  return {
690
- create: jt(t),
690
+ create: Pt(t),
691
691
  get: At(t),
692
- list: Pt(t),
692
+ list: jt(t),
693
693
  remove: Mt(t),
694
694
  update: Ft(t)
695
695
  };
@@ -814,8 +814,8 @@ function Gt(t) {
814
814
  colors_primary: o,
815
815
  colors_page_background_type: n,
816
816
  colors_page_background_start: s,
817
- colors_page_background_end: d,
818
- colors_page_background_angle_dev: c,
817
+ colors_page_background_end: l,
818
+ colors_page_background_angle_dev: d,
819
819
  font_url: g,
820
820
  ...m
821
821
  } = a;
@@ -826,8 +826,8 @@ function Gt(t) {
826
826
  page_background: {
827
827
  type: n,
828
828
  start: s,
829
- end: d,
830
- angle_deg: c
829
+ end: l,
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, d, c, g, m, w, b, Z, ee, te, ae, re, ne, oe, se, ie, ce, le;
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
- colors_page_background_type: (d = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : d.type,
846
- colors_page_background_start: (g = (c = a.colors) == null ? void 0 : c.page_background) == null ? void 0 : g.start,
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 = (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: (le = a.font) == null ? void 0 : le.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 = z({
993
993
  ...r,
@@ -996,15 +996,15 @@ 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 la(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
- function da(t) {
1007
+ function la(t) {
1008
1008
  return async (e, a) => {
1009
1009
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
1010
1010
  return o ? Re.parse(
@@ -1032,7 +1032,7 @@ function ha(t) {
1032
1032
  function _a(t) {
1033
1033
  return {
1034
1034
  create: ua(t),
1035
- get: da(t),
1035
+ get: la(t),
1036
1036
  update: ma(t),
1037
1037
  remove: ha(t)
1038
1038
  };
@@ -1086,10 +1086,10 @@ function ya(t) {
1086
1086
  credentials: o,
1087
1087
  settings: n,
1088
1088
  enabled: s,
1089
- ...d
1089
+ ...l
1090
1090
  } = a;
1091
1091
  return _({
1092
- ...d,
1092
+ ...l,
1093
1093
  credentials: JSON.parse(o),
1094
1094
  settings: JSON.parse(n),
1095
1095
  enabled: !!s
@@ -1178,24 +1178,24 @@ function Sa(t) {
1178
1178
  a.q && (r = O(t, r, a.q, ["token", "session_id"]));
1179
1179
  let o = r;
1180
1180
  if (a.sort && a.sort.sort_by) {
1181
- const { ref: c } = t.dynamic;
1181
+ const { ref: d } = t.dynamic;
1182
1182
  o = o.orderBy(
1183
- c(a.sort.sort_by),
1183
+ d(a.sort.sort_by),
1184
1184
  a.sort.sort_order
1185
1185
  );
1186
1186
  }
1187
1187
  o = o.offset(a.page * a.per_page).limit(a.per_page);
1188
- const n = await o.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), d = x(s);
1188
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1189
1189
  return {
1190
- refresh_tokens: n.map((c) => ({
1191
- ...c,
1192
- rotating: !!c.rotating,
1193
- device: c.device ? JSON.parse(c.device) : {},
1194
- resource_servers: c.resource_servers ? JSON.parse(c.resource_servers) : []
1190
+ refresh_tokens: n.map((d) => ({
1191
+ ...d,
1192
+ rotating: !!d.rotating,
1193
+ device: d.device ? JSON.parse(d.device) : {},
1194
+ resource_servers: d.resource_servers ? JSON.parse(d.resource_servers) : []
1195
1195
  })),
1196
1196
  start: a.page * a.per_page,
1197
1197
  limit: a.per_page,
1198
- length: d
1198
+ length: l
1199
1199
  };
1200
1200
  };
1201
1201
  }
@@ -1272,7 +1272,7 @@ const J = p({
1272
1272
  var K;
1273
1273
  class Da {
1274
1274
  constructor() {
1275
- P(this, "nodeStack", []);
1275
+ j(this, "nodeStack", []);
1276
1276
  y(this, K, p({
1277
1277
  AliasNode: this.transformAlias.bind(this),
1278
1278
  ColumnNode: this.transformColumn.bind(this),
@@ -1377,7 +1377,7 @@ class Da {
1377
1377
  return this.nodeStack.pop(), p(a);
1378
1378
  }
1379
1379
  transformNodeImpl(e) {
1380
- return l(this, K)[e.kind](e);
1380
+ return c(this, K)[e.kind](e);
1381
1381
  }
1382
1382
  transformNodeList(e) {
1383
1383
  return e && p(e.map((a) => this.transformNode(a)));
@@ -2123,48 +2123,48 @@ const Ia = p({
2123
2123
  UpdateQueryNode: !0,
2124
2124
  MergeQueryNode: !0
2125
2125
  });
2126
- var j, T, S, f, ge, ye, we, $, q, Ne;
2127
- class ja extends Da {
2126
+ var P, T, S, f, ge, ye, we, $, q, Ne;
2127
+ class Pa extends Da {
2128
2128
  constructor(a) {
2129
2129
  super();
2130
2130
  y(this, f);
2131
- y(this, j);
2131
+ y(this, P);
2132
2132
  y(this, T, /* @__PURE__ */ new Set());
2133
2133
  y(this, S, /* @__PURE__ */ new Set());
2134
- M(this, j, a);
2134
+ M(this, P, a);
2135
2135
  }
2136
2136
  transformNodeImpl(a) {
2137
2137
  if (!u(this, f, ge).call(this, a))
2138
2138
  return super.transformNodeImpl(a);
2139
2139
  const r = u(this, f, we).call(this, a);
2140
2140
  for (const s of r)
2141
- l(this, S).add(s);
2141
+ c(this, S).add(s);
2142
2142
  const o = u(this, f, ye).call(this, a);
2143
2143
  for (const s of o)
2144
- l(this, T).add(s);
2144
+ c(this, T).add(s);
2145
2145
  const n = super.transformNodeImpl(a);
2146
2146
  for (const s of o)
2147
- l(this, T).delete(s);
2147
+ c(this, T).delete(s);
2148
2148
  for (const s of r)
2149
- l(this, S).delete(s);
2149
+ c(this, S).delete(s);
2150
2150
  return n;
2151
2151
  }
2152
2152
  transformSchemableIdentifier(a) {
2153
2153
  const r = super.transformSchemableIdentifier(a);
2154
- return r.schema || !l(this, T).has(a.identifier.name) ? r : {
2154
+ return r.schema || !c(this, T).has(a.identifier.name) ? r : {
2155
2155
  ...r,
2156
- schema: J.create(l(this, j))
2156
+ schema: J.create(c(this, P))
2157
2157
  };
2158
2158
  }
2159
2159
  transformReferences(a) {
2160
2160
  const r = super.transformReferences(a);
2161
2161
  return r.table.table.schema ? r : {
2162
2162
  ...r,
2163
- table: U.createWithSchema(l(this, j), r.table.table.identifier.name)
2163
+ table: U.createWithSchema(c(this, P), r.table.table.identifier.name)
2164
2164
  };
2165
2165
  }
2166
2166
  }
2167
- j = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge = function(a) {
2167
+ P = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge = function(a) {
2168
2168
  return a.kind in Ia;
2169
2169
  }, ye = function(a) {
2170
2170
  const r = /* @__PURE__ */ new Set();
@@ -2183,21 +2183,21 @@ j = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge =
2183
2183
  o && u(this, f, q).call(this, o.table, r);
2184
2184
  }, q = function(a, r) {
2185
2185
  const o = a.identifier.name;
2186
- !l(this, T).has(o) && !l(this, S).has(o) && r.add(o);
2186
+ !c(this, T).has(o) && !c(this, S).has(o) && r.add(o);
2187
2187
  }, Ne = function(a, r) {
2188
2188
  for (const o of a.expressions) {
2189
2189
  const n = o.name.table.table.identifier.name;
2190
- l(this, S).has(n) || r.add(n);
2190
+ c(this, S).has(n) || r.add(n);
2191
2191
  }
2192
2192
  };
2193
2193
  var L;
2194
- class Pa {
2194
+ class ja {
2195
2195
  constructor(e) {
2196
2196
  y(this, L);
2197
- M(this, L, new ja(e));
2197
+ M(this, L, new Pa(e));
2198
2198
  }
2199
2199
  transformQuery(e) {
2200
- return l(this, L).transformNode(e.node);
2200
+ return c(this, L).transformNode(e.node);
2201
2201
  }
2202
2202
  async transformResult(e) {
2203
2203
  return e.result;
@@ -2213,7 +2213,7 @@ class Ma {
2213
2213
  }
2214
2214
  }
2215
2215
  const Aa = "kysely_migration", _e = "kysely_migration_lock", Fa = !1, B = "migration_lock", La = p({ __noMigrations__: !0 });
2216
- var h, i, A, N, v, D, Ce, C, be, xe, Te, Se, Oe, G, I, H, ke, $e, De, X, Ie, je, Pe, Me, Ae, F;
2216
+ var h, i, A, N, v, D, Ce, C, be, xe, Te, Se, Oe, G, I, H, ke, $e, De, X, Ie, Pe, je, Me, Ae, F;
2217
2217
  class ve {
2218
2218
  constructor(e) {
2219
2219
  y(this, i);
@@ -2226,7 +2226,7 @@ class ve {
2226
2226
  * The returned array is sorted by migration name.
2227
2227
  */
2228
2228
  async getMigrations() {
2229
- const e = await u(this, i, I).call(this, l(this, i, v)) ? await l(this, h).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, v)).select(["name", "timestamp"]).execute() : [];
2229
+ const e = await u(this, i, I).call(this, c(this, i, v)) ? await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select(["name", "timestamp"]).execute() : [];
2230
2230
  return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2231
2231
  const n = e.find((s) => s.name === r);
2232
2232
  return {
@@ -2313,9 +2313,9 @@ class ve {
2313
2313
  return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2314
2314
  if (e === La)
2315
2315
  return { direction: "Down", step: 1 / 0 };
2316
- if (!a.find((d) => d.name === e))
2316
+ if (!a.find((l) => l.name === e))
2317
2317
  throw new Error(`migration "${e}" doesn't exist`);
2318
- const n = r.indexOf(e), s = o.findIndex((d) => d.name === e);
2318
+ const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2319
2319
  if (n !== -1)
2320
2320
  return {
2321
2321
  direction: "Down",
@@ -2368,79 +2368,79 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2368
2368
  return a instanceof Q ? a.resultSet : { error: a };
2369
2369
  }
2370
2370
  }, N = function() {
2371
- return l(this, h).migrationTableSchema;
2371
+ return c(this, h).migrationTableSchema;
2372
2372
  }, v = function() {
2373
- return l(this, h).migrationTableName ?? Aa;
2373
+ return c(this, h).migrationTableName ?? Aa;
2374
2374
  }, D = function() {
2375
- return l(this, h).migrationLockTableName ?? _e;
2375
+ return c(this, h).migrationLockTableName ?? _e;
2376
2376
  }, Ce = function() {
2377
- return l(this, h).allowUnorderedMigrations ?? Fa;
2377
+ return c(this, h).allowUnorderedMigrations ?? Fa;
2378
2378
  }, C = function() {
2379
- return l(this, i, N) ? new Pa(l(this, i, N)) : new Ma();
2379
+ return c(this, i, N) ? new ja(c(this, i, N)) : new Ma();
2380
2380
  }, be = async function() {
2381
2381
  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);
2382
2382
  }, xe = async function() {
2383
- if (l(this, i, N) && !await u(this, i, G).call(this))
2383
+ if (c(this, i, N) && !await u(this, i, G).call(this))
2384
2384
  try {
2385
- await u(this, i, F).call(this, l(this, h).db.schema.createSchema(l(this, i, N)));
2385
+ await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N)));
2386
2386
  } catch (e) {
2387
2387
  if (!await u(this, i, G).call(this))
2388
2388
  throw e;
2389
2389
  }
2390
2390
  }, Te = async function() {
2391
- if (!await u(this, i, I).call(this, l(this, i, v)))
2391
+ if (!await u(this, i, I).call(this, c(this, i, v)))
2392
2392
  try {
2393
- l(this, i, N) && await u(this, i, F).call(this, l(this, h).db.schema.createSchema(l(this, i, N))), await u(this, i, F).call(this, l(this, h).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2393
+ c(this, i, N) && await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N))), await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2394
2394
  } catch (e) {
2395
- if (!await u(this, i, I).call(this, l(this, i, v)))
2395
+ if (!await u(this, i, I).call(this, c(this, i, v)))
2396
2396
  throw e;
2397
2397
  }
2398
2398
  }, Se = async function() {
2399
- if (!await u(this, i, I).call(this, l(this, i, D)))
2399
+ if (!await u(this, i, I).call(this, c(this, i, D)))
2400
2400
  try {
2401
- await u(this, i, F).call(this, l(this, h).db.schema.withPlugin(l(this, i, C)).createTable(l(this, i, D)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2401
+ await u(this, i, F).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)));
2402
2402
  } catch (e) {
2403
- if (!await u(this, i, I).call(this, l(this, i, D)))
2403
+ if (!await u(this, i, I).call(this, c(this, i, D)))
2404
2404
  throw e;
2405
2405
  }
2406
2406
  }, Oe = async function() {
2407
2407
  if (!await u(this, i, H).call(this))
2408
2408
  try {
2409
- await l(this, h).db.withPlugin(l(this, i, C)).insertInto(l(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2409
+ await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2410
2410
  } catch (e) {
2411
2411
  if (!await u(this, i, H).call(this))
2412
2412
  throw e;
2413
2413
  }
2414
2414
  }, G = async function() {
2415
- return (await l(this, h).db.introspection.getSchemas()).some((a) => a.name === l(this, i, N));
2415
+ return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, N));
2416
2416
  }, I = async function(e) {
2417
- const a = l(this, i, N);
2418
- return (await l(this, h).db.introspection.getTables({
2417
+ const a = c(this, i, N);
2418
+ return (await c(this, h).db.introspection.getTables({
2419
2419
  withInternalKyselyTables: !0
2420
2420
  })).some((o) => o.name === e && (!a || o.schema === a));
2421
2421
  }, H = async function() {
2422
- return !!await l(this, h).db.withPlugin(l(this, i, C)).selectFrom(l(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2422
+ return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2423
2423
  }, ke = async function(e) {
2424
- const a = l(this, h).db.getExecutor().adapter, r = p({
2425
- lockTable: l(this, h).migrationLockTableName ?? _e,
2424
+ const a = c(this, h).db.getExecutor().adapter, r = p({
2425
+ lockTable: c(this, h).migrationLockTableName ?? _e,
2426
2426
  lockRowId: B,
2427
- lockTableSchema: l(this, h).migrationTableSchema
2427
+ lockTableSchema: c(this, h).migrationTableSchema
2428
2428
  }), o = async (n) => {
2429
2429
  try {
2430
2430
  await a.acquireMigrationLock(n, r);
2431
2431
  const s = await u(this, i, $e).call(this, n);
2432
2432
  if (s.migrations.length === 0)
2433
2433
  return { results: [] };
2434
- const { direction: d, step: c } = e(s);
2435
- return c <= 0 ? { results: [] } : d === "Down" ? await u(this, i, Me).call(this, n, s, c) : d === "Up" ? await u(this, i, Ae).call(this, n, s, c) : { results: [] };
2434
+ const { direction: l, step: d } = e(s);
2435
+ return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Ae).call(this, n, s, d) : { results: [] };
2436
2436
  } finally {
2437
2437
  await a.releaseMigrationLock(n, r);
2438
2438
  }
2439
2439
  };
2440
- return a.supportsTransactionalDdl ? l(this, h).db.transaction().execute(o) : l(this, h).db.connection().execute(o);
2440
+ return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2441
2441
  }, $e = async function(e) {
2442
2442
  const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2443
- u(this, i, je).call(this, a, r), l(this, i, Ce) || u(this, i, Pe).call(this, a, r);
2443
+ u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2444
2444
  const o = u(this, i, De).call(this, a, r);
2445
2445
  return p({
2446
2446
  migrations: a,
@@ -2451,42 +2451,42 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2451
2451
  }, De = function(e, a) {
2452
2452
  return e.filter((r) => !a.includes(r.name));
2453
2453
  }, X = async function() {
2454
- const e = await l(this, h).provider.getMigrations();
2454
+ const e = await c(this, h).provider.getMigrations();
2455
2455
  return Object.keys(e).sort().map((a) => ({
2456
2456
  ...e[a],
2457
2457
  name: a
2458
2458
  }));
2459
2459
  }, Ie = async function(e) {
2460
- return (await e.withPlugin(l(this, i, C)).selectFrom(l(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2461
- }, je = function(e, a) {
2460
+ return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2461
+ }, Pe = function(e, a) {
2462
2462
  for (const r of a)
2463
2463
  if (!e.some((o) => o.name === r))
2464
2464
  throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2465
- }, Pe = function(e, a) {
2465
+ }, je = function(e, a) {
2466
2466
  for (let r = 0; r < a.length; ++r)
2467
2467
  if (e[r].name !== a[r])
2468
2468
  throw new Error(`corrupted migrations: expected previously executed migration ${a[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`);
2469
2469
  }, Me = async function(e, a, r) {
2470
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((d) => d.name === s)), n = o.map((s) => ({
2470
+ const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2471
2471
  migrationName: s.name,
2472
2472
  direction: "Down",
2473
2473
  status: "NotExecuted"
2474
2474
  }));
2475
2475
  for (let s = 0; s < n.length; ++s) {
2476
- const d = o[s];
2476
+ const l = o[s];
2477
2477
  try {
2478
- d.down && (await d.down(e), await e.withPlugin(l(this, i, C)).deleteFrom(l(this, i, v)).where("name", "=", d.name).execute(), n[s] = {
2479
- migrationName: d.name,
2478
+ l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, v)).where("name", "=", l.name).execute(), n[s] = {
2479
+ migrationName: l.name,
2480
2480
  direction: "Down",
2481
2481
  status: "Success"
2482
2482
  });
2483
- } catch (c) {
2483
+ } catch (d) {
2484
2484
  throw n[s] = {
2485
- migrationName: d.name,
2485
+ migrationName: l.name,
2486
2486
  direction: "Down",
2487
2487
  status: "Error"
2488
2488
  }, new Q({
2489
- error: c,
2489
+ error: d,
2490
2490
  results: n
2491
2491
  });
2492
2492
  }
@@ -2499,30 +2499,30 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2499
2499
  status: "NotExecuted"
2500
2500
  }));
2501
2501
  for (let s = 0; s < n.length; s++) {
2502
- const d = a.pendingMigrations[s];
2502
+ const l = a.pendingMigrations[s];
2503
2503
  try {
2504
- await d.up(e), await e.withPlugin(l(this, i, C)).insertInto(l(this, i, v)).values({
2505
- name: d.name,
2504
+ await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, v)).values({
2505
+ name: l.name,
2506
2506
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2507
2507
  }).execute(), n[s] = {
2508
- migrationName: d.name,
2508
+ migrationName: l.name,
2509
2509
  direction: "Up",
2510
2510
  status: "Success"
2511
2511
  };
2512
- } catch (c) {
2512
+ } catch (d) {
2513
2513
  throw n[s] = {
2514
- migrationName: d.name,
2514
+ migrationName: l.name,
2515
2515
  direction: "Up",
2516
2516
  status: "Error"
2517
2517
  }, new Q({
2518
- error: c,
2518
+ error: d,
2519
2519
  results: n
2520
2520
  });
2521
2521
  }
2522
2522
  }
2523
2523
  return { results: n };
2524
2524
  }, F = async function(e) {
2525
- l(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2525
+ c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2526
2526
  };
2527
2527
  var E;
2528
2528
  class Q extends Error {
@@ -2532,13 +2532,13 @@ class Q extends Error {
2532
2532
  M(this, E, a);
2533
2533
  }
2534
2534
  get resultSet() {
2535
- return l(this, E);
2535
+ return c(this, E);
2536
2536
  }
2537
2537
  }
2538
2538
  E = new WeakMap();
2539
2539
  class Fe {
2540
2540
  constructor(e) {
2541
- P(this, "migrations");
2541
+ j(this, "migrations");
2542
2542
  this.migrations = e;
2543
2543
  }
2544
2544
  async getMigrations() {
@@ -2732,7 +2732,7 @@ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2732
2732
  down: sr,
2733
2733
  up: or
2734
2734
  }, Symbol.toStringTag, { value: "Module" }));
2735
- async function cr(t) {
2735
+ async function dr(t) {
2736
2736
  await t.schema.alterTable("passwords").addColumn(
2737
2737
  "password",
2738
2738
  "varchar(255)",
@@ -2740,13 +2740,13 @@ async function cr(t) {
2740
2740
  (e) => e.notNull()
2741
2741
  ).execute();
2742
2742
  }
2743
- async function lr(t) {
2743
+ async function cr(t) {
2744
2744
  await t.schema.alterTable("passwords").dropColumn("password").execute();
2745
2745
  }
2746
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2746
+ const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2747
2747
  __proto__: null,
2748
- down: lr,
2749
- up: cr
2748
+ down: cr,
2749
+ up: dr
2750
2750
  }, Symbol.toStringTag, { value: "Module" }));
2751
2751
  async function ur(t) {
2752
2752
  }
@@ -2819,20 +2819,20 @@ const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2819
2819
  down: Dr,
2820
2820
  up: $r
2821
2821
  }, Symbol.toStringTag, { value: "Module" }));
2822
- async function jr(t) {
2822
+ async function Pr(t) {
2823
2823
  await t.schema.createTable("keys").addColumn("kid", "varchar(255)", (e) => e.primaryKey()).addColumn(
2824
2824
  "tenant_id",
2825
2825
  "varchar(255)",
2826
2826
  (e) => e.references("tenants.id").onDelete("cascade")
2827
2827
  ).addColumn("created_at", "varchar(255)", (e) => e.notNull()).addColumn("revoked_at", "varchar(255)").addColumn("cert", "varchar(2048)").addColumn("pkcs7", "varchar(2048)").addColumn("fingerprint", "varchar(256)").addColumn("thumbprint", "varchar(256)").addColumn("current_since", "varchar(256)").addColumn("current_until", "varchar(256)").execute();
2828
2828
  }
2829
- async function Pr(t) {
2829
+ async function jr(t) {
2830
2830
  await t.schema.dropTable("keys").execute();
2831
2831
  }
2832
2832
  const Mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2833
2833
  __proto__: null,
2834
- down: Pr,
2835
- up: jr
2834
+ down: jr,
2835
+ up: Pr
2836
2836
  }, Symbol.toStringTag, { value: "Module" }));
2837
2837
  async function Ar(t) {
2838
2838
  }
@@ -2922,21 +2922,21 @@ async function on(t) {
2922
2922
  async function sn(t) {
2923
2923
  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();
2924
2924
  }
2925
- const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2925
+ const dn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2926
2926
  __proto__: null,
2927
2927
  down: sn,
2928
2928
  up: on
2929
2929
  }, Symbol.toStringTag, { value: "Module" }));
2930
- async function ln(t) {
2930
+ async function cn(t) {
2931
2931
  await t.schema.createIndex("users_name_index").on("users").column("name").execute();
2932
2932
  }
2933
- async function dn(t) {
2933
+ async function ln(t) {
2934
2934
  await t.schema.dropIndex("users_name_index").execute();
2935
2935
  }
2936
2936
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2937
2937
  __proto__: null,
2938
- down: dn,
2939
- up: ln
2938
+ down: ln,
2939
+ up: cn
2940
2940
  }, Symbol.toStringTag, { value: "Module" }));
2941
2941
  async function mn(t) {
2942
2942
  }
@@ -3007,19 +3007,19 @@ async function Dn(t) {
3007
3007
  }
3008
3008
  async function In(t) {
3009
3009
  }
3010
- const jn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3010
+ const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3011
3011
  __proto__: null,
3012
3012
  down: In,
3013
3013
  up: Dn
3014
3014
  }, Symbol.toStringTag, { value: "Module" }));
3015
- async function Pn(t) {
3015
+ async function jn(t) {
3016
3016
  }
3017
3017
  async function Mn(t) {
3018
3018
  }
3019
3019
  const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3020
3020
  __proto__: null,
3021
3021
  down: Mn,
3022
- up: Pn
3022
+ up: jn
3023
3023
  }, Symbol.toStringTag, { value: "Module" }));
3024
3024
  async function Fn(t) {
3025
3025
  await t.schema.createTable("authentication_codes").addColumn(
@@ -3219,11 +3219,11 @@ const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3219
3219
  }, Symbol.toStringTag, { value: "Module" }));
3220
3220
  async function Io(t) {
3221
3221
  }
3222
- async function jo(t) {
3222
+ async function Po(t) {
3223
3223
  }
3224
- const Po = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3224
+ const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3225
3225
  __proto__: null,
3226
- down: jo,
3226
+ down: Po,
3227
3227
  up: Io
3228
3228
  }, Symbol.toStringTag, { value: "Module" }));
3229
3229
  async function Mo(t) {
@@ -3375,22 +3375,22 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3375
3375
  async function is(t) {
3376
3376
  await t.schema.alterTable("logins").addColumn("authParams_prompt", "varchar(16)").execute();
3377
3377
  }
3378
- async function cs(t) {
3378
+ async function ds(t) {
3379
3379
  await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute();
3380
3380
  }
3381
- const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3381
+ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3382
3382
  __proto__: null,
3383
- down: cs,
3383
+ down: ds,
3384
3384
  up: is
3385
3385
  }, Symbol.toStringTag, { value: "Module" }));
3386
- async function ds(t) {
3386
+ async function ls(t) {
3387
3387
  }
3388
3388
  async function us(t) {
3389
3389
  }
3390
3390
  const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3391
3391
  __proto__: null,
3392
3392
  down: us,
3393
- up: ds
3393
+ up: ls
3394
3394
  }, Symbol.toStringTag, { value: "Module" }));
3395
3395
  async function hs(t) {
3396
3396
  await t.schema.alterTable("logins").addColumn("authParams_act_as", "varchar(255)").execute();
@@ -3485,11 +3485,11 @@ const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3485
3485
  }, Symbol.toStringTag, { value: "Module" }));
3486
3486
  async function Is(t) {
3487
3487
  }
3488
- async function js(t) {
3488
+ async function Ps(t) {
3489
3489
  }
3490
- const Ps = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3490
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3491
3491
  __proto__: null,
3492
- down: js,
3492
+ down: Ps,
3493
3493
  up: Is
3494
3494
  }, Symbol.toStringTag, { value: "Module" }));
3495
3495
  async function Ms(t) {
@@ -3598,6 +3598,41 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3598
3598
  __proto__: null,
3599
3599
  down: Hs,
3600
3600
  up: Gs
3601
+ }, Symbol.toStringTag, { value: "Module" }));
3602
+ async function Ys(t) {
3603
+ await t.schema.createTable("sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3604
+ "sessions_user_id_constraint",
3605
+ ["user_id", "tenant_id"],
3606
+ "users",
3607
+ ["user_id", "tenant_id"],
3608
+ (e) => e.onDelete("cascade")
3609
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("authenticated_at", "varchar(35)").addColumn("last_interaction_at", "varchar(35)").addColumn("used_at", "varchar(35)").addColumn("revoked_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("clients", "varchar(1024)", (e) => e.notNull()).execute(), await t.schema.createTable("login_sessions").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3610
+ "tenant_id",
3611
+ "varchar(255)",
3612
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3613
+ ).addColumn(
3614
+ "session_id",
3615
+ "varchar(21)",
3616
+ (e) => e.references("sessions.id").onDelete("cascade")
3617
+ ).addColumn("csrf_token", "varchar(21)", (e) => e.notNull()).addColumn("authParams_client_id", "varchar(255)", (e) => e.notNull()).addColumn("authParams_vendor_id", "varchar(255)").addColumn("authParams_username", "varchar(255)").addColumn("authParams_response_type", "varchar(255)").addColumn("authParams_response_mode", "varchar(255)").addColumn("authParams_audience", "varchar(255)").addColumn("authParams_scope", "varchar(511)").addColumn("authParams_state", "varchar(511)").addColumn("authParams_code_challenge_method", "varchar(256)").addColumn("authParams_code_challenge", "varchar(256)").addColumn("authParams_redirect_uri", "varchar(256)").addColumn("authParams_organization", "varchar(256)").addColumn("authorization_url", "varchar(1024)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)", (e) => e.notNull()).addColumn("ip", "varchar(39)").addColumn("useragent", "varchar(1024)").execute(), await t.schema.createTable("refresh_tokens").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3618
+ "client_id",
3619
+ "varchar(21)",
3620
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3621
+ ).addColumn("tenant_id", "varchar(255)").addColumn("session_id", "varchar(21)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3622
+ "refresh_tokens_user_id_constraint",
3623
+ ["user_id", "tenant_id"],
3624
+ "users",
3625
+ ["user_id", "tenant_id"],
3626
+ (e) => e.onDelete("cascade")
3627
+ ).addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("expires_at", "varchar(35)").addColumn("idle_expires_at", "varchar(35)").addColumn("last_exchanged_at", "varchar(35)").addColumn("device", "varchar(2048)", (e) => e.notNull()).addColumn("resource_servers", "varchar(2048)", (e) => e.notNull()).addColumn("rotating", "boolean", (e) => e.notNull()).execute();
3628
+ }
3629
+ async function Zs(t) {
3630
+ await t.schema.dropTable("login_sessions").execute();
3631
+ }
3632
+ const ei = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3633
+ __proto__: null,
3634
+ down: Zs,
3635
+ up: Ys
3601
3636
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3602
3637
  m1_init: Ja,
3603
3638
  m2_magicLink: Ua,
@@ -3607,7 +3642,7 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3607
3642
  m6_sessions: tr,
3608
3643
  m7_passwords: nr,
3609
3644
  m8_logsTableNewFields: ir,
3610
- m9_passwordTableNewField: dr,
3645
+ m9_passwordTableNewField: lr,
3611
3646
  n01_codesTable: hr,
3612
3647
  n11_universalLoginSession: pr,
3613
3648
  n12_userFields: wr,
@@ -3624,7 +3659,7 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3624
3659
  n23_dropUsersFields: Yr,
3625
3660
  n24_logsIndexes: tn,
3626
3661
  n25_logDescMaxLength: nn,
3627
- n26_logsTableExtraFields: cn,
3662
+ n26_logsTableExtraFields: dn,
3628
3663
  n27_usersTableNameIndex: un,
3629
3664
  n28_usersEmailConstrain: _n,
3630
3665
  n29_increaseOtpStateLength: gn,
@@ -3632,7 +3667,7 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3632
3667
  n31_branding: bn,
3633
3668
  n32_indexesAndNotNull: Sn,
3634
3669
  n33_vendorIdInUniversalLoginSession: $n,
3635
- n34_auth0ClientInUniversalLoginSession: jn,
3670
+ n34_auth0ClientInUniversalLoginSession: Pn,
3636
3671
  n35_increaseUniversalSessionStateLength: An,
3637
3672
  n36_authenticationCodes: En,
3638
3673
  n37_disableSignUps: Kn,
@@ -3650,7 +3685,7 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3650
3685
  n49_removeFields: xo,
3651
3686
  n50_authParamsNonce: Oo,
3652
3687
  n51_connectionid: Do,
3653
- n52_cert: Po,
3688
+ n52_cert: jo,
3654
3689
  n53_codes_primary_key: Fo,
3655
3690
  n54_cleanup_tables: zo,
3656
3691
  n55_logs_index: Ro,
@@ -3660,7 +3695,7 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3660
3695
  n59_connection_options: es,
3661
3696
  n60_users_metadata: rs,
3662
3697
  n61_userLocales: ss,
3663
- n62_prompt: ls,
3698
+ n62_prompt: cs,
3664
3699
  n63_connection_cleanup: ms,
3665
3700
  n64_act_as: fs,
3666
3701
  n65_code_verifier: ys,
@@ -3668,16 +3703,16 @@ const Xs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3668
3703
  n67_drop_tickets: xs,
3669
3704
  n68_login_useragents: Os,
3670
3705
  n70_refresh_tokens: Ds,
3671
- n71_session_new_fields: Ps,
3706
+ n71_session_new_fields: js,
3672
3707
  n72_session_primary_key: Fs,
3673
3708
  n73_drop_sessions: zs,
3674
3709
  n74_custom_domains: Rs,
3675
3710
  n75_organizations: Qs,
3676
3711
  n76_authorization_url_length: qs,
3677
- n77_drop_sessions: Xs
3678
- // n78_login_sessions,
3712
+ n77_drop_sessions: Xs,
3713
+ n78_login_sessions: ei
3679
3714
  };
3680
- async function ai(t, e = !1) {
3715
+ async function oi(t, e = !1) {
3681
3716
  e && console.log("migrating...");
3682
3717
  const a = new Fe(Le), r = new ve({
3683
3718
  db: t,
@@ -3690,7 +3725,7 @@ async function ai(t, e = !1) {
3690
3725
  }), o)
3691
3726
  throw console.error("failed to migrate"), console.error(o), o;
3692
3727
  }
3693
- async function ri(t) {
3728
+ async function si(t) {
3694
3729
  console.log("migrating...");
3695
3730
  const e = new Fe(Le), a = new ve({
3696
3731
  db: t,
@@ -3701,7 +3736,7 @@ async function ri(t) {
3701
3736
  }), r)
3702
3737
  throw console.error("failed to migrate"), console.error(r), r;
3703
3738
  }
3704
- function ni(t) {
3739
+ function ii(t) {
3705
3740
  return {
3706
3741
  applications: It(t),
3707
3742
  branding: Xt(t),
@@ -3713,18 +3748,18 @@ function ni(t) {
3713
3748
  hooks: ra(t),
3714
3749
  keys: Rt(t),
3715
3750
  loginSessions: _a(t),
3716
- logs: lt(t),
3751
+ logs: ct(t),
3717
3752
  passwords: wt(t),
3718
3753
  promptSettings: ga(t),
3719
3754
  refreshTokens: Oa(t),
3720
3755
  sessions: ft(t),
3721
3756
  tenants: nt(t),
3722
- themes: la(t),
3757
+ themes: ca(t),
3723
3758
  users: Xe(t)
3724
3759
  };
3725
3760
  }
3726
3761
  export {
3727
- ni as default,
3728
- ri as migrateDown,
3729
- ai as migrateToLatest
3762
+ ii as default,
3763
+ si as migrateDown,
3764
+ oi as migrateToLatest
3730
3765
  };