@authhero/kysely-adapter 10.2.0 → 10.4.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.
@@ -25,8 +25,8 @@ var V = class extends Error {
25
25
  };
26
26
  function Be(t) {
27
27
  return async (e, a) => {
28
- const { identities: r, ...n } = a, o = {
29
- ...n,
28
+ const { identities: r, ...o } = a, n = {
29
+ ...o,
30
30
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
31
31
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
32
32
  login_count: 0,
@@ -37,16 +37,16 @@ function Be(t) {
37
37
  user_metadata: JSON.stringify(a.user_metadata)
38
38
  };
39
39
  try {
40
- await t.insertInto("users").values(o).execute();
40
+ await t.insertInto("users").values(n).execute();
41
41
  } catch (s) {
42
42
  throw s.code === "SQLITE_CONSTRAINT_UNIQUE" || s.message.includes("AlreadyExists") ? new V(409, { message: "User already exists" }) : new V(500, { message: `${s.code}, ${s.message}` });
43
43
  }
44
44
  return {
45
- ...o,
45
+ ...n,
46
46
  // TODO: check if this is correct. Should it be optional?
47
- email: o.email || "",
48
- email_verified: o.email_verified === 1,
49
- is_social: o.is_social === 1
47
+ email: n.email || "",
48
+ email_verified: n.email_verified === 1,
49
+ is_social: n.is_social === 1
50
50
  };
51
51
  };
52
52
  }
@@ -77,13 +77,13 @@ function fe(t) {
77
77
  }
78
78
  function Qe(t) {
79
79
  return async (e, a) => {
80
- const [r, n] = await Promise.all([
80
+ const [r, o] = await Promise.all([
81
81
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.user_id", "=", a).selectAll().executeTakeFirst(),
82
82
  t.selectFrom("users").where("users.tenant_id", "=", e).where("users.linked_to", "=", a).selectAll().execute()
83
83
  ]);
84
84
  if (!r)
85
85
  return null;
86
- const { tenant_id: o, ...s } = r, l = {
86
+ const { tenant_id: n, ...s } = r, l = {
87
87
  ...s,
88
88
  email: r.email || "",
89
89
  email_verified: r.email_verified === 1,
@@ -97,39 +97,39 @@ function Qe(t) {
97
97
  user_id: Y(r.user_id).id,
98
98
  isSocial: !!r.is_social
99
99
  },
100
- ...n.map(fe)
100
+ ...o.map(fe)
101
101
  ]
102
102
  };
103
103
  return _(l);
104
104
  };
105
105
  }
106
106
  function O(t, e, a, r) {
107
- return a.split(/\s+/).map((o) => o.replace(/^([^:]+)=/g, "$1:")).map((o) => {
108
- let s = o.startsWith("-"), l, d, g, m;
109
- return o.startsWith("-_exists_:") ? (l = o.substring(10), g = !0, s = !0) : o.startsWith("_exists_:") ? (l = o.substring(9), g = !0, s = !1) : o.includes(":") ? (s = o.startsWith("-"), [l, d] = s ? o.substring(1).split(":") : o.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 = o, g = !1), { key: l, value: d, isNegation: s, isExistsQuery: g, operator: m };
110
- }).forEach(({ key: o, value: s, isNegation: l, isExistsQuery: d, operator: g }) => {
111
- if (o)
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 }) => {
111
+ if (n)
112
112
  if (d)
113
- l ? e = e.where(o, "is", null) : e = e.where(o, "is not", null);
113
+ l ? e = e.where(n, "is", null) : e = e.where(n, "is not", null);
114
114
  else if (l)
115
115
  switch (g) {
116
116
  case ">":
117
- e = e.where(o, "<=", s);
117
+ e = e.where(n, "<=", s);
118
118
  break;
119
119
  case ">=":
120
- e = e.where(o, "<", s);
120
+ e = e.where(n, "<", s);
121
121
  break;
122
122
  case "<":
123
- e = e.where(o, ">=", s);
123
+ e = e.where(n, ">=", s);
124
124
  break;
125
125
  case "<=":
126
- e = e.where(o, ">", s);
126
+ e = e.where(n, ">", s);
127
127
  break;
128
128
  default:
129
- e = e.where(o, "!=", s);
129
+ e = e.where(n, "!=", s);
130
130
  }
131
131
  else
132
- e = e.where(o, g, s);
132
+ e = e.where(n, g, s);
133
133
  else {
134
134
  const { ref: m } = t.dynamic;
135
135
  e = e.where(
@@ -154,7 +154,7 @@ function Ve(t) {
154
154
  const { ref: m } = t.dynamic;
155
155
  r = r.orderBy(m(a.sort.sort_by), a.sort.sort_order);
156
156
  }
157
- const o = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = o.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 = o.map((m) => {
157
+ const n = await r.offset(a.page * a.per_page).limit(a.per_page).selectAll().execute(), s = n.map((m) => m.user_id), l = s.length ? await t.selectFrom("users").selectAll().where("users.tenant_id", "=", e).where("users.linked_to", "in", s).execute() : [], d = n.map((m) => {
158
158
  const w = l.filter(
159
159
  (b) => b.linked_to === m.user_id
160
160
  );
@@ -192,18 +192,18 @@ function qe(t) {
192
192
  }
193
193
  function Ge(t) {
194
194
  return async (e, a, r) => {
195
- const n = {
195
+ const o = {
196
196
  ...r,
197
197
  email_verified: qe(r),
198
198
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
199
199
  };
200
- return r.app_metadata && (n.app_metadata = JSON.stringify(r.app_metadata)), r.user_metadata && (n.user_metadata = JSON.stringify(r.user_metadata)), (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", a).execute()).length === 1;
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;
201
201
  };
202
202
  }
203
203
  function He(t) {
204
- return async (e, a, r, n) => {
205
- const o = { linked_to: null };
206
- return (await t.updateTable("users").set(o).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${n}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
204
+ return async (e, a, r, o) => {
205
+ const n = { linked_to: null };
206
+ return (await t.updateTable("users").set(n).where("users.tenant_id", "=", e).where("users.user_id", "=", `${r}|${o}`).where("users.linked_to", "=", `${a}`).execute()).length === 1;
207
207
  };
208
208
  }
209
209
  function Xe(t) {
@@ -253,14 +253,14 @@ function tt(t) {
253
253
  a = a.orderBy(l(e.sort.sort_by), e.sort.sort_order);
254
254
  }
255
255
  e.q && (a = a.where((l) => l.or([l("name", "like", `%${e.q}%`)])));
256
- const n = await a.offset(e.page * e.per_page).limit(e.per_page).selectAll().execute();
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
- tenants: n
259
+ tenants: o
260
260
  };
261
- const { count: o } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(o);
261
+ const { count: n } = await a.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow(), s = x(n);
262
262
  return {
263
- tenants: n.map(_),
263
+ tenants: o.map(_),
264
264
  start: (e.page - 1) * e.per_page,
265
265
  limit: e.per_page,
266
266
  length: s
@@ -295,7 +295,7 @@ function ue(t) {
295
295
  const ot = 1024;
296
296
  function st(t) {
297
297
  return async (e, a) => {
298
- var n, o, s;
298
+ var o, n, s;
299
299
  const r = {
300
300
  id: k(),
301
301
  ...a,
@@ -304,10 +304,10 @@ function st(t) {
304
304
  return await t.insertInto("logs").values({
305
305
  ...r,
306
306
  // Truncate long strings to avoid database errors
307
- description: (n = r.description) == null ? void 0 : n.substring(0, 256),
307
+ description: (o = r.description) == null ? void 0 : o.substring(0, 256),
308
308
  isMobile: a.isMobile ? 1 : 0,
309
309
  tenant_id: e,
310
- scope: (o = a.scope) == null ? void 0 : o.join(","),
310
+ scope: (n = a.scope) == null ? void 0 : n.join(","),
311
311
  auth0_client: ue(a.auth0_client),
312
312
  details: (s = ue(a.details)) == null ? void 0 : s.substring(0, 8192)
313
313
  }).execute(), r;
@@ -343,18 +343,18 @@ function it(t) {
343
343
  }) => {
344
344
  let r = t.selectFrom("logs").where("logs.tenant_id", "=", e);
345
345
  a.q && (r = O(t, r, a.q, ["user_id", "ip"]));
346
- let n = r;
346
+ let o = r;
347
347
  if (a.sort && a.sort.sort_by) {
348
348
  const { ref: l } = t.dynamic;
349
- n = n.orderBy(
349
+ o = o.orderBy(
350
350
  l(a.sort.sort_by),
351
351
  a.sort.sort_order
352
352
  );
353
353
  }
354
- n = n.offset(a.page * a.per_page).limit(a.per_page);
355
- const o = await n.selectAll().execute(), { count: s } = await r.select((l) => l.fn.countAll().as("count")).executeTakeFirstOrThrow();
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();
356
356
  return {
357
- logs: o.map(pe),
357
+ logs: n.map(pe),
358
358
  start: a.page * a.per_page,
359
359
  limit: a.per_page,
360
360
  length: x(s)
@@ -379,10 +379,10 @@ function lt(t) {
379
379
  const r = await t.selectFrom("sessions").where("sessions.tenant_id", "=", e).where("sessions.id", "=", a).selectAll().executeTakeFirst();
380
380
  if (!r)
381
381
  return null;
382
- const { tenant_id: n, device: o, clients: s, ...l } = r;
382
+ const { tenant_id: o, device: n, clients: s, ...l } = r;
383
383
  return {
384
384
  ...l,
385
- device: JSON.parse(o),
385
+ device: JSON.parse(n),
386
386
  clients: JSON.parse(s)
387
387
  };
388
388
  };
@@ -409,13 +409,13 @@ function mt(t) {
409
409
  }
410
410
  function ht(t) {
411
411
  return async (e, a, r) => {
412
- const n = {
412
+ const o = {
413
413
  ...r,
414
414
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
415
415
  device: r.device ? JSON.stringify(r.device) : void 0,
416
416
  clients: r.clients ? JSON.stringify(r.clients) : void 0
417
417
  };
418
- return !!(await t.updateTable("sessions").set(n).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
418
+ return !!(await t.updateTable("sessions").set(o).where("tenant_id", "=", e).where("sessions.id", "=", a).execute()).length;
419
419
  };
420
420
  }
421
421
  function _t(t) {
@@ -426,18 +426,18 @@ function _t(t) {
426
426
  }) => {
427
427
  let r = t.selectFrom("sessions").where("sessions.tenant_id", "=", e);
428
428
  a.q && (r = O(t, r, a.q, ["user_id", "session_id"]));
429
- let n = r;
429
+ let o = r;
430
430
  if (a.sort && a.sort.sort_by) {
431
431
  const { ref: d } = t.dynamic;
432
- n = n.orderBy(
432
+ o = o.orderBy(
433
433
  d(a.sort.sort_by),
434
434
  a.sort.sort_order
435
435
  );
436
436
  }
437
- n = n.offset(a.page * a.per_page).limit(a.per_page);
438
- const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
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((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
439
439
  return {
440
- sessions: o.map((d) => ({
440
+ sessions: n.map((d) => ({
441
441
  ...d,
442
442
  device: JSON.parse(d.device),
443
443
  clients: JSON.parse(d.clients)
@@ -462,8 +462,8 @@ function pt(t) {
462
462
  const r = await t.selectFrom("passwords").where("passwords.tenant_id", "=", e).where("passwords.user_id", "=", a).selectAll().executeTakeFirst();
463
463
  if (!r)
464
464
  return null;
465
- const { tenant_id: n, ...o } = r;
466
- return o;
465
+ const { tenant_id: o, ...n } = r;
466
+ return n;
467
467
  };
468
468
  }
469
469
  function gt(t) {
@@ -500,9 +500,9 @@ function vt(t) {
500
500
  }) => {
501
501
  let r = t.selectFrom("codes").where("codes.tenant_id", "=", e);
502
502
  a.q && (r = O(t, r, a.q, ["code", "login_id"]));
503
- const o = 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();
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: o.map((d) => {
505
+ codes: n.map((d) => {
506
506
  const { tenant_id: g, ...m } = d;
507
507
  return Je.parse(_(m));
508
508
  }),
@@ -529,10 +529,10 @@ function Ct(t) {
529
529
  }
530
530
  function bt(t) {
531
531
  return async (e, a, r) => {
532
- let n = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
533
- e.length && (n = n.where("codes.tenant_id", "=", e));
534
- const o = await n.selectAll().executeTakeFirst();
535
- return o ? _(o) : null;
532
+ let o = t.selectFrom("codes").where("codes.code_id", "=", a).where("codes.code_type", "=", r);
533
+ e.length && (o = o.where("codes.tenant_id", "=", e));
534
+ const n = await o.selectAll().executeTakeFirst();
535
+ return n ? _(n) : null;
536
536
  };
537
537
  }
538
538
  function xt(t) {
@@ -553,14 +553,14 @@ function St(t) {
553
553
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
554
554
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
555
555
  ...a
556
- }, n = JSON.stringify(a.allowed_origins), o = JSON.stringify(a.callbacks), s = JSON.stringify(a.web_origins), l = JSON.stringify(a.allowed_logout_urls), d = 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,
560
560
  disable_sign_ups: a.disable_sign_ups ? 1 : 0,
561
561
  addons: a.addons ? JSON.stringify(a.addons) : "{}",
562
- callbacks: o,
563
- allowed_origins: n,
562
+ callbacks: n,
563
+ allowed_origins: o,
564
564
  web_origins: s,
565
565
  allowed_logout_urls: l,
566
566
  allowed_clients: d
@@ -569,15 +569,15 @@ function St(t) {
569
569
  }
570
570
  function Ot(t) {
571
571
  return async (e) => ({
572
- applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((o) => ({
573
- ...o,
574
- disable_sign_ups: !!o.disable_sign_ups,
575
- addons: o.addons ? JSON.parse(o.addons) : {},
576
- callbacks: o.callbacks ? JSON.parse(o.callbacks) : [],
577
- allowed_origins: o.allowed_origins ? JSON.parse(o.allowed_origins) : [],
578
- web_origins: o.web_origins ? JSON.parse(o.web_origins) : [],
579
- allowed_logout_urls: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : [],
580
- allowed_clients: o.allowed_logout_urls ? JSON.parse(o.allowed_logout_urls) : []
572
+ applications: (await t.selectFrom("applications").where("applications.tenant_id", "=", e).selectAll().execute()).map((n) => ({
573
+ ...n,
574
+ disable_sign_ups: !!n.disable_sign_ups,
575
+ addons: n.addons ? JSON.parse(n.addons) : {},
576
+ callbacks: n.callbacks ? JSON.parse(n.callbacks) : [],
577
+ allowed_origins: n.allowed_origins ? JSON.parse(n.allowed_origins) : [],
578
+ web_origins: n.web_origins ? JSON.parse(n.web_origins) : [],
579
+ allowed_logout_urls: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : [],
580
+ allowed_clients: n.allowed_logout_urls ? JSON.parse(n.allowed_logout_urls) : []
581
581
  }))
582
582
  });
583
583
  }
@@ -600,7 +600,7 @@ function $t(t) {
600
600
  }
601
601
  function Dt(t) {
602
602
  return async (e, a, r) => {
603
- const n = {
603
+ const o = {
604
604
  ...r,
605
605
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
606
606
  allowed_origins: r.allowed_origins ? JSON.stringify(r.allowed_origins) : void 0,
@@ -611,7 +611,7 @@ function Dt(t) {
611
611
  addons: r.addons ? JSON.stringify(r.addons) : "{}",
612
612
  disable_sign_ups: r.disable_sign_ups ? 1 : 0
613
613
  };
614
- return await t.updateTable("applications").set(n).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
614
+ return await t.updateTable("applications").set(o).where("applications.id", "=", a).where("applications.tenant_id", "=", e).execute(), !0;
615
615
  };
616
616
  }
617
617
  function It(t) {
@@ -675,13 +675,13 @@ function Ft(t) {
675
675
  }
676
676
  function At(t) {
677
677
  return async (e, a, r) => {
678
- const n = {
678
+ const o = {
679
679
  ...r,
680
680
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
681
681
  };
682
682
  return await t.updateTable("connections").set({
683
- ...n,
684
- options: n.options ? JSON.stringify(n.options) : void 0
683
+ ...o,
684
+ options: o.options ? JSON.stringify(o.options) : void 0
685
685
  }).where("connections.id", "=", a).where("connections.tenant_id", "=", e).execute(), !0;
686
686
  };
687
687
  }
@@ -703,10 +703,10 @@ function zt(t) {
703
703
  const r = await t.selectFrom("tenants").selectAll().where("id", "=", a.tenant_id).executeTakeFirst();
704
704
  if (!r)
705
705
  throw new V(404, { message: "Tenant not found" });
706
- const n = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
706
+ const o = await t.selectFrom("connections").where("tenant_id", "=", a.tenant_id).selectAll().execute();
707
707
  return {
708
708
  ...a,
709
- connections: n.map(
709
+ connections: o.map(
710
710
  (s) => Ke.parse(
711
711
  _({
712
712
  ...s,
@@ -787,12 +787,12 @@ function Vt(t) {
787
787
  }
788
788
  function Wt(t) {
789
789
  return async (e, a, r) => {
790
- const n = {
790
+ const o = {
791
791
  ...r,
792
792
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
793
793
  primary: r.primary ? 1 : 0
794
794
  };
795
- return (await t.updateTable("custom_domains").set(n).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
795
+ return (await t.updateTable("custom_domains").set(o).where("custom_domains.tenant_id", "=", e).where("custom_domains.custom_domain_id", "=", a).execute()).length > 0;
796
796
  };
797
797
  }
798
798
  function qt(t) {
@@ -811,8 +811,8 @@ function Gt(t) {
811
811
  return null;
812
812
  const {
813
813
  tenant_id: r,
814
- colors_primary: n,
815
- colors_page_background_type: o,
814
+ colors_primary: o,
815
+ colors_page_background_type: n,
816
816
  colors_page_background_start: s,
817
817
  colors_page_background_end: l,
818
818
  colors_page_background_angle_dev: d,
@@ -822,9 +822,9 @@ function Gt(t) {
822
822
  return _({
823
823
  ...m,
824
824
  colors: {
825
- primary: n,
825
+ primary: o,
826
826
  page_background: {
827
- type: o,
827
+ type: n,
828
828
  start: s,
829
829
  end: l,
830
830
  angle_deg: d
@@ -837,10 +837,10 @@ function Gt(t) {
837
837
  function Ht(t) {
838
838
  return async (e, a) => {
839
839
  var s, l, d, g, m, w, b, Z, ee, te, ae, re, ne, oe, se, ie, de, ce;
840
- const { colors: r, font: n, ...o } = a;
840
+ const { colors: r, font: o, ...n } = a;
841
841
  try {
842
842
  await t.insertInto("branding").values({
843
- ...o,
843
+ ...n,
844
844
  colors_primary: r == null ? void 0 : r.primary,
845
845
  colors_page_background_type: (l = (s = a.colors) == null ? void 0 : s.page_background) == null ? void 0 : l.type,
846
846
  colors_page_background_start: (g = (d = a.colors) == null ? void 0 : d.page_background) == null ? void 0 : g.start,
@@ -851,7 +851,7 @@ function Ht(t) {
851
851
  }).execute();
852
852
  } catch {
853
853
  await t.updateTable("branding").set({
854
- ...o,
854
+ ...n,
855
855
  colors_primary: r == null ? void 0 : r.primary,
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,
@@ -876,9 +876,9 @@ 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 o = 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();
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: o.map((d) => {
881
+ hooks: n.map((d) => {
882
882
  const { tenant_id: g, enabled: m, synchronous: w, ...b } = d;
883
883
  return _({
884
884
  ...b,
@@ -923,13 +923,13 @@ function ta(t) {
923
923
  }
924
924
  function aa(t) {
925
925
  return async (e, a, r) => {
926
- const n = {
926
+ const o = {
927
927
  ...r,
928
928
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
929
929
  enabled: r.enabled !== void 0 ? r.enabled ? 1 : 0 : void 0,
930
930
  synchronous: r.enabled !== void 0 ? r.synchronous ? 1 : 0 : void 0
931
931
  };
932
- return await t.updateTable("hooks").set(n).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
932
+ return await t.updateTable("hooks").set(o).where("hooks.hook_id", "=", a).where("hooks.tenant_id", "=", e).execute(), !0;
933
933
  };
934
934
  }
935
935
  function ra(t) {
@@ -944,24 +944,24 @@ function ra(t) {
944
944
  function E(t, e = "", a = {}) {
945
945
  for (let r in t)
946
946
  if (Object.prototype.hasOwnProperty.call(t, r)) {
947
- const n = e ? `${e}_${r}` : r;
948
- typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? E(t[r], n, a) : a[n] = t[r];
947
+ const o = e ? `${e}_${r}` : r;
948
+ typeof t[r] == "object" && t[r] !== null && !Array.isArray(t[r]) ? E(t[r], o, a) : a[o] = t[r];
949
949
  }
950
950
  return a;
951
951
  }
952
952
  function na(t, e) {
953
953
  const a = {};
954
- for (const [r, n] of Object.entries(t)) {
955
- const o = e.find(
954
+ for (const [r, o] of Object.entries(t)) {
955
+ const n = e.find(
956
956
  (s) => r.startsWith(`${s}_`)
957
957
  );
958
- if (!o)
959
- a[r] = n;
958
+ if (!n)
959
+ a[r] = o;
960
960
  else {
961
- const s = r.slice(o.length + 1);
962
- a[o] = {
963
- ...a[o],
964
- [s]: n
961
+ const s = r.slice(n.length + 1);
962
+ a[n] = {
963
+ ...a[n],
964
+ [s]: o
965
965
  };
966
966
  }
967
967
  }
@@ -989,11 +989,11 @@ function ia(t) {
989
989
  }
990
990
  function da(t) {
991
991
  return async (e, a, r) => {
992
- const n = E({
992
+ const o = E({
993
993
  ...r,
994
994
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
995
995
  });
996
- return await t.updateTable("themes").set(n).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
996
+ return await t.updateTable("themes").set(o).where("themes.id", "=", a).where("themes.tenant_id", "=", e).execute(), !0;
997
997
  };
998
998
  }
999
999
  function ca(t) {
@@ -1006,19 +1006,19 @@ function ca(t) {
1006
1006
  }
1007
1007
  function la(t) {
1008
1008
  return async (e, a) => {
1009
- const r = (/* @__PURE__ */ new Date()).toISOString(), n = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1010
- return n ? Re.parse(
1011
- na(_(n), ["authParams"])
1009
+ const r = (/* @__PURE__ */ new Date()).toISOString(), o = await t.selectFrom("login_sessions").where("login_sessions.expires_at", ">", r).where("login_sessions.id", "=", a).selectAll().executeTakeFirst();
1010
+ return o ? Re.parse(
1011
+ na(_(o), ["authParams"])
1012
1012
  ) : null;
1013
1013
  };
1014
1014
  }
1015
1015
  function ua(t) {
1016
1016
  return async (e, a) => {
1017
- var n;
1017
+ var o;
1018
1018
  const r = {
1019
1019
  id: k(),
1020
1020
  ...a,
1021
- authorization_url: (n = a.authorization_url) == null ? void 0 : n.slice(0, 1024),
1021
+ authorization_url: (o = a.authorization_url) == null ? void 0 : o.slice(0, 1024),
1022
1022
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1023
1023
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
1024
1024
  };
@@ -1085,38 +1085,38 @@ function ya(t) {
1085
1085
  return null;
1086
1086
  const {
1087
1087
  tenant_id: r,
1088
- credentials: n,
1089
- settings: o,
1088
+ credentials: o,
1089
+ settings: n,
1090
1090
  enabled: s,
1091
1091
  ...l
1092
1092
  } = a;
1093
1093
  return _({
1094
1094
  ...l,
1095
- credentials: JSON.parse(n),
1096
- settings: JSON.parse(o),
1095
+ credentials: JSON.parse(o),
1096
+ settings: JSON.parse(n),
1097
1097
  enabled: !!s
1098
1098
  });
1099
1099
  };
1100
1100
  }
1101
1101
  function wa(t) {
1102
1102
  return async (e, a) => {
1103
- const { credentials: r, settings: n, enabled: o, ...s } = a;
1103
+ const { credentials: r, settings: o, enabled: n, ...s } = a;
1104
1104
  await t.updateTable("email_providers").set({
1105
1105
  ...s,
1106
1106
  credentials: r ? JSON.stringify(r) : void 0,
1107
- settings: n ? JSON.stringify(n) : void 0,
1108
- enabled: o !== void 0 ? o ? 1 : 0 : void 0
1107
+ settings: o ? JSON.stringify(o) : void 0,
1108
+ enabled: n !== void 0 ? n ? 1 : 0 : void 0
1109
1109
  }).where("tenant_id", "=", e).execute();
1110
1110
  };
1111
1111
  }
1112
1112
  function va(t) {
1113
1113
  return async (e, a) => {
1114
- const { credentials: r, settings: n, enabled: o, ...s } = a;
1114
+ const { credentials: r, settings: o, enabled: n, ...s } = a;
1115
1115
  await t.insertInto("email_providers").values({
1116
1116
  ...s,
1117
- enabled: o ? 1 : 0,
1117
+ enabled: n ? 1 : 0,
1118
1118
  credentials: JSON.stringify(r),
1119
- settings: JSON.stringify(n),
1119
+ settings: JSON.stringify(o),
1120
1120
  tenant_id: e,
1121
1121
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
1122
1122
  updated_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -1161,13 +1161,13 @@ function xa(t) {
1161
1161
  }
1162
1162
  function Ta(t) {
1163
1163
  return async (e, a, r) => {
1164
- const n = {
1164
+ const o = {
1165
1165
  ...r,
1166
1166
  device: r.device ? JSON.stringify(r.device) : void 0,
1167
1167
  resource_servers: r.resource_servers ? JSON.stringify(r.resource_servers) : void 0,
1168
1168
  rotating: r.rotating ? 1 : 0
1169
1169
  };
1170
- return !!(await t.updateTable("refresh_tokens").set(n).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1170
+ return !!(await t.updateTable("refresh_tokens").set(o).where("tenant_id", "=", e).where("refresh_tokens.id", "=", a).execute()).length;
1171
1171
  };
1172
1172
  }
1173
1173
  function Sa(t) {
@@ -1178,18 +1178,18 @@ function Sa(t) {
1178
1178
  }) => {
1179
1179
  let r = t.selectFrom("refresh_tokens").where("refresh_tokens.tenant_id", "=", e);
1180
1180
  a.q && (r = O(t, r, a.q, ["token", "session_id"]));
1181
- let n = r;
1181
+ let o = r;
1182
1182
  if (a.sort && a.sort.sort_by) {
1183
1183
  const { ref: d } = t.dynamic;
1184
- n = n.orderBy(
1184
+ o = o.orderBy(
1185
1185
  d(a.sort.sort_by),
1186
1186
  a.sort.sort_order
1187
1187
  );
1188
1188
  }
1189
- n = n.offset(a.page * a.per_page).limit(a.per_page);
1190
- const o = await n.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1189
+ o = o.offset(a.page * a.per_page).limit(a.per_page);
1190
+ const n = await o.selectAll().execute(), { count: s } = await r.select((d) => d.fn.countAll().as("count")).executeTakeFirstOrThrow(), l = x(s);
1191
1191
  return {
1192
- refresh_tokens: o.map((d) => ({
1192
+ refresh_tokens: n.map((d) => ({
1193
1193
  ...d,
1194
1194
  rotating: !!d.rotating,
1195
1195
  device: d.device ? JSON.parse(d.device) : {},
@@ -1217,19 +1217,22 @@ function ka(t) {
1217
1217
  ).toISOString(), r = new Date(
1218
1218
  Date.now() - 1e3 * 60 * 60 * 24 * 30 * 3
1219
1219
  ).toISOString();
1220
- await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), await t.deleteFrom("logs").where("date", "<", r).limit(1e5).execute(), await t.deleteFrom("refresh_tokens").where("expires_at", "<", a).limit(1e5).execute(), await t.deleteFrom("sessions").where(
1221
- (n) => n.and([
1222
- n.or([
1223
- n("sessions.expires_at", "<", a),
1224
- n("sessions.idle_expires_at", "<", a)
1225
- ]),
1226
- n(
1227
- "sessions.id",
1228
- "not in",
1229
- t.selectFrom("refresh_tokens").select("session_id")
1230
- )
1220
+ console.log("delete codes"), await t.deleteFrom("codes").where("created_at", "<", e).limit(1e5).execute(), console.log("delete sessions"), await t.deleteFrom("login_sessions").where("created_at", "<", a).where("session_id", "is", null).limit(1e5).execute(), console.log("delete logs"), await t.deleteFrom("logs").where("date", "<", r).limit(1e5).execute(), console.log("delete refresh tokens"), await t.deleteFrom("refresh_tokens").where("expires_at", "<", a).limit(1e5).execute(), console.log("delete sessions");
1221
+ const o = await t.selectFrom("sessions").select("id").where(
1222
+ (n) => n.or([
1223
+ n("expires_at", "<", a),
1224
+ n("idle_expires_at", "<", a)
1231
1225
  ])
1226
+ ).where(
1227
+ "id",
1228
+ "not in",
1229
+ t.selectFrom("refresh_tokens").select("session_id")
1232
1230
  ).limit(1e5).execute();
1231
+ o.length > 0 && await t.deleteFrom("sessions").where(
1232
+ "id",
1233
+ "in",
1234
+ o.map((n) => n.id)
1235
+ ).execute(), console.log("cleanup complete");
1233
1236
  };
1234
1237
  }
1235
1238
  function $a(t) {
@@ -2163,15 +2166,15 @@ class ja extends Ia {
2163
2166
  const r = u(this, f, we).call(this, a);
2164
2167
  for (const s of r)
2165
2168
  c(this, S).add(s);
2166
- const n = u(this, f, ye).call(this, a);
2167
- for (const s of n)
2169
+ const o = u(this, f, ye).call(this, a);
2170
+ for (const s of o)
2168
2171
  c(this, T).add(s);
2169
- const o = super.transformNodeImpl(a);
2170
- for (const s of n)
2172
+ const n = super.transformNodeImpl(a);
2173
+ for (const s of o)
2171
2174
  c(this, T).delete(s);
2172
2175
  for (const s of r)
2173
2176
  c(this, S).delete(s);
2174
- return o;
2177
+ return n;
2175
2178
  }
2176
2179
  transformSchemableIdentifier(a) {
2177
2180
  const r = super.transformSchemableIdentifier(a);
@@ -2193,25 +2196,25 @@ P = new WeakMap(), T = new WeakMap(), S = new WeakMap(), f = new WeakSet(), ge =
2193
2196
  }, ye = function(a) {
2194
2197
  const r = /* @__PURE__ */ new Set();
2195
2198
  if ("name" in a && a.name && W.is(a.name) && u(this, f, q).call(this, a.name, r), "from" in a && a.from)
2196
- for (const n of a.from.froms)
2197
- u(this, f, $).call(this, n, r);
2199
+ for (const o of a.from.froms)
2200
+ u(this, f, $).call(this, o, r);
2198
2201
  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)
2199
- for (const n of a.joins)
2200
- u(this, f, $).call(this, n.table, r);
2202
+ for (const o of a.joins)
2203
+ u(this, f, $).call(this, o.table, r);
2201
2204
  return "using" in a && a.using && u(this, f, $).call(this, a.using, r), r;
2202
2205
  }, we = function(a) {
2203
2206
  const r = /* @__PURE__ */ new Set();
2204
2207
  return "with" in a && a.with && u(this, f, ve).call(this, a.with, r), r;
2205
2208
  }, $ = function(a, r) {
2206
- const n = U.is(a) ? a : Da.is(a) && U.is(a.node) ? a.node : null;
2207
- n && u(this, f, q).call(this, n.table, r);
2209
+ const o = U.is(a) ? a : Da.is(a) && U.is(a.node) ? a.node : null;
2210
+ o && u(this, f, q).call(this, o.table, r);
2208
2211
  }, q = function(a, r) {
2209
- const n = a.identifier.name;
2210
- !c(this, T).has(n) && !c(this, S).has(n) && r.add(n);
2212
+ const o = a.identifier.name;
2213
+ !c(this, T).has(o) && !c(this, S).has(o) && r.add(o);
2211
2214
  }, ve = function(a, r) {
2212
- for (const n of a.expressions) {
2213
- const o = n.name.table.table.identifier.name;
2214
- c(this, S).has(o) || r.add(o);
2215
+ for (const o of a.expressions) {
2216
+ const n = o.name.table.table.identifier.name;
2217
+ c(this, S).has(n) || r.add(n);
2215
2218
  }
2216
2219
  };
2217
2220
  var L;
@@ -2251,12 +2254,12 @@ class Ne {
2251
2254
  */
2252
2255
  async getMigrations() {
2253
2256
  const e = await u(this, i, I).call(this, c(this, i, N)) ? await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select(["name", "timestamp"]).execute() : [];
2254
- return (await u(this, i, X).call(this)).map(({ name: r, ...n }) => {
2255
- const o = e.find((s) => s.name === r);
2257
+ return (await u(this, i, X).call(this)).map(({ name: r, ...o }) => {
2258
+ const n = e.find((s) => s.name === r);
2256
2259
  return {
2257
2260
  name: r,
2258
- migration: n,
2259
- executedAt: o ? new Date(o.timestamp) : void 0
2261
+ migration: o,
2262
+ executedAt: n ? new Date(n.timestamp) : void 0
2260
2263
  };
2261
2264
  });
2262
2265
  }
@@ -2334,16 +2337,16 @@ class Ne {
2334
2337
  * ```
2335
2338
  */
2336
2339
  async migrateTo(e) {
2337
- return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: n }) => {
2340
+ return u(this, i, F).call(this, ({ migrations: a, executedMigrations: r, pendingMigrations: o }) => {
2338
2341
  if (e === za)
2339
2342
  return { direction: "Down", step: 1 / 0 };
2340
2343
  if (!a.find((l) => l.name === e))
2341
2344
  throw new Error(`migration "${e}" doesn't exist`);
2342
- const o = r.indexOf(e), s = n.findIndex((l) => l.name === e);
2343
- if (o !== -1)
2345
+ const n = r.indexOf(e), s = o.findIndex((l) => l.name === e);
2346
+ if (n !== -1)
2344
2347
  return {
2345
2348
  direction: "Down",
2346
- step: r.length - o - 1
2349
+ step: r.length - n - 1
2347
2350
  };
2348
2351
  if (s !== -1)
2349
2352
  return { direction: "Up", step: s + 1 };
@@ -2441,7 +2444,7 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2441
2444
  const a = c(this, i, v);
2442
2445
  return (await c(this, h).db.introspection.getTables({
2443
2446
  withInternalKyselyTables: !0
2444
- })).some((n) => n.name === e && (!a || n.schema === a));
2447
+ })).some((o) => o.name === e && (!a || o.schema === a));
2445
2448
  }, H = async function() {
2446
2449
  return !!await c(this, h).db.withPlugin(c(this, i, C)).selectFrom(c(this, i, D)).where("id", "=", B).select("id").executeTakeFirst();
2447
2450
  }, ke = async function(e) {
@@ -2449,28 +2452,28 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2449
2452
  lockTable: c(this, h).migrationLockTableName ?? _e,
2450
2453
  lockRowId: B,
2451
2454
  lockTableSchema: c(this, h).migrationTableSchema
2452
- }), n = async (o) => {
2455
+ }), o = async (n) => {
2453
2456
  try {
2454
- await a.acquireMigrationLock(o, r);
2455
- const s = await u(this, i, $e).call(this, o);
2457
+ await a.acquireMigrationLock(n, r);
2458
+ const s = await u(this, i, $e).call(this, n);
2456
2459
  if (s.migrations.length === 0)
2457
2460
  return { results: [] };
2458
2461
  const { direction: l, step: d } = e(s);
2459
- return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, o, s, d) : l === "Up" ? await u(this, i, Fe).call(this, o, s, d) : { results: [] };
2462
+ return d <= 0 ? { results: [] } : l === "Down" ? await u(this, i, Me).call(this, n, s, d) : l === "Up" ? await u(this, i, Fe).call(this, n, s, d) : { results: [] };
2460
2463
  } finally {
2461
- await a.releaseMigrationLock(o, r);
2464
+ await a.releaseMigrationLock(n, r);
2462
2465
  }
2463
2466
  };
2464
- return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(n) : c(this, h).db.connection().execute(n);
2467
+ return a.supportsTransactionalDdl ? c(this, h).db.transaction().execute(o) : c(this, h).db.connection().execute(o);
2465
2468
  }, $e = async function(e) {
2466
2469
  const a = await u(this, i, X).call(this), r = await u(this, i, Ie).call(this, e);
2467
2470
  u(this, i, Pe).call(this, a, r), c(this, i, Ce) || u(this, i, je).call(this, a, r);
2468
- const n = u(this, i, De).call(this, a, r);
2471
+ const o = u(this, i, De).call(this, a, r);
2469
2472
  return p({
2470
2473
  migrations: a,
2471
2474
  executedMigrations: r,
2472
2475
  lastMigration: $a(r),
2473
- pendingMigrations: n
2476
+ pendingMigrations: o
2474
2477
  });
2475
2478
  }, De = function(e, a) {
2476
2479
  return e.filter((r) => !a.includes(r.name));
@@ -2484,67 +2487,67 @@ h = new WeakMap(), i = new WeakSet(), F = async function(e) {
2484
2487
  return (await e.withPlugin(c(this, i, C)).selectFrom(c(this, i, N)).select("name").orderBy(["timestamp", "name"]).execute()).map((r) => r.name);
2485
2488
  }, Pe = function(e, a) {
2486
2489
  for (const r of a)
2487
- if (!e.some((n) => n.name === r))
2490
+ if (!e.some((o) => o.name === r))
2488
2491
  throw new Error(`corrupted migrations: previously executed migration ${r} is missing`);
2489
2492
  }, je = function(e, a) {
2490
2493
  for (let r = 0; r < a.length; ++r)
2491
2494
  if (e[r].name !== a[r])
2492
2495
  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.`);
2493
2496
  }, Me = async function(e, a, r) {
2494
- const n = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), o = n.map((s) => ({
2497
+ const o = a.executedMigrations.slice().reverse().slice(0, r).map((s) => a.migrations.find((l) => l.name === s)), n = o.map((s) => ({
2495
2498
  migrationName: s.name,
2496
2499
  direction: "Down",
2497
2500
  status: "NotExecuted"
2498
2501
  }));
2499
- for (let s = 0; s < o.length; ++s) {
2500
- const l = n[s];
2502
+ for (let s = 0; s < n.length; ++s) {
2503
+ const l = o[s];
2501
2504
  try {
2502
- l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", l.name).execute(), o[s] = {
2505
+ l.down && (await l.down(e), await e.withPlugin(c(this, i, C)).deleteFrom(c(this, i, N)).where("name", "=", l.name).execute(), n[s] = {
2503
2506
  migrationName: l.name,
2504
2507
  direction: "Down",
2505
2508
  status: "Success"
2506
2509
  });
2507
2510
  } catch (d) {
2508
- throw o[s] = {
2511
+ throw n[s] = {
2509
2512
  migrationName: l.name,
2510
2513
  direction: "Down",
2511
2514
  status: "Error"
2512
2515
  }, new Q({
2513
2516
  error: d,
2514
- results: o
2517
+ results: n
2515
2518
  });
2516
2519
  }
2517
2520
  }
2518
- return { results: o };
2521
+ return { results: n };
2519
2522
  }, Fe = async function(e, a, r) {
2520
- const o = a.pendingMigrations.slice(0, r).map((s) => ({
2523
+ const n = a.pendingMigrations.slice(0, r).map((s) => ({
2521
2524
  migrationName: s.name,
2522
2525
  direction: "Up",
2523
2526
  status: "NotExecuted"
2524
2527
  }));
2525
- for (let s = 0; s < o.length; s++) {
2528
+ for (let s = 0; s < n.length; s++) {
2526
2529
  const l = a.pendingMigrations[s];
2527
2530
  try {
2528
2531
  await l.up(e), await e.withPlugin(c(this, i, C)).insertInto(c(this, i, N)).values({
2529
2532
  name: l.name,
2530
2533
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
2531
- }).execute(), o[s] = {
2534
+ }).execute(), n[s] = {
2532
2535
  migrationName: l.name,
2533
2536
  direction: "Up",
2534
2537
  status: "Success"
2535
2538
  };
2536
2539
  } catch (d) {
2537
- throw o[s] = {
2540
+ throw n[s] = {
2538
2541
  migrationName: l.name,
2539
2542
  direction: "Up",
2540
2543
  status: "Error"
2541
2544
  }, new Q({
2542
2545
  error: d,
2543
- results: o
2546
+ results: n
2544
2547
  });
2545
2548
  }
2546
2549
  }
2547
- return { results: o };
2550
+ return { results: n };
2548
2551
  }, A = async function(e) {
2549
2552
  c(this, h).db.getExecutor().adapter.supportsCreateIfNotExists && (e = e.ifNotExists()), await e.execute();
2550
2553
  };
@@ -3667,6 +3670,24 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3667
3670
  __proto__: null,
3668
3671
  down: ri,
3669
3672
  up: ai
3673
+ }, Symbol.toStringTag, { value: "Module" }));
3674
+ async function oi(t) {
3675
+ await t.schema.dropTable("custom_domains").execute(), await t.schema.createTable("custom_domains").addColumn(
3676
+ "custom_domain_id",
3677
+ "varchar(256)",
3678
+ (e) => e.notNull().primaryKey()
3679
+ ).addColumn(
3680
+ "tenant_id",
3681
+ "varchar(255)",
3682
+ (e) => e.references("tenants.id").onDelete("cascade").notNull()
3683
+ ).addColumn("domain", "varchar(255)", (e) => e.notNull()).addColumn("primary", "boolean", (e) => e.notNull()).addColumn("status", "varchar(50)", (e) => e.notNull()).addColumn("type", "varchar(50)", (e) => e.notNull()).addColumn("origin_domain_name", "varchar(255)").addColumn("verification", "varchar(2048)").addColumn("custom_client_ip_header", "varchar(50)").addColumn("tls_policy", "varchar(50)").addColumn("domain_metadata", "varchar(2048)").addColumn("created_at", "varchar(35)", (e) => e.notNull()).addColumn("updated_at", "varchar(35)", (e) => e.notNull()).execute();
3684
+ }
3685
+ async function si(t) {
3686
+ }
3687
+ const ii = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3688
+ __proto__: null,
3689
+ down: si,
3690
+ up: oi
3670
3691
  }, Symbol.toStringTag, { value: "Module" })), Le = {
3671
3692
  m1_init: Ka,
3672
3693
  m2_magicLink: Ba,
@@ -3745,33 +3766,34 @@ const ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3745
3766
  n76_authorization_url_length: Gs,
3746
3767
  n77_drop_sessions: Ys,
3747
3768
  n78_login_sessions: ti,
3748
- n79_drop_sessions_2: ni
3769
+ n79_drop_sessions_2: ni,
3770
+ n80_recreate_custom_domains: ii
3749
3771
  };
3750
- async function ci(t, e = !1) {
3772
+ async function mi(t, e = !1) {
3751
3773
  e && console.log("migrating...");
3752
3774
  const a = new Ae(Le), r = new Ne({
3753
3775
  db: t,
3754
3776
  provider: a
3755
- }), { error: n, results: o } = await r.migrateToLatest();
3756
- if (o == null || o.forEach((s) => {
3777
+ }), { error: o, results: n } = await r.migrateToLatest();
3778
+ if (n == null || n.forEach((s) => {
3757
3779
  s.status === "Success" ? e && console.log(
3758
3780
  `migration "${s.migrationName}" was executed successfully`
3759
3781
  ) : s.status === "Error" && console.error(`failed to execute migration "${s.migrationName}"`);
3760
- }), n)
3761
- throw console.error("failed to migrate"), console.error(n), n;
3782
+ }), o)
3783
+ throw console.error("failed to migrate"), console.error(o), o;
3762
3784
  }
3763
- async function li(t) {
3785
+ async function hi(t) {
3764
3786
  console.log("migrating...");
3765
3787
  const e = new Ae(Le), a = new Ne({
3766
3788
  db: t,
3767
3789
  provider: e
3768
- }), { error: r, results: n } = await a.migrateDown();
3769
- if (n == null || n.forEach((o) => {
3770
- o.status === "Success" ? console.log(`migration "${o.migrationName}" was reverted successfully`) : o.status === "Error" && console.error(`failed to execute migration "${o.migrationName}"`);
3790
+ }), { error: r, results: o } = await a.migrateDown();
3791
+ if (o == null || o.forEach((n) => {
3792
+ n.status === "Success" ? console.log(`migration "${n.migrationName}" was reverted successfully`) : n.status === "Error" && console.error(`failed to execute migration "${n.migrationName}"`);
3771
3793
  }), r)
3772
3794
  throw console.error("failed to migrate"), console.error(r), r;
3773
3795
  }
3774
- function ui(t) {
3796
+ function _i(t) {
3775
3797
  return {
3776
3798
  applications: It(t),
3777
3799
  branding: Xt(t),
@@ -3795,7 +3817,7 @@ function ui(t) {
3795
3817
  };
3796
3818
  }
3797
3819
  export {
3798
- ui as default,
3799
- li as migrateDown,
3800
- ci as migrateToLatest
3820
+ _i as default,
3821
+ hi as migrateDown,
3822
+ mi as migrateToLatest
3801
3823
  };