@authhero/kysely-adapter 6.0.0 → 8.0.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.
@@ -3,9 +3,9 @@ var de = (t) => {
3
3
  throw TypeError(t);
4
4
  };
5
5
  var Je = (t, e, a) => e in t ? Ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
6
- var j = (t, e, a) => Je(t, typeof e != "symbol" ? e + "" : e, a), U = (t, e, a) => e.has(t) || de("Cannot " + a);
7
- var c = (t, e, a) => (U(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (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) => (U(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (U(t, e, "access private method"), a);
8
- import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ue, promptSettingSchema as Ke } from "@authhero/adapter-interfaces";
6
+ var j = (t, e, a) => Je(t, typeof e != "symbol" ? e + "" : e, a), K = (t, e, a) => e.has(t) || de("Cannot " + a);
7
+ var d = (t, e, a) => (K(t, e, "read from private field"), a ? a.call(t) : e.get(t)), w = (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) => (K(t, e, "write to private field"), r ? r.call(t, a) : e.set(t, a), a), u = (t, e, a) => (K(t, e, "access private method"), a);
8
+ import { parseUserId as Y, codeSchema as ze, connectionSchema as Re, loginSchema as Ke, 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) {
@@ -50,13 +50,13 @@ function Be(t) {
50
50
  };
51
51
  };
52
52
  }
53
- function f(t) {
53
+ function _(t) {
54
54
  const e = { ...t };
55
55
  for (const a in e)
56
- e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(f) : e[a] = f(e[a]));
56
+ e[a] === null ? delete e[a] : typeof e[a] == "object" && (Array.isArray(e[a]) ? e[a] = e[a].map(_) : e[a] = _(e[a]));
57
57
  return e;
58
58
  }
59
- function _e(t) {
59
+ function fe(t) {
60
60
  let e = {};
61
61
  try {
62
62
  e = JSON.parse(t.profileData || "{}");
@@ -83,7 +83,7 @@ function Qe(t) {
83
83
  ]);
84
84
  if (!r)
85
85
  return null;
86
- const { tenant_id: n, ...s } = r, l = {
86
+ const { tenant_id: n, ...s } = r, c = {
87
87
  ...s,
88
88
  email: r.email || "",
89
89
  email_verified: r.email_verified === 1,
@@ -97,21 +97,21 @@ function Qe(t) {
97
97
  user_id: Y(r.user_id).id,
98
98
  isSocial: !!r.is_social
99
99
  },
100
- ...o.map(_e)
100
+ ...o.map(fe)
101
101
  ]
102
102
  };
103
- return f(l);
103
+ return _(c);
104
104
  };
105
105
  }
106
106
  function T(t, e, a, r) {
107
107
  return a.split(/\s+/).map((n) => n.replace(/^([^:]+)=/g, "$1:")).map((n) => {
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 }) => {
108
+ let s = n.startsWith("-"), c, l, g, m;
109
+ return n.startsWith("-_exists_:") ? (c = n.substring(10), g = !0, s = !0) : n.startsWith("_exists_:") ? (c = n.substring(9), g = !0, s = !1) : n.includes(":") ? (s = n.startsWith("-"), [c, l] = s ? n.substring(1).split(":") : n.split(":"), g = !1, l.startsWith(">=") ? (m = ">=", l = l.substring(2)) : l.startsWith(">") ? (m = ">", l = l.substring(1)) : l.startsWith("<=") ? (m = "<=", l = l.substring(2)) : l.startsWith("<") ? (m = "<", l = l.substring(1)) : m = "=") : (c = null, l = n, g = !1), { key: c, value: l, isNegation: s, isExistsQuery: g, operator: m };
110
+ }).forEach(({ key: n, value: s, isNegation: c, isExistsQuery: l, operator: g }) => {
111
111
  if (n)
112
- if (d)
113
- l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
- else if (l)
112
+ if (l)
113
+ c ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
+ else if (c)
115
115
  switch (g) {
116
116
  case ">":
117
117
  e = e.where(n, "<=", s);
@@ -154,11 +154,11 @@ 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() : [], d = n.map((m) => {
158
- const y = l.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), c = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], l = n.map((m) => {
158
+ const y = c.filter(
159
159
  (x) => x.linked_to === m.user_id
160
160
  );
161
- return f({
161
+ return _({
162
162
  ...m,
163
163
  email_verified: m.email_verified === 1,
164
164
  is_social: m.is_social === 1,
@@ -171,22 +171,22 @@ function Ve(t) {
171
171
  user_id: Y(m.user_id).id,
172
172
  isSocial: !!m.is_social
173
173
  },
174
- ...y.map(_e)
174
+ ...y.map(fe)
175
175
  ]
176
176
  });
177
177
  }), { count: g } = await r.select((m) => m.fn.countAll().as("count")).executeTakeFirstOrThrow();
178
178
  return {
179
- users: d,
179
+ users: l,
180
180
  start: a.page * a.per_page,
181
181
  limit: a.per_page,
182
182
  length: b(g)
183
183
  };
184
184
  };
185
185
  }
186
- function We(t) {
186
+ function qe(t) {
187
187
  return async (e, a) => (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).execute(), (await t.deleteFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1);
188
188
  }
189
- function qe(t) {
189
+ function We(t) {
190
190
  if (t.email_verified !== void 0)
191
191
  return t.email_verified ? 1 : 0;
192
192
  }
@@ -194,7 +194,7 @@ function Ge(t) {
194
194
  return async (e, a, r) => {
195
195
  const o = {
196
196
  ...r,
197
- email_verified: qe(r),
197
+ email_verified: We(r),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
200
200
  return r.app_metadata && (o.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (o.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
@@ -209,7 +209,7 @@ function He(t) {
209
209
  function Xe(t) {
210
210
  return {
211
211
  create: Be(t),
212
- remove: We(t),
212
+ remove: qe(t),
213
213
  get: Qe(t),
214
214
  list: Ve(t),
215
215
  update: Ge(t),
@@ -238,7 +238,7 @@ function Ze(t) {
238
238
  function et(t) {
239
239
  return async (e) => {
240
240
  const a = await t.selectFrom("tenants").where("tenants.id", "=", e).selectAll().executeTakeFirst();
241
- return a ? f(a) : null;
241
+ return a ? _(a) : null;
242
242
  };
243
243
  }
244
244
  function tt(t) {
@@ -249,18 +249,18 @@ function tt(t) {
249
249
  }) => {
250
250
  let a = t.selectFrom("tenants");
251
251
  if (e.sort && e.sort.sort_by) {
252
- const { ref: l } = t.dynamic;
253
- a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
252
+ const { ref: c } = t.dynamic;
253
+ a = a.orderBy(c(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
- e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
255
+ e.q && (a = a.where((c) => c.or([c("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((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(n);
261
+ const { count: n } = await a.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = b(n);
262
262
  return {
263
- tenants: o.map(f),
263
+ tenants: o.map(_),
264
264
  start: (e.page - 1) * e.per_page,
265
265
  limit: e.per_page,
266
266
  length: s
@@ -345,14 +345,14 @@ function it(t) {
345
345
  a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
346
346
  let o = r;
347
347
  if (a.sort && a.sort.sort_by) {
348
- const { ref: l } = t.dynamic;
348
+ const { ref: c } = t.dynamic;
349
349
  o = o.orderBy(
350
- l(a.sort.sort_by),
350
+ c(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((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
355
+ const n = await o.selectAll().execute(), { count: s } = await r.select((c) => c.fn.countAll().as("count")).executeTakeFirstOrThrow();
356
356
  return {
357
357
  logs: n.map(pe),
358
358
  start: a.page * a.per_page,
@@ -361,17 +361,17 @@ function it(t) {
361
361
  };
362
362
  };
363
363
  }
364
- function lt(t) {
364
+ function ct(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 ct(t) {
370
+ function lt(t) {
371
371
  return {
372
372
  create: st(t),
373
373
  list: it(t),
374
- get: lt(t)
374
+ get: ct(t)
375
375
  };
376
376
  }
377
377
  function dt(t) {
@@ -379,10 +379,9 @@ function dt(t) {
379
379
  const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).where("sessions.revoked_at", "is", null).selectAll().executeTakeFirst();
380
380
  if (!r)
381
381
  return null;
382
- const { tenant_id: o, device: n, clients: s, ...l } = r, d = l.id || l.session_id || "";
382
+ const { tenant_id: o, device: n, clients: s, ...c } = r;
383
383
  return {
384
- ...l,
385
- id: d,
384
+ ...c,
386
385
  device: JSON.parse(n),
387
386
  clients: JSON.parse(s)
388
387
  };
@@ -392,8 +391,6 @@ function ut(t) {
392
391
  return async (e, a) => {
393
392
  const r = {
394
393
  ...a,
395
- // fallback untill we changed primary key
396
- session_id: a.id,
397
394
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
398
395
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
399
396
  authenticated_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -421,7 +418,7 @@ function ht(t) {
421
418
  return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
422
419
  };
423
420
  }
424
- function ft(t) {
421
+ function _t(t) {
425
422
  return async (e, a = {
426
423
  page: 0,
427
424
  per_page: 50,
@@ -431,31 +428,31 @@ function ft(t) {
431
428
  a.q && (r = T(t, r, a.q, ["user_id", "session_id"]));
432
429
  let o = r;
433
430
  if (a.sort && a.sort.sort_by) {
434
- const { ref: d } = t.dynamic;
431
+ const { ref: l } = t.dynamic;
435
432
  o = o.orderBy(
436
- d(a.sort.sort_by),
433
+ l(a.sort.sort_by),
437
434
  a.sort.sort_order
438
435
  );
439
436
  }
440
437
  o = o.offset(a.page * a.per_page).limit(a.per_page);
441
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
438
+ const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
442
439
  return {
443
- sessions: n.map((d) => ({
444
- ...d,
445
- device: JSON.parse(d.device),
446
- clients: JSON.parse(d.clients)
440
+ sessions: n.map((l) => ({
441
+ ...l,
442
+ device: JSON.parse(l.device),
443
+ clients: JSON.parse(l.clients)
447
444
  })),
448
445
  start: a.page * a.per_page,
449
446
  limit: a.per_page,
450
- length: l
447
+ length: c
451
448
  };
452
449
  };
453
450
  }
454
- function _t(t) {
451
+ function ft(t) {
455
452
  return {
456
453
  create: ut(t),
457
454
  get: dt(t),
458
- list: ft(t),
455
+ list: _t(t),
459
456
  remove: mt(t),
460
457
  update: ht(t)
461
458
  };
@@ -500,11 +497,11 @@ function Nt(t) {
500
497
  }) => {
501
498
  let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
499
  a.q && (r = T(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((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
500
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
504
501
  return {
505
- codes: n.map((d) => {
506
- const { tenant_id: g, ...m } = d;
507
- return ze.parse(f(m));
502
+ codes: n.map((l) => {
503
+ const { tenant_id: g, ...m } = l;
504
+ return ze.parse(_(m));
508
505
  }),
509
506
  start: a.page * a.per_page,
510
507
  limit: a.per_page,
@@ -532,7 +529,7 @@ function bt(t) {
532
529
  let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
533
530
  e.length && (o = o.where("codes.tenant_id", "=", e));
534
531
  const n = await o.selectAll().executeTakeFirst();
535
- return n ? f(n) : null;
532
+ return n ? _(n) : null;
536
533
  };
537
534
  }
538
535
  function xt(t) {
@@ -553,7 +550,7 @@ function St(t) {
553
550
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
554
551
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
555
552
  ...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), d = JSON.stringify(a.allowed_clients);
553
+ }, o = JSON.stringify(a.allowed_origins), n = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), c = JSON.stringify(a.allowed_logout_urls), l = JSON.stringify(a.allowed_clients);
557
554
  return await t.insertInto("applications").values({
558
555
  ...r,
559
556
  tenant_id: e,
@@ -562,8 +559,8 @@ function St(t) {
562
559
  callbacks: n,
563
560
  allowed_origins: o,
564
561
  web_origins: s,
565
- allowed_logout_urls: l,
566
- allowed_clients: d
562
+ allowed_logout_urls: c,
563
+ allowed_clients: l
567
564
  }).execute(), r;
568
565
  };
569
566
  }
@@ -584,7 +581,7 @@ function Ot(t) {
584
581
  function kt(t) {
585
582
  return async (e, a) => {
586
583
  const r = await t.selectFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).selectAll().executeTakeFirst();
587
- return r ? f({
584
+ return r ? _({
588
585
  ...r,
589
586
  disable_sign_ups: !!r.disable_sign_ups,
590
587
  addons: JSON.parse(r.addons),
@@ -598,7 +595,7 @@ function kt(t) {
598
595
  function $t(t) {
599
596
  return async (e, a) => (await t.deleteFrom("applications").where("applications.tenant_id", "=", e).where("applications.id", "=", a).executeTakeFirst()).numDeletedRows > 0;
600
597
  }
601
- function It(t) {
598
+ function Dt(t) {
602
599
  return async (e, a, r) => {
603
600
  const o = {
604
601
  ...r,
@@ -614,13 +611,13 @@ function It(t) {
614
611
  return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
615
612
  };
616
613
  }
617
- function Dt(t) {
614
+ function It(t) {
618
615
  return {
619
616
  create: St(t),
620
617
  list: Ot(t),
621
618
  get: kt(t),
622
619
  remove: $t(t),
623
- update: It(t)
620
+ update: Dt(t)
624
621
  };
625
622
  }
626
623
  function Pt(t) {
@@ -648,16 +645,16 @@ function jt(t) {
648
645
  let r = t.selectFrom("connections").where("connections.tenant_id", "=", e);
649
646
  a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
650
647
  const s = (await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute()).map(
651
- (d) => f({
652
- ...d,
653
- options: JSON.parse(d.options)
648
+ (l) => _({
649
+ ...l,
650
+ options: JSON.parse(l.options)
654
651
  })
655
- ), { count: l } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow();
652
+ ), { count: c } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
656
653
  return {
657
654
  connections: s,
658
655
  start: a.page * a.per_page,
659
656
  limit: a.per_page,
660
- length: b(l)
657
+ length: b(c)
661
658
  };
662
659
  };
663
660
  }
@@ -667,7 +664,7 @@ function Mt(t) {
667
664
  function At(t) {
668
665
  return async (e, a) => {
669
666
  const r = await t.selectFrom("connections").where("connections.tenant_id", "=", e).where("connections.id", "=", a).selectAll().executeTakeFirst();
670
- return r ? f({
667
+ return r ? _({
671
668
  ...r,
672
669
  options: JSON.parse(r.options)
673
670
  }) : null;
@@ -707,10 +704,10 @@ function Et(t) {
707
704
  return {
708
705
  ...a,
709
706
  connections: o.map(
710
- (l) => Re.parse(
711
- f({
712
- ...l,
713
- options: l.options ? JSON.parse(l.options) : {}
707
+ (c) => Re.parse(
708
+ _({
709
+ ...c,
710
+ options: c.options ? JSON.parse(c.options) : {}
714
711
  })
715
712
  )
716
713
  ),
@@ -721,7 +718,7 @@ function Et(t) {
721
718
  web_origins: a.web_origins ? JSON.parse(a.web_origins) : [],
722
719
  allowed_logout_urls: a.allowed_logout_urls ? JSON.parse(a.allowed_logout_urls) : [],
723
720
  allowed_clients: a.allowed_clients ? JSON.parse(a.allowed_clients) : [],
724
- tenant: f(r),
721
+ tenant: _(r),
725
722
  // this is really an integer in the database
726
723
  disable_sign_ups: !!a.disable_sign_ups
727
724
  };
@@ -744,14 +741,14 @@ function zt(t) {
744
741
  function Rt(t) {
745
742
  return async (e, a) => !!(await t.updateTable("keys").set(a).where("kid", "=", e).execute()).length;
746
743
  }
747
- function Ut(t) {
744
+ function Kt(t) {
748
745
  return {
749
746
  create: zt(t),
750
747
  list: Jt(t),
751
748
  update: Rt(t)
752
749
  };
753
750
  }
754
- function Kt(t) {
751
+ function Ut(t) {
755
752
  return async (e, a) => {
756
753
  const r = {
757
754
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -767,7 +764,7 @@ function Bt(t) {
767
764
  return async (e, a) => {
768
765
  let r = t.selectFrom("domains").where("domains.tenant_id", "=", e);
769
766
  a.q && (r = T(t, r, a.q, ["user_id", "ip"]));
770
- const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
767
+ 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();
771
768
  return {
772
769
  domains: n,
773
770
  start: a.page * a.per_page,
@@ -778,7 +775,7 @@ function Bt(t) {
778
775
  }
779
776
  function Qt(t) {
780
777
  return {
781
- create: Kt(t),
778
+ create: Ut(t),
782
779
  list: Bt(t)
783
780
  };
784
781
  }
@@ -792,36 +789,36 @@ function Vt(t) {
792
789
  colors_primary: o,
793
790
  colors_page_background_type: n,
794
791
  colors_page_background_start: s,
795
- colors_page_background_end: l,
796
- colors_page_background_angle_dev: d,
792
+ colors_page_background_end: c,
793
+ colors_page_background_angle_dev: l,
797
794
  font_url: g,
798
795
  ...m
799
796
  } = a;
800
- return f({
797
+ return _({
801
798
  ...m,
802
799
  colors: {
803
800
  primary: o,
804
801
  page_background: {
805
802
  type: n,
806
803
  start: s,
807
- end: l,
808
- angle_deg: d
804
+ end: c,
805
+ angle_deg: l
809
806
  }
810
807
  },
811
808
  font: g ? { url: g } : void 0
812
809
  });
813
810
  };
814
811
  }
815
- function Wt(t) {
812
+ function qt(t) {
816
813
  return async (e, a) => {
817
- var s, l, d, g, m, y, x, Z, ee, te, ae, re, ne, oe, se, ie, le, ce;
814
+ var s, c, l, g, m, y, x, Z, ee, te, ae, re, ne, oe, se, ie, ce, le;
818
815
  const { colors: r, font: o, ...n } = a;
819
816
  try {
820
817
  await t.insertInto("branding").values({
821
818
  ...n,
822
819
  colors_primary: r == null ? void 0 : r.primary,
823
- colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
824
- colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
820
+ colors_page_background_type: (c = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : c.type,
821
+ colors_page_background_start: (g = (l = a.colors) == null ? void 0 : l.page_background) == null ? void 0 : g.start,
825
822
  colors_page_background_end: (y = (m = a.colors) == null ? void 0 : m.page_background) == null ? void 0 : y.end,
826
823
  colors_page_background_angle_dev: (Z = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : Z.angle_deg,
827
824
  font_url: (ee = a.font) == null ? void 0 : ee.url,
@@ -834,16 +831,16 @@ function Wt(t) {
834
831
  colors_page_background_type: (ae = (te = a.colors) == null ? void 0 : te.page_background) == null ? void 0 : ae.type,
835
832
  colors_page_background_start: (ne = (re = a.colors) == null ? void 0 : re.page_background) == null ? void 0 : ne.start,
836
833
  colors_page_background_end: (se = (oe = a.colors) == null ? void 0 : oe.page_background) == null ? void 0 : se.end,
837
- colors_page_background_angle_dev: (le = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : le.angle_deg,
838
- font_url: (ce = a.font) == null ? void 0 : ce.url
834
+ colors_page_background_angle_dev: (ce = (ie = a.colors) == null ? void 0 : ie.page_background) == null ? void 0 : ce.angle_deg,
835
+ font_url: (le = a.font) == null ? void 0 : le.url
839
836
  }).where("tenant_id", "=", e).execute();
840
837
  }
841
838
  };
842
839
  }
843
- function qt(t) {
840
+ function Wt(t) {
844
841
  return {
845
842
  get: Vt(t),
846
- set: Wt(t)
843
+ set: qt(t)
847
844
  };
848
845
  }
849
846
  function Gt(t) {
@@ -854,11 +851,11 @@ function Gt(t) {
854
851
  }) => {
855
852
  let r = t.selectFrom("hooks").where("hooks.tenant_id", "=", e);
856
853
  a.q && (r = T(t, r, a.q, ["url"]));
857
- 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();
854
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
858
855
  return {
859
- hooks: n.map((d) => {
860
- const { tenant_id: g, enabled: m, synchronous: y, ...x } = d;
861
- return f({
856
+ hooks: n.map((l) => {
857
+ const { tenant_id: g, enabled: m, synchronous: y, ...x } = l;
858
+ return _({
862
859
  ...x,
863
860
  enabled: !!m,
864
861
  synchronous: !!y
@@ -873,7 +870,7 @@ function Gt(t) {
873
870
  function Ht(t) {
874
871
  return async (e, a) => {
875
872
  const r = await t.selectFrom("hooks").where("hooks.tenant_id", "=", e).where("hooks.hook_id", "=", a).selectAll().executeTakeFirst();
876
- return r ? f({
873
+ return r ? _({
877
874
  ...r,
878
875
  enabled: !!r.enabled,
879
876
  synchronous: !!r.synchronous
@@ -962,7 +959,7 @@ function ra(t) {
962
959
  function na(t) {
963
960
  return async (e, a) => {
964
961
  const r = await t.selectFrom("themes").where("themes.tenant_id", "=", e).where("themes.theme_id", "=", a).selectAll().executeTakeFirst();
965
- return r ? f(r) : null;
962
+ return r ? _(r) : null;
966
963
  };
967
964
  }
968
965
  function oa(t) {
@@ -985,12 +982,12 @@ function sa(t) {
985
982
  function ia(t) {
986
983
  return async (e, a) => {
987
984
  const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("logins").where("logins.expires_at", ">", r).where("logins.login_id", "=", a).selectAll().executeTakeFirst();
988
- return o ? Ue.parse(
989
- ta(f(o), ["authParams"])
985
+ return o ? Ke.parse(
986
+ ta(_(o), ["authParams"])
990
987
  ) : null;
991
988
  };
992
989
  }
993
- function la(t) {
990
+ function ca(t) {
994
991
  return async (e, a) => {
995
992
  const r = {
996
993
  login_id: k(),
@@ -1001,7 +998,7 @@ function la(t) {
1001
998
  return await t.insertInto("logins").values({ ...J(r), tenant_id: e }).execute(), r;
1002
999
  };
1003
1000
  }
1004
- function ca(t) {
1001
+ function la(t) {
1005
1002
  return async (e, a, r) => (await t.updateTable("logins").set(J(r)).where("logins.login_id", "=", a).where("logins.tenant_id", "=", e).execute()).length === 1;
1006
1003
  }
1007
1004
  function da(t) {
@@ -1009,16 +1006,16 @@ function da(t) {
1009
1006
  }
1010
1007
  function ua(t) {
1011
1008
  return {
1012
- create: la(t),
1009
+ create: ca(t),
1013
1010
  get: ia(t),
1014
- update: ca(t),
1011
+ update: la(t),
1015
1012
  remove: da(t)
1016
1013
  };
1017
1014
  }
1018
1015
  function ma(t) {
1019
1016
  return async (e) => {
1020
1017
  const [a] = await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id", "=", e).selectAll().execute();
1021
- return f({
1018
+ return _({
1022
1019
  identifier_first: !!(a != null && a.identifier_first),
1023
1020
  password_first: !!(a != null && a.password_first),
1024
1021
  webauthn_platform_first_factor: !!(a != null && a.webauthn_platform_first_factor),
@@ -1027,7 +1024,7 @@ function ma(t) {
1027
1024
  };
1028
1025
  }
1029
1026
  function he(t) {
1030
- return f({
1027
+ return _({
1031
1028
  ...t,
1032
1029
  webauthn_platform_first_factor: t.webauthn_platform_first_factor ? !!t.webauthn_platform_first_factor : void 0,
1033
1030
  identifier_first: t.identifier_first ? !!t.identifier_first : void 0,
@@ -1038,7 +1035,7 @@ function he(t) {
1038
1035
  function ha(t) {
1039
1036
  return async (e, a) => {
1040
1037
  try {
1041
- const r = Ke.parse(a);
1038
+ const r = Ue.parse(a);
1042
1039
  await t.insertInto("prompt_settings").values({
1043
1040
  ...he(r),
1044
1041
  tenant_id: e
@@ -1048,13 +1045,13 @@ function ha(t) {
1048
1045
  }
1049
1046
  };
1050
1047
  }
1051
- function fa(t) {
1048
+ function _a(t) {
1052
1049
  return {
1053
1050
  get: ma(t),
1054
1051
  set: ha(t)
1055
1052
  };
1056
1053
  }
1057
- function _a(t) {
1054
+ function fa(t) {
1058
1055
  return async (e) => {
1059
1056
  const [a] = await t.selectFrom("email_providers").where("email_providers.tenant_id", "=", e).selectAll().execute();
1060
1057
  if (!a)
@@ -1064,10 +1061,10 @@ function _a(t) {
1064
1061
  credentials: o,
1065
1062
  settings: n,
1066
1063
  enabled: s,
1067
- ...l
1064
+ ...c
1068
1065
  } = a;
1069
- return f({
1070
- ...l,
1066
+ return _({
1067
+ ...c,
1071
1068
  credentials: JSON.parse(o),
1072
1069
  settings: JSON.parse(n),
1073
1070
  enabled: !!s
@@ -1101,13 +1098,21 @@ function ga(t) {
1101
1098
  }
1102
1099
  function wa(t) {
1103
1100
  return {
1104
- get: _a(t),
1101
+ get: fa(t),
1105
1102
  create: ga(t),
1106
1103
  update: pa(t)
1107
1104
  };
1108
1105
  }
1109
1106
  function ya(t) {
1110
- return async (e, a) => await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", a).where("refresh_tokens.revoked_at", "is", null).selectAll().executeTakeFirst() ?? null;
1107
+ return async (e, a) => {
1108
+ const r = await t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e).where("refresh_tokens.token", "=", a).selectAll().executeTakeFirst();
1109
+ return r ? {
1110
+ ...r,
1111
+ rotating: !!r.rotating,
1112
+ device: r.device ? JSON.parse(r.device) : {},
1113
+ resource_servers: r.resource_servers ? JSON.parse(r.resource_servers) : []
1114
+ } : null;
1115
+ };
1111
1116
  }
1112
1117
  function Na(t) {
1113
1118
  return async (e, a) => {
@@ -1115,14 +1120,28 @@ function Na(t) {
1115
1120
  ...a,
1116
1121
  created_at: (/* @__PURE__ */ new Date()).toISOString()
1117
1122
  };
1118
- return await t.insertInto("refresh_tokens").values({ ...r, tenant_id: e }).execute(), { ...a, ...r };
1123
+ return await t.insertInto("refresh_tokens").values({
1124
+ ...r,
1125
+ tenant_id: e,
1126
+ rotating: a.rotating ? 1 : 0,
1127
+ device: JSON.stringify(a.device),
1128
+ resource_servers: JSON.stringify(a.resource_servers)
1129
+ }).execute(), { ...a, ...r };
1119
1130
  };
1120
1131
  }
1121
1132
  function va(t) {
1122
1133
  return async (e, a) => !!(await t.deleteFrom("refresh_tokens").where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1123
1134
  }
1124
1135
  function Ca(t) {
1125
- return async (e, a, r) => !!(await t.updateTable("refresh_tokens").set(r).where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1136
+ return async (e, a, r) => {
1137
+ const o = {
1138
+ ...r,
1139
+ device: r.device ? JSON.stringify(r.device) : void 0,
1140
+ resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1141
+ rotating: r.rotating ? 1 : 0
1142
+ };
1143
+ return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.token", "=", a).execute()).length;
1144
+ };
1126
1145
  }
1127
1146
  function ba(t) {
1128
1147
  return async (e, a = {
@@ -1134,19 +1153,24 @@ function ba(t) {
1134
1153
  a.q && (r = T(t, r, a.q, ["token", "session_id"]));
1135
1154
  let o = r;
1136
1155
  if (a.sort && a.sort.sort_by) {
1137
- const { ref: d } = t.dynamic;
1156
+ const { ref: l } = t.dynamic;
1138
1157
  o = o.orderBy(
1139
- d(a.sort.sort_by),
1158
+ l(a.sort.sort_by),
1140
1159
  a.sort.sort_order
1141
1160
  );
1142
1161
  }
1143
1162
  o = o.offset(a.page * a.per_page).limit(a.per_page);
1144
- const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = b(s);
1163
+ const n = await o.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), c = b(s);
1145
1164
  return {
1146
- refresh_tokens: n,
1165
+ refresh_tokens: n.map((l) => ({
1166
+ ...l,
1167
+ rotating: !!l.rotating,
1168
+ device: l.device ? JSON.parse(l.device) : {},
1169
+ resource_servers: l.resource_servers ? JSON.parse(l.resource_servers) : []
1170
+ })),
1147
1171
  start: a.page * a.per_page,
1148
1172
  limit: a.per_page,
1149
- length: l
1173
+ length: c
1150
1174
  };
1151
1175
  };
1152
1176
  }
@@ -1175,7 +1199,7 @@ const z = p({
1175
1199
  name: t
1176
1200
  });
1177
1201
  }
1178
- }), W = p({
1202
+ }), q = p({
1179
1203
  is(t) {
1180
1204
  return t.kind === "SchemableIdentifierNode";
1181
1205
  },
@@ -1203,20 +1227,20 @@ const z = p({
1203
1227
  alias: e
1204
1228
  });
1205
1229
  }
1206
- }), K = p({
1230
+ }), U = p({
1207
1231
  is(t) {
1208
1232
  return t.kind === "TableNode";
1209
1233
  },
1210
1234
  create(t) {
1211
1235
  return p({
1212
1236
  kind: "TableNode",
1213
- table: W.create(t)
1237
+ table: q.create(t)
1214
1238
  });
1215
1239
  },
1216
1240
  createWithSchema(t, e) {
1217
1241
  return p({
1218
1242
  kind: "TableNode",
1219
- table: W.createWithSchema(t, e)
1243
+ table: q.createWithSchema(t, e)
1220
1244
  });
1221
1245
  }
1222
1246
  });
@@ -1328,7 +1352,7 @@ class Oa {
1328
1352
  return this.nodeStack.pop(), p(a);
1329
1353
  }
1330
1354
  transformNodeImpl(e) {
1331
- return c(this, R)[e.kind](e);
1355
+ return d(this, R)[e.kind](e);
1332
1356
  }
1333
1357
  transformNodeList(e) {
1334
1358
  return e && p(e.map((a) => this.transformNode(a)));
@@ -2074,88 +2098,88 @@ const ka = p({
2074
2098
  UpdateQueryNode: !0,
2075
2099
  MergeQueryNode: !0
2076
2100
  });
2077
- var P, S, O, _, ge, we, ye, $, q, Ne;
2101
+ var P, S, O, f, ge, we, ye, $, W, Ne;
2078
2102
  class $a extends Oa {
2079
2103
  constructor(a) {
2080
2104
  super();
2081
- w(this, _);
2105
+ w(this, f);
2082
2106
  w(this, P);
2083
2107
  w(this, S, /* @__PURE__ */ new Set());
2084
2108
  w(this, O, /* @__PURE__ */ new Set());
2085
2109
  M(this, P, a);
2086
2110
  }
2087
2111
  transformNodeImpl(a) {
2088
- if (!u(this, _, ge).call(this, a))
2112
+ if (!u(this, f, ge).call(this, a))
2089
2113
  return super.transformNodeImpl(a);
2090
- const r = u(this, _, ye).call(this, a);
2114
+ const r = u(this, f, ye).call(this, a);
2091
2115
  for (const s of r)
2092
- c(this, O).add(s);
2093
- const o = u(this, _, we).call(this, a);
2116
+ d(this, O).add(s);
2117
+ const o = u(this, f, we).call(this, a);
2094
2118
  for (const s of o)
2095
- c(this, S).add(s);
2119
+ d(this, S).add(s);
2096
2120
  const n = super.transformNodeImpl(a);
2097
2121
  for (const s of o)
2098
- c(this, S).delete(s);
2122
+ d(this, S).delete(s);
2099
2123
  for (const s of r)
2100
- c(this, O).delete(s);
2124
+ d(this, O).delete(s);
2101
2125
  return n;
2102
2126
  }
2103
2127
  transformSchemableIdentifier(a) {
2104
2128
  const r = super.transformSchemableIdentifier(a);
2105
- return r.schema || !c(this, S).has(a.identifier.name) ? r : {
2129
+ return r.schema || !d(this, S).has(a.identifier.name) ? r : {
2106
2130
  ...r,
2107
- schema: z.create(c(this, P))
2131
+ schema: z.create(d(this, P))
2108
2132
  };
2109
2133
  }
2110
2134
  transformReferences(a) {
2111
2135
  const r = super.transformReferences(a);
2112
2136
  return r.table.table.schema ? r : {
2113
2137
  ...r,
2114
- table: K.createWithSchema(c(this, P), r.table.table.identifier.name)
2138
+ table: U.createWithSchema(d(this, P), r.table.table.identifier.name)
2115
2139
  };
2116
2140
  }
2117
2141
  }
2118
- P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), _ = new WeakSet(), ge = function(a) {
2142
+ P = new WeakMap(), S = new WeakMap(), O = new WeakMap(), f = new WeakSet(), ge = function(a) {
2119
2143
  return a.kind in ka;
2120
2144
  }, we = function(a) {
2121
2145
  const r = /* @__PURE__ */ new Set();
2122
- if ("name" in a && a.name && W.is(a.name) && u(this, _, q).call(this, a.name, r), "from" in a && a.from)
2146
+ if ("name" in a && a.name && q.is(a.name) && u(this, f, W).call(this, a.name, r), "from" in a && a.from)
2123
2147
  for (const o of a.from.froms)
2124
- u(this, _, $).call(this, o, r);
2125
- if ("into" in a && a.into && u(this, _, $).call(this, a.into, r), "table" in a && a.table && u(this, _, $).call(this, a.table, r), "joins" in a && a.joins)
2148
+ u(this, f, $).call(this, o, r);
2149
+ if ("into" in a && a.into && u(this, f, $).call(this, a.into, r), "table" in a && a.table && u(this, f, $).call(this, a.table, r), "joins" in a && a.joins)
2126
2150
  for (const o of a.joins)
2127
- u(this, _, $).call(this, o.table, r);
2128
- return "using" in a && a.using && u(this, _, $).call(this, a.using, r), r;
2151
+ u(this, f, $).call(this, o.table, r);
2152
+ return "using" in a && a.using && u(this, f, $).call(this, a.using, r), r;
2129
2153
  }, ye = function(a) {
2130
2154
  const r = /* @__PURE__ */ new Set();
2131
- return "with" in a && a.with && u(this, _, Ne).call(this, a.with, r), r;
2155
+ return "with" in a && a.with && u(this, f, Ne).call(this, a.with, r), r;
2132
2156
  }, $ = function(a, r) {
2133
- const o = K.is(a) ? a : Sa.is(a) && K.is(a.node) ? a.node : null;
2134
- o && u(this, _, q).call(this, o.table, r);
2135
- }, q = function(a, r) {
2157
+ const o = U.is(a) ? a : Sa.is(a) && U.is(a.node) ? a.node : null;
2158
+ o && u(this, f, W).call(this, o.table, r);
2159
+ }, W = function(a, r) {
2136
2160
  const o = a.identifier.name;
2137
- !c(this, S).has(o) && !c(this, O).has(o) && r.add(o);
2161
+ !d(this, S).has(o) && !d(this, O).has(o) && r.add(o);
2138
2162
  }, Ne = function(a, r) {
2139
2163
  for (const o of a.expressions) {
2140
2164
  const n = o.name.table.table.identifier.name;
2141
- c(this, O).has(n) || r.add(n);
2165
+ d(this, O).has(n) || r.add(n);
2142
2166
  }
2143
2167
  };
2144
2168
  var L;
2145
- class Ia {
2169
+ class Da {
2146
2170
  constructor(e) {
2147
2171
  w(this, L);
2148
2172
  M(this, L, new $a(e));
2149
2173
  }
2150
2174
  transformQuery(e) {
2151
- return c(this, L).transformNode(e.node);
2175
+ return d(this, L).transformNode(e.node);
2152
2176
  }
2153
2177
  async transformResult(e) {
2154
2178
  return e.result;
2155
2179
  }
2156
2180
  }
2157
2181
  L = new WeakMap();
2158
- class Da {
2182
+ class Ia {
2159
2183
  transformQuery(e) {
2160
2184
  return e.node;
2161
2185
  }
@@ -2163,8 +2187,8 @@ class Da {
2163
2187
  return e.result;
2164
2188
  }
2165
2189
  }
2166
- const Pa = "kysely_migration", fe = "kysely_migration_lock", ja = !1, B = "migration_lock", Ma = p({ __noMigrations__: !0 });
2167
- var h, i, A, N, v, I, Ce, C, be, xe, Te, Se, Oe, G, D, H, ke, $e, Ie, X, De, Pe, je, Me, Ae, F;
2190
+ const Pa = "kysely_migration", _e = "kysely_migration_lock", ja = !1, B = "migration_lock", Ma = p({ __noMigrations__: !0 });
2191
+ 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;
2168
2192
  class ve {
2169
2193
  constructor(e) {
2170
2194
  w(this, i);
@@ -2177,7 +2201,7 @@ class ve {
2177
2201
  * The returned array is sorted by migration name.
2178
2202
  */
2179
2203
  async getMigrations() {
2180
- const e = await u(this, i, D).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() : [];
2204
+ const e = await u(this, i, I).call(this, d(this, i, v)) ? await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, v)).select(["name", "timestamp"]).execute() : [];
2181
2205
  return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2182
2206
  const n = e.find((s) => s.name === r);
2183
2207
  return {
@@ -2264,9 +2288,9 @@ class ve {
2264
2288
  return u(this, i, A).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2265
2289
  if (e === Ma)
2266
2290
  return { direction: "Down", step: 1 / 0 };
2267
- if (!a.find((l) => l.name === e))
2291
+ if (!a.find((c) => c.name === e))
2268
2292
  throw new Error(`migration "${e}" doesn't exist`);
2269
- const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2293
+ const n = r.indexOf(e), s = o.findIndex((c) => c.name === e);
2270
2294
  if (n !== -1)
2271
2295
  return {
2272
2296
  direction: "Down",
@@ -2319,96 +2343,96 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2319
2343
  return a instanceof Q ? a.resultSet : { error: a };
2320
2344
  }
2321
2345
  }, N = function() {
2322
- return c(this, h).migrationTableSchema;
2346
+ return d(this, h).migrationTableSchema;
2323
2347
  }, v = function() {
2324
- return c(this, h).migrationTableName ?? Pa;
2325
- }, I = function() {
2326
- return c(this, h).migrationLockTableName ?? fe;
2348
+ return d(this, h).migrationTableName ?? Pa;
2349
+ }, D = function() {
2350
+ return d(this, h).migrationLockTableName ?? _e;
2327
2351
  }, Ce = function() {
2328
- return c(this, h).allowUnorderedMigrations ?? ja;
2352
+ return d(this, h).allowUnorderedMigrations ?? ja;
2329
2353
  }, C = function() {
2330
- return c(this, i, N) ? new Ia(c(this, i, N)) : new Da();
2354
+ return d(this, i, N) ? new Da(d(this, i, N)) : new Ia();
2331
2355
  }, be = async function() {
2332
2356
  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);
2333
2357
  }, xe = async function() {
2334
- if (c(this, i, N) && !await u(this, i, G).call(this))
2358
+ if (d(this, i, N) && !await u(this, i, G).call(this))
2335
2359
  try {
2336
- await u(this, i, F).call(this, c(this, h).db.schema.createSchema(c(this, i, N)));
2360
+ await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N)));
2337
2361
  } catch (e) {
2338
2362
  if (!await u(this, i, G).call(this))
2339
2363
  throw e;
2340
2364
  }
2341
2365
  }, Te = async function() {
2342
- if (!await u(this, i, D).call(this, c(this, i, v)))
2366
+ if (!await u(this, i, I).call(this, d(this, i, v)))
2343
2367
  try {
2344
- 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()));
2368
+ d(this, i, N) && await u(this, i, F).call(this, d(this, h).db.schema.createSchema(d(this, i, N))), await u(this, i, F).call(this, d(this, h).db.schema.withPlugin(d(this, i, C)).createTable(d(this, i, v)).addColumn("name", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("timestamp", "varchar(255)", (e) => e.notNull()));
2345
2369
  } catch (e) {
2346
- if (!await u(this, i, D).call(this, c(this, i, v)))
2370
+ if (!await u(this, i, I).call(this, d(this, i, v)))
2347
2371
  throw e;
2348
2372
  }
2349
2373
  }, Se = async function() {
2350
- if (!await u(this, i, D).call(this, c(this, i, I)))
2374
+ if (!await u(this, i, I).call(this, d(this, i, D)))
2351
2375
  try {
2352
- await u(this, i, F).call(this, c(this, h).db.schema.withPlugin(c(this, i, C)).createTable(c(this, i, I)).addColumn("id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn("is_locked", "integer", (e) => e.notNull().defaultTo(0)));
2376
+ await u(this, i, F).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)));
2353
2377
  } catch (e) {
2354
- if (!await u(this, i, D).call(this, c(this, i, I)))
2378
+ if (!await u(this, i, I).call(this, d(this, i, D)))
2355
2379
  throw e;
2356
2380
  }
2357
2381
  }, Oe = async function() {
2358
2382
  if (!await u(this, i, H).call(this))
2359
2383
  try {
2360
- await c(this, h).db.withPlugin(c(this, i, C)).insertInto(c(this, i, I)).values({ id: B, is_locked: 0 }).execute();
2384
+ await d(this, h).db.withPlugin(d(this, i, C)).insertInto(d(this, i, D)).values({ id: B, is_locked: 0 }).execute();
2361
2385
  } catch (e) {
2362
2386
  if (!await u(this, i, H).call(this))
2363
2387
  throw e;
2364
2388
  }
2365
2389
  }, G = async function() {
2366
- return (await c(this, h).db.introspection.getSchemas()).some((a) => a.name === c(this, i, N));
2367
- }, D = async function(e) {
2368
- const a = c(this, i, N);
2369
- return (await c(this, h).db.introspection.getTables({
2390
+ return (await d(this, h).db.introspection.getSchemas()).some((a) => a.name === d(this, i, N));
2391
+ }, I = async function(e) {
2392
+ const a = d(this, i, N);
2393
+ return (await d(this, h).db.introspection.getTables({
2370
2394
  withInternalKyselyTables: !0
2371
2395
  })).some((o) => o.name === e && (!a || o.schema === a));
2372
2396
  }, H = async function() {
2373
- return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, I)).where("id", "=", B).select("id").executeTakeFirst();
2397
+ return !!await d(this, h).db.withPlugin(d(this, i, C)).selectFrom(d(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2374
2398
  }, ke = async function(e) {
2375
- const a = c(this, h).db.getExecutor().adapter, r = p({
2376
- lockTable: c(this, h).migrationLockTableName ?? fe,
2399
+ const a = d(this, h).db.getExecutor().adapter, r = p({
2400
+ lockTable: d(this, h).migrationLockTableName ?? _e,
2377
2401
  lockRowId: B,
2378
- lockTableSchema: c(this, h).migrationTableSchema
2402
+ lockTableSchema: d(this, h).migrationTableSchema
2379
2403
  }), o = async (n) => {
2380
2404
  try {
2381
2405
  await a.acquireMigrationLock(n, r);
2382
2406
  const s = await u(this, i, $e).call(this, n);
2383
2407
  if (s.migrations.length === 0)
2384
2408
  return { results: [] };
2385
- const { direction: l, step: d } = e(s);
2386
- 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: [] };
2409
+ const { direction: c, step: l } = e(s);
2410
+ return l <= 0 ? { results: [] } : c === "Down" ? await u(this, i, Me).call(this, n, s, l) : c === "Up" ? await u(this, i, Ae).call(this, n, s, l) : { results: [] };
2387
2411
  } finally {
2388
2412
  await a.releaseMigrationLock(n, r);
2389
2413
  }
2390
2414
  };
2391
- return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2415
+ return a.supportsTransactionalDdl ? d(this, h).db.transaction().execute(o) : d(this, h).db.connection().execute(o);
2392
2416
  }, $e = async function(e) {
2393
- const a = await u(this, i, X).call(this), r = await u(this, i, De).call(this, e);
2394
- u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2395
- const o = u(this, i, Ie).call(this, a, r);
2417
+ const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2418
+ u(this, i, Pe).call(this, a, r), d(this, i, Ce) || u(this, i, je).call(this, a, r);
2419
+ const o = u(this, i, De).call(this, a, r);
2396
2420
  return p({
2397
2421
  migrations: a,
2398
2422
  executedMigrations: r,
2399
2423
  lastMigration: Ta(r),
2400
2424
  pendingMigrations: o
2401
2425
  });
2402
- }, Ie = function(e, a) {
2426
+ }, De = function(e, a) {
2403
2427
  return e.filter((r) => !a.includes(r.name));
2404
2428
  }, X = async function() {
2405
- const e = await c(this, h).provider.getMigrations();
2429
+ const e = await d(this, h).provider.getMigrations();
2406
2430
  return Object.keys(e).sort().map((a) => ({
2407
2431
  ...e[a],
2408
2432
  name: a
2409
2433
  }));
2410
- }, De = async function(e) {
2411
- return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2434
+ }, Ie = async function(e) {
2435
+ return (await e.withPlugin(d(this, i, C)).selectFrom(d(this, i, v)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2412
2436
  }, Pe = function(e, a) {
2413
2437
  for (const r of a)
2414
2438
  if (!e.some((o) => o.name === r))
@@ -2418,26 +2442,26 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2418
2442
  if (e[r].name !== a[r])
2419
2443
  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.`);
2420
2444
  }, Me = async function(e, a, r) {
2421
- const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2445
+ const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((c) => c.name === s)), n = o.map((s) => ({
2422
2446
  migrationName: s.name,
2423
2447
  direction: "Down",
2424
2448
  status: "NotExecuted"
2425
2449
  }));
2426
2450
  for (let s = 0; s < n.length; ++s) {
2427
- const l = o[s];
2451
+ const c = o[s];
2428
2452
  try {
2429
- 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] = {
2430
- migrationName: l.name,
2453
+ c.down && (await c.down(e), await e.withPlugin(d(this, i, C)).deleteFrom(d(this, i, v)).where("name", "=", c.name).execute(), n[s] = {
2454
+ migrationName: c.name,
2431
2455
  direction: "Down",
2432
2456
  status: "Success"
2433
2457
  });
2434
- } catch (d) {
2458
+ } catch (l) {
2435
2459
  throw n[s] = {
2436
- migrationName: l.name,
2460
+ migrationName: c.name,
2437
2461
  direction: "Down",
2438
2462
  status: "Error"
2439
2463
  }, new Q({
2440
- error: d,
2464
+ error: l,
2441
2465
  results: n
2442
2466
  });
2443
2467
  }
@@ -2450,30 +2474,30 @@ h = new WeakMap(), i = new WeakSet(), A = async function(e) {
2450
2474
  status: "NotExecuted"
2451
2475
  }));
2452
2476
  for (let s = 0; s < n.length; s++) {
2453
- const l = a.pendingMigrations[s];
2477
+ const c = a.pendingMigrations[s];
2454
2478
  try {
2455
- await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, v)).values({
2456
- name: l.name,
2479
+ await c.up(e), await e.withPlugin(d(this, i, C)).insertInto(d(this, i, v)).values({
2480
+ name: c.name,
2457
2481
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2458
2482
  }).execute(), n[s] = {
2459
- migrationName: l.name,
2483
+ migrationName: c.name,
2460
2484
  direction: "Up",
2461
2485
  status: "Success"
2462
2486
  };
2463
- } catch (d) {
2487
+ } catch (l) {
2464
2488
  throw n[s] = {
2465
- migrationName: l.name,
2489
+ migrationName: c.name,
2466
2490
  direction: "Up",
2467
2491
  status: "Error"
2468
2492
  }, new Q({
2469
- error: d,
2493
+ error: l,
2470
2494
  results: n
2471
2495
  });
2472
2496
  }
2473
2497
  }
2474
2498
  return { results: n };
2475
2499
  }, F = async function(e) {
2476
- c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2500
+ d(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2477
2501
  };
2478
2502
  var E;
2479
2503
  class Q extends Error {
@@ -2483,7 +2507,7 @@ class Q extends Error {
2483
2507
  M(this, E, a);
2484
2508
  }
2485
2509
  get resultSet() {
2486
- return c(this, E);
2510
+ return d(this, E);
2487
2511
  }
2488
2512
  }
2489
2513
  E = new WeakMap();
@@ -2585,11 +2609,11 @@ const za = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2585
2609
  }, Symbol.toStringTag, { value: "Module" }));
2586
2610
  async function Ra(t) {
2587
2611
  }
2588
- async function Ua(t) {
2612
+ async function Ka(t) {
2589
2613
  }
2590
- const Ka = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2614
+ const Ua = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2591
2615
  __proto__: null,
2592
- down: Ua,
2616
+ down: Ka,
2593
2617
  up: Ra
2594
2618
  }, Symbol.toStringTag, { value: "Module" }));
2595
2619
  async function Ba(t) {
@@ -2609,14 +2633,14 @@ const Va = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2609
2633
  down: Qa,
2610
2634
  up: Ba
2611
2635
  }, Symbol.toStringTag, { value: "Module" }));
2612
- async function Wa(t) {
2613
- }
2614
2636
  async function qa(t) {
2615
2637
  }
2638
+ async function Wa(t) {
2639
+ }
2616
2640
  const Ga = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2617
2641
  __proto__: null,
2618
- down: qa,
2619
- up: Wa
2642
+ down: Wa,
2643
+ up: qa
2620
2644
  }, Symbol.toStringTag, { value: "Module" }));
2621
2645
  async function Ha(t) {
2622
2646
  await t.schema.createTable("sessions").addColumn("session_id", "varchar(255)", (e) => e.primaryKey()).addColumn(
@@ -2703,14 +2727,14 @@ const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2703
2727
  down: sr,
2704
2728
  up: or
2705
2729
  }, Symbol.toStringTag, { value: "Module" }));
2706
- async function lr(t) {
2707
- }
2708
2730
  async function cr(t) {
2709
2731
  }
2732
+ async function lr(t) {
2733
+ }
2710
2734
  const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2711
2735
  __proto__: null,
2712
- down: cr,
2713
- up: lr
2736
+ down: lr,
2737
+ up: cr
2714
2738
  }, Symbol.toStringTag, { value: "Module" }));
2715
2739
  async function ur(t) {
2716
2740
  }
@@ -2721,14 +2745,14 @@ const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2721
2745
  down: mr,
2722
2746
  up: ur
2723
2747
  }, Symbol.toStringTag, { value: "Module" }));
2724
- async function fr(t) {
2725
- }
2726
2748
  async function _r(t) {
2727
2749
  }
2750
+ async function fr(t) {
2751
+ }
2728
2752
  const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2729
2753
  __proto__: null,
2730
- down: _r,
2731
- up: fr
2754
+ down: fr,
2755
+ up: _r
2732
2756
  }, Symbol.toStringTag, { value: "Module" }));
2733
2757
  async function gr(t) {
2734
2758
  await t.schema.createIndex("users_email_index").on("users").column("email").execute();
@@ -2781,12 +2805,12 @@ async function $r(t) {
2781
2805
  (e) => e.references("tenants.id").onDelete("cascade")
2782
2806
  ).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();
2783
2807
  }
2784
- async function Ir(t) {
2808
+ async function Dr(t) {
2785
2809
  await t.schema.dropTable("keys").execute();
2786
2810
  }
2787
- const Dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2811
+ const Ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2788
2812
  __proto__: null,
2789
- down: Ir,
2813
+ down: Dr,
2790
2814
  up: $r
2791
2815
  }, Symbol.toStringTag, { value: "Module" }));
2792
2816
  async function Pr(t) {
@@ -2820,11 +2844,11 @@ const zr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2820
2844
  }, Symbol.toStringTag, { value: "Module" }));
2821
2845
  async function Rr(t) {
2822
2846
  }
2823
- async function Ur(t) {
2847
+ async function Kr(t) {
2824
2848
  }
2825
- const Kr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2849
+ const Ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2826
2850
  __proto__: null,
2827
- down: Ur,
2851
+ down: Kr,
2828
2852
  up: Rr
2829
2853
  }, Symbol.toStringTag, { value: "Module" }));
2830
2854
  async function Br(t) {
@@ -2838,16 +2862,16 @@ const Vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2838
2862
  down: Qr,
2839
2863
  up: Br
2840
2864
  }, Symbol.toStringTag, { value: "Module" }));
2841
- async function Wr(t) {
2865
+ async function qr(t) {
2842
2866
  await t.schema.alterTable("users").dropColumn("tags").execute();
2843
2867
  }
2844
- async function qr(t) {
2868
+ async function Wr(t) {
2845
2869
  await t.schema.alterTable("users").addColumn("tags", "varchar(255)").execute();
2846
2870
  }
2847
2871
  const Gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2848
2872
  __proto__: null,
2849
- down: qr,
2850
- up: Wr
2873
+ down: Wr,
2874
+ up: qr
2851
2875
  }, Symbol.toStringTag, { value: "Module" }));
2852
2876
  async function Hr(t) {
2853
2877
  await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(), await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(), await t.schema.createIndex("logs_date").on("logs").column("date").execute();
@@ -2888,12 +2912,12 @@ async function on(t) {
2888
2912
  async function sn(t) {
2889
2913
  await t.schema.dropIndex("users_name_index").execute();
2890
2914
  }
2891
- const ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2915
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2892
2916
  __proto__: null,
2893
2917
  down: sn,
2894
2918
  up: on
2895
2919
  }, Symbol.toStringTag, { value: "Module" }));
2896
- async function cn(t) {
2920
+ async function ln(t) {
2897
2921
  }
2898
2922
  async function dn(t) {
2899
2923
  await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute();
@@ -2901,7 +2925,7 @@ async function dn(t) {
2901
2925
  const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2902
2926
  __proto__: null,
2903
2927
  down: dn,
2904
- up: cn
2928
+ up: ln
2905
2929
  }, Symbol.toStringTag, { value: "Module" }));
2906
2930
  async function mn(t) {
2907
2931
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(8192)").execute();
@@ -2909,12 +2933,12 @@ async function mn(t) {
2909
2933
  async function hn(t) {
2910
2934
  await t.schema.alterTable("otps").dropColumn("state").execute(), await t.schema.alterTable("otps").addColumn("state", "varchar(1024)").execute();
2911
2935
  }
2912
- const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2936
+ const _n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2913
2937
  __proto__: null,
2914
2938
  down: hn,
2915
2939
  up: mn
2916
2940
  }, Symbol.toStringTag, { value: "Module" }));
2917
- async function _n(t) {
2941
+ async function fn(t) {
2918
2942
  await t.schema.alterTable("tickets").dropColumn("state").execute(), await t.schema.alterTable("tickets").addColumn("state", "varchar(8192)").execute();
2919
2943
  }
2920
2944
  async function pn(t) {
@@ -2923,7 +2947,7 @@ async function pn(t) {
2923
2947
  const gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2924
2948
  __proto__: null,
2925
2949
  down: pn,
2926
- up: _n
2950
+ up: fn
2927
2951
  }, Symbol.toStringTag, { value: "Module" }));
2928
2952
  async function wn(t) {
2929
2953
  await t.schema.createTable("branding").addColumn(
@@ -2967,14 +2991,14 @@ const $n = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2967
2991
  down: kn,
2968
2992
  up: On
2969
2993
  }, Symbol.toStringTag, { value: "Module" }));
2970
- async function In(t) {
2971
- }
2972
2994
  async function Dn(t) {
2973
2995
  }
2996
+ async function In(t) {
2997
+ }
2974
2998
  const Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2975
2999
  __proto__: null,
2976
- down: Dn,
2977
- up: In
3000
+ down: In,
3001
+ up: Dn
2978
3002
  }, Symbol.toStringTag, { value: "Module" }));
2979
3003
  async function jn(t) {
2980
3004
  await t.schema.createTable("authentication_codes").addColumn(
@@ -3015,27 +3039,27 @@ const Rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3015
3039
  down: zn,
3016
3040
  up: Jn
3017
3041
  }, Symbol.toStringTag, { value: "Module" }));
3018
- async function Un(t) {
3042
+ async function Kn(t) {
3019
3043
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(1024)").execute();
3020
3044
  }
3021
- async function Kn(t) {
3045
+ async function Un(t) {
3022
3046
  await t.schema.alterTable("logs").dropColumn("user_agent").execute(), await t.schema.alterTable("logs").addColumn("user_agent", "varchar(255)").execute();
3023
3047
  }
3024
3048
  const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3025
3049
  __proto__: null,
3026
- down: Kn,
3027
- up: Un
3050
+ down: Un,
3051
+ up: Kn
3028
3052
  }, Symbol.toStringTag, { value: "Module" }));
3029
3053
  async function Qn(t) {
3030
3054
  }
3031
3055
  async function Vn(t) {
3032
3056
  }
3033
- const Wn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3057
+ const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3034
3058
  __proto__: null,
3035
3059
  down: Vn,
3036
3060
  up: Qn
3037
3061
  }, Symbol.toStringTag, { value: "Module" }));
3038
- async function qn(t) {
3062
+ async function Wn(t) {
3039
3063
  await t.schema.createTable("hooks").addColumn("hook_id", "varchar(255)", (e) => e.notNull().primaryKey()).addColumn(
3040
3064
  "tenant_id",
3041
3065
  "varchar(255)",
@@ -3052,7 +3076,7 @@ async function Gn(t) {
3052
3076
  const Hn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3053
3077
  __proto__: null,
3054
3078
  down: Gn,
3055
- up: qn
3079
+ up: Wn
3056
3080
  }, Symbol.toStringTag, { value: "Module" }));
3057
3081
  async function Xn(t) {
3058
3082
  }
@@ -3107,12 +3131,12 @@ async function so(t) {
3107
3131
  }
3108
3132
  async function io(t) {
3109
3133
  }
3110
- const lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3134
+ const co = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3111
3135
  __proto__: null,
3112
3136
  down: io,
3113
3137
  up: so
3114
3138
  }, Symbol.toStringTag, { value: "Module" }));
3115
- async function co(t) {
3139
+ async function lo(t) {
3116
3140
  await t.schema.alterTable("logins").addColumn("auth0Client", "varchar(256)").execute();
3117
3141
  }
3118
3142
  async function uo(t) {
@@ -3121,17 +3145,17 @@ async function uo(t) {
3121
3145
  const mo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3122
3146
  __proto__: null,
3123
3147
  down: uo,
3124
- up: co
3148
+ up: lo
3125
3149
  }, Symbol.toStringTag, { value: "Module" }));
3126
3150
  async function ho(t) {
3127
3151
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(8192)").execute();
3128
3152
  }
3129
- async function fo(t) {
3153
+ async function _o(t) {
3130
3154
  await t.schema.alterTable("logins").dropColumn("authParams_state").execute(), await t.schema.alterTable("logins").addColumn("authParams_state", "varchar(511)").execute();
3131
3155
  }
3132
- const _o = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3156
+ const fo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3133
3157
  __proto__: null,
3134
- down: fo,
3158
+ down: _o,
3135
3159
  up: ho
3136
3160
  }, Symbol.toStringTag, { value: "Module" }));
3137
3161
  async function po(t) {
@@ -3176,12 +3200,12 @@ async function ko(t) {
3176
3200
  }
3177
3201
  async function $o(t) {
3178
3202
  }
3179
- const Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3203
+ const Do = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3180
3204
  __proto__: null,
3181
3205
  down: $o,
3182
3206
  up: ko
3183
3207
  }, Symbol.toStringTag, { value: "Module" }));
3184
- async function Do(t) {
3208
+ async function Io(t) {
3185
3209
  await t.schema.dropTable("codes").execute(), await t.schema.createTable("codes").addColumn("code_id", "varchar(255)", (e) => e.notNull()).addColumn(
3186
3210
  "tenant_id",
3187
3211
  "varchar(255)",
@@ -3213,7 +3237,7 @@ async function Po(t) {
3213
3237
  const jo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3214
3238
  __proto__: null,
3215
3239
  down: Po,
3216
- up: Do
3240
+ up: Io
3217
3241
  }, Symbol.toStringTag, { value: "Module" }));
3218
3242
  async function Mo(t) {
3219
3243
  await t.schema.dropTable("otps").execute(), await t.schema.dropTable("authentication_codes").execute();
@@ -3257,12 +3281,12 @@ async function zo(t) {
3257
3281
  }
3258
3282
  async function Ro(t) {
3259
3283
  }
3260
- const Uo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3284
+ const Ko = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3261
3285
  __proto__: null,
3262
3286
  down: Ro,
3263
3287
  up: zo
3264
3288
  }, Symbol.toStringTag, { value: "Module" }));
3265
- async function Ko(t) {
3289
+ async function Uo(t) {
3266
3290
  await t.schema.createTable("prompt_settings").addColumn("tenant_id", "varchar(64)", (e) => e.primaryKey()).addColumn(
3267
3291
  "universal_login_experience",
3268
3292
  "varchar(16)",
@@ -3287,15 +3311,15 @@ async function Bo(t) {
3287
3311
  const Qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3288
3312
  __proto__: null,
3289
3313
  down: Bo,
3290
- up: Ko
3314
+ up: Uo
3291
3315
  }, Symbol.toStringTag, { value: "Module" }));
3292
3316
  async function Vo(t) {
3293
3317
  }
3294
- async function Wo(t) {
3318
+ async function qo(t) {
3295
3319
  }
3296
- const qo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3320
+ const Wo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3297
3321
  __proto__: null,
3298
- down: Wo,
3322
+ down: qo,
3299
3323
  up: Vo
3300
3324
  }, Symbol.toStringTag, { value: "Module" }));
3301
3325
  async function Go(t) {
@@ -3340,11 +3364,11 @@ const ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3340
3364
  }, Symbol.toStringTag, { value: "Module" }));
3341
3365
  async function is(t) {
3342
3366
  }
3343
- async function ls(t) {
3367
+ async function cs(t) {
3344
3368
  }
3345
- const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3369
+ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3346
3370
  __proto__: null,
3347
- down: ls,
3371
+ down: cs,
3348
3372
  up: is
3349
3373
  }, Symbol.toStringTag, { value: "Module" }));
3350
3374
  async function ds(t) {
@@ -3361,12 +3385,12 @@ const ms = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3361
3385
  async function hs(t) {
3362
3386
  await t.schema.alterTable("codes").addColumn("code_verifier", "varchar(128)").execute();
3363
3387
  }
3364
- async function fs(t) {
3388
+ async function _s(t) {
3365
3389
  await t.schema.alterTable("codes").dropColumn("code_verifier").execute();
3366
3390
  }
3367
- const _s = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3391
+ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3368
3392
  __proto__: null,
3369
- down: fs,
3393
+ down: _s,
3370
3394
  up: hs
3371
3395
  }, Symbol.toStringTag, { value: "Module" }));
3372
3396
  async function ps(t) {
@@ -3446,14 +3470,41 @@ async function ks(t) {
3446
3470
  async function $s(t) {
3447
3471
  await t.schema.alterTable("sessions").dropColumn("id").dropColumn("idle_expires_at").dropColumn("updated_at").dropColumn("revoked_at").dropColumn("authenticated_at").dropColumn("last_interaction_at").dropColumn("device").dropColumn("clients").execute();
3448
3472
  }
3449
- const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3473
+ const Ds = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3450
3474
  __proto__: null,
3451
3475
  down: $s,
3452
3476
  up: ks
3477
+ }, Symbol.toStringTag, { value: "Module" }));
3478
+ async function Is(t) {
3479
+ await t.schema.alterTable("refresh_tokens").addColumn("rotating", "boolean").execute(), await t.schema.alterTable("refresh_tokens").addColumn("device", "varchar(1024)").execute(), await t.schema.alterTable("refresh_tokens").addColumn("resource_servers", "varchar(1024)").execute(), await t.schema.alterTable("refresh_tokens").addColumn("user_id", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("scope").execute(), await t.schema.alterTable("refresh_tokens").addColumn("scope", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("audience").execute(), await t.schema.alterTable("refresh_tokens").addColumn("audience", "varchar(255)").execute(), await t.schema.alterTable("refresh_tokens").dropColumn("session_id").execute(), await t.schema.alterTable("refresh_tokens").addColumn("session_id", "varchar(255)").execute(), await t.schema.createTable("sessions_new").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn("tenant_id", "varchar(255)").addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3480
+ "user_id_constraint",
3481
+ ["user_id", "tenant_id"],
3482
+ "users",
3483
+ ["user_id", "tenant_id"],
3484
+ (e) => e.onDelete("cascade")
3485
+ ).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("refresh_tokens_new").addColumn("id", "varchar(21)", (e) => e.primaryKey()).addColumn(
3486
+ "client_id",
3487
+ "varchar(21)",
3488
+ (e) => e.references("applications.id").onDelete("cascade").notNull()
3489
+ ).addColumn("tenant_id", "varchar(255)").addColumn("session_id", "varchar(21)", (e) => e.notNull()).addColumn("user_id", "varchar(255)").addForeignKeyConstraint(
3490
+ "user_id_constraint",
3491
+ ["user_id", "tenant_id"],
3492
+ "users",
3493
+ ["user_id", "tenant_id"],
3494
+ (e) => e.onDelete("cascade")
3495
+ ).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("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();
3496
+ }
3497
+ async function Ps(t) {
3498
+ await t.schema.dropTable("sessions_new").execute(), await t.schema.dropTable("refresh_tokens_new").execute();
3499
+ }
3500
+ const js = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3501
+ __proto__: null,
3502
+ down: Ps,
3503
+ up: Is
3453
3504
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3454
3505
  m1_init: La,
3455
3506
  m2_magicLink: za,
3456
- m3_updateAt: Ka,
3507
+ m3_updateAt: Ua,
3457
3508
  m4_logTable: Va,
3458
3509
  m5_userProfile: Ga,
3459
3510
  m6_sessions: Ya,
@@ -3467,19 +3518,19 @@ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3467
3518
  n14_profileDataField: Cr,
3468
3519
  n15_userEmailIndex: Tr,
3469
3520
  n16_userLocale: kr,
3470
- n17_signingKeys: Dr,
3521
+ n17_signingKeys: Ir,
3471
3522
  n18_logsFields: Mr,
3472
3523
  n19_connectionsUserinfo: Lr,
3473
3524
  n20_missingFields: zr,
3474
- n21_sessionDeletedAt: Kr,
3525
+ n21_sessionDeletedAt: Ur,
3475
3526
  n22_dropLogsFields: Vr,
3476
3527
  n23_dropUsersFields: Gr,
3477
3528
  n24_logsIndexes: Yr,
3478
3529
  n25_logDescMaxLength: tn,
3479
3530
  n26_logsTableExtraFields: nn,
3480
- n27_usersTableNameIndex: ln,
3531
+ n27_usersTableNameIndex: cn,
3481
3532
  n28_usersEmailConstrain: un,
3482
- n29_increaseOtpStateLength: fn,
3533
+ n29_increaseOtpStateLength: _n,
3483
3534
  n30_increaseTicketStateLength: gn,
3484
3535
  n31_branding: Nn,
3485
3536
  n32_indexesAndNotNull: bn,
@@ -3490,39 +3541,40 @@ const Is = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3490
3541
  n37_disableSignUps: En,
3491
3542
  n38_otpIpAddress: Rn,
3492
3543
  n39_increaseUserAgentLength: Bn,
3493
- n40_userId: Wn,
3544
+ n40_userId: qn,
3494
3545
  n41_hooks: Hn,
3495
3546
  n42_userIdIndexes: Zn,
3496
3547
  n43_userIdIndexes: ao,
3497
3548
  n44_codes: oo,
3498
- n45_hookProperties: lo,
3549
+ n45_hookProperties: co,
3499
3550
  n46_loginAuth0Client: mo,
3500
- n47_loginAuth0Client: _o,
3551
+ n47_loginAuth0Client: fo,
3501
3552
  n48_saml: wo,
3502
3553
  n49_removeFields: vo,
3503
3554
  n50_authParamsNonce: xo,
3504
3555
  n51_connectionid: Oo,
3505
- n52_cert: Io,
3556
+ n52_cert: Do,
3506
3557
  n53_codes_primary_key: jo,
3507
3558
  n54_cleanup_tables: Fo,
3508
3559
  n55_logs_index: Jo,
3509
- n56_application_fields: Uo,
3560
+ n56_application_fields: Ko,
3510
3561
  n57_prompt_settings: Qo,
3511
- n58_connection_client_id: qo,
3562
+ n58_connection_client_id: Wo,
3512
3563
  n59_connection_options: Xo,
3513
3564
  n60_users_metadata: es,
3514
3565
  n61_userLocales: rs,
3515
3566
  n62_prompt: ss,
3516
- n63_connection_cleanup: cs,
3567
+ n63_connection_cleanup: ls,
3517
3568
  n64_act_as: ms,
3518
- n65_code_verifier: _s,
3569
+ n65_code_verifier: fs,
3519
3570
  n66_email_providers: ws,
3520
3571
  n67_drop_tickets: vs,
3521
3572
  n68_login_useragents: xs,
3522
3573
  n70_refresh_tokens: Os,
3523
- n71_session_new_fields: Is
3574
+ n71_session_new_fields: Ds,
3575
+ n72_session_primary_key: js
3524
3576
  };
3525
- async function As(t, e = !1) {
3577
+ async function Es(t, e = !1) {
3526
3578
  e && console.log("migrating...");
3527
3579
  const a = new Fe(Le), r = new ve({
3528
3580
  db: t,
@@ -3535,7 +3587,7 @@ async function As(t, e = !1) {
3535
3587
  }), o)
3536
3588
  throw console.error("failed to migrate"), console.error(o), o;
3537
3589
  }
3538
- async function Fs(t) {
3590
+ async function Js(t) {
3539
3591
  console.log("migrating...");
3540
3592
  const e = new Fe(Le), a = new ve({
3541
3593
  db: t,
@@ -3546,30 +3598,30 @@ async function Fs(t) {
3546
3598
  }), r)
3547
3599
  throw console.error("failed to migrate"), console.error(r), r;
3548
3600
  }
3549
- function Ls(t) {
3601
+ function zs(t) {
3550
3602
  return {
3551
- applications: Dt(t),
3552
- branding: qt(t),
3603
+ applications: It(t),
3604
+ branding: Wt(t),
3553
3605
  clients: Et(t),
3554
3606
  codes: Tt(t),
3555
3607
  connections: Lt(t),
3556
3608
  emailProviders: wa(t),
3557
3609
  domains: Qt(t),
3558
3610
  hooks: ea(t),
3559
- keys: Ut(t),
3611
+ keys: Kt(t),
3560
3612
  logins: ua(t),
3561
- logs: ct(t),
3613
+ logs: lt(t),
3562
3614
  passwords: yt(t),
3563
- promptSettings: fa(t),
3615
+ promptSettings: _a(t),
3564
3616
  refreshTokens: xa(t),
3565
- sessions: _t(t),
3617
+ sessions: ft(t),
3566
3618
  tenants: nt(t),
3567
3619
  themes: sa(t),
3568
3620
  users: Xe(t)
3569
3621
  };
3570
3622
  }
3571
3623
  export {
3572
- Ls as default,
3573
- Fs as migrateDown,
3574
- As as migrateToLatest
3624
+ zs as default,
3625
+ Js as migrateDown,
3626
+ Es as migrateToLatest
3575
3627
  };